How to do shadow under a hero?

Hello.

My hero walks on a platform. The shadow under the hero is just semi-transparent sprite. Shadow should be visible only on platform’s surface. When platform ends, shadow should not be visible. How to do this?

The game is 2D. Platform is made with use of tilemap.

Thanks in advance for your help.

1 Like

There are several ways. One simple way you can try is to have a trigger collision object under the character that turns the shadow on and off depending on if the trigger collides with ground or not.

2 Likes

Unfortunatelly, switching shadow on and off is not a good solution in my case, since I need to hide shadow partially, when e.g. first half of it should be visible on the platform (before the edge) and the second half should not be visible.

1 Like

Ok, then you need to mask the shadow somehow. See this thread for some ideas how to do that: Making a "flashlight"

1 Like