Moved player input

This commit is contained in:
2025-07-01 15:50:08 -05:00
parent 3e95481282
commit 58126341ba
14 changed files with 138 additions and 12 deletions

View File

@@ -1,8 +1,9 @@
[gd_scene load_steps=9 format=3 uid="uid://2ch34sio36nv"] [gd_scene load_steps=10 format=3 uid="uid://2ch34sio36nv"]
[ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://scripts/entities/player/Player.gd" id="1_24gqh"] [ext_resource type="Script" uid="uid://ylmy3nvpirgr" path="res://scripts/entities/player/Player.gd" id="1_24gqh"]
[ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://scripts/entities/player/PlayerMovement.gd" id="2_o7et6"] [ext_resource type="Script" uid="uid://bwxdv3kxrs4oj" path="res://scripts/entities/player/PlayerMovement.gd" id="2_o7et6"]
[ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://scripts/entities/player/PlayerInteraction.gd" id="3_24gqh"] [ext_resource type="Script" uid="uid://b3nty7pvbo58d" path="res://scripts/entities/player/PlayerInteraction.gd" id="3_24gqh"]
[ext_resource type="Script" uid="uid://bdv1fj1pwknrs" path="res://scripts/entities/player/PlayerInput.gd" id="4_yjynp"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2m2ha"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2m2ha"]
@@ -30,6 +31,11 @@ script = ExtResource("3_24gqh")
interactableArea = NodePath("../../InteractableArea") interactableArea = NodePath("../../InteractableArea")
player = NodePath("../..") player = NodePath("../..")
[node name="PlayerInput" type="Node" parent="Scripts" node_paths=PackedStringArray("interaction", "movement")]
script = ExtResource("4_yjynp")
interaction = NodePath("../PlayerInteraction")
movement = NodePath("../PlayerMovement")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("CapsuleShape3D_2m2ha") shape = SubResource("CapsuleShape3D_2m2ha")

View File

@@ -1,9 +1,10 @@
[gd_scene load_steps=3 format=3 uid="uid://baos0arpiskbp"] [gd_scene load_steps=4 format=3 uid="uid://baos0arpiskbp"]
[ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/ui/VNTextbox.tscn" id="1_1mtk3"] [ext_resource type="PackedScene" uid="uid://bkx3l0kckf4a8" path="res://scenes/ui/VNTextbox.tscn" id="1_1mtk3"]
[ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://scripts/singletons/UI.gd" id="1_son71"] [ext_resource type="Script" uid="uid://dq3qyyayugt5l" path="res://scripts/singletons/UI.gd" id="1_son71"]
[ext_resource type="PackedScene" uid="uid://c0i5e2dj11d8c" path="res://scenes/ui/pause/PauseMenu.tscn" id="2_atyu8"]
[node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX")] [node name="UI" type="Control" node_paths=PackedStringArray("TEXTBOX", "PAUSE")]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
@@ -12,6 +13,12 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_son71") script = ExtResource("1_son71")
TEXTBOX = NodePath("VNTextbox") TEXTBOX = NodePath("VNTextbox")
PAUSE = NodePath("PauseMenu")
[node name="PauseMenu" parent="." instance=ExtResource("2_atyu8")]
visible = false
layout_mode = 1
[node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")] [node name="VNTextbox" parent="." instance=ExtResource("1_1mtk3")]
visible = false
layout_mode = 1 layout_mode = 1

View File

@@ -0,0 +1,52 @@
[gd_scene load_steps=2 format=3 uid="uid://bt0okj2rie8qf"]
[ext_resource type="Script" uid="uid://c7kvg0jw6w340" path="res://scripts/ui/pause/PauseMain.gd" id="1_b5xfl"]
[node name="PauseMain" type="VBoxContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_b5xfl")
metadata/_custom_type_script = "uid://c7kvg0jw6w340"
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2
size_flags_vertical = 3
[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
[node name="ItemList" type="ItemList" parent="HBoxContainer"]
layout_mode = 2
auto_width = true
item_count = 6
item_0/text = "Equpiment"
item_1/text = "Abilities"
item_2/text = "Items"
item_3/text = "Quests"
item_4/text = "Options"
item_5/text = "Save"
[node name="HBoxContainer2" type="HBoxContainer" parent="."]
layout_mode = 2
[node name="PanelContainer" type="PanelContainer" parent="HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
[node name="HBoxContainer" type="GridContainer" parent="HBoxContainer2/PanelContainer"]
layout_mode = 2
size_flags_horizontal = 8
theme_override_constants/h_separation = 8
columns = 2
[node name="Money" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"]
layout_mode = 2
text = "%MONEY%"
[node name="Playtime" type="Label" parent="HBoxContainer2/PanelContainer/HBoxContainer"]
layout_mode = 2
text = "%PLAYTIME%"

View File

@@ -0,0 +1,17 @@
[gd_scene load_steps=3 format=3 uid="uid://c0i5e2dj11d8c"]
[ext_resource type="PackedScene" uid="uid://bt0okj2rie8qf" path="res://scenes/ui/pause/PauseMain.tscn" id="1_33nyv"]
[ext_resource type="Script" uid="uid://cgvf34t5qgwbm" path="res://scripts/ui/pause/PauseMenu.gd" id="1_82qxy"]
[node name="PauseMenu" type="Control" node_paths=PackedStringArray("MAIN")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_82qxy")
MAIN = NodePath("PauseMain")
[node name="PauseMain" parent="." instance=ExtResource("1_33nyv")]
layout_mode = 1

View File

@@ -0,0 +1,13 @@
class_name PlayerInput extends Node
@export var interaction:PlayerInteraction
@export var movement:PlayerMovement
func _process(delta: float) -> void:
if Input.is_action_just_pressed("pause"):
PAUSE.menuPause()
if Input.is_action_just_pressed("interact"):
interaction.interact()
movement.inputDir = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized()

View File

@@ -0,0 +1 @@
uid://bdv1fj1pwknrs

View File

@@ -8,13 +8,10 @@ func canInteract() -> bool:
return false return false
return true return true
func _process(delta: float) -> void: func interact() -> void:
if !canInteract(): if !canInteract():
return return
if !Input.is_action_just_pressed("interact"):
return
var overlapping = interactableArea.get_overlapping_areas() var overlapping = interactableArea.get_overlapping_areas()
var interactable: InteractableArea = null var interactable: InteractableArea = null

View File

@@ -1,9 +1,10 @@
class_name PlayerMovement extends Node class_name PlayerMovement extends Node
const TURN_SPEED = 12.0 const TURN_SPEED = 30.0
const SPEED = 8.0 const SPEED = 8.0
@export var player:CharacterBody3D @export var player:CharacterBody3D
var inputDir:Vector2 = Vector2.ZERO
func canMove() -> bool: func canMove() -> bool:
if PAUSE.isMovementPaused(): if PAUSE.isMovementPaused():
@@ -18,8 +19,6 @@ func _physics_process(delta:float) -> void:
# Player movement # Player movement
var directionAdjusted = Vector3.ZERO var directionAdjusted = Vector3.ZERO
if canMove(): if canMove():
var inputDir = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized()
# Use camera orientation for movement direction # Use camera orientation for movement direction
var cam_basis = cameraCurrent.global_transform.basis var cam_basis = cameraCurrent.global_transform.basis
# Forward and right vectors, ignore vertical component # Forward and right vectors, ignore vertical component

View File

@@ -8,9 +8,19 @@ func cutscenePause() -> void:
func cutsceneResume() -> void: func cutsceneResume() -> void:
cutscenePaused = false cutscenePaused = false
func isMovementPaused() -> bool: func isMovementPaused() -> bool:
if cutscenePaused: if cutscenePaused:
return true return true
if !UI.TEXTBOX.isClosed: if !UI.TEXTBOX.isClosed:
return true return true
return false
if UI.PAUSE.isOpen():
return true
return false
func menuPause() -> void:
UI.PAUSE.open()

View File

@@ -1,3 +1,4 @@
class_name UISingleton extends Control class_name UISingleton extends Control
@export var TEXTBOX: VNTextbox @export var TEXTBOX: VNTextbox
@export var PAUSE: PauseMenu

View File

@@ -0,0 +1,4 @@
class_name PauseMain extends VBoxContainer
func _ready() -> void:
visible = true

View File

@@ -0,0 +1 @@
uid://c7kvg0jw6w340

View File

@@ -0,0 +1,17 @@
class_name PauseMenu extends Control
@export var MAIN:PauseMain
func _ready() -> void:
hide()
func isOpen() -> bool:
return visible
func open() -> void:
visible = true
MAIN.visible = true
func close() -> void:
visible = false
MAIN.visible = false

View File

@@ -0,0 +1 @@
uid://cgvf34t5qgwbm