Howto:Add aerotow hitch to an AI-aircraft

From FlightGear wiki
Jump to navigation Jump to search

For the visualization of the tow rope, it is advantageous if a hitch position is defined for the AI tow plane.

To set the hitch position for the AI aircraft, add the following code to the top of the {aircraft}-ai.xml file:

<?xml version="1.0"?>
<PropertyList>

  <nasal>
    <load>
      var acNode = cmdarg(); # "/ai/models/aircraft"
      acNode.getNode("sim/hitches/aerotow/local-pos-x", true).setValue(x); # forward
      acNode.getNode("sim/hitches/aerotow/local-pos-y", true).setValue(y); # left
      acNode.getNode("sim/hitches/aerotow/local-pos-z", true).setValue(z); # up
    </load>
    <unload>
      acNode.getNode("sim/hitches").remove();
    </unload>
  </nasal>

  <!-- Rest of content here -->

</PropertyList>

In place of x, y, z, enter appropriate values for the hitch position. Coordinate system: x forward, y to the left, and z up. The units are meters.

That's it! The tow rope ends at the defined position.

Related content