0 votes

Hi guys;

I have a default enemy follow code for my default enemy character that is:

extends KinematicBody2D

const MOVE_SPEED = 180
var ENEMY_1_LIFE = 100


onready var player = get_parent().get_node("player")

func _physics_process(delta):

    var vec_to_player = player.global_position - global_position
    vec_to_player = vec_to_player.normalized()
    global_rotation = atan2(vec_to_player.y, vec_to_player.x)
    move_and_collide(vec_to_player * MOVE_SPEED * delta)

I was thinking if it is possible to adapt this default code and make enemy follows player with a zig zag walk just changing some positions, or the best way is using some PathFollow2D.

Thanks guys.

PS: I'm learning how to format posts in the godot forum; if it's a bit confuse, please tell me to edit

in Engine by (170 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.