Bird
Raised Fist0
Unityframework~20 mins

New Input System overview in Unity - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
New Input System Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
What is the output of this Input Action callback?

Consider this Unity C# code snippet using the New Input System:

using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    public InputAction jumpAction;

    void OnEnable()
    {
        jumpAction.Enable();
        jumpAction.performed += ctx => Debug.Log($"Jump performed at {ctx.time}");
    }

    void OnDisable()
    {
        jumpAction.Disable();
    }
}

If the player presses the jump button at game time 5.2 seconds, what will be printed?

Unity
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerController : MonoBehaviour
{
    public InputAction jumpAction;

    void OnEnable()
    {
        jumpAction.Enable();
        jumpAction.performed += ctx => Debug.Log($"Jump performed at {ctx.time}");
    }

    void OnDisable()
    {
        jumpAction.Disable();
    }
}
ANo output because jumpAction is not enabled
BJump performed at 0
CJump performed at ctx.time
DJump performed at 5.2
Attempts:
2 left
💡 Hint

Look at the ctx.time property in the callback. It gives the time of the input event.

🧠 Conceptual
intermediate
1:30remaining
Which Input System component stores the player's input bindings?

In Unity's New Input System, where are the player's input bindings (like keyboard keys or gamepad buttons) stored?

AInputUser
BInputActionAsset
CInputControlScheme
DInputActionMap
Attempts:
2 left
💡 Hint

Think about the asset that holds all actions and their bindings.

❓ Predict Output
advanced
2:00remaining
What is the output of this InputAction value reading?

Given this code snippet:

var moveAction = new InputAction(type: InputActionType.Value, binding: "/leftStick");
moveAction.Enable();
var value = moveAction.ReadValue<Vector2>();
Debug.Log(value);

If the left stick is centered (not moved), what will be printed?

Unity
var moveAction = new InputAction(type: InputActionType.Value, binding: "<Gamepad>/leftStick");
moveAction.Enable();
var value = moveAction.ReadValue<Vector2>();
Debug.Log(value);
A(0.0, 0.0)
B(1.0, 1.0)
C(0.5, 0.5)
DNullReferenceException
Attempts:
2 left
💡 Hint

Think about the default position of a gamepad's left stick when untouched.

🔧 Debug
advanced
2:00remaining
Why does this InputAction callback never run?

Look at this code:

public InputAction fireAction;

void Start()
{
    fireAction.performed += ctx => Debug.Log("Fire!");
}

void Update()
{
    if (fireAction.triggered)
        Debug.Log("Triggered");
}

Why does pressing the fire button never print "Fire!"?

Unity
public InputAction fireAction;

void Start()
{
    fireAction.performed += ctx => Debug.Log("Fire!");
}

void Update()
{
    if (fireAction.triggered)
        Debug.Log("Triggered");
}
AThe performed event only fires in Update, not Start
BThe lambda syntax is incorrect
CfireAction is never enabled, so callbacks don't run
Dtriggered is false because fireAction is disabled
Attempts:
2 left
💡 Hint

Check if the InputAction is enabled before use.

🧠 Conceptual
expert
2:30remaining
Which feature allows multiple players to use separate input devices simultaneously?

In Unity's New Input System, what feature lets you manage multiple players each with their own input devices, so they don't interfere with each other?

AInputUser
BInputBindingMask
CInputActionMap
DInputControlScheme
Attempts:
2 left
💡 Hint

Think about the system that tracks users and their devices.

Practice

(1/5)
1. What is the main purpose of the New Input System in Unity?
easy
A. To create 3D models for games
B. To handle multiple input devices easily and flexibly
C. To manage game physics and collisions
D. To optimize game graphics performance

Solution

  1. Step 1: Understand the role of input systems

    The New Input System is designed to manage inputs from devices like keyboard, mouse, gamepads, etc.
  2. Step 2: Compare with other options

    Options B, C, and D relate to graphics, physics, or modeling, not input handling.
  3. Final Answer:

    To handle multiple input devices easily and flexibly -> Option B
  4. Quick Check:

    New Input System = device input management [OK]
Hint: Focus on input device management purpose [OK]
Common Mistakes:
  • Confusing input system with graphics or physics
  • Thinking it only handles keyboard input
  • Assuming it creates game assets
2. Which of the following is the correct way to enable an input action in the New Input System?
easy
A. inputAction.Run();
B. inputAction.Start();
C. inputAction.Activate();
D. inputAction.Enable();

Solution

  1. Step 1: Recall method names in New Input System

    The method to activate an input action is called Enable(), not Start(), Activate(), or Run().
  2. Step 2: Confirm syntax correctness

    inputAction.Enable(); is the correct syntax to enable the action.
  3. Final Answer:

    inputAction.Enable(); -> Option D
  4. Quick Check:

    Enable() activates input actions [OK]
Hint: Remember Enable() activates input actions [OK]
Common Mistakes:
  • Using Start() instead of Enable()
  • Confusing method names with Activate() or Run()
  • Forgetting parentheses after method name
3. Given this code snippet using the New Input System:
var moveAction = playerInput.actions["Move"];
moveAction.Enable();
var value = moveAction.ReadValue<Vector2>();
Debug.Log(value);

What does value represent?
medium
A. The current 2D vector input from the Move action
B. A boolean indicating if Move is pressed
C. The name of the Move action as a string
D. An integer representing Move action's ID

Solution

  1. Step 1: Understand ReadValue<Vector2>()

    This method reads the current input value as a Vector2, typically for movement directions.
  2. Step 2: Analyze the variable 'value'

    Since moveAction is enabled and ReadValue<Vector2>() is called, value holds the 2D input vector from the Move action.
  3. Final Answer:

    The current 2D vector input from the Move action -> Option A
  4. Quick Check:

    ReadValue<Vector2>() returns Vector2 input [OK]
Hint: ReadValue<Vector2>() returns 2D input vector [OK]
Common Mistakes:
  • Thinking it returns a boolean
  • Confusing value with action name or ID
  • Not enabling the action before reading
4. What is wrong with this code snippet using the New Input System?
var jumpAction = playerInput.actions["Jump"];
jumpAction.ReadValue<float>();
jumpAction.Enable();
medium
A. The action is read before it is enabled
B. ReadValue<float>() is not a valid method
C. The action name "Jump" is invalid
D. Enable() should be called twice

Solution

  1. Step 1: Check the order of method calls

    The code reads the input value before enabling the action, which means no input is active yet.
  2. Step 2: Understand correct usage

    Enable() must be called before reading values to get valid input data.
  3. Final Answer:

    The action is read before it is enabled -> Option A
  4. Quick Check:

    Enable() must come before ReadValue() [OK]
Hint: Always enable input action before reading values [OK]
Common Mistakes:
  • Reading input before enabling action
  • Assuming ReadValue<float>() is invalid
  • Thinking action names must be changed
5. You want to temporarily stop all player input during a cutscene using the New Input System. Which approach is best?
hard
A. Delete the input action asset during the cutscene
B. Set all input action callbacks to null
C. Call playerInput.actions.Disable() to disable all input actions
D. Ignore input values but keep actions enabled

Solution

  1. Step 1: Understand disabling input actions

    Calling Disable() on the actions disables all input reading cleanly and temporarily.
  2. Step 2: Evaluate other options

    Deleting assets is destructive, setting callbacks to null is error-prone, ignoring inputs wastes resources.
  3. Final Answer:

    Call playerInput.actions.Disable() to disable all input actions -> Option C
  4. Quick Check:

    Disable() cleanly stops input during cutscenes [OK]
Hint: Use Disable() to pause all inputs safely [OK]
Common Mistakes:
  • Deleting input assets instead of disabling
  • Nullifying callbacks causing errors
  • Ignoring inputs wastes CPU
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard