PhysicsShape AddHullShape( Vector3 position, Rotation rotation, List<Vector3> points, bool rebuildMass )
PhysicsShape AddHullShape( Vector3 position, Rotation rotation, System.Span<Vector3> points, bool rebuildMass )

book_4_sparkGenerated
code_blocksInput

Description

The AddHullShape method is used to add a convex hull shape to a PhysicsBody. This shape is defined by a set of points, and it can be positioned and rotated within the physics body. The method also provides an option to rebuild the mass of the physics body based on the new shape.

Usage

To use the AddHullShape method, you need to provide the following parameters:

  • position: A Vector3 representing the position of the hull shape within the physics body.
  • rotation: A Rotation object that defines the orientation of the hull shape.
  • points: A List<Vector3> containing the vertices that define the convex hull.
  • rebuildMass: A bool indicating whether the mass of the physics body should be recalculated after adding the shape.

This method returns a PhysicsShape object representing the newly added hull shape.

Example

// Example of adding a hull shape to a PhysicsBody
PhysicsBody body = new PhysicsBody();
Vector3 position = new Vector3(0, 0, 0);
Rotation rotation = Rotation.Identity;
List<Vector3> points = new List<Vector3>
{
    new Vector3(1, 0, 0),
    new Vector3(0, 1, 0),
    new Vector3(0, 0, 1)
};
bool rebuildMass = true;

PhysicsShape hullShape = body.AddHullShape(position, rotation, points, rebuildMass);