Keep casting a shadow at the same location after the actor moved

I was wondering if there was a way to keep casting a shadow even if the actor who casted the shadow moved away, possibly using BluePrint programming.
I was thinking to set a custom light to a light source to cast the previously saved shadow, but I cannot think of a way to get the current raycasting using BluePrint.

Setting an actor/object as “Static” instead of “Movable” should bake it’s shadow when you build lighting but then the shadow will be there “forever”. You could try putting a “dummy” mesh/actor (exact duplicate) in the same location as the original actor. Set the “dummy” actor’s visibility to hidden but ensure that it is set to “Cast Shadow”. You may have to play with the settings of the blueprint but I’m pretty sure you can still cast shadows from a hidden/invisible object.

If you can’t get this idea to work then you might be out of luck. Shadows are either baked into the level for static actors or they are dynamic and move according to the lighting. They can not be manipulated outside the basic functions of lighting conditions.

One way to implement this without dwelling into render code is to place a copy of the said actor in that place so it can keep casting the shadow. Now you should disable all collisions for this dummy actor. Also make sure you do the following for the static mesh component of this actor:

  • In the Rendering section, set the Actor Hidden In Game flag to true
  • In the Lighting section, set the Cast Hidden Shadow flag to true

This should be enough to get a shadow without rendering the dummy actor.

Another possible option is to disable Render in Main Pass under the object’s Rendering options.

If your actor has a skeletal mesh, this may not work. You may need to additional code to freeze the actor’s pose.

The actor could be a skeletal mesh yes, but if I copy it I think it would be ok?
The problem about it is that if I would need to do it wih many actors, copying them all they would slow down the game.

EDIT: Plus, the bigger problem would be that if I would put a new light, it would cast a new shadow. I just need to impress a previous casted shadow onto a surface, not making new ones :confused:

EDIT2: Another problem is that if something would get behind the actor, a shadow would be casted over it.

Not sure if this would work. I am not an expert in materials.

You can try creating a render target and render the shadow to it using scene depth comparison in a custom material. Then use this render target as a texture source for a decal material which will be projected onto the level geometry.

Like I said, this si just an idea. I am not sure how doable it is.

Well this is for now the best answer I think, I’m not an expert in materials either, plus I just found these bugs with the SceneCaptureComponent’s to use with the render target: [Bug] Two bugs about SceneCaptureComponent's (2D and Cube) (MaterialBillboard and array bugs) - Rendering - Epic Developer Community Forums