35 lines
891 B
GDScript3
35 lines
891 B
GDScript3
|
extends Area3D
|
||
|
|
||
|
|
||
|
@onready
|
||
|
var _dialog = $"../Kreb/WinDialog"
|
||
|
@onready
|
||
|
var _float_point = $FloatPoint
|
||
|
|
||
|
var _lockout = false
|
||
|
var _grabbed_monitor: RigidBody3D
|
||
|
|
||
|
|
||
|
func _on_body_entered(body: Node3D) -> void:
|
||
|
if not body.is_in_group('monitors') or _lockout:
|
||
|
return
|
||
|
|
||
|
_lockout = true
|
||
|
|
||
|
_dialog.play()
|
||
|
|
||
|
# TODO: Better way to get the player?
|
||
|
for player in get_tree().get_nodes_in_group("players"):
|
||
|
if player._held_object == body:
|
||
|
player.force_drop()
|
||
|
|
||
|
_grabbed_monitor = body
|
||
|
_grabbed_monitor.remove_from_group('can_hold')
|
||
|
|
||
|
|
||
|
func _physics_process(delta: float) -> void:
|
||
|
if _grabbed_monitor:
|
||
|
var delta_position = _float_point.global_position - _grabbed_monitor.global_position
|
||
|
var move_speed = min(delta_position.length() * 400, 1000)
|
||
|
_grabbed_monitor.linear_velocity = delta_position.normalized() * move_speed * delta
|