Trigger only working once
by David Ravel · in Torque Game Builder · 02/23/2009 (6:21 pm) · 4 replies
I've mounted my camera to a scene object using the Mount Camera behavior. I've then created a class of trigger that tells the camera's object to move across the screen to the right whenever an instance of the trigger is hit. The only problem is this only works for the first trigger. For some reason all later instances of the trigger get triggered, but doesn't move the camera.
Here's my trigger's script.
function frameTrigger::onEnter(%this)
{
cameraMount.moveTo(cameraMount.getPositionX+176.25, -1.4, 20, true, false, true, 0.01);
echo("camera moving");
}
Thanks for any help you can provide,
David
Here's my trigger's script.
function frameTrigger::onEnter(%this)
{
cameraMount.moveTo(cameraMount.getPositionX+176.25, -1.4, 20, true, false, true, 0.01);
echo("camera moving");
}
Thanks for any help you can provide,
David
#2
02/24/2009 (9:00 am)
Yes I am using 1.7.4.
#3
cameraMount.moveTo(cameraMount.getPositionX+176.25, -1.4, 20, true, false, true, 0.01);
getPositionX is a method, not a variable, this line should be:
cameraMount.moveTo(cameraMount.getPositionX()+176.25, -1.4, 20, true, false, true, 0.01);
What it's doing right now is trying to access cameraMount.getPositionX as a variable, which doesn't exist, so it always gets zero back, and just puts your camera at x = 176.25. Which the first time moves the camera, but every other time it's moving the camera to the same spot it's already at.
It's an easy mistake to make, I do it all the time.
02/24/2009 (12:48 pm)
Your problem is right here:cameraMount.moveTo(cameraMount.getPositionX+176.25, -1.4, 20, true, false, true, 0.01);
getPositionX is a method, not a variable, this line should be:
cameraMount.moveTo(cameraMount.getPositionX()+176.25, -1.4, 20, true, false, true, 0.01);
What it's doing right now is trying to access cameraMount.getPositionX as a variable, which doesn't exist, so it always gets zero back, and just puts your camera at x = 176.25. Which the first time moves the camera, but every other time it's moving the camera to the same spot it's already at.
It's an easy mistake to make, I do it all the time.
#4
02/24/2009 (8:58 pm)
ah, that makes sense, thanks.
Associate Phillip O'Shea
Violent Tulip