Question by
dylan_j_f · Dec 27, 2015 at 11:47 AM ·
c#unity5camera-movementplayer movementmoving
How do you move the camera with the player. Whats wrong with my code?
using UnityEngine;
using System.Collections;
public class CameraController : MonoBehaviour {
public GameObject player;
private Vector3 offset;
void Start () {
offset = transform.position - player.transform.position;
}
void LateUpdate () }
transform.position = player.transform.position + offset;
}
Comment
Whats wrong with my code?
Other than the curly brackets being all messed up in LateUpdate so that the code doesn't even compile, nothing. The code works fine for me after changing to.
void LateUpdate() {
transform.position = player.transform.position + offset;
}
It would help a lot if you told us what kind of behavior you are seeing on your screen and how it differs from what you are expecting.