How do I Pick nearest object of instance

Get help using Construct 2

Post » Fri Feb 17, 2017 8:04 pm

Hi everyone !

First topic for me!

I've been looking for few hours now about the following problem, but didn't find anything about it:

I have an object with some instance of it in my scene. I would like, for each instance, to check the distance between the picked instance (current "loopindex") and the nearest one.
Unfortunatly, when i use the "Pick nearest" condition, it considers the closest instance as the object himself (-_-') . Which is logic in a way, but absolutely not what I want !

How can i resolve my problem?

Thanks guys !
B
4
Posts: 10
Reputation: 220

Post » Fri Feb 17, 2017 9:26 pm

It's difficult because I'm not sure where these sprites are in motion or exactly what the setup is...assuming that they are static, I might try having an array that is filled with the UID's of the instances at the start of the layout, then use the a function to select the UID at loopindex (which I believe would be the array.at(x)-1) and pick object by function.param(whichever parameter has this array variable) and pick nearest where + (invert action) UID is equal to function.param. I habit had to try this myself, but this is my first thought about it. You could also just try adding that last bit, with the inverted action to what you have and see if that fixes it?
B
54
S
32
G
23
Posts: 333
Reputation: 16,591

Post » Fri Feb 17, 2017 10:07 pm

Without using a family. Drag em around.

https://www.dropbox.com/s/07iesd3m2nfku ... .capx?dl=0
B
33
S
18
G
27
Posts: 2,430
Reputation: 20,324

Post » Sun Feb 19, 2017 6:13 pm

Thank you guys ! Both of you! It worked well, but finally what i was trying to do was an awful idea :D
I will try something else.
But thanks.
B
4
Posts: 10
Reputation: 220


Return to How do I....?

Who is online

Users browsing this forum: Meqara, Twili and 1 guest