How do I pick a random instance from family BUT not the nearest to player?

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I am making a minigame inside my game, where you are attacked by enemies who spawn randomly on the layout at specific spawn points. Now I tried two different solutions:

    1. (Yellow solution) I let the system pick a spawn point randomly to spawn the enemy. Problem with that was, that the enemies sometimes spawn so close to you, you actually have no time to react an get hit. Not fun...

    2. (green solution) I always pick the spawn point furthest away from the player. The player must collect things on the layout anyway and therefore will move. Enemies mmight just spawn far away from him and thanks to their other behaviors they eventually reach player and attack. Problem is, too many spawn at the same point, forming clusters, game gets too easy, since they sort of attack in waves that are easy to handle.

    I would like enemies to spawn on all the possible spawn points except for the closest to the player.

    ... but i am too dumb for that yet. Does someone see a way to insert that?

  • If the task is not to spawn too close to the player, you can in first condition filter all spawn points by distance, then pick a random one among them:

    System pick Spawn by evaluate distance(Spawn.x, Spawn.y, player.x, player.y)>200

    System pick random Spawn

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That sounds lovely! Thanks a lot! :D

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