Game Development Community

t2dtrigger collision poly denial

by Dan Pascal · in Torque X 2D · 01/14/2010 (3:50 pm) · 11 replies

I put a T2DTrigger component (and t2dcollison component) on a blank scene object, and edit the collision poly.

Tx ignores the poly and uses the scene object's box outline as the poly instead.

Is that the way it's supposed to work?



#1
01/14/2010 (4:11 pm)
"You can also optionally specify a T2DCollisionImage for the trigger to use in addition to the initial bounding box check. Note that the initial check is still limited to the bounding box of the owning scene object.
"

how can I specify that the polyimage to use is the owning objects collision polyimage?
#2
01/14/2010 (4:44 pm)
iirc there is some code missing in T2DTriggerComponent - basically when the game runs it's not automatically installing the custom collision polygon you created in the editor.

Try adding the following lines to the end of T2DTriggerComponent's _OnRegister(), just before it returns true:

foreach (T2DCollisionImage image in SceneObject.Collision.Images)
{
    InstallImage(image);
}
#3
01/14/2010 (8:32 pm)
bingo!
you nailed it, thanks
#4
01/15/2010 (2:37 am)
Amazing. I just came in to a situation that I needed something like this and BAM! First post on the board.

Thanks a ton guys :D

Having the source is sweet.

Here's a little bit to add as well, I ran this on a trigger that doesn't have a collision component and it breaks down.

if(SceneObject.Collision != null)
            foreach(T2DCollisionImage image in SceneObject.Collision.Images) {
               InstallImage(image);
            }
#5
01/24/2010 (2:40 pm)
we should put this in for the next update no?
i mention it just incase it falls thru the cracks
#6
12/02/2010 (5:14 am)
WOW this fixed something I've been scratching my head on for months !
#7
05/15/2011 (12:23 pm)
This is already in the CEV? However it does not seem to work at all, I am still getting the entire image as a collision
#8
05/15/2011 (2:30 pm)
Unless it didn't get copied across in the CEV4 upgrade work? Can you add it?
#9
05/15/2011 (2:53 pm)
Actually it is way weirder than that.

It also doesn't read the Collision image of the colliding object, it uses the entire bounds. So If I have say a 50% box as my collision in my char, and a 50% box on the Trigger, the trigger hits as soon as the edge of 100% of the char hits the trigger's box.

It makes no difference what the collision shape is on the "theirObject" it pays absolutely no attention to it.

I am digging into it.

#10
05/15/2011 (3:02 pm)
OK sorry to sound like stream of consciousnesses but if you install a collision image and also have collision on the object with a trigger it seems the trigger never gets called as the collision takes priority. You also cannot seem to scale or edit the Collision Image that is installed in the trigger.

#11
05/15/2011 (6:09 pm)
What I ended up doing for anyone else who may be trying. I had to add a new object that only has a trigger, and mount it to my object, so when the player gets close it hits the trigger and when the player finally collides it does the collision.