Tap & Hold w/ New Unity Input System

Tyler Smallwood
3 min readApr 26, 2023

Objective: Use Tap & Hold interaction to make the player jump.

We will start this out by creating a plane for the player to stand and jump on. We will need a player as well, we’ll create a sphere for now.

Next we will need to add a RigidBody onto the player.

Now to work on the input. We will create a new InputAction in the Project window.

We will open this window and create a new action map.

Next will an Action with the binding of Space key.

Next will be to add a Tap and Hold interactions on the jump. Uncheck the hold time default and change the time to 1.

Now it’s time to generate a C# script of the input actions.

Next, let’s create our player script and add it onto the player.

In the script we will get the InputSystem library. Next we will assign a PlayerInputAction to _input. In Start, we will initialize it and Enable the Player Action Map.

We will need to assign the Rigidbody as well. We will use the rigidbody later.

We will call the Performed and canceled actions. When calling them hit tab and let the IDE auto complete the methods.

Performed will be called when the Space key is held for the one second. So in there we will use the Rigidbody to add force to the player.

Now we jump if we hold for the full 1 second.

In the Canceled method we will do the same but for one thing. We will need a var forceEffect to get the duration of the hold. Once we got that, we will call the _rb.AddForce again by multiple the jump force by forceEffect. We will need to cast the forceEffect as a float because the duration is a double.

Now we can not jump as high if we let go sooner.

We can control how we jump with just this few adjustments. Thank you for reading and have a wonderful day!



Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer