Description
The Capsule.FromHeightAndRadius
method is a static method that creates a new Capsule
instance using a specified height and radius. A capsule is a geometric shape that consists of a cylinder with hemispherical ends. This method is useful for generating capsules in 3D space with specific dimensions.
Usage
To use the FromHeightAndRadius
method, call it with the desired height and radius values. The method will return a Capsule
object that represents a capsule with the specified dimensions.
Parameters:
height
(System.Single
): The total height of the capsule, including the cylindrical part and the hemispherical ends.
radius
(System.Single
): The radius of the capsule, which is the radius of the cylindrical part and the hemispherical ends.
Returns: A Capsule
object with the specified height and radius.
Example
// Example of creating a capsule with a height of 10 units and a radius of 2 units.
Capsule myCapsule = Capsule.FromHeightAndRadius(10.0f, 2.0f);
// Accessing properties of the capsule
Vector3 centerA = myCapsule.CenterA;
Vector3 centerB = myCapsule.CenterB;
float radius = myCapsule.Radius;
// Getting a random point inside the capsule
Vector3 randomPointInside = myCapsule.RandomPointInside;
// Getting a random point on the edge of the capsule
Vector3 randomPointOnEdge = myCapsule.RandomPointOnEdge;