How do I pick multiple nearest?

Get help using Construct 2

Post » Fri Jul 01, 2016 2:06 am

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.
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,060
Reputation: 14,054

Post » Fri Jul 01, 2016 3:25 am

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.
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Fri Jul 01, 2016 8:42 am

Prominent wrote: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 ;)
Follow my progress on Twitter
or in this thread Archer Devlog
B
42
S
18
G
19
Posts: 1,060
Reputation: 14,054


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 32 guests