Question by
edgartip2003 · Apr 09, 2019 at 11:43 AM ·
cameracamera followjittering
My camera jitters a lot. Any fix?
Hello everyone. I am making a 2D platformer and I have a simple camera follow script. The problem is that the whole screen jitters from time, making it very ugly to look at. I tried getting a new script, tried editing the time settings in the project settings , tried making my gameobjects smaller but nothing worked. Would appreciate some help. Here is the script :
using UnityEngine;
public class CameraFollow : MonoBehaviour
{
public GameObject player; //Public variable to store a reference to the player game object
private Vector3 offset; //Private variable to store the offset distance between the player and camera
// Use this for initialization
void Start()
{
//Calculate and store the offset value by getting the distance between the player's position and camera's position.
offset = transform.position - player.transform.position;
}
// LateUpdate is called after Update each frame
void LateUpdate()
{
// Set the position of the camera's transform to be the same as the player's, but offset by the calculated offset distance.
transform.position = player.transform.position + offset;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to get the camera to follow a prefab? 2 Answers
Camera always behind player 0 Answers