{"id":106,"date":"2025-10-12T05:31:06","date_gmt":"2025-10-12T05:31:06","guid":{"rendered":"https:\/\/blackhatseomaster.com\/?p=106"},"modified":"2025-10-12T05:58:49","modified_gmt":"2025-10-12T05:58:49","slug":"creating-a-simple-platformer-game-with-unity-c","status":"publish","type":"post","link":"https:\/\/blackhatseomaster.com\/en-in\/creating-a-simple-platformer-game-with-unity-c\/","title":{"rendered":"Creating a Simple Platformer Game with Unity (C#)"},"content":{"rendered":"<p>Learn how to make a classic 2D platformer with Unity and C#, including player movement, jumping, and collisions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Full Blog:<\/h3>\n\n\n\n<p>Platformers like <em>Mario<\/em> are timeless. With Unity, creating one isn\u2019t as hard as it looks.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Set Up the Scene<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a 2D project.<\/li>\n\n\n\n<li>Add a <code>Player<\/code> sprite and <code>Ground<\/code> tile.<\/li>\n\n\n\n<li>Add <code>Rigidbody2D<\/code> and <code>BoxCollider2D<\/code> to both.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Player Movement Script<\/h4>\n\n\n\n<p>Create <code>PlayerMovement.cs<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using UnityEngine;\n\npublic class PlayerMovement : MonoBehaviour {\n    public float speed = 5f;\n    public float jumpForce = 7f;\n    private Rigidbody2D rb;\n    private bool isGrounded;\n\n    void Start() {\n        rb = GetComponent&lt;Rigidbody2D&gt;();\n    }\n\n    void Update() {\n        float move = Input.GetAxis(\"Horizontal\");\n        rb.velocity = new Vector2(move * speed, rb.velocity.y);\n\n        if (Input.GetButtonDown(\"Jump\") &amp;&amp; isGrounded) {\n            rb.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);\n        }\n    }\n\n    void OnCollisionEnter2D(Collision2D collision) {\n        if (collision.gameObject.CompareTag(\"Ground\")) {\n            isGrounded = true;\n        }\n    }\n\n    void OnCollisionExit2D(Collision2D collision) {\n        if (collision.gameObject.CompareTag(\"Ground\")) {\n            isGrounded = false;\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Adding Obstacles and Goals<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add enemies as prefabs with colliders.<\/li>\n\n\n\n<li>Detect collision to reduce health or restart level.<\/li>\n\n\n\n<li>Add a coin or goal object for level completion.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Step 4: Polish the Game<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add background music<\/li>\n\n\n\n<li>Include animations with Animator Controller<\/li>\n\n\n\n<li>Add UI for score and lives.<\/li>\n<\/ul>\n\n\n\n<p>\u2705 <strong>Key Takeaways:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Unity simplifies physics and collisions.<\/li>\n\n\n\n<li>Platformers rely heavily on movement, collision, and timing.<\/li>\n\n\n\n<li>You can easily extend this to a full game.<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Learn how to make a classic 2D platformer with Unity and C#, including player movement, jumping, and collisions. Full Blog: Platformers like Mario are timeless. With Unity, creating one isn\u2019t as hard as it looks. Step 1: Set Up the Scene Step 2: Player Movement Script Create PlayerMovement.cs: Step 3: Adding Obstacles and Goals Step &#8230; <a title=\"Creating a Simple Platformer Game with Unity (C#)\" class=\"read-more\" href=\"https:\/\/blackhatseomaster.com\/en-in\/creating-a-simple-platformer-game-with-unity-c\/\" aria-label=\"Read more about Creating a Simple Platformer Game with Unity (C#)\">Read more<\/a><\/p>","protected":false},"author":1,"featured_media":107,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,15],"tags":[],"class_list":["post-106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-game-codes","category-latest"],"_links":{"self":[{"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":1,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/posts\/106\/revisions\/108"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/media\/107"}],"wp:attachment":[{"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blackhatseomaster.com\/en-in\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}