# Flying enemies

Get help using Construct 2

### » Thu Jun 21, 2012 6:21 pm

Trying to make a flying enemy. I cannot figure out how to though. I have on the Global attack range so when I get close he'll attack me, but not happening. Also How can I get him to go up and down as a platform enemy would go left and right while patrolling?
B
23
S
6
G
3
Posts: 122
Reputation: 2,922

### » Thu Jun 21, 2012 8:04 pm

If you mean floating up and down in a wave motion? If so have his Y coordinate add a multiple of the 'sine' wave.

With enemies I would usually have a variable such as 'InRange'. Default set to '0'. Once the player gets within range of the enemy, the 'InRange' variable is set to '1'. If the 'InRange' variable is set to '1', then the enemy angles towards the player and begins shooting etc...

InRange = 0 Would therefore be in a passible mode
InRange = 1 Would therefore be in an aggressive attacking mode.

If the Global Attack range is not working. Instead either use a sprite as a hitbox (Big circule), so that when the player collides with it InRange is set to '1'. Alternatively have an event which checks the players distance such as the expression "distance(x1, y1, x2, y2)", if this number returns too low, then have InRange set to 1.
B
85
S
31
G
14
Posts: 106
Reputation: 16,450

### » Fri Jun 22, 2012 6:21 am

I'm thankful for your help, but I don't quite understand how I would put that in. Can you tell me in simpler terms.

Example: "Player > On Collision With > Platform"

I do appreciate it, but I just need broken down a bit more. I'm still very new to this.
B
23
S
6
G
3
Posts: 122
Reputation: 2,922

### » Fri Jun 22, 2012 4:23 pm

what hes sayin is every tick check the distance from the players location to the enemy location and if its less than however close you want it to be before the enemy reacts then make it react
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

### » Sat Nov 08, 2014 6:58 am

how do you make the player fly?
B
4
Posts: 3
Reputation: 208

### Who is online

Users browsing this forum: Rasputin, Speedkillerr, wiredcleric and 20 guests