Camera Controller: Switching Targets

allstar602

New member
Hello,

In my game, I switch between different Character Controllers as one of our main mechanics. I am using the Camera Controller's Character property to swap to the new character. Here is a snippet:
Code:
CameraController cameraController = camera.gameObject.GetCachedComponent<CameraController>();
cameraController.Character = form.FormTransform.gameObject;

Using this code, I am able to make it switch to the new character, but I would like the transition to be smoother. I was wondering if there was a built in way to switch between targets smoothly, or perhaps keep the same rotation of the camera.

Here is a short video:

 
When you switch targets the camera instantly snaps to the new target. In order to have it smoothly transition I would create a new view type that moves to the new character and then sets the character property. Take a look at this page for the view type api:

 
@Justin Thanks for the suggestion. I spent a couple days learning the View Type system and implementing my own. I figured out I could take advantage of the "Transition" view type to smoothly move the camera to the new character.

So I lock the view, switch the character, and switch back to the Adventure view type:
Code:
//Lock the camera
cameraController.SetViewType(typeof(Locked), false);
//Get the camera and set new target
cameraController.Character = form.FormTransform.gameObject;
//Unlock the camera
cameraController.SetViewType(typeof(Adventure), false);

There is one issue with it. The transition doesn't kick in until I run this code a second time. Seems like an initialization issue with the second character.

Here is a video of the change:


It looks nicer, but I would prefer to keep the Yaw and Pitch values of the camera as I am switching. I tried storing the yaw/pitch of the view type before switching targets, then setting them back afterwards, but this creates a flicker when transitioning.
 
So Locked is the new view type that does the transition? If the Locked view type is transitioning towards the target location of the adventure view type then after the character has been set you should be able to set the second parameter to true within SetViewType. This will instantly move the camera to that position, but since it is already at that position there won't be any jitter.
 
Top