Camera Jump Issue

Gif link in case it doesn’t want to work as an embed: Imgur: The magic of the Internet

I’ve been trying to get a 3rd person melee action camera together for a while now, but I keep coming across jump/jitter issues. Finally, I go with this ultra simple script and for some reason this random jump issue happens. I don’t see any reason for it whatsoever and I’m being driven insane by all the camera issues I’ve been dealing with. Hoping someone else with some fresh eyes can explain why the camera wants to randomly jump around when it moves.

Edit: So I figured out that’s it has something to do with the project, cause I created a new one, implemented the camera system, no jump issue whatsoever. Unfortunately I’m working in a project that has had quite a few cooks in the kitchen already and is a massive mess, so I have no idea what’s causing the issue but yay it’s not me being a complete dumb dumb.

using System.Collections;

using System.Collections.Generic;

using UnityEngine;



public class CameraFollow : MonoBehaviour

{



public float CameraMoveSpeed = 120.0f;

public GameObject CameraFollowObj;

Vector3 FollowPos;

public float clampAngle = 80.0f;

public float inputSens = 150.0f;

public float camDistanceXToPlayer;

public float camDistanceYToPlayer;

public float camDistanceZXToPlayer;

public float mouseX;

public float mouseY;

public float finalInputX;

public float finalInputZ;





private float rotationY = 0.0f;

private float rotationX = 0.0f;



void Start()

{

Vector3 rot = transform.localRotation.eulerAngles;

rotationY = rot.y;

rotationX = rot.x;

Cursor.lockState = CursorLockMode.Locked;

Cursor.visible = false;



}



void Update()

{

float inputX = Input.GetAxis("RightStickHorizontal");

float inputZ = Input.GetAxis("RightStickVertical");

mouseX = Input.GetAxis("Mouse X");

mouseY = Input.GetAxis("Mouse Y");

finalInputX = inputX + mouseX;

finalInputZ = inputZ + mouseY;



rotationY += finalInputX * inputSens * Time.deltaTime;

rotationX += finalInputZ * inputSens * Time.deltaTime;



rotationX = Mathf.Clamp(rotationX, -clampAngle, clampAngle);

Quaternion localRotation = Quaternion.Euler(rotationX, rotationY, 0.0f);

transform.rotation = localRotation;

}



private void LateUpdate()

{

CameraUpdater();



}



void CameraUpdater()

{

Transform target = CameraFollowObj.transform;



float step = CameraMoveSpeed * Time.deltaTime;

transform.position = Vector3.MoveTowards(transform.position, target.position, step);



}

}

You should consider breaking your scenes into multiple additively-loaded scenes, rather than one honkin’ big scene. Here’s some ways I break up my play scene:

  • single loader scene that additively loads these scenes
  • whatever content is required for this level
  • whatever lighting is required for this level
  • UI system for in-game play
  • player controller
  • pause menu scene overlay

etc. etc. etc.

This way your scenes are relatively smaller and less likely to have folks stomping on each other. Once you work this way for a while, you’ll never again want to all be in one huge scene.

The scene in question here is literally it’s own test scene with a plane, cubes and camera.

I’ve since deleted a very old version of Cinemachine that was haphazardly added to the project - i.e. not via the package manager - and the size of the jumps diminished significantly but still occur.