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
COMMUNITY QUESTION
How can I get a brick's velocity in a specific direction?[I figured it out]
2 answers
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?
1 comment
0
I don't think it really matters where I want to determine it, but I want to determine it in studio
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Nice job. +1