1D Vector composite with/New Unity Input System.

Suleiman Abdullah
3 min readFeb 16, 2023

--

Objective: 1D Vector composite with/New Unity Input System.

Before doing this create action assets and a player action map. then create an Input script and attach it to the Player game object.

In the first step, create a new action called Rotate, then select it <action property, change Action type to value, then change control type to an axis.

Note: When setting control type to axis means this Vector1.

Now select Rotate Action then right-click and choose Positive/Negative binding. This will create A vector1 binding which is called negative or positive binding.

Vector 1 was to be named AD but let's go.

In this step, I will create a reference off of the PlayerInputActions asset in my PlayerInput, then I will create an Instance for this PlayerInputActions asset. Then I will enable the Rotate Action.

In this step, I want to rotate my player to the left when I press A and rotate to the right when I press D. To do this I will use transform.Rotate inside this method I will pass Vector3.up which means rotating this object using the y-axis and multiplying Time.delta and rotation speed.

To get the ReadValue of Vector1, I will create a float variable called rotationDirection, then assign it to the read value of my rotation action. Last I will multiply it by our rotation speed.

If we play the editor like this, we will have the issue, if press A my player will rotate right and if I press D the player will rotate left.

To solve this Select our Action <process, hit plus button<add Invert, or you can select A Vector1(WSAD) <process, hit plus button<add Invert. Make sure you save the asset.

Let's play the editor.

See you in the next article.

--

--

Suleiman Abdullah

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