How to Make Spotlight Lag, Following Player

I’m working with Unity for the first time ever for school, and I’m making a Roll a Ball project. I’m trying to get the spotlight to follow the Player, and used the same script I used to make the camera follow the player but changed CameraController to LightController, but I didn’t like how to light followed the player instantly. I ended up changing my code to this:

using UnityEngine;
using System.Collections;

public class LightController : MonoBehaviour {

	public GameObject player;
	private Vector3 offset;
	public float delay = 0.5f; 
	public float followNow;

	void Start()
	{
		followNow = Time.time + delay;
		offset = transform.position;

	}
		

	void LateUpdate ()
	{
		if (Time.time > followNow) {
			if (player != null) {
				transform.position = player.transform.position + offset;
			}
			followNow += delay;
		}

	}
}

And this way, the light waits 0.5 frames to center on the player, but it’s erratic and not smooth at all. It practically teleports to the player’s new location after 0.5f, but I want to know how to make it lag behind like it is, and smoothly make it’s way to the player to center on it if it comes to a stop. Can somebody help me figure this out?

114027-capture.jpg

Also, I don’t know if this is useful info, but I made the spotlight a rigid body and made it kinematic so it would stop shrinking into the player after every frame.

I may not be able to help you much, BUT, you want the camera to lag behind the player right?
Well,
There are 2 things that I would try, first, change your code a bit,

you have offset as your new vector 3 which you base your light vector 3 off of.

  offset = transform.position;

well, this gets the v3 of your player. We want the camera to trail behind the player a couple of frames. so, here is what you should try,

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {
    private Vector3 pos;
    public GameObject light;

	void Update () {
        pos = gameObject.transform.position;
        offset();

	}
    IEnumerator offset()
    {
        yield return new WaitForSeconds(.5f);
        light.transform.position = pos;

    }
}

this way, you get the v3 of the player, then you wait 1/2 a second, then you apply the half second v3 to the light, so the light is always 1/2s behind the player. If you stop, then the light should go the players location, and then if you move, it will stay there for 1/2 second.

Hope this helps,
quadack