b3dDestroyPhysicsBody

Destroys physics body attached to an entity. Takes entityHandle (entity with physics body from b3dCreatePhysicsBody). Returns nothing.

3D Graphics

Parameters & Returns

Parameters

entityHandle Int

Returns

Void

Quick Summary

Destroys physics body attached to an entity. Takes entityHandle (entity with physics body from b3dCreatePhysicsBody). Returns nothing.

Technical Exegesis...

Destroys physics body attached to an entity, removing it from physics simulation. Takes entityHandle (entity handle from b3dLoadMesh/b3dCreateBox/etc that has physics body attached via b3dCreatePhysicsBody). Returns nothing. Removes Jolt physics body from physics world, freeing physics resources while keeping visual entity intact.

Example

Example.bam
; Create physics body
box = b3dCreateBox()
b3dCreatePhysicsBody(box, 1, 10.0, 0, 0, 0)

; Later, destroy physics when no longer needed
b3dDestroyPhysicsBody(box)

; LOD system - destroy distant physics bodies
For i = 0 To lastEntity
    entity = entityList(i)
    distance = EntityDistance(player, entity)
    If distance > lodDistance Then
        b3dDestroyPhysicsBody(entity)
    EndIf
Next

; Cleanup settled debris after some time
If debrisSettled And MilliSecs() > debrisTime + 5000 Then
    b3dDestroyPhysicsBody(debrisEntity)
EndIf