Description
The IsOnGround
property of the CharacterController
class indicates whether the character is currently in contact with the ground. This property is useful for determining if the character can perform actions that require ground contact, such as jumping.
Usage
To check if a character is on the ground, access the IsOnGround
property from an instance of CharacterController
. This property returns a bool
value, where true
indicates the character is on the ground, and false
indicates it is not.
Example
// Example of using the IsOnGround property
CharacterController characterController = new CharacterController();
if (characterController.IsOnGround)
{
// The character is on the ground, perform ground-specific actions
// e.g., allow jumping
}
else
{
// The character is in the air, handle air-specific logic
}