-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsystem.flush()
10 lines (8 loc) · 904 Bytes
/
system.flush()
1
2
3
4
5
6
7
8
9
10
--in the system slot, flush() filter, insert the following somewhere below Axis but above Rotation.
-- Pitch Helper
if PitchHelper == 1 then
local currentPitchDeg = math.max(math.min(getRoll(worldVertical, constructRight, -constructForward)/60, 1), -1) -- Angle of construct's current pitch, expressed as a value between -1 and 1, up to 60 degrees
local heightDiff = math.max(math.min((TargetAltitude - core.getAltitude())/1000, 1), -1) -- Difference between current and target altitude; values expressed between -1 and 1, up to 1000m
local verticalSpeed = vec3(core.getWorldVelocity()):dot(-vec3(core.getWorldVertical()))*3.6/2500 -- Speed moving up/down, in km/h, divided by 1000
finalPitchInput = (heightDiff - currentPitchDeg) - verticalSpeed -- Increase pitch relative to needed altitude change, decrease relative to current pitch, decrease relative to current vertical speed
end