This project has moved and is read-only. For the latest updates, please go here.

OnCollision, Contact List(check collision)

Mar 16, 2009 at 7:53 PM
Hey everyone im trying to do a simple collision check but I am having ALOT of trouble with the onCollision method, mostly because i have no idea what to do with the contact list argument.
Is their a simpler way to check collision?
i saw there was verts.intersect but it doesnt seem like its possible to use that.

Mar 16, 2009 at 9:50 PM
If you don't need (or use) the contact list, just ignore it.
When you have subscribed to the OnCollision event, you should be good to go.

As for a "simpler" way of doing collision checks, you can always use Geom.Collide() or PhysicsSimulator.Collide()

I would not recommend the use of those Collide() methods over the OnCollision event since the OnCollision event by design is faster. But they both have their uses.
Use PhysicsSimulator.Collide() to check if any geometry collide with a single point and use the OnCollision event in cases where you need some game logic to start when a collision happens.
Mar 17, 2009 at 12:27 AM
Edited Mar 17, 2009 at 12:33 AM
thank you very much 
i had not realized i could use null 

edit: when i tried to use null it said i did not set to an instance of an object is their a different way to avoid the contat list?
Mar 17, 2009 at 3:53 AM
What genbox is saying is dont do anything with the contact list, not make it null.
Mar 17, 2009 at 5:17 AM
well i tried that as well and it just gives me an argument saying it does not take 2 arguments.
what i write is this
if (geom1.onCollision(geom1, geom2))
doSomething( );
but it wont allow it.
Is there another using statement that just went way over my head?
Mar 17, 2009 at 6:18 AM
If i understand correctly, OnCollision is an event that gets fired when any two geoms collide, not a method you call to check if 2 geoms are colliding.
Mar 17, 2009 at 6:58 AM
Edited Mar 17, 2009 at 7:00 AM
well thats what i was asking, i want to check collision,
i want see if their is a collision occuring between two geometries.
And the onCollision method is one that returns true or false, s why cant it be used that way?

But if its not the way to go im willing to try anything that works!
The ways genbox suggested would be alright but if they do not work anywhere near acceptable i would not want to use them as im looking for code that is good in the long-run not a part time fix.
Mar 17, 2009 at 8:26 AM
hmm... im not sure how to do this... Maybe Genbox would be able to help....
Mar 17, 2009 at 10:35 PM
the return value of OnCollision defines if the Geom should interpenetrate

if i understand you correctly, you want to know if at a given time the Geoms collide or not collide, and not just be informed if they are colliding. my usual solution to this is to store the update cycle interval in OnCollision and check in OnSeparation, if there has been a collision in the current update cycle. if not, then this is the last other Geom separating from the testing Geom and it is no longer colliding.
Mar 17, 2009 at 10:45 PM
thanks ill try : )