Triggers not recognizing StaticShapes
by Steve Self · in Torque Game Engine · 03/12/2006 (10:21 am) · 5 replies
Hello! I was wondering if anybody could help me with this:
I have programmed in a trigger which moves around a central rotating object. For some reason, it recognizes the player when the player moves through it, but not the StaticShape object that I want it to recognize. What am I doing wrong?
Here is the code defining the trigger, in case I need to add in something more.
I have programmed in a trigger which moves around a central rotating object. For some reason, it recognizes the player when the player moves through it, but not the StaticShape object that I want it to recognize. What am I doing wrong?
Here is the code defining the trigger, in case I need to add in something more.
datablock TriggerData(ActionTrigger)
{
tickPeriodMS = 100;
};
$trigger = new Trigger(SActionTrigger)
{
dataBlock = "ActionTrigger";
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
};
#2
StaticShapes do not check for collision against triggers. By default in Torque only the objects that move (players, vehicles, a non-static shape) have to check themselves whether or not they've entered in a trigger and act appropriately.
This means code changes to the engine.
You'll need to enable collision on the static shape for every tick (in processTick()) for it to check whether or not it has entered a trigger. And after you've enabled collision, and have been walking through the list of convexs your code would look something like this:
- Eric
03/12/2006 (12:21 pm)
Stefan is correct.StaticShapes do not check for collision against triggers. By default in Torque only the objects that move (players, vehicles, a non-static shape) have to check themselves whether or not they've entered in a trigger and act appropriately.
This means code changes to the engine.
You'll need to enable collision on the static shape for every tick (in processTick()) for it to check whether or not it has entered a trigger. And after you've enabled collision, and have been walking through the list of convexs your code would look something like this:
if(pConvex->getObject()->getTypeMask() & TriggerObjectType)
{
Trigger* pTrigger = static_cast<Trigger*>(pConvex->getObject());
pTrigger->potentialEnterObject(this);
}- Eric
#3
03/12/2006 (12:47 pm)
Thank you very much! I'll get on it.
#4
Good answer though!
03/12/2006 (1:01 pm)
Minor point (it's not a lot of code) but this is a public forum, and you shouldn't post source code to the public.Good answer though!
#5
I'll keep a look out next time ;)
- Eric
03/12/2006 (1:11 pm)
My apologies. I didn't realize it was a public forum post until you pointed it out.I'll keep a look out next time ;)
- Eric
Torque Owner Stefan Lundmark