trigger moving towards
by Anthony Ratcliffe · in Torque Game Builder · 04/28/2009 (2:45 pm) · 24 replies
hi there, i'll set the scene I have a a player named playerclass and class named player. I have an enemy.class name enemy with a trigger mounted to it with the class name enemytigger. what im trying to do is move toward the player when the player moves within the trigger, i tried dissembling the move towards behavior and came up with this
function enemytrigger::onEnter(%this, %object)
{
%this.enemy.moveTo(%playerclass.object.position, 10);
echo("im in the trigger");
}
i think im along the right lines the trigger fire however i get no move towards
i have an error in the log
game/gameScripts/enemy.cs (7): Unable to find object: '' attempting to call function 'moveTo'
doesn't seem to be able to find my playerclass.
its been a good year since i used tgb and never used trigger before so would anyone mind explain correcting my work
regards ant
function enemytrigger::onEnter(%this, %object)
{
%this.enemy.moveTo(%playerclass.object.position, 10);
echo("im in the trigger");
}
i think im along the right lines the trigger fire however i get no move towards
i have an error in the log
game/gameScripts/enemy.cs (7): Unable to find object: '' attempting to call function 'moveTo'
doesn't seem to be able to find my playerclass.
its been a good year since i used tgb and never used trigger before so would anyone mind explain correcting my work
regards ant
About the author
#22
05/13/2009 (5:25 pm)
im having a slight problem with this, when i fire the trigger causes a collision if i deactivate collsions for that layer the player doesnt get hit either any suggestions?
#23
05/16/2009 (12:53 am)
Yes. Check the object type in the trigger collision area, and don't do anything unless that object type is a player (like in the code example) if it's a player, move toward, otherwise ignore it. Enable collisions on your bad guy, and check the object type on the enemy::onCollision. If it's a projectile object, then take damage....
#24
05/16/2009 (6:04 pm)
sorry didn't explain well i meant it hits the trigger Ive layed down when i fire it collides with the outer edge of the trigger not the enemy, however if i turn off the collision with the bullet for the trigger the enemy doesn't get hit
Torque Owner Anthony Ratcliffe