I've seen that the game "Alto's Odyssey" has a very nice way of projecting shadows on the ground the player is sliding on:
How could i replicate that? Would I use some shader magic, or by projecting a 3D mesh/image on the ground plane?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
My approach would be similar as mentioned in the comments. I would take a grey copy of the sprite and would have it mirrored. I would set an offset for the shadow which depends on how far the player is away from the floor. You can use Rays to check that. I also would apply the rotation of the player object to shadow object inversed (just the negative value). The shadow depends on how you set your imaginary light source. so you can use other values. But I would say.
float shadowOffset = playerheight / 2; //so shadow is always halfway-> for realistic light effects position = currentFloorPosition - new Vector2(0, shadowOffset); rotation = -playerRotation; //not sure about this line that it works shadowScale *= (shadowOffset * adjustValue) //maybe you need a adjust value which makes sure that the shadows size is good //code to find the actual postion of the floor
so in this code example, you get a rough idea. You need to find the current position of the floor because it´s not constant as it´s curvy. You could also use the player position as a reference point for your shadow offset but I would be scared that the shadow jumps off the floor. To find the current position of the floor you could use a ray or a line cast and use the hit point as the current position. If you have any questions feel free to comment or message me. I hope I could help you. BTW these lines are more pseudo code than the real working code you might tweak some values etc.