Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 3D object moving and I need to be able to apply forces to it such as gravity. In 2D, I would simply store its movement in dx and dy, but since this is in 3D, I am using a Vector3D direction and a float speed. How can I determine how much to rotate the direction and change the speed when by using something like applyForce(Vector3D force)?

share|improve this question
You should store the movement in 3D with dx, dy and dz instead of direction and speed. And the dx,dy,dz would be just a vector, so you should have Vector3D velocity. – msell Oct 21 '12 at 5:54

There's a problem with the information you have. Speed (or velocity), is not a force! You need to have an acceleration value and a mass value if you want to apply a force.

Remember that F = MA. Or mass times acceleration. If this is the force of gravity, you use the mass of the object times gravity (roughly 9.8 m/s). If it's some kind of rocket or walking force you need to decide an appropriate force to use.

You may find that you just want to use the mass of the object in all cases, that's fine, and it simplifies things. Then you can simply set your acceleration appropriately to get the kind of forces you want.

Whatever mass*acceleration you use: Take your direction, normalize it, scale it by the acceleration. That will give you an acceleration in the direction of travel. Then multiply it by the mass. Finally apply it as a force to your object.

share|improve this answer

Just a simple idea for your reference. The force in 3D space is also a 3D vector, so that's all about 3D vector arithmetic, suppose you have a model with a velocity of V and mass of m, and you want to apply a force F on it, use the second law of Newton, then it is something as below

Vector3 a = F / m;
V' = V + at;

where a is the acceleration, that's also a 3D vector. V' is the new velocity when applying the force.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.