本文整理汇总了C#中RigidBody.AddForceAtBodyPoint方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.AddForceAtBodyPoint方法的具体用法?C# RigidBody.AddForceAtBodyPoint怎么用?C# RigidBody.AddForceAtBodyPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RigidBody
的用法示例。
在下文中一共展示了RigidBody.AddForceAtBodyPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: updateforcefromtensor
internal void updateforcefromtensor(RigidBody body, float duration, Matrix3 tensor)
{
Vector3 velocity = body.GetVelocity();
velocity += WindSpeed;
Vector3 bodyVel = body.GetTransform().TransformInverseDirection(velocity);
Vector3 bodyForce = tensor.Transform(bodyVel);
Vector3 force = body.GetTransform().TransformDirection(bodyForce);
body.AddForceAtBodyPoint(force, Position);
}