Collision filtering confusion... 3 questions

Jan 29, 2011 at 7:36 AM

Hi everyone. 

Let's say two geometries collide, and one geometry's OnCollision method returns true.  Does that guarantee that the collision be enforced, overriding all other factors (even when the other geometry's OnCollision returns false)?

And what if two geometries collide, and only one has an OnCollision method, which returns false.  The other does not have an OnCollision method.  Is the collision then disregarded?

Finally, let's say that I DON'T want geometries' OnCollision methods to be called when they intersect a sensor (a geometry with IsSensor = true).  Can I do this?  Or do I have to write code in each geometry's OnCollision to return false when hitting sensors?

Developer
Jan 31, 2011 at 2:40 PM
MidnightFolder wrote:

Let's say two geometries collide, and one geometry's OnCollision method returns true.  Does that guarantee that the collision be enforced, overriding all other factors (even when the other geometry's OnCollision returns false)?

Not 100% sure. But I think currently returning false in either one results in the collision being canceled. True is kinda the default behaviour, so you may not return false in any of the two delegates if you want the collision to happen.

And what if two geometries collide, and only one has an OnCollision method, which returns false.  The other does not have an OnCollision method.  Is the collision then disregarded?

Yes.

Finally, let's say that I DON'T want geometries' OnCollision methods to be called when they intersect a sensor (a geometry with IsSensor = true).  Can I do this?  Or do I have to write code in each geometry's OnCollision to return false when hitting sensors?

If an OnCollision delegate is empty it is not called. Sensors also don't have any collision response, so I don't really see the need to cancel anything there. You can also set up some collision filtering, specifying which (groups of) objects should collide with each other. Have a look at the collision groups sample in SimpleSamples for that.