Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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)?

Thanks

share|improve this question

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.

share|improve this answer

Your Answer

 
discard

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.