Ok, let's say I had a brick that was moving diagonally across the X and Z axis, but it was facing north the whole time. How would I determine the velocity of the direction that the brick is facing? Sorry if this question sounds a bit confusing
Nevermind, I figured it out. In case anyone was wondering the same question too, I'll post my solution:
local Part = script.Parent function GetVecAng(A,B) return math.acos( A:Dot(B) / ( A.magnitude * B.magnitude ) ) end while true do local LookV = Part.CFrame.lookVector local VelocityUnit = Part.Velocity.unit local AngleBetween = math.min( GetVecAng(LookV,VelocityUnit) , math.pi / 2) local LookVelocity = ( math.pi / 2 - AngleBetween ) * ( 2 / math.pi ) * Part.Velocity print(LookVelocity) wait() end
Do you want to determine it in game?? Or in studio?