Join Jesse Freeman for an in-depth discussion in this video Dynamically resizing 2D box colliders, part of Unity 5: 2D Essential Training (2015).
- Now in the last video,…we added random sprites to each of our objects.…And we noticed that the collider for…each of these objects isn't…correctly re-sizing itself.…We're also able to see that every time we…create a new object, we are able to find…other scripts that contain the…iRecycle interface.…So, let's go back in…and clean all this stuff up.…The first thing we're gonna wanna do is…go back into our recycle script.…
Once it opens up, let's delete this…debug statement, since we no longer need it,…as we can see that it's working.…Next, let's go into our obstacle class…and add in the logic we need,…in order to resize the collider.…The easiest way for us to do this…is to get a reference of the collider…and then change its size to the…size of the sprite.…Here, I'll create a variable for the collider,…and we'll use Get Component to find the…reference of the box collider 2D.…
Next, we can tell the collider its size,…that it should equal the…renderer's bounds size property.…This will give us the correct size…based on the current sprite in the render.…
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.