How do I pick multiple nearest?

0 favourites
  • 3 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I find 'pick nearest' very useful in many cases. But sometimes i feel it's a bit restricted. Can I in some way use this condition to pick multiple nearest? I don't know what would be the best solution to pick the 5 nearest.

    Repeat it after a variable is set, and pick nearest without that variable. Or is there any other way?

    I'm trying to use it for picking the 3 nearest spawnpoints on death, and then spawn at a random one of these.

  • Hm,

    You could give the spawnpoints an instance variable "distanceToPlayer".

    Then on death, do for each Spawnpoints, set instance variable to distance(player.x,player.y,spawnpoint.x,spawnpoint.y)

    Then do a for each (ordered), set to ascending, with the evaluation set to the instance variable,

    then stop at a random instance before you get to the 4th instance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hm,

    You could give the spawnpoints an instance variable "distanceToPlayer".

    Then on death, do for each Spawnpoints, set instance variable to distance(player.x,player.y,spawnpoint.x,spawnpoint.y)

    Then do a for each (ordered), set to ascending, with the evaluation set to the instance variable,

    then stop at a random instance before you get to the 4th instance.

    Thanks that could work too.

    My original thought worked also after I tried it out, nice to see there's different ways to solve it

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