EDIT: Solution [SOLVED] GetButtonDown / GetButtonUp with the new system - Unity Engine - Unity Discussions
Hello. First of all, congrats for the UI with this new Input System. It’s waaaaay better than the old one. The setup of different button for PC/XBOX/PS4 works perfectly!
However, the new system is also really confusing and i feel that even with all its limitations, the old system was way easier to setup and control.
I have a simple Jump action that requires GetButtonDown and GetButtonUp. Cool, with the old system it was two lines of code.
I tried to do this with the new system for hours and i cannot understand how it really works. It doesn’t help that the tutorials/videos/forums explain things in 2/3 different ways, and the Migrating section of the documentation is really vague in terms of explaining how to setup ButtonUp/Down.
So, i ask for help because i feel totally lost:
This was my previous code
public bool GetJump(bool Down)
{
if (Down)
{
return Input.GetButtonDown("Jump");
}
else
{
return Input.GetButtonUp("Jump");
}
}
And yes, i have read dozens of threads before creating this post. And no, none of the ‘solutions’ worked. We just want a simple way to get the two events, because this is the nonsense that i have and still fails:
private void Awake()
{
controls = new PlayerControls();
controls.Gameplay.Move.performed += ctx => _directionInfo = ctx.ReadValue<Vector2>();
controls.Gameplay.Jump.started += ctx => _JumpPressed = true; _JumpReleased = false;
controls.Gameplay.Jump.canceled += ctx => _JumpPressed = false;
}
My Jump button is set to Tap. It’s the closest thing to the previous version of my Jump, but still fails.
In fact, the closest one was this:
controls.Gameplay.Jump.performed -= ctx =>
{
var control = ctx.control;
var button = control as ButtonControl;
if (button != null)
{
if (button.wasPressedThisFrame)
{
_JumpPressed = true;
_JumpReleased = false;
}
else if (button.wasReleasedThisFrame)
{
_JumpPressed = false;
_JumpReleased = true;
}
}
};
Jump button on Press and Release. ALMOST WORKS, but i can hold Jump and i will jump constantly once i touch the ground again. With the old system, ButtonDown will be called one time, and i need to ButtonUp for the next Jump.
Even if i can get this to work, the new system in its current state is way difficult to setup compared to the old one. There are 2/3 ways that i saw on the forums to configure things. It’s modularity is killing the most basic setups for a lot of teams, which will end up using the old one or just purchasing one from the Asset Store.