![]() Also note, that you can access official courses and lessons directly from Unity Hub.This player movement controller script can be applied to your player object to gain movement control in a 2D platform world. 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. I especially recommend the Unity microgame tutorials if longer projects seem too daunting. I highly recommend you try some of the Unity tutorials to help familiarize yourself with C# and Unity. 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).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |