How to tell if object is Player
by Anthony · in Torque Game Engine · 08/18/2005 (5:55 am) · 6 replies
I know this may be an elementry question, but it is late (or early, depending on how you look at it). I have set-up some triggers to get the campaign mode going, they work great, only problem is that the NPC's can also trigger these triggers (so you end up with however many background musics playing at once, ect.) I can solve this with a simple test in the triggers I only want to be activated by the player. How would I go about tesing the triggering object to see if it is the player?
Any help would be apprectiated.
Anthony Bertolo
BBiGames
Any help would be apprectiated.
Anthony Bertolo
BBiGames
#2
08/18/2005 (6:24 am)
Thank you for the quick reply, your help is very much apprectiated. :)
#3
Anyone have any ideas?
08/18/2005 (10:32 pm)
Perhaps I am doing something wrong in the syntax. But the object is not seeming to be valid, the console spits a cannot find object error when it gets to the %obj.playAudio function.function inGamePioraTrigger::onTickTrigger(%this,%trigger,%obj)
{
if (%obj.isbot == false)
{
$gameTime++;
// now that we have reached this point we know that all
// sequences are okay to play. So we will now go through all
// the steps.
$timeSinceLastTalk = $gameTime - $lastTalkTime;
if ($gameStep == 1) // we are in the room waking up
{
if ($timeSinceLastTalk > 4)
{
// Duce is trying to wake vince up.
%obj.playAudio(1,VinceVoice1);
bottomPrint(%obj.client,"Uhg... I'm awake... What is it soldier, something happen?",7,1);
$lastTalkTime = $gameTime;
$gameStep = 2;
}
}
else
{
// do nothing because everything should be scripted
bottomPrint(%obj.client,"Sorry Guys, this is where it stops...",5,1);
}
}
}Anyone have any ideas?
#4
08/19/2005 (2:26 pm)
I was going to erase my previous post, but maybe my findings may benefit somone else who made the same idiot mistake I did. Basically I was thinking that onTickTrigger could pass a %obj, which it cannot, therefore it was always invalid.
#5
08/19/2005 (6:19 pm)
To tell if an object is a player you can do the following:if(%obj.getClassName() $= "Player")
{
// do something
}
#6
08/19/2005 (7:20 pm)
...or if it's a bot you want this:if (%obj.getClassName() $= "AIPlayer")
{
// do cool things
}
Torque Owner Chris Labombard
Premium Preferred
%player = new AIPlayer () ......
%player.isBot = true;
in trigger:
if(%obj.isBot == false)
{
// I AM NOT A BOT
}