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

Relative rotations with limits?

Asked by
pidgey 548 Moderation Voter
5 years ago

I'm trying to make a simple flying system, however, I'm having an issue with the gyro.

How do I make a gyro rotate a Part relative to its base with a limit of rotation?

Throttle is just a number -1, 0, or 1 that the client passes to the server to handle direction to the vehicle

BodyGyro.CFrame = Top.CFrame * CFrame.Angles(-Throttle * math.rad(45), 0, Steer * math.rad(25))

https://i.imgur.com/RtsoQla.gifv This will rotate the model relative to the top axis, but Top.CFrame's angles will update and the new rotation will be applied in its place making it spin limitless

BodyGyro.CFrame = CFrame.Angles(-Throttle * math.rad(45), 0, Steer * math.rad(25))

https://i.imgur.com/AMEAtEr.gifv This, however, will rotate the model relative to the world axis. It will also never exceed the rotation of Throttle * 45 because the world doesn't ever change orientation. Also, it always turns facing the world axis as well. That doesn't really make sense in real life. Do I need to do something with the Y value?

Help would be appreciated

Answer this question