13,212
edits
m (First section: bullet effects → gun effects, etc) |
(xml highlighting etc) |
||
Line 5: | Line 5: | ||
There is no default key/button binding for a trigger in FlightGear, so you will have to make your own. An obvious choice of button would be the trigger on a [[joystick]], but you can also make a keyboard binding by adding something like this to your <tt>[[$FG ROOT]]/keyboard.xml</tt> file: | There is no default key/button binding for a trigger in FlightGear, so you will have to make your own. An obvious choice of button would be the trigger on a [[joystick]], but you can also make a keyboard binding by adding something like this to your <tt>[[$FG ROOT]]/keyboard.xml</tt> file: | ||
<syntaxhighlight lang="xml"> | |||
<key n="101"> | <key n="101"> | ||
<name>e</name> | <name>e</name> | ||
Line 21: | Line 22: | ||
</mod-up> | </mod-up> | ||
</key> | </key> | ||
</syntaxhighlight> | |||
In the code, we have used | In the code, we have used the {{key press|e}} key as the trigger. You can change it to a choice of your own but {{key press|e}} is the standard key binding used by most aircraft in FlightGear. | ||
Joystick bindings are a bit more complex. Sample code is below, but you | Joystick bindings are a bit more complex. Sample code is below, but you may want to read the article on [[Input device|joysticks]]. | ||
See more complex/complete sample code below. | See more complex/complete sample code below. | ||
== Adding | == Adding gun and bullet effects to your aircraft == | ||
Once you have a key or button binding defined to active the trigger, you'll then need to add the needed [[AI Systems#Submodels]] | Once you have a key or button binding defined to active the trigger, you'll then need to add the needed [[AI Systems#Submodels|submodel configuration file]] to your aircraft's root directory, and ensure the file is activated in your *-set.xml file. The choice of tracer, smoke and impact visual models is up to you. You may also add a sound effect to your sound configuration file that activates with the trigger. | ||
The standard trigger location for FlightGear is | The standard trigger location for FlightGear is | ||
Line 44: | Line 46: | ||
In a submodel.xml file, this typically looks something like this: | In a submodel.xml file, this typically looks something like this: | ||
<syntaxhighlight lang="xml"> | |||
<submodel> | <submodel> | ||
<name>cowl-guns-bullets</name> | <name>cowl-guns-bullets</name> | ||
Line 49: | Line 52: | ||
<trigger>/controls/armament/trigger</trigger> | <trigger>/controls/armament/trigger</trigger> | ||
. . . | . . . | ||
</syntaxhighlight> | |||
== Aircraft already equipped with guns == | == Aircraft already equipped with guns == | ||
Line 89: | Line 93: | ||
The following code, which you can place in your keyboard.xml file or (if you are an aircraft designer) in your aircraft's -set.xml file in the <keyboard> section, triggers both locations, both types of armament, and works with almost all FG aircraft. | The following code, which you can place in your keyboard.xml file or (if you are an aircraft designer) in your aircraft's -set.xml file in the <keyboard> section, triggers both locations, both types of armament, and works with almost all FG aircraft. | ||
It uses | It uses {{key press|e}} to trigger the main armament and {{key press|Shift|e}} to trigger the secondary: | ||
<syntaxhighlight lang="xml"> | |||
<key n="101"> | <key n="101"> | ||
<name>e</name> | <name>e</name> | ||
Line 133: | Line 138: | ||
</mod-up> | </mod-up> | ||
</key> | </key> | ||
</syntaxhighlight> | |||
== Sample joystick code == | == Sample joystick code == | ||
Line 138: | Line 144: | ||
This sample code that can be modified/inserted into a joystick XML file uses one button to trigger the main armament and another button to trigger the secondary armament: | This sample code that can be modified/inserted into a joystick XML file uses one button to trigger the main armament and another button to trigger the secondary armament: | ||
<syntaxhighlight lang="xml"> | |||
<button n="0"> | <button n="0"> | ||
<name>trigger</name> | <name>trigger</name> | ||
Line 176: | Line 183: | ||
</mod-up> | </mod-up> | ||
</button> | </button> | ||
</syntaxhighlight> | |||
[[Category:Aircraft enhancement]] | [[Category:Aircraft enhancement]] | ||
[[Category:Howto]] | [[Category:Howto]] |