Game Development Reference
In-Depth Information
3.
Set the same new Platform tag as the tag to the Platform object.
4.
Create a new empty GameObject and name it SceneryToggler .
On Scenerytoggler , add a Box Collider 2D component and make the
SceneryToggler object a child of the Player object. The SceneryToggler
object is going to be used for the player to know what it collided against
in the scene.
5.
Set the Size property for the Box Collider 2D component of SceneryToggler
to be about X: 0.74 , Y: 0.06 .
6.
With the position of SceneryToggler at X:0 , Y:0 and the Center fields
as X: 0 , Y: 0.03 , the collider should be at the bottom of the player.
Make sure that the collider is below and completely covers the feet area
of the player, and goes below the feet area as well.
7.
Also, make sure that the Is Trigger property in the Box Collider 2D section
is checked.
What you should now have is a rectangular collision box that stretches out below the
player object's colliders, as shown in the following screenshot. Here, you can see the
big collider around the player and the new SceneryToggler box at the base of the
player sprite:
We have created a unique collider mesh. The reason we use a second Box Collider 2D
component to check what we're touching below the player is because the player's box
collider is smart enough to not intersect with the platform's box collider. The result is
that the OnTriggerEnter2D of the SceneryToggler object will never toggle if we rely
on the player's box collider—which is a good thing, because we want those collisions
to be accurate!
 
Search WWH ::




Custom Search