diff --git a/scenes/main.tscn b/scenes/main.tscn index d442603..2991950 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -71,5 +71,3 @@ transform = Transform3D(0.994703, -0.00611287, -0.102607, 0.101106, 0.238088, 0. shadow_enabled = true [node name="player" parent="." instance=ExtResource("1_1hi18")] -JumpVelocity = 5.5 -gravity = 14.0 diff --git a/src/player.cs b/src/player.cs index 6a0fddd..221ed6c 100644 --- a/src/player.cs +++ b/src/player.cs @@ -42,7 +42,7 @@ public partial class player : CharacterBody3D Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward"); direction = (Transform.basis * new Vector3(inputDir.x, 0, inputDir.y)).Normalized(); - if (direction != Vector3.Zero) + if (direction != Vector3.Zero && Input.MouseMode == Input.MouseModeEnum.Captured) { velocity.x = direction.x * Speed; velocity.z = direction.z * Speed; @@ -50,7 +50,7 @@ public partial class player : CharacterBody3D //checks for movement and adjusts the character direction with camera roatation playerResetPosition = Rotation; camPosition = cameraCenter.Rotation; - playerResetPosition.y = camPosition.y * -1f; + playerResetPosition.y = camPosition.y * -1f; Rotation -= playerResetPosition; cameraCenter.Rotation = new Vector3(camPosition.x, 0, 0); } @@ -59,11 +59,9 @@ public partial class player : CharacterBody3D velocity.x = Mathf.MoveToward(Velocity.x, 0, Speed); velocity.z = Mathf.MoveToward(Velocity.z, 0, Speed); } - if(Input.MouseMode == Input.MouseModeEnum.Captured) - { + Velocity = velocity; - } - MoveAndSlide(); + MoveAndSlide(); } public override void _Input(InputEvent @event) {