How To Bring Your Character To Life In Vanda Engine – Part 2

In previous tutorial, you learned how to import a T-Pose mesh as well as its animations into Vanda Engine, setup its initial states, and save the character as prefab.

There are two different approaches for animations:

  • Looping Animation handled by BlendCycle() and ClearCycle()
  • One time animation handled by ExecuteAction and ReverseExecuteAction

In this tutorial, we use BlendCycle() and ClearCycle() to blend the animations of our character.

Inserting The Character

Run Vanda Engine. From the main menu, go to Prefab | Prefab Editor. Locate your character prefab and hit Insert button to insert your character into your level. In my case, Vanda Engine activates the stand animation of woman character. For more information about setting up the initial state of character, please refer to previous tutorial.

Adding A Light

I prefer to add a directional light to my level. From the main menu of Vanda Engine, go to Insert | Light…. Select directional light type, give your light a name, and specify a direction for your light. I prefer to insert my light in (10,10,10) position and choose a bright gray color. Hit OK button to insert your directional light into your level.


Inserting The Triggers

I’m going to insert three individual trigger into level. We will later assign our scripts to these triggers to activate stand, walk, and run animations of our character. Create your first box trigger by going to Insert | Trigger… menu, choose Trigger1 name, and press Create to add the trigger. Make sure that your trigger is still selected, go to Edit | Translate, and move your trigger to (-3, 0,2). Create two other triggers with the following properties:

  • Trigger2 => (0,0,2)
  • Trigger3 => (3,0,2)

Built-In Functions To Manage Animations

Before we write our scripts and assign them to our triggers, lets discuss about two important functions that deal with skeletal animations:


bool BlendCycle (char* prefabInstanceName, char* clipName, float weight, float delay)

This function interpolates the weight of an animation cycle to a new value in a given amount of time. If the specified animation cycle is not active yet, it is activated.


  • prefabInstanceName: The prefab instance name that its animation clip should be blended.
  • clipName: The clip name of the animation cycle that should be blended. If your scene does not contain animation clip, set this parameter to “defaultClip”.
  • weight:The weight to interpolate the animation cycle to.
  • delay:The time in seconds until the new weight should be reached.


One of the following values:

  • true if successful
  • false if an error happened
BlendCycle() plays the animation in loop. In order to play the animation only once, use ExecuteAction() instead.


bool ClearCycle (char* prefabInstanceName, char* clipName, float delay)

This function fades an animation cycle out in a given amount of time.


  • prefabInstanceName: The external scene name that its animation clip should be cleared.
  • clipName: The clip name of the animation cycle that should be cleared. If your scene does not contain animation clip, set this parameter to “defaultClip”.
  • delay: The time in seconds until the the animation cycle is completely removed.

One of the following values:

  • true if successful
  • false if an error happened
Vanda Engine supports what is called Animation blending. In summary, it means making a smooth transition between several animations on a single character. Vanda Engine also supports mixing several animations together. Simply activate two or more animations with BlendCycle() and they will be mixed together by Vanda Engine

Writing First Script

In tutorial 11, we discussed about Lua scripting language and its dedicated IDE (please refer to Lua Scripting Language section). Before we write our first script, lets find the appropriate names that should be passed to our functions. In my case, it’s called 1_Samples_Female.

Prefab Instance Name: Look at the upper right corner of the editor. Under Prefab section, you’ll find the name of your character instance. We will pass this name to first argument of BlendCycle() and ClearCycle() functions.


Animation Clip Name: Do you remember the animation files that we imported in previous tutorial? While importing an animation file, Vanda Engine creates an animation clip repository, names that animation clips based on the file name of animation file without .dae extension, and fills that animation clip with animation data imported from animation file. For example if your animation file name is walk.dae, your animation clip name will be walk. We will pass these animation clip names to the second argument of BlendCycle() and ClearCycle() functions.

Run sciTE, and write the following code to fade out the stand and sprint animations and fade in the walk animation:


This will fade out stand and sprint animation (if active) within 1 second and fade in the walk animation within 1 second. Save your script and make sure to include .lua extension at the end of your file name, return back to Vanda Engine, select Trigger1 object, hit Attach Script button, and in new dialog that appears, hit Trigger::Enter, locate Trigger1.lua and press Open. Vanda Engine should report that your trigger loaded successfully. Otherwise, return back to sciTE IDE, fix your script, and re-attach your script to Trigger1 trigger.


Now we play-test our new script. Make sure that Physics debug mode is enabled (Modify | General PhysX Options… | Debug Mode), hit Play button, and enter Trigger1 trigger. In my case, stand animation fades out in 1 second and simultaneously, walk animation fades in in 1 second. Because sprint animation is not active, the following function has no effect and returns false:

ClearCycle( “1_Samples_Female”, “Laura_sprint”, 1.0)

entering trigger 1 activates walk animation and deactivates stand animation

Similarly, write the following scripts to activate sprint or stand animations and attach them to enter events of trigger 2 and trigger 3:


Fade In sprint, Fade out stand and walk (if active)


Fade In stand, Fade out sprint and walk (if active)

(c) copyright Zehne Ziba Co., Ltd. For more information, please refer to copyright notice.

adminHow To Bring Your Character To Life In Vanda Engine – Part 2