How do I do the Motor6D equivalent of a CFrame.lookAt

I’m trying to make a Motor6D have it’s part face a position, and I think I’m quite close, however, it does something weird which kind of just makes it look the opposite way.


Above is the video, this is the script:

local tweencframe = (CFrame.lookAt(NPC.HumanoidRootPart.Position, Position) - NPC.HumanoidRootPart.CFrame.Position) * CFrame.Angles(math.rad(90),math.rad(180),math.rad(-90))
local tweencframe = tweencframe * CFrame.Angles(-math.rad(tweencframe.Rotation.X),-math.rad(tweencframe.Rotation.Y),-math.rad(tweencframe.Rotation.Z))
turncurrenttween = TS:Create(NPC.HumanoidRootPart.RootJoint,TweenInfo.new(Config.Manueverability,Enum.EasingStyle.Linear),{C1 = tweencframe})
turncurrenttween:Play()

I’m not sure how to actually do cframe math, I’ve tried making a negative angle and adding that or something, but I’m not sure how to actually do this. I know I’ve made something similar where the rotations seem to rotate the opposite way, but I still am not very sure why this is. Thanks!

Note: It also does the inverse movements when looking up and down.

2 Likes

This is my current script, the npc seems to just kind of… spin around.

local tweencframe1 = CFrame.lookAt(NPC.BodyGyro.Position, Position)
local tweencframe = worldCFrameToC0ObjectSpace(NPC.HumanoidRootPart.RootJoint,tweencframe1)

I’m not sure, but maybe my C0 and C1 is mixed? But inverting the function itself just kind of makes it spin aswell. I’ll check for now.

Oh, nevermind, I did in fact mix the C0 and C1. Thank you very much!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.