October 2016
Beginner
506 pages
10h 1m
English
Our camera follows our player, but our hero can still walk off the screen and keep going forever, so let's stop that from happening.
As you saw in the preceding section, you can use Unity's camera logic to figure out where things are on the screen. You can also do more complex ray testing to check where things are, but I find these are overly complex unless you depend on that level of interaction.
The simpler answer is just to use the native Box2D physics system to keep things in the scene. This might seem like overkill, but the 2D physics system is very fast and fluid, and it is simple to use.
We already added the physics components, Rigidbody 2D (to apply physics) and a Box Collider 2D (to detect collisions), ...
Read now
Unlock full access