How to make The Best First Person Camera in Unity

Поділитися
Вставка
  • Опубліковано 14 лип 2024
  • I've been playing around with different camera configurations in Unity to achieve a non-jittery camera and I think I might've come across the best solution.
    Timestamps:
    0:00 - Introduction
    0:42 - Chapter 1: Understanding the problem
    1:45 - Chapter 2: FixedUpdate vs Update
    4:56 - Chapter 3: The solution
    5:17 - Chapter 4: The solution part 2
    6:18 - Chapter 4: The solution part 3
    #unity
    --
    Music used:
    Daystar - Lemon Cake
    A Hat in Time - Train Rush [Remix] by Qumu
    Cinematic - Aylex
    Fortune - Kyatto
    Lamp - Kyatto
    Once - RYU ITO MUSIC
  • Ігри

КОМЕНТАРІ • 21

  • @Montigorable
    @Montigorable 2 місяці тому

    Thanks for the solution!

  • @MichaelH-zb8gg
    @MichaelH-zb8gg 26 днів тому +4

    Nice Tutorial. I've updated to 3.0.1 and it works well. The only problem with Cinemachine is setting up player rotation on camera movement. So below is a script to handle the player rotation on camera movement. Put the script below on the player.
    using UnityEngine;
    public class PlayerRotate : MonoBehaviour
    {
    private Camera mainCamera;
    private void Start()
    {
    // Find the main camera in the scene
    mainCamera = Camera.main;
    }
    private void Update()
    {
    // Rotate the player towards the camera every frame
    RotatePlayerTowardsCamera();
    }
    private void RotatePlayerTowardsCamera()
    {
    if (mainCamera != null)
    {
    Vector3 cameraForward = mainCamera.transform.forward;
    cameraForward.y = 0f; // Ignore the y-axis rotation
    if (cameraForward != Vector3.zero)
    {
    Quaternion newRotation = Quaternion.LookRotation(cameraForward);
    transform.rotation = newRotation;
    }
    }
    }
    }

  • @problem1O1
    @problem1O1 2 місяці тому +1

    Cinematic cut-scene tutorial 🙌

  • @StephHami
    @StephHami 2 місяці тому

    how do you add the Cinemachine namespace in my C# scripts

  • @Rauza31
    @Rauza31 2 місяці тому

    usually when utilising a camera with a rigidbody it is good to have it separated because that also prevents the camera jittering

    • @blinkachu5275
      @blinkachu5275 2 дні тому

      It also happens on a CharacterController which isn't a Rigidbody, so that doesn't matter

    • @Rauza31
      @Rauza31 10 годин тому

      @@blinkachu5275 I’ve never experienced this while using a cc before?

  • @controlledsingularity8084
    @controlledsingularity8084 2 місяці тому +1

    Here's a short explanation of how to actually do this whitout needing cinemachine or other crap:
    Step1: create a empty game object. This is the game object you will be moving around in update and represents the target position of your camera.
    Step2: create a script that interpolates the position and rotation of your camera towards this empty game object, about 0.6-0.8 of the way per frame will do.
    Step3. Done. You are done.

  • @nikz000
    @nikz000 24 дні тому

    I just interpolated the rotation values between each fixedupdate in update

  • @ze1st_
    @ze1st_ 2 місяці тому +3

    but how did cinemachine fix this?

    • @semikoder
      @semikoder  2 місяці тому

      Cinemachine incorporates the solutions I've mentioned at 8:19

    • @ze1st_
      @ze1st_ 2 місяці тому

      @@semikoder thx. But when i enable interpolation my players movement becomes broken wtf.

  • @sebastiangeraldohirales4935
    @sebastiangeraldohirales4935 Місяць тому

    I can only find the cinemachine 2.9 version

  • @Th3_V3ct0rAT2
    @Th3_V3ct0rAT2 Місяць тому

    Will it work on mobile devices?

  • @StephHami
    @StephHami 2 місяці тому

    where do i get cm3

  • @ZeonplayzYt
    @ZeonplayzYt 2 місяці тому +1

    pls make tutorial on how to make cod mw type movement and camera animations

  • @EuclidStreams
    @EuclidStreams 22 дні тому

    just use late update for camera rotation lol, wtf

  • @srydustar5754
    @srydustar5754 Місяць тому +2

    It's crazy how you have to do all those steps in Unity and in Unreal you don't 😂