Make shadow interact with 3d objects

I’m making a puzzle game in which the player character is a shadow on a wall and there are multiple 3d objects in the room which shadows are cast to the wall and the player can move and rotate those 3d objects (bring them close to a light source and the shadow on the wall will become bigger), the player character can’t interact with 3d objects but can interact with their shadows like climb on shadow of a table, now the question is how can I make my shadow interactive.

This is a problem on the level of complexity that you’re pretty much gonna have to hire an expert specifically to do. If I saw this feature in a puzzle game, I would think, “Oh, that’s impressive, I wonder how they coded that?” If anyone can give you a satisfactory answer in a forum post I’d be genuinely shocked.

Edit: I think what I would do to resolve this would be to make a render texture from the point of view of the camera, with shader replacement and/or layers set up so that it renders a flat two-color image which you process into platforms/etc. Then put that rendered image/data into a 2D “scene” setup and do every bit of game logic within that 2D scene. Then you can use raycasts to convert that 2D scene back to your 3D world. If all that sounds complicated, that’s because it really really is, which gets back to my original point. (As a point of reference for how niche this is, in 16 years of pro game dev there are at least two distinct steps in that process I’ve never done and would have to do a decent amount of research to figure out how - and that’s the easiest way I can think of)

2 Likes

I put the thread on watch for similar reasons. It’s an actually interresting (read: complex) problem.

If we had certain limitations to work around it might be possible to come up with a solution. Like if there was a static global light source and the shadows could not increase or decrease in size, you could possibly, maybe, cheese the effect. This would still be talking about a far from trivial solution.
But the character being an actual shadow and interacting with actual shadows, is orders of magnitude more complex.

There would also, on a conceptual level, be some elements that are unclear to me. Not that it matters at this point, or would us get closer to a solution. But the character being an actual shadow and interacting with actual shadows… has some weird corner cases. What if he drags an object closer to a light source and the shadow thus swallows the player? Usually this is not a big deal, since shadows are designed to be purely visual. However in your case the character would literally be a shadow, so he cant just get swallowed by another shadow like that. And all of that is still assuming we cheese the effect somehow, for example by having dynamically reshaped colliders (by some very complex logic) to act like shadows. If what you want is for these mechanics to work fully out of the box with any kind of shadow… then there is a whole other set of implications. Like what would happen if you dimmed the light, or turned it off?

So tl;dr, you certainly need a whole lot of restrictions and a controlled environment to pull this off. And even then it would be a truckload of work, and nothing people can offer out of the box algorithmic solutions for.

1 Like

Most, if not all of the above problems can be solved, as demonstrated quite well by this game In My Shadow on Steam

It’s not something I’d want to try to do myself though!

2 Likes

And as mentioned the game imposes limitations that allow the problems to be solved. For example, at a glance it appears that the shadows never move while the shadow-player is moving, which is a big one.

1 Like

That game is largely constrained exactly to level out the problem space, which is humongous. Frankly, I wouldn’t be surprised if there are certain physical paradoxes to be discovered down that route, let alone usability breakers.

1 Like

I still can not solve that.,.