From ce8f172d4193f9f3dc5fcd4a0963e9861b0ad60d Mon Sep 17 00:00:00 2001
From: JaN0h4ck <95576868+JaN0h4ck@users.noreply.github.com>
Date: Thu, 21 Mar 2024 09:08:30 +0100
Subject: [PATCH 1/3] upgrade to godot 4.2
---
icon.png.import | 2 +-
project.godot | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/icon.png.import b/icon.png.import
index 4075532..f482cf1 100644
--- a/icon.png.import
+++ b/icon.png.import
@@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.cte
[params]
compress/mode=0
+compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
-compress/bptc_ldr=0
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
diff --git a/project.godot b/project.godot
index 525f9ad..8ea83f6 100644
--- a/project.godot
+++ b/project.godot
@@ -12,7 +12,7 @@ config_version=5
config/name="Godot .NET thirdperson controller"
run/main_scene="res://scenes/main.tscn"
-config/features=PackedStringArray("4.0", "Forward Plus")
+config/features=PackedStringArray("4.2", "C#", "Forward Plus")
boot_splash/bg_color=Color(0.141176, 0.141176, 0.141176, 1)
boot_splash/show_image=false
config/icon="res://icon.png"
From 8dbf6de4ea0fdf427fba764009393ca8ed322de2 Mon Sep 17 00:00:00 2001
From: JaN0h4ck <95576868+JaN0h4ck@users.noreply.github.com>
Date: Thu, 21 Mar 2024 09:12:59 +0100
Subject: [PATCH 2/3] regenerate solution
---
gd-mono-thirdpersoncontroller.csproj | 9 +++++++++
gd-mono-thirdpersoncontroller.sln | 19 +++++++++++++++++++
gd-net-thirdpersoncontroller.csproj | 7 -------
gd-net-thirdpersoncontroller.sln | 19 -------------------
4 files changed, 28 insertions(+), 26 deletions(-)
create mode 100644 gd-mono-thirdpersoncontroller.csproj
create mode 100644 gd-mono-thirdpersoncontroller.sln
delete mode 100644 gd-net-thirdpersoncontroller.csproj
delete mode 100644 gd-net-thirdpersoncontroller.sln
diff --git a/gd-mono-thirdpersoncontroller.csproj b/gd-mono-thirdpersoncontroller.csproj
new file mode 100644
index 0000000..7320af9
--- /dev/null
+++ b/gd-mono-thirdpersoncontroller.csproj
@@ -0,0 +1,9 @@
+
+
+ net6.0
+ net7.0
+ net8.0
+ true
+ gdmonothirdpersoncontroller
+
+
\ No newline at end of file
diff --git a/gd-mono-thirdpersoncontroller.sln b/gd-mono-thirdpersoncontroller.sln
new file mode 100644
index 0000000..f18f085
--- /dev/null
+++ b/gd-mono-thirdpersoncontroller.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gd-mono-thirdpersoncontroller", "gd-mono-thirdpersoncontroller.csproj", "{AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ ExportDebug|Any CPU = ExportDebug|Any CPU
+ ExportRelease|Any CPU = ExportRelease|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
+ {AC7B5940-D2F5-4F43-AF3D-D23E4111E15D}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
+ EndGlobalSection
+EndGlobal
diff --git a/gd-net-thirdpersoncontroller.csproj b/gd-net-thirdpersoncontroller.csproj
deleted file mode 100644
index 63c6e8c..0000000
--- a/gd-net-thirdpersoncontroller.csproj
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
- net6.0
- true
- gd-net-thirdpersoncontroller
-
-
\ No newline at end of file
diff --git a/gd-net-thirdpersoncontroller.sln b/gd-net-thirdpersoncontroller.sln
deleted file mode 100644
index 6f2a105..0000000
--- a/gd-net-thirdpersoncontroller.sln
+++ /dev/null
@@ -1,19 +0,0 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2012
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gd-net-thirdpersoncontroller", "gd-net-thirdpersoncontroller.csproj", "{C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- ExportDebug|Any CPU = ExportDebug|Any CPU
- ExportRelease|Any CPU = ExportRelease|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
- {C0DA1341-EAB0-4F7B-BEA9-60129C156BFE}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
- EndGlobalSection
-EndGlobal
From 72434b2480ef90c2ca43d08016a49e24f2b79620 Mon Sep 17 00:00:00 2001
From: JaN0h4ck <95576868+JaN0h4ck@users.noreply.github.com>
Date: Thu, 21 Mar 2024 09:28:53 +0100
Subject: [PATCH 3/3] Move GetNode calls to _Ready function
---
src/player.cs | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/player.cs b/src/player.cs
index ba7c562..2b2b0b4 100644
--- a/src/player.cs
+++ b/src/player.cs
@@ -5,6 +5,8 @@ public partial class player : CharacterBody3D
public Vector3 direction;
public Vector2 gpCamVector;
public bool gamepadMode;
+ private Marker3D cameraCenter {get; set;}
+ private MeshInstance3D collisionBody {get; set;}
[Export] float speed = 5.0f;
[Export] float jumpVelocity = 5f;
[Export] float gravity = 14f;
@@ -12,6 +14,11 @@ public partial class player : CharacterBody3D
[Export(PropertyHint.Range, "-90,0,1")] float minCamPitch = -50f;
[Export(PropertyHint.Range, "0,90,1")] float maxCamPitch = 30f;
+ public override void _Ready() {
+ cameraCenter = GetNode("camera_center");
+ collisionBody = GetNode("collision/body");
+ }
+
public override void _Process(double delta)
{
//uncapturing the mouse disables PC movement but still simulates gravity
@@ -22,19 +29,19 @@ public partial class player : CharacterBody3D
maybe rotate extra collisions separately for invisible lag that may occur**/
if (direction != Vector3.Zero && Input.MouseMode == Input.MouseModeEnum.Captured | gamepadMode)
{
- Vector3 bodyRotation = GetNode("collision/body").Rotation;
+ Vector3 bodyRotation = collisionBody.Rotation;
bodyRotation.Y = Mathf.LerpAngle(bodyRotation.Y,Mathf.Atan2(-direction.X, -direction.Z), (float)delta * speed);
- GetNode("collision/body").Rotation = bodyRotation;
+ collisionBody.Rotation = bodyRotation;
}
//camera gamepad part (needs constant movement so _Input event wouldn't work with this like mouseinput)
gpCamVector = Input.GetVector("gp_cam_left", "gp_cam_right", "gp_cam_up", "gp_cam_down");
if(gpCamVector != Vector2.Zero)
{
- Vector3 camRot = GetNode("camera_center").RotationDegrees;
+ Vector3 camRot = cameraCenter.RotationDegrees;
camRot.Y -= gpCamVector.X * camSensitivity * (float)delta * 500;
camRot.X -= gpCamVector.Y * camSensitivity * (float)delta * 500;
camRot.X = Mathf.Clamp(camRot.X, minCamPitch, maxCamPitch); //prevents camera from going endlessly around the player
- GetNode("camera_center").RotationDegrees = camRot;
+ cameraCenter.RotationDegrees = camRot;
}
}
public override void _PhysicsProcess(double delta)
@@ -65,13 +72,13 @@ public partial class player : CharacterBody3D
public override void _Input(InputEvent @event)
{
gamepadMode = @event is InputEventJoypadButton | @event is InputEventJoypadMotion;
- Vector3 camRot = GetNode("camera_center").RotationDegrees;
+ Vector3 camRot = cameraCenter.RotationDegrees;
if (@event is InputEventMouseMotion mouseMotion && Input.MouseMode == Input.MouseModeEnum.Captured)
{
camRot.Y -= mouseMotion.Relative.X * camSensitivity;
camRot.X -= mouseMotion.Relative.Y * camSensitivity;
}
camRot.X = Mathf.Clamp(camRot.X, minCamPitch, maxCamPitch); //prevents camera from going endlessly around the player
- GetNode("camera_center").RotationDegrees = camRot;
+ cameraCenter.RotationDegrees = camRot;
}
}