Week 4 Tutorial: Building My 3D Game with Background Music and Effects
This week’s tutorial was all about bringing a simple 3D game to life with engaging sound and movement. For Task 04, our goal was to create a 3D game where the player character jumps through a constantly moving background while sound effects and background music enhance the experience.
Challenge 3 - Balloons, Bombs, & Booleans
In Challenge 3, I dove deeper into the mechanics of arcade-style gameplay by introducing elements that really bring our balloon-themed game to life. The objective was to make the gameplay more dynamic and interactive by implementing floating balloons, scrolling backgrounds, and spawning obstacles like bombs and collectible objects. Here’s a breakdown of what I accomplished and learned during this week.
Challenge Objectives
The goal of this challenge was to:
- Make the player’s balloon float when pressing the spacebar.
- Create a seamless scrolling background to enhance the immersive feel of a floating world.
- Spawn bombs or collectible objects (like money) that either help or hinder the player’s progress.
- Display fireworks as a fun effect when collecting money.
- Prevent the balloon from floating too high or dropping too low.
Key Features and Code Highlights
1. Floating the Balloon with Spacebar
- I used the
Input.GetKey(KeyCode.Space)
check to make the balloon float up as long as the player holds down the spacebar. This mechanic gave players direct control over the balloon, adding a fun and engaging challenge. - I made sure this function only works if
gameOver
isfalse
, so players can’t float endlessly after the game has ended.
2. Seamless Scrolling Background
- To create an endless background effect, I used a repeating background script (
RepeatBackgroundX
) that resets the background position once it reaches a certain boundary. - This small but important detail enhanced the gameplay by providing a sense of continuous movement through the sky.
3. Bombs and Money Spawn Mechanics
- Using the
SpawnManagerX
script, I set up obstacles (bombs) and collectibles (money) to spawn at randomized intervals. - I implemented the
InvokeRepeating
function to call theSpawnObjects()
method, spawning these items periodically to keep the gameplay interesting.
4. Adding Effects and Sounds
- When the player collects money, the
fireworksParticle
effect andmoneySound
are triggered, creating a satisfying reward for the player. - On the other hand, if the balloon collides with a bomb, the
explosionParticle
effect is triggered, followed by theexplodeSound
, which ends the game.
5. Game Boundaries
- To prevent the player’s balloon from floating too high or sinking too low, I added boundary conditions in the player movement script. This ensures that the balloon bounces back or stops moving if it reaches the set limits, maintaining control over gameplay.
Comments
Post a Comment