Lean
Last updated
Was this helpful?
Last updated
Was this helpful?
Leaning means to be in or move into a sloping position.
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!
Not all first-person games have this feature, but as it becomes more popular, it is important to get right.
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 multiplier for this component; the final effect makes the object smoothly transition from one side to the other based on player input.
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.