API reference
API reference
Select your platform
No SDKs available
No versions available

ScenePhysicsCollider Class

Modifiers: open
Represents a standalone collision shape that can be shared across multiple ScenePhysicsObjects.
A collider defines the shape used for physics collision detection without creating a full physics body. Multiple physics objects can reference the same collider, allowing for efficient reuse of collision shapes.
Needs the PhysicsFeature to be enabled to work.
Example usage:
// Create a reusable box collider
val boxCollider = ScenePhysicsCollider.createBox(scene, 1.0f, 1.0f, 1.0f)
// Create multiple physics objects using the same collider
val physics1 = ScenePhysicsObject.createFromCollider(scene, entity1, boxCollider, 1.0f)
val physics2 = ScenePhysicsObject.createFromCollider(scene, entity2, boxCollider, 1.0f)
// Create a compound collider with multiple child shapes
val compound = ScenePhysicsCollider.createCompound(scene)
compound.addChildBox(0.5f, 0.1f, 0.5f, Pose())  // Base
compound.addChildSphere(0.2f, Vector3(0f, 0.5f, 0f))  // Top

Signature

open class ScenePhysicsCollider

Properties

handle : Long
[Get]
Native handle to the collider.
Signature
var handle: Long

Functions

addChildBox ( halfW , halfH , halfD , localPose )
Adds a box child shape to this compound collider.
Signature
fun addChildBox(halfW: Float, halfH: Float, halfD: Float, localPose: Pose)
Parameters
halfW: Float
  Half-width of the box in meters
halfH: Float
  Half-height of the box in meters
halfD: Float
  Half-depth of the box in meters
localPose: Pose
  Local transform of the child shape relative to compound origin
addChildCylinder ( radius , halfHeight , localPose )
Adds a cylinder child shape to this compound collider.
The cylinder is oriented along the Y-axis by default. Use the localPose rotation to reorient it.
Signature
fun addChildCylinder(radius: Float, halfHeight: Float, localPose: Pose)
Parameters
radius: Float
  Radius of the cylinder in meters
halfHeight: Float
  Half-height of the cylinder in meters
localPose: Pose
  Local transform of the child shape relative to compound origin
addChildSphere ( radius , localPos )
Adds a sphere child shape to this compound collider.
Signature
fun addChildSphere(radius: Float, localPos: Vector3)
Parameters
radius: Float
  Radius of the sphere in meters
localPos: Vector3
  Local position of the child shape relative to compound origin
destroy ()
Destroys this collider and releases native resources.
After calling this method, the collider should not be used. If there are physics objects still using this collider, they will continue to work due to internal reference counting.
Note: This method is idempotent - calling it multiple times is safe.
Signature
fun destroy()
getColliderID ()
Gets the internal collider ID.
Signature
fun getColliderID(): Long
Returns
Long
  The collider ID used by the physics world

Companion Object

Companion Object Functions

createBox ( scene , width , height , depth )
Creates a box-shaped collider.
Signature
fun createBox(scene: Scene, width: Float, height: Float, depth: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
width: Float
  Width of the box in meters
height: Float
  Height of the box in meters
depth: Float
  Depth of the box in meters
Returns
  A new box-shaped collider
createCapsuleX ( scene , radius , halfHeight )
Creates a capsule-shaped collider oriented along the X-axis.
A capsule is a cylinder with hemispherical caps at both ends.
Signature
fun createCapsuleX(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the capsule in meters
halfHeight: Float
  Half-height of the cylinder portion in meters (total height = 2<i>halfHeight + 2</i>radius)
Returns
  A new capsule-shaped collider
createCapsuleY ( scene , radius , halfHeight )
Creates a capsule-shaped collider oriented along the Y-axis.
A capsule is a cylinder with hemispherical caps at both ends. This is the most common orientation for character controllers and standing entities.
Signature
fun createCapsuleY(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the capsule in meters
halfHeight: Float
  Half-height of the cylinder portion in meters (total height = 2<i>halfHeight + 2</i>radius)
Returns
  A new capsule-shaped collider
createCapsuleZ ( scene , radius , halfHeight )
Creates a capsule-shaped collider oriented along the Z-axis.
A capsule is a cylinder with hemispherical caps at both ends.
Signature
fun createCapsuleZ(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the capsule in meters
halfHeight: Float
  Half-height of the cylinder portion in meters (total height = 2<i>halfHeight + 2</i>radius)
Returns
  A new capsule-shaped collider
createCompound ( scene )
Creates an empty compound collider.
Use addChildBox() and addChildSphere() to add child shapes to the compound.
Example:
val compound = ScenePhysicsCollider.createCompound(scene)
compound.addChildBox(0.5f, 0.1f, 0.5f, Pose())  // Base platform
compound.addChildSphere(0.2f, Vector3(0f, 0.3f, 0f))  // Sphere on top

Signature
fun createCompound(scene: Scene): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
Returns
  A new empty compound collider
createConvexHull ( scene , filename )
Creates a convex hull collider from a GLTF model file.
The collision shape will be generated as a convex hull around the model's geometry. This is more efficient than a full mesh collider but may not perfectly match concave shapes.
Signature
fun createConvexHull(scene: Scene, filename: String): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
filename: String
  Path to the GLTF model file
Returns
  A new convex hull collider
createCylinderX ( scene , radius , halfHeight )
Creates a cylinder-shaped collider oriented along the X-axis.
Signature
fun createCylinderX(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the cylinder in meters
halfHeight: Float
  Half-height of the cylinder in meters
Returns
  A new cylinder-shaped collider
createCylinderY ( scene , radius , halfHeight )
Creates a cylinder-shaped collider oriented along the Y-axis.
Signature
fun createCylinderY(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the cylinder in meters
halfHeight: Float
  Half-height of the cylinder in meters
Returns
  A new cylinder-shaped collider
createCylinderZ ( scene , radius , halfHeight )
Creates a cylinder-shaped collider oriented along the Z-axis.
Signature
fun createCylinderZ(scene: Scene, radius: Float, halfHeight: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the cylinder in meters
halfHeight: Float
  Half-height of the cylinder in meters
Returns
  A new cylinder-shaped collider
createGLTF ( scene , filename )
Creates a mesh collider from a GLTF model file.
The collision shape will exactly match the model's geometry. This is more accurate than a convex hull but more expensive for physics simulation. Best used for static objects.
Signature
fun createGLTF(scene: Scene, filename: String): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
filename: String
  Path to the GLTF model file
Returns
  A new mesh collider
createSphere ( scene , radius )
Creates a sphere-shaped collider.
Signature
fun createSphere(scene: Scene, radius: Float): ScenePhysicsCollider
Parameters
scene: Scene
  The scene in which to create the collider
radius: Float
  Radius of the sphere in meters
Returns
  A new sphere-shaped collider
Did you find this page helpful?