Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that we've got states created in Mecanim, we can start to make transitions between and eventually script in some kind of interactivity for our character. We can do things like have that transition occur between states depending on character's proximity or tags. Before I get in to that though, I'd like to look at something that's been noticeable and maybe a little nagging in the scene. As you can see, I've got open an any state in the animator with a French door 20 swing. At some point, I had created this animation, and basically what we're seeing is that the default state for that French door number 20 is to swing.
And that's why that door is opening and closing, and opening and closing. Because there is no state set and no transition to, well, anything else, we end up seeing that animation over and over. I'm going to delete this animator controller off the door, as I'm controlling those doors through an activate trigger on a box collider. Now look at my Waiting Emmas. I'll scroll down here and select the Waiting Emmas in the hierarchy. I've got my state set up, and I'm going to set up a simple loop here. Running between still idle and a head turn.
What I'll do is to pick still idle, right-click and choose Set As Default. This way the first thing from an any state that Mecanim goes to is emma idling, just standing there. Now I'll make a transition, picking any state, right-clicking, choosing Make Transition and dragging onto still idle. Then I'll pick still idle, right click, Make Transition, and head turn. From head turn, I'll right click and make transition back to still idle. She'll idle for a sec, turn her head, then idle.
It'll animate just enough, we can gauge the repetitive motion and see if this is working. Now look at the transitions themselves. What happens is that the transition is governed by an exit time between events. What we can see here is that the exit time is 92% from head turn to still idle. That is, when head turn is 92% played, It will start to fade out and still idle will fade back in. We can adjust these transitions by dragging on the markers here on the timeline to pull those back and together. I'll run it so that it starts at 95 and out to 100. And then I'll look at the still idle the head turn transition as well. This one starts at zero and transitions out to head turn. We can either leave it alone or stretch them out further. I'm going to pull over head turn a little bit. Move the timeline over and stretch out the markers just a bit. Now I'll pull out head turn so that it barely overlaps.
There's just a little fade of head turn which is slow anyway. And we hold our still idle just a bit. I'll try this out and see how it looks. I can always add in more states and more conditions in our parameters. If you'd like to explore it further, in our parameters, we've got Float, Int, Bool, and Trigger. Float, accepting a floating point number, or Integer, an integer or enum. Boolean accepts well, a yes or no like a Boolean. And finally, a Trigger can be a triggered event. I'd highly recommend Sue Blackman's course on Mecanim in Unity as a terrific way to get deep in the inner workings of making Mecanim and characters really come to life. For this course though, we'll look at just having this character's head turned and just enough that it's noticeable the statue looks over at us. I'll test this out by going into my game and playing. And I'll navigate over and see if it turns, looks, and turns again here in my scene. I'll scroll forward, and there's the statue looking over, looking back and pausing, looking over, looking back and pausing. It's working terrifically. The transition is working, and I've set up my first tree in Mecanim. I'm ready to add in more states and more behaviors with additional scripting work. Now I'm ready to light up the space. I'll get the sunlight streaming in through the windows, and turn on the cam lights. And look at both light baking and light probes, as well working with all-dynamic light, and see what the differences are.
Get unlimited access to all courses for just $25/month.Become a member
100 Video lessons · 9995 Viewers
94 Video lessons · 27844 Viewers
83 Video lessons · 12798 Viewers
147 Video lessons · 6890 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.