Player Input System

Is the method of creating the input system a better way than just attaching the component Player Input to the player gameobject itself and then use OnMove from the player controller that Unity will generate from that component? I remember from another course that it was done in a different way, are there any differences here or is it just a personal preference on how to implement it?

Welcome to the community!

Well personally I would do this

Public float horizontalInput
Public float speed = 10f;

Void update ()
{

horizontalInput = Input.GetAxis(“Horizontal”);

transform.Translate(Vector3.right * horizontalInput * Time.deltaTime * speed);

}

This script is then attached to what you want moved

What this does is return a value for horizontalInput between 0 and 1, and then multiplied it to Vector3.right, to make the character go left and right, this allows you to use the left and right arrow keys to go left and right, the same thing can be done up and down.

This is what I do for a simple project, for an advanced one, I suggest getting familiar with the input system.

I can always code up a project and show you as an example with a screen shot.

Hope this helps!

The input system in unity is being changed since the old legacy system but you can still use both.
In fact due to an oversight on Stephen’s part later on he uses the old input system to get the mouse position.
Its worth getting used to the newer input system as that will become the standard in the future.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms