How to use ExternalForce in Unreal Engine #1340
Replies: 3 comments 6 replies
-
|
I'd suggest taking a look at some of the JSBSim based aircraft models that are used in FlightGear with an aircraft carrier, for example here are some snippets from @Zaretto's F-14 model. <pure_gain name="systems/catapult/cat-force">
<input>inertia/weight-lbs</input>
<gain>3</gain>
</pure_gain>
<switch name="systems/catapult/cat-final">
<default value="0"/>
<test logic="AND" value="systems/catapult/cat-force">
systems/catapult/cat-launch-cmd == 1
systems/catapult/cat-pos-norm lt 0.999
systems/catapult/cat-pos-norm gt 0.0
gear/unit[0]/WOW ne 0
</test>
<output>external_reactions/catapult/magnitude</output>
</switch>So you can see he's generating a catapult force that is equal to 3 times the aircraft's weight, and assuming the catapult is engaged etc. it outputs this force to the property Then in the FDM for the F-14 he defines the location and direction of the https://github.com/Zaretto/f-14b/blob/d592041d50d74916a3e45c172333d8882151c0fa/f-14b.xml#L3084-L3095 <force name="catapult" frame="BODY">
<location unit="IN">
<x> 667 </x>
<y> 0 </y>
<z> 0 </z>
</location>
<direction>
<x> 1 </x>
<y> 0 </y>
<z> 0 </z>
</direction>
</force>@Zaretto I was expecting the catapult force to be applied to the nose landing gear, but looking at the locations it doesn't look like it's applied to the nose landing gear. Any particular reason for the choice of the location for the catapult external force? <contact type="BOGEY" name="NOSE_LG">
<location unit="IN">
<x> 197 </x>
<y> 0 </y>
<z> -92 </z>So in your Unreal based application all you need to do is set the magnitude for the external reaction property. |
Beta Was this translation helpful? Give feedback.
-
|
The catapult take-off is a lot easier than the arrested landing. For the arrested landing you'll need to write some code to work out whether the tailhook has engaged one of the arrestor wires. You can take a look at the FlightGear source code to see how they do it in https://gitlab.com/flightgear/flightgear/-/blob/release/2024.1/src/FDM/JSBSim/JSBSim.cxx#L1429 Once FlightGear detects that the tailhook has engaged an arrestor wire it sets a property and then relies on the aircraft model to calculate and return the force applied by the arrestor wire via the property - <fcs_function>
<description>
Hook deceleration force.
</description>
<function>
<product>
<p>systems/hook/arrestor-wire-available</p>
<p>systems/hook/funcs/hook-operational-efficiency</p>
<sum>
<!-- Simulate the operation of arrestor wire;
1. overspeed will reduce the effiency, up until
2. up until a 15kts overspeed at which point the arrestor will will no longer work
3. the arrestor wire will take 60 seconds to reset
4. arrestor-wire-available; this is 1 or 0 as a function of the maximum contact speed. -->
<p>forces/fbx-prop-lbs</p>
<product>
<p>systems/hook/hook-decel-multiplier</p>
<p>inertia/weight-lbs</p>
</product>
</sum>
</product>
</function>
<output>systems/hook/force</output>
</fcs_function>FlightGear then goes ahead and uses fgSetDouble("/fdm/jsbsim/external_reactions/hook/magnitude", fgGetDouble("/fdm/jsbsim/systems/hook/force"))With the FDM developer specifying a location and direction for this external hook force in their FDM. https://github.com/Zaretto/f-14b/blob/d592041d50d74916a3e45c172333d8882151c0fa/f-14b.xml#L3110-L3121 <force name="hook" frame="BODY">
<location unit="IN">
<x> 300 </x>
<y> 0 </y>
<z> 0 </z>
</location>
<direction>
<x> -0.9995 </x>
<y> 0.0 </y>
<z> 0.01 </z>
</direction>
</force> |
Beta Was this translation helpful? Give feedback.
-
As I mentioned above, all you need to do is update the JSBSim property based on the name of the external force that you have defined in your aircraft's FDM, for example based on the F-14 example it would be If you're specifically asking how to update JSBSim properties from Unreal have you looked at the documentation? https://github.com/JSBSim-Team/jsbsim/tree/master/UnrealEngine#extended-commands-and-properties |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How to use ExternalForce in Unreal Engine to achieve aircraft catapult takeoff or arrested landing
Beta Was this translation helpful? Give feedback.
All reactions