Classic Style Character Movement Physics

nickgravelyn

13-07-2006 06:06:37

I'm trying to implement a character movement model that doesn't seem to be easy to achieve with Newton.

My game is being designed with game controllers in mind. I want movement with both buttons (also for users with just keyboards) as well as the joystick.

The game is played as a third person sidescrolling-esque game (the character can move forward and back along the Z axis, but only a short distance). This means that all movement is not relative to the direction of the character.

When the user pressed right on the controller (or D for keyboard users), the character should simply start going a certain speed; not accelerate towards that speed. The joystick is similar except that the percentage of the distance the joystick is pressed is the percentage of the speed the character can possibly go.

So far, my character movement is simply at adding forces to my character which causes the unwanted acceleration. Any ideas how to achieve this more "classic" model of character physics using OgreNewt?

HexiDave

13-07-2006 07:09:42

You're saying instead of a 0-60 type speed you just want zero and 60? You press right (D button) and you're instantly at full speed? Instead of adding forces, can't you just set the velocity directly?

I'm about to fall asleep here, so sorry if I mis-read what you're asking.

nickgravelyn

13-07-2006 08:49:39

You're saying instead of a 0-60 type speed you just want zero and 60? You press right (D button) and you're instantly at full speed? Instead of adding forces, can't you just set the velocity directly?

I'm about to fall asleep here, so sorry if I mis-read what you're asking.


That's what I want, but using setVelocity() doesn't quite work for a couple reasons:
1) Mass no longer matters as far as collision. My character at 10 units of mass can easily push objects of hundreds of units of mass.
2) I can no longer use any external forces to move the character such as moving vehicles or conveyor belts.

Any other ideas?

OvermindDL1

13-07-2006 23:17:20

Correct, never use SetVelocity. What you need to do is calculate how much acceleration you need to instantly get up to stated speed. All further calculations will be to calculate the acceleration required to continue that speed overcoming the natural resistances of friction and such (or just turn off friction when moving)

nickgravelyn

14-07-2006 01:02:13

I still have a small grasp on physics calculations from last year, but can you offer a brief refresher of how I would calculate the needed acceleration? My largest problem is determining the time difference. Does the Newton world track the time differences between updates or do I use Ogre's time difference between frames?

OvermindDL1

14-07-2006 05:15:18

Newton has its own time difference you handle when you plug in a time, it needs to be consistent (unlike graphics which do not need to be consistent). You'll need to get someone else here to post the formulas. :)