Description
The Height
property of the CharacterController
class represents the height of the character in the game world. This property is used to define the vertical size of the character's collision capsule, which is essential for determining how the character interacts with the environment, such as fitting through spaces and colliding with other objects.
Usage
To set or get the height of a character, use the Height
property. The value is a float
and should be within the range specified by the RangeAttribute
, which is from 0 to 200. This range ensures that the height is realistic and suitable for most game scenarios.
Example usage:
CharacterController characterController = new CharacterController();
characterController.Height = 1.8f; // Set the height to 1.8 units
float currentHeight = characterController.Height; // Get the current height
Example
// Example of setting and getting the Height property
CharacterController characterController = new CharacterController();
// Set the character's height
characterController.Height = 1.8f;
// Retrieve the character's height
float currentHeight = characterController.Height;
// Output the current height
// Note: Avoid using Console.WriteLine in Sandbox environment
// Instead, use appropriate logging or debugging tools
// Console.WriteLine($"Character Height: {currentHeight}");