Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thrustAngle = getThrustAngleFromEngine();
- //Current angle engines are thrusting at. I'm assuming 90 degrees = vertically downwards, 0 degrees = forward.
- verticalSettingsRatio = sin(thrustAngle);
- //Will be '1' when engines are angled at 90 degrees for vertical ascent, and will be '0' when engines are set to 0 degrees for forward flight
- forwardSettingsRatio = cos(thrustAngle);
- //Will be '0' when engines are angled at 90 degrees for vertical ascent, and will be '1' when engines are set to 0 degrees for forward flight
- maxThrustBiasPitch = 0.2;
- maxThrustBiasRoll = 0.2;
- maxThrustBiasYaw = 0.2;
- //These 3 are the maximum offset from default thrust allowed. If throttle = 100kN, these will allow a range of 80-120kN
- maxThrustAnglePitch = 15;
- maxThrustAngleRoll = 15;
- maxThrustAngleYaw = 15;
- //These 3 are the maximum offset from the 'set' angle allows. If angle = 45 degrees (firing diagonally down and backwards), these will allow a range of 30-60 degrees
- function calcPitchBehaviour(thrustAngle){
- thrustBias = maxThrustBiasPitch * gameInputs.pitch; //Or however you get pitch from the game. I am blissfully ignorant of such things.
- frontThrust *= 1 + thrustbias
- rearThrust *= 1 - thrustBias //These do not get sent to the engines yet. That comes later.
- frontAngleModifier = maxThrustAnglePitch * gameInputs.pitch
- rearAngleModifier = maxThrustAnglePitch * gameInputs.pitch //Again these are not actually applied to the engines yet
- frontThrustToSend = regularThrust * frontThrust * verticalSettingsRatio;
- rearThrustToSend = regularThrust * rearThrust * verticalSettingsRatio;
- //Sorry this looks like a mess. This basically just causes the engines to use 100% thrust control when vertical, reducing to 0% thrust control in forward flight
- frontAngleToSend = regularThrustAngle + frontAngleModifier * forwardSettingsRatio;
- rearAngleToSend = regularThrustAngle + rearAngleModifier * forwardSettingsRatio;
- //This basically just causes the engines to use 0% direction control when vertical, climbing to 100% directional control in forward flight
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement