Enemies follow MULTIPLE players

Get help using Construct 2

Post » Sun Jan 26, 2014 5:48 pm

Obviously everyone here should know how to make an enemy follow the player... I currently have 4 players, each with a different instance variable "player"... however, currently this is the code I'm using:

For Each -> Baddie : Baddie -> Rotate 3 degrees toward (Player.X, Player.Y)

Which makes the Baddie follow Player instance variable 0... for some reason, rather than all of them. How would I make it, so that it follows the closest one for example?

I can't even do a "distance(Baddie.X, Baddie.Y, Player.X, Player.Y" because it assumes the first player instance.

I really don't want to quadruple up on all my events to separately track each player.

Any pointers?Nitro1872014-01-26 17:50:28
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Jan 26, 2014 6:07 pm

system pick nearest player?
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 » Sun Jan 26, 2014 6:07 pm

I think I figured it out.... but this may not be the best way:

Rotate 3 degrees towards (Player(0).X, Player(0).Y)

only thing is, I'll have to do that four times to each reference of "Player"... sigh.

Is there another way? At least I have it working... some what.
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Jan 26, 2014 6:09 pm

[QUOTE=LittleStain] system pick nearest player?[/QUOTE]

Never heard of that... nor do I see it... how can that be used in an action? Nitro1872014-01-26 18:09:53
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Sun Jan 26, 2014 6:22 pm

Sorry I'm not at my computer right now. So I can't check what I'm saying.

It's not an action, it's a condition to reference the right object.

It might be a condition of the player object itself though..
player pick nearest to baddy.x, baddy.y
add that condition and the action will apply to that player..
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 » Sun Jan 26, 2014 7:18 pm

Thanks man - it worked. Hard to get your head wrapped around the way it works sometimes... but it makes sense now. :)
B
47
S
15
G
3
Posts: 201
Reputation: 4,625


Return to How do I....?

Who is online

Users browsing this forum: ChoosyZerk, Google [Bot], lukewasthefish and 17 guests