Upgrading Drone Controls from Legacy Input to the new Input System
New Input System Framework
Objective: Learn how to upgrade your drone controls from Unity’s Legacy Input System to the New Input System.
This tutorial is part of the Software Engineering Framework developed by Game Dev HQ.
We’ll jump straight into upgrading the existing drone control code. If you’re new to the New Input System, check out these helpful resources first
💡 Need help setting up Input Actions Scripts? [Click here]
💡 New to the Input System? [Start here].
Additional links will be provided throughout the article to support you as needed.
Table of Contents
· EnablingDrone Input
· Disabling Drone Input
· Update Logic — Rotation
∘ Refactoring for the New Input System:
· Calculating Drone Tilt
∘ Refactored for the New Input System:
∘ Tilt Movement Result
· Fixed Update Logic — Vertical Movement
∘ Refactored Logic
∘ Up and Down Movement Result
EnablingDrone Input
Initializing Action Maps
Drone controls can be complex, so we’ll take it step-by-step. Unlike our player controller upgrade, drone input must be initialized directly within the drone script, since we’re toggling between player mode and drone mode dynamically.
🔍Code Highlights
- The
EnterFlightMode()method is responsible for switching control from the player to the drone. - This is the ideal place to initialize drone-specific input using the New Input System.
- (We’ll cover interactable zone logic in a separate article.)
Initialize Drone Input in the Input Manager
All input logic is handled in a centralized Input Manager Script. This keeps things modular and clean.
💡 Want to learn more? Check out:
The Best Way to Organize Input Scripts
🔍Code Breakdown
- We create a public method in the Input Manager that handles drone input initialization.
- The player input is disabled through the Input Actions reference.
- The drone input is then enabled from the same reference.
- Reference the Input Manager object in the Drone Script through the Inspector.
- Finally, call this method inside the drone’s
EnterFlightMode()method.
Disabling Drone Input
When exiting drone mode, we’ll want to re-enable player controls and disable drone input.
The starter code already has an method to handle this, so it should follow the same logic as theEnterFlightMode() method.
- Create a separate public method in the Input Manager to disable drone input.
- Call this method in the
ExitFlightMode()method within the drone script. - This mirrors our initialization process and keeps logic cleanly separated.
Update Logic — Rotation
Drone movement consists of rotation (handled in Update()) and physics-based movement (handled in FixedUpdate()).
🔍Original Code Observation:
- Rotation is manually calculated per key (e.g., left/right arrow).
- A temporary rotation variable (
tempRot) stores euler angles. - Left rotation subtracts from the Y-axis; right adds to it.
With the new unity input system, we don’t need to hard code this rotational values, instead we can use a context variable, and reduce this bulk of code to a few lines.
Refactoring for the New Input System:
🔍Code Breakdown
- Create a public method in the Drone Script for rotation.
- Add a float
rotInputparameter, which will hold the input value from the Input Manager. - Use the
rotInputvalue to apply rotation dynamically based on input. - Update the local rotation with
transform.localRotation.
By refactoring our code, we significantly reduce the bulk of it as we no longer need to hard-code movement logic per-key.
Registering Rotation Input
In the Input Manager’s Update() method, we’ll register the rotation input:
🔍Code Breakdown
- Create a
float rotInputvariable to match the Drone’sCalculateRotation(rotInput)method. - Use a 1D Axis Input Map (left = -1, right = 1).
- Use
ReadValue<float>()to read the live input value. - Pass it into the Drone’s method to apply rotation in real-time.
Rotation Movement Result
Calculating Drone Tilt
Like rotation, tilt was previously handled through repetitive code for each key.
🔍Original Code Observation
- Tilts the drone using fixed 30-degree rotations for WASD keys.
- Each direction required its own manual input logic.
💡If you need help setting up a WASD(Vector 2) Action Map click [here].
Refactored for the New Input System:
🔍Code Breakdown
- Change the tilt method to public
- Add a
Vector2 tiltInputparameter to match WASD directional input - Use the tilt input to calculate and apply a consistent 30-degree tilt in the appropriate direction.
Registering Tilt Input
n the Input Manager’s Update() method.
🔍Code Breakdown
- Create a
Vector2 tiltInputvariable to match theCalculateTilt(Vector2 tilt)method. - Use
ReadValue<Vector2>()to capture live directional input. - Pass this into the Drone’s tilt logic for smooth control.
Tilt Movement Result
Fixed Update Logic — Vertical Movement
Vertical movement (up and down) is handled through physics in FixedUpdate().
🔍Original Code Observation:
- Uses
Rigidbody.AddForce()withForceMode.Acceleration. - Direction is set manually for each key (e.g., up arrow =
transform.up, down arrow =-transform.up). - Movement depends on direction and speed.
Refactored Logic:
The code can be reduced to a single line.
🔍Code Breakdown
- Change the method to public so it can be accessed by the Input Manager.
- Add a
float directionparameter to determine movement direction from input. - Use a 1D Axis Input Map (up = 1, down = -1).
- Apply a single force line using the direction variable and
ForceMode.Acceleratio
Registering Vertical Movement Input
In the Input Manager’s FixedUpdate() method:
🔍Code Breakdown
- Create a
float directionvariable to match the drone's vertical movement method. - Add a condition to check if the input is not zero (i.e., -1 or 1).
- If valid, call the drone’s method and apply the directional force (optionally invert the direction if needed)
Up and Down Movement Result
Your drone input is now modular, optimized, and future-proof!
✅Clean separation between input logic (Input Manager) and drone behavior (Drone Script)
✅ Refactored methods that are scalable, readable, and easy to manage
✅ A fully functional drone controller powered by Unity’s New Input System
Thanks for reading!
If you found this guide helpful, feel free to check out [my portfolio] or follow me — I’m currently open to opportunities in the video game industry! 😊
