From ac72c3b22e626af800ed1e3fb934bc679fc15daa Mon Sep 17 00:00:00 2001 From: vaporvee Date: Mon, 5 Dec 2022 21:07:16 +0100 Subject: [PATCH] player controller works now completely with camera movement --- src/player.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/player.cs b/src/player.cs index b8f1dd4..08251da 100644 --- a/src/player.cs +++ b/src/player.cs @@ -29,10 +29,9 @@ public partial class player : CharacterBody3D { playerResetPosition = Rotation; camPosition = cameraCenter.Rotation; - playerResetPosition.y = camPosition.y; - Rotation = playerResetPosition / 2; - Vector3 cameraResetPosition = cameraCenter.Rotation; - cameraCenter.Rotation = new Vector3 (cameraResetPosition.x,0,0); + playerResetPosition.y = camPosition.y * -1f; + Rotation -= playerResetPosition; + cameraCenter.Rotation = new Vector3 (camPosition.x,0,0); } } public override void _PhysicsProcess(double delta) @@ -68,7 +67,6 @@ public partial class player : CharacterBody3D Vector3 generalRot = Rotation; if (Input.IsActionPressed("move_forward")) generalRot.y -= motionEvent.Relative.x * mouseSensitivity; Rotation = generalRot; - generalRot = cameraCenter.Rotation; if (!Input.IsActionPressed("move_forward")) generalRot.y -= motionEvent.Relative.x * mouseSensitivity; generalRot.x -= motionEvent.Relative.y * mouseSensitivity;