1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2025-02-16 17:13:58 +00:00
hella-farm/behaviours/move_towards_physics.gd

17 lines
407 B
GDScript

extends MoveTowards
class_name MoveTowardsGravity
# [field speed] is actually used as acceleration. Oh well.
var velocity := Vector2.ZERO
func _physics_process(delta: float) -> void:
if enabled:
if target:
var gap = target.global_position - global_position
var norm = gap.normalized()
velocity += norm * delta * speed
Log.p(self, "Velocity: %s" % velocity)
move.emit(velocity * delta)