25 lines
805 B
GDScript3
Raw Normal View History

2024-12-18 16:35:26 -05:00
class_name Target extends Node3D
@export var moveSpeed: float = 100
@export_group("Movements Bounds")
@export var topBound: float
@export var bottomBound: float
@export var leftBound: float
@export var rightBound: float
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if (!City.moving): return
2024-12-18 16:35:26 -05:00
var horizontalMovement: float = Input.get_axis("right", "left")
var verticalMovement: float = Input.get_axis("down", "up")
position.x += horizontalMovement * moveSpeed * delta
position.y += verticalMovement * moveSpeed * delta
if (position.x < leftBound): position.x = leftBound
elif (position.x > rightBound): position.x = rightBound
if (position.y < bottomBound): position.y = bottomBound
elif (position.y > topBound): position.y = topBound