Skip to content Skip to sidebar Skip to footer

Create Stunning Vertical Shoot 'Em Up for Mobile with Unity

Create Stunning Vertical Shoot 'Em Up for Mobile with Unity

Ready to take your game development skills to the next level? Join us in this exciting course where we will teach you how to create a fully functional Shoot Em 

Enroll Now

Creating a stunning vertical shoot 'em up (shmup) game for mobile with Unity is an exciting and rewarding project. Unity's versatility and extensive toolset make it ideal for developing engaging and visually appealing mobile games. In this guide, we'll walk through the essential steps to create a vertical shoot 'em up game, covering game design, asset creation, coding, and optimization for mobile devices.

Game Design

Before diving into Unity, it's crucial to outline the game's design. A vertical shoot 'em up typically involves the player controlling a spaceship or aircraft that moves vertically, shooting enemies and avoiding obstacles. The key elements to consider are:

  1. Player Ship: The main character the player controls. It should have movement, shooting capabilities, and potentially power-ups or special abilities.
  2. Enemies: Various types of enemy ships or objects that challenge the player. These can have different behaviors, patterns, and difficulty levels.
  3. Power-ups: Items that enhance the player's abilities, such as improved weapons, shields, or speed boosts.
  4. Levels: Different stages or waves of enemies that increase in difficulty. Each level should have a unique design and layout.
  5. UI Elements: Score, lives, health bars, and other interface elements that provide essential feedback to the player.

Setting Up Unity

  1. Install Unity: Make sure you have the latest version of Unity installed. You can download it from the Unity website.
  2. Create a New Project: Open Unity Hub and create a new 2D project. Name it something appropriate, like "VerticalShmup".
  3. Organize the Project: Set up your project folders for better organization. Common folders include Assets, Scripts, Scenes, Prefabs, Sprites, and UI.

Creating Assets

You'll need various assets for your game, including sprites for the player ship, enemies, bullets, power-ups, and background. You can create these assets using graphic design software like Adobe Photoshop, GIMP, or Aseprite. Alternatively, you can find free or paid assets online.

  1. Player Ship: Design a simple yet visually appealing spaceship. Save it as a PNG file with a transparent background.
  2. Enemies: Create multiple enemy sprites with different designs and colors to add variety.
  3. Bullets: Design bullet sprites for both the player and enemies.
  4. Power-ups: Create distinct icons for different power-ups.
  5. Background: Design a scrolling background that gives the illusion of movement.

Implementing the Player Ship

  1. Import Assets: Import your player ship sprite into Unity by dragging it into the Sprites folder.
  2. Create Player Object: In the Hierarchy window, right-click and create a new Sprite object. Assign your player ship sprite to it.
  3. Add Components: Attach necessary components to the player object, such as a Rigidbody2D for physics and a BoxCollider2D for collision detection.
  4. Movement Script: Create a new script named PlayerMovement and attach it to the player object. Here's a simple movement script:
using UnityEngine; public class PlayerMovement : MonoBehaviour { public float speed = 5f; void Update() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector2 position = transform.position; position.x += horizontal * speed * Time.deltaTime; position.y += vertical * speed * Time.deltaTime; transform.position = position; } }

Shooting Mechanism

  1. Bullet Prefab: Create a bullet sprite and turn it into a prefab by dragging it into the Prefabs folder.
  2. Shooting Script: Create a new script named PlayerShooting and attach it to the player object. This script will handle shooting bullets.
using UnityEngine; public class PlayerShooting : MonoBehaviour { public GameObject bulletPrefab; public float bulletSpeed = 10f; public float fireRate = 0.5f; private float nextFireTime = 0f; void Update() { if (Input.GetButton("Fire1") && Time.time > nextFireTime) { Shoot(); nextFireTime = Time.time + fireRate; } } void Shoot() { GameObject bullet = Instantiate(bulletPrefab, transform.position, Quaternion.identity); Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>(); rb.velocity = Vector2.up * bulletSpeed; } }

Enemy Implementation

  1. Enemy Prefab: Import enemy sprites and create prefabs for each type.
  2. Enemy Movement and Behavior: Create a script named Enemy and attach it to the enemy prefabs. This script will handle enemy movement and behavior.
using UnityEngine; public class Enemy : MonoBehaviour { public float speed = 2f; public int health = 3; void Update() { transform.Translate(Vector2.down * speed * Time.deltaTime); if (transform.position.y < -5f) { Destroy(gameObject); } } void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet")) { health--; Destroy(collision.gameObject); if (health <= 0) { Destroy(gameObject); } } } }

Spawning Enemies

  1. Enemy Spawner: Create an empty GameObject in the scene named EnemySpawner. Create a script named EnemySpawner and attach it to this object.
using UnityEngine; public class EnemySpawner : MonoBehaviour { public GameObject[] enemyPrefabs; public float spawnRate = 2f; private float nextSpawnTime = 0f; void Update() { if (Time.time > nextSpawnTime) { SpawnEnemy(); nextSpawnTime = Time.time + spawnRate; } } void SpawnEnemy() { int randomIndex = Random.Range(0, enemyPrefabs.Length); Vector2 spawnPosition = new Vector2(Random.Range(-2.5f, 2.5f), transform.position.y); Instantiate(enemyPrefabs[randomIndex], spawnPosition, Quaternion.identity); } }


  1. Power-up Prefabs: Create and import power-up sprites. Create prefabs for each type of power-up.
  2. Power-up Script: Create a script named PowerUp and attach it to the power-up prefabs.
using UnityEngine; public class PowerUp : MonoBehaviour { public enum PowerUpType { Shield, Speed, Weapon } public PowerUpType powerUpType; public float duration = 5f; void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { // Apply the power-up effect based on its type Destroy(gameObject); } } }

Background Scrolling

  1. Background Setup: Import your background sprite and create a new GameObject named Background.
  2. Scrolling Script: Create a script named BackgroundScroller and attach it to the background object.
using UnityEngine; public class BackgroundScroller : MonoBehaviour { public float scrollSpeed = 0.5f; private Vector2 offset; void Update() { offset = new Vector2(0, Time.time * scrollSpeed); GetComponent<Renderer>().material.mainTextureOffset = offset; } }

UI Elements

  1. Score and Health: Create UI elements for the score, health, and other necessary information. Use Unity's UI system to design these elements.
  2. UI Script: Create a script named GameUI to handle updating the UI elements.
using UnityEngine; using UnityEngine.UI; public class GameUI : MonoBehaviour { public Text scoreText; public Text healthText; private int score = 0; private int health = 3; void Update() { scoreText.text = "Score: " + score; healthText.text = "Health: " + health; } public void AddScore(int value) { score += value; } public void UpdateHealth(int value) { health += value; } }

Optimization for Mobile

  1. Performance: Optimize your game for mobile by reducing the number of draw calls, using sprite atlases, and minimizing the use of expensive operations.
  2. Input: Use Unity's Input system to handle touch controls. Modify the player movement script to respond to touch input.
void Update() { if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Vector2 touchPosition = Camera.main.ScreenToWorldPoint(touch.position); transform.position = Vector2.Lerp(transform.position, touchPosition, speed * Time.deltaTime); } }

Final Steps

  1. Testing: Test your game thoroughly on various mobile devices to ensure it runs smoothly and is free of bugs.
  2. Build and Publish: Once you're satisfied with your game, use Unity's build settings to create a build for Android or iOS. Follow the necessary steps to publish your game on the Google Play Store or Apple App Store.

Creating a vertical shoot 'em up game in Unity involves a combination of design, asset creation, coding, and optimization. By following this guide, you'll be well on your way to developing a fun and engaging mobile game. Happy developing!

Online Course CoupoNED based Analytics Education Company and aims at Bringing Together the analytics companies and interested Learners.