This tutorial will describe setting up Cirrus SR22 in an empty Unity scene. The end result scene of the guide is included in the project and is named TutorialScene.
Cirrus SR22 model can be found under NWH ⇒ Aerodynamics ⇒ Models directory.
Reading the Airfoil documentation before starting the aircraft setup is highly recommended
Scene.GameObject and name it SceneManager.InputSystemAircraftInputProvider and InputSystemSceneInputProvider - these will handle the user input.ShiftingOrigin to SceneManager - more about shifting origin here.Terrain to the scene and position it at [-500, 0, -500] to center it.MeshRenderer on them. Add MeshCollider to all four. It is important that a Rigidbody has at least one collider.AircraftController to the parent object (Cirrus SR22 in this case). This will add other required components automatically.Variable Center Of Mass inspector adjust the Base Mass to 1000 and set the Center Of Mass Offset to [0, -0.18, 0.9].Use Default Inertia and adjust the Dimensions field if required. Dimensions are displayed as gizmo lines. Red for width, green for height and blue for length. After adjusting the dimensions click Update Inertia Tensor.That is it for the core aircraft setup. The next step is making the aircraft fly.
CameraChanger component to the newly created object.Camera and parent it to the Cameras object and add CameraMouseDrag component to it.Distance field of CameraMouseDrag to 10.Tips:
Airfoils should extend up to roughly the centerline of the aircraft as in the image above.To test out the setup place the aircraft 500m above the ground and press play. It should slowly tip forward and gain speed.
Once the Airfoils are set up as per the instructions above the aircraft should look like this:
Besides airfoils aircraft also have objects that contribute little or nothing to lift, but do cause drag. In NWH Aerodynamics these can be set up using AerodynamicDragObject.
AerodynamicDragObject component to the Fuselage object.Center and Dimensions so that the box gizmo roughly matches the shape of the fuselage.After pressing play, currently the aircraft drops to the ground. To prevent this we need to add the landing gear.
LandingGear component to LandingGear_F, LandingGear_L and LandingGear_R.Position field to match the position of the landing gear.MeshFilter and MeshRenderer from the duplicated objects. These will act as holders for WheelCollider.WheelCollider to all three duplicated objects and adjust the Radius field until the gizmo matches the wheel size.WheelCollider to Wheel Collider field of LandingGear component added in first step. Also assign the corresponding wheel meshes to the Wheel field (LG_F_Wheel to LandingGear_F, etc.).Max Steer Angle to 10 for the LandingGear_F. This value can be set to 0 for wheels that do not steer, a positive value for normal steering, or a negative value for inverse steering (e.g. rear wheel).Static Transform field.
The landing gear for Cirrus SR22 is now set up. For more details on LandingGear check out this page.
The final step to setting up a functional aircraft is adding propulsion.
Cirrus SR22 is propelled by a piston engine connected to a variable-pitch propeller so PistonEngine and PropellerPropulsor will be used.
PistonEngine to the Engine object and set the Max Power to 400 and Starter Torque to 150.PropellerPropulsor the the Propeller object and assign it to the Propulsors field of PistonEngine.Thrust Point and Thrust Direction of the PropellerPropulsor. Variable Prop Pitch. Also tick Auto Prop Pitch.To test the propulsion enter play mode and hold the T key for 2 to 3 seconds to start the engine. Afterwards, press F4 to increase the throttle to 100%. After gaining some speed the aircraft will be able to take off.
The aircraft is now fully functional but is lacking sound.
AircraftSoundManager to the aircraft. EngineStartingAircraftSoundComponent and EngineRunningAircraftSoundComponent to the Engine object.WindAircraftSoundComponent and CrashAircraftSoundComponent to the Cirrus SR22 object. These can be placed anywhere on the aircraft.Press play to test out the sounds.
For testing purposes a DemoReadouts component can be helpful as it shows the basic flight data. This step is optional but recommended.
Canvas and create a child Panel.Image.DemoRedouts to the panel and set the Readout Prefab field to NWH/Aerodynamics/Scripts/AircraftController/Demo/Readout.prefab.Grid Layout Group with Cell Size of [100, 50] to the panel.Target AC.Pressing play will now produce a row of basic flight data readouts.
The basic aircraft setup is now finished. For steps on setting up other optional aspects of the aircraft such as lights, instruments and fuel check out their respective pages: