How to spawn object at random specific positions

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

    Currently I have 4 spawn points. In fact, it is an object called "spawnPoint". This object has an instant variable called "position". I set the position for each spawnPoint from 1 to 4.

    Now I want for each 2 seconds, spawns a new object from 1 of these 4 points. I do not know how to do it.

    Cheers,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • make a global (or local) variable first, lets call it "whichspawn"

    Condition:

    system - every 2 seconds

    action

    whichspawn = int(random (1,5))

    system/

    create object yourobject at location whichspawn.X, whichspawn.Y

    something along these lines. I hope I could help.

    Regards;

    -Wind.

  • make a global (or local) variable first, lets call it "whichspawn"

    Condition:

    system - every 2 seconds

    action

    whichspawn = int(random (1,5))

    system/

    create object yourobject at location whichspawn.X, whichspawn.Y

    something along these lines. I hope I could help.

    Regards;

    -Wind.

    Hi Windwalker,

    Thanks for your help. According to your suggestion, I solved out my issue. However, the actually code is a little bit different:

    Condition:

    system - every 2 seconds

    action

    whichspawn = int(random (1,5))

    system/

    create object myObject at location myObject(whichspawn).X, myObject(whichspawn).Y

    Hope that will help other people as well.

    Cheers,

  • Pick a random instance of spawnPoint then create the new object at spawnPoint

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