# How can I create a 2D sprite shadow like in “Alto's Odyssey”?

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?

• I don't know how the game looks while you are playing (how the shadow moves) but from the screenshot it looks like you just take the player's sprite, mirror it and scale it down on Y and place it on the ground. There is no point over complicating stuff with shaders and 3D meshes for a 2D shadow. – TomTsagk Oct 31 '18 at 9:03
• @TomTsagk the shadow squashes down when the player gets close to the ground, and gets stretched when he goes up – Gabriele Vierti Oct 31 '18 at 9:24
• @TomTsagk that way though it wouldn't look believable... – Gabriele Vierti Oct 31 '18 at 9:25
• @TomTsagk I'd upvote an answer about the technique you describe with a little more detail. – DMGregory Oct 31 '18 at 11:58
• Wow, I had never noticed the shadow before... – Quentin Oct 31 '18 at 12:37

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);
//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.

• I hope I thought right that shadows get bigger as you get farer away from your floor :P – Pascal Lohscheidt Oct 31 '18 at 20:06