Description
The Radius
property of the CapsuleCollider
class specifies the radius of the capsule shape used in collision detection. This property is a float
value representing the distance from the center of the capsule's circular cross-section to its edge.
Usage
To set or get the radius of a CapsuleCollider
, use the Radius
property. Adjusting the radius will affect the size of the collider and, consequently, how it interacts with other colliders in the scene.
Example
// Create a new CapsuleCollider instance
CapsuleCollider capsuleCollider = new CapsuleCollider();
// Set the radius of the capsule
capsuleCollider.Radius = 1.5f;
// Get the current radius of the capsule
float currentRadius = capsuleCollider.Radius;
// Output the current radius
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use in-game debugging tools or UI elements to display values
DebugOverlay.Text( $"Current Radius: {currentRadius}" );