From the course: Unity 5: 2D Level Design

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Code door animation events

Code door animation events - Unity Tutorial

From the course: Unity 5: 2D Level Design

Start my 1-month free trial

Code door animation events

- [Instructor] At this point, we have the animation for the door and the code for the door, but the two aren't connected. Let's select our door from the hierarchy, and go to the Animations window. We're going to want to trigger some of the methods in our class through the animation. We can take a look at each of the frames of our animation and pick the right moment to do this. We're going to focus primarily on enabling and disabling the Collider. Starting on the DoorOpenAnimation, let's select the second to last frame. And now we're going to add an event marker. Let's double-click on the event marker, and now we'll have a window that allows us to map an event in the timeline to a method call on the class attached to our game object. Let's go ahead and call DisableCollider2D, so as the door opens, we'll remove the Collider. Going over to the DoorCloseAnimation in the same place, let's go ahead and add another marker and here, we'll enable the Collider 2D. Now, let's go ahead and save…

Contents