Closed Johnney1337 closed 7 months ago
Hey :)
Yes you can do this, now the sit tracking is done with Action, so I didn't count on such functionality, but it's a little tricky. For the old input system you can write this code.
public void Update()
{
if (UnityEngine.Input.GetKeyDown(KeyCode.Space)) SetJumpInput();
if (UnityEngine.Input.GetKeyDown(KeyCode.LeftControl)) SetSitInput();
if (UnityEngine.Input.GetKeyUp(KeyCode.LeftControl)) SetSitInput(); // Cheat;)
SprintInput();
MoveInput();
LookInput();
LeanInput();
}
(OldPlayerInputHandler.cs)
For New Input System
private void Awake()
{
_playerInputActions = new PlayerInputActions();
_playerInputActions.Enable();
_playerInputActions.Player.Move.SubscribeStartEndAction(OnMove);
_playerInputActions.Player.Look.SubscribeStartEndAction(OnLook);
_playerInputActions.Player.Sprint.SubscribeStartEndAction(OnSprint);
_playerInputActions.Player.Lean.SubscribeStartEndAction(OnLean);
_playerInputActions.Player.Jump.SubscribeStartAction(OnJump);
_playerInputActions.Player.Sit.SubscribeStartAction(OnSit);
_playerInputActions.Player.Sit.SubscribeEndAction(OnSit); // Cheat;)
}
(NewPlayerInputHandler.cs)
Sorry for the delay(
I hope this helps you.
But it would be better to rewrite sit from Action to bool then it will be more correct. The option I gave is not ideal and some bugs may arise
That was a good point. I changed it to boolean at it works very well. Thank you :)
Hey :)
I have a new question. Is it possible to define that sitting should just be hold if the sit key is pressed?
Hopfe for help, thanks! 👍