Stencyl 3.4.0 is now out. Get it now!

Detect how many 'enemy' actors on screen

nikopol

  • Posts: 24
Hello,

So I am brewing this Platformer game, where my Player can cast a spell (see ActorEvents_8 attachment).
As you can see, the spell will be created by pressing action1, and pushed over to an actor of group : 'enemies'.

There are two problems : 
  • when there are many enemies on the scene/screen, spells head for the last created one, even if off screen
  • when there are no enemies, the spell doesn't move

I'd like for the spell to aim at the nearest enemy on the side of the scene where he is looking.
And if there are no enemies, for the spell just to go straight.

Thanks in advance

greatanthony

  • Posts: 99
you finally want to detect the NUMBER OF ENEMIES PRESENT ON SCREEN ?


nikopol

  • Posts: 24
Yes, but also get their coordinates.

greatanthony

  • Posts: 99
wait a moment....this will get you number of enemies present on screen
( it automatically updates if any enemy exits........)


create a LIST ATTRIBUTE named "No. of ENEMIES PRESENT ON SCREEN"



then :

AND THEN NUMBER OF ENEMIES PRESENT ON SCREEN IS


--in place of that [enemy] you have to CHOOSE ACTOR TYPE > and choose your Enemy actor Type......

Note : when your enemy dies ( the condition may vary on your game how it dies EX.by bullet,by falling ,etc)
             Then you have to also remove that enemy actor from the list :
              so just [REMOVE [actor] from [ the list]]


« Last Edit: March 19, 2017, 03:59:36 am by greatanthony »

nikopol

  • Posts: 24
Great this works to keep track of the number of enemies.

But how to I get the coordinates of those enemies ?

Thanks for your help so far

CmdrWhitey13

  • Posts: 443
Get x of (get item#n in no. of enemies on screen)
Get y of (get item#n in no. of enemies on screen)

n being the actor in question at the time.