Does "Pick Nearest" pick itself?

0 favourites
  • 7 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.
  • You have 2 instances of the same Sprite.

    The following snippet:

    Sprite -> Pick Nearest to Self.X, Self.Y

    Does it pick itself, or does it pick the other sprite?

  • Yes they would.

  • I tried another method.

    I have 2 instances of Sprite.

    One with UID 0 and one with UID 1.

    Pick Sprite with UID 0

    • > Pick Nearest Sprite to Self.X Self.Y

       -> Set Text to Sprite.UID

    It seems to select the sprite with UID 0, in the first pick, and not the sprite with UID with pick 1.

    How would you make a sprite pick the nearest other sprite of the same type?

  • First you would have to pick one instance, and save its x, and y to a variable, then you would need to make it so that instance is not picked again. So..

    On you condition/ trigger picking your object

    - call function("myfunction") set parameter index 0 to object.x, set parameter index 1 to object.y

    -- set object instance variable variable ("dontPickMe") to 1

    On function("myfunction")

    -object compare variable("dontPickMe") =0

    --object pick closest to object.variable((myfunction.parameter(0),myfunction.parameter(1))

    So basically add a function object to get out of the picking issue.

  • newt

    Thanks for the tip. I tried it but it didnt work properly. I'll repost this in the howto section furter and explain my problem better with more detail.

  • I believe newts example would work, as long as the order is exactly followed. EXCEPT: the first action, make sure to Set the "DontPickMe" to 1 before calling the function.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Check Yann's example in this post:

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