From the course: Unity Medical Visualization: 03 Deployment and Usability

Configuring a rotator object

- [Instructor] In this section of the course, we're going to be focusing on cinematics for our heart visualization. You can see in the viewport, we have our heart and right now, when I switch to the Game tab, the view we're getting of the heart is the view from the scene Main Camera. Now right now, this camera is not controllable in play mode. We can't directly control or move the camera to look at the heart from different angles. And I want to implement this kind of camera where we have user navigation and to so this, we're going to be using the Unity package, Cinemachine. Now, we imported this package way, way at the beginning of the course. You can always confirm that it's imported into your project by moving to the menu at the top and you'll see that we have Cinemachine. If you have an imported Cinemachine, you can simply move to the Window, choose Package Manager and import Cinemachine from there. For the rest of this movie and the rest of this section, I'll be using the imported Cinemachine tools. Now, I want to control the Main Camera here. We could, of course, write a script and attach it to this camera and control the camera directly and there's nothing wrong per se in doing that but Cinemachine gives us a lot of additional tools for controlling cameras and I'm going to be using those. In particular, I'm going to be creating a Cinemachine camera and we're going to be controlling that and that in turn will update and control this camera. To get started, I'm going to click on the Cinemachine menu and we get a range of different types of cameras that we can use. In this case, I'm going to be using the FreeLook Camera, which is the second option down. I'm going to choose Create FreeLook Camera. And this will go ahead and create a FreeLook camera that you can see here in the hierarchy. By default, it's named CM FreeLook1. Also, in adding this camera, the main camera has changed. Next to the Main Camera in the hierarchy, we have a Cinemachine icon. And when I select the camera and take a look in the Inspector and scroll all the way down to the bottom, you can see that Cinemachine has automatically added a CinemachineBrain component. This component intelligently links to the FreeLook camera that we've selected here and by controlling the FreeLook camera, we will control the Main Camera in turn. So we have the FreeLook camera here and this is known as a virtual camera because it's not a camera in itself but contains a whole bunch of properties that allow us to control cameras. Now, when I select this object, inside the Hierarchy panel, in factor, let me put the Scene and the Game tab side by side here. When I move this object around, you can see actually it's updating the camera in the scene, even though the camera is remaining where it is. I'm going to undo that here first of all. Take the FreeLook camera, select the rotation and set that to 180 degrees and then I can zoom the camera out here, the FreeLook camera in fact and I'm just going to position that around about here inside the scene. You can see the effect that's having here with the heart. I'm just going to center that up to kind of look at the heart here. Okay and that's looking pretty good. Now, I want this camera to focus on a center object and you can see here when I select the camera, in the Follow and the Look At parameters right now, no object is specified. I want my FreeLook camera to look basically at the heart. Now, rather than drag and drop the heart object into this section here, I'm going to create a new dedicated empty object, specifically for the purpose of being a target. To do that, I'm going to right click on the Heart object and simply create an empty object that I'm going to name as CameraTarget like so. I'm going to click on the cube icon to associate a nice big orange label so that I can see that inside the viewport and then position this empty object at the location where I want the camera to focus. So that's pretty much dead at the center of the heart. About there. I'll select my FreeLook camera here and for the following, I'll look at parameters. I'm going to drag and drop my camera target into those fields. Now, when I do this, the position and the location of the camera changes quite dramatically. That certainly isn't the view I want and we're going to be tweaking the settings to get the values that we need. But this is a really great setup. This is a really great beginning. We've created a virtual FreeLook camera and we've identified the target of that camera by creating an empty object. In the next movie, we're going to be tweaking the FreeLook camera even further.

Contents