Home Tutorials Download Beta Store Forum Documentation KnowledgeBase Wiki Blog
Main Page About Help FAQ Special pages Log in

An Introduction to AnimClips

From ShiVa Wiki

Using animClips for simple Objects like Sliding Doors

Select the object you want to animate in the Scene Viewer.

Right click on the Object > Controllers > Animation > Create an AnimBank


Select the "Animation" Desktop (or Tab) in Shiva. The AnimBank you created should be opened in the AnimBank Editor.

From the Animbank Editor, click Edit > Create AnimClip


An AnimClip will be created and opened in the AnimClip Editor. The AnimClip will be added to the existing AnimBank with an AnimClip index of 0, as seen in the AnimBank Editor.

Now, in the AnimClip Editor: Only 1 channel, "Default", is created. Right click the channel name and select "Edit Channel". Chose Translation, Rotation, and Scale depending on which of these you will be animating.


Make sure the object you want to animate is still selected in the Scene Viewer, go to the Attributes Editor and click "Animation Controller". Here you will need to set which Channel the object will use. By default, this will be set to None, change it to the channel we want to use, "Default".


In the AnimClip Editor, select the channel. There are 9 tracks total: X, Y, Z for Translation X, Y, Z for Rotation X, Y, Z for Scale

You can easily show or hide tracks using the TRS and XYZ buttons on the Track Toolbar.

Now select the track(s) that you want to animate.


By default, the AnimClip will have a Key Range of 0 - 0. 30 frames is 1 second in the game so an animation with a Key Range of 0 - 59 will take 2 seconds to play. The animation will start at Key 0 so make sure your object is in the position you want it to be at the beginning of the animation.

With the track(s) selected, Press K, OR click Track > Add Point at Cursor.


This animation is going to be one second, 30 frames, so zoom out on the graph using the mouse scroll until you can see the number 30. Now click on the frame slider and slide it up to frame 30.


Now we need to move the object into the final position it will be in at the end of the animation. Make TRS changes in the Scene Viewer then come back into the AnimClip Editor and make sure the correct track(s) are still selected.

With the track(s) selected, Press K, OR click Track > Add Point at Cursor.

Now there should be 2 keys: 1 key at the beginning (frame 0) and 1 key at the end (frame 30).


Don't forget to save the AnimClip and clip play to test it!

ShiVa Script and AI Model

Create an AI Model for your object. From the Scene Viewer select your object then Right Click > Controllers > AI > Create AI.

My AI Model has 1 variable, 1 function, and 2 handlers:

bOpen: Boolean variable to track whether the door is open or not

setupAnimations: Function to setup the animation defaults

onActivateDoor: Custom Handler to toggle between the 2 animations

onInit: onInit only has 1 purpose, to call function setupAnimations

function AI_Door.setupAnimations ( )

   local hObject = this.getObject ( )
   if ( object.hasController ( hObject, object.kControllerTypeAnimation ) )
       animation.setCurrentClip            ( hObject, 0,  0 )
       animation.setPlaybackMode           ( hObject, 0,  animation.kPlaybackModeOnce )
       animation.setPlaybackLevel          ( hObject, 0,  0 )
       animation.setCurrentClip            ( hObject, 1,  1 )
       animation.setPlaybackMode           ( hObject, 1,  animation.kPlaybackModeOnce )
       animation.setPlaybackLevel          ( hObject, 1,  0 )


function AI_Door.onActivateDoor ( )

   local hObject = this.getObject ( )
   if ( this.bOpen ( ) )
       -- Set Close to 1 and Open to 0
       animation.setPlaybackLevel ( hObject, 0, 0 )
       animation.setPlaybackLevel ( hObject, 1, 1 )
       -- Move the Playback Cursor (position) back to 0
       animation.setPlaybackCursor ( hObject, 1, 0 )
       this.bOpen ( false )
       -- Set Close to 0 and Open to 1
       animation.setPlaybackLevel ( hObject, 1, 0 )
       animation.setPlaybackLevel ( hObject, 0, 1 )
       -- Move the Playback Cursor (position) back to 0
       animation.setPlaybackCursor ( hObject, 0, 0 )
       this.bOpen ( true )


function AI_Door.onInit ( )

   this.setupAnimations ( )


Credits and Further Reading

Created by forum user Selzier
Link to the original forum thread

Retrieved from "http://www.stonetrip.com/developer/wiki/index.php?title=An_Introduction_to_AnimClips"

This page has been accessed 2,270 times. This page was last modified on 19 March 2012, at 19:16.