Skip to content

Instantly share code, notes, and snippets.

@lamarmarshall
Created March 5, 2025 15:50
Show Gist options
  • Save lamarmarshall/0fe0fe1b6aafea96f47193d4746448e5 to your computer and use it in GitHub Desktop.
Save lamarmarshall/0fe0fe1b6aafea96f47193d4746448e5 to your computer and use it in GitHub Desktop.
godot, move,between, to points, back and forth, up and down
extends Area2D
@export var move_direction: Vector2
@export var move_speed: float = 100
@onready var marker_2d: Marker2D = $Marker2D
@onready var start_position: Vector2 = global_position
@onready var target_position: Vector2 = marker_2d.global_position
func _physics_process(delta: float) -> void:
global_position = global_position.move_toward(target_position, move_speed * delta)
if global_position.y == target_position.y:
target_position.y = start_position.y
if global_position.y == start_position.y:
target_position.y = move_direction.y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment