ALWAYS display shadow UNDER character (3d platformer)??

I’m working on a 3d platformer. What is the best way to display a shadow on the ground UNDER the character regardless of lighting position? this is essential for 3d platformers and I’m wondering how to implement this. Perhaps using a ray cast? and move the “shadow object” to where the hit is detected?
For that matter, what should the shadow made of? a 3d object? with a feathered/transparent type of shader?
Thanks guys!

Thanks bro! exactly what I am looking for!

Ok so I noticed the shadows go through all ground surfaces. I mean I COULD limit the length /distance of the shadow but is there another way to automated the shadow to just show on the current ground only? Right now I have layered 3 platforms and if I stand at the top one, the shadow bleeds down across all three platforms.

Any ideas?

Look at Ignore Layers option. You can specify what gameObject layers the projector is applied to.

Ignore Layers Objects in Layers that you specify here will not be projected upon. The default value is None.

TO read up on layers:

Generally, setting layer options on components allow you to override default behaviour of a component.

Yes I tinkered with this but the don’t want the layers to be ignored as I need shadows on those too. Just not all at once. Only when I’m directly on top of it.

for example if I’m on the top platform, the shadow will show down through middle and bottom platform. So I see the shadows on all platformswhen I’m only on the top platform. Same thing happens if I am on the middle platform, it’ll go through and also show on the bottom platform. (New drinking game idea: take a shot every time I say platform lol)

This is probably a long shot since the post is over two years old now, but did you end up working out a solution for this? I’m messing around with a shadow just like this right now (using a projector) and came across the same issue, “shadows” showing up on all sides of an object being projected on.

In my personal experience you are better off either using a decal shader of some kind or if you really wanna go low-tech just use a sprite and use a raycast to position and orient it below the characters.

I generally don’t recommend using the projector at all. It can have significant performance impact if you aren’t aware of how it works (effectively it re-renders all of the geometry it is touching). As well, you can see some of the limitations it has. If you are dead set on using it then I’d say the two best options are to either set the far range to something that generally doesn’t interact too poorly or use a raycast or spherecast to dynamically set the far range so that it is always about the correct range for the nearest surface you’d expect to see it on.

1 Like