Currently, I've been trying to use a KinematicBody2d to move towards a set location after spawning. I have no trouble moving the object. However, it's teleporting instead of moving over to the set location.
extends KinematicBody2D
const SPEED = 10
var vel = Vector2(640,360)
onready var target = get_node("/root/Node2D/Player")
func _ready():
var t = Timer.new()
t.set_wait_time(1)
t.set_one_shot(true)
self.add_child(t)
t.start()
yield(t, "timeout")
t.queue_free()
var velocity = (self.position - target.position).normalized()
# move_and_collide(velocity * SPEED)
move_and_collide(vel , true)
# move_and_slide(target.position * SPEED)
Am I using move_and_collide wrong? Or the wrong function? Or maybe even wrong node?
How should I set this up so I can get my object moving towards a location and not teleporting?