Pick nearest not working as expected.(SOLVED)

Get help using Construct 2

Post » Fri Nov 11, 2016 10:38 am

In my game I have proximity mines that work 'should' work by:
Distance(mine and enemy) less than or equal to 150 pixels.
Mine pick nearest enemy.
Mine is not playing animation "active".
Then:
Mine set animation active (from beginning).
However this doesn't work when multiple mines are on-screen.

The gun fires a volley of four mines, each with bullet behaviors. Currently the mines have an overlapping sprite pin to them with a larger collision polygon, when they hit the enemy it activates the mine. However because of reasons this method doesnt work well and is limited to one volley at a time. If anyone knows another way that is simple and works independent of the number of mines please let me know.
Last edited by currypuff on Fri Nov 11, 2016 11:42 pm, edited 1 time in total.
B
14
S
3
Posts: 55
Reputation: 912

Post » Fri Nov 11, 2016 10:49 am

Do you try system condition "For each" ?
Image Image
B
22
S
13
G
129
Posts: 868
Reputation: 67,314

Post » Fri Nov 11, 2016 12:38 pm

I tried that but what happens is when the first mine is activated the other mines only activate when they are within the radius of the enemy that set off the first mine. I.e. it only picks the nearest enemy to the first mine, does anyone know how to work around this?
B
14
S
3
Posts: 55
Reputation: 912

Post » Fri Nov 11, 2016 1:24 pm

Try line of sight.
Image ImageImage
B
168
S
50
G
163
Posts: 8,220
Reputation: 105,059

Post » Fri Nov 11, 2016 1:46 pm

@currypuff :

Don't compare... use picking conditions for picking...

Don't use this:
Distance(mine and enemy) less than or equal to 150 pixels.

Use this:
Pick (by comparison) : Enemy.X > Mine.X &
Pick (by comparison) : Enemy.X < or = Mine.X + 150



And also, use For Each

Complete event:


For Each (Enemy)
Pick (by comparison) : Enemy.X > Mine.X &
Pick (by comparison) : Enemy.X < or = Mine.X + 150
Mine pick nearest enemy.
Mine is not playing animation "active".
Then:
Mine set animation active (from beginning).
However this doesn't work when multiple mines are on-screen.



Or if it's too complicated for you, then use "Line of Sight"
Image



The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
55
S
17
G
90
Posts: 1,111
Reputation: 59,145

Post » Fri Nov 11, 2016 11:41 pm

Thanks chadorireborn for the suggestion but it didn't give the result I wanted, however line of sight did. Thanks a lot newt, I'm surprised I didn't think of it earlier.
B
14
S
3
Posts: 55
Reputation: 912


Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 8 guests