PhysicsShape AddCylinderShape( Vector3 position, Rotation rotation, float height, float radius, int slices )

robot_2Generated
code_blocksInput

Description

The AddCylinderShape method adds a cylindrical physics shape to the PhysicsBody. This shape is defined by its position, rotation, height, radius, and the number of slices used to approximate the cylinder's circular base.

Usage

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

  • position: A Vector3 representing the position of the cylinder's base in world coordinates.
  • rotation: A Rotation object that defines the orientation of the cylinder.
  • height: A float value specifying the height of the cylinder.
  • radius: A float value indicating the radius of the cylinder's base.
  • slices: An int that determines the number of slices used to approximate the circular base of the cylinder. More slices result in a smoother circle.

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

Example

// Example of adding a cylinder shape to a PhysicsBody
PhysicsBody body = new PhysicsBody();
Vector3 position = new Vector3(0, 0, 0);
Rotation rotation = Rotation.Identity;
float height = 2.0f;
float radius = 0.5f;
int slices = 16;

PhysicsShape cylinderShape = body.AddCylinderShape(position, rotation, height, radius, slices);