I also tried that. Its also inaccurate.
Youâre trying to calculate a value that doesnât have a definition (at least according to all the people in this thread so far, including yourself). If you donât know what youâre looking for, how can you judge whatâs accurate?
Its because I am testing it in Roblox Studio. So I do know if its accurate or not.
We cannot comprehend what exactly do you want, try to clarify.
So I am making a Ladder, that rotates from a âpivotâ from the ground when you hold E, and when you release E it tweens back to the original CFrame.
It takes 8 seconds for the ladder to fully be placed on the wall, but if the player release the E key when, for example the ladder is half-way in its tween, it starts to tween back to the original position but with half the speed, I want it to keep the speed and not decrease/increase when the distance is smaller or bigger.
function a(b,c)
return c*b
end
local p = workspace.Part
local d = (a(p.CFrame:ToAxisAngle()) - a(originalCFrame:ToAxisAngle())).magnitude/math.pi
local len = 5 --tween length in seconds for maximum (180°) difference
local tweenInfo = TweenInfo.new(len*d, Enum.EasingStyle.Linear)
How am I the only one that understands this?
When you interpolate something, it is ten studs away and the interpolation lasts two seconds.
Thatâs 10/2 = 5 studs per second for interpolation.
Now say you have something thirty studs away, but want to use the same speed rather than the same duration. Thatâs 30/5, or 6 seconds of interpolation. Without knowing the distance, either ten or thirty studs, you canât figure exactly how long the duration should be.
He wants to apply the same to rotation, and needs to know how many degrees one angle is from another so that he can specify a duration based on degrees/second.
StrategicPlayZ, it sounds like in this instance you may want to look into constraints rather than CFrames, if just to solve this issue.
I figured it out, thanks to emojipasta.
local function GetDistanceOfCFrames(cf,cf2) --
local axis,theta = cf:ToAxisAngle()
local axis2,theta2 = cf2:ToAxisAngle()
return (cf.Position-cf2.Position).Magnitude,((axis*theta)-(axis2*theta2)).Magnitude
end
You could of just did this xD
local distance = (target1.CFrame.p - targer2.CFrame.p).Magnitude
Not quite what he wanted though.
This post is old. I have already found a way to do what I was trying to do when I made the post, Lerping.
I thought TweenService animates object using specific increments, but I was wrong, it uses Lerping, so I applied the same concept later on and it worked better than this post.
Coulden`t (Cf1.LookVector - Cf2.LookVector).Magnitude work?
That would result in a 0 for directions pointing opposite.
This still isnât a solution by itself, but you can get the angle between two vectors like this.
math.acos(Cf1.LookVector:Dot(Cf2.LookVector))
Seriously though, this post is over a year old and itâs already solved.