Mother of all walk animations |
Now it's finally time for some coding. Unfortunately I did not manage to get the tutorial script running for my level design. I do not use one dedicated block as bottom border but instead wanted to build my level using many sprite blocks put in line with each other like this:
Player standing on two layers of blocks |
What the tutorial script does is the following: Cast two short rays downwards, one on each edge of the sprite, and check if a ground block was hit. If yes then the falling state is set to false and player is positioned on the ground:
But as there are two layers of ground in my level the sprite kept falling after being positioned on the ground and ended up walking underground.
I spent some frustrating hours trying to figure out a solution using the distance to the ground below or above (if already underground), and finally had to give up for the night.
The next evening I tried something different. Why should I even bother casting rays if Unity already offers a full blown collision system. Yes maybe this is overkill for 2D gaming, but I desperately need some success.
I ended up using a Character Controller and some input from the 2D Gameplay Tutorial to make my little red fellow walk and jump... finally:
No comments:
Post a Comment