ModelBuilder AddCollisionCapsule( Vector3 center0, Vector3 center1, float radius )

book_4_sparkGenerated
code_blocksInput

Description

The AddCollisionCapsule method allows you to add a collision capsule to a model being constructed using the ModelBuilder class. A collision capsule is defined by two center points and a radius, forming a cylindrical shape with hemispherical ends. This method is useful for creating collision geometries that approximate the shape of elongated objects.

Usage

To use the AddCollisionCapsule method, you need to provide two center points and a radius. These parameters define the capsule's shape and size:

  • center0: A Vector3 representing the first center point of the capsule.
  • center1: A Vector3 representing the second center point of the capsule.
  • radius: A float representing the radius of the capsule.

The method returns the ModelBuilder instance, allowing for method chaining.

Example

// Example of adding a collision capsule to a model
ModelBuilder builder = new ModelBuilder();

// Define the two center points and the radius of the capsule
Vector3 center0 = new Vector3(0, 0, 0);
Vector3 center1 = new Vector3(0, 0, 10);
float radius = 2.0f;

// Add the collision capsule to the model
builder.AddCollisionCapsule(center0, center1, radius);

// Continue building the model or finalize it
Model model = builder.Create();