Page 1 of 1

Rogue body and collision detection

Posted: Sat Nov 17, 2012 7:40 pm
by kandkstuart
I need to use rogue bodies to move objects I don't want controlled by chipmunk but I need to have collision detection possible with the rogue bodies. Is this possible? And if so how would one accomplish it if the rogue bodies are part of the space?

Thanks for any help!

Re: Rogue body and collision detection

Posted: Sat Nov 17, 2012 10:35 pm
by slembcke
When you say "collision detection" which do you mean? That callbacks should be called or that there should be a collision response?

Collisions are not detected at all between infinite mass objects (so no callbacks or response). If you changed it so that it did you would have to make sure to return false from the the begin or preSolve callbacks to avoid an unsolvable collision. Working with finite mass rogue bodies is not really recommended. You'd really have to know what you are doing.

Collisions between infinite mass and finite mass bodies (rogue or otherwise) works normally.

Re: Rogue body and collision detection

Posted: Sun Nov 18, 2012 7:25 am
by kandkstuart
I guess I'm trying to figure out the best way to move an object myself but use chipmunks collision detection for that object. I have a pathfinding AI that moves my enemy objects so I don't need chipmunk to do that work but I would like chipmunk to detect when the enemy objects collide with other objects. What would you suggest? Things I have tried haven't been successful.

Re: Rogue body and collision detection

Posted: Mon Nov 19, 2012 1:00 pm
by slembcke
Hmm. It sounds like maybe you just want sensor shapes?

Re: Rogue body and collision detection

Posted: Mon Nov 19, 2012 6:42 pm
by kandkstuart
Do you have a link to an example of sensor shapes somewhere?

Re: Rogue body and collision detection

Posted: Mon Nov 19, 2012 8:56 pm
by kandkstuart
I see you just set a flag. By setting the Sensor flag that shape can be moved manually without impact from Chipmunks perspective? Oh ya, will chipmunk detect a collision between the same object if given a callback routine?

Re: Rogue body and collision detection

Posted: Tue Nov 20, 2012 2:42 am
by slembcke
Yep, sensors are for collision shapes where you want callbacks but no collision response. Basically the same as if you returned false for the preSolve callback each time.

One problem that I noticed a day or two ago is that collisions between infinite mass objects is filtered out before even calling the callbacks. So don't make infinite mass sensor objects. I intend to change it to work like sensors instead though.

Re: Rogue body and collision detection

Posted: Tue Nov 20, 2012 6:02 am
by kandkstuart
that does the trick! Thanks as always!