So I was wondering if there is any way to make animating body parts easier like not the plugin but, I am talking about the angle so that CFrame.Angles how would I get the perfect coordinates for that to do things? I hope someone can help me out with this I want to know how to get the correct coordinates a bit easier so that if I need the arms to be in an animation until the player stops pressing that certain button or loop an animation so basically he arms stay in one position until the player unequips the tool.
Lerp
is quite a fun way of interpolating (smoothly transitioning) between vectors/CFrames.
This article is quite good at explaining it. If you are having trouble with it then drop a comment and I'll try and re-explain it.
As requested to expand:
So, lerp
is essentially a mathematical function which you can use to work out a point between two CFrame/vector3s
It is used like the following:
FIRST_CFRAME:lerp(FINAL_CFRAME, FRACTION)
FIRST_CFRAME:
This is the starting position/cframe
FINAL_CFRAME:
This is the ending point, which you want the part to end up at.
(This can be a Vector3 as well, works the same way)
FRACTION:
This fraction will represent how far along the path (between the part's position and end FINAL_CFRAME) the function will get a value from.
So if you imagine the following scenario:
FirstPosition = Vector3.new(0, 0, 0) FinalPosition = Vector3.new(4, 0, 0)
FirstPosition:lerp(FinalPosition, 0.5) will return Vector3.new(2, 0, 0) as it is half way (0.5 out of 1) between the FirstPosition and the Final position.
To put this into a script, you can tween between points using:
local FirstCFrame = workspace.Part.CFrame --Get the original CFrame local FinalCFrame = CFrame.new(0, 50, 0) --Get the final CFrame for i=1,50 do --Lets go with 50 frames local NewCFrame = FirstCFrame:lerp(FinalCFrame, i/50) --Use lerp to get the CFrame workspace.Part.CFrame = NewCFrame --Set the part's CFrame to the lerp'd CFrame wait(0.25) --So it isn't instantaneous end
I hope this helped! Please comment below if you have more questions.