How do I call a raycast from Update with a delay between each call

Normally of course, setting a raycast from a function in Update casts a ray every frame. I’m trying to use a Coroutine to have the raycasts happen every 0.2 seconds instead of every frame but I’m struggling big time.

To be clear:

  1. The function that casts the ray is called from Update, meaning the function is accessed every frame.

  2. By default, the ray is cast every frame but I need it to be cast every fraction (0.2f) of a second instead.

  3. I need the Debug.DrawRay command included for testing.

  4. I need rays to keep being cast (but with a delay between each). Not fire once or twice and that’s it.

  5. THE LANGUAGE HAS TO BE C#. Not JS

Found out on my own after research. It’s a combination of InvokeRepeating() and CancelInvoke().