Hey everyone,
I’ve been trying to use trig to make an object look at a certain position. Here’s a video of my attempt:
Here’s the code for it:
local part = workspace.Part;
local follow = workspace.follow;
follow.Changed:Connect(function()
local follow_from_part = part.CFrame:ToObjectSpace(follow.CFrame)
-- lol SOH (sin -> opp/hyp)
local hypotenuse = math.abs(follow_from_part.Position.Magnitude)
local opposite = math.abs(follow_from_part.X)
part.CFrame *= CFrame.Angles(0, -math.asin(opposite/hypotenuse), 0)
end)
As you can see, it does these weird glitches when it rotates sometimes. I’m not sure what I did wrong so if you know, please leave a reply down below. Thanks!
PS: note that I’m not the best at math; might not understand what you are saying