I’ve got a spot light aiming at the player. When the player moves, I need the light to stay in the same position, but rotate so as to always be aiming at the player.
I’ve been trying to work it out for a while but haven’t found a solution, is this possible?
public class AlwaysLookAt : MonoBehaviour {
public Transform Target;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.LookAt(Target);
}
}
Just add that to your light and set Target to the player object in the editor. For future reference though, check out the transform object it has a lot of useful methods to deal with common things like that.