|
pXent_setgroup ( entity, unsigned short groupID); |
Sets
the entity's ID. This number is used in subsequent calls to
pX_selectgroup,
for enabling or disabling physical entities. You can assign each
object an individual ID or set multiple objects to share a single ID
number. However, you must not use 0 as GroupID, cause this would
always disable the entity. Every new entity is assigned to group 1 by
default. So you don't have to call pXent_setgroup
unless you want better control of
which objects are enabled or should collide with each other.
Collision checking is disabled for objects of the same group ID
(except group 0 and 1). Thus if you want two objects to not have
collision detection with each other, set them to the same group ID of
2 or higher.
|
Parameters: |
|
entity |
registered Entity pointer (Actor) |
|
groupID |
new ID number of the object, should be 2 or higher ! |
|
Returns: |
1 if successful, 0 otherwise.
|
Remarks: |
groupID should be a power of two so individual groups can be enabled and disabled using simple addition (cf. example). Values 0 and 1 are reserved. 0 is reserved because it could never be enabled using a bitmask (it always remains 0). 1 is reserved as a convenience so that new objects are automatically part of a group, yet can also collide with each other.
This function can also be called for non-physics entities to set the group ID of the entity.
|
Speed: |
Fast
// player collides with bot and forcefield, but bot can walk through the forcefield pXent_setgroup( player, 2 ); pXent_setgroup( forcefield, 4 ); pXent_setgroup( patrolling_bot, 4 ); while (1) { if (player_inside_building) { pX_selectgroup( 1+2+4 ); // activate group 1+2+4 } else { pX_selectgroup( 1+2 ); // disable group 4 cause player has left the building } }