Page 1 of 1

problem with collisions

Posted: Wed Dec 15, 2010 6:57 am
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.

Re: problem with collisions

Posted: Wed Dec 15, 2010 9:47 am
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.

Re: problem with collisions

Posted: Wed Dec 15, 2010 10:24 am
by bylvinkle
slembcke, thanks a lot! It was so simple. I promise i will do donation after i have done my(first) project.