Jump to content
  • Advertisement
Sign in to follow this  

Object on ground in my 2D Physic Engine

This topic is 2783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!