1 00:00:00,249 --> 00:00:02,445 The animation view allows you to create and 2 00:00:02,445 --> 00:00:06,040 modify animation clips directly inside Unity. 3 00:00:06,595 --> 00:00:08,595 It is designed to act as a powerful 4 00:00:08,595 --> 00:00:10,595 and straightforward alternative to external 5 00:00:10,595 --> 00:00:12,595 3D animation programmes. 6 00:00:13,772 --> 00:00:15,772 For instance, if we wanted to have 7 00:00:15,772 --> 00:00:17,772 a camera fly around a scene to give 8 00:00:17,772 --> 00:00:20,186 a player an overview of a level 9 00:00:20,186 --> 00:00:23,313 we can create that animation for it in Unity. 10 00:00:24,794 --> 00:00:26,794 Here we have a scene with a camera 11 00:00:26,794 --> 00:00:28,040 in the corner. 12 00:00:29,018 --> 00:00:31,018 We would like to create an animation 13 00:00:31,018 --> 00:00:33,512 for that camera which will allow it to move 14 00:00:33,512 --> 00:00:36,129 from one side of the scene to the other. 15 00:00:36,965 --> 00:00:38,965 Since we want to make an animation for the 16 00:00:38,965 --> 00:00:40,965 camera we will want to ensure 17 00:00:40,965 --> 00:00:43,986 that it is selected in the Hierarchy view. 18 00:00:44,652 --> 00:00:46,955 We can then open the Animation view 19 00:00:46,955 --> 00:00:49,356 by clicking Window - Animation. 20 00:00:50,477 --> 00:00:53,015 Like any other view this is moveable 21 00:00:53,015 --> 00:00:55,015 resizable and dockable. 22 00:00:55,805 --> 00:00:57,805 There are many different buttons and options 23 00:00:57,805 --> 00:01:00,723 visible when you first open the Animation view. 24 00:01:01,355 --> 00:01:04,862 First and foremost is the animation drop-down. 25 00:01:04,862 --> 00:01:06,572 Here is where we can select our different 26 00:01:06,572 --> 00:01:08,252 animations to edit. 27 00:01:08,906 --> 00:01:11,404 Since we don't currently have any animations 28 00:01:11,404 --> 00:01:13,404 this drop-down is blank except for the 29 00:01:13,404 --> 00:01:15,974 ability to create a new animation. 30 00:01:17,907 --> 00:01:19,907 When you create a new animation you will 31 00:01:19,907 --> 00:01:22,447 be prompted for a name and a location 32 00:01:22,447 --> 00:01:24,447 to save the animation file. 33 00:01:25,140 --> 00:01:27,140 We will create an animation called 34 00:01:27,140 --> 00:01:29,140 CameraFlyThu and place it 35 00:01:29,140 --> 00:01:31,140 in the Animations folder. 36 00:01:32,496 --> 00:01:34,426 The Add Curve button allows us to choose 37 00:01:34,426 --> 00:01:36,148 which components of our object, 38 00:01:36,148 --> 00:01:38,148 or any child objects, we wish to modify 39 00:01:38,148 --> 00:01:40,148 with our animation. 40 00:01:41,090 --> 00:01:43,020 Each component can be expanded 41 00:01:43,020 --> 00:01:45,020 to view more options. 42 00:01:45,520 --> 00:01:47,982 To add a curve click the + sign next 43 00:01:47,982 --> 00:01:49,692 to the item you wish to add. 44 00:01:50,192 --> 00:01:52,748 Since we want our camera to fly around the scene 45 00:01:52,748 --> 00:01:56,847 we will add the transform's position and rotation. 46 00:01:57,969 --> 00:01:59,969 The timeline is where you will be able to 47 00:01:59,969 --> 00:02:02,786 establish the timing of your animation. 48 00:02:02,786 --> 00:02:05,408 The timeline is measured in frames and seconds. 49 00:02:06,004 --> 00:02:08,152 The red scrubber allows you to choose what 50 00:02:08,152 --> 00:02:10,152 frame you wish to modify. 51 00:02:12,171 --> 00:02:14,700 Next is the Record and Play buttons. 52 00:02:15,085 --> 00:02:16,920 When the record button is pressed 53 00:02:16,920 --> 00:02:18,529 changes made to the chosen object 54 00:02:18,529 --> 00:02:21,336 in the Scene view will be added automatically 55 00:02:21,336 --> 00:02:24,345 to the animation at the currently selected frame. 56 00:02:25,714 --> 00:02:27,949 The play button will allow you to preview 57 00:02:27,949 --> 00:02:29,249 your animation. 58 00:02:30,670 --> 00:02:32,409 The left and right arrows allow you to 59 00:02:32,409 --> 00:02:34,930 navigate through the keyframes of the animation. 60 00:02:35,696 --> 00:02:37,847 Next are the buttons which allow you to 61 00:02:37,847 --> 00:02:39,847 add keyframes and events to the 62 00:02:39,847 --> 00:02:41,847 currently selected frame. 63 00:02:42,430 --> 00:02:44,430 The Sample property determines how many 64 00:02:44,430 --> 00:02:46,747 frames make up one second of animation. 65 00:02:47,192 --> 00:02:50,618 Reducing this number makes our animations slower. 66 00:02:52,057 --> 00:02:54,057 At the bottom are two buttons that allow 67 00:02:54,057 --> 00:02:56,777 you to transition between dope sheet mode, 68 00:02:56,777 --> 00:02:58,447 which we are currently on, 69 00:02:58,447 --> 00:03:00,447 and curve view mode. 70 00:03:01,541 --> 00:03:03,541 With the record button pressed 71 00:03:03,541 --> 00:03:05,803 it can be very easy to rough out the animation 72 00:03:05,803 --> 00:03:07,081 that we want. 73 00:03:07,698 --> 00:03:10,306 Simply select the frame we want to modify 74 00:03:12,306 --> 00:03:14,802 and rotation in the scene view. 75 00:03:10,306 --> 00:03:12,306 and then set the desired camera position 76 00:03:15,306 --> 00:03:17,540 You will notice that a keyframe has been added 77 00:03:17,540 --> 00:03:20,149 to the timeline with the appropriate values. 78 00:03:20,883 --> 00:03:22,883 Properties that are currently being animated 79 00:03:22,883 --> 00:03:25,588 are highlighted in red in the Inspector. 80 00:03:27,054 --> 00:03:29,941 We can continue doing this for the various phases 81 00:03:29,941 --> 00:03:31,941 of our fly through animation. 82 00:03:33,325 --> 00:03:35,463 To preview the animation click the 83 00:03:35,463 --> 00:03:38,116 play icon next to the record icon 84 00:03:38,116 --> 00:03:40,116 in the animator view. 85 00:03:41,776 --> 00:03:44,381 If we were satisfied with our animation 86 00:03:44,381 --> 00:03:46,381 we could be done now. 87 00:03:46,381 --> 00:03:49,297 If we wanted to fine tune our animation however 88 00:03:49,297 --> 00:03:51,717 we would want to look at the curves mode. 89 00:03:52,253 --> 00:03:55,364 To enter the curves mode select the Curves button 90 00:03:55,364 --> 00:03:58,082 at the bottom of the animation view. 91 00:03:59,010 --> 00:04:01,010 Here we can see the various curves of our 92 00:04:01,010 --> 00:04:03,497 animation by selecting the corresponding 93 00:04:03,497 --> 00:04:05,677 component on the left. 94 00:04:05,677 --> 00:04:08,771 Again we can select a frame using the red 95 00:04:08,771 --> 00:04:10,771 red scrubber on the timeline. 96 00:04:13,509 --> 00:04:15,605 To modify a value on a curve 97 00:04:15,605 --> 00:04:17,605 click and drag a keyframe to the new 98 00:04:17,605 --> 00:04:19,479 desired value. 99 00:04:19,479 --> 00:04:21,852 To create a new keyframe click the 100 00:04:21,852 --> 00:04:23,742 Create Keyframe button, 101 00:04:23,742 --> 00:04:25,742 or double click on the curve. 102 00:04:26,974 --> 00:04:28,779 Right-clicking on a keyframe will pull up 103 00:04:28,779 --> 00:04:30,695 some of it's options. 104 00:04:30,695 --> 00:04:32,695 the most notable of these options is the ability 105 00:04:32,695 --> 00:04:34,695 to choose Free Smooth. 106 00:04:35,278 --> 00:04:37,830 This will create two handles are the keyframe 107 00:04:37,830 --> 00:04:39,830 which you can use to smooth the curve 108 00:04:39,830 --> 00:04:41,830 to your liking. 109 00:04:42,786 --> 00:04:44,786 Another way to control our curves is to 110 00:04:44,786 --> 00:04:46,786 choose the Broken option. 111 00:04:47,949 --> 00:04:49,687 This allows you to control each side of the 112 00:04:49,687 --> 00:04:51,687 keyframe indecently. 113 00:04:52,960 --> 00:04:55,400 In this example we will want to add 114 00:04:55,400 --> 00:04:56,986 a little variance to the exposition 115 00:04:56,986 --> 00:04:58,791 of the transform. 116 00:04:58,791 --> 00:05:01,205 Doing so will give us more of a weightless feel 117 00:05:01,205 --> 00:05:03,205 to our animation. 118 00:05:04,492 --> 00:05:07,323 Again we can do so by creating keyframes 119 00:05:07,323 --> 00:05:09,323 on the exposition curve and changing 120 00:05:09,323 --> 00:05:11,323 our values manually. 121 00:05:13,356 --> 00:05:16,192 The animations created in Unity have the same 122 00:05:16,192 --> 00:05:18,555 Inspector settings as animations made 123 00:05:18,555 --> 00:05:20,237 in external programmes. 124 00:05:20,654 --> 00:05:22,403 We can see these by selecting our clip 125 00:05:22,403 --> 00:05:24,636 in the Project view. 126 00:05:24,636 --> 00:05:26,319 Since we want our camera to fly across the 127 00:05:26,319 --> 00:05:29,278 screen only once, we best uncheck 128 00:05:29,278 --> 00:05:31,278 are Loop Time property. 129 00:05:32,441 --> 00:05:34,828 It is interesting to note that an animator 130 00:05:34,828 --> 00:05:36,828 is in charge of animation playback for generic 131 00:05:36,828 --> 00:05:39,463 objects the same as it is for humanoids. 132 00:05:40,184 --> 00:05:42,184 Unity has automatically added the 133 00:05:42,184 --> 00:05:44,543 animator to our camera and created an 134 00:05:44,543 --> 00:05:47,113 animator controller, a state machine 135 00:05:47,113 --> 00:05:49,113 and added it to this component 136 00:05:50,000 --> 00:05:52,477 The clip we just created is added to the 137 00:05:52,477 --> 00:05:54,477 state machine as the default clip 138 00:05:54,477 --> 00:05:56,477 that would be played at runtime. 139 00:05:57,695 --> 00:05:59,695 This means we can go on to record 140 00:05:59,695 --> 00:06:01,695 other clips and use the animator 141 00:06:01,695 --> 00:06:03,695 to decide when to play them. 142 00:06:04,195 --> 00:06:06,473 In this manner, once our animation clip 143 00:06:06,473 --> 00:06:08,952 is completed we can run our scene 144 00:06:08,952 --> 00:06:10,952 to see it in action.