Now, we are making our character jump by using
Physics.Raycast in Unity. We can also use the
OnCollisionStay functions to check the collision detection between our character and the floor, but in this case we will use
because it's more flexible to adjust.
However, because the
Raycast is only a line with no thickness, there is a chance that if we have a very thin platform, the
Raycast can miss it. And it will cause the problem that we might not be able to jump. So, we should make sure that the platform should have the thickness of least 0.1 units.
Continuing from the last step, let's get on with it as follows:
CharacterController_2D.jsfile and add this ...