Sign in to follow this  

Object on ground in my 2D Physic Engine

Recommended Posts

Hi Community!!

i'm working on a little and very simple 2d physic engine capable o moving a ball in a level made of tiles. It works well by now.

It works like this:
- I have velocity and i need to update position.
- I move my object position of unit by unit. A unit is unit=normalize(velocity).
- Each time i move i check collision with the world (the tiles).
- For each contact i found the normal (precomputed and stored in a grid of bi-dimensional vectors).
- For each contact i resolve interpenetration and found impulse. The impulse is added to the velocity.

OK - it works.
Now i'd like to make my sphere 'jump' (applying a force opposite to the gravity) but i have no idea how to check if the object is acqually on ground. The player should be able to jump only if he's touching the floor...
I tried to do it this way (no success):
I'm on ground if i have a contact with normal -normalize(g) (where g is gravity vector) but when the object is not standing still it doesn't give the expected results (due to resting contacts). Another problem is that whenever i press 'jump' the object doesn't move away from ground fast enough and the 'jump force' is applied for more than one update frame resulting in 'super-jumps' if the player holds the button.

I know i was not very clear... if you need more explanations just ask for!!

Thanks a lot for any reply...

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this