Page 1 of 1

Quick scripting question

PostPosted: Sat Aug 27, 2011 6:21 pm
by BS87
Hi,
currently finishing up my project and got a question how to write the following in script editor (if it even is possible) since I don't know the functions of all the commands yet:

if(Player 1 collides with switch)
{
if(Player 2's current animation is X)
{
Change Player 2's animation to Y
}
}

The problem is that, with my current knowledge, I only am able to give Player 1 another animation as soon as he hits the switch, but not player 2. The switch so far triggers a variable which changes the players animations as soon as he moves, but since I got two players and one of them switches, the other one may not move at the moment and the animation stays the same. Hard to describe and understand, I know, but I would need help for that. Thanks!

Re: Quick scripting question

PostPosted: Sat Aug 27, 2011 6:51 pm
by skydereign
Well, first are they the same actor? Or are they like player1 and player2? If the latter, most of the functions in gE, such as ChangeAnimation, allows you to pick another actor but it defaults to "Event Actor". If you change that to player2, then it will change player2's animation. But anyway, the first if statement you have is taken care of a collision event with the switch.
player1 -> Collision with switch -> Script Editor
Code: Select all
if(player2.animindex==X)
{
    ChangeAnimation("player2", "Y", FORWARD);
}

Re: Quick scripting question

PostPosted: Sat Aug 27, 2011 7:53 pm
by BS87
Thanks bro! Exactly what I needed! :D