[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/bbcode.php on line 112: 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 112: 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 112: 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 112: 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 112: 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 - Detecting Collisions

Detecting Collisions

Chipmunk2D Bindings for the Unity3D engine

Detecting Collisions

Postby Roland » Sat Aug 10, 2013 1:24 pm

User avatar
Roland
 
Posts: 16
Joined: Thu Aug 08, 2013 3:32 pm

Re: Detecting Collisions

Postby ShawnMcCool » Sun Aug 11, 2013 2:12 pm

I have basically the same question. I'd also like to know if you can assign many collision types to a shape.
ShawnMcCool
 
Posts: 6
Joined: Sun Aug 11, 2013 2:06 pm

Re: Detecting Collisions

Postby Roland » Tue Aug 13, 2013 11:17 pm

Mr. McCool and I must has answers.
User avatar
Roland
 
Posts: 16
Joined: Thu Aug 08, 2013 3:32 pm

Re: Detecting Collisions

Postby ShawnMcCool » Wed Aug 14, 2013 4:00 am

I'd be happy just to have access to some sort of basic documentation about how collision detection works. I learned what I can from the example, I think. I understand how to create a custom resolver between two types. But, there's more generic concepts that I'm lacking.
ShawnMcCool
 
Posts: 6
Joined: Sun Aug 11, 2013 2:06 pm

Re: Detecting Collisions

Postby Steve Oldmeadow » Wed Aug 14, 2013 5:57 am

I found the Chipmunk2D manual very useful for understanding how collisions work. Chipmunk's layers are available in Unity but they are not exposed in the editor UI so you need to write some code to specify a shape's layer mask.

Something that just clicked with me is that shapes are monobehaviors therefore you have access to the game object plus all the other components attached to the game object. So you have Chipmunk collision types, collision layers and collision groups plus Unity's layers, tags and game object name at your disposal within a collision handler. If that isn't enough you can always attach another component to your game object and access it from the collision handler. That is a lot of power and certainly more than you get with PhysX.

Maybe it is better to explain what you are trying to do rather than asking for specific functionality such as specifying multiple collision types for a shape.
Steve Oldmeadow
 
Posts: 17
Joined: Tue Jul 16, 2013 10:27 pm

Re: Detecting Collisions

Postby Roland » Wed Aug 14, 2013 9:52 am

Well, say you have defined an area on a level through a Chipmunk shape where there's a specific amount of force being applied to any body that enters it; like to simulate wind or something. So I figure you'd have a sensor shape with a collision manager defining a begin or presolve method for types labelled "wind" and... what? "object"? What if you have an object that you also need to be handling collision for on a different pair like between "projectile" and "player" at the same time you want the "wind" to have effect on them? Now you have to define collision handlers for every possible combination. Would be much easier to be able to set multiple collision types so that something can be considered "player" and "object" at the same time.

Or is there some other mechanic that I'm not aware of?
User avatar
Roland
 
Posts: 16
Joined: Thu Aug 08, 2013 3:32 pm

Re: Detecting Collisions

Postby slembcke » Wed Aug 14, 2013 10:15 am

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Detecting Collisions

Postby slembcke » Wed Aug 14, 2013 10:26 am

Hmm. Ok. In that use case default collision handlers might be useful.

On the other hand, that gives me an idea for something better. In the Unity version, it makes C# delegates out of your ChipmunkCollisionManager methods and passes those on to the C code. The name of the methods is only important so it can figure out what types to associate the delegates with. It's also possible for me to make an API call where you could easily associate a single delegate or method with multiple collision types. Still not as good as a wildcard, but it would make it easier to enumerate the things you want to collide.

On the TODO list! :)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Detecting Collisions

Postby Roland » Wed Aug 14, 2013 11:22 am

User avatar
Roland
 
Posts: 16
Joined: Thu Aug 08, 2013 3:32 pm

Re: Detecting Collisions

Postby slembcke » Wed Aug 14, 2013 1:32 pm

Triggering multiple handlers is bad because that can do more than respond to the events. The return value of the begin and preSolve callbacks allow you to filter collisions, and the preSolve in particular exists to allow you to change a collision's outcome. If there are multiple callbacks what if their return values don't agree, what rule is used to handle that? What order should it run them in if they both make changes to the arbiter parameters? This is something that will need to be addressed with wildcards as well, but in that case there are only two to deal with.

The performance of a default collision handler may be somewhat poor. I don't have hard number though. Calling across the C -> C# language barrier is relatively expensive and its possible to have a lot of callbacks that you'd need to handle for a given frame. That's part of the reason why it's designed like it is.

As for the collision methods stopping, is the object falling asleep? Pre/PostStep methods are not called for sleeping objects since the collisions themselves are not active.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Next

Return to Chipmunk2D for Unity

Who is online

Users browsing this forum: No registered users and 0 guests

cron