are you confusing type variable structures and collision types ?
Basicly you need to define a EntityType for everything you want to be affected by Collision Handling.
Then, with the "Collisions" command you'll define once, how any contact between two such types has to be handled. Eg:
Entitytype bullet,1
entitytype target,2
collisions 1,2,2,2
would define sphere-to-polygon collision check for mesh "bullet" against mesh "target" (use Entityradius for bullet).
Once defined, you only have to call Updateworld each loop. The Collsion action takes place automaticly.
after Updateworld, you can test if a collision took place.
target_handle=Entitycollided(bullet_handle,target_type)
if target_handle<>0 then
freeentity target_handle
endif
Note: target_type is the type defined using EntityType (see above)
Usually ppl use constants or variables instead of plain numbers to give those types useful names, such as "TYPE_PLAYER" or "TYPE_ENVIROMENT" etc.
eg (assuming you are recycling 100 Bullets, stored in an array):
TYPE_BULLET=1
dim bullet(100)
for i=0 to 100
bullet(i)=createcube()
EntityType bullet(i), TYPE_BULLET
next
Basicly you need to define a EntityType for everything you want to be affected by Collision Handling.
Then, with the "Collisions" command you'll define once, how any contact between two such types has to be handled. Eg:
Entitytype bullet,1
entitytype target,2
collisions 1,2,2,2
would define sphere-to-polygon collision check for mesh "bullet" against mesh "target" (use Entityradius for bullet).
Once defined, you only have to call Updateworld each loop. The Collsion action takes place automaticly.
after Updateworld, you can test if a collision took place.
target_handle=Entitycollided(bullet_handle,target_type)
if target_handle<>0 then
freeentity target_handle
endif
Note: target_type is the type defined using EntityType (see above)
Usually ppl use constants or variables instead of plain numbers to give those types useful names, such as "TYPE_PLAYER" or "TYPE_ENVIROMENT" etc.
eg (assuming you are recycling 100 Bullets, stored in an array):
TYPE_BULLET=1
dim bullet(100)
for i=0 to 100
bullet(i)=createcube()
EntityType bullet(i), TYPE_BULLET
next