// 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
halfH:
Float
halfD:
Float
|
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
halfHeight:
Float
|
addChildSphere
(
radius
, localPos
)
|
Adds a sphere child shape to this compound collider.
Signature
fun addChildSphere(radius: Float, localPos: Vector3) Parameters
radius:
Float
|
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
|
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
height:
Float
depth:
Float
|
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
halfHeight:
Float
|
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
halfHeight:
Float
|
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
halfHeight:
Float
|
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
|
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
halfHeight:
Float
|
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
halfHeight:
Float
|
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
halfHeight:
Float
|
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
|
createSphere
(
scene
, radius
)
|
Creates a sphere-shaped collider.
Signature
fun createSphere(scene: Scene, radius: Float): ScenePhysicsCollider Parameters
radius:
Float
|