Converting Interactable Legacy Input to the New Unity Input System

Suleiman Abdullah
2 min readMar 23, 2023

--

Objective: Converting Interactable Legacy Input to the New Unity Input System.

Before doing anything create InputAction assets, then createAction map an action called Interact and two bindings.

I did not use Trigger Explosion binding to make the article easy to follow. Otherwise, I will need to hardcode zoneId for that binding.

In the first step, Initialize the Input Action Assets in the start method, enable it then create a performed event and canceled event function. I add the Start event in the end.

In the performed function I will move code to check if we are in the zone and if we press the E Key then I will remove the old input code with the context dot performed.

You do not need to use context to check if it's canceled or STarted since this event is checking that directly.

I will take the code to allow the user to press button and do some action according to that zone Id.

You do not need to use context to check if it's canceled or STarted since this event is checking that directly.

Then I will check if use the let go Key so I can cancel calling some logic for specific zone.

You do not need to use context to check if it's canceled or STarted since this event is checking that directly.

Let's see the Result

I use E to Detonate the C4

See you at the next one, Suleiman out.

--

--

Suleiman Abdullah
Suleiman Abdullah

Written by Suleiman Abdullah

Self taught Unity Developer, who is passion about making games ,and he loves Math For Game Development

No responses yet