Sets entity collision type (0-31) for collision filtering.
Takes entity (entity handle), typeID (collision type 0-31, where 0 = no collision).
Returns nothing.
3D Graphics
Parameters & Returns
Parameters
entityInt
typeIDInt
Returns
Void
Quick Summary
Sets entity collision type (0-31) for collision filtering.
Takes entity (entity handle), typeID (collision type 0-31, where 0 = no collision).
Returns nothing.
Technical Exegesis...
Sets entity collision type (0-31) for collision filtering. Takes entity (entity handle), typeID (collision type 0-31, where 0 = no collision). Returns nothing. Stores typeID in entity.collisionType field and initializes prevPosition for movement tracking.
This function assigns collision type. Collision types: 32 possible types (0-31), type 0 = no collision (special default value), types 1-31 = user-defined categories (player, enemies, walls, pickups, etc.
Sets entity collision type (0-31) for collision filtering. Takes entity (entity handle), typeID (collision type 0-31, where 0 = no collision). Returns nothing. Stores typeID in entity.collisionType field and initializes prevPosition for movement tracking.
This function assigns collision type. Collision types: 32 possible types (0-31), type 0 = no collision (special default value), types 1-31 = user-defined categories (player, enemies, walls, pickups, etc.), types are simple integers (not bitmasks in this implementation), each entity has one collision type at a time. Type assignment: sets entity.collisionType field, used by collision matrix to determine response, combined with b3dCollisions to define which types interact, allows grouping entities by category for selective collision. First-time initialization: when typeID > 0 and prevPositionSaved = false, initializes entity.prevPosition = entity.position (sets starting point for swept collision), sets prevPositionSaved = true (prevents re-initialization), ensures collision system has valid previous position for movement tracking. Movement tracking: prevPosition stores entity location from previous frame, current position - prevPosition = movement vector for swept collision, swept collision prevents tunneling (continuous collision detection), collision system traces ray from prev to current position. Use cases: (1) Player collision (player type=1, collide with walls/enemies), (2) Bullet filtering (bullets type=3, ignore other bullets), (3) Trigger zones (triggers type=5, detect player entry), (4) Pickup items (pickups type=6, pass through but detect), (5) Platform distinction (moving platforms type=7, special response). Common patterns: setup phase = assign types to all entities at creation (b3dEntityType(wall, TYPE_WALL)), player setup = b3dEntityType(player, 1) then b3dCollisions(1, 2, 2) for sliding, layered collision = different entity categories for different purposes (physics vs triggers), type 0 disable = set to 0 to temporarily disable collision (b3dEntityType(ghost, 0)). Typical usage: call immediately after entity creation, assign type before entity moves or collides, combine with b3dCollisions to define interaction matrix, use b3dGetEntityType to query current type. Type 0 behavior: type 0 entities do not collide with anything, effectively disables collision for that entity, collision system skips type 0 entities, useful for decorative objects or temporarily disabled collision. Collision matrix interaction: typeID is used as index into collision pairs, b3dCollisions(srcType, destType, response) defines behavior, bidirectional (type A hitting B same as B hitting A), matrix lookup is O(n) linear search through g_collisionPairs vector. Performance: O(1) assignment (simple field write), prevPosition initialization is one-time cost (first assignment only), negligible impact on frame time, collision type checked during collision detection (not during assignment). Validation: no type ID range validation (accepts any integer), types outside 0-31 may cause undefined behavior in collision matrix, no error message for invalid types (silent acceptance). Type persistence: collision type persists until changed, survives b3dPositionEntity/b3dRotateEntity calls, reset when entity copied (b3dCopyEntity preserves type), cleared when entity freed. Relationship to b3dSetCollisionMode: b3dEntityType sets WHAT collides (type category), b3dSetCollisionMode sets HOW it collides (polygon/box/sphere shape), both are independent settings (type for filtering, mode for shape). Common type assignments: 0 = no collision (disabled), 1 = player character, 2 = walls/obstacles, 3 = projectiles/bullets, 4 = enemies/NPCs, 5 = trigger volumes, 6 = pickup items, 7 = moving platforms, 8-31 = user-defined. Collision detection flow: (1) entity moves (position changes), (2) collision system checks collisionType, (3) looks up type in collision matrix, (4) determines response based on b3dCollisions settings, (5) applies response (none/stop/slide). Related: b3dGetEntityType queries current type (read entity's collision type), b3dCollisions defines type interaction matrix (sets response between type pairs), b3dSetCollisionMode sets collision shape (polygon/box/sphere), b3dEntityCollided detects collisions with specific type (filters by typeID).
Example
Example.bam
; Setup collision types for game entities
Const TYPE_PLAYER% = 1
Const TYPE_WALL% = 2
Const TYPE_ENEMY% = 3
Const TYPE_PICKUP% = 4
Const TYPE_TRIGGER% = 5; Create entities and assign types
player = b3dCreateCube()
b3dEntityType(player, TYPE_PLAYER%)
wall = b3dCreateCube()
b3dEntityType(wall, TYPE_WALL%)
enemy = b3dCreateSphere()
b3dEntityType(enemy, TYPE_ENEMY%)
healthPickup = b3dCreateSphere()
b3dEntityType(healthPickup, TYPE_PICKUP%)
; 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_PLAYER%, TYPE_PICKUP%, 0) ; Player passes through pickups
b3dCollisions(TYPE_PLAYER%, TYPE_TRIGGER%, 0) ; Player passes through triggers
; Disable collision for a ghost entity
ghost = b3dCreateCube()
b3dEntityType(ghost, 0) ; Type0 = no collision