0 Favourites

Pick ALL EXCEPT Lowest

  • I have a game where I want to highlight the nearest object (set it to a shiny animation) and make all others plain, within 24 distance.

    So I can pick the nearest object just fine, but I am having trouble making all the other ones stop shining. If I have an event Object is further than 24 > Set animation to plain, that does sort out the further objects, but then if I have two objects within 24 distance they both light up instead of the nearest one. Help!

  • Wouldn't it just be:

    pick all objects - set animation to plain

    pick nearest - set animation to shine

  • Wouldn't that also pick the nearest object and set it back and forth between plain and shine?

    edit: it seems to work ok for static animations but if i want an animated shine then only the first frame shows.

    edit2: thank you! i added an "on any finished" condition to the pick all event so there is a slight delay, but it always lets the animation play before switching it.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The probably better option would be to extend on LittleStain's code would be:

    pick all objects - set animation to "plain"

    pick nearest object

    object's animation name <> (not equal) "shine" " - set animation to "shine"

    This way it only set's it to shine, if it's not already shining.

    You can even take it further and lower the amount of computation C2 has to do, considering most of the times the nearest object doesn't change (this would only do stuff, when another sprite becomes the nearest object):

    localvar = 0

    pick nearest object

    object's animation name <> (not equal) "shine":

    -- set object's animation to "shine"

    -- set localvar = object.UID

    *(subevent of this one) pick all objects

    object.animationname = "shine"

    object.UID <> (not equal) localvar: set animation to "plain"

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