本文整理汇总了C#中RigidBody.AddForce方法的典型用法代码示例。如果您正苦于以下问题:C# RigidBody.AddForce方法的具体用法?C# RigidBody.AddForce怎么用?C# RigidBody.AddForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RigidBody
的用法示例。
在下文中一共展示了RigidBody.AddForce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateForce
public override void UpdateForce(RigidBody body, float duration)
{
if (body.Mass < 0.0f) return;
body.AddForce(VectorGravity * body.Mass);
}
示例2: UpdateForce
public override void UpdateForce(RigidBody body, float duration)
{
if (body.HasFiniteMass()) return;
body.AddForce(VectorGravity * body.GetMass());
}
示例3: BuildScene
private void BuildScene()
{
// creating two boxShapes with different sizes
Shape boxShape = new BoxShape(JVector.One);
Shape groundShape = new BoxShape(new JVector(10, 1, 10));
// create new instances of the rigid body class and pass
// the boxShapes to them
RigidBody boxBody1 = new RigidBody(boxShape);
RigidBody boxBody2 = new RigidBody(boxShape);
boxBody1.Tag = Color.LightPink;
boxBody2.Tag = Color.LightSkyBlue;
RigidBody groundBody = new RigidBody(groundShape);
groundBody.Tag = Color.LightGreen;
// set the position of the box size=(1,1,1)
// 2 and 5 units above the ground box size=(10,1,10)
boxBody1.Position = new JVector(0, 4, 1.0f);
boxBody2.Position = new JVector(0, 4, -1.0f);
pointConstraint = new PointConstraint(
boxBody1, boxBody2, new JVector(0, 4f, 0));
// add a force to one body - so it's not that boring
boxBody1.AddForce(JVector.One * 10);
world.AddConstraint(pointConstraint);
// make the body static, so it can't be moved
groundBody.IsStatic = true;
// add the bodies to the world.
world.AddBody(boxBody1);
world.AddBody(boxBody2);
world.AddBody(groundBody);
}