From the course: Advanced Unity 2D: Platformer Player Movement

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Building a collision state manager

Building a collision state manager - Unity Tutorial

From the course: Advanced Unity 2D: Platformer Player Movement

Start my 1-month free trial

Building a collision state manager

- So at this point we now have the player who can walk and can run but we don't really know much about the world outside of the player. In order to do this, we're going to need to manage collision states with the player and other objects in the game. Notably, the floor itself. We're going to actually create a collision state class similar to our input state class that'll manage these relationships. To get started we're going to start detecting how to actually know when the player is standing on something solid. Let's go into our Scripts folder, create a new folder called Collision and inside of this we'll create a new C# class called CollisionState and let's open this up in MonoDevelop. Now we'll need a few public properties in order to keep track of the Collision States. The first will be the actual collision layer we'll be doing the tests with. Here we'll make a public property called layerMask and we'll call this collisionLayer. Next we'll want a boolean to represent whether the…

Contents