• Register

A Little Less Desperation is an homage to the classic gems of the point & click adventure game genre. Sure it might not contain retro pixel art but it does include a load of wacky humor, eccentric characters & puzzles bordering on the fringe between logical & illogical.

Post tutorial Report RSS Dynamic Character Blink (on idle)

A few days ago (or so) the dev lead asked me to add dynamic blinking to the main character for the idle character animations. He wanted the character to blink at random intervals instead of at the end of each idle animation loop cycle. The solution ended up being pretty simple...

Posted by on - Basic Client Side Coding


First I started off by attaching the blink animation to the end of each of the idle animations & then I edited the first frame of each of the idle animations & created an execute a script action part containing...

if math.random(20) < 13 then
 ActiveAnimations["animation_name"].AnimationLastFrame = 16
else
 ActiveAnimations["animation_name"].AnimationLastFrame = 21
end

"animation_name" would be the name of the animation (I added a generic name to the code block). Also the number values are the amount of frames of the animation without & with the blink part of the animation. In this case frames 1-16 were the idle part of the animation & frames 17-21 was the blink part.

The little script above randomly generates a number between 1 & 20 & if the number is less than 13 then it will only play the idle part of the animation but if it equals 13 or more then it will play the idle part of the animation & then the blink part of the animation. This means that there is a 7 out of 20 chance that the character will blink at the end of the idle animations loop cycle.

In Visionaire Studio we can force which animation frames of an animation can be played by defining the initial & end frame using AnimationFirstFrame & AnimationLastFrame.

Pretty straightforward, no?

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: