Skip to main content
code format + image description
Source Link
EnoughTea
  • 2.5k
  • 16
  • 16

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);
            }
        }
    }
 }

Example of Camera movement

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);
         }
     }
 }
 }

Example of Camera movement

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);
            }
        }
    }
}

Example of Camera movement

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);
         }
     }
 }
 }

} enter image description hereExample of Camera movement

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);
         }
     }
 }

} enter image description here

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);
         }
     }
 }
 }

Example of Camera movement

Source Link

Smooth Camera Follow

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);
         }
     }
 }

} enter image description here