How to change freelook rig to face a gameobject.

I have a basic 3rd person shooter freelook camera rig set up. What I want to do is force the player’s view to lock onto a target when the key is pressed. It is not as simple as changing the target look at because I want to conserve the third person shooter look at transform set up.

Basically I would like to go from this


To this :

on the click of a button

It requires more than just changing the look-at target. Really LockOn and FreeLook are completely different camera behaviours, so the way to do it is to implement 2 cameras and swap between them (allowing CM to execute a blend).

This tutorial is pretty good:

What version of Unity are you using? I ask because if it’s 2022.3 or up and you’re just starting to use Cinemachine, it might be a good moment to upgrade CM to version 3.0.1. CM3 comes with a Lock-on Target sample scene that you can look at.

1 Like

Aweomse thank you Gregory. I actuallt had seen this video before but I don’t to lock onto my target. I would like my perspective and lookat to remain the same. What I’m looking for is an “aim lock on” that can serve as a feature in a third person shooter without a perspective change

Something like this?

9752251--1395814--aim_mode.gif

Something like this but that would auto aim to one of the players as well

You’ll have to describe more carefully what you want, because I don’t really understand.

The way the sample illustrated by my image works, there are 2 camera modes: freelook and aim. In freelook mode, the camera can orbit around the player and face any direction, regardless of which way the player is facing. In aim mode, the camera forward is locked to player forward. Rotating the camera rotates the player. When the player fires while in aim mode, it will hit whatever is under the reticle at screen center. If you enter aim mode while the player is looking in some other direction, the player will rotate to face camera forward.

How is what you want different?

Yes sorry for not explaining very well. my character is always in the aim mode. But I want the crosshair which is in the middle of the screen to align with the targeted object (in my example the sphere) while still being in the player’s rig. So basically something that could simulate the freelook input to adjust the aiming towards a specific target.

What exactly is your setup? Can you show the vcam inspector?

Finally I managed to solve my issue by switching over from a freecam to a Virtual cam with a third person body. Thank you for your help.