420 lines
15 KiB
GDScript3
420 lines
15 KiB
GDScript3
|
|
extends CharacterBody3D
|
||
|
|
class_name PlayerCharacter
|
||
|
|
|
||
|
|
@export_category("Movement")
|
||
|
|
@export var SPEED = 5.0 ##base walking speed
|
||
|
|
@export var SPRINT_MULTIPLIER = 1.5 ##how much faster should you move, when sprinting
|
||
|
|
@export var SPRINT_STAMINA_COST = 10.0 ##how much stamina should be consumed each frame while sprinting (delta * SPRINT_STAMINA_COST)
|
||
|
|
@export var CROUCH_SPEED_MULTIPLIER = .5 ##how much slower you should be going while crouching
|
||
|
|
|
||
|
|
@export_category("Jump")
|
||
|
|
@export var JUMP_VELOCITY = 4.5 ##how high you can jump
|
||
|
|
@export var JUMP_STAMINA_COST = 10 ##how much stamina each jump consumes
|
||
|
|
|
||
|
|
@export_category("Camera")
|
||
|
|
@export var LOOK_SENSITIVITY = 1.0 ##camera sensitivity
|
||
|
|
@export var CAMERA_VELOCITY_MULTIPLIER = 1.5 ##how heavy should the UI movement feel
|
||
|
|
@export var CAMERA_BOB_FREQUENCY = 2.4 ##how quick the camera bobs whilst moving
|
||
|
|
@export var CAMERA_BOB_AMPLITUDE = 0.08 ##how hard the camera bobs whilst moving
|
||
|
|
@export var CAMERA_BOB_MULTIPLIER = 200.0 ##how much the ui reacts to head bobbing
|
||
|
|
@export var CAMERA_SIDEWAYS_BOB_AMPLITUDE = 0.003 ## how many degrees does the camera bob sideways
|
||
|
|
|
||
|
|
@export_category("UI")
|
||
|
|
@export var UI_SCALE: float = 1 ##rational scale of the ui
|
||
|
|
@export var UI_MOVEMENT_SENSITIVITY = 0.5 ##how much the UI moves when you move the camera
|
||
|
|
@export var UI_MOVEMENT_SPEED = 15.0 ##how fast the UI moves when you move the camera
|
||
|
|
@export var UI_MOVEMENT_VELOCITY_MULTIPLIER = 2.0 ##how much the ui leans when walking or strafing
|
||
|
|
|
||
|
|
@export_category("Inventory")
|
||
|
|
@export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory
|
||
|
|
@export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory
|
||
|
|
|
||
|
|
@export_category("Audio")
|
||
|
|
@export var AUDIO_LOUDNESS: float = 100.0
|
||
|
|
@export var NORMAL_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##normal footsteps -- walking
|
||
|
|
@export var HEAVY_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##heavy footsteps -- running
|
||
|
|
@export var LIGHT_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##light footsteps -- crouching
|
||
|
|
@export var SHUFFLE_FOOTSTEP_SOUNDS: Array[AudioStreamWAV] ##shuffling -- random chance of playing while running
|
||
|
|
@export var FLASHLIGHT_CLICK_SOUNDS: Array[AudioStreamWAV] ##flashlight click
|
||
|
|
@export var SHUFFLE_CHANCE: float = 20 ##percentage of chance for a shuffle noise to be played whilst running
|
||
|
|
|
||
|
|
@export_category("Grabbing")
|
||
|
|
@export var GRAB_POWER: float = 15.0 ##how fast the grabbed object snaps to the hold position
|
||
|
|
@export var GRAB_ROTATION_POWER: float = 15.0 ##how fast the object rotates towards the player
|
||
|
|
@export var GRAB_PANEL: PackedScene ##panel that goes over the grabbable object to show its grabbable
|
||
|
|
|
||
|
|
@export_category("Player Physics")
|
||
|
|
@export_flags_3d_physics var PLAYER_COLLISION_MASK: int = 16
|
||
|
|
|
||
|
|
@onready var camera = $CameraPivot/PlayerCamera
|
||
|
|
@onready var camera_pivot = $CameraPivot
|
||
|
|
@onready var ui = $PlayerUi
|
||
|
|
@onready var ui_base_position = ui.position
|
||
|
|
@onready var in_game_menu = $InGameMenu
|
||
|
|
@onready var left_foot_sound_player = $SoundEmitters/LeftFoot
|
||
|
|
@onready var left_foot_texture_sound_player = $SoundEmitters/LeftFoot/LeftFootTexture
|
||
|
|
@onready var right_foot_sound_player = $SoundEmitters/RightFoot
|
||
|
|
@onready var right_foot_texture_sound_player = $SoundEmitters/RightFoot/RightFootTexture
|
||
|
|
@onready var flashlight_sound_player = $SoundEmitters/FlashlightSound
|
||
|
|
@onready var cursor_raycast = $CameraPivot/PlayerCamera/CursorRaycast
|
||
|
|
@onready var hold_position = $CameraPivot/PlayerCamera/HoldPosition
|
||
|
|
@onready var popup_panels = $PopupPanels
|
||
|
|
|
||
|
|
var walking: bool = false
|
||
|
|
var running: bool = false
|
||
|
|
var crouching: bool = false
|
||
|
|
var in_menu: bool = false
|
||
|
|
var stamina: float = 100.0
|
||
|
|
var stamina_recharge_on: bool = false
|
||
|
|
var selected_item: int = 0
|
||
|
|
var t_bob: float = 0
|
||
|
|
var last_bob_y: float = 0.0
|
||
|
|
var held_object: RigidBody3D = null
|
||
|
|
|
||
|
|
var _mouse_motion: Vector2 = Vector2.ZERO
|
||
|
|
var _mouse_motion_delta: Vector2 = Vector2.ZERO
|
||
|
|
var _last_camera_global_position: Vector3 = Vector3.ZERO
|
||
|
|
var _current_leg_is_right: bool = false ##if true: current leg is the right leg
|
||
|
|
var _current_footstep_sound: AudioStreamWAV = null
|
||
|
|
var _current_flashlight_sound: AudioStreamWAV = null
|
||
|
|
var _camera_original_position: Vector3 = Vector3(0,.75,0)
|
||
|
|
|
||
|
|
func play_footstep_sound():
|
||
|
|
var sound_to_play
|
||
|
|
if walking:
|
||
|
|
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
while sound_to_play == _current_footstep_sound:
|
||
|
|
sound_to_play = NORMAL_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
elif running:
|
||
|
|
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
while sound_to_play == _current_footstep_sound:
|
||
|
|
sound_to_play = HEAVY_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
if randf_range(1, 100) > 100 - SHUFFLE_CHANCE:
|
||
|
|
match _current_leg_is_right:
|
||
|
|
true:
|
||
|
|
right_foot_texture_sound_player.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
||
|
|
right_foot_texture_sound_player.do_play()
|
||
|
|
false:
|
||
|
|
left_foot_texture_sound_player.do_set_stream(SHUFFLE_FOOTSTEP_SOUNDS.pick_random())
|
||
|
|
left_foot_texture_sound_player.do_play()
|
||
|
|
|
||
|
|
elif crouching:
|
||
|
|
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
while sound_to_play == _current_footstep_sound:
|
||
|
|
sound_to_play = LIGHT_FOOTSTEP_SOUNDS.pick_random()
|
||
|
|
|
||
|
|
_current_footstep_sound = sound_to_play
|
||
|
|
|
||
|
|
if _current_leg_is_right:
|
||
|
|
right_foot_sound_player.do_set_stream(sound_to_play)
|
||
|
|
right_foot_sound_player.pitch_scale = randf_range(0.8, 1.2)
|
||
|
|
right_foot_sound_player.do_play()
|
||
|
|
_current_leg_is_right = false
|
||
|
|
else:
|
||
|
|
left_foot_sound_player.do_set_stream(sound_to_play)
|
||
|
|
left_foot_sound_player.pitch_scale = randf_range(0.8, 1.2)
|
||
|
|
left_foot_sound_player.do_play()
|
||
|
|
_current_leg_is_right = true
|
||
|
|
|
||
|
|
func ui_handling(delta):
|
||
|
|
ui.offset_transform_scale *= UI_SCALE
|
||
|
|
ui_movement_handling(delta)
|
||
|
|
ui.set_stamina_bar(stamina)
|
||
|
|
var horizontal_speed = Vector3(velocity.x, velocity.y, velocity.z).length()
|
||
|
|
|
||
|
|
if is_on_floor() and horizontal_speed > 0.05:
|
||
|
|
t_bob += delta * (velocity.length() * float(is_on_floor()) + (int(Input.is_action_pressed("crouch"))) * 3)
|
||
|
|
|
||
|
|
var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY)
|
||
|
|
|
||
|
|
#footstep handling
|
||
|
|
if last_bob_y >= -.95 and current_sin_pos < -.95:
|
||
|
|
play_footstep_sound()
|
||
|
|
|
||
|
|
last_bob_y = current_sin_pos
|
||
|
|
|
||
|
|
camera_bobbing(t_bob)
|
||
|
|
|
||
|
|
#idle breathing
|
||
|
|
elif is_on_floor() and horizontal_speed < 0.05:
|
||
|
|
t_bob += delta * 1
|
||
|
|
camera_breathing(t_bob)
|
||
|
|
else:
|
||
|
|
camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004)
|
||
|
|
camera.transform.origin.y = lerpf(camera.transform.origin.y, _camera_original_position.y, delta * 5.0)
|
||
|
|
if camera.transform.origin.length() < 0.01:
|
||
|
|
t_bob = 0
|
||
|
|
last_bob_y = 0.0
|
||
|
|
|
||
|
|
func ui_movement_handling(delta: float):
|
||
|
|
var mouse_offset = -_mouse_motion_delta * UI_MOVEMENT_SENSITIVITY
|
||
|
|
|
||
|
|
var current_camera_global_position = camera.global_position
|
||
|
|
var camera_global_velocity = (current_camera_global_position - _last_camera_global_position) / delta
|
||
|
|
|
||
|
|
var cam_local_vel = camera.global_transform.basis.inverse() * camera_global_velocity
|
||
|
|
|
||
|
|
var inertia_offset = Vector2(
|
||
|
|
-cam_local_vel.x,
|
||
|
|
cam_local_vel.y - (cam_local_vel.z * 0.25)
|
||
|
|
) * CAMERA_VELOCITY_MULTIPLIER
|
||
|
|
|
||
|
|
var target_offset = mouse_offset + inertia_offset
|
||
|
|
ui.position = ui.position.lerp(ui_base_position + target_offset, delta * UI_MOVEMENT_SPEED)
|
||
|
|
|
||
|
|
_last_camera_global_position = current_camera_global_position
|
||
|
|
|
||
|
|
var ui_scaling_target = Vector2(-cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1, -cam_local_vel.z * UI_MOVEMENT_SENSITIVITY * .002 + 1)
|
||
|
|
ui.offset_transform_scale = ui.offset_transform_scale.lerp(ui_scaling_target, delta * UI_MOVEMENT_SPEED)
|
||
|
|
|
||
|
|
var ui_rotation_target = -inertia_offset.x - mouse_offset.x * 0.25
|
||
|
|
ui.offset_transform_rotation = lerpf(ui.offset_transform_rotation, ui_rotation_target * UI_MOVEMENT_SENSITIVITY * 0.003, delta * UI_MOVEMENT_SPEED)
|
||
|
|
|
||
|
|
func toggle_menu():
|
||
|
|
if !in_game_menu.visible:
|
||
|
|
ui.visible = false
|
||
|
|
popup_panels.visible = false
|
||
|
|
in_game_menu.visible = true
|
||
|
|
$Cursor.visible = false
|
||
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||
|
|
in_menu = true
|
||
|
|
else:
|
||
|
|
ui.visible = true
|
||
|
|
popup_panels.visible = true
|
||
|
|
in_game_menu.visible = false
|
||
|
|
$Cursor.visible = true
|
||
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||
|
|
in_menu = false
|
||
|
|
|
||
|
|
func toggle_flashlight():
|
||
|
|
$CameraPivot/PlayerCamera/Flashlight.visible = not $CameraPivot/PlayerCamera/Flashlight.visible
|
||
|
|
var play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||
|
|
|
||
|
|
while play_sound == _current_flashlight_sound:
|
||
|
|
play_sound = FLASHLIGHT_CLICK_SOUNDS.pick_random()
|
||
|
|
|
||
|
|
flashlight_sound_player.do_set_stream(play_sound)
|
||
|
|
flashlight_sound_player.pitch_scale = randf_range(.8, 1.2)
|
||
|
|
flashlight_sound_player.do_play()
|
||
|
|
_current_flashlight_sound = play_sound
|
||
|
|
|
||
|
|
func camera_bobbing(time: float):
|
||
|
|
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
||
|
|
camera.rotation.z += sin(time * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
||
|
|
|
||
|
|
func camera_breathing(time: float):
|
||
|
|
camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75
|
||
|
|
camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE
|
||
|
|
|
||
|
|
func _process(delta: float) -> void:
|
||
|
|
if Input.is_action_just_pressed("next_item"):
|
||
|
|
next_item()
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("prev_item"):
|
||
|
|
prev_item()
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("select_item_1"):
|
||
|
|
select_item(0)
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("select_item_2"):
|
||
|
|
select_item(1)
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("select_item_3"):
|
||
|
|
select_item(2)
|
||
|
|
|
||
|
|
if stamina_recharge_on:
|
||
|
|
stamina = move_toward(stamina, 100, .5)
|
||
|
|
|
||
|
|
_mouse_motion.y = clamp(_mouse_motion.y, -1560, 1560)
|
||
|
|
transform.basis = Basis.from_euler(Vector3(0, _mouse_motion.x * -0.001 * LOOK_SENSITIVITY, 0))
|
||
|
|
camera.transform.basis = lerp(camera.transform.basis, Basis.from_euler(Vector3(_mouse_motion.y * -0.001 * LOOK_SENSITIVITY, 0, 0)), delta * 10)
|
||
|
|
|
||
|
|
#handle grabbable panel
|
||
|
|
if grabbable_panel != null:
|
||
|
|
var target_position = $Cursor.position - camera.unproject_position(grabbable_panel_body.global_position)
|
||
|
|
grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50)
|
||
|
|
|
||
|
|
func _init() -> void:
|
||
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||
|
|
|
||
|
|
func _ready() -> void:
|
||
|
|
ui.select_item(0)
|
||
|
|
_last_camera_global_position = camera.global_position
|
||
|
|
|
||
|
|
func next_item():
|
||
|
|
if selected_item + 1 > INVENTORY_MAX - 1:
|
||
|
|
selected_item = 0
|
||
|
|
else:
|
||
|
|
selected_item += 1
|
||
|
|
ui.select_item(selected_item)
|
||
|
|
|
||
|
|
func prev_item():
|
||
|
|
if selected_item - 1 < 0:
|
||
|
|
selected_item = INVENTORY_MAX - 1
|
||
|
|
else:
|
||
|
|
selected_item -= 1
|
||
|
|
ui.select_item(selected_item)
|
||
|
|
|
||
|
|
func select_item(index: int):
|
||
|
|
selected_item = index
|
||
|
|
ui.select_item(index)
|
||
|
|
|
||
|
|
func _input(event):
|
||
|
|
if Input.is_action_just_pressed("open_menu"):
|
||
|
|
toggle_menu()
|
||
|
|
|
||
|
|
if not in_menu:
|
||
|
|
if event is InputEventMouseMotion:
|
||
|
|
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||
|
|
_mouse_motion += event.relative
|
||
|
|
_mouse_motion_delta = event.relative
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("flashlight"):
|
||
|
|
toggle_flashlight()
|
||
|
|
|
||
|
|
if Input.is_action_just_released("jump") or Input.is_action_just_released("sprint"):
|
||
|
|
$StaminaReset.start()
|
||
|
|
|
||
|
|
if Input.is_action_just_pressed("grab"):
|
||
|
|
if cursor_raycast.is_colliding():
|
||
|
|
var hit_object = cursor_raycast.get_collider()
|
||
|
|
|
||
|
|
if hit_object is RigidBody3D and hit_object.is_in_group("grabbable"):
|
||
|
|
held_object = hit_object
|
||
|
|
held_object.gravity_scale = 0.0
|
||
|
|
held_object.angular_damp = 5.0
|
||
|
|
popup_panels.visible = false
|
||
|
|
|
||
|
|
if Input.is_action_just_released("grab") and held_object != null:
|
||
|
|
held_object.gravity_scale = 1.0
|
||
|
|
held_object.angular_damp = 0.0
|
||
|
|
held_object = null
|
||
|
|
popup_panels.visible = true
|
||
|
|
|
||
|
|
func is_crouched(yes:bool):
|
||
|
|
if yes:
|
||
|
|
crouching = true
|
||
|
|
walking = false
|
||
|
|
running = false
|
||
|
|
else:
|
||
|
|
crouching = false
|
||
|
|
|
||
|
|
func is_walking(yes:bool):
|
||
|
|
if yes:
|
||
|
|
crouching = false
|
||
|
|
walking = true
|
||
|
|
running = false
|
||
|
|
else:
|
||
|
|
walking = false
|
||
|
|
|
||
|
|
func is_running(yes:bool):
|
||
|
|
if yes:
|
||
|
|
crouching = false
|
||
|
|
walking = false
|
||
|
|
running = true
|
||
|
|
else:
|
||
|
|
running = false
|
||
|
|
|
||
|
|
|
||
|
|
func _physics_process(delta: float) -> void:
|
||
|
|
if not is_on_floor():
|
||
|
|
velocity += get_gravity() * delta
|
||
|
|
|
||
|
|
if not in_menu:
|
||
|
|
if Input.is_action_just_pressed("jump") and is_on_floor() and stamina > JUMP_STAMINA_COST:
|
||
|
|
velocity.y = JUMP_VELOCITY
|
||
|
|
stamina -= JUMP_STAMINA_COST
|
||
|
|
stamina_recharge_on = false
|
||
|
|
|
||
|
|
var input_dir = Input.get_vector("left", "right", "forward", "backward")
|
||
|
|
#var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||
|
|
var lean_dir = -Input.get_axis("lean_left", "lean_right") * .1
|
||
|
|
|
||
|
|
if lean_dir:
|
||
|
|
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, lean_dir, delta*10)
|
||
|
|
camera_pivot.position.x = lerpf(camera_pivot.position.x, -lean_dir * 5, delta * 7)
|
||
|
|
else:
|
||
|
|
camera_pivot.rotation.z = lerpf(camera_pivot.rotation.z, 0, delta*10)
|
||
|
|
camera_pivot.position.x = lerpf(camera_pivot.position.x, 0, delta * 7)
|
||
|
|
|
||
|
|
var target_speed = SPEED
|
||
|
|
var is_moving = input_dir != Vector2.ZERO
|
||
|
|
|
||
|
|
if Input.is_action_pressed("crouch"):
|
||
|
|
$PlayerHitBox.shape.height = lerpf($PlayerHitBox.shape.height, .5, delta * 5)
|
||
|
|
target_speed *= CROUCH_SPEED_MULTIPLIER
|
||
|
|
is_crouched(true)
|
||
|
|
else:
|
||
|
|
$PlayerHitBox.shape.height = lerpf($PlayerHitBox.shape.height, 2, delta * 10)
|
||
|
|
is_crouched(false)
|
||
|
|
|
||
|
|
if Input.is_action_pressed("sprint") and stamina > 0:
|
||
|
|
target_speed *= SPRINT_MULTIPLIER
|
||
|
|
is_running(true)
|
||
|
|
stamina -= delta * SPRINT_STAMINA_COST
|
||
|
|
stamina_recharge_on = false
|
||
|
|
else:
|
||
|
|
is_running(false)
|
||
|
|
|
||
|
|
|
||
|
|
#apply motion
|
||
|
|
var local_vel = transform.basis.inverse() * velocity
|
||
|
|
var target_local_vel = Vector3(input_dir.x, 0, input_dir.y) * target_speed
|
||
|
|
var accel_rate = 6.0 if is_moving else 9.0
|
||
|
|
local_vel.x = lerpf(local_vel.x, target_local_vel.x, delta * accel_rate)
|
||
|
|
local_vel.z = lerpf(local_vel.z, target_local_vel.z, delta * accel_rate)
|
||
|
|
|
||
|
|
var global_horizontal = transform.basis * local_vel
|
||
|
|
velocity.x = global_horizontal.x
|
||
|
|
velocity.z = global_horizontal.z
|
||
|
|
|
||
|
|
if is_moving and not running and not crouching:
|
||
|
|
is_walking(true)
|
||
|
|
else:
|
||
|
|
is_walking(false)
|
||
|
|
|
||
|
|
ui_handling(delta)
|
||
|
|
|
||
|
|
#handle grabbed object
|
||
|
|
if held_object != null:
|
||
|
|
var target_pos = hold_position.global_position
|
||
|
|
var current_pos = held_object.global_position
|
||
|
|
var direction = target_pos - current_pos
|
||
|
|
|
||
|
|
held_object.linear_velocity = direction * GRAB_POWER
|
||
|
|
|
||
|
|
var current_quat = held_object.global_transform.basis.get_rotation_quaternion()
|
||
|
|
var target_quat = hold_position.global_transform.basis.get_rotation_quaternion()
|
||
|
|
|
||
|
|
var delta_quat = target_quat * current_quat.inverse()
|
||
|
|
var angle = delta_quat.get_angle()
|
||
|
|
var axis = delta_quat.get_axis()
|
||
|
|
|
||
|
|
if angle > PI:
|
||
|
|
angle -= TAU
|
||
|
|
|
||
|
|
held_object.angular_velocity = axis * angle * GRAB_ROTATION_POWER
|
||
|
|
else:
|
||
|
|
velocity.x = lerpf(velocity.x, 0, delta * 10)
|
||
|
|
velocity.z = lerpf(velocity.z, 0, delta * 10)
|
||
|
|
|
||
|
|
move_and_slide()
|
||
|
|
|
||
|
|
func _on_stamina_reset_timeout() -> void:
|
||
|
|
stamina_recharge_on = true
|
||
|
|
|
||
|
|
var grabbable_panel = null
|
||
|
|
var grabbable_panel_body = null
|
||
|
|
|
||
|
|
func _on_grabbable_finder_body_entered(body: Node3D) -> void:
|
||
|
|
if body.is_in_group("grabbable"):
|
||
|
|
grabbable_panel = GRAB_PANEL.instantiate()
|
||
|
|
popup_panels.add_child(grabbable_panel)
|
||
|
|
grabbable_panel_body = body
|
||
|
|
|
||
|
|
func _on_grabbable_finder_body_exited(body: Node3D) -> void:
|
||
|
|
if body == grabbable_panel_body:
|
||
|
|
popup_panels.remove_child(grabbable_panel)
|
||
|
|
grabbable_panel = null
|
||
|
|
grabbable_panel_body = null
|