Skip to content

carlitodavis/ApplePicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apple Picker – Unity (C#)

An enhanced version of the classic Apple Picker made in Unity using 3D physics.
Catch apples with a basket, play through 4 rounds (based on remaining baskets), and use a start screen and game-over UI with restart.


Features

  • Start Screen with Start button (game is paused until pressed).
  • 4 Baskets (lives) managed by ApplePicker.
  • Rounds UI (Round 1 → Round 4), switches to Game Over when all baskets are gone.
  • Restart Button on Game Over.
  • High Score tracking and on-screen Score Counter.
  • Uses 3D physics (Rigidbody, Collider) — not 2D.

Project Structure (scripts)

Assets/
  Scripts/
    Apple.cs
    ApplePicker.cs
    AppleTree.cs
    Basket.cs
    GameMan.cs
    HighScore.cs
    ScoreCounter.cs
    StartGame.cs

What each script does

  • Apple.cs – When an apple falls below bottomY, destroys itself and calls ApplePicker.AppleMissed().
  • ApplePicker.cs – Creates 4 baskets at start, removes one when an apple is missed, and informs GameMan to update the round / show Game Over.
  • AppleTree.cs – Spawns apples at intervals while moving left/right across the screen.
  • Basket.cs – Follows the mouse horizontally; scores points when colliding with apples.
  • GameMan.cs – UI & state: round label, game-over panel, optional reason text, restart scene, optional pause on game over.
  • HighScore.cs – Persistent high score using PlayerPrefs.
  • ScoreCounter.cs – Displays the current score.
  • StartGame.cs – Shows start panel and pauses game until Start is clicked.

Scenes & UI

Scenes

  • Game Scene – Main play scene (contains AppleTree, GameMan, Canvas, etc.).

UI Elements (in your Canvas)

  • Round Label (TMP): Center top; bound to GameMan.roundLabel.
  • Game Over Panel: Hidden at start; enable on game over; contains Restart button calling GameMan.RestartCurrentScene().
  • Score Counter (TMP): Displays score.
  • Start Panel: Visible at launch; Start button calls StartGame.OnStartClicked().

Prefabs & Tags

Create or verify these prefabs and tags:

Tags (Edit → Project Settings → Tags and Layers)

  • Apple, Basket, Ground

Apple (Prefab)

  • Rigidbody (3D): Use Gravity = ON; Collision Detection = Continuous Dynamic; Interpolate = Interpolate.
  • Collider (3D): Sphere/Box; Is Trigger = OFF (simplest).
  • Tag: Apple

Basket (Scene object or Prefab)

  • Collider (3D): Box/Mesh; Is Trigger = OFF (for standard collisions).
  • Tag: Basket

Ground (Scene object)

  • A plane/cube with a Collider (3D) near the bottom to catch/stop apples visually.
  • Tag: Ground (optional for scripting since Apple.cs uses bottomY).

Inspector Wiring

GameMan (in scene)

  • roundLabel → TMP text at top center.
  • gameOverPanel → your panel (inactive at start).
  • gameOverReasonText → (optional) TMP under panel.
  • pauseOnGameOvertrue (recommended).

AppleTree (in scene)

  • applePrefab → Apple prefab.
  • appleDropDelay → spawn rate (e.g., 1.0 sec).
  • speed, leftAndRightEdge, changeDirChance → movement behavior.

StartGame (in scene)

  • startPanel → your panel shown on load.
  • Start button → OnClick → StartGame.OnStartClicked().

Controls

  • Mouse: Move the basket horizontally (follows mouse X).
  • Catch Apples to score.
  • Missing apples removes a basket; when all baskets are gone → Game Over.

Build & Run

  1. File → Build Settings…
  2. Add your main scene(s) to Scenes in Build.
  3. Choose platform (PC/Mac/Linux Standalone, etc.).
  4. Build or Build and Run.

GitHub Setup (recommended)

  1. Unity Editor Settings:
    • Version Control: Visible Meta Files
    • Asset Serialization: Force Text
  2. Add a Unity .gitignore (ignore Library/, Temp/, Obj/, Build/, Logs/, etc.).
  3. Install Git LFS and track large binaries (e.g., *.psd, *.fbx, *.wav, *.mp4).

Scenes (.unity), prefabs (.prefab), and .meta files are text and should be versioned (not LFS).


Troubleshooting

  • No collisions: Confirm you’re using 3D physics (not 2D). At least one of the two objects must have a Rigidbody. Make sure both share the same Z depth and the Physics Layer Collision Matrix allows them to collide.
  • Apples not scoring: Ensure Basket collider is present and Is Trigger = OFF (or if using triggers, that OnTriggerEnter is firing and one side has a Rigidbody).
  • Rounds/UI not updating: Confirm ApplePicker calls GameMan.OnBasketsChanged() and GameMan.roundLabel is assigned.
  • Console spam: Remove or guard Debug.Log calls, or set Console filters.

Credits / License

  • You control the license. A common choice is MIT for open source.
  • Art/audio assets should include their own licenses or credits.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors