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.
- 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.
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 belowbottomY, destroys itself and callsApplePicker.AppleMissed().ApplePicker.cs– Creates 4 baskets at start, removes one when an apple is missed, and informsGameManto 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 usingPlayerPrefs.ScoreCounter.cs– Displays the current score.StartGame.cs– Shows start panel and pauses game until Start is clicked.
- Game Scene – Main play scene (contains
AppleTree,GameMan,Canvas, etc.).
- 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().
Create or verify these prefabs and tags:
Apple,Basket,Ground
- Rigidbody (3D): Use Gravity = ON; Collision Detection = Continuous Dynamic; Interpolate = Interpolate.
- Collider (3D): Sphere/Box; Is Trigger = OFF (simplest).
- Tag:
Apple
- Collider (3D): Box/Mesh; Is Trigger = OFF (for standard collisions).
- Tag:
Basket
- A plane/cube with a Collider (3D) near the bottom to catch/stop apples visually.
- Tag:
Ground(optional for scripting sinceApple.csusesbottomY).
- roundLabel → TMP text at top center.
- gameOverPanel → your panel (inactive at start).
- gameOverReasonText → (optional) TMP under panel.
- pauseOnGameOver →
true(recommended).
- applePrefab → Apple prefab.
- appleDropDelay → spawn rate (e.g.,
1.0sec). - speed, leftAndRightEdge, changeDirChance → movement behavior.
- startPanel → your panel shown on load.
- Start button → OnClick →
StartGame.OnStartClicked().
- Mouse: Move the basket horizontally (follows mouse X).
- Catch Apples to score.
- Missing apples removes a basket; when all baskets are gone → Game Over.
- File → Build Settings…
- Add your main scene(s) to Scenes in Build.
- Choose platform (PC/Mac/Linux Standalone, etc.).
- Build or Build and Run.
- Unity Editor Settings:
- Version Control: Visible Meta Files
- Asset Serialization: Force Text
- Add a Unity
.gitignore(ignoreLibrary/,Temp/,Obj/,Build/,Logs/, etc.). - Install Git LFS and track large binaries (e.g.,
*.psd,*.fbx,*.wav,*.mp4).
Scenes (
.unity), prefabs (.prefab), and.metafiles are text and should be versioned (not LFS).
- 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
OnTriggerEnteris firing and one side has a Rigidbody). - Rounds/UI not updating: Confirm
ApplePickercallsGameMan.OnBasketsChanged()andGameMan.roundLabelis assigned. - Console spam: Remove or guard
Debug.Logcalls, or set Console filters.
- You control the license. A common choice is MIT for open source.
- Art/audio assets should include their own licenses or credits.