Disclaimer:
Hello, this is my first post, so it is possible that I am not being accurate in many ways, such as the forum threads. If that is the case, please accept my apologies. I come from Game Maker, where I developed a point and click adventure and now I am triying to prototype a metroidvania game in Unity3D.
The problem:
This method allows me to calculate when my character’s sprite is grounded by casting a ray from its center, but as it is only a 1px ray, it fails to accurately validate the jump when my character is in the very edge, thus resulting in poor control when it is near the borders:
grounded = Physics2D.Linecast (transform.position, groundCheck.position,
1 << LayerMask.NameToLayer ("Ground"));
I have been thinking about throwing 2 linecasts:
1 from: (center + sprite_width/2)
Another 1 from: (center - sprite_width/2)
But since there can be a situation where I stay on a very narrow platform this could not work either.
Here I show an image of my character, not grounded, although it should:
Any indea/s? Thank you very much for reading untill this point.