// 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
open class ScenePhysicsCollider
handle
: Long
[Get] |
Native handle to the collider.
Signature
var handle: Long |
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
|
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
|
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
|
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
|
createBox
(
scene
, width
, height
, depth
)
|
Creates a box-shaped collider.
Signature
fun createBox(scene: Scene, width: Float, height: Float, depth: Float): ScenePhysicsCollider Parameters width: Float
Width of the box in meters
height: Float
Height of the box in meters
depth: Float
Depth of the box in meters
|
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 radius: Float
Radius of the capsule in meters
halfHeight: Float
Half-height of the cylinder portion in meters (total height = 2halfHeight + 2radius)
|
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 radius: Float
Radius of the capsule in meters
halfHeight: Float
Half-height of the cylinder portion in meters (total height = 2halfHeight + 2radius)
|
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 radius: Float
Radius of the capsule in meters
halfHeight: Float
Half-height of the cylinder portion in meters (total height = 2halfHeight + 2radius)
|
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 |
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 filename: String
Path to the GLTF model file
|
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 radius: Float
Radius of the cylinder in meters
halfHeight: Float
Half-height of the cylinder in meters
|
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 radius: Float
Radius of the cylinder in meters
halfHeight: Float
Half-height of the cylinder in meters
|
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 radius: Float
Radius of the cylinder in meters
halfHeight: Float
Half-height of the cylinder in meters
|
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 filename: String
Path to the GLTF model file
|
createSphere
(
scene
, radius
)
|
Creates a sphere-shaped collider.
Signature
fun createSphere(scene: Scene, radius: Float): ScenePhysicsCollider Parameters radius: Float
Radius of the sphere in meters
|