

The code is properly commented for ease of use for everyone and is beginner friendly. The asset pack is completely tweak-able and provides you the freedom to test different parameters for different game feel. To get a feel of the script we've also provided a demo scene to test out the correct parameters for your games. This movement script will get you up and running with your project in no-time and will give you the freedom to start testing your ideas as soon as you hook them up with your graphics assets. Also note, that you can access official courses and lessons directly from Unity Hub.The "Basic Platformer Movement Script" Unity asset helps you start your Platformer games without writing the movement script from scratch. It will give you a crash course in the basics and you'll finish the courses with a collection of games you can modify yourself. Feel free to call the script whatever makes sense to you. Inside of the Scripts folder we will create a new C script named CharacterMovement.


I especially recommend the Unity microgame tutorials if longer projects seem too daunting. Create the Top Down Movement Script To start our movement script, we will create a project folder in Unity named Scripts to hold all of our script files. I highly recommend you try some of the Unity tutorials to help familiarize yourself with C# and Unity. MoveWithWASD.cs This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. You will need to fine tune how the character moves to what you want in your game. This approach is by no means perfect, or even good. If you want to be sure you understand how this works, try adding vertical movement in yourself, the code is very similar to what I've written here (even if you don't need vertical movement its good for practice). Transform.position = new Vector2( - (speed * ltaTime), ) Transform.localScale = new Vector3(-1, 1, 1) Transform.position = new Vector2( + (speed * ltaTime), ) Įlse if (Input.GetAxis("Horizontal") < -0.01f) You want to edit transform.position of the GameObject (the location of your object).Īssuming that this is a 2D project, for basic horizontal movement you can do the following: using System.Collections

Right now, your code is just changing what direction the player faces since you're editing transform.localScale (how big the object is / what direction your object faces).
