camera follows player unity 2d platform code example
Example: 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;
}
}