- Home /
Question by
CheMBurN · Jan 22, 2021 at 06:31 PM ·
variableinputmanagerinputs
New Input System how to set a variable for context callback?
Upgraded my project to the new Unity Input system and I'm having a lot of trouble adopting it.
public void GetJumpInput(InputAction.CallbackContext context)
{
if (context.action.triggered && Player.isGrounded)
{
isJumping = true;
}
if (context.action.triggered && !Player.isGrounded && extraJumps == 1)
{
isJumping = true;
extraJumps--;
}
}
private void FixedUpdate()
{
if (isJumping == true)
{
p_rb.velocity = Vector2.up * initialJumpVelocity;
isJumping = false;
}
}
This is the closest I could get for my jump to work as I would want. A lot of other things I tried made the player keep jumping for as long as the key is being held down.
What would be the best way for set up some kind of variable for the button to be called when pressed and then a 'negative' call when released (preferably without having to put all that code within that void function)(is that even possible with the Input System?)
Comment
Answer by Quazaar_studios · Jan 22, 2021 at 09:25 PM
https://www.youtube.com/watch?v=p-3S73MaDP8 I would recommend this tutorial, in this video he shows how to do exactly that :D