0
Q:

how to make camera follow player unity 2d

public class CameraFollow : MonoBehaviour {

    public GameObject Target;
    private Vector3 Offset;


    // Start is called before the first frame update
    void Start() {

        Offset = transform.position - Target.transform.position;
        
    }

    // Update is called once per frame
    void Update() {
    
        transform.position = Target.transform.position+Offset;

        
    }
}
1
  public Transform player;  public Vector3 offset;    void Update ()   {      transform.position = new Vector3 (player.position.x + offset.x, player.position.y + offset.y, offset.z); // Camera follows the player with specified offset position  }
-1

New to Communities?

Join the community