edit: problem solved!
I am trying to make a third-person camera view control where the player place at middle of the screen, and when it lock-on to a target, place player at bottom-left of the screen and look at the target at middle of the screen.
I create a freelook camera and a virtual camera and switch its priority in each mode
(1) Freelook camera when there are no locked on target
- the player’s character rotate himself follow the camera’s rotation
(2) Virtual camera with Framing Tramposer and Composer
- the player’s character always look at the target every frame
Issue:
-when player switches back to freelook camera from the lock-on camera, it goes back to the rotation before lock-on is enabled, and that could even rotate the player itself
Sorry for my bad English. I feel like there are better way to do this but I’m stuck. If I’m in the wrong direction in the first place please guide me…
Screenshot of the setting:
Code that switch between two camera:
void LockOnTriggered()
{
if (!lockOnMode)
{
//change to lock on mode if the camera can find a target
lockOnTarget = FindTarget();
if (lockOnTarget != null)
{
lockOnCamera.Priority = 1;
freeLookCamera.Priority = 0;
lockOnMode = true;
//set aiming target
lockOnCamera.LookAt = GetCameraFocusAvailable(lockOnTarget);
}
}
else
{
//back to default
lockOnCamera.Priority = 0;
freeLookCamera.Priority = 1;
lockOnCamera.LookAt = null;
lockOnTarget = null;
lockOnMode = false;
//reset free look camera's rotation
--------Change the rotation of freelook camera here----------
}
//Canvas
Reticle.SetActive(lockOnMode);
}