Don't create sprite if already exists at location

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I am creating a wandering monster feature in my game and would like to check for a random monster every X seconds, and based on a random value, if fails, then create a monster at a random location.

    The player follows the path of a ground tile ... so I want to create a monster at random ground tile location, which I am able to do. What I want to do is prevent the creation of monster if a monster sprite already exists there.

    What would be the best way to do this?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can use an invisible Sprite to position at random location and check if it overlaps with the monster.

    P.S. 2 sprites that are side by side on a pixel level WILL trigger an overlap condition in C2. Make sure that the Sprite is 1-2 px smaller than the tile, so is no chance of touching the edge of the monster. (I found that the hard way)

    TIP: if you want to use a "snap to grid" use the formula:


  • That worked! I just created an invisible sprite called Positioner, and moved it to the spot that I wanted to creating something at, and tested for overlap, if there was none, I spawned the new object.

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