Created
March 5, 2025 15:50
-
-
Save lamarmarshall/0fe0fe1b6aafea96f47193d4746448e5 to your computer and use it in GitHub Desktop.
godot, move,between, to points, back and forth, up and down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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