Converting Attack Speed to Time Between Attacks

I’m trying to figure out how to calculate Time Between Attacks from Attack Speed so I can use it for a Debounce

An example would be

2.5 attacks per second would equal to 0.4 seconds for Time Between Attacks or you can call it a delay/ wait time

Time between attacks = 1 ÷ Attacks per second
1 ÷ 2.5 attacks per second = 0.4s in your example.

1 Like

Thank you!

I feel bad for not knowing how to solve this simple math problem

Don’t man! It’s just something you haven’t learned yet

1 Like

Bit of a late reply, but here’s the explanation:


You can represent the amount of attacks per second as a ratio. In your case:

Attacks : Second


Now we plot the numbers:

A : S
2.5 : 1

This ratio shows that for every second elapsed, 2.5 attacks have occurred.


Here’s the cool bit:

If you multiply or divide a number on one side of an equation, you do the exact same for the other

This means that if we do 2.5 / 2.5, we would get 1. However, we would also have to do the same for the other side: 1 / 2.5 = 0.4.


Therefore:

A : S
2.5 : 1
1 : 1 / 2.5
1 : 0.4

So for every attack, 0.4 seconds have elapsed.


Edit

Sorry if you already knew this but was having a brain fart XD

1 Like

Using ratios for this is not the best way, it would be better to represent time between attacks as a function of attacks per second i.e.

Let n = number of attacks per second, and let t = the time between each attack:
We can surmise that if you have n attacks per second, and t time between each attack, then t*n = 1 second.

We can then use what you said about operating on an equation. Because we’re trying to find t, we would divide both sides by n. t*n÷n = n, and 1÷n = 1/n, so t = 1/n