Solved How to make a brake animation after run animation?

Question that is answered or resolved.

hbdhl

Active member
I'd like to create a character with a lot of inertia:
The character runs fast, and when the player releases the arrow keys, the character slides forward slightly, like skating on ice.
 
Solution
I liked how it turns out. Question: do we need to use a freespecial for that? Can't we use the native run?
I don't want to use many cancels to use runattack, run jump, etc.
Now the code is using the native run but with a follow animation for the brake frames.
Basically the script will preserve the current speed moment for both X/Z axis during the brake animation and allow it to be gradually reduced.

Animations
Code:
anim idle
    loop    1
    delay    16
    offset    127 179
    bbox    117 109 19 72
    @cmd animVar "runFlag" 1 openborconstant("ANI_FOLLOW15") #CHANGE TO THE BRAKE ANIMATION IF THE RUNFLAG IS 1
    frame    data/chars/heroes/blaze/sor2/idle00.png
    frame    data/chars/heroes/blaze/sor2/idle01.png
    frame...
I'm having trouble with switching to an idle animation with its specific frame after braking. I also tried switching to a follow animation.

I tried replacing setIdle function with either an animation change or any combo of an animation and its specific frame together. I tried without animation flag of 2. When I use either changeentityproperty or executeanimation, I only can make the character move backwards with keyint. But I cannot move anywhere at all if I press forward, up, or down, since I want to have it do an alternate idle pose in either anim idle with a specific frame or anim follow right after the brake animation.

C:
void aniframe(void Ani, int Frame){   
    // Changes anim and select frame
    void self = getlocalvar("self"); // Get self/player

    changeentityproperty(self, "animation", Ani, 2); //Change animation
    changeentityproperty(self, "animpos", Frame); //Change frame
}

void aniframe2(void Ani, int Frame){
    void self = getlocalvar("self");
    performattack(self, Ani, 2);
    updateframe(self, Frame);
}

void aniframe3(void Ani, int Frame){
    void self = getlocalvar("self");
    executeanimation(self, Ani, 2);
    updateframe(self, Frame);
}

void anichange(void Ani)
{// Animation changer
    void self = getlocalvar("self");
    changeentityproperty(self, "animation", Ani, 2); //Change the animation
}

Code:
anim follow15 #BRAKE ANIMATION
    loop    0
    delay    16
    offset    127 179
    bbox    117 109 19 72
    @cmd loadSpeed 2 2 #LOAD PREVIOUSLY SAVED SPEED IN THE RUN ANIMATION AND REDUCE GRADUALLY
    frame    data/chars/heroes/blaze/sor2/idle00.png
    @cmd loadSpeed 2 2
    frame    data/chars/heroes/blaze/sor2/idle01.png
    @cmd loadSpeed 2 2
    frame    data/chars/heroes/blaze/sor2/idle02.png
    @cmd dasher 0 0 0
    frame    data/chars/heroes/blaze/sor2/idle03.png
    @cmd setEntityVar "runFlag" NULL() #CLEAR THE RUNFLAG
    #@cmd setIdle #SET ANIMATION TO IDLE
    @cmd aniframe openborconstant("ANI_IDLE") 6
    frame    data/chars/heroes/blaze/sor2/idle00.png

Code:
anim follow1 #Brake
    delay 10
    offset 128 243
    @cmd loadSpeed 8 8 #LOAD PREVIOUSLY SAVED SPEED IN THE RUN ANIMATION AND REDUCE GRADUALLY
    frame data/chars/xxxxxx/brake00.png
@cmd loadSpeed 8 8
    frame data/chars/xxxxxx/brake01.png
@cmd loadSpeed 8 8
    frame data/chars/xxxxxx/brake02.png
@cmd loadSpeed 8 8
    frame data/chars/xxxxxx/brake03.png
@cmd dasher 0 0 0
    frame data/chars/xxxxxx/brake04.png
@cmd setEntityVar "runFlag" NULL() #CLEAR THE RUNFLAG
    #@cmd setIdle #SET ANIMATION TO IDLE
@cmd aniframe3 openborconstant("ANI_IDLE") 9
    frame data/chars/xxxxxx/brake04.png

Code:
anim idle
    #loop 1
    delay 10
    offset 128 243
    # Idle A
@cmd animVar "runFlag" 1 openborconstant("ANI_FOLLOW1") #CHANGE TO THE BRAKE ANIMATION IF THE RUNFLAG IS 1
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0 #Normal turn
    frame data/chars/xxxxxx/idlea00.png #0
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea01.png #1
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea02.png #2
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea03.png #3
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea04.png #4
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea05.png #5
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea06.png #6
@cmd keyint openborconstant("ANI_FOLLOW6") 0 "B" 0 0
    frame data/chars/xxxxxx/idlea07.png #7
@cmd updateframe getlocalvar("self") 0
    frame data/chars/xxxxxx/idlea07.png #8

@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb00.png #9
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb01.png #10
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb02.png
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb03.png
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb04.png
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb05.png
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb06.png
@cmd keyint openborconstant("ANI_FOLLOW3") 0 "B" 0 0
    frame data/chars/xxxxxx/idleb07.png
@cmd updateframe getlocalvar("self") 9
    frame data/chars/xxxxxx/idleb07.png

Code:
anim follow3 #Alternate turn
    delay 4
    offset 128 243
    flipframe 2
@cmd stop
    frame data/chars/xxxxxx/turnb00.png
    frame data/chars/xxxxxx/turnb01.png
    frame data/chars/xxxxxx/idleb00.png
@cmd aniframe openborconstant("ANI_IDLE") 9
    frame data/chars/xxxxxx/idleb00.png

How can I enable its walk from switching alternate idle pose (in anim idle or anim follow) to anim walk like normal (with its respective movement)? When I tried pressing forward, up, or down to move anywhere except back, it only stays stuck without moving anywhere.
 
How can I enable its walk from switching alternate idle pose (in anim idle or anim follow) to anim walk like normal (with its respective movement)? When I tried pressing forward, up, or down to move anywhere except back, it only stays stuck without moving anywhere.
Nevermind. I solved it with a change to a follow animation using keyint (or a specified frame with anim idle) and put setidle in it. setidle does solve the problem for allowing to move freely.

Now I have another issue. When I do the run-jump, the character does the brake animation after landing instead of just switching to a jumpland animation. Do I need anim runjump and switch to jumpland anim under the last frame of runjump anim? Let me give it a try.
 
I tried to do the runjump anim and forced it on the last frame of that animation to set idle so there wouldn't be a brake animation after landing from runjump. However, no matter how many times I forced it to change from the follow animation which is brake, the character plays the follow animation without even performing anim jumpland. It seems that animVar function and runflag (under anim walk) make it to perform anim follow for a brake animation.

How can I make her perform a landing animation instead of just letting it play the brake (follow) animation? When I runjump and then land, the brake animation plays.
 
Everything is fine now. I solved it by clearing the flag of "runFlag" with 0. It halts the character from playing the brake animation on ground after runjumping. Not only did I add it in anim runjump, but anim jumpland as well.

Code:
anim jumpland
    delay 7
    offset 128 243
    @cmd spawn01 "smoke" -30 0 -1
    @cmd spawn01 "smoke" -10 0 1
    @cmd spawn01 "smoke"  30 0 -1
    @cmd spawn01 "smoke" 10 0 1
    frame data/chars/xxxxxx/jumpland00.png
    frame data/chars/xxxxxx/jumpland01.png
    frame data/chars/xxxxxx/jumpland02.png
    @cmd setEntityVar "runFlag" 0
    frame data/chars/xxxxxx/jumpland03.png
    
anim runjump
    delay 22
    offset 128 243
    loop 1 6 9
    landframe 9
    frame data/chars/xxxxxx/jump00.png
    delay 5
    frame data/chars/xxxxxx/jump01.png
    frame data/chars/xxxxxx/jump02.png
    frame data/chars/xxxxxx/jump03.png
    frame data/chars/xxxxxx/jump04.png
    frame data/chars/xxxxxx/jump05.png
    delay 4
    frame data/chars/xxxxxx/jumpdrop00.png
    frame data/chars/xxxxxx/jumpdrop01.png
    frame data/chars/xxxxxx/jumpdrop02.png
    @cmd setEntityVar "runFlag" 0 #CLEAR THE RUNFLAG
    frame data/chars/xxxxxx/jumpland00.png

It's all good, guys. I got it all solved.
 
Back
Top Bottom