gd: fixed look inputs

This commit is contained in:
2025-05-29 09:49:56 +02:00
parent 5104144ba3
commit c3e2c974ca
21 changed files with 348 additions and 558 deletions

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://boasm0g587eov"
path.s3tc="res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Dark/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.s3tc.ctex", "res://.godot/imported/texture_01.png-9deee4bf2e81814eb5c9325f2657f8c8.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://3e1klega6uye"
path.s3tc="res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Green/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.s3tc.ctex", "res://.godot/imported/texture_01.png-ae5afc2ae737d1e792f0b8a0a5af4d3f.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://0t6ie0fkv2op"
path.s3tc="res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Light/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.s3tc.ctex", "res://.godot/imported/texture_01.png-1dcf4b27bd12b1fd18e6c870b30bb902.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://t10lfkxrg7ay"
path.s3tc="res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Orange/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.s3tc.ctex", "res://.godot/imported/texture_01.png-2d26b48d2dec4e4e9eea4b1c047417c0.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://dgix86l87u86s"
path.s3tc="res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.s3tc.ctex"
path.etc2="res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/GridTexture/Red/texture_01.png"
dest_files=["res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"]
dest_files=["res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.s3tc.ctex", "res://.godot/imported/texture_01.png-a7949be0e945f82b88e838fe48a6f350.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://woq2hudxhckr"
path.s3tc="res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.s3tc.ctex"
path.etc2="res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Assets/Textures/PerlinNoise/Gabor 1 - 512x512.png"
dest_files=["res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"]
dest_files=["res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.s3tc.ctex", "res://.godot/imported/Gabor 1 - 512x512.png-35241d8f4670c338b8c89a271f5b5891.etc2.ctex"]
[params]

View File

@ -3,16 +3,17 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://lp2pt8mtj7ty"
path.s3tc="res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.s3tc.ctex"
path.etc2="res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"
metadata={
"imported_formats": ["etc2_astc"],
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://player_controller/Examples/MovementTestbed/Hills/kenney-green-checkerboar-cc0.png"
dest_files=["res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"]
dest_files=["res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.s3tc.ctex", "res://.godot/imported/kenney-green-checkerboar-cc0.png-2ce8609a39a655125c8e037014f6f2db.etc2.ctex"]
[params]

View File

@ -1,9 +1,7 @@
[gd_scene load_steps=34 format=3 uid="uid://bei4nhkf8lwdo"]
[gd_scene load_steps=26 format=3 uid="uid://bei4nhkf8lwdo"]
[ext_resource type="Script" uid="uid://bbbrf5ckydfna" path="res://player_controller/Scripts/PlayerController.cs" id="1_poq2x"]
[ext_resource type="Material" uid="uid://dtq8i1ka1f2pn" path="res://player_controller/Assets/Materials/Health/CameraVignette.tres" id="2_6hee7"]
[ext_resource type="Material" uid="uid://nyh5tn1yoxeu" path="res://player_controller/Assets/Materials/Health/CameraDistortion.tres" id="3_mxh1y"]
[ext_resource type="Shader" uid="uid://btw6vsb6sa7sn" path="res://player_controller/Shaders/Blur.gdshader" id="4_jyscr"]
[ext_resource type="Resource" uid="uid://bl5crtu1gkrtr" path="res://systems/inputs/walk_mode/base_mode.tres" id="3_cresl"]
[ext_resource type="Resource" uid="uid://cpdaw41ah5gic" path="res://systems/inputs/walk_mode/rotate_y.tres" id="4_rxwoh"]
[ext_resource type="Resource" uid="uid://ccrb5xsnphc8" path="res://systems/inputs/walk_mode/rotate_floorplane.tres" id="5_4u7i3"]
[ext_resource type="Script" uid="uid://dv7v1ywmbvvcd" path="res://player_controller/Scripts/HealthSystem.cs" id="5_umw0l"]
@ -12,117 +10,27 @@
[ext_resource type="Resource" uid="uid://dgfww8118d8gj" path="res://systems/inputs/walk_mode/aim.tres" id="7_cresl"]
[ext_resource type="Resource" uid="uid://j1o5ud0plk4" path="res://systems/inputs/walk_mode/aim_release.tres" id="8_lhb11"]
[ext_resource type="Script" uid="uid://dd1yrt7eiiyf4" path="res://player_controller/Scripts/CapsuleCollider.cs" id="8_lmtjd"]
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle_system.tscn" id="8_qu4wy"]
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://systems/mantle/mantle_system.tscn" id="8_qu4wy"]
[ext_resource type="Resource" uid="uid://7wm8ywvujwf" path="res://systems/inputs/walk_mode/aim_cancel.tres" id="9_5p2qc"]
[ext_resource type="Script" uid="uid://bt0xv2q8iv1vn" path="res://player_controller/Scripts/Gravity.cs" id="9_lsueh"]
[ext_resource type="Script" uid="uid://dwoppk8j5fxeg" path="res://player_controller/Scripts/DashSystem.cs" id="9_qu4wy"]
[ext_resource type="Script" uid="uid://g8idirw62qe0" path="res://player_controller/Scripts/Bobbing.cs" id="10_7wk1w"]
[ext_resource type="Script" uid="uid://c6bx47wr7fbdm" path="res://player_controller/Scripts/Mouse.cs" id="11_huhen"]
[ext_resource type="PackedScene" uid="uid://0ysqmqphq6mq" path="res://systems/head/head_system.tscn" id="11_rxwoh"]
[ext_resource type="Script" uid="uid://b6k73aj5povgv" path="res://player_controller/Scripts/FieldOfView.cs" id="12_m2mxi"]
[ext_resource type="Script" uid="uid://bt8flen3mi28r" path="res://player_controller/Scripts/AnimationPlayer.cs" id="13_vnh4e"]
[ext_resource type="Script" uid="uid://b5nk6ntlps3x0" path="res://systems/inputs/input_system.gd" id="16_v31n3"]
[ext_resource type="Resource" uid="uid://htqvokm8mufq" path="res://systems/inputs/walk_mode/move.tres" id="17_h6vvl"]
[ext_resource type="Resource" uid="uid://dijkqkltwkrfe" path="res://systems/inputs/walk_mode/walk_mode.tres" id="18_sik0q"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_xc2g5"]
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_wydro"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_o1np4"]
shader = ExtResource("4_jyscr")
shader_parameter/limit = 0.0
shader_parameter/blur = 0.0
[sub_resource type="SphereShape3D" id="SphereShape3D_qu4wy"]
[sub_resource type="SphereMesh" id="SphereMesh_qu4wy"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v31n3"]
[sub_resource type="Animation" id="Animation_vcu7l"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Head:rotation:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Head:rotation:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Head:rotation:z")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
[sub_resource type="Animation" id="Animation_tsmqm"]
resource_name = "player_head_on_dying1"
[sub_resource type="Animation" id="Animation_6iwn4"]
resource_name = "players_head_on_dying"
length = 8.0
step = 5.0
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = false
tracks/0/path = NodePath("Head:rotation:x")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = false
tracks/1/path = NodePath("Head:rotation:y")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("Head:rotation:z")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0, 0, 0, 0, 0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 1.5, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 1.1, -0.25, 0, 0.25, 0, 1.05, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 0.358541, 0.995647, 2, 4.7)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_vd0e2"]
_data = {
&"RESET": SubResource("Animation_vcu7l"),
&"player_head_on_dying1": SubResource("Animation_tsmqm"),
&"players_head_on_dying": SubResource("Animation_6iwn4")
}
[node name="Player" type="CharacterBody3D"]
script = ExtResource("1_poq2x")
WalkSpeed = 10.0
@ -130,7 +38,7 @@ SprintSpeed = 15.0
[node name="InputController" type="Node3D" parent="."]
script = ExtResource("16_v31n3")
walk_mode = ExtResource("18_sik0q")
base_mode = ExtResource("3_cresl")
move = ExtResource("17_h6vvl")
rotate_y = ExtResource("4_rxwoh")
rotate_floorplane = ExtResource("5_4u7i3")
@ -147,54 +55,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
shape = SubResource("CapsuleShape3D_wydro")
script = ExtResource("8_lmtjd")
[node name="Head" type="Node3D" parent="."]
[node name="HeadSystem" parent="." instance=ExtResource("11_rxwoh")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68, 0)
[node name="CameraSmooth" type="Node3D" parent="Head"]
[node name="Camera3D" type="Camera3D" parent="Head/CameraSmooth"]
transform = Transform3D(0.15, 0, 0, 0, 0.15, 0, 0, 0, 0.15, 0, 0, 0)
current = true
[node name="CLVignette(Layer_1)" type="CanvasLayer" parent="Head/CameraSmooth/Camera3D"]
[node name="HealthVignetteRect" type="ColorRect" parent="Head/CameraSmooth/Camera3D/CLVignette(Layer_1)"]
material = ExtResource("2_6hee7")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="CLDistortion(Layer_2)" type="CanvasLayer" parent="Head/CameraSmooth/Camera3D"]
layer = 2
[node name="HealthDistortionRect" type="ColorRect" parent="Head/CameraSmooth/Camera3D/CLDistortion(Layer_2)"]
material = ExtResource("3_mxh1y")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="CLBlur(Layer_2)" type="CanvasLayer" parent="Head/CameraSmooth/Camera3D"]
layer = 2
[node name="BlurRect" type="ColorRect" parent="Head/CameraSmooth/Camera3D/CLBlur(Layer_2)"]
material = SubResource("ShaderMaterial_o1np4")
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
[node name="RayCast3D" type="RayCast3D" parent="Head/CameraSmooth/Camera3D"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -0.64723)
visible = false
[node name="HealthSystem" type="Node3D" parent="."]
script = ExtResource("5_umw0l")
@ -247,12 +110,6 @@ script = ExtResource("11_huhen")
[node name="FieldOfView" type="Node3D" parent="."]
script = ExtResource("12_m2mxi")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_vd0e2")
}
script = ExtResource("13_vnh4e")
[node name="HeadCollisionDetectors" type="Node3D" parent="."]
[node name="HeadCollisionDetector0" type="RayCast3D" parent="HeadCollisionDetectors"]

View File

@ -140,7 +140,6 @@ public partial class HealthSystem : Node3D
private bool _dead;
private Node3D _head;
private AnimationPlayer _animationPlayer;
private ShaderMaterial _blurMaterial;
public struct HealthSystemInitParams
@ -148,7 +147,6 @@ public partial class HealthSystem : Node3D
public Gravity Gravity;
public CharacterBody3D Parent;
public Camera3D Camera;
public AnimationPlayer AnimationPlayer;
public Node3D Head;
public ColorRect VignetteRect;
public ColorRect DistortionRect;
@ -187,8 +185,6 @@ public partial class HealthSystem : Node3D
_blurMaterial.SetShaderParameter(Constants.BLUR_SHADER_LIMIT, 0.0f);
_blurMaterial.SetShaderParameter(Constants.BLUR_SHADER_BLUR, 0.0f);
_animationPlayer = initParams.AnimationPlayer;
}
public override void _Process(double delta)
@ -250,7 +246,6 @@ public partial class HealthSystem : Node3D
if (!_deathAnimationPlayed)
{
_animationPlayer.PlayCameraRotationOnDeath();
_deathAnimationPlayed = true;
}

View File

@ -1,58 +0,0 @@
using System;
using Godot;
using RustyOptions;
namespace PolarBears.PlayerControllerAddon;
public partial class MantleSystem: Node3D
{
[Export(PropertyHint.Range, "0,2,0.1,suffix:m,or_greater")]
public float MantleEndLocationDistanceFromWall { get; set; } = 1f;
[Export(PropertyHint.Range, "0,10,0.1,suffix:m,or_greater")]
public float MantleHeightCastStart { get; set; } = 2f;
[Export(PropertyHint.Range, "0,10,0.01,suffix:m,or_greater")]
public float MaxStepHeight = 0.5f;
private Node3D _head;
private ShapeCast3D _wallInFrontCast3D;
private ShapeCast3D _mantleCast3D;
private RayCast3D _mantleCheckCast3D;
public void Init(Node3D head)
{
_head = head;
_wallInFrontCast3D = GetNode<ShapeCast3D>("WallInFrontCast3D");
_mantleCast3D = GetNode<ShapeCast3D>("MantleCast3D");
}
public Option<Vector3> FindMantleInFrontOfPlayer()
{
_wallInFrontCast3D.SetRotation(new Vector3(
_wallInFrontCast3D.Rotation.X,
_head.Rotation.Y,
_wallInFrontCast3D.Rotation.Z));
if (!_wallInFrontCast3D.IsColliding())
{
return Option<Vector3>.None;
}
var collisionPoint = _wallInFrontCast3D.GetCollisionPoint(0);
var collisionNormal = _wallInFrontCast3D.GetCollisionNormal(0);
return FindMantleLocationAtPoint(collisionPoint, collisionNormal);
}
public Option<Vector3> FindMantleLocationAtPoint(Vector3 point, Vector3 wallNormal)
{
var horizontalEndLocation = point - wallNormal * MantleEndLocationDistanceFromWall;
var shapeCastStartLocation = horizontalEndLocation + Vector3.Up * MantleHeightCastStart;
_mantleCast3D.SetGlobalPosition(shapeCastStartLocation);
var targetLocation = Vector3.Down * MantleHeightCastStart + Vector3.Up * MaxStepHeight;
_mantleCast3D.SetTargetPosition(targetLocation);
if (_mantleCast3D.IsColliding() && _mantleCast3D.GetCollisionNormal(0).Y > 0.9f)
return Option.Some(_mantleCast3D.GetCollisionPoint(0));
return Option<Vector3>.None;
}
}

View File

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

View File

@ -8,8 +8,6 @@ public partial class Mouse : Node3D
[Export(PropertyHint.Range, "0,0.1,0.001,or_greater")]
public float Sensitivity { get; set; } = 0.004f;
private Node3D _head;
private Camera3D _camera;
@ -40,17 +38,4 @@ public partial class Mouse : Node3D
_camera.Rotation = currentCameraRotation;
}
public override void _UnhandledInput(InputEvent @event)
{
if (_isPlayerDead())
{
return;
}
if (@event is InputEventMouseMotion eventMouseMotion)
{
var lookDir = new Vector2(-eventMouseMotion.Relative.X, -eventMouseMotion.Relative.Y);
LookAround(lookDir);
}
}
}

View File

@ -8,7 +8,7 @@ namespace PolarBears.PlayerControllerAddon;
public partial class PlayerController : CharacterBody3D
{
// User API to important child nodes.
public Node3D Head;
public HeadSystem HeadSystem;
public Bobbing Bobbing;
public FieldOfView FieldOfView;
public Stamina Stamina;
@ -18,7 +18,7 @@ public partial class PlayerController : CharacterBody3D
public CapsuleCollider CapsuleCollider;
public Gravity Gravity;
public HealthSystem HealthSystem;
public Mouse Mouse;
[Export(PropertyHint.Range, "0,20,0.1,or_greater")]
public float WalkSpeed { get; set; } = 5.0f;
@ -31,9 +31,6 @@ public partial class PlayerController : CharacterBody3D
[Export(PropertyHint.Range, "0,5,0.1,or_greater")]
public float DoubleJumpSpeedFactor { get; set; } = 2f;
[Export(PropertyHint.Range, "1,50,1,or_greater")]
public float ControllerSensitivity { get; set; } = 20f;
private bool _canDoubleJump = true;
private bool _movementEnabled = true;
@ -100,7 +97,8 @@ public partial class PlayerController : CharacterBody3D
{
_currentSpeed = WalkSpeed;
Head = GetNode<Node3D>("Head");
HeadSystem = GetNode<HeadSystem>("HeadSystem");
HeadSystem.Init();
_headCollisionDetectors = new RayCast3D[NumOfHeadCollisionDetectors];
@ -111,25 +109,23 @@ public partial class PlayerController : CharacterBody3D
}
// Getting dependencies of the components(In godot we manage this from upwards to downwards not vice versa)
Camera3D camera = GetNode<Camera3D>("Head/CameraSmooth/Camera3D");
Camera3D camera = GetNode<Camera3D>("HeadSystem/CameraSmooth/Camera3D");
RayCast3D stairsBelowRayCast3D = GetNode<RayCast3D>("StairsBelowRayCast3D");
RayCast3D stairsAheadRayCast3D = GetNode<RayCast3D>("StairsAheadRayCast3D");
Node3D cameraSmooth = GetNode<Node3D>("Head/CameraSmooth");
AnimationPlayer animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
Node3D cameraSmooth = GetNode<Node3D>("HeadSystem/CameraSmooth");
// Getting universal setting from GODOT editor to be in sync
float gravitySetting = (float)ProjectSettings.GetSetting("physics/3d/default_gravity");
ColorRect vignetteRect = GetNode<ColorRect>(
"Head/CameraSmooth/Camera3D/CLVignette(Layer_1)/HealthVignetteRect");
"HeadSystem/CameraSmooth/Camera3D/CLVignette(Layer_1)/HealthVignetteRect");
ColorRect distortionRect = GetNode<ColorRect>(
"Head/CameraSmooth/Camera3D/CLDistortion(Layer_2)/HealthDistortionRect");
"HeadSystem/CameraSmooth/Camera3D/CLDistortion(Layer_2)/HealthDistortionRect");
ColorRect blurRect = GetNode<ColorRect>("Head/CameraSmooth/Camera3D/CLBlur(Layer_2)/BlurRect");
ColorRect blurRect = GetNode<ColorRect>("HeadSystem/CameraSmooth/Camera3D/CLBlur(Layer_2)/BlurRect");
Node3D mapNode = GetTree().Root.FindChild("Map", true, false) as Node3D;
@ -148,10 +144,10 @@ public partial class PlayerController : CharacterBody3D
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
MantleSystem = GetNode<MantleSystem>("MantleSystem");
MantleSystem.Init(Head);
MantleSystem.Init(HeadSystem);
DashSystem = GetNode<DashSystem>("DashSystem");
DashSystem.Init(Head, camera);
DashSystem.Init(HeadSystem, camera);
CapsuleCollider = GetNode<CapsuleCollider>("CapsuleCollider");
@ -165,17 +161,13 @@ public partial class PlayerController : CharacterBody3D
Gravity = Gravity,
Parent = this,
Camera = camera,
AnimationPlayer = animationPlayer,
Head = Head,
Head = HeadSystem,
VignetteRect = vignetteRect,
DistortionRect = distortionRect,
BlurRect = blurRect,
};
HealthSystem.Init(healthSystemParams);
Mouse = GetNode<Mouse>("Mouse");
Mouse.Init(Head, camera, HealthSystem.IsDead);
}
private void DisableMovement()
@ -325,16 +317,15 @@ public partial class PlayerController : CharacterBody3D
_currentSpeed = SprintSpeed;
}
// Vector2 inputLookDir = Input.GetVector("look_left", "look_right", "look_up", "look_down");
Vector2 inputLookDir = new Vector2(_inputRotateY, _inputRotateFloorplane);
Mouse.LookAround(-1 * ControllerSensitivity * inputLookDir);
HeadSystem.LookAround(inputLookDir);
// Basis is a 3x4 matrix. It contains information about scaling and rotation of head.
// By multiplying our Vector3 by this matrix we're doing multiple things:
// a) We start to operate in global space;
// b) We're applying to Vector3 the current rotation of "head" object;
// c) We're applying to Vector3 the current scaling of "head" object;
Vector3 direction = Head.Transform.Basis * _inputMove;
Vector3 direction = HeadSystem.Transform.Basis * _inputMove;
if (isPlayerDead)
{