b3dSetCollisionMode

Sets entity collision detection mode (0=Polygon, 1=Box, 2=Sphere). Takes entity (entity handle), mode (0=Polygon, 1=AABB/Box, 2=Sphere). Returns nothing.

3D Graphics

Parameters & Returns

Parameters

entity Int
mode Int

Returns

Void

Quick Summary

Sets entity collision detection mode (0=Polygon, 1=Box, 2=Sphere). Takes entity (entity handle), mode (0=Polygon, 1=AABB/Box, 2=Sphere). Returns nothing.

Technical Exegesis...

Sets entity collision detection mode (0=Polygon, 1=Box, 2=Sphere). Takes entity (entity handle), mode (0=Polygon, 1=AABB/Box, 2=Sphere). Returns nothing. Stores mode in entity.collisionMode field. Modes outside 0-2 range are ignored (silent fail).

This function sets collision shape. Collision modes: 0 = Polygon (per-triangle collision, most accurate but slowest), 1 = AABB/Box (axis-aligned bounding box, faster than polygon), 2 = Sphere (spherical collision volume, fastest and smoothest).

Example

Example.bam
; Player character with smooth sphere collision
player = b3dCreateCube()
b3dSetCollisionMode(player, 2)  ; Sphere mode
b3dSetEntityRadius(player, 0.5)  ; 0.5 unit radius
b3dEntityType(player, TYPE_PLAYER%)

; Static wall with accurate polygon collision
wall = b3dLoadMesh("wall.glb")
b3dSetCollisionMode(wall, 0)  ; Polygon mode (per-triangle)
b3dEntityType(wall, TYPE_WALL%)

; Enemy with sphere collision for smooth AI movement
enemy = b3dCreateSphere()
b3dSetCollisionMode(enemy, 2)  ; Sphere mode
b3dSetEntityRadius(enemy, 0.75)  ; Larger radius
b3dEntityType(enemy, TYPE_ENEMY%)

; Crate with box collision for performance
crate = b3dCreateCube()
b3dSetCollisionMode(crate, 1)  ; AABB/Box mode
b3dEntityType(crate, TYPE_OBSTACLE%)

; Configure collision responses
b3dCollisions(TYPE_PLAYER%, TYPE_WALL%, 2)     ; Player slides on walls
b3dCollisions(TYPE_PLAYER%, TYPE_ENEMY%, 1)    ; Player stops at enemies
b3dCollisions(TYPE_ENEMY%, TYPE_WALL%, 2)      ; Enemy slides on walls
b3dCollisions(TYPE_OBSTACLE%, TYPE_WALL%, 1)   ; Crates stop at walls