Global and Collisions

Blitz3D Forums/Blitz3D Beginners Area/Global and Collisions

Ok, here it is, thx for being willing to take a look.

Now, when I shoot at my badguys, it works kinda...meaning that when I kill one, only the first one loaded takes the damage, and respawns, but the one's I actually shoot are still there.

so it seems that a\entity loaded first takes all the damage from all the others.

;Load Actor(s)
SeedRnd MilliSecs()
For loop = 1 To 15
	a.actor = New actor
	a\entity  = CopyEntity( scifiguy )
	EntityType a\entity,TYPE_BADGUY
	EntityRadius a\entity,rsize#
	Animate a\entity,1,.5,1
	PositionEntity a\entity,Rnd(1,200),32,Rnd(1,290)
	ScaleEntity a\entity,.12,.12,.12
	Print loop
Next


;Shooting the badguy
If CountCollisions(b\sprite)>0 ;this is my bullet
	
	If EntityCollided(b\sprite,TYPE_BADGUY) ;collisions have been set via Const

	  For a.actor = Each actor
            If EntityDistance(b\sprite,a\entity)<9
			  enemy_hit_counter=enemy_hit_counter+1
			   EmitSound bad_guy_sound,a\entity
			   RotateEntity a\entity,0,270,0
		 	 If enemy_hit_counter=>1 
		 	  score=score+5115
			   PlaySound spawn_sound
			   kill_counter=kill_counter+1
		  	  HideEntity a\entity:TranslateEntity a\entity,0,-200,0:PositionEntity a\entity,80,-1,-88:ShowEntity a\entity
		 	  enemy_hit_counter=0
		 	 EndIf
		 	EndIf

	   Next
 EndIf
EndIf