Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

enemy follow player

emojiemoji Posts: 46Member, BASIC

Hello, I'm trying to make my enemy follow my player but for some reason, the player just goes left and right. I have declared two variable of xPos and yPos and assign it to player position. attach is my enemy setting. It is supposed
to follow my player but it not. can someone please assist me. thank very much.


  • AlchimiaStudiosAlchimiaStudios Posts: 1,034Member, PRO
    edited July 2018


    Accelerate toward will ramp up the acceleration and only turn it down once the x and y are reached, but because the acceleration is still in effect it will go past it, then it retriggers and continues to do that, forever.

    It's better to do the following:

    rule when all the follow are happening:

    if attribute self.position.x != game.posX


    move to game.posX / game.posY

    Also make sure you are using constrains on the player actor so

    constrain game.posX to self.position.x

    constrain game.posY to self.position.y

    Follow us: Twitter - Website

  • emojiemoji Posts: 46Member, BASIC

    update, in my player setting, how come this global variable xPos and yPos does not change when my player moving?

  • AlchimiaStudiosAlchimiaStudios Posts: 1,034Member, PRO

    See above. Make sure you're using constrains.

    Follow us: Twitter - Website

  • emojiemoji Posts: 46Member, BASIC

    I got it working. thank you a lot.

Sign In or Register to comment.