WEBVTT 00:00:00.249 --> 00:00:02.445 The animation view allows you to create and 00:00:02.445 --> 00:00:06.040 modify animation clips directly inside Unity. 00:00:06.595 --> 00:00:08.595 It is designed to act as a powerful 00:00:08.595 --> 00:00:10.595 and straightforward alternative to external 00:00:10.595 --> 00:00:12.595 3D animation programmes. 00:00:13.772 --> 00:00:15.772 For instance, if we wanted to have 00:00:15.772 --> 00:00:17.772 a camera fly around a scene to give 00:00:17.772 --> 00:00:20.186 a player an overview of a level 00:00:20.186 --> 00:00:23.313 we can create that animation for it in Unity. 00:00:24.794 --> 00:00:26.794 Here we have a scene with a camera 00:00:26.794 --> 00:00:28.040 in the corner. 00:00:29.018 --> 00:00:31.018 We would like to create an animation 00:00:31.018 --> 00:00:33.512 for that camera which will allow it to move 00:00:33.512 --> 00:00:36.129 from one side of the scene to the other. 00:00:36.965 --> 00:00:38.965 Since we want to make an animation for the 00:00:38.965 --> 00:00:40.965 camera we will want to ensure 00:00:40.965 --> 00:00:43.986 that it is selected in the Hierarchy view. 00:00:44.652 --> 00:00:46.955 We can then open the Animation view 00:00:46.955 --> 00:00:49.356 by clicking Window - Animation. 00:00:50.477 --> 00:00:53.015 Like any other view this is moveable 00:00:53.015 --> 00:00:55.015 resizable and dockable. 00:00:55.805 --> 00:00:57.805 There are many different buttons and options 00:00:57.805 --> 00:01:00.723 visible when you first open the Animation view. 00:01:01.355 --> 00:01:04.862 First and foremost is the animation drop-down. 00:01:04.862 --> 00:01:06.572 Here is where we can select our different 00:01:06.572 --> 00:01:08.252 animations to edit. 00:01:08.906 --> 00:01:11.404 Since we don't currently have any animations 00:01:11.404 --> 00:01:13.404 this drop-down is blank except for the 00:01:13.404 --> 00:01:15.974 ability to create a new animation. 00:01:17.907 --> 00:01:19.907 When you create a new animation you will 00:01:19.907 --> 00:01:22.447 be prompted for a name and a location 00:01:22.447 --> 00:01:24.447 to save the animation file. 00:01:25.140 --> 00:01:27.140 We will create an animation called 00:01:27.140 --> 00:01:29.140 CameraFlyThu and place it 00:01:29.140 --> 00:01:31.140 in the Animations folder. 00:01:32.496 --> 00:01:34.426 The Add Curve button allows us to choose 00:01:34.426 --> 00:01:36.148 which components of our object, 00:01:36.148 --> 00:01:38.148 or any child objects, we wish to modify 00:01:38.148 --> 00:01:40.148 with our animation. 00:01:41.090 --> 00:01:43.020 Each component can be expanded 00:01:43.020 --> 00:01:45.020 to view more options. 00:01:45.520 --> 00:01:47.982 To add a curve click the + sign next 00:01:47.982 --> 00:01:49.692 to the item you wish to add. 00:01:50.192 --> 00:01:52.748 Since we want our camera to fly around the scene 00:01:52.748 --> 00:01:56.847 we will add the transform's position and rotation. 00:01:57.969 --> 00:01:59.969 The timeline is where you will be able to 00:01:59.969 --> 00:02:02.786 establish the timing of your animation. 00:02:02.786 --> 00:02:05.408 The timeline is measured in frames and seconds. 00:02:06.004 --> 00:02:08.152 The red scrubber allows you to choose what 00:02:08.152 --> 00:02:10.152 frame you wish to modify. 00:02:12.171 --> 00:02:14.700 Next is the Record and Play buttons. 00:02:15.085 --> 00:02:16.920 When the record button is pressed 00:02:16.920 --> 00:02:18.529 changes made to the chosen object 00:02:18.529 --> 00:02:21.336 in the Scene view will be added automatically 00:02:21.336 --> 00:02:24.345 to the animation at the currently selected frame. 00:02:25.714 --> 00:02:27.949 The play button will allow you to preview 00:02:27.949 --> 00:02:29.249 your animation. 00:02:30.670 --> 00:02:32.409 The left and right arrows allow you to 00:02:32.409 --> 00:02:34.930 navigate through the keyframes of the animation. 00:02:35.696 --> 00:02:37.847 Next are the buttons which allow you to 00:02:37.847 --> 00:02:39.847 add keyframes and events to the 00:02:39.847 --> 00:02:41.847 currently selected frame. 00:02:42.430 --> 00:02:44.430 The Sample property determines how many 00:02:44.430 --> 00:02:46.747 frames make up one second of animation. 00:02:47.192 --> 00:02:50.618 Reducing this number makes our animations slower. 00:02:52.057 --> 00:02:54.057 At the bottom are two buttons that allow 00:02:54.057 --> 00:02:56.777 you to transition between dope sheet mode, 00:02:56.777 --> 00:02:58.447 which we are currently on, 00:02:58.447 --> 00:03:00.447 and curve view mode. 00:03:01.541 --> 00:03:03.541 With the record button pressed 00:03:03.541 --> 00:03:05.803 it can be very easy to rough out the animation 00:03:05.803 --> 00:03:07.081 that we want. 00:03:07.698 --> 00:03:10.306 Simply select the frame we want to modify 00:03:12.306 --> 00:03:14.802 and rotation in the scene view. 00:03:10.306 --> 00:03:12.306 and then set the desired camera position 00:03:15.306 --> 00:03:17.540 You will notice that a keyframe has been added 00:03:17.540 --> 00:03:20.149 to the timeline with the appropriate values. 00:03:20.883 --> 00:03:22.883 Properties that are currently being animated 00:03:22.883 --> 00:03:25.588 are highlighted in red in the Inspector. 00:03:27.054 --> 00:03:29.941 We can continue doing this for the various phases 00:03:29.941 --> 00:03:31.941 of our fly through animation. 00:03:33.325 --> 00:03:35.463 To preview the animation click the 00:03:35.463 --> 00:03:38.116 play icon next to the record icon 00:03:38.116 --> 00:03:40.116 in the animator view. 00:03:41.776 --> 00:03:44.381 If we were satisfied with our animation 00:03:44.381 --> 00:03:46.381 we could be done now. 00:03:46.381 --> 00:03:49.297 If we wanted to fine tune our animation however 00:03:49.297 --> 00:03:51.717 we would want to look at the curves mode. 00:03:52.253 --> 00:03:55.364 To enter the curves mode select the Curves button 00:03:55.364 --> 00:03:58.082 at the bottom of the animation view. 00:03:59.010 --> 00:04:01.010 Here we can see the various curves of our 00:04:01.010 --> 00:04:03.497 animation by selecting the corresponding 00:04:03.497 --> 00:04:05.677 component on the left. 00:04:05.677 --> 00:04:08.771 Again we can select a frame using the red 00:04:08.771 --> 00:04:10.771 red scrubber on the timeline. 00:04:13.509 --> 00:04:15.605 To modify a value on a curve 00:04:15.605 --> 00:04:17.605 click and drag a keyframe to the new 00:04:17.605 --> 00:04:19.479 desired value. 00:04:19.479 --> 00:04:21.852 To create a new keyframe click the 00:04:21.852 --> 00:04:23.742 Create Keyframe button, 00:04:23.742 --> 00:04:25.742 or double click on the curve. 00:04:26.974 --> 00:04:28.779 Right-clicking on a keyframe will pull up 00:04:28.779 --> 00:04:30.695 some of it's options. 00:04:30.695 --> 00:04:32.695 the most notable of these options is the ability 00:04:32.695 --> 00:04:34.695 to choose Free Smooth. 00:04:35.278 --> 00:04:37.830 This will create two handles are the keyframe 00:04:37.830 --> 00:04:39.830 which you can use to smooth the curve 00:04:39.830 --> 00:04:41.830 to your liking. 00:04:42.786 --> 00:04:44.786 Another way to control our curves is to 00:04:44.786 --> 00:04:46.786 choose the Broken option. 00:04:47.949 --> 00:04:49.687 This allows you to control each side of the 00:04:49.687 --> 00:04:51.687 keyframe indecently. 00:04:52.960 --> 00:04:55.400 In this example we will want to add 00:04:55.400 --> 00:04:56.986 a little variance to the exposition 00:04:56.986 --> 00:04:58.791 of the transform. 00:04:58.791 --> 00:05:01.205 Doing so will give us more of a weightless feel 00:05:01.205 --> 00:05:03.205 to our animation. 00:05:04.492 --> 00:05:07.323 Again we can do so by creating keyframes 00:05:07.323 --> 00:05:09.323 on the exposition curve and changing 00:05:09.323 --> 00:05:11.323 our values manually. 00:05:13.356 --> 00:05:16.192 The animations created in Unity have the same 00:05:16.192 --> 00:05:18.555 Inspector settings as animations made 00:05:18.555 --> 00:05:20.237 in external programmes. 00:05:20.654 --> 00:05:22.403 We can see these by selecting our clip 00:05:22.403 --> 00:05:24.636 in the Project view. 00:05:24.636 --> 00:05:26.319 Since we want our camera to fly across the 00:05:26.319 --> 00:05:29.278 screen only once, we best uncheck 00:05:29.278 --> 00:05:31.278 are Loop Time property. 00:05:32.441 --> 00:05:34.828 It is interesting to note that an animator 00:05:34.828 --> 00:05:36.828 is in charge of animation playback for generic 00:05:36.828 --> 00:05:39.463 objects the same as it is for humanoids. 00:05:40.184 --> 00:05:42.184 Unity has automatically added the 00:05:42.184 --> 00:05:44.543 animator to our camera and created an 00:05:44.543 --> 00:05:47.113 animator controller, a state machine 00:05:47.113 --> 00:05:49.113 and added it to this component 00:05:50.000 --> 00:05:52.477 The clip we just created is added to the 00:05:52.477 --> 00:05:54.477 state machine as the default clip 00:05:54.477 --> 00:05:56.477 that would be played at runtime. 00:05:57.695 --> 00:05:59.695 This means we can go on to record 00:05:59.695 --> 00:06:01.695 other clips and use the animator 00:06:01.695 --> 00:06:03.695 to decide when to play them. 00:06:04.195 --> 00:06:06.473 In this manner, once our animation clip 00:06:06.473 --> 00:06:08.952 is completed we can run our scene 00:06:08.952 --> 00:06:10.952 to see it in action.