So basically I'm trying to use a motor object to smoothly rotate a tank barrel rather than using a weld and constantly using loops to smoothly rotate, but for some reason, when I move the mouse to rotate the barrel, the barrel rotates in steps rather than smoothly. As in, it'll smoothly rotate to 1 position, then I have to move my mouse a certain distance before it rotates again. I did debugging and the angle that I want the DesiredAngle to be is updating properly, the only problem is that the DesiredAngle itself is staying at a certain angle until I move the mouse a certain amount of degrees from the center. Is there any explanation to why this happens or any ways to fix this problem? Thanks.
Here's the code by the way:
--Pos is the mouse hit position local XCF = XMotor.Part1.CFrame:toObjectSpace(CF(XMotor.Part1.Position, Pos)) local XAng, _ = getAnglesYX(XCF) XMotor.DesiredAngle = XAng print(XAng, XMotor.DesiredAngle)
Also here's a gif of what's going on for better understanding
Assuming your script is working correctly, I'd say that this looks like an optimization by Roblox - "only rotate something if there's a significant difference between DesiredAngle and the current angle". One possible workaround would be to make DesiredAngle significantly different for one frame, then return it to where you want it. If you notice the motor overshooting the angle you actually want it at, you'd have to slow it down for the duration of that frame. If you end up slowing it down, you'll probably want to make sure that you only do this workaround when you need it (vs all the time) to ensure that the motor moves to the proper angle at the regular speed for large movements.