Completing walk-cycle animation after character has stopped moving

Started by Quintaros, Sun 22/03/2015 23:10:22

Previous topic - Next topic

Quintaros

I have an NPC that is essentially a ball with a bouncing walk-cycle.  I figured there were two ways I could animate it: include the bounce in the walk cycle sprites or create the bounce by coding the characters z coordinate.  I tried the first approach with frame 0 and 47 being the character on the ground and frame 24 being the peak of its bounce.  But I run into a problem when the character stops moving and the animation goes to frame 0 of the walk-cycle regardless of what frame it was at when the character stopped. I tried the code below to complete the remaining frames in the cycle to bring it to the ground after it stops moving but even with this there is a momentary stutter of frame 0 displaying.

Code: ags

function repeatedly_execute() {


    if(cRover.Moving==true){
        RoverLastFrame=cRover.Frame;//global variable
        RoverWasWalking=true;//global variable
    }else if(RoverWasWalking==true){//Rover just finished walking
        if((RoverLastFrame>0)&&(RoverLastFrame<24)){// Rover is still ascending
          cRover.Frame=RoverLastFrame-1;
          RoverLastFrame=cRover.Frame;
        }else if((RoverLastFrame>=24)&&(RoverLastFrame<46)){// Rover has already begun his descent
          cRover.Frame=RoverLastFrame+1;
          RoverLastFrame=cRover.Frame;
        }else{
          RoverWasWalking=false;
        }           
    }
}


Anyone have any ideas to resolve this?

Monsieur OUXX

Are you sure these are "momentary stutters of frame 0"? Are you sure it's not that your artifical loop ending works well, but if the player starts moving again while the loop is still finishing (using your trick) then the ball is still up in the air when the walk animation starts playing from frame 0, hence the stutter?
 

Quintaros

Yes, I've just tested and confirmed that the stutter occurs at the point that the character stops moving before the coded loop completes the cycle. 

I'm not sure if there would be any impact but although the character will be an NPC in game I've been making the character playbable for testing the animation.

Snarky

That shouldn't matter.

I suspect this might be another instantiation of the problem where AGS updates character loops and positions AFTER your script runs but BEFORE the screen is rendered. If you manipulate those properties directly in script, that often means there will be one game cycle where it shows the wrong frame/position.

This problem is basically impossible to fully solve with AGS as it is. (I worked for weeks to create a complicated workaround in order to do custom scaling, but could never get it to work 100%.) However, Calin Leafshade made an experimental engine fix that lets you avoid it, and Crimson Wizard kindly built a custom version of 3.3.3 for me with it included. Since it's now been pretty thoroughly tested in the Awards client, I hope it will be included in the next AGS release. Meanwhile, you can get it from here: http://www.mediafire.com/download/jd86vdw6jxr6n5y/acwin_3.3.3--laterepexec.zip (just copy the exe file into an existing AGS 3.3.3 editor-installation directory, overwriting the one already there. Remember that it's still experimental, so backup your AGS installation and game projects first.) I hope CW doesn't mind that I share it; since it's open-source already I figure it's not a problem.

Then you'd just put your code in "late_repeatedly_execute_always()" instead of repeatedly_execute().

SMF spam blocked by CleanTalk