Enemy AI(Regular Movement, Pursue, Attack)

Get help using Construct 2

Post » Mon Feb 17, 2014 8:35 pm

I have been having this issue for a while now and I have finally decided to try and reach out for help. Just so you guys know I have search the forums and I haven't found exactly what I was looking for.

What I would like to do is have the enemies spawn from the spawn objects and when they land on the ground I would like them to choose a random direction to got between left and right.

Next I want the enemy to identify when the player is in "pursue" range and change its animation frame to 1 and moves toward the player and if it get in "attack" range of the player I want it to stop movement and change its animation frame to 2. If player is out of "attack" range and "pursue" range I would the enemy to start its regular movement based on the direction it is facing.

The results that I getting:

1. Right now I the enemy spawns randomly between intervals of five seconds, which is good but I can't get the enemy to choose a random direction once it is on the ground
2. When the player is in pursue range of the enemy the enemy will not move towards the player it just stays in the same position.
3. All enemies react the same instead of reacting to the player individually

I understand that this may be a lot that I'm asking for but I can't seem to find answer anywhere else. Any help is appreciated. Thanks.Scottydoes3d2014-02-17 21:09:23
B
8
S
1
Posts: 39
Reputation: 685

Post » Tue Feb 18, 2014 5:48 pm

I'm new to Construct 2 but I hope I can help you with the Random Direction. I made a little example here: RandomDirection.capx
B
5
S
1
Posts: 7
Reputation: 556

Post » Tue Feb 18, 2014 5:57 pm

you can combine 1,2,3 in 1 loop


event:
for each enemy

sub:
distance(enemy.X,enemy.Y,player.X,playeer.Y) > 100
action:
enemy move at angle
angle: choose(0,90,180,270)
pixels: choose(50,100,200) * dt
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Thu Feb 20, 2014 1:31 pm

Thanks for the help. I'm at work now but I will definitely try this when I get home. Thanks again.
B
8
S
1
Posts: 39
Reputation: 685


Return to How do I....?

Who is online

Users browsing this forum: David181 and 29 guests