Physics for a character running
Posted: Wed Jan 02, 2008 6:25 am
Hi everyone
I was wondering if anyone had a good idea about a good way to simulate (really boldly) a human running, like a character sprite for a game, in chipmunk.
What I am doing right now is :
world
* gravity = 400 downward
ground
static body
* mass = inf
* inertia = inf
with a segment shape
* friction (u) = 1.0
man
a body
* mass = 1.0
* inertia = 1000
with a square shape (-50,-50 -> 50,50)
* friction (u) = 0.2
When a key is pressed to run, I apply a force of 100 to the right
When a key is pressed to jump, I apply an impulse of 200 upward
So far, it works (after a lot of tries), but not exactly like I want :
- Acceleration and deceleration are quite low (you have to keep the run button on for a long time to get it "running", and to have it "stop" once the button is released)
- I don't think it reaches a "peak" speed like it should (if I keep pressing on the run button, it gets faster and faster)
I am quite new to this, and not really good at physics (been a long time), but I am really interested if someone has any suggestion to achieve this (quick acceleration to reach a peak speed, quick deceleration to stop)
Thanks
I was wondering if anyone had a good idea about a good way to simulate (really boldly) a human running, like a character sprite for a game, in chipmunk.
What I am doing right now is :
world
* gravity = 400 downward
ground
static body
* mass = inf
* inertia = inf
with a segment shape
* friction (u) = 1.0
man
a body
* mass = 1.0
* inertia = 1000
with a square shape (-50,-50 -> 50,50)
* friction (u) = 0.2
When a key is pressed to run, I apply a force of 100 to the right
When a key is pressed to jump, I apply an impulse of 200 upward
So far, it works (after a lot of tries), but not exactly like I want :
- Acceleration and deceleration are quite low (you have to keep the run button on for a long time to get it "running", and to have it "stop" once the button is released)
- I don't think it reaches a "peak" speed like it should (if I keep pressing on the run button, it gets faster and faster)
I am quite new to this, and not really good at physics (been a long time), but I am really interested if someone has any suggestion to achieve this (quick acceleration to reach a peak speed, quick deceleration to stop)
Thanks