Strange trigger problem
by Michael Cozzolino · in Torque Game Engine Advanced · 11/16/2006 (9:43 am) · 1 replies
Using Paul Dana's Turret Resource
Here is my Ai Turret's onAdd()
Now when I call this on add method when deploying it as a player all is well.
Probelm is when I place a turret within the mission editor. The trigger position starts at 0 0 0 and gets modified with the + or - (%obj.getDatablock().range) /2 instead of starting off with the turret position.
Am I missing something here?
Here is my Ai Turret's onAdd()
function AITurretData::onAdd(%this,%obj)
{
Parent::onAdd(%this,%obj);
echo("AITurretData::onAdd");
%size = %this.triggerRadius;
%pos = %obj.position;
// now we have to give the static shape a
// controlling trigger of the right size and location
%trigger = new Trigger()
{
dataBlock = AITurretTriggerData;
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1";
};
echo(%obj.position);
%x = getWord(%pos, 0) - (%obj.getDatablock().range) /2;
%y = getWord(%pos, 1) + (%obj.getDatablock().range) /2;
%z = getWord(%pos, 2) - (%obj.getDatablock().range) /2;
%position = %x @ " " @ %y @ " " @ %z;
%trigger.position = %position;
%scale = %obj.getDatablock().range *2;
%trigger.setScale(%scale SPC %scale SPC %scale);
echo("TriggerPos: "@%trigger.getTransform());
%trigger.setOwner(%obj);
%obj.trigger = %trigger;
}Now when I call this on add method when deploying it as a player all is well.
Probelm is when I place a turret within the mission editor. The trigger position starts at 0 0 0 and gets modified with the + or - (%obj.getDatablock().range) /2 instead of starting off with the turret position.
Am I missing something here?
About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
Torque 3D Owner Michael Cozzolino
Big Monk Games