Rapid Prototyping with New Unity Input System

Simon Pham
2 min readJan 17, 2024

The New Unity Input System is quick to set up and easy to use, but there are situations where you want to rapidly prototype something simple and don’t want to have to go through the process of creating Action Maps and enabling Actions. Well, there is a way to do that with the new Input System using the “wasPressedThisFrame” property.

Demonstration

I’ve set up a simple scene with a sphere and a plane.

The sphere has a simple script attached to it that would make it jump when the space key is pressed:

using UnityEngine;
using UnityEngine.InputSystem;

public class Test : MonoBehaviour
{
private float _jumpForce = 300f;
private Rigidbody _rb;

void Start()
{
_rb = GetComponent<Rigidbody>();
if (_rb == null)
{
Debug.LogError("Rigidbody is null");
}
}

void Update()
{
if(Keyboard.current.spaceKey.wasPressedThisFrame)
{
_rb.AddForce(Vector3.up * _jumpForce, ForceMode.Force);
}
}
}

Here’s the result:

Also, you can use the “wasReleasedThisFrame” property if you want the action to be performed when a key is released.

--

--