0 Favourites

Random spawn help

  • Okay I've been trying to look around the forum for help, even the FAQ but no luck. Well my problem is that I am making a survival zombie game. Think like the turorial where there are ghosts, like that but with zombies and I want my zombies to spawn randomly on the layout.

    And I can guess that it's possible that if my score is x then spawn a new type of zombies. If you can then please help me.

  • If you have no restrictions on where the should spawn it's fairly easy. Use random to create a X and a Y value within the borders of your layout. Then you can utilize the "System - Create Object" with these values to spawn your Zombies.

  • where is the reference manual for using things like random()

  • rafhelp: it's the system expressions in the system references.

    You can also have a look at the system conditions and actions.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • If you have no restrictions on where the should spawn it's fairly easy. Use random to create a X and a Y value within the borders of your layout. Then you can utilize the "System - Create Object" with these values to spawn your Zombies.

    I am really new to construct 2 and very new to programming..when you say "Use random to create a X and a Y value within the borders of your layout" what exactly needs to be done on the event sheet ??

  • Have a trigger, such as time, score etc.

    Then - System -> Create Object (which is right at the top)

    Choose a layer and then input and X and a Y value. X and Y being a pixel value corresponding to the playing area. Just say your layout size is 1280 by 1024 (you can check this by clicking on your layout in the Projects Bar), the enter a number between 0 and 1280 for X and 0 and 1024 for Y.

    Instead of entering a number, you can use the "random" expression to make it generate a random number. In which case enter random(0,1281) in the X section, and random(0,1025) in the Y section of the Create Object event. The random() expression will return a random number between the two numbers you enter. Well actually, it will return a value between and including the first number, and one less than the second number, hence why I added 1 to the last number of those examples.

  • thank you so much..that at least helped me to get started with placing the objects randomly in my game.. is there anyway i can control the number of objects spwan when the player is in the game screen...i am making a 2d..free run...survival side scroller..

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