Spawn enemies in a random specified location

0 favourites
  • 12 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hi!

    I'm trying to make enemies spawn randomly in a specified location but i can't get it to work, for example:

    I have a sprite called Spawn and then i duplicated it all over the map, until here is all fine but when i do System -> Every 5 seconds -> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y) it always creates the enemy always in the first spawn and not in the others <img src="smileys/smiley26.gif" border="0" align="middle" />,

    I tried to change the (Spawn.X , Spawn.Y) to (random(Spawn.X) , random(Spawn.Y)) but it also doesn't work (enemies never spawns). <img src="smileys/smiley26.gif" border="0" align="middle" />

    Can anyone help me?

    Thank you ^^

    you can use the choose operator like this:

    System.Every 5 Seconds:

         -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

    You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

    Here is the cap with smitchell idea(thanks): dl.dropbox.com/u/18148396/spawn2.capx

    Here is the cap without smitchell idea (which only spawns in 1 location): dl.dropbox.com/u/18148396/Spawn.capx

  • You can make it using an overlapping conditional, when the spawner is overlapping the "invisible area of spawn" sprite, it can shot the enemies ^^

  • Post a .capx so more people could take a look. It's hard to know the problem with just the explanation

  • you can use the choose operator like this:

    System.Every 5 Seconds:

         -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

    You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • you can use the choose operator like this:

    System.Every 5 Seconds:

         -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

    You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

    Hmm... smitchell the way you said it works but if i have for example 50 spawns positions and for some reason i have to delete or change the spawn location i will have to look every 50 positions to see which one that i need to change in the event sheet <img src="smileys/smiley19.gif" border="0" align="middle" />

    Post a .capx so more people could take a look. It's hard to know the problem with just the explanation

    Here is the cap with smitchell idea(thanks): dl.dropbox.com/u/18148396/spawn2.capx

    Here is the cap without smitchell idea (which only spawns in 1 location): dl.dropbox.com/u/18148396/Spawn.capx

    You can make it using an overlapping conditional, when the spawner is overlapping the "invisible area of spawn" sprite, it can shot the enemies ^^

    I think i didn't understood what you said or you didn't understood what i asked <img src="smileys/smiley36.gif" border="0" align="middle" />

    Thanks anyway <img src="smileys/smiley20.gif" border="0" align="middle" />

  • System:Every 5 seconds
    System:Pick random Spawn instance
    [ul]
    	[li]> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y)
  • System:Every 5 seconds
    System:Pick random Spawn instance
     -> Create Object Enemy on layer 0 at (Spawn.X , Spawn.Y)

    Thank you!!!! It worked!

    <img src="smileys/smiley17.gif" border="0" align="middle" /> <img src="smileys/smiley17.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" />

    Thank's to everyone who tried to help !

  • Good info! Like for spawning random bullets as asteroids.

  • What else, if i want to spawn enemies and i want my enemies go from A to B, and die in B.

  • you can use the choose operator like this:

    System.Every 5 Seconds:

         -> System.Create Object Enemy at layer 0 at (Choose(x1, x2, x3, x4), Choose(y1, y2, y3, y4)

    You can add as many parameters to the choose operator as you want(I think). Change the x1 to x positions you want obviously.

    Hope that helps! <img src="smileys/smiley1.gif" border="0" align="middle" />

    I want to ask if there is anyway to spawn enemies at different spawns WITH many duplicated objects. I have created a 'spawn' object, duplicated it all over the map, but the choose function has to have two or more parameters and that 'spawn' object is the only object for spawning. I wonder how can it spawns randomly but on duplicated objects?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • JustForFun119 use the "Pick Random Instance" action instead.

  • Thanks for the lightning-quick reply :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)