Best way to move objects manually?

Topics: User Forum
Apr 6, 2011 at 2:49 AM

Hi,

I'm looking to make a top down shooter and have figured out the basics of collision, but I can't figure out the best way to manually move my character around the world. I know that manually setting either the position or velocity of a character is a very bad idea, but I don't know the best alternatives to the easy way out, and how to implement them.

If anybody could help me with this, that would be great.

-Evan

Apr 6, 2011 at 1:55 PM

why is manually setting the position a problem?

Apr 6, 2011 at 3:35 PM

Because in manually setting a body's position, you are "teleporting" the object without the benefits of CCD or even basic collision reaction. Also, manually setting a body's position is a good recipe for tunneling. All in all, if I manually set the position, I will get a jerky camera, tunneling, and no CCD or collision reaction.

 

Please give me an answer that is correct...

-Evan

Developer
Apr 6, 2011 at 3:45 PM

Have a look at kinematic bodies or try moving your objects with a force and impulse driven approach. The latter approach would be more "realistic" but is hard to tune and probably doesn't give you enough control over your objects. Kinematic bodies have other problems like no collision with other kinematic or static bodies.

Apr 6, 2011 at 4:44 PM
Edited Apr 6, 2011 at 4:46 PM

I've always just applied a constant force to give the correct acceleration, then manually limited the velocity. I suppose you could reduce the force as the velocity gets close to it's limit, to give you an ease-in to max speed effect.

Apr 6, 2011 at 6:11 PM

So what I ended up doing was to take the difference of the wanted velocity and the current velocity, and multiplied that by the mass to get the force to apply. If the difference is large, then I increase the acceleration to simulate fast turnarounds and starting movement. Just thought I'd post this for future reference.

-Evan