CAMERA FOLLOW MOVING PLAYER PROBLEM ?
Hi there, i am kinda a new to unity so please help me with my problem.
Basically i am working on a game in unity for 2 months and i had this problem from the start, everytime i update my game with some new features i always try to solve this problem but failed many times.
So my problem is MY CAMERA IS NOT FOLLOWING MY (CONSTANT MOVING) PLAYER SMOOTHLY and when i say not smooth i mean glitchy or jerky or you get the idea!
So Please help me, i've tried Update(), LateUpdate(), FixedUpdate(), transform.position, vector3.lerp, vector.smoothDamp, etc.
the camera is not smooth on my android device (MI3)
the camera or the game does'nt lag on my windows, My brother's android phone (Galaxy S4) only on my phone and i know what you might be thinking that my phone is lagging not the game but i played many games on my phone and not a single one lag!
I will give you any info. you want but please guide me to the right path coz this problem is ruining my game and my time.
i will provide the Player Script and the cameraFollow Script of C# in unity.
Have a look and if you can figure out the problem, Please!
PLAYER SCRIPT
private float gameSpeed;
public bool dead;
public bool quitGameNow;
void Start ()
{
gameSpeed = 6.5f;
dead = GetComponent<PLAYER>();
quitGameNow = GetComponent<ExitMenu> ();
}
void Update()
{
dead = PLAYER.isDead;
quitGameNow = ExitMenu.quitGame;
transform.Translate (gameSpeed * Time.deltaTime, 0f, 0f);
if (dead == true || quitGameNow == true)
{
gameSpeed = 0f;
}
if (gameSpeed < 9f)
{
gameSpeed += 0.0007f;
}
}
}
CAMERA FOLLOW SCRIPT
public Transform lookAt;
private Vector3 offset = new Vector3 (4.5f,0f,-10f);
public bool activateCam;
public static bool allowTouch;
public bool isDead;
void Start()
{
activateCam = GetComponent<PLAYER>();
isDead = GetComponent<PLAYER>();
}
void Update()
{
activateCam = PLAYER.activateCamera;
isDead = PLAYER.isDead;
if (activateCam == true && isDead == false)
{
allowTouch = true;
}
}
void LateUpdate()
{
Vector3 desiredPosition = lookAt.transform.position + offset;
if (activateCam == true && isDead == false)
{
transform.position = Vector3.Lerp (transform.position, desiredPosition, 0.2f);
}
}
BTW - My player does'nt have a rigidbody attached to it and i am moving the camera after it triggers a object (activate cam) and the bool is set to TRUE. (Static Values)
Any Question about the script and about my game ? i am happy to answer :)
THANKS!
Your answer
Follow this Question
Related Questions
How do I assign MainCamera to a dynamically created primitive? 0 Answers
Cinemachine crashes unity 1 Answer
3D objects appear behind 2D on mobile, but in correct order in editor 1 Answer
When i change the resolution in the game tab does the camera covers that much area only 0 Answers
Android build display bug/glitch ? 0 Answers