Creating a timer for combat (C#)

Hi, I would like to clarify that I don’t want you to do this for me. I would however like for you to point me in the right direction by supplying me with any relevant methods I could use etc.

If anyone’s played runescape or other such games, basic attacks occur looped on a consistent basis, say 1 attack every second or so. This is what I am trying to achieve.

I don’t know how to go about doing this, I maybe would like to implement a timer which other classes can use to decide their own responses. So if you have ANY relevant information which might make this easier on me that would be awesome!

See:

  • InvokeRepeating()
  • Coroutines
  • Or you can manipulate a timer by adding ‘Time.deltaTime’ to a float each frame and then processing the result.

Note these three methods behave differently in some situations like setting Time.timeScale to 0.0 or what happens when the game object is disabled.