Input System: How to declare interaction types to compare to callback context?
Hi All,
Trying to get the new input system running and its been quite simple so far, however I am trying to deal with two interactions on a single binding which in this case is space bar for jump. If the space is tapped I want the character to jump, if it is held i want the character to use its boosters to fly up. this seems to be simple in the documentation as it shows that you simply look for the interaction type inside the callback context, it shows that you simply check if the interaction is "TapInteraction". The issue is where do I define what "TapInteraction" is as cannot find anywhere a method that returns the correct thing to compare. Help :)
Code that I would think would work is below given the documentation link below (see Interaction): (https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputAction.CallbackContext.html)
public void OnJump(InputAction.CallbackContext jumpInteraction)
{
if (jumpInteraction.interaction is TapInteraction && jumpInteraction.performed)
{
isJumping = true;
}
if (jumpInteraction.interaction is HoldInteraction && jumpInteraction.performed)
{
isBoosting = true;
}
else
{
isJumping = false;
isBoosting = false;
}
}
Your answer
Follow this Question
Related Questions
movement speed still changes with FPS; Despite using Time.deltaTime (And GetAxisRaw)! 0 Answers
Stop player going up when camera looks up. 1 Answer
Drunk Walk VR Simulation,Drunk VR Simulation 0 Answers
Character sliding across terrain 1 Answer
is it possible to edit the Continuous Move provider (Action based) to add a jump feature? 0 Answers