0% found this document useful (0 votes)
3 views

2D_Platformer_Dev_with_Coding_Stages

This document outlines the development process of a 2D platformer game called 'Shadow Leap' using Unity, covering aspects from conceptualization to deployment. It includes detailed sections on game design, player movement, enemy AI, collectibles, UI elements, and level design, along with C# code examples for each feature. The content is tailored for postgraduate learners interested in professional game development workflows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

2D_Platformer_Dev_with_Coding_Stages

This document outlines the development process of a 2D platformer game called 'Shadow Leap' using Unity, covering aspects from conceptualization to deployment. It includes detailed sections on game design, player movement, enemy AI, collectibles, UI elements, and level design, along with C# code examples for each feature. The content is tailored for postgraduate learners interested in professional game development workflows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Design and Development of a 2D Platformer Game Using Unity

This document details the full development lifecycle of a 2D platformer game titled 'Shadow
Leap' using Unity. It includes conceptualization, design, programming stages, C# code
examples, testing, and deployment strategies. The content is aimed at postgraduate-level
learners exploring professional game development workflows.

Game Concept and Planning


Define game genre, target audience, and gameplay features.

Create a Game Design Document (GDD) with storyline, levels, and characters.

Unity Project Setup


Create a new Unity 2D project.

Set up folders: Scripts, Scenes, Prefabs, Sprites, Audio.

Player Movement Script


Basic player movement is handled with Unity's physics system using Rigidbody2D.

C# Code Example:
```csharp
public class PlayerMovement : MonoBehaviour {
public float moveSpeed = 5f;
private Rigidbody2D rb;
private Vector2 movement;

void Start() {
rb = GetComponent<Rigidbody2D>();
}

void Update() {
movement.x = Input.GetAxisRaw("Horizontal");
movement.y = Input.GetAxisRaw("Vertical");
}

void FixedUpdate() {
rb.MovePosition(rb.position + movement * moveSpeed * Time.fixedDeltaTime);
}
}
```

Jump and Gravity Handling


Implement jump with Rigidbody2D velocity and add grounded check.
C# Code Example:
```csharp
public float jumpForce = 10f;
public Transform groundCheck;
public LayerMask groundLayer;
private bool isGrounded;

void Update() {
isGrounded = Physics2D.OverlapCircle(groundCheck.position, 0.1f, groundLayer);
if (Input.GetButtonDown("Jump") && isGrounded) {
rb.velocity = new Vector2(rb.velocity.x, jumpForce);
}
}
```

Enemy AI (Simple Patrol)


Add patrol logic for basic enemy movement.

C# Code Example:
```csharp
public class EnemyPatrol : MonoBehaviour {
public Transform pointA, pointB;
public float speed = 2f;
private Vector3 target;

void Start() {
target = pointB.position;
}

void Update() {
transform.position = Vector3.MoveTowards(transform.position, target, speed *
Time.deltaTime);
if (transform.position == pointB.position) target = pointA.position;
else if (transform.position == pointA.position) target = pointB.position;
}
}
```

Collectibles and Score System


Add collectible objects and update the score.

C# Code Example:
```csharp
public class Collectible : MonoBehaviour {
void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("Player")) {
ScoreManager.instance.AddScore(10);
Destroy(gameObject);
}
}
}
```

UI: Health Bar and Score


Display player health and score on screen using Unity UI.

C# Code Example:
```csharp
public class ScoreManager : MonoBehaviour {
public static ScoreManager instance;
public Text scoreText;
private int score = 0;

void Awake() {
instance = this;
}

public void AddScore(int value) {


score += value;
scoreText.text = "Score: " + score.ToString();
}
}
```

Main Menu and Game Over


Use Unity's UI system to create a main menu and handle game over screen.

Level Design
Use Unity Tilemap system to design multiple platformer levels with obstacles and hazards.

Testing and Debugging


Playtest all features and fix issues using Unity Console and Debug.Log statements.

Deployment and Build


Build settings for PC, Android or WebGL export.

You might also like