Okay. In this demo, I use several variables, one being ready. I use ready to signify the ability for the actor to do an event. So for every event that would change the animation, I set the variable ready to 0.
Actor->KeyDown(SPACE)->Script Editor // This is what is there
- Code: Select all
if (sword==0)
{
sword=1;
ChangeAnimation("Event Actor", "standsword", FORWARD);
}
if (sword==1)
{
sword=0;
ChangeAnimation("Event Actor", "stand", FORWARD);
}
Now, you want it to change animation, so you the animation to the desired one. And to prevent an attack before the animation finishes, you need to set ready to 0. But to pull out your sword, you must be ready to recieve an action, so you would use a conditional to create this effect.
- Code: Select all
if (ready==1)
{
if (sword==0)
{
sword=1;
ready=0;
ChangeAnimation("Event Actor", "swordanim", FORWARD);
}
if (sword==1)
{
sword=0;
ready=0;
ChangeAnimation("Event Actor", "standanim", FORWARD);
}
}
There is an event already on the actor's animation finish, that resets ready to 1. Now you could either use variables to do the next part or just use the animationfinish event.
Actor->AnimationFinish(swordanim)-> Set it to change animation to standsword
and another one
Actor->AnimationFinish(standanim)-> Set it to change animation to stand