b3dSetPhysicsBodyType

Sets physics body motion type (0=static immovable, 1=kinematic script-controlled, 2=dynamic physics-simulated). Takes bodyHandle (physics body handle from b3dCreatePhysicsBody), bodyType (0=static, 1=kinematic, 2=dynamic). Returns nothing (void function).

3D Graphics

Parameters & Returns

Parameters

bodyHandle Int
bodyType Int

Returns

Void

Quick Summary

Sets physics body motion type (0=static immovable, 1=kinematic script-controlled, 2=dynamic physics-simulated). Takes bodyHandle (physics body handle from b3dCreatePhysicsBody), bodyType (0=static, 1=kinematic, 2=dynamic). Returns nothing (void function).

Technical Exegesis...

Sets physics body motion type (0=static immovable, 1=kinematic script-controlled, 2=dynamic physics-simulated). Takes bodyHandle (physics body handle from b3dCreatePhysicsBody), bodyType (0=static immovable infinite mass, 1=kinematic script-controlled no physics forces, 2=dynamic fully physics-simulated affected by forces/gravity). Returns nothing (void function, no return value). Changes Jolt body's EMotionType, affects how body interacts with physics simulation.

Example

Example.bam
; Create anchor body (initially dynamic with mass)
Local anchor:Int = b3dCreateCube(1, 0, 0)
b3dPositionEntity(anchor, 0, 10, 0)
Local anchorBody:Int = b3dCreatePhysicsBody(anchor, -1, 1.0, 0, 0, 0)

; Convert to static BEFORE creating constraint
b3dSetPhysicsBodyType(anchorBody, 0)  ; 0 = static (immovable)

; Create dynamic weight
Local weight:Int = b3dCreateCube(1, 0, 0)
b3dPositionEntity(weight, 0, 5, 0)
Local weightBody:Int = b3dCreatePhysicsBody(weight, -1, 1.0, 0, 0, 0)
; weightBody is already dynamic (type 2)

; Create constraint between static anchor and dynamic weight
Local constraint:Int = b3dCreatePointConstraint(anchorBody, weightBody, 0, -1, 0, 0, 1, 0)

; Later: make anchor kinematic to move it with script
b3dSetPhysicsBodyType(anchorBody, 1)  ; 1 = kinematic
b3dSetPhysicsBodyPosition(anchorBody, 0, 10 + Sin(GetTimer()), 0)

; Or freeze weight in mid-air
b3dSetPhysicsBodyType(weightBody, 0)  ; 0 = static (freeze)