second closest

For questions about using Classic.

Post » Fri Aug 13, 2010 8:27 pm

is there a way to simply select second closest.

I tried to deselect first by using

'block' variable not equal to enemy.uid
pick closest 'block'

But it does nothing because it still picks the closest block and the condition never suceeds...
because the closest block is equal to enemy.uid,

but how could i rule out the closest one within the condition so i dont have to do too much events for this.? Mostly cause this is already within a loop and to iterate it is pretty much asking for trouble. If thats the correct term. :D
B
3
G
4
Posts: 54
Reputation: 1,183

Post » Fri Aug 13, 2010 9:07 pm

Here's a way to do it with one global variable and two events:
[code:2uwyojk0]+ Sprite: Pick closest to: MouseX, MouseY
-> System: Set global variable 'notthis' to Sprite.UID

+ Sprite: [negated] Sprite: Unique ID is global('notthis')
+ Sprite: Pick closest to: MouseX, MouseY[/code:2uwyojk0]
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Fri Aug 13, 2010 9:26 pm

not quite as simple as you were hoping I'm afraid, but it was the first semi simple solution I found
[url:rvmg39r1]http://dl.dropbox.com/u/1013446/second.cap[/url:rvmg39r1]

edit:
nm, rojo's method is much better :)
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Aug 14, 2010 12:13 am

[quote="R0J0hound":1ddaobb1]Here's a way to do it with one global variable and two events:
[code:1ddaobb1]+ Sprite: Pick closest to: MouseX, MouseY
-> System: Set global variable 'notthis' to Sprite.UID

+ Sprite: [negated] Sprite: Unique ID is global('notthis')
+ Sprite: Pick closest to: MouseX, MouseY[/code:1ddaobb1][/quote:1ddaobb1]

I did that myself in the first place but it doesn't work, mostly because it still pick closest to mouse.x even with first negation event, its like however i decide to outrule the first one from picking it, it is still picked.

And the most problem is because i have multiple blocks and enemies. Actually just finding the closest enemy from enemy would suffice and actually would be the best description of what i am trying to do but i wouldnt know how do that aswell, as pick closest does not negate the first object that was negated by any other condition.

But actually i got an idea of how would i do it, i just have to check it out... :D
B
3
G
4
Posts: 54
Reputation: 1,183

Post » Sat Aug 14, 2010 12:18 am

If yours doesn't work, maybe my not as nice as rojos way will
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Aug 14, 2010 1:14 am

well thanks lucid for trying but there is no way this is possible, i tried like anything and everything.
Ok maybe it is but i will have to sleep on it and kick my ass aswell. Maybe then!
B
3
G
4
Posts: 54
Reputation: 1,183

Post » Sat Aug 14, 2010 2:38 am

[quote="Skyhunter":3ctczbur][quote="R0J0hound":3ctczbur]Here's a way to do it with one global variable and two events:
[code:3ctczbur]+ Sprite: Pick closest to: MouseX, MouseY
-> System: Set global variable 'notthis' to Sprite.UID

+ Sprite: [negated] Sprite: Unique ID is global('notthis')
+ Sprite: Pick closest to: MouseX, MouseY[/code:3ctczbur][/quote:3ctczbur]

I did that myself in the first place but it doesn't work, mostly because it still pick closest to mouse.x even with first negation event, its like however i decide to outrule the first one from picking it, it is still picked.[/quote:3ctczbur]

R0J0hound's example does work to pick the second closest. The second pick closest condition cannot pick the actual closest object, if you set the events up correctly, because it has been excluded from the selected object list that the second pick condition applies to.

I made a small example to demonstrate his method. I added a 'On left mouse button down' to activate it, just to show how you may have to group the events as sub-events somewhere in your event sheet, based upon some other condition.

http://dl.dropbox.com/u/5868916/SecondNearest.cap

It's made with v0.99.92
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Sat Aug 14, 2010 7:37 am

Well, yes it works whilst it's not in a loop, but i need to loop all the objects and put the distance from the second closest into a variable into each one...

Nevermind, i had a stroke of genius or something, used that function thingy again, which deselected the object but remained in the loop...
http://www.mediafire.com/?t8er1afja67aqlo

Thanks for all the input guys.
B
3
G
4
Posts: 54
Reputation: 1,183


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests