fixed mouse uncapture while jumping leads to flying bug
This commit is contained in:
@@ -71,5 +71,3 @@ transform = Transform3D(0.994703, -0.00611287, -0.102607, 0.101106, 0.238088, 0.
|
|||||||
shadow_enabled = true
|
shadow_enabled = true
|
||||||
|
|
||||||
[node name="player" parent="." instance=ExtResource("1_1hi18")]
|
[node name="player" parent="." instance=ExtResource("1_1hi18")]
|
||||||
JumpVelocity = 5.5
|
|
||||||
gravity = 14.0
|
|
||||||
|
@@ -42,7 +42,7 @@ public partial class player : CharacterBody3D
|
|||||||
|
|
||||||
Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward");
|
Vector2 inputDir = Input.GetVector("move_left", "move_right", "move_forward", "move_backward");
|
||||||
direction = (Transform.basis * new Vector3(inputDir.x, 0, inputDir.y)).Normalized();
|
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.x = direction.x * Speed;
|
||||||
velocity.z = direction.z * 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
|
//checks for movement and adjusts the character direction with camera roatation
|
||||||
playerResetPosition = Rotation;
|
playerResetPosition = Rotation;
|
||||||
camPosition = cameraCenter.Rotation;
|
camPosition = cameraCenter.Rotation;
|
||||||
playerResetPosition.y = camPosition.y * -1f;
|
playerResetPosition.y = camPosition.y * -1f;
|
||||||
Rotation -= playerResetPosition;
|
Rotation -= playerResetPosition;
|
||||||
cameraCenter.Rotation = new Vector3(camPosition.x, 0, 0);
|
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.x = Mathf.MoveToward(Velocity.x, 0, Speed);
|
||||||
velocity.z = Mathf.MoveToward(Velocity.z, 0, Speed);
|
velocity.z = Mathf.MoveToward(Velocity.z, 0, Speed);
|
||||||
}
|
}
|
||||||
if(Input.MouseMode == Input.MouseModeEnum.Captured)
|
|
||||||
{
|
|
||||||
Velocity = velocity;
|
Velocity = velocity;
|
||||||
}
|
MoveAndSlide();
|
||||||
MoveAndSlide();
|
|
||||||
}
|
}
|
||||||
public override void _Input(InputEvent @event)
|
public override void _Input(InputEvent @event)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user