21 lines
593 B
GDScript
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
|