Join Jesse Freeman for an in-depth discussion in this video Spawning new obstacles, part of Unity 5: 2D Essential Training (2015).
- Now that we have our Obstacle set up,…we're going to need a way…to create lots of Obstacles throughout the game.…In order to do that,…we're going to make a Spawner.…A Spawner will basically have a timer attached to it,…and when the timer runs out,…it will create a new Object…and continue to do this until the game is over.…To get started, let's go into our Scripts folder…and create a new script called Spawner.…Now, let's open up the Spawner.…To begin with,…let's create an array that will contain…all the different types of Prefabs our Spawner can make.…
We'll make this public, GameObject, type it to an array,…and call it Prefabs.…Next, let's add a delay.…We'll make this a float, call it Delay,…and set it up for 2 seconds.…Finally, we'll need a way to know…if the Spawner is active or not.…This way, we can shut it down when the game is over.…Let's create a public boolean and call it Active.…And we'll automatically set it to true.…Now, in our Start method…we're going to create something called a coroutine.…
A coroutine is a way that we can run a script…
Super Zombie Runner riffs off the popular endless runner genre: a one-button casual game that's not only fun to play but exciting to build. The focus of the work is a reusable code base that you can extend and make your own, while learning the basics of object pooling, supporting multiple screen resolutions, tracking scoring, and multi-platform publishing. Along the way, Jesse covers key Unity features, such as working with sprites, creating animations, and leveraging the UI components.
- Working with sprites and animation
- Creating the player
- Spawning GameObjects
- Adding obstacles and collisions
- Building the game objects and logic
- Managing game state
- Creating pixel-perfect cameras
- Designing for multiple screen resolutions
- Adding scores
- Optimizing performance
- Publishing to desktop, web, and mobile platforms
Skill Level Intermediate
1. Working with Sprites
2. Creating Repeating Textures
3. Creating Obstacles
4. Object Pooling
5. Creating the Player
6. Setting Up the Game
7. Adding UI
8. Creating More Obstacles
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.