Moved player input
This commit is contained in:
@@ -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://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://bdv1fj1pwknrs" path="res://scripts/entities/player/PlayerInput.gd" id="4_yjynp"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_2m2ha"]
|
||||
|
||||
@@ -30,6 +31,11 @@ script = ExtResource("3_24gqh")
|
||||
interactableArea = NodePath("../../InteractableArea")
|
||||
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="."]
|
||||
shape = SubResource("CapsuleShape3D_2m2ha")
|
||||
|
||||
|
@@ -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="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
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
@@ -12,6 +13,12 @@ grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_son71")
|
||||
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")]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
|
52
scenes/ui/pause/PauseMain.tscn
Normal file
52
scenes/ui/pause/PauseMain.tscn
Normal 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%"
|
17
scenes/ui/pause/PauseMenu.tscn
Normal file
17
scenes/ui/pause/PauseMenu.tscn
Normal 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
|
13
scripts/entities/player/PlayerInput.gd
Normal file
13
scripts/entities/player/PlayerInput.gd
Normal 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()
|
1
scripts/entities/player/PlayerInput.gd.uid
Normal file
1
scripts/entities/player/PlayerInput.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bdv1fj1pwknrs
|
@@ -8,13 +8,10 @@ func canInteract() -> bool:
|
||||
return false
|
||||
return true
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
func interact() -> void:
|
||||
if !canInteract():
|
||||
return
|
||||
|
||||
if !Input.is_action_just_pressed("interact"):
|
||||
return
|
||||
|
||||
var overlapping = interactableArea.get_overlapping_areas()
|
||||
var interactable: InteractableArea = null
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
class_name PlayerMovement extends Node
|
||||
|
||||
const TURN_SPEED = 12.0
|
||||
const TURN_SPEED = 30.0
|
||||
const SPEED = 8.0
|
||||
|
||||
@export var player:CharacterBody3D
|
||||
var inputDir:Vector2 = Vector2.ZERO
|
||||
|
||||
func canMove() -> bool:
|
||||
if PAUSE.isMovementPaused():
|
||||
@@ -18,8 +19,6 @@ func _physics_process(delta:float) -> void:
|
||||
# Player movement
|
||||
var directionAdjusted = Vector3.ZERO
|
||||
if canMove():
|
||||
var inputDir = Input.get_vector("move_left", "move_right", "move_back", "move_forward").normalized()
|
||||
|
||||
# Use camera orientation for movement direction
|
||||
var cam_basis = cameraCurrent.global_transform.basis
|
||||
# Forward and right vectors, ignore vertical component
|
||||
|
@@ -8,9 +8,19 @@ func cutscenePause() -> void:
|
||||
func cutsceneResume() -> void:
|
||||
cutscenePaused = false
|
||||
|
||||
|
||||
func isMovementPaused() -> bool:
|
||||
if cutscenePaused:
|
||||
return true
|
||||
|
||||
if !UI.TEXTBOX.isClosed:
|
||||
return true
|
||||
|
||||
if UI.PAUSE.isOpen():
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
|
||||
func menuPause() -> void:
|
||||
UI.PAUSE.open()
|
@@ -1,3 +1,4 @@
|
||||
class_name UISingleton extends Control
|
||||
|
||||
@export var TEXTBOX: VNTextbox
|
||||
@export var PAUSE: PauseMenu
|
4
scripts/ui/pause/PauseMain.gd
Normal file
4
scripts/ui/pause/PauseMain.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
class_name PauseMain extends VBoxContainer
|
||||
|
||||
func _ready() -> void:
|
||||
visible = true
|
1
scripts/ui/pause/PauseMain.gd.uid
Normal file
1
scripts/ui/pause/PauseMain.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c7kvg0jw6w340
|
17
scripts/ui/pause/PauseMenu.gd
Normal file
17
scripts/ui/pause/PauseMenu.gd
Normal 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
|
1
scripts/ui/pause/PauseMenu.gd.uid
Normal file
1
scripts/ui/pause/PauseMenu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cgvf34t5qgwbm
|
Reference in New Issue
Block a user