problem with collisions

Official forum for the Chipmunk2D Physics Library.
Post Reply
bylvinkle
Posts: 3
Joined: Wed Dec 15, 2010 5:56 am
Location: Kiev
Contact:

problem with collisions

Post by bylvinkle »

Hi! I have an convex polygon body(dinosaur) and also i have a static polygon body(house). I want that "dinosaur" and "house" would collide only if "dinosaur" hits roof of that house. I think to reach such effect i should check locations of "dinosaur" and "house" when beginCollisionHandlerFunction is called.

But maybe there is more easy way to do so(pick up collision between "dinosaur" and roof of the "house")? Can i know when "dinosaur" hits the roof of the "house" only if "dinosaur" falls on the roof?
Below is image to explain what i want more easy.
Image

Any advices or examples of code would be appreciated.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: problem with collisions

Post by slembcke »

You can use the layers bitmask to filter out the collision between the house and monster. To do a one-way collision with the roof, see the one-way demo: http://code.google.com/p/chipmunk-physi ... ay.c?r=670 It uses a simple pre-solve collision callback to implement the filtering.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
bylvinkle
Posts: 3
Joined: Wed Dec 15, 2010 5:56 am
Location: Kiev
Contact:

Re: problem with collisions

Post by bylvinkle »

slembcke, thanks a lot! It was so simple. I promise i will do donation after i have done my(first) project.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests