27 lines
856 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
2024-12-31 23:31:28 -05:00
var controlling: bool = true
2024-12-18 16:35:26 -05:00
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
2024-12-31 23:31:28 -05:00
if (!City.moving || !City.controlling): 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