Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avatar moving on its own when pressin CAPS (#1743) #2227

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace DCL.CharacterMotion.Components
{
public struct MovementInputComponent : IInputComponent
{
public bool AutoWalk;
public MovementKind Kind;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ public partial class UpdateInputMovementSystem : UpdateInputSystem<MovementInput
private readonly InputAction movementAxis;
private readonly InputAction sprintAction;
private readonly InputAction walkAction;
private readonly InputAction autoWalkAction;

public UpdateInputMovementSystem(World world, DCLInput dclInput) : base(world)
{
movementAxis = dclInput.Player.Movement;
sprintAction = dclInput.Player.Sprint;
walkAction = dclInput.Player.Walk;
autoWalkAction = dclInput.Player.AutoWalk;
}

protected override void Update(float t)
Expand All @@ -43,12 +41,6 @@ private void UpdateInput(ref MovementInputComponent inputToUpdate, in InputModif

inputToUpdate.Axes = movementAxis.ReadValue<Vector2>();

if (!inputModifierComponent.DisableWalk && autoWalkAction.WasPerformedThisFrame())
inputToUpdate.AutoWalk = !inputToUpdate.AutoWalk;

if (inputToUpdate is { AutoWalk: true, Axes: { sqrMagnitude: > 0.1f } })
inputToUpdate.AutoWalk = false;

if (inputToUpdate.Axes == Vector2.zero)
inputToUpdate.Kind = MovementKind.IDLE;
else
Expand All @@ -58,12 +50,6 @@ private void UpdateInput(ref MovementInputComponent inputToUpdate, in InputModif

inputToUpdate.Kind = ProcessInputMovementKind(inputModifierComponent, runPressed, walkPressed);
}

if (inputToUpdate.AutoWalk)
{
inputToUpdate.Axes = new Vector2(0, 1);
inputToUpdate.Kind = MovementKind.WALK;
}
}

private static MovementKind ProcessInputMovementKind(InputModifierComponent inputModifierComponent, bool runPressed, bool walkPressed)
Expand Down
30 changes: 0 additions & 30 deletions Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,6 @@ public @DCLInput()
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""AutoWalk"",
""type"": ""Button"",
""id"": ""b4656ae5-6783-44e3-aab6-f47c82bbb0b5"",
""expectedControlType"": ""Button"",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
Expand Down Expand Up @@ -601,17 +592,6 @@ public @DCLInput()
""action"": ""Walk"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""ce03bf46-b4a6-4780-b639-6cf34b8a35cc"",
""path"": ""<Keyboard>/capsLock"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""AutoWalk"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
},
Expand Down Expand Up @@ -2919,7 +2899,6 @@ public @DCLInput()
m_Player_ActionBackward = m_Player.FindAction("ActionBackward", throwIfNotFound: true);
m_Player_ActionRight = m_Player.FindAction("ActionRight", throwIfNotFound: true);
m_Player_ActionLeft = m_Player.FindAction("ActionLeft", throwIfNotFound: true);
m_Player_AutoWalk = m_Player.FindAction("AutoWalk", throwIfNotFound: true);
// Camera
m_Camera = asset.FindActionMap("Camera", throwIfNotFound: true);
m_Camera_ZoomOut = m_Camera.FindAction("ZoomOut", throwIfNotFound: true);
Expand Down Expand Up @@ -3070,7 +3049,6 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
private readonly InputAction m_Player_ActionBackward;
private readonly InputAction m_Player_ActionRight;
private readonly InputAction m_Player_ActionLeft;
private readonly InputAction m_Player_AutoWalk;
public struct PlayerActions
{
private @DCLInput m_Wrapper;
Expand All @@ -3090,7 +3068,6 @@ public struct PlayerActions
public InputAction @ActionBackward => m_Wrapper.m_Player_ActionBackward;
public InputAction @ActionRight => m_Wrapper.m_Player_ActionRight;
public InputAction @ActionLeft => m_Wrapper.m_Player_ActionLeft;
public InputAction @AutoWalk => m_Wrapper.m_Player_AutoWalk;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
Expand Down Expand Up @@ -3145,9 +3122,6 @@ public void AddCallbacks(IPlayerActions instance)
@ActionLeft.started += instance.OnActionLeft;
@ActionLeft.performed += instance.OnActionLeft;
@ActionLeft.canceled += instance.OnActionLeft;
@AutoWalk.started += instance.OnAutoWalk;
@AutoWalk.performed += instance.OnAutoWalk;
@AutoWalk.canceled += instance.OnAutoWalk;
}

private void UnregisterCallbacks(IPlayerActions instance)
Expand Down Expand Up @@ -3197,9 +3171,6 @@ private void UnregisterCallbacks(IPlayerActions instance)
@ActionLeft.started -= instance.OnActionLeft;
@ActionLeft.performed -= instance.OnActionLeft;
@ActionLeft.canceled -= instance.OnActionLeft;
@AutoWalk.started -= instance.OnAutoWalk;
@AutoWalk.performed -= instance.OnAutoWalk;
@AutoWalk.canceled -= instance.OnAutoWalk;
}

public void RemoveCallbacks(IPlayerActions instance)
Expand Down Expand Up @@ -3967,7 +3938,6 @@ public interface IPlayerActions
void OnActionBackward(InputAction.CallbackContext context);
void OnActionRight(InputAction.CallbackContext context);
void OnActionLeft(InputAction.CallbackContext context);
void OnAutoWalk(InputAction.CallbackContext context);
}
public interface ICameraActions
{
Expand Down
20 changes: 0 additions & 20 deletions Explorer/Assets/DCL/Input/UnityInputSystem/DCLInput.inputactions
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "AutoWalk",
"type": "Button",
"id": "b4656ae5-6783-44e3-aab6-f47c82bbb0b5",
"expectedControlType": "Button",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
Expand Down Expand Up @@ -579,17 +570,6 @@
"action": "Walk",
"isComposite": false,
"isPartOfComposite": false
},
{
"name": "",
"id": "ce03bf46-b4a6-4780-b639-6cf34b8a35cc",
"path": "<Keyboard>/capsLock",
"interactions": "",
"processors": "",
"groups": "",
"action": "AutoWalk",
"isComposite": false,
"isPartOfComposite": false
}
]
},
Expand Down
Loading