0
0
Unityframework~30 mins

New Input System overview in Unity - Mini Project: Build & Apply

Choose your learning style9 modes available
New Input System overview
📖 Scenario: You are creating a simple Unity project to understand how the New Input System works. This system helps your game detect player actions like moving or jumping in a clean and flexible way.
🎯 Goal: Build a basic Unity script that sets up the New Input System to read player movement input and print the movement direction.
📋 What You'll Learn
Create an InputAction asset with a 'Move' action
Set up a Vector2 variable to store movement input
Write a method to read the 'Move' input value
Print the movement input direction when it changes
💡 Why This Matters
🌍 Real World
Game developers use the New Input System in Unity to handle player controls cleanly and support multiple devices like keyboard, gamepad, and touch.
💼 Career
Understanding the New Input System is essential for Unity game developers to create responsive and flexible player input handling.
Progress0 / 4 steps
1
Create InputAction asset with 'Move' action
Create an InputAction asset called playerInputActions with a Move action of type Value and control type Vector2.
Unity
Need a hint?

Use Unity's InputAction class to define a 'Move' action with type Value and Vector2 control.

2
Add Vector2 variable to store movement input
Add a Vector2 variable called movementInput to store the player's movement direction.
Unity
Need a hint?

Declare a public Vector2 variable named movementInput inside the PlayerController class.

3
Read 'Move' input value in Update method
In the PlayerController class, write an Update() method that reads the Move action's current value into movementInput using ReadValue<Vector2>().
Unity
Need a hint?

Inside Update(), assign movementInput by calling playerInputActions.Move.ReadValue<Vector2>()

4
Print movement direction when input changes
Add a Debug.Log statement inside Update() to print the current movementInput value whenever it changes.
Unity
Need a hint?

Use Debug.Log to print the movementInput value inside Update().