I am trying to make a gun rotate on a mount using a Motor.
The problem is that the motor seems to snap to increments instead of moving to the exact desired angle.
See the video below:
robloxapp-20200429-1357538.wmv (114.7 KB)
I couldn’t find any documentation on this behavior.
Here is my current code:
while true do
wait()
local t = time() * 0.1
motor1:SetDesiredAngle(t)
end
I know I can decrease the max rotation speed of the motor, but that doesn’t fix the angle snapping effect.
If I print out the CurrentAngle of the motor in the loop, I get this:
0 (x4)
0.037916667759418 (x9)
0.075833335518837 (x12)
0.11583334207535 (x13)
0.15916667878628 (x13)
0.20250001549721 (x14)
0.24875001609325 (x14)
0.2954166829586 (x15)
0.34541669487953 (x15)
0.39541667699814 (x8)
Clearly it is snapping the motor to specific angles. (The increment is about 7/150.)
Even if I remove the loop and set the angles directly, the actual angle snaps to unusual increments. For example:
motor1:SetDesiredAngle(1.01)
wait(0.5)
print(motor1.CurrentAngle)
motor1:SetDesiredAngle(1.03)
wait(0.5)
print(motor1.CurrentAngle)
motor1:SetDesiredAngle(1.07)
wait(0.5)
print(motor1.CurrentAngle)
motor1:SetDesiredAngle(1.25)
wait(0.5)
print(motor1.CurrentAngle)
This prints
1.0099999904633
1.0099999904633
1.0099999904633
1.25
Does anyone know of a way around this? I would like to avoid updating the joint on every frame if possible. I basically need some sort of motorized ball-socket constraint, but one doesn’t seem to exist.