Game Development Community

Multiple Collisions...

by Paul /*Wedge*/ DElia · in Torque Game Builder · 03/03/2008 (9:47 pm) · 2 replies

As far as I can tell, onCollision callbacks only register for the first object you collide with, and won't register until you're no longer colliding with that object. Fine, that makes sense. However unless I'm missing something, the t2dTrigger appears to follow this behaviour as well for it's onEnter callbacks. This leaves me with a problem.

I was hoping I could just have a mounted Trigger that gives me an onEnter callback everytime it hits something new, but as far as I can tell, this doesn't work when collisions are overlapping. I have found I can get a full set of colliding objects using castCollisionList, but that's really not optimal, as I sometimes need to do this check over a period of time on a moving object.

So is there a better way to do this I'm missing, or am I going to have to hack up some special method? If it's just the case all manners of collision callbacks fail when overlapped, I guess I may be able to do something where I temporarily deactivate collision on things I've already hit, but that's a mess I'd like to try to avoid.

#1
03/03/2008 (11:52 pm)
Why do you need to have a trigger mounted to an object? I am guessing that you might want to find objects in a certain area. How about you have a look at the t2dSceneGraphs's "pick" functions. They will return a list of objects in the selected area.
#2
03/04/2008 (5:20 pm)
I can already find objects within a (collision) area using castCollisionList. The problem is those are all immediate checks, where I need something that's constantly checking over a period of time. I wanted to avoid having to constantly make checks in script, but I suppose that's not going to happen.

Probably what I'll do is use a mounted trigger, and then have castCollisionList checks inside it's onStay callback, so at least I can avoid hacking stuff into onTimer or onSceneUpdate...