0 Favourites

Enemy AI(Regular Movement, Pursue, Attack)

  • 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.

  • 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

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Thanks for the help. I'm at work now but I will definitely try this when I get home. Thanks again.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
233 22,271
TiAm's avatar
TiAm
Unread hot topic
0 Favourites
Path Movement Behavior
98 52,483
R0J0hound's avatar
R0J0hound
Unread hot topic
49 6,121
sekocit's avatar
sekocit