Api Capsule
struct

Capsule

public sealed struct Capsule

A capsule object, defined by 2 points and a radius. A capsule is a cylinder with round ends (inset half spheres on each end).

Constructors

Capsule(Vector3 a, Vector3 b, Single r)

Properties

Name Type Description
RandomPointInside Vector3 Returns a random point within this capsule.
RandomPointOnEdge Vector3 Returns a random point on the edge of this capsule.
Volume Single Gets the volume of the capsule in cubic units.
Bounds BBox Gets the Bounding Box of the capsule.

Methods

static Capsule FromHeightAndRadius(Single height, Single radius)

Creates a capsule where Point A is radius units above the ground and Point B is height minus radius units above the ground.

Single GetEdgeDistance(Vector3 localPos)

Calculates the distance from a given point to the edge of the capsule.

localPos — Position in the same coordinate space as the capsule
Boolean Contains(Vector3 point)

Determines if the capsule contains the specified point.

Fields

Name Type Description
CenterA Vector3 Position of point A.
CenterB Vector3 Position of point B.
Radius Single Radius of a capsule.
Assembly: Sandbox.System Full Name: Capsule