Skip to content

Commit

Permalink
Merge pull request #276 from hackerspace-ntnu/fix/hat-barrel
Browse files Browse the repository at this point in the history
Fix crouching being more visible, fix gamepad look sensitivity
  • Loading branch information
Fueredoriku authored Nov 7, 2023
2 parents 0f05424 + c536632 commit 83d23b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Assets/Prefabs/Input/Player.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ MonoBehaviour:
leapForce: 12.5
jumpTimeout: 0.5
leapTimeout: 0.875
crouchedHeightOffset: 0.3
crouchedHeightOffset: 0.8
airThreshold: 0.4
slopeAngleThreshold: 50
state: 1
Expand Down Expand Up @@ -177,6 +177,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
maxHitDistance: 100
targetStartOffset: 0.9
overrideAimTarget: 0
inputManager: {fileID: 0}
identity: {fileID: 0}
hudController: {fileID: 555885729091202788}
Expand Down
4 changes: 3 additions & 1 deletion Assets/Scripts/Control&Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class InputManager : MonoBehaviour

[SerializeField]
private float mouseLookScale = 0.1f;
[SerializeField]
private float gamepadLookScale = 0.75f;

private bool isMouseAndKeyboard = false;

Expand Down Expand Up @@ -130,7 +132,7 @@ private void LookInputPerformed(InputAction.CallbackContext ctx)
}
else
{
lookInput = ctx.ReadValue<Vector2>();
lookInput = ctx.ReadValue<Vector2>() * gamepadLookScale;
}
}

Expand Down
9 changes: 5 additions & 4 deletions Assets/Scripts/Control&Input/PlayerMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,18 @@ private void SetCrouch(InputAction.CallbackContext ctx)

if (ctx.performed)
{
if (IsInAir())
return;
animator.SetBool("Crouching", true);
strafeForce = strafeForceCrouched;
if (!IsInAir())
inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f);
inputManager.gameObject.LeanMoveLocalY(localCameraHeight - crouchedHeightOffset, 0.2f);
}

if (ctx.canceled)
{
animator.SetBool("Crouching", false);
strafeForce = strafeForceGrounded;
if (!IsInAir())
inputManager.gameObject.LeanMoveLocalY(localCameraHeight, 0.2f);
inputManager.gameObject.LeanMoveLocalY(localCameraHeight, 0.2f);
}

}
Expand Down Expand Up @@ -200,6 +200,7 @@ private void UpdatePosition(Vector3 input)
var groundNormal = GroundNormal();
var direction = Vector3.ProjectOnPlane(input, groundNormal);
body.AddForce(direction * strafeForce, ForceMode.VelocityChange);
body.AddForce(direction * strafeForce, ForceMode.Impulse);
if (IsInAir()) state = PlayerState.IN_AIR;
break;
}
Expand Down

0 comments on commit 83d23b1

Please sign in to comment.