B3D Collisions EntityCollided()

Blitz3D Forums/Blitz3D Programming/B3D Collisions EntityCollided()

_PJ_(Posted 2009) [#1]
I can see now why B3D collision stuff is avoided so much.

I Have set up my collisions with the 'Collisions' command, and givent he entities involved EntityTypes when 'in-game', the collisions appear to work, as (using STOP response) the entities that collide are indeed stopped.

However, when I come to check the collision:

		If (EntityCollided(ShipMesh,CollisionTypeAlien))
			DebugLog "ShipHit "+EntityName(EntityCollided(ShipMesh,CollisionTypeAlien)))
		End If


I have tried this code both before, after and without UpdateWorld and still the debug message never appears :(


Vorderman(Posted 2009) [#2]
Have you assigned them collision radiuses (assuming you're using sphere->sphere collisions)?


Warner(Posted 2009) [#3]
Because multiple collisions can occur, it is better to use CountCollisions and CollisionEntity instead:



_PJ_(Posted 2009) [#4]
Yes, Vorderman. they all have collision radii.

Warner - Considering the 'ShipMesh' will only collide with one thing at a time, and I only need to check for ANY collision with an "Alien" type entity, is the count collisions necessary?

Also, I should have mentioned, the "Alien" entities are made with CopyEntity (Although the master has a radius and type set too) Is that likely to be a factor?


Warner(Posted 2009) [#5]
That should no be an issue:



_PJ_(Posted 2009) [#6]
		For iterColls=1 To CountCollisions(ShipMesh)
			DebugLog "Counting: "+iterColls
			Collided=(CollisionEntity(ShipMesh,iterColls))
			If (Collided)
				DebugLog "ShipHit "+EntityName$(Collided)
			End If
		Next


-=-=-=-=

Edit edit edit:
(I made a silly mistake, trying to fid the name of anentitybefore it was even verified to exist!)

Thanks for the help, Warner. The above works fine now I put CountCollisions in. Thank you!