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
|