Hingeconstraint turret won't point towards mouse when what it's mounted to isn't pointing straight

Hi, I made a turret controlled by HingeConstraints that’s mounted onto a moving object. It functions normally until it’s mount is turned in anyway that isn’t facing forward. I don’t know what I could do to fix it, I’ve tried inverting it when the mount is at a specific orientation, but it doesn’t work.

^ Its normal behavior

^ Its weird behavior

^ The code used to rotate the turret.

Any suggestions and help would be greatly appreciated, I’ve been on this issue for days.

servo.TargetAngle = math.deg(-theta) + turretBase.Orientation.Y

Worked for me.

(what i did)

local AngleX = math.atan2(MyX, MyZ) + math.rad(-Turret.ReferenceCFrame.Orientation.Y) + math.rad(-90)
1 Like

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