Everdevs Community
Published in

Everdevs Community

“Funslingers” Devblog #1 | Simple Character Movement In Unity

Hey Devs!

We‘re gonna kick this thing off with a fast and dirty prototype to get all our basic features and functionalities working for our game. We MUST do that before we get into ANY nitty gritty details. So, our first step in making this game will be to get my character to make their first steps as well. (even if that character is a cube with no legs)

Meet Cubert! He’s our adorable little cube friend, he may not look like much, but he is gonna take us from square one (pun intended), all the way to square one-hundred and beyond!

Part 1:

Start Position

So before we get moving, we need to establish a start position for Cubert, that way no matter where I leave him in our scene, when the game starts he will always be exactly where we want him.

To do this all we need to do is get the position coordinates from the transform that I want him to start in.

I want Cubert to sit right at the bottom of our camera angle, so this current position is:

(0, 1, -7.5)!

Great! Now we just have to create our Player script, attach it to Cubert, set Cubert’s transform.position to the position that we want and put it in the Start method.

Can’t get easier than that!

Part 2:

Character Movement

Now it’s time we get Cubert up and running!

My favorite method of Character Movement is with physics! Which means Cubert is gonna get himself his very own Rigidbody! We’ll turn off gravity for now since I have no plans for Cubert to start jumping around.

Next we are gonna need to translate player input to Cubert moving around the screen. All we need to do is get a reference to Cubert’s Rigidbody, access an Input Axis, and then happily marry the two for character movement!

So simple and yet so effective, let’s see how Cubert reacts to these new legs!

Look at little Cubert go! Not bad for just a few lines of code! But it feels really choppy (that’s not just the gif) and I’m gonna want to be able to control Cubert’s speed so let’s add that now.

It’s as simple as that! Throw in some Time.fixedDeltaTime too and we should have smooth, responsive, and most of all EASY character movement!

Next Devblog we’re gonna give Cubert a gun!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ethan Bristowe

Ethan Bristowe

Passionate self taught game developer excited to learn and share everything I can about game development!