Unity 3D – Animation calls Functions – Animation Events – JavaScript

Animation Events, which allow you to call functions in the object’s script at specified points in the timeline.

Official docs: http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html

1. Create a Cube

2. Attach Cube.js:

// This JavaScript function can be called by an Animation Event
function PrintFloat (theValue : float) {
    Debug.Log ("PrintFloat is called with a value of " + theValue);
}

3. Select the Cube GameObject, MAIN TOP MENU> Window> Animation> Animation Toolbar>
> Add Keyframe, create your animation
> Add Event, Select a function, setup a value

4. Play