Sets collision response between two entity type groups (0-31).
Takes srcType (source collision type 0-31), destType (destination collision type 0-31), response (0=none, 1=stop, 2=slide, 3=slide2).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
srcTypeInt
destTypeInt
responseInt
Returns
Void
Quick Summary
Sets collision response between two entity type groups (0-31).
Takes srcType (source collision type 0-31), destType (destination collision type 0-31), response (0=none, 1=stop, 2=slide, 3=slide2).
Returns nothing.
Technical Exegesis...
Sets collision response between two entity type groups (0-31). Takes srcType (source collision type 0-31), destType (destination collision type 0-31), response (0=none, 1=stop, 2=slide, 3=slide2). Returns nothing. Configures how entities of srcType behave when colliding with entities of destType.
This function configures collision matrix.
Sets collision response between two entity type groups (0-31). Takes srcType (source collision type 0-31), destType (destination collision type 0-31), response (0=none, 1=stop, 2=slide, 3=slide2). Returns nothing. Configures how entities of srcType behave when colliding with entities of destType.
This function configures collision matrix. Collision types: entities assigned type ID 0-31 via b3dEntityType (entities can belong to multiple groups via bitmask), allows grouping entities by category (player=1, enemies=2, walls=3, pickups=4). Response modes: 0 (none) = entities pass through (no collision), 1 (stop) = entities stop at surface (hard collision, zero velocity transfer), 2 (slide) = entities slide along surface (player walking into wall), 3 (slide2) = alternative slide mode (different friction characteristics). Collision matrix: srcType and destType define collision pair (bidirectional relationship, b3dCollisions(1,2,1) affects type 1 hitting type 2 AND type 2 hitting type 1), 32x32 matrix of all possible type combinations, each cell stores response mode. Use cases: (1) Player-wall collision (player type=1, walls type=2, response=2 for sliding), (2) Bullet-enemy collision (bullets type=3, enemies type=4, response=0 with custom hit detection), (3) Trigger volumes (triggers type=5, player type=1, response=0 for pass-through with event), (4) Pickup items (pickups type=6, player type=1, response=0 for collection), (5) Platform collision (player type=1, platforms type=7, response=1 for standing). Common patterns: player movement b3dCollisions(1,2,2) for sliding against walls, projectiles b3dCollisions(3,0,0) for no collision (manual ray-based hit), trigger zones b3dCollisions(1,5,0) for pass-through detection, one-way platforms b3dCollisions(1,7,1) from above only (requires custom logic). Typical usage: called during initialization to set up collision matrix (one-time setup), configure all type pairs before spawning entities, combine with b3dEntityType to assign entities to groups. Type assignment: entities default to type 0 (collides with everything), use b3dEntityType(entity, typeID) to assign type, types are bitmasks (can belong to multiple groups via OR), type 0 is special universal collision type. Response details: stop mode = entities cannot overlap, velocity zeroed on contact, good for solid obstacles; slide mode = entities maintain movement parallel to surface, perpendicular velocity zeroed, good for character controllers; none mode = entities overlap freely, use b3dEntityCollided for detection, good for triggers/pickups. Bidirectional symmetry: b3dCollisions(A,B,response) same as b3dCollisions(B,A,response), only need to set one direction, collision system automatically applies both ways. Performance: collision matrix lookup is O(1) (simple array access), minimal runtime cost, set once at startup, affects only overlapping entities. Default behavior: if not configured, entities default to type 0, type 0 collides with all types using slide mode (default safe behavior). Validation: type IDs outside 0-31 range ignored, response modes outside 0-3 clamped to nearest valid, invalid parameters print warning to console. Related: b3dEntityType sets entity collision type (assigns entity to group), b3dGetEntityType queries entity collision type (read entity's type ID), b3dEntityCollided detects collision occurrence (check if entities hit), b3dCountCollisions gets number of collisions (count collision events), b3dCollisionEntity gets collided entity (retrieve collision partner).
Example
Example.bam
; Setup collision matrix for game; Type 1 = Player, Type 2 = Walls, Type 3 = Enemies, Type 4 = Pickups; Player slides against walls
b3dCollisions(1, 2, 2)
; Player stops when hitting enemies
b3dCollisions(1, 3, 1)
; Player passes through pickups (detect with b3dEntityCollided)
b3dCollisions(1, 4, 0)
; Enemies slide against walls
b3dCollisions(3, 2, 2)
; Assign entity types
b3dEntityType(player, 1)
b3dEntityType(wall, 2)
b3dEntityType(enemy, 3)
b3dEntityType(pickup, 4)