Pick ALL EXCEPT Lowest

Get help using Construct 2

Post » Wed May 06, 2015 4:54 pm

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!
B
3
Posts: 7
Reputation: 189

Post » Wed May 06, 2015 4:57 pm

Wouldn't it just be:

pick all objects - set animation to plain
pick nearest - set animation to shine
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed May 06, 2015 4:59 pm

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. ;)
B
3
Posts: 7
Reputation: 189

Post » Wed May 06, 2015 5:49 pm

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"
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests