Skip to content

aadityaa29/Unity-Game

Repository files navigation

Unity 3D Platformer Game

A complete 3D platformer game created in Unity featuring player movement, collectibles, moving platforms, and comprehensive game mechanics.

🎮 Features

  • 3D Player Movement: WASD movement with space bar jumping and CharacterController physics
  • Third-Person Camera: Mouse look with smooth camera controls
  • Collectible System: Rotating coins with bob animations and sound effects
  • Moving Platforms: Platforms that move between waypoints with player attachment
  • Game Timer: 3-minute gameplay sessions with countdown
  • Score System: Collect items to increase score and win condition
  • Pause Menu: Press P or Escape to pause/resume
  • Complete UI: Score display, timer, game over screens
  • Automatic Level Generator: LevelEditor script for quick scene setup

🚀 Quick Start

  1. Clone this repository
  2. Open Unity Hub and click "Add project from disk"
  3. Select the project folder
  4. Open in Unity 2022.3.7f1 or later
  5. Use LevelEditor script for automatic level generation, OR
  6. Follow manual setup instructions below
  7. Press Play to start the game!

📋 Game Scripts Overview

PlayerController.cs

  • Character movement using Unity's CharacterController
  • Ground detection and jumping mechanics
  • WASD movement with gravity simulation
  • Mouse look integration for camera-relative movement

CameraController.cs

  • Third-person camera that smoothly follows the player
  • Mouse control for horizontal and vertical rotation
  • Configurable sensitivity and angle limits
  • Cursor lock/unlock functionality

Collectible.cs

  • Rotating collectible items with visual appeal
  • Smooth bobbing animation using sine waves
  • Sound effects and particle effects support
  • Automatic score integration with GameManager

GameManager.cs

  • Central game state management
  • Score tracking and win/lose conditions
  • Timer system with formatted display
  • Pause functionality and game restart
  • UI management for all game screens

MovingPlatform.cs

  • Platforms that move between configurable waypoints
  • Player attachment system for realistic platform riding
  • Customizable movement speed, wait times, and patterns
  • Visual gizmos for waypoint debugging

LevelEditor.cs

  • Automatic level generation tool
  • Creates complete playable scenes with one click
  • Generates player, platforms, collectibles, UI, and game manager
  • Perfect for rapid prototyping and testing

🔧 Setup Instructions

Option 1: Automatic Setup (Recommended)

  1. Create an empty GameObject named "LevelGenerator"
  2. Add the LevelEditor script to it
  3. Right-click the script in Inspector
  4. Select "Generate Basic Level" from context menu
  5. Everything will be created automatically!

Option 2: Manual Setup

Player Setup:

  1. Create Capsule GameObject, rename to "Player"
  2. Add tag "Player" to the GameObject
  3. Remove Capsule Collider, add CharacterController
  4. Add PlayerController script
  5. Set position to (0, 2, 0)

Camera Setup:

  1. Select Main Camera
  2. Add CameraController script
  3. Drag Player object to "Target" field

Ground/Platforms:

  1. Create Cube GameObjects for platforms
  2. Set layer to "Ground" (create if needed)
  3. Add MovingPlatform script for moving platforms
  4. Position at various heights

Collectibles:

  1. Create Cylinder GameObjects
  2. Scale to (0.8, 0.3, 0.8)
  3. Enable "Is Trigger" on Collider
  4. Add Collectible script
  5. Distribute around the level

Game Manager & UI:

  1. Create empty GameObject named "GameManager"
  2. Add GameManager script
  3. Create UI Canvas with Text elements for score/timer
  4. Assign UI elements to GameManager script

🎯 Controls

  • WASD / Arrow Keys: Move player
  • Space: Jump
  • Mouse: Look around / Camera control
  • P / Escape: Pause/Resume game
  • R: Restart game
  • Escape: Toggle cursor lock

🛠️ Customization Options

Player Movement:

  • Adjust moveSpeed, jumpForce, and gravity in PlayerController
  • Modify ground detection distance and layer mask

Camera Feel:

  • Change mouseSensitivity and angle limits in CameraController
  • Adjust smoothSpeed for camera follow responsiveness

Game Settings:

  • Modify gameTime and totalCollectibles in GameManager
  • Customize collectible animations and effects
  • Add new platform movement patterns

Visual Enhancement:

  • Create materials in Assets/Materials folder
  • Add particle effects for collectibles
  • Implement sound effects and background music

🏗️ Build Instructions

  1. Go to File > Build Settings
  2. Add Open Scenes to include your game scene
  3. Select target platform (PC, Mac, Linux, etc.)
  4. Configure Player Settings if needed
  5. Click Build and choose output folder
  6. Run the executable to play your game!

📁 Project Structure

Unity-Game/
├── Assets/
│   ├── Scenes/
│   │   ├── MainGame.unity
│   │   └── GameScene.unity
│   ├── Scripts/
│   │   ├── PlayerController.cs
│   │   ├── CameraController.cs
│   │   ├── Collectible.cs
│   │   ├── GameManager.cs
│   │   ├── MovingPlatform.cs
│   │   └── LevelEditor.cs
│   ├── Materials/ (for your custom materials)
│   └── Prefabs/ (for reusable game objects)
├── ProjectSettings/ (Unity configuration)
├── README.md
├── UNITY_SETUP_GUIDE.md
└── .gitignore

🎲 Game Objective

Goal: Collect all coins within the 3-minute time limit!

  • Navigate through platforms using WASD movement
  • Jump between platforms with precise timing
  • Use moving platforms to reach higher areas
  • Collect all rotating coins to win the game
  • Beat the clock for the ultimate challenge!

⚙️ Technical Requirements

  • Unity Version: 2022.3.7f1 or later (LTS recommended)
  • Platform: Windows, Mac, or Linux
  • Dependencies: Standard Unity 3D project packages
  • Input System: Unity Legacy Input Manager
  • Physics: Unity 3D Physics with CharacterController

🐛 Troubleshooting

Player falls through ground:

  • Ensure platforms have "Ground" layer assigned
  • Check PlayerController groundMask includes "Ground" layer

Camera doesn't follow:

  • Verify CameraController target is assigned to Player
  • Check Player GameObject is active in scene

Collectibles don't register:

  • Confirm Collider "Is Trigger" is enabled
  • Verify Player has "Player" tag assigned
  • Check Collectible script is attached

Scripts show as missing:

  • Ensure all scripts are in Assets/Scripts folder
  • Wait for Unity to finish importing scripts
  • Check Console window for compilation errors

🚀 Future Enhancements

  • Add enemies and combat mechanics
  • Implement multiple levels and progression
  • Add power-ups and special abilities
  • Create main menu and level selection
  • Add achievements and leaderboards
  • Implement save/load functionality
  • Add visual and audio polish

Enjoy building and playing your Unity 3D Platformer Game! 🎮✨

Feel free to modify, extend, and make it your own. Happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published