Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why doesn't the DesiredAngle update as smoothly as the required angle in a motor object?

Asked by 8 years ago

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

0
@TurboFusion What is 'Pos'? DigitalVeer 1473 — 8y
0
@DigitalVeer I updated the question TurboFusion 1821 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

0
Damn. Thanks anyways TurboFusion 1821 — 8y
Ad

Answer this question