Hello everyone,
I am currently trying to implement a procedural equipping animation to my sword. The script works fine, but I’m not too sure on its efficiency. Here’s the code:
local final = self.idle_cf
local render_spring = nil
local alpha = TWS:GetValue(0.3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
self.idle_cf = self.idle_cf * CFrame.new(0, -10, 0)
for i = 1, 5 do
local dt = RUS.RenderStepped:Wait()
self.joint.C0 = self.joint.C0:lerp(final, alpha * 60 * dt)
end
self.idle_cf = final
Structure of the code
- get final and tweening value
- set its starting point 10 studs below the final
- repeat 5 times:
- lerp joint.c0 to the goal
- change idle_cf back to final
If you have an idea that I can do to optimize this, please leave a reply below. Thank you!