Double Collision effect
by Michael S · in Torque Game Builder · 02/12/2007 (4:45 am) · 1 replies
Hi my name is Michael.
I have a problem when i developing a game.
I have 3 sprite
1.Player with send and receive collision activated
2.Enemy with just only receive collision activated
3.and also computer desk with just only receive collision activated
i've programmed
enemy::oncollision(bla bla)
{
myplayer.die();
}
computer::oncollision(bla bla)
{myplayer.work();
}
the problem is if my player working with that computer and
the enemy collide with the player
my player won't die and still working
how can i solve this case?
thanks
I have a problem when i developing a game.
I have 3 sprite
1.Player with send and receive collision activated
2.Enemy with just only receive collision activated
3.and also computer desk with just only receive collision activated
i've programmed
enemy::oncollision(bla bla)
{
myplayer.die();
}
computer::oncollision(bla bla)
{myplayer.work();
}
the problem is if my player working with that computer and
the enemy collide with the player
my player won't die and still working
how can i solve this case?
thanks
Torque Owner Apurva Amin
computer::onCollision(bla bla)
{
$playerWorking = true; //set to true so that player cannot be killed while (s)he's working.
myplayer.work();
}
and in your enemy collision, check whether he's working or not.
enemy::onCollision(bla bla)
{
if($playerworking != true) //if the player is not working....
myplayer.die(); //...then carry out the die method.
}
Hopefully that should work. Don't forget to reset the $playerWorking to false after otherwise the enemy will never kill the player.