Sliding off hills

Official forum for the Chipmunk2D Physics Library.
Post Reply
tross
Posts: 1
Joined: Tue Jun 18, 2013 4:48 pm
Contact:

Sliding off hills

Post by tross »

Hi all, I've been trying to use Chipmunk to make a Tiny Wings style game.

I make static body segments for the hills, and a body for the player.
I apply a small force to the player body so it slides down the hill and over.

This is OK, except the momentum going into the valley carries it slightly off the ground.

I've got an example attached to illustrate.
Example
Example
example.png (4.89 KiB) Viewed 3161 times
I want it to stick to the ground all the time, except when I apply a force to jump.

Is this normal for Chipmunk? It works fine in Box2D with similar functions.

Thanks!

--Tyson
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Sliding off hills

Post by slembcke »

Well, it's normal for physics in general.

An object thrown forwards will curve downwards in a parabola. An object rolling over terrain is going to try and follow the same parabola. If the hill curves downwards faster than gravity would pull the object down, then it will lift off the ground for a while. If you don't want that to happen, then it means you need to set gravity to be higher. Simply touching the ground doesn't make an object accelerate downwards faster than gravity.

Keep in mind that the same thing happens in Tiny Wings or you would never actually leave the ground ever. It also happens the same way in real life, but rarely happens. Real hills curve much more gradually and are never so steep. You also don't drive as fast as you can over them. If you did... ;)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests