How do I spawn random sprite from spawner?

0 favourites
  • 5 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hello there, trying to make my first game using Construct.

    So, there are 5 spawners, that should spawn any of 5 random sprites every second.

    1. How to pick a random sprite spawned by single spawner?

    2. How to make spawners not to spawn twice in a row? (in this case sprites overlap each other)

    Any help would be much appreciated,

    Thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • add your 5 sprites to a family. Instead of spawn sprite you just spawn family and this will pick one of the sprites from the family group at random

    How to prevent your spawn point been picked straight away again…

    give your spawn points Boolean instance variable (called for example "busy")

    give your spawn points a timer behaviour

    then in your code you will have an event which say something like

    every X seconds

    add a 2nd condition which says

    pick all the spawn points that are not "busy"

    add a 3rd condition which says

    from all of these available spawn points pick one at random

    The action to this condition is

    from this spawn point spawn a member of the family

    set the timer on this spawn point for a suitable delay

    set the instant variable Boolean "busy" to true

    add a new condition/action which says

    when the spawn point timer is up reset its instance variable Boolean "busy" to false

    Hope this makes sense?

    edit

  • Wow, Thank you so much. Everything works as it should now!

  • is there any possibles way to make this ? without families ?

  • Just do it manually. Generate a random int, and use If Else to decode the value and create each type based on the value.

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