Free Look Camera

Hi all. Alright this may or may not be direct, depending on whose responding, but I want my Cinemachine to be a freelook camera, where I can press the WASD/Arrow keys to be able to look around the player, by rotating the camera, at a full 360 degree horizontal angle, and a clamped angle to the floor of the player (i.e: I don’t want the camera going from right under the player… :stuck_out_tongue_winking_eye: ). There’s some stuff my mouse can’t click on in-game, and my Raycaster just won’t debate to look under it for the land that can be clicked (not expecting it to, but I want to rotate my camera so this doesn’t become a problem for my game)

I saw an old tutorial regarding that, but it caused me some significant issues rather than results. I’m using Unity 2021.3.21f1 LTS

Or at the very least, I seek a script that makes stuff smoothly vanish when the camera collides with it, and then smoothly re-appear when the camera goes beyond it (ahh… this is a bit hard to explain, but I hope you get my point)

How do we go around this?

You’ll start with a script like this:

using System;
using UnityEngine;
using UnityEngine.EventSystems;

namespace RPG.Cinematics
    public class CameraPivot : MonoBehaviour
        [SerializeField] private float rotationSpeed;
        private Vector2 lastScreenPosition;
        private bool isDragging = false;
        private Transform player;
        private void Awake()
            player = GameObject.FindWithTag("Player").transform;

        void Update()
            transform.position = player.position;
            if (Input.GetMouseButtonDown(1))
                if (EventSystem.current.IsPointerOverGameObject()) return;
                isDragging = true;
                lastScreenPosition = Input.mousePosition;
            if (Input.GetMouseButtonUp(1))
                isDragging = false;
            if (!isDragging) return;
            float delta = Input.mousePosition.x - lastScreenPosition.x;
            lastScreenPosition = Input.mousePosition;
            if (Mathf.Abs(delta) < 2) return; //filter out mouse noise
            float direction = Mathf.Sign(delta);
            transform.Rotate(Vector3.up, direction * rotationSpeed * Time.deltaTime);

You’ll need a new GameObject that is a child of the Core, but NOT a child of the camera or the player.
Add this script to the target, and set the initial position to be identical to the initial position of the player.

Next, you’ll need to change the Follow component in the Follow Camera from Framing Transposer to 3rd person follow. The initial settings in Third Person Follow will be wrong, so you’ll need to set the Y offset and Z offset to similar numbers to the ones you were using in the Framing Transposer.

I also activated the Aim component, with the Aim target set to the player’s hip bone.

Now when you Drag the right mouse button left or right, the camera pivot will rotate. The Third Person Follow is designed to keep the camera behind the target at all times, so this will rotate the camera.

I followed the instructions accordingly. I created an empty gameObject under CORE, named it ‘Target’ (I assumed that was the case), attached the script to it, made the initial position exactly the same one as the player, and then you can see my new settings for my third person follow camera (along with ‘Aim’… was not sure how to set that to be the Players’ hip). In the end, the camera points straight at the players’ shoes, from a very low angle (looks cool for car epic shots :stuck_out_tongue_winking_eye: ), and the camera rotates like crazy whenever I click on somewhere on the map. Where did I go wrong? (P.S: I’m not very familiar with CineMachine)

The Follow Camera should be set to Follow the new Target Object.
The Hips for the aim are under the root in the skeleton (Player/Character_Knights_Soldier_02/Root)

OK it rotates now, but… that’s an interesting view. How do we change this view to something more convenient?

Your target’s transform.position should start the same as the player’s position (I would copy the transform in the Player, and then on the Target, I would paste in the component values.

Then the Shoulder Offset in the Third Person Follow camera needs to be set. By default, the Follow camera’s Shoulder Offset is directly behind and a touch up…
I used (0, 5, 10) for the follow Camera.

yup, that fixed the angle. Any recommended rotation speed for the Target’s camera pivot script though? Too slow and it’s not enough for me to properly rotate. Too fast and it’s… shaky when we rotate too fast, it just kills the experience

It’s okay if there’s no solution right now, but I’d appreciate one that makes my gameplay a bit smoother :slight_smile:

You have to find a value that works best for you.
The speed is degrees per second… so a very low number won’t rotate quickly at all. In my playtesting, I used 50, but it’s entirely up to you the speed.

125 works best for me personally. Problem is… it’s a bit, well… heavily shaky when moving around the player, like it can really use a virtual vibration dampener there

I’m sure playing around with the Damping values could help there. That being said, that’s a pretty fast transition, so I’m not terribly surprised it’s shaky. [cue Harry Belafante music here]

Apparently playing with the dampeners under ‘Body’ turns it into a Cinematic masterpiece. Great entrance, terrible follow up speed :stuck_out_tongue_winking_eye: (gotta fix that lel…)

1 Like

OK umm… is there anyway we can upload short video snips on here? I have a VERY interesting camera pattern I’d like to show you, it’s a little hard to explain

I just want to eliminate the damping when rotating my camera (if we can make it as smooth as what Unity does to its cameras in the Scene Edit mode, that would be ideal!), and there’s a shaky footage effect when we get to fighting that is… well… surprisingly beautiful. It gives the game the vibe of an attack/strong hit, and I love it. Can we make this higher the stronger our player hits? not too crazy high, but a little higher would be nice

You can link YouTube videos, but this is something the community is much more likely to be able to help you with than me. I would take the issue of fine tuning the Free Look Camera to our Discord.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms