PhysicsShape AddConeShape( Vector3 position, Rotation rotation, float height, float radius1, float radius2, int slices )

book_4_sparkGenerated
code_blocksInput

Description

The AddConeShape method adds a cone-shaped physics shape to the PhysicsBody. This shape is defined by its position, rotation, height, and two radii, allowing for a truncated cone shape. The number of slices determines the level of detail of the cone's circular base.

Usage

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

  • position: A Vector3 representing the position of the cone's base in world coordinates.
  • rotation: A Rotation object that defines the orientation of the cone.
  • height: A float specifying the height of the cone.
  • radius1: A float for the radius of the cone's base.
  • radius2: A float for the radius of the cone's top, allowing for a truncated cone.
  • slices: An int indicating the number of slices for the cone's base, affecting the smoothness of the shape.

The method returns a PhysicsShape object representing the newly created cone shape.

Example

PhysicsBody body = new PhysicsBody();
Vector3 position = new Vector3(0, 0, 0);
Rotation rotation = Rotation.Identity;
float height = 5.0f;
float radius1 = 2.0f;
float radius2 = 1.0f;
int slices = 16;

PhysicsShape coneShape = body.AddConeShape(position, rotation, height, radius1, radius2, slices);