Posted June 26, 2025 by Shivani
drone controls
public class DroneInputHandler : MonoBehaviour
// Properties public Vector2 Cyclic { get => cyclic; } public float Pedals { get => pedals; } public float Throttle { get => throttle; }
The DroneInputHandler.cs script handles the player input using Unity's new input system. It requires a PlayerInput component provided by Unity, which allows the input to receive messages from the script created.
public class DroneRigidbody : MonoBehaviour
private void FixedUpdate() { HandleDronePhysics(); } protected virtual void HandleDronePhysics() { }
The DroneRigidbody.cs script utilises the default rigidbody component provided by Unity, allowing me to customise the properties via code. It also allows me to seperate code into specific scripts. For this script, I created a protected virtual function that can be inherited in another script.
public class DroneController : DroneRigibody
protected override void HandleDronePhysics() { HandleDroneControls(); }
This script inherits from the drone rigidbody, which allows it to access any protected functions or variables. I overrode the HandleDronePhysics() function, which enables me to add any physics-related functionality.