This is a kind of game that can be found in various indie game projects. Just like every indie game, 2D platformer movement is easy to make!
This video will help you make a small game scene that will be controlled by a character made of sprites. The character design process takes part of a specific video. You can customize it as you want, but I recommend you create the scene that I did in this video. Unity Game Development is my dream, I will make more videos in no time!
In this video, I will teach you how to make a 2D platformer in Unity. After completing the 3D series, it is time for a small 2D platformer tutorial series. First, it is a super easy-to-follow video that will show you everything you need for a stunning 2D platformer movement in Unity. Furthermore, any similar video will cover the basic movement script, that will soon be available on my website. This video is also a perfect entry for the future of 2D game development.
Also, C# programming is something I like to do, so this video contains some C# lines that you should know about. Movement Script in C# is a perfect example of what you can make as a beginner in Unity.
Lastly, I have been making a break of Unity tutorials and it is time to do something new: 2D platformer that I used to work on last month. I was at my summer holiday so I was not doing anything for my channel, I was taking a break. The assets (for 2D platformer movement project) will be available to download.
DOWNLOAD THE ASSETS!
These assets are for the 2D platformer project. You can add them into any educational purpose video!
Therefore, all you have to do is to unzip the archive and copy the assets in a separate folder, then in Unity you should right click and select Import Assets. Additionally, all assets should be Sprite (2D and UI) and sprite mode has to be Multiple. Any multiple sprites have to be sliced and then you can have a sprite sheet from a single image, rather than importing multiple images at once. The 2D platformer script for player movement is defined in this preformatted text format:
public class PlayerMovement : MonoBehaviour { private Rigidbody2D rb; private BoxCollider2D coll; private Animator anim; private SpriteRenderer spr; private float direction = 0f; [SerializeField] private LayerMask groundLayers; [SerializeField] private float moveSpeed = 7f; [SerializeField] private float jumpSpeed = 6f; private enum StateAnimation { idle, run, jump, falling } // Start is called before the first frame update void Start() { rb = GetComponent<Rigidbody2D>(); coll = GetComponent<BoxCollider2D>(); anim = GetComponent<Animator>(); spr = GetComponent<SpriteRenderer>(); } // Update is called once per frame void Update() { direction = Input.GetAxisRaw("Horizontal"); rb.velocity = new Vector2(direction * moveSpeed, rb.velocity.y); if (Input.GetButtonDown("Jump") && IsGrounded()) { rb.velocity = new Vector2(rb.velocity.x, jumpSpeed); } StateAnimation state; if(direction > 0f) { //anim.SetBool("isRunning", true); state = StateAnimation.run; spr.flipX = false; } else if(direction < 0f) { state = StateAnimation.run; spr.flipX = true; } else { //anim.SetBool("isRunning", false); state = StateAnimation.idle; } if(rb.velocity.y > .1f) { //anim.SetBool("isJumping", true); state = StateAnimation.jump; } else if (rb.velocity.y < -.1f) { //anim.SetBool("isJumping", false); state = StateAnimation.falling; } anim.SetInteger("state", (int)state); } bool IsGrounded() { return Physics2D.BoxCast(coll.bounds.center, coll.bounds.size, 0f, Vector2.down, .1f, groundLayers); } }
The animation part will be covered in the next video. It will be explained with more details! If you want to continue making your own game, stay tuned to the next blog post from the Creator!
No responses yet