I am using a fixed static background. I have a gameobject(Current ref. image) which is moving with the help of waypoints. I have made camera to follow the Current. The camera is stuttering while moving. Can anyone help me to solve the camera stuttering and make it follow the Current smoothly?
This is my code attached to camera following the star
public class CameraController : MonoBehaviour {
void Start ()
{
GameObject.FindGameObjectWithTag("OptionCamera").GetComponent<Camera>().orthographicSize =
(20.0f / Screen.width * Screen.height / 2.0f);
}
void LateUpdate()
{
if (GameObject.FindGameObjectWithTag ("Current") != null) {
if (GameObject.FindGameObjectWithTag ("Current").GetComponent<CurrentController>().Greenblast == false &&
GameObject.FindGameObjectWithTag ("Current").GetComponent<CurrentController>().Redblast == false)
{
Vector3 pos = GameObject.FindGameObjectWithTag ("Current").transform.position;
transform.position = new Vector3 (transform.position.x, pos.y, transform.position.z);
}
}
}
}