void ApplyFriction( float frictionAmount, float stopSpeed )

robot_2Generated
code_blocksInput

Description

The ApplyFriction method is used to apply a specified amount of friction to the current velocity of a character. This method is part of the CharacterController class, which allows for collision-constrained movement without the need for a rigidbody. The friction applied will affect how quickly the character slows down when moving across a surface.

Usage

To use the ApplyFriction method, you need to provide two parameters:

  • frictionAmount (type: System.Single): The amount of friction to apply. This value determines how much the character's velocity is reduced.
  • stopSpeed (type: System.Single): The speed at which the character should come to a complete stop. If the character's velocity falls below this speed, it will be set to zero.

Note that you do not need to scale the friction amount by the time delta, as this is handled internally by the method.

Example

// Example of using ApplyFriction in a CharacterController
CharacterController characterController = new CharacterController();

// Apply friction with a friction amount of 0.5 and a stop speed of 0.1
characterController.ApplyFriction(0.5f, 0.1f);