In this video, we're going to look at how we can set different animation actions. The animation system for 3ds is quite sophisticated, and it allows you to blend actions together. If we look at our player control method, you'll see that we're setting an action simply by using its name. Recall when we load it in actions, we had a, an array of names. And we use that to create a full path to the FBX. exe file that contain that animation.
Once it was loaded in, we grab the first animation that we can find in the object and We assigned that to game player using the animation name. We now have a series of animations that we can reference simply by the name. So we play a dot wall called player dot run, player dot gather objects, player dot look around, are all available to us as possible animations. So how do we use those animations? Well, if you look here, once all the animations have loaded, we actually assign an animation simply by putting game dot action equals and the name of the animation. So how does that work?
Well, we're in a class, when you're in a class, you can use a setter or a getter. So when we call this dot action, what actually happens is this Functions called with the name passed in. So this dot action equals walk, we would come to this function with name equals walk, we get the animation that we stored in the player using that name. And we turn that into an action using the mixer as the animation mixer, the clip action method and they the animation that we're talking about. And then the root level bone to facilitate animations that don't loop. We set the action time to zero.
And then we stop all actions that are being played. One of our actions gather objects needs to only play once, and so we're going to deal with that slightly differently than anything anything else If it turns out our current action being played is gather objects that we must have an event listener needs deleted. Suppose the name is gather objects that we want to set the loop for this action to loop once. By default it loops indefinitely. We put a reference to a game. So we can use that.
And then we add an event listener for it. And we use the event finished. And then we call a function that uses our game objects, sets action equals a look around. So there was called this again, only this time, you'd be setting the action to look around. We saved the name of our current action. So we can use it to find out whether or not we're currently in an action called gather objects.
And we set out Fade In period to half a second. And then we play the animation. So that's going to blend over half a second, all the bones from the previous animation into this new animation that we've just set. So let's have a look at how that then works. Here we have the animation look around. It turns to walk.
Terry blends back, so stop, foot goes back. Doesn't matter where we stop below is go back to that point over half a second. You can actually set an action directly by using the console. Game action. Give it a name. There she is bending down to pick something up.
And at the end of that the animation finished shows that the event listener got cold and look around got sad. We could change it to run the she's running back to that the walk will take over. So very simple to be able to use multiple different animations and see them seamlessly blend into each other.