Set up player movement in Unity3D

We will create a null object and have that be our _startingposition gameobject. I’m also going to have my ship mesh lerp toward the main parent object to create a smooth moving gameobject. For my game, I’m going to have my ship snap to the starting position whenever the game begins.

We then give our player a quick test to verify the movement of our ship. To do this, we want to add a transform.translate, move it to the right, apply it to time.deltatime, and provide a speed variable to make adjustments.

Now let’s go ahead and map the user inputs to this player. We will use the input manager.

This will allow us to move the ship on a horizontal and vertical axis based on our input. I also want to adjust the rotation of my ship. Let’s have a little fun with this. I created a empty game object called _shiprotation and based on the float value of my horizontal input, the rotation of that null changes. Now I make my ship mesh rotate via lerp to the _shiprotation gameobject to achieve that smooth movement.

Now the ship flies smoothly and rotates as well!

--

--

--

Unity Developer and Software Engineer who loves making games with GameDevHQ

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Oracle Always Free Cloud instances in HA configuration

FOSDEM: More Popular Than Ever

What makes the best software developers in the world?

Transforming With DevSecOps (Nov 4, 2020)

Emerging Trends in DotNet

I built an app at the AutomobilityLA ‘17 Hackathon, and left proud to be Angeleno.

David Koberlein’s Agenda For Rick And Morty Doxxed (Not Dev Team Agenda)

CS373 Spring 2021 Final Entry: Vincent Huynh

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
Al Heck

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ

More from Medium

Replay: How Blockchain Game Yohero achieved an 11-day payback period

A step back into the past, with an eye to the future with an old friend

Welcome to Multiverse Capital $MVC

Merchant guide — Accepting Crypto Payments!