enemy follow player
emoji
Member, BASIC Posts: 66
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.
Comments
@emoji
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
do:
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
update, in my player setting, how come this global variable xPos and yPos does not change when my player moving?
See above. Make sure you're using constrains.
Follow us: Twitter - Website
I got it working. thank you a lot.