Files
mobile-run-garbo-game/scripts/control_box.gd
2025-07-05 13:32:33 +01:00

21 lines
593 B
GDScript

extends MeshInstance3D
var movingTowards: Vector3
var currentLocation: Vector3
func _ready() -> void:
GameEngine.getGE().controlBox = self
currentLocation = self.position
movingTowards = currentLocation
func _process(delta: float) -> void:
var currentMousePos = GameEngine.getGE().mainCamera.getMouseRayCast();
if currentMousePos != Vector3.INF && currentMousePos != movingTowards:
movingTowards.x = currentMousePos.x
self.position = self.position.move_toward(movingTowards, GameEngine.getGE().getGameSpeed(delta))
func getMoveToLocation() -> Vector3:
return self.position