Welcome to part 3! If you have not completed part 2, please go back and complete part 2. This part will cover creating prefabs for your level, creating a level and then optimizing that level.
Part 1: Getting Started
Part 2: Animations
Part 3: Prefabs
Part 4: Enemies
Part 5: Modular Scripting
Part 6: Timed Prefab Instantiation
Part 7: Health Bars
Part 8: Finishing Touches
Part 9: Publishing
Create some obstacles!
- Find the crate and drop one onto your scene.
- Click Add Component, Physics 2D -> Box Collider
- Drop some tileable Brick down on the scene.
- Now lets border the brick with the crates.
- OH NO!!!! Things disappear and act funny.
- We need to adjust the layers they are sorted on.
- Navigate to Layers and edit.
7. Navigate to the sprite renderer component of each of the game objects and set them appropriately.
- Navigate to the prefabs folder. Right click -> Create ->Prefab.
- Highlight multiple objects you want to be a prefabricated component and drag them onto the view of the pre-fab in the projects view.
- Delete the objects from the view.
Create a few more prefabs of scenery.
Create LOTS OF PREFABS! I like to create prefabs of pieces of scenery that I think I will use commonly for building a level. Below is an image of all the prefabs I built for the starter kit of this game.
Create a Level using your prefabs
Optimizing your prefabs
- Drop the prefab you want to optimize onto your scene.
- Look at all of the box colliders you have for each crate. That’s a lot of box colliders, we don’t need that many.
- Delete the colliders from each of your boxes.
- Create a new box collider that covers the entire space of the old colliders.
- Drop this set of objects back onto the original prefab to save the changes to all of the prefabs already created.
Notice the left collider covers the entire wall, while the top wall section has individual colliders for each crate.