Dec 2, 2009 at 3:28 PM
Edited Dec 2, 2009 at 3:29 PM
1. We have a great foundation for a tank inside our AdvancedSamples. You move the tank using force, but since we are a physics engine, you can actually simulate the engine and track of a real tank. Take a look at it and see if it tickles
Otherwise you can use ApplyForce() to apply force in a direction. It applies the force at the centroid of the geometry (the body position) - the amount you apply is really up to you. You just have to find a value range that "feels" right to you.
As for the accelerate key - Force is the correct thing to use here since it has to be constantly applied to make an object move.
2. Use ApplyTorque() instead.
3. If you use ApplyForce() and ApplyTorque, you can use the FrictionCoefficient property. The LinearDragCoefficient is the amount of drag applied to the object at each update.
It is calculated like this: LinearDrag = -LinearVelocity * LinearDragCoefficient
and then the LinearDrag amount is applied to the body as a force.
4. Use RotationalDragCoefficient. It works, you just have to apply a higher value.
5. The mass is used to determine the amount of force that should be applied in reactions and how much force it is required to move an object. As you said yourself: F = ma. A higher mass makes the tank move a shorter distance with the same
6. Yes. But it depends on what kind of reaction you want to have. If your tank is hit by a missile, do you want the turret to detect collisions separate from the tank? You can combine multiple geometries using one body. This is by far the
easiest in most cases, but if you need the turret to be a separate unit for some reason, you need to create two geometries, and ignore collision between the two.
7. How does it jitter around? The bullet might be stuck in the create (due to
tunneling) and that could cause the crate to jump around. Once a bullet has hit something, it might be a good idea to remove it from the physics simulator (if your tank can shoot a lot of bullets in a short period of time, make sure you use a pool).