# Enemy Platform

Get help using Construct 2

### » Thu Feb 06, 2014 4:32 pm

Could someone help me out, by telling me how to make an Enemy shoot only if the player is at, lets say x distance away from it? [Platformer Game]

Please if possible if you could make an attached file for it.

Thank you,

kind regards,

Rafael0125
B
8
S
1
Posts: 37
Reputation: 593

### » Thu Feb 06, 2014 4:44 pm

For each enemy
system compare two values : distance(enemy.x,enemy.y,player.x,enemy.y) < 100
- enemy shoot
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

### » Thu Feb 06, 2014 4:47 pm

for the secound one is it

distance(enemy.x,enemy.y,player.x,player.y or enemy.y??

thanks for the reply... will just try it out
B
8
S
1
Posts: 37
Reputation: 593

### » Thu Feb 06, 2014 4:49 pm

I used enemy.y because I thought you only wanted the horizontal distance (x)
If you use player.y it will be like a circle arond the enemy.LittleStain2014-02-06 16:50:11
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

### » Thu Feb 06, 2014 4:53 pm

ok ... so when I went to system ccompare two values .... it asks for the first one than compare than secound value...

So for the first one I write:   enemy.xenemy.y
less or equal
for the second one I write:     player.x,enemy.y

yup for horizontal

thanks :)
B
8
S
1
Posts: 37
Reputation: 593

### » Thu Feb 06, 2014 4:55 pm

no you write in the first one:

distance(enemy.x,enemy.y,player.x,enemy.y)

and in the second one the number of pixels distance you'd like.LittleStain2014-02-06 16:55:36
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

### » Thu Feb 06, 2014 4:58 pm

Thank you very much ... sorry for acting like a noob ... I am bad at programming :( trying my best to learn
B
8
S
1
Posts: 37
Reputation: 593