Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Nizil |
how can i write the movement of the mob towards the player? how can i write the movement of the mob towards the player? I’m new to development and I have no idea why the mob doesn’t move on startup.
extends KinematicBody2D
export var mob_speed = 400
var velocity = Vector2()
var target
func _ready():
var target = get_tree().current_scene.get_node("Player")
var velocity = (target.position - position).normalized * mob_speed
func _process(delta):
velocity = move_and_slide(velocity)