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 - Ігри
Thanks for the solution!
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;
}
}
}
}
Cinematic cut-scene tutorial 🙌
how do you add the Cinemachine namespace in my C# scripts
usually when utilising a camera with a rigidbody it is good to have it separated because that also prevents the camera jittering
It also happens on a CharacterController which isn't a Rigidbody, so that doesn't matter
@@blinkachu5275 I’ve never experienced this while using a cc before?
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.
I just interpolated the rotation values between each fixedupdate in update
but how did cinemachine fix this?
Cinemachine incorporates the solutions I've mentioned at 8:19
@@semikoder thx. But when i enable interpolation my players movement becomes broken wtf.
I can only find the cinemachine 2.9 version
Will it work on mobile devices?
where do i get cm3
you have to have the latest version of unity
x2
@@sebastiangeraldohirales4935 ?
pls make tutorial on how to make cod mw type movement and camera animations
just use late update for camera rotation lol, wtf
It's crazy how you have to do all those steps in Unity and in Unreal you don't 😂