Help with Triggers activating objects in same group
by Roland Stralberg · in Torque Game Engine · 09/16/2005 (5:02 pm) · 4 replies
I want to activate a radar (an animated dts, which works with playThread )
when the player comes near it (not collides with it).
My plan was to place a Trigger which covers an area
around the radar and place both the trigger and the
radar in a SimGroup. According to the doc's triggers
will activate ::onTrigger on every object within same
group as the trigger.
The sad thing is that I cant get this to work.
When player enters the trigger my RadarTrigger::onEnterTrigger
is executed, but Radar::onTrigger is never called.
Can anyone help me with this problem. I have read similar
quiestions in the forum without been able to find what I'm
doing wrong. Would really appreciate any help.
Here is my code
when the player comes near it (not collides with it).
My plan was to place a Trigger which covers an area
around the radar and place both the trigger and the
radar in a SimGroup. According to the doc's triggers
will activate ::onTrigger on every object within same
group as the trigger.
The sad thing is that I cant get this to work.
When player enters the trigger my RadarTrigger::onEnterTrigger
is executed, but Radar::onTrigger is never called.
Can anyone help me with this problem. I have read similar
quiestions in the forum without been able to find what I'm
doing wrong. Would really appreciate any help.
Here is my code
// --- the radar
datablock StaticShapeData( Radar )
{
category = "Misc" ;
shapeFile = "~/data/shapes/radar.dts" ;
} ;
function StaticShapeData::create(%data)
{
%obj = new StaticShape()
{
dataBlock = %data ;
}
return %obj ;
}
function Radar::onTrigger(%this,%obj,%trigger,%state)
{
if ( %state == 1 )
%this.playThread(0,"rotate") ;
}
// --- the trigger
datablock TriggerData(RadarTrigger)
{
tickPeriodMS = 100;
};
function RadarTrigger::onEnterTrigger(%this,%trigger,%obj)
{
// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onEnterTrigger(%this,%trigger,%obj);
}
// In mission file
new SimGroup(RadarTest) {
new StaticShape(R1) {
position = "0.902434 11.622 0";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Radar";
};
new Trigger(T1) {
position = "-2.10599 13.9702 -0.349939";
rotation = "1 0 0 0";
scale = "6.03268 22.0119 1";
dataBlock = "RadarTrigger";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};
};
#2
09/16/2005 (8:33 pm)
I'm no coder, but what Class or object is RayCone, isn't the object you're dealing with the "Radar"??
#3
You are right. RayCone is wrong.
I was a typo when writing this letter,
and i have corrected it now. The problem
is still the same though.
Thanks.
09/17/2005 (2:28 am)
Rex: You are right. RayCone is wrong.
I was a typo when writing this letter,
and i have corrected it now. The problem
is still the same though.
Thanks.
#4
Thanks to Eric's thread Ridiculous Trigger Problem
All that needs get the radar working was following additon
Many thanks Eric.
09/17/2005 (7:07 am)
Now my problem is solved.Thanks to Eric's thread Ridiculous Trigger Problem
All that needs get the radar working was following additon
function StaticShape::onTrigger(%this, %obj, %state )
{
%this.getDatablock().onTrigger(%this, %state);
}Many thanks Eric.
Alessandro Loureiro