# How do I pick up good instance after a "compare two values"

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

Enjoying a lot this software ...

However something simple I don't get at all :

I want an ennemi of "Evil" type to wake up when Hero gets close. I use "compare two values" :

distance(Evil.X,Evil.Y,Hero.X,Hero.Y) < 600

Then :

Evil set awake to 1

Problem : When triggered, every "Evil" type have awake set to 1

Spent 2 hours on this, read a lot about it ... Still don't get it, any help will be greatly appreciated !!

Best,

Charles

• you 'd have to add a System>For each Evil condition for this to work (not sure it is the best way to do it, since it can make a lot of calculs if there is a lot of evil and hero))

• it actually did the trick yes, thanks a lot

• You can also just use "Pick nearest Enemy to Hero" and use it together with the distance check you already have.

The reason it picks everyone, is because you haven't told it which "Evil" you want to check the distance to hero. So it just take all of them or a random one, not sure.

• Thanks that's good idea so it only check the nearest. Actually, I tried to replace it by

Evil : awake = 0

it seems to work as well

• ## Try Construct 3

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

Construct 3 users don't see these ads
• try instance variables learn about instance variables here

https://www.scirra.com/tutorials/806/instance-variable

• I use something similar in my level selection, you can probably add instance variables, lets say its called (Sleep) set all to -1 for "Evil" except the intended evil, set it to 1,

• Distance ( x ) < 600

-- System Evil.Sleep = 1 ----> Set Awake = 1 (Compare instance Variable for Evil)

I'm not properly skilled but that's how I work out my events. Hope this helps =o)

• 7 posts