[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Collision Detection Question

Collision Detection Question

Official forum for the .

Collision Detection Question

Postby Gulganei » Sun Jan 04, 2009 5:25 pm

Hello all,

I am new to Chipmunk but am finding it to be an excellent engine.

I have a question regarding collision detection that I'm hoping someone can chime in on. I've posted the same question to the cocos2d-iphone forum since I'm using Chipmunk and cocos2d on that platform.

What I'm trying to do is detect two different types of collision on a single body. The first one (which is larger than the body) would occur when one body gets within a certain proximity of another (e.g. two enemy units coming into range of each other). The second (which is the same size as the body) would occur when an actual bullet collision occurs on the body.

Does anyone have any ideas on how to implement this that could get me going in the right direction? I tried creating two shapes on a Chipmunk body but I only seem to see the larger shape receive the collision callback.

Thanks in advance for any help!
Gulganei
 
Posts: 2
Joined: Sun Jan 04, 2009 5:17 pm

Re: Collision Detection Question

Postby supertommy » Mon Jan 05, 2009 3:59 am

The idea with two shapes sounds to me like it should work. Make sure you're returning 0 from the collision callback for the larger shape. Also, if your smaller shape is very small, and the bullet travels very fast, it could be that it jumps right over your body, since we don't have swept collisions.

That's all I could think of that could go wrong. If neither of these suggestions help, maybe you could post the code you use to set up the body and the two shapes?
supertommy
 
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm

Re: Collision Detection Question

Postby Gulganei » Tue Jan 06, 2009 9:38 pm

Thanks for the response, supertommy.

I modified things slightly and it seems to work: rather than make the larger shape enclose the smaller one, I put the larger shape in front of the object to act as a proximity detector. I then just differentiate which game object shape triggered the collision and act appropriately.
Gulganei
 
Posts: 2
Joined: Sun Jan 04, 2009 5:17 pm

Re: Collision Detection Question

Postby LegoCylon » Thu Jan 23, 2014 11:29 am

I had a similar need in my project and this worked fine for me as long as the larger shape was a sensor. I preferred to classify it as a sensor rather than return false from preSolve (as was suggested previously) because sensors are automatically excluded from cpSpaceNearestPointQueryNearest (docs don't mention this) and cpSpaceSegmentQueryFirst.
LegoCylon
 
Posts: 29
Joined: Wed May 09, 2012 12:06 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron