How do I spawn to object?

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi to everyone

    in my app i need to spawn an object, i have 12 differents fixed blocks and i want my object to spawn at one of those 12 different blocks

    how can i achieve that?

    i tried this formula but its not working: random(Meteor_generator.ImagePointX(0))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Pick random instance" first, then spawn at it's ImagePoint.

  • You could always use "Pick instance with UID" along with Choose(0,1,2,3,4,5,6,7,8,9,10,11,12). I tried multiple ways to use random(0,13) but random doesn't seem to work well with Pick UID...

    Of course the UID numbers I use assume your spawners are the first 12 sprites made in the project, otherwise you will need to use your UIDs.

    but then if your spawner objects are all the same instance you could just use "Pick random instance".

    Regardless, you will need to choose the spawn point first and then fire off the spawn.

  • Random doesent work because it gives a number between 0 and 13 which could be 5,654365764 for example.

    I guess it would work with round(random(13)) or floor(random(14).

    But still "pick random instance" is the best option here.

  • i solved my problem by jus doing a random x position with the windows screen size thanks for your help

  • [quote:3ab0pqrz]Random doesent work because it gives a number between 0 and 13 which could be 5,654365764 for example.

    I guess it would work with round(random(13)) or floor(random(14).

    That's right.. you would need to use floor(random(0,4)) for whole numbers.

    Glad you worked it out!

  • Hi. I will like to ask a question here so I don't have to create another post since is related with the title. I want to spawn/create an object to a random position of the player (in an area around the player). Something like Player.X(random(-200,200)) ; Player.Y(random(-200,200)) ; I can't figure out how to do this . Thanks !

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