type collisions

Blitz3D Forums/Blitz3D Programming/type collisions

Rook Zimbabwe(Posted 2004) [#1]
I use a type to create bullets and a different type to create targets

How do I check for collisions between each type? Linepick???

-RZ


Neo Genesis10(Posted 2004) [#2]
The commands you need are EntityCollided and Collisions. Set a collision type for bullets and targets (different types for each) using Collisions then use EntityCollided to check collisions.


Rook Zimbabwe(Posted 2004) [#3]
It is the entitycollided that I fail to uderstand or use.

I have the bullets stoping now when they hit a target but I can't seem to make the target dissappear OR update the score... You wanna see code?
-RZ


Rook Zimbabwe(Posted 2004) [#4]
OK I got the score to work by making sure it is GLOBAL but I still can't kill the targets!


jfk EO-11110(Posted 2004) [#5]
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