So, i' making a gui to switch between different characters, and when you click on the image of the character you want to switch to, an animation starts; anyway, if the character is in the same room, there are no problems, but if the player is in another room, the room changes after the animation (and i want it to start after the room change). Since setAsPlayer waits for the entire function to finish before switching, what can i do?
You can work around it by setting a flag variable instead of starting an animation on clicking the image.
Then you can check for that flag in the repeatedly_execute() event function of the main global script and run animation from there:
At the top of the main global script:
bool bRunAnimation = false;
on clicking the image:
cSomeCharacter.SetAsPlayer();
bRunAnimation = true;
repeatedly_execute()
if ( bRunAnimation == true )
{
< start animation here >
bRunAnimation = false; // to avoid starting it repeatedly
}
Thanks Scorpius, it worked :D
You are welcome :)
Ah and one thing to add: if you were running different animations for different images, you can reproduce it with if-else within repeatedly_execute taking a current value of the player variable as condition to check for:
repeatedly_execute()
if ( bRunAnimation == true )
{
if (player == cEgo1) < start cEgo1-specific animation here >;
else if (player == cEgo2) < start cEgo2-specific animation here >;
else if (player == cEgo3) < start cEgo3-specific animation here >;
bRunAnimation = false; // to avoid starting it repeatedly
}