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;
|
||||||
@@ -59,10 +59,8 @@ 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