val hinge = ScenePhysicsConstraint.createHinge(
scene = getScene(),
entityA = doorFrame,
entityB = door,
anchorA = Vector3(0.5f, 0f, 0f),
anchorB = Vector3(-0.5f, 0f, 0f),
axis = Vector3(0f, 1f, 0f),
lowerLimit = -1.57f,
upperLimit = 1.57f
)
open class ScenePhysicsConstraint
constraintType
: ScenePhysicsConstraint.ConstraintType
[Get] |
The type of this constraint.
Signature
val constraintType: ScenePhysicsConstraint.ConstraintType |
entityA
: Entity?
[Get] |
First entity connected by this constraint.
Signature
val entityA: Entity? |
entityB
: Entity?
[Get] |
Second entity connected by this constraint (null = world anchor).
Signature
val entityB: Entity? |
handle
: Long
[Get] |
Native handle to the constraint.
Signature
var handle: Long |
destroy
()
|
Destroys this constraint and releases native resources.
Signature
fun destroy() |
getAppliedImpulse
()
|
Gets the impulse currently applied by this constraint.
Useful for detecting stress on the constraint.
Signature
fun getAppliedImpulse(): Float Returns
Float
|
isBroken
()
|
Checks if this constraint has been broken.
Signature
fun isBroken(): Boolean Returns
Boolean
|
setBreakingThreshold
(
force
, torque
)
|
Sets the breaking threshold for this constraint.
When the applied impulse exceeds these thresholds, the constraint will break.
Signature
fun setBreakingThreshold(force: Float, torque: Float = 0.0f) Parameters
force:
Float
torque:
Float
|
setEnabled
(
enabled
)
|
Enables or disables this constraint.
Signature
fun setEnabled(enabled: Boolean) Parameters
enabled:
Boolean
|
setLimits
(
lower
, upper
)
|
Sets the limits for this constraint.
For hinge: angular limits in radians. For slider: linear limits in meters.
Signature
fun setLimits(lower: Float, upper: Float) Parameters
lower:
Float
upper:
Float
|
setMotor
(
enabled
, targetVelocity
, maxForce
)
|
Configures the motor for this constraint (hinge/slider only).
Signature
fun setMotor(enabled: Boolean, targetVelocity: Float, maxForce: Float) Parameters
enabled:
Boolean
targetVelocity:
Float
maxForce:
Float
|
createBallSocket
(
scene
, entityA
, entityB
, anchorA
, anchorB
)
|
Creates a ball-socket constraint between two entities.
A ball-socket allows rotation in all directions around a point, like a shoulder joint or chain link.
Signature
fun createBallSocket(scene: Scene, entityA: Entity?, entityB: Entity?, anchorA: Vector3, anchorB: Vector3): ScenePhysicsConstraint Parameters |
createConeTwist
(
scene
, entityA
, entityB
, anchorA
, anchorB
, twistAxis
, swingSpan1
, swingSpan2
, twistSpan
, softness
, biasFactor
, relaxationFactor
)
|
Creates a cone-twist constraint between two entities.
A cone-twist allows rotation within a cone and twist around an axis. Ideal for ragdoll joints like shoulders, hips, and spine.
Signature
fun createConeTwist(scene: Scene, entityA: Entity?, entityB: Entity?, anchorA: Vector3, anchorB: Vector3, twistAxis: Vector3 = Vector3(0f, 1f, 0f), swingSpan1: Float = (Math.PI / 2).toFloat(), swingSpan2: Float = (Math.PI / 2).toFloat(), twistSpan: Float = Math.PI.toFloat(), softness: Float = 1.0f, biasFactor: Float = 0.3f, relaxationFactor: Float = 1.0f): ScenePhysicsConstraint Parameters
swingSpan1:
Float
swingSpan2:
Float
twistSpan:
Float
softness:
Float
biasFactor:
Float
relaxationFactor:
Float
|
createFixed
(
scene
, entityA
, entityB
, anchorA
, anchorB
)
|
Creates a fixed constraint between two entities.
A fixed constraint rigidly connects two bodies with no relative movement. Useful for breakable connections.
Signature
fun createFixed(scene: Scene, entityA: Entity?, entityB: Entity?, anchorA: Vector3 = Vector3(0f, 0f, 0f), anchorB: Vector3 = Vector3(0f, 0f, 0f)): ScenePhysicsConstraint Parameters |
createHinge
(
scene
, entityA
, entityB
, anchorA
, anchorB
, axis
, lowerLimit
, upperLimit
)
|
Creates a hinge constraint between two entities.
A hinge allows rotation around a single axis, like a door hinge or wheel axle.
Signature
fun createHinge(scene: Scene, entityA: Entity?, entityB: Entity?, anchorA: Vector3, anchorB: Vector3, axis: Vector3, lowerLimit: Float = -Math.PI.toFloat(), upperLimit: Float = Math.PI.toFloat()): ScenePhysicsConstraint Parameters
lowerLimit:
Float
upperLimit:
Float
|
createSlider
(
scene
, entityA
, entityB
, axis
, lowerLimit
, upperLimit
)
|
Creates a slider constraint between two entities.
A slider allows linear movement along a single axis, like a piston or drawer.
Signature
fun createSlider(scene: Scene, entityA: Entity?, entityB: Entity?, axis: Vector3, lowerLimit: Float = -1f, upperLimit: Float = 1.0f): ScenePhysicsConstraint Parameters
lowerLimit:
Float
upperLimit:
Float
|
createSpring
(
scene
, entityA
, entityB
, anchorA
, anchorB
, stiffness
, damping
, restLength
)
|
Creates a spring constraint between two entities.
A spring applies a restoring force between bodies based on their distance.
Signature
fun createSpring(scene: Scene, entityA: Entity?, entityB: Entity?, anchorA: Vector3, anchorB: Vector3, stiffness: Float = 100.0f, damping: Float = 1.0f, restLength: Float = 0.0f): ScenePhysicsConstraint Parameters
stiffness:
Float
damping:
Float
restLength:
Float
|
enum ConstraintType : Enum<ScenePhysicsConstraint.ConstraintType>
| Member | Description |
|---|---|
FIXED |
Fixed constraint - rigidly connects two bodies with no relative movement.
|
HINGE |
Hinge constraint - allows rotation around a single axis (doors, wheels).
|
BALL_SOCKET |
Ball-socket constraint - allows rotation in all directions around a point (chains).
|
SLIDER |
Slider constraint - allows linear movement along an axis (pistons).
|
SPRING |
Spring constraint - applies spring force between bodies (suspension).
|
CONE_TWIST |
Cone-twist constraint - allows rotation within a cone (ragdoll joints).
|