void Punch( Vector3& amount )

book_4_sparkGenerated
code_blocksInput

Description

The Punch method in the CharacterController class is used to disconnect the character from the ground and apply a force to its velocity. This is particularly useful for actions such as jumping, where you want the character to momentarily leave the ground and move upwards or in a specified direction.

Usage

To use the Punch method, you need to provide a reference to a Vector3 that specifies the amount and direction of the force to be applied to the character's velocity. This method modifies the character's velocity directly, so it should be used when you want to apply an immediate and direct change to the character's movement.

Example

// Example of using the Punch method
CharacterController characterController = new CharacterController();

// Define the force to apply
Vector3 force = new Vector3(0, 0, 10);

// Apply the punch to the character
characterController.Punch(ref force);