About Picking

Get help using Construct 2

Post » Sat Dec 17, 2011 4:22 pm

I'm making my enemies AI. So picking is really important here. My question:

In an event like this:

Object1.X > Object2.X -> Object2.SetMirrored

Does all Object2 instances get's affected or just the one picked by the condition ? It seems the all Object2's are getting affected.
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sat Dec 17, 2011 4:51 pm

Big difference between object1.x > object2.x, and object2.x > object1.x.
Basically your first comparison is picking object1, if any of object2 meet the condition.
What you want is to pick object2 if any of object1 meet the criteria.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Dec 17, 2011 5:27 pm

Ok, got it thanks !
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sat Dec 17, 2011 5:39 pm

Well it turns out that i'm using System Compare Two Values. So it not picks as expected. In my example. I have:

System: abs(Object2.X - Object1.X) <= Value -> Object2.Var = Something
All Object2 instances get affected. Resuming what is happening is that my Object2 acts defined by an AI. But when an event triggers an action on one instance all other instances do the same action. Clearly a picking problem. I'll try to find a workaround.
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sat Dec 17, 2011 6:05 pm

Don't use system compare, it doesn't do any picking.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sat Dec 17, 2011 6:14 pm

If you want your ennemies to always look at the player (that's how I understand your AI) you just have to do :
[code]enemy: X <= Player.X
-> enemy: set not mirrored
enemy: X > Player.X
-> enemy : set mirrored[/code]

Yann2011-12-17 18:18:50
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Dec 17, 2011 8:07 pm

Ok about the mirroring that's it thanks. But the problem is that i want enemies to act when at a determined distance from player (but of course individually :) ), that's why i'm using system compare. There's sight distance and stuff. The problem is that i must track exactly which enemy triggered the event so that i can act only on it and not on them all. Well, i think that's when using detached (not assigned to an object in particular) events falls short. Maybe it's something simple and i'm missing. Maybe i could instead of comparing distances use a bit sprite detector around my player so that when enemies overlap it i can pick them correctly. But i'd prefer not have to resort to that. I'll keep trying.Kiyoshi2011-12-17 20:09:16
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Sat Dec 17, 2011 8:23 pm

I did this capx a while ago.

Making another instance of the enemy works a bit (not perfect), but the distance/targeting seems to work as intended.

You might find it useful hopefuly.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Dec 17, 2011 8:24 pm

[code]enemy: X <= Player.X
enemy: X > Player.X-distance
-> enemy: set not mirrored
enemy: X > Player.X
enemy: X < Player.X+distance
-> enemy : set mirrored[/code]

Like that? o.oYann2011-12-17 20:24:35
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Dec 17, 2011 8:24 pm

Ashley should be adding overlap at offset soon.
Thats whats needed here.
Other wise you would be checking enemy.x < player.x +offsetnewt2011-12-17 20:26:23
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Next

Return to How do I....?

Who is online

Users browsing this forum: fredriksthlm, MPPlantOfficial and 25 guests