HoverKit  1.0
The best hovercraft physics library available for Unity
HoverMovement Class Reference

The HoverMovement Component is responsible for providing your vehicle's forward and lateral movement. It continuously calculates and applies the correct physics forces necessary to move the vehicle's Rigidbody in the desired direction at the desired speed. More...

Inheritance diagram for HoverMovement:

Detailed Description

The HoverMovement Component is responsible for providing your vehicle's forward and lateral movement. It continuously calculates and applies the correct physics forces necessary to move the vehicle's Rigidbody in the desired direction at the desired speed.

To move the vehicle, simply set the ForwardSpeed and/or LateralSpeed properties (or call the SetSpeedNormalized function) to indicate the speed at which you'd like the vehicle to move, and the HoverMovement Component takes care of the rest. This makes it easy to drive the vehicle from user input or even an AI script.

Public Member Functions

void SetSpeedNormalized (float forwardSpeedNormalized, float lateralSpeedNormalized)
 Sets the vehicle's ForwardSpeed and LateralSpeed properties. More...
 

Public Attributes

Rigidbody TargetRigidBody
 The Rigidbody instance that will be updated by this component. More...
 
float DriftCancellation = 1f
 Specifies the amount of momentum cancellation that will be applied. Higher values will result in the vehicle coming to a stop quicker, while lower values will cause the vehicle to drift longer before coming to a stop. If this value is set to zero, no momentum cancellation will be performed, and the vehicle will drift forever in the last direction of movement. Perhaps more importantly, drift cancellation is also used when the vehicle is cornering, to counter the sideways drift that results from the previous forward movement. In this case, higher DriftCancellation values will result in sharper turns with less sideways drift, while lower values will result in wide cornering and more sideways drift. More...
 
float MaxForwardSpeed = 20f
 The max speed (in meters per second) that the craft can move forward. More...
 
float MaxReverseSpeed = 10f
 The max speed (in meters per second) that the craft can move in reverse. More...
 
float MaxLateralSpeed = 15f
 The max speed (in meters per second) that the craft can move laterally (strafing). More...
 
float MaxForwardForce = 10000f
 The maximum amount of force that can be applied to the RigidBody in the forward direction. More...
 
float MaxBackwardForce = 5000f
 The maximum amount of force that can be applied to the RigidBody in the backward direction. More...
 
float MaxLateralForce = 10000f
 The maximum amount of force that can be applied to the RigidBody in the sideways direction. More...
 
float InAirForceMultiplier = 0f
 The amount of force to apply when the vehicle is in the air (not grounded) More...
 
bool EnablePowerCurves = false
 When set to TRUE, the ForwardPowerCurve and LateralPowerCurve curves will be applied to the component's force output. In most cases this will not be necessary, as the movementPID configuration already provides a great deal of flexibility, but has been included for those situations where a finer level of control is desired. More...
 
AnimationCurve ForwardPowerCurve = new AnimationCurve( new Keyframe( 0f, 0f, 0f, 1f ), new Keyframe( 1f, 1f, 1f, 0f ) )
 When EnablePowerCurve is TRUE, this animation curve will be used to modify the component's force output in the forward/backward direction. More...
 
AnimationCurve LateralPowerCurve = new AnimationCurve( new Keyframe( 0f, 0f, 0f, 1f ), new Keyframe( 1f, 1f, 1f, 0f ) )
 When EnablePowerCurve is TRUE, this animation curve will be used to modify the component's force output in the left/right direction. More...
 

Properties

float ForwardSpeed [get, set]
 Gets or sets the desired forward (or backward if negative) speed (in m/s) More...
 
float LateralSpeed [get, set]
 Gets or sets the desired lateral speed (in m/s) More...
 
Vector3 EngineOutput [get]
 Returns the amount of force currently being applied on each local axis More...
 

Member Function Documentation

void SetSpeedNormalized ( float  forwardSpeedNormalized,
float  lateralSpeedNormalized 
)

Sets the vehicle's ForwardSpeed and LateralSpeed properties.

Parameters
forwardSpeedNormalizedA normalized (0..1) value indicating the percentage of MaxForwardSpeed to assign to the ForwardSpeed property.
lateralSpeedNormalizedA normalized (0..1) value indicating the percentage of MaxLateralSpeed to assign to the ForwardSpeed property.

Property Documentation

Vector3 EngineOutput
get

Returns the amount of force currently being applied on each local axis

float ForwardSpeed
getset

Gets or sets the desired forward (or backward if negative) speed (in m/s)

float LateralSpeed
getset

Gets or sets the desired lateral speed (in m/s)