Spaceship Controller
The VehicleEngines3D component provides a way to easily control a vehicle in 3D space.

Activating/Deactivating The Engine

To activate/deactivate the spaceship engines, call the SetEngineActivation function with a parameter of True to activate and False to deactivate.

Steering And Movement

This component provides a way to send input for steering, movement (3D movement including strafing left/right and up/down) and boost (forward).
This input ranges between -1 and 1, which an 'amount' that is multiplied by the values you set in the inspector of the VehicleEngines3D component to determine the forces (movement) and torques (steering) that are applied to the ship's Rigidbody.
To control a spaceship, begin by adding a VehicleEngines3D component to the root transform of your ship.
To make a spaceship move, call the SetMovementInputs function on the VehicleEngines3D component.
This function takes a Vector3 value: - The X value represents sideways movement (-1 is full left, 1 is full right). - The Y value represents up/down movement (-1 is full down, 1 is full up). - The Z value represents forward/back movement (-1 is full backward, 1 is full forward).
To make a spaceship steer, call the SetRotationInputs function on the VehicleEngines3D component.
This function takes a Vector3 value: - The X value represents X-axis rotation (pitch up/down) (-1 is full pitch up, 1 is full pitch down). - The Y value represents Y-axis rotation (yaw left/right) (-1 is full yaw left, 1 is full yaw right). - The Z value represents Z-axis rotation (roll left/right) (-1 is full roll right, 1 is full roll left).
To make a spaceship boost, call the SetBoostInputs function on the VehicleEngines3D component. NOTE: boost currently only works on the forward axis, this will be corrected soon. This function takes a Vector3 value: - The X value represents X-axis boost (-1 is full boost left, 1 is full boost right). - The Y value represents the Y-axis boost (-1 is full boost down, 1 is full boost up). - The Z value represents Z-axis boost (-1 is full boost back, 1 is full boost up).
The VehicleEngines3D component also provides functions for incrementing the steering and movement values (rather than setting them directly).

Setting Maximum Limits

In the inspector of the VehicleEngines3D component, you can set the maximum limits for the amount of force (movement) and torque (steering) that can be applied to the vehicle.
To set the maximum forces (movement) that can be applied to the ship, set the 'Max Movement Forces' (Vector3) in the inspector.
These are the maximum forces that can be applied on each axis (X-axis left/right, Y-axis up/down, Z-axis forward/back) both in the negative and positive directions.
To set the maximum torques (steering forces) that can be applied to the ship, set the 'Max Steering Forces' (Vector3) in the inspector.
These are the maximum steering forces that can be applied to turn the ship around each axis (X-axis pitch, Y-axis yaw, Z-axis roll) both in the negative and positive directions.
​
​
Last modified 1yr ago
Copy link