Spawn objects on custom spots

0 favourites
  • 5 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • Hello,

    So I have 2 slots in wich I want to spawn one object. My problem is that if one slot is occupied how do I make the object to spawn on the other one. I have to mention that there can be 10 slots and I want to spawn the object on the ones that are not occupied... one by one. The idea of the game is to have 1 plate of food and when I press a button the plate spawns random on one of the slots but not on the slots that already have a plate on them. And when one spot is cleared it should be again available for spawning.

    Thank you and have a nice day

  • Hello o/

    There are many ways you can do that, and the best way to do it depends on what you are looking to achieve on the rest of the game. So I will give you a few ideas, and you try to see if any of them works with what you are trying to do, and if they don't you come back here and try to be a bit more specific on what's going on on that game of yours.

    First thing I would try is a "system > for each" and make the slot spawn the object. This will select each slot once and spawn the object for each one of them.

    Another look would set at the slot properties a variable to define if the object is occupied or not. After that every time you want to spawn something you go "system>pick by comparison" and compare the variable of the slot with the value that tells if it is occupied or not.

    And another way, that I wouldn't suggest that much, but it can still work is trying to check if the slot is overlapping the object you want it to spawn, and if it is not then spawn it.

    Again, see if any of this helps and if it doesn't just come back here o/

    Good luck

  • PreacH Would this work for you?:

    https://www.dropbox.com/s/why3eeheyjhd7 ... .capx?dl=0

    Tap any key to add a random plate.

    Left click a plate to remove it.

    Tapping a key populates calls a function that populates the array with the UIDs of all plate objects that have an animation frame of 0, then picks one at random and assigns it a random plate frame (excluding 0).

    You can scale this by adding more plate objects to the layout, no need to adjust the code.

    If you want more plates of food you can add extra frames to the animation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mekonbekon Your example is perfect for what I need. Thank you very much for this and thank you RayKi as well for the great ideas

  • PreacH You're welcome

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