I am working on a simple game and I am deciding how I should let users interact with the world. I really have 2 options,

1.) When the user moves an object I apply a force to the body

2.) With each move iteration I "move" the body by setting position.

Which is "better" or am I looking at this wrong entirely and should I be doing something different?

Also, does it matter if I want to keep the object stationary when it is hit by another body (I am assuming this means I will need to use static body which leads me back to #2)?



1 Answer 1


I wouldn't recommend the static body solution, what I've done is something very similar to this answer, but when you apply horizontal forces reduce the ground friction.

Now you have to think carefully what are the types of objects you will have in your world, because you said:

I want to keep the object stationary when it is hit by another body

Well the terrain is a body, and you want that your character interact with the floor, if you want your character not be affected by dynamic objects, you can set its weight with a very high number, which isn't the same that set it static, because the kinematics will still apply, but other objects will bounce on its surface.

Another more advanced solution, without change the weight, is that you can detect the character collisions and change its output, so you character won't react to collisions with other objects.

In any case, if you want to check if the character is in contact with the floor, you need to detect the character collision.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .