AnimMesh Collisions?

Blitz3D Forums/Blitz3D Programming/AnimMesh Collisions?

wmaass(Posted 2009) [#1]
Looking for some help here.

I have an "enemy" type that is an animated b3d. I used an alien model from the Dark Matter collection converted to b3d and it has a body, legs etc. When I create an instance of the type, I set the collision parameters for all of its parts. When a bullet hits ANY part, I want to free the model and the type. But it only seems to work if the part that is hit happens to be the mesh root (top level parent). Here are the relevant functions:

Function EntityAnimColType(m)

	If EntityClass$(m)="Mesh"
		EntityType m,alien_col
	EndIf
 		
	For i=1 To CountChildren(m)
 		ww=GetChild(m,i)
		EntityAnimColType(ww)
 	Next

End Function


If EntityCollided (bullet\obj,alien_col)

   	colnum = CountCollisions(bullet\obj)
	colenemy = CollisionEntity(bullet\obj,colnum)
	
	checkpartsforhit(colenemy)

	FreeEntity bullet\obj
    Delete bullet
    Return

EndIf

Function checkpartsforhit(p)

	For e.enemy = Each enemy
		For i=1 To CountChildren(e\model)
 			h=GetChild(e\model,i)
			If h = p
				FreeEntity e\model
				Delete e
				Return
			EndIf
		Next
	Next
	
End Function




wmaass(Posted 2009) [#2]
I ended up creating a pivot to control the enemies. That way I could just use EntityDistance to do the bullet vs enemy check. It also gave me a way to have the enemies walk on the ground...good enough for now.