Simple 2d Movement in Unity

Chandler Lane
May 23, 2022

--

We’re going to be using the Old Input system for this. I find it convenient for quick prototyping.

first, We’re going to start out by serializing a speed variable that we can adjust from the editor.

Easy enough. Now, for the meat and potatoes. We need to access the vertical and horizontal input so we can use that in our movement calculations.

We’ll put this in update for now, but it will be moved to its own method later on.

Now for the movement calculations.

The Translate() method is the main player here. We move based on the input and speed and the movement is smoothed out by using Time.deltaTime. Super easy!

This is a caveman method. There are definitely more advanced ways of doing this using the new Input System, but the core fundamentals are still there.

--

--

Chandler Lane
Chandler Lane

Written by Chandler Lane

Unity Developer - Professional Actor

No responses yet