Unity for Games Profile picture
The leading platform for creating immersive and interactive 2D, 3D, and VR games on 20+ platforms | Part of the @unity solutions portfolio 🚀 🎮

May 30, 2023, 12 tweets

#UnityTips 3:

Unity’s Newer Input System offers a ton of benefits over the old one, here are some cool reasons why you should be using the newer one 🧵

@samyam_youtube

The new system is built on Scriptable Objects. This means it is designed for modularity and ease of use.

You start by creating an Input Action Asset (1/11)

From there you can add Actions (like Moving, Jumping) and their Bindings, or the controls that trigger them.

It supports multiple bindings per action. (2/11)

It is Cross-Platform Compatible. As I mentioned above, there can be multiple bindings per action, and these bindings are tied to a control type (Keyboard, Mouse, Controller, etc.) (3/11)

Now you don’t have to write duplicate code to handle Keyboard vs Controller input, just add a new binding and it will automatically trigger the action for you when it detects the input! (4/11)

The Input System is event based with three main events, Started, Performed, and Canceled. Long gone are the days of manually checking everything in the Update() function. Just subscribe to the action’s event, and perform the logic when it’s called. (5/11)

Interactions and Processors!

Interactions let you decide when an action is triggered/performed.

Processors let you add some processing to the action like inverting the value before you read it. (6/11)

Composites are groups of bindings.

For example, you can make a Vector2 Composite where its X axis is [A] and [D], and its Y axis is [S] and [W], for the WASD keys. It will automatically return a Vector2 when one of those keys is pressed. (7/11)

Modifiers allow you to only trigger an action when more than one button is pressed. If you want the player to only perform an action when [E] and [Ctrl] are pressed, you can create a Button with One Modifier, assign the [E] to the button and the [Ctrl] to the Modifier. (8/11)

Now the action will only be performed once both are being pressed. (9/11)

Did I mention all of these are customizable? You can make your own types of Actions, Interactions, and Processors. That’s the power of the Input System. (10/11)

I have a whole playlist of videos on the Input System.

You can watch them here: youtube.com/playlist?list=… or follow me on @samyam_youtube for more tips! (11/11)

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling