本文整理汇总了C#中RigidBody.GetPointInWorldSpace方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.GetPointInWorldSpace方法的具体用法?C# RigidBody.GetPointInWorldSpace怎么用?C# RigidBody.GetPointInWorldSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RigidBody
的用法示例。
在下文中一共展示了RigidBody.GetPointInWorldSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateForce
public override void UpdateForce(RigidBody body, float duration)
{
Vector3 lws = body.GetPointInWorldSpace(ConnectionPoint);
Vector3 ows = body.GetPointInWorldSpace(OtherConnectionPoint);
Vector3 force = lws - ows;
float magnitude = force.Magnitude;
magnitude = MathHelper.Abs(magnitude - RestLength);
magnitude *= SpringConstant;
force.Normalize();
force *= -magnitude;
body.AddForceAtPoint(force, lws);
}
示例2: UpdateForce
public override void UpdateForce(RigidBody body, float duration)
{
Vector3 pointInWorld = body.GetPointInWorldSpace(CenterOfBuoyancy);
float depth = pointInWorld.Y;
if (depth >= WaterHeight + MaxDepth) return;
Vector3 force = new Vector3(0, 0, 0);
if (depth <= WaterHeight - MaxDepth)
{
force.Y = LiquidDensity * Volume;
body.AddForceAtBodyPoint(force, CenterOfBuoyancy);
return;
}
force.Y = LiquidDensity * Volume * ((depth - MaxDepth - WaterHeight) / 2.0f) * MaxDepth;
body.AddForceAtBodyPoint(force, CenterOfBuoyancy);
}