Link Search Menu Expand Document

Platformer Extras

Adding Graphics to Your Game

Try adding your own graphics to your Assets folder (bottom window in Unity) and then adding them to the “Sprite” property of your Player or to your Ground Tilemap.

Falling to Death + Respawn

In your PlayerController.cs script, try adding an if statement to your void FixedUpdate() method. The if statement will reload the Scene if the player falls below a certain y position.

// Add this to the top of your file
using UnityEngine.SceneManagement;

// Add this to the bottom of your FixedUpdate method
if (transform.position.y < -5) {
    // Reload the Scene if you get below -5 (or whatever y position you determine)
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

Die on Collision + Respawn

  1. Add a GameObject that represents an enemy.
  2. Give it an “Enemy” tag.
  3. Add this to your void OnCollisionEnter2D(Collision2D collision) method in your PlayerController.cs script.
if (collision.gameObject.tag == "Enemy") {
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

Timer

Visit this page for a tutorial on how to make an in-game timer for your platformer.

Add another Tilemap

Add another tilemap that either doesn’t have collision or is tagged as “Wall” instead of Ground so that your Player can’t jump off it.

Make it Bouncier

Prevents wall jumping a little better.