Crystal Entity Layer: 4.3.6 Hover

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

### 4.3.6 Hover

This property class, defines a hovering object when used in conjunction with ``pcmechobject'`.

#### Property Class Details

- Name: ``pchover'`
- Factory ID: ``cel.pcfactory.hover'`
- Interface: `iPcHover`
- Header: ``include/propclass/hover.h'`

#### General Information

A Hovering object can be something like a hovercraft or a anti-gravity ship. As well as hovering your object, it will also align it to the terrain, so that as it goes down a hill, the ship will also tilt.

#### PID parameters

How your object corrects its height can be done by messing with 3 parameters called p_factor, i_factor and d_factor.

`iPcHover->SetAngularBeamOffset (2.0, 3.0, 4.0)`

Will set p_factor to 2.0, i_factor to 3.0 and d_factor to 4.0 - there is no magic formula for adjusting these values, it's just educated guesswork and playing around with them.

You may also wish to set the hovering height with `iPcHover->SetHoverHeight (float)`

#### Stopping hovering over some objects.

If you don't want hovering over a certain object then just set the flag CS_ENTITY_NOHITBEAM on that object.

You can switch off hovering entirely with `iPcHover->HoverOff ()` and use `iPcHover->HoverOn ()` to turn it back on. Note that angular correction will still be happening though (which will do nothing if you're resting on the ground).

#### Angular Correction

This refers to the object correcting its angle as it flies over terrain (facing downwards as it flies down hills).

The implementation of this is done by calculating the object's height at its center and then calculating the height away from the center. Using the differences in height and a bit of trigonmetry, you can see the angle of the object relative to the terrain.

- `iPcHover->SetAngularBeamOffset (float)` refers to how far away from the center of the object the second height test is done. Smaller values are better on more noisy terrain, but less accurate and more jerky, whereas larger values are more likely to approximate (that small bump won't get noticed). Values like 0.5 are usually small enough to suffice.
- `iPcHover->SetAngularCorrectionStrength (float)` is how fast the object corrects its rotation. High values and it will jerk extremely fast, smaller and it will hardly re-align. 1.0 is normal.
- `iPcHover->SetAngularCutoffHeight (float)` is the height at which the angular correction stops working - you obviously don't want a ship re-aligning itself with terrain as its flying in the air.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ]

This document was generated using texi2html 1.76.