Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I CFrame animate a reloading animation?

Would I lerp, or use a loop that rotates my fake arms to reload and etc. And to return my original arms back to there original position, would I i just rotate them opposite?

1 answer

✓ Accepted answer

Both. You lerp with a loop so both.

To return them back to their original position lerp from the changed position to the unachanged.

Note that you'll be lerping welds not the objects' CFrame


######Lerping example

local start = CFrame.new(0,0,0);
local finish = start * CFrame.Angles(math.rad(10),0,0) * CFrame.new(0,10,0);
local smooth = 50;

for i = 1,smooth do
	local newCF = start:lerp(finish,i/smooth);
	wait();
end

7 comments

0

I have a question with lerping, isnt lerping like taking a parts position to another position, so how would I do this?

0

Edited with an example.

0

first argument of lerp is the target, second is the alpha(a number, to be a percentage between start and target)

0

oh wow thanks!

0

I have a question on your second part, why would you divide i by 50?

0

'i' is the current iteration of the for loop. If 'i' goes from 1 to 50 then 25 is the halfway point. 25/50 = .5 = 50%

0

The second argument is supposed to be a number that acts as a percentage(x/100)

This discussion is preserved as it was. New answers, comments, and votes are closed.