Lean

Leaning means to be in or move into a sloping position.

Description

What this component does is tilt and move the object into a position where it looks like it's leaning; again, as with most of these components, the main objects that would use something like this are the player’s camera and guns!

This effect, just like any other in the asset, is something you can remove from the player, this way no matter whether your game has leaning, the asset is still for you!

Not all first-person games have this feature, but as it becomes more popular, it is important to get right.

How does it work?

The effect works its magic as soon as the player presses one of the ‘leaning’ inputs (those being 'q' and 'e’ in the asset).

Every frame, the component checks for the player’s leaning input, when there is any, the object it’s on receives a position-force in the form of the similarly named position variable, and a rotation force from the rotation.

The script then takes the value of the lean axis and multiplies it by those forces and the State Data multiplier for this component; the final effect makes the object smoothly transition from one side to the other based on player input.

Tweaking the effect

There are two variables that you can change when trying to alter this effect, the two of them are forces that apply to the position and rotation of the object accordingly.

The State Data for the player’s current state has a multiplier for this effect.

Based on whether the position and rotation values are positive or negative, the leaning can be in reverse.

Last updated

Was this helpful?