Hello everyone, I am trying to make the plane not go more up when hitting a limit, but it doesn’t work, here’s how I am checking it:
if planeModel.Body.Orientation.X < 65 or planeModel.Body.Orientation.X > -56 then
--make plane turn
end
Hello everyone, I am trying to make the plane not go more up when hitting a limit, but it doesn’t work, here’s how I am checking it:
if planeModel.Body.Orientation.X < 65 or planeModel.Body.Orientation.X > -56 then
--make plane turn
end
You could use math.clamp(). Basically, when you set planeModel.Body.Orientation.X
you can do something like…
math.clamp(yourValue, minValue, maxValue)
.
What this will do is make sure yourValue
is within the range of minValue
and maxValue
no matter what. If you assign yourValue
to 5, and minValue
to 7, math.clamp() will return 7, not 5; it works the same for maxValue if you exceed it.
Hope this helps.
It works, but I have a problem. When it passes the limit it stops turning, but it gets stuck forever. How could I make it so it can’t go through the limit but can still turn down after hitting the limit?