Follow enemy only when player is nearby (Solved)

Hi!

Curently working on a side scroller and I was following this game from flowlab themselves as they do have a follow enemy example video, but I believe its outdated due to the proximity trigger not existing anymore, thus making the code wonky.

^^ link to the game I was copying the code off of

I copied what they did and made small adjustments that wouldn’t affect the larger picture, and the enemy would start following but then would get stuck once it collided with a block. I’ve looked at other forum posts and they all detail follow behavior but behavior that starts right away with no trigger of the player being nearby.

^^ Link to the game where I test the mechanics out, all the code is on the blue slime

Is there anyway to make this outdated code work or perhaps change the behaviors of the other follow and try to implement it so it doesn’t trigger right away but only when player is nearby.

Thanks for the help so far! :slight_smile:

Try using raycasts that helps

Use two raycasts for each direction a raycast one the left and right then put the raycast put into the player so if the play hits the raycast in the left the enemy moves on the left its really easy

Also, change the impulse for the jump on the down of the up key. Makes it more fluid.

I haven’t been on here in forever but thanks! My jump was a little wonky but I had no idea how to fix it. It looks much better now. I also solved the follow enemy problem I just forgot to set the global variable for the character’s x position. :sweat_smile: