Hi all,
I was wondering if it was possible to slowly rotate one part to face another. The complication being that the second part is in motion, ruling out the possibility of using tweens or some other form of built-in interpolation.
Here is my current attempt to solve the problem:
while true do
wait()
local v1 = workspace.p1.Position
local currentAngles = Vector3.new(script.Parent.CFrame:ToEulerAnglesXYZ())
local targetAngles = Vector3.new(CFrame.new(script.Parent.CFrame.p, v1):ToEulerAnglesXYZ())
local angularDisplacement = targetAngles - currentAngles
script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(angularDisplacement.x, angularDisplacement.y, angularDisplacement.z)
end
This causes strange behavior when the part reaches a certain range, I would also maintain that there is likely a more efficient way to do this. A friend suggested that I attempt to normalize the vectors representing the Euler angles but to no avail. Any attempt to help would be appreciated.