Attack Speed Calculations

How do I calculate attack speed?

the minimum adjustspeed im gonna use is .8
the maximum adjustspeed is gonna be 1.8
which i can use math.clamp()

but the real problem is on how im gonna calculate the x (adjustspeedvalue) im gonna use

can somebody show a sample formula for me?

for example (for more context)

the max attackspeed i will be putting is like 500 (I’ll change it if somebody suggests it)
so if i have like 1 attackspeed, adjust speed value will be somewhere in 1.83.
if i have 230 attack speed, maybe somewhere in 1.4-1.6 depending on the formula,
max attack speed (which is 500), will be 1.8 as put in the maximum value of the mathclamp on how im gonna use the :AdjustSpeed(math.clamp(x, .8, 1.8))

I really cant think of a formula. Thanks!

Extra question: is this the right place to be asking? scripting support?

Not sure if I fully understand your question, but maybe look into lerping the values? Although I don’t quite understand your initial question that well.

function lerp(a, b, t)
	return a + (b - a) * t
end

lerp(10, 20, 0.5) --> 15
-- t is any value between 0 and 1.
-- a & b are your minimum and maximum values respectively.
1 Like

so, higher attack speed = higher animation speed? your question is a little hard to understand, i agree with synical

1 Like

yes, the value of adjust speed must be 0.8 to 1.8 though

sorry for not adding more context
image

image

the first arguement in the math.clamp is the formula im asking for.

in the adjust speed part

local minValue = 0.8
local maxValue = 1.8

local maxAttackSpeed = 500
local attackSpeed = 450

local newValue = minValue + ((attackSpeed / maxAttackSpeed) * (maxValue - minValue))

print(newValue) -- 1.7
1 Like

attack:AdjustSpeed(math.clamp(.8 + Data.AttackSpeed.Value / 100, .8, 1.8))
I kinda found it out already, but thanks I will try yours, and see which is better thanks!

I made a print to compare and it is just the same. Thanks bro!

1 Like

Optionally, you could also do a math.map:

local minValue = 0.8
local maxValue = 1.8

local maxAttackSpeed = 500
local attackSpeed = 450

local newValue = math.map(attackSpeed, 0, maxAttackSpeed, minValue, maxValue)
print(newValue) -- 1.70
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.