Advertisement
Guest User

Untitled

a guest
Nov 8th, 2013
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. thrustAngle = getThrustAngleFromEngine();
  2. //Current angle engines are thrusting at. I'm assuming 90 degrees = vertically downwards, 0 degrees = forward.
  3. verticalSettingsRatio = sin(thrustAngle);
  4. //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
  5. forwardSettingsRatio = cos(thrustAngle);
  6. //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
  7.  
  8. maxThrustBiasPitch = 0.2;
  9. maxThrustBiasRoll = 0.2;
  10. maxThrustBiasYaw = 0.2;
  11. //These 3 are the maximum offset from default thrust allowed. If throttle = 100kN, these will allow a range of 80-120kN
  12. maxThrustAnglePitch = 15;
  13. maxThrustAngleRoll = 15;
  14. maxThrustAngleYaw = 15;
  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
  16.  
  17. function calcPitchBehaviour(thrustAngle){
  18. thrustBias = maxThrustBiasPitch * gameInputs.pitch; //Or however you get pitch from the game. I am blissfully ignorant of such things.
  19. frontThrust *= 1 + thrustbias
  20. rearThrust *= 1 - thrustBias //These do not get sent to the engines yet. That comes later.
  21.  
  22. frontAngleModifier = maxThrustAnglePitch * gameInputs.pitch
  23. rearAngleModifier = maxThrustAnglePitch * gameInputs.pitch //Again these are not actually applied to the engines yet
  24.  
  25. frontThrustToSend = regularThrust * frontThrust * verticalSettingsRatio;
  26. rearThrustToSend = regularThrust * rearThrust * verticalSettingsRatio;
  27. //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
  28.  
  29. frontAngleToSend = regularThrustAngle + frontAngleModifier * forwardSettingsRatio;
  30. rearAngleToSend = regularThrustAngle + rearAngleModifier * forwardSettingsRatio;
  31. //This basically just causes the engines to use 0% direction control when vertical, climbing to 100% directional control in forward flight
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement