i developing side Scrolling endless Game. i want to Change X Axis of camera as player moving to Right. and i almost Done That. but the problem is when move Camera to the Right then its look so stiff in Android Device not Move Smooth. That's the code I Write in my Script to move Camera when player move.
public static float offsetX;
void Update () {
if (BirdScript.instance != null) {
if (BirdScript.instance.isAlive) {
MoveTheCamera ();
}
}
}
void MoveTheCamera() {
Vector3 temp = transform.position;
temp.x = BirdScript.instance.GetPositionX () + offsetX;
transform.position = temp;
}
and in my Player Script(BirdScript.cs) i also set my player Position and also Get in CameraScript
void Awake() {
setCameraX();
}
void setCameraX() {
CameraScript.offsetX = (Camera.main.transform.position.x - transform.position.x) - 1f;
}
public float GetPositionX(){
return transform.position.x;
}
what should i do to move my camera smoothly in device? thanks.....