How to get the name of an collided entity ?

Blitz3D Forums/Blitz3D Programming/How to get the name of an collided entity ?

Osoko(Posted 2006) [#1]
Hi there,
I've tried this code :
EntityName( EntityCollided (player,2) )
But it cause a memory acces violation.
Have you à solution ?


b32(Posted 2006) [#2]
Turn Debug Enabled on (Program->Debug Enabled) With this enabled, the errors are more specific.
When there is no collision, EntityCollided() will be zero.
Using EntityName$(0) will give a 'entity does not exist' error.
The solution would be checking EntityCollided first:
If EntityCollided(player, 2) then
After that, use
For i = 1 to CountCollisions(player)
mesh = CollidedEntity(player, i)
Then you get all the entities that collided. To get their names, use EntityName$(mesh)