Gunroar:Cannon() wrote: ↑Wed Dec 07, 2022 7:13 pm
I think when the (Y) value of the goal is bigger than the (Y) value of the origin it has an opposite arc and reversing the at. just makes it wobble. Anyway to always make the arc one that goes up and back down no matter what (while still using tweening)?
local function lerp(a, b, t)
return t < 0.5 and a + (b - a) * t or b - (b - a) * (1 - t)
end
local function tween_parabola(a, b, t)
return lerp(a, b, 1-(t*2-1)^2)
end
print(tween_parabola(5, 100, 0)) -- prints 5
print(tween_parabola(5, 100, 0.5)) -- prints 100
print(tween_parabola(5, 100, 1)) -- prints 5
What you're doing with the parameters is not the function's fault.
Gunroar:Cannon() wrote: ↑Wed Dec 07, 2022 7:13 pm
I think when the (Y) value of the goal is bigger than the (Y) value of the origin it has an opposite arc and reversing the at. just makes it wobble. Anyway to always make the arc one that goes up and back down no matter what (while still using tweening)?
local function lerp(a, b, t)
return t < 0.5 and a + (b - a) * t or b - (b - a) * (1 - t)
end
local function tween_parabola(a, b, t)
return lerp(a, b, 1-(t*2-1)^2)
end
print(tween_parabola(5, 100, 0)) --5
print(tween_parabola(5, 100, 0.5))-- 100
print(tween_parabola(5, 100, 1))-- 5
Oh, the function makes it go high to back to the original value when used. Okay, that makes sense now. I used it thinking it adds the parabola then takes it to the final value. To my discredit I didn't even try and see if I could understand the function, but now I see what happens in relation to t and how you got the formula (exp+1 )
Thanks again.
The risk I took was calculated,
but man, am I bad at math.