Game Development Reference
In-Depth Information
We're almost done with our simulation now, but we need to do a few more things. This
last section will handle the
update
method and what happens when the physics is run-
ning and the bridge is being tested:
1. In the
update
method, we parse through all the items in the segment list and set
the
z
value of
linearVelocity
to
0
, as follows:
Vector3f velocity =
segment.getControl(RigidBodyControl.class).getLinearVelocity();
velocity.setZ(0);
segment.getControl(RigidBodyControl.class).setLinearVelocity(velocity);
2. After this, we parse through all the items in the joint's list. For each, we should
check whether the joint's
appliedImpulse
value is higher than a value, let's
say
10
. If it is, the joint should be removed from the list as well as from
phys-
icsSpace
, as follows:
Point2PointJoint p = joints.get(i);
if (p.getAppliedImpulse() > maxImpulse) {
bulletAppState.getPhysicsSpace().remove(p);
joints.remove(p);
}