Help needed with WaitForSeconds()

I am trying to invoke a shooting animation in the Update function and then wait for 0.5 seconds before spawning the laser shot. The below code isn’t working for me. What can I do to achieve the desired result?

void Update()
{
    if (Input.GetMouseButtonDown (0)) 
    {
    	animator.SetTrigger("Shoot"); // Start animation
    
    	WaitAndShoot();			
    }
}
    
IEnumerator WaitAndShoot()
{
    yield return new WaitForSeconds(0.5f);

    Instantiate (shot, shotSpawn.transform.position,shotSpawn.transform.rotation);
}

I didn’t realize you have to call a coroutine like this:

void Update()
{
    if (Input.GetMouseButtonDown (0)) 
    {
        animator.SetTrigger("Shoot"); // Start animation

        StartCoroutine(WaitAndShoot());         
    }
}

Disclaimer: I’m no expert at Unity

Honestly, WaitForSeconds should be avoided when possible. It’s not really the greatest thing to use timed functions when running a synchronous loop program (a game).

What I’d do:

On mouse button down, store the date of the input lastShot = Time.time
Mark a boolean as true, meaning you want to shoot shooting = true
In update, if the boolean is true, check if Time.time - lastShot > 0.5f
If so, do your thing and mark the shooting boolean as false

Example :

   public Transform shotSpawn;
	public Transform shot;
	public float shootTimer = 0.5f;

	private bool shooting = false;
	private float lastShoot;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetMouseButtonDown(0)) {
			shooting = true;
			lastShoot = Time.time;
		}

		if (shooting) {
			if (Time.time - lastShoot > shootTimer) {
				Instantiate (shot, shotSpawn.transform.position,shotSpawn.transform.rotation);
			}
		}
	}