Make a light follow a first person controller

Hi I am just starting out in unity so I will appologise if this has been asked before, I have searched but cannot find a post that helps. How do I make a direction light follow a first person controller. I presume that you add a script to the light object and then target it to the FPS object. I trird the following with no sucess my FPS object is called “Bod”.

function Update () {
GameObject.Find(“Bod”).GetComponent(“SmoothFollow”);

}

I just want the scene to light in the direction the FPS controler is facing.

Yours is not the best way to do it, although it’s theoretically possible. The proper way would be to set the light to be a child of the camera (which should in turn be a child of the whole fps controller thing) and make it face the same way in edit mode. Then, when the camera rotates, the light will rotate with it. This will make the light follow every movement of the camera without delay.

Thanks I thought there would be a simpler way to do this. The only problem is if I add the light to the built in FPS Prefab it breaks it. I presume to do this I will need to create a new FPS prefab with the light included.

You can just make the directional light a child of the first person controller, then it will follow it around in the direction that you are facing on the x and z axis. However if you want the light to follow the mouse in other planes then you’ll need to write a function.