HoverLift Component

HoverLift

The HoverLift Component is responsible for providing your vehicle’s hovering capabilities. It does this by performing raycasts from user-defined points on the vehicle downward to the surface on which the vehicle should float. The results of these raycasts are used to determine the forces that need to be applied to the vehicle’s Rigidbody in order to make it hover at the specified height.

Physics

Target Rigid Body

Specifies which Rigidbody instance the component will operate on. If this field is left empty, on startup the HoverLift component will attempt to obtain a reference to a Rigidbody component on the same GameObject.

hoverlift-physics-section

Raycasting

Hover Points

This is an array of Transforms that specify each location where the HoverLift component should perform a raycast to the ground surface. For every Transform in this array, a raycast will be performed from the Transform’s world position along the Transform’s down direction. These Transforms can be empty GameObjects or child objects of the vehicle. They must be properly located in order to provide the correct balance, and the array should contain only as many entries as needed to provide a stable hovering behavior. As an example, you might choose to create empty GameObjects as a child of the vehicle, and place them at the four “corners” of the bottom of the vehicle with an unobstructed path for raycasting downward.

Hover Target Height

This field specifies how high the vehicle should hover above the ground surface.  The HoverLift component will always try to maintain this distance between each HoverPoint entry and the ground surface above which it is located.

Hover Ray Distance

Specifies the maximum distance for the raycast queries, and should be at least a little larger than the HoverTargetHeight value. For raycast queries that detect a surface that is closer than the distance specified in the HoverTargetHeight field, a lifting force will be applied to the corresponding HoverPoint entry. For hits that are farther than the distance specified by HoverTargetHeight, an attraction force may be applied (see the MaxAttractionForce field for more information).

Raycast Layers

Specifies which Layers the raycasts can be performed against, which is used to determine which types of surfaces the vehicle can hover above.

Ignore Triggers

If this field is set to TRUE, all Colliders that are configured as Triggers will be ignored by this component. The default value for this field is TRUE.

hoverlift-raycasting-section

Lift Forces

Max Lift Force

Specifies the maximum amount of lift force that can be applied to each HoverPoint to raise the vehicle off of the ground surface. This value should be at least large enough that the combined forces applied by all HoverPoints can lift the Rigidbody into the air, taking into account the Rigidbody’s total mass. The higher this value is, the quicker the vehicle will be able to reach the specified HoverTargetHeight. If the value is insufficient, the vehicle may not be able to achieve the correct hover height, or will take much longer to reach that height.

hoverlift-forces-section

Attraction Forces

Max Attraction Force

Specifies the maximum amount of attraction force that can be applied to each HoverPoint to cause the vehicle to remain attracted to the ground surface. Higher values will cause the vehicle to hug the ground or remain more strongly grounded, while lower values can cause more bounciness and make it easier to leave the ground for jumps, etc.  If the value is sufficiently high, the vehicle will be able to perform feats such as “wall driving” or drive on any surface orientation, even while hovering “above” that surface.

Enable Attraction Scaling

If set to TRUE, attraction forces will be scaled to match the surface’s slope, from 100% at zero slope to 0% at MaxAttractionSlope. If set to FALSE, attraction forces will always be applied when needed and will not be scaled to match the surface slope.

Max Attraction Slope

Specifies the maximum slope angle at which attraction forces will be applied if EnableAttractionScaling is set to TRUE.

hoverlift-attraction-forces

Power Curve

Enable Power Curve

When set to TRUE, the PowerCurve will be applied to the component’s force output. This value defaults to FALSE.

Power Curve

When EnablePowerCurve is TRUE, this animation curve will be used to modify the component’s force output. In most cases this will not be necessary, as the LiftPID configuration already provides a great deal of flexibility, but has been included for those situations where a finer level of control is desired.

hoverlift-powercurve-section

Computation

Lift PID

The LiftPID field configures the feedback control that is used to calculate the actual forces applied to the Rigidbody at any given point in time.  Specifically, it configures a generalized PID Controller (Proportional/Integral/Derivative controller) that can be tuned to provide a wide range of physics behaviors.

The proportional term (P) controls how quickly the hovercraft reaches the correct hover height, while the derivative term (D) controls the amount of ‘wobble’ and ‘bounciness’ (the higher the value, the more ‘damping’ is performed).

Although it looks complicated at first glance, HoverKit includes the ability to automatically determine the starting values that can be used for your vehicle, and with a little experimentation it quickly becomes obvious how to tweak the values to achieve the behavior you desire.

P Factor

This value determines how quickly the vehicle will adjust to arrive at the proper physics solution for hovering, with higher numbers achieving the correct hover height faster than lower numbers, allowing you to choose between a more rigid and springy feel or a softer floating feel and anywhere in between.

Values between 100% and 200% of the vehicle’s Rigidbody mass provide a good starting point for experimentation.

D Factor

In the case of the HoverLift component, the dFactor value provides control over how quickly the system responds to external conditions like a load disturbance or collision, with higher numbers resulting in faster stabilization and less bounciness, while lower numbers can result in a wobbly response. As noted above, this can function much like a “damping” value in practice.

This value will typically be much lower than the P value, often not more than 10% to 20% of the P value.

hoverlift-computation-section

HoverLift API Documentation

View the API documentation for the HoverLift Component class online.