0 Favourites

second closest

This forum is currently in read-only mode.
  • 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.

  • Here's a way to do it with one global variable and two events:

    + 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]
  • not quite as simple as you were hoping I'm afraid, but it was the first semi simple solution I found

    http://dl.dropbox.com/u/1013446/second.cap

    edit:

    nm, rojo's method is much better

  • Here's a way to do it with one global variable and two events:

    + 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]
    

    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...

  • If yours doesn't work, maybe my not as nice as rojos way will

  • 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!

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • > Here's a way to do it with one global variable and two events:

    >

    + 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]
    > 
    
    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.
    

    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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic Locked topic
198 18,655
Tom's avatar
Tom Construct Team Founder
Unread hot topic
98 7,593
norum82's avatar
norum82
Unread hot topic
74 4,513
Dalal's avatar
Dalal