Difference between revisions of "Animation Tips and Tricks"

From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 37: Line 37:
 
This next tip is a bit of a tricky one, but it's one of my favorite methods for turn borning repetitive animations into animations that feel & look more natural by applying a dynamically generated duration value between specific animation frames - it also works a treat for adding a dynamic delay between animation loops.
 
This next tip is a bit of a tricky one, but it's one of my favorite methods for turn borning repetitive animations into animations that feel & look more natural by applying a dynamically generated duration value between specific animation frames - it also works a treat for adding a dynamic delay between animation loops.
  
1. select the animation frame you want to apply a dynamic duration to. edit the frame & open up the action
+
1. Select the animation frame you want to apply a dynamic duration to. Edit the animation frame via [[File:Anim_editframev2.png|16px|link=]] & open up the action modal box via [[File:Aktionenv2.png|16px|link=]].
  
[[File:Dynamic_duration_setup.gif|800px]]
+
2. Inside of the action modal box create a new action via [[File:Addv2.png|16px|link=]]. Now create a new '''execute a script''' action part & add something along the lines of this into it...
 +
 
 +
<syntaxhighlight lang="lua">
 +
Animations["example"].Pause = math.random(1000, 3000) -- set dynamic duration of frame between 1 & 3 seconds
 +
</syntaxhighlight>
 +
 
 +
3. Close the action modal box & the animation frame editor modal box & then select the animation to the right of the one you have just edited & repeat the same steps, except in the execute a script action part you want to reset the pause value back to whatever the global pause (duration) value is that you specified inside of the properties for the animation, which should look like something along the lines of this...
 +
 
 +
<syntaxhighlight lang="lua">
 +
Animations["example"].Pause = 40 -- change frame duration back to global pause (duration) value
 +
</syntaxhighlight>
 +
 
 +
& that's it. You can use this method on multiple animation frames or even specific ranges of animation frames. Have fun experimenting with dynamic frame durations & don't be afraid to get creative.
 +
 
 +
<html><iframe width="560" height="315" src="https://www.youtube.com/embed/TktQQfrbxLY" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></html>

Revision as of 18:14, 23 July 2022

On this page you will find a bunch of different tips & tricks that you can apply to animations that you have imported into the animation frame sequencer; some of these tips & tricks might be applicable to Spine sprite part animation models & 3D character models.

The whole point in this page is give you ideas on how you can optimize your animations & your game overall by reducing the amount of animation frames needed to create smooth looking animations.

Anyway, let's crack on...

What is the Animation Frame Sequencer?

I'm just going to assume that most of you already know what it is, but just in case you don't, it's the animation form you can find around various sections of the Visionaire Studio editor that let's you import or batch import animation frame images into the engine. By default you can control the global duration of the frames, the playback direction of the frames, & the amount of loops the animation should perform - however, we can get a lot more creative with what's possible via action parts, scripting, & some clever edits to the duration of individual frames.

Animation frame sequencer.png

Getting Started

Now before I go over the various animation tips & tricks, we need to setup a few things first that we will need further down the road for some of the methods listed below. This involves a bit of scripting, but don't worry it's nothing complicated. I just need you to navigate to the script section of the Visionaire Studio editor, create a new definition type script, rename it to workflow_functions, & then paste the code below into it.

math.randomseed( os.time() ) -- init math.random (make sure math.random is actually random each session)
math.random(); math.random(); math.random() -- shake things up a bit & make sure it is actually random

-- * function used to force animation frame range; i.e: frame 2 to 4 or frame 1 to 1, etc. * --
function setAnimFrames(anim, f, t) -- syntax: setAnimFrames(animation name, from, to)
  t = t or f -- fallback in cast t equals nil
  ActiveAnimations[anim].FirstFrame = f -- update from animation frame range
  ActiveAnimations[anim].LastFrame =  t -- update to animation frame range
end

Individual Frame Duration

By default animations will automatically use the global pause (duration) value specified in the properties section for the animation, however you can enable the option set pause for each frame, which will allow you to specify a unique duration value for each animation frame. Only frames that have a value other than -1 will be affected by this option. All frames that contain a value of -1 will use the global pause (duration) value.

Using this option lets you create dynamic looking animations where you can give your animations the appearance that they have some weight behind them. It's also a useful method for reducing the amount of animation frames you need to use for an animation, for example... let's say that you want a specific frame to play 3 times in a row, well in other programs you might need to import the same image 3 times to do that, but in Visionaire you can just adjust the duration of that specific animation to last 3x the global pause (duration) value.

Dynamic Frame Duration

This next tip is a bit of a tricky one, but it's one of my favorite methods for turn borning repetitive animations into animations that feel & look more natural by applying a dynamically generated duration value between specific animation frames - it also works a treat for adding a dynamic delay between animation loops.

1. Select the animation frame you want to apply a dynamic duration to. Edit the animation frame via Anim editframev2.png & open up the action modal box via Aktionenv2.png.

2. Inside of the action modal box create a new action via Addv2.png. Now create a new execute a script action part & add something along the lines of this into it...

Animations["example"].Pause = math.random(1000, 3000) -- set dynamic duration of frame between 1 & 3 seconds

3. Close the action modal box & the animation frame editor modal box & then select the animation to the right of the one you have just edited & repeat the same steps, except in the execute a script action part you want to reset the pause value back to whatever the global pause (duration) value is that you specified inside of the properties for the animation, which should look like something along the lines of this...

Animations["example"].Pause = 40 -- change frame duration back to global pause (duration) value

& that's it. You can use this method on multiple animation frames or even specific ranges of animation frames. Have fun experimenting with dynamic frame durations & don't be afraid to get creative.