How to set random spawn choices

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

    I need some tips whats the easiest or most effective way to randomize my powerup spawns.

    Case is like this:

    i have one point from wich i spawn powerups and since i have several of them i would like to randomise choice.

    Lets say every 3 seconds spawn powerup1 or powerup2 or powerup3 etc.


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How are your power ups organised ? Are they all the same object, with different animation/frame ? If so, you just have to spawn one power up, set its animation to "floor(random(3))+1" (witch will sent back 1, 2 or 3, so add a prefix before it) and you are done.

    If it's different object, you will want to make a function "spawnPowerUp" that will start by doing a random, storing it in a local variable, and then will instance an object depending on the random. Example in this link.

  • instead of


    you could also use


    If you are using different objects use one of these two expressions to set a variable and create a differnt object based on the value of the variable.

  • LittleStain Thanks ! Didn't know this one ! It will simplify a lot of things :) (btw, nice new avatar ^^) Thanks again !

  • Thank you for your advices...

    I could go either way but theres one matter later in game...

    Later i intent to make collecting specific powerup as assigned.


    In upper left corner of UI shud be immage of certain powerup that is assigned and only that one when collected would give bonus and rest of powerups that spawn would not.

    Having this on mind wich approach would be better?


  • Either, it won't change. The "problem" you described just now is during the powerUp collection, not spawning. Either way would be usable later on. But personally I would go with multiple objects in the same family. It seems the most easy to scale right now.

  • Thank you, i will try that approach.


  • Thank you very much, Guizmus! I was hoping to find a similar answer in this forum and was lucky enough to stumble upon your posts here. Good stuff!

  • Hey everyone! I'm kinda stuck with the situation when I need to have the sprite to appear in several specific locations randomly with different frequency ( up to the certain point with 3 sec interval then less).

    Any ideas?

    Thanks a lot.

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