FPS: Invisible to camera but cast shadow

I’m making a FPS demo and I place my camera at eye’s position. In some situation, the head will move inside the camera and it is bad. Is it possible to make the head invisible to camera but also cast shadow?

I found a post that had a solution that worked for my case. Here: https://www.reddit.com/r/unrealengine/comments/4bbwlw/shadowao_and_transparent_material/

In case the post gets deleted:

  • On the lighting section in the static mesh component:

  • Enable Cast Shadow

  • Enable Affect Distance Field Lighting

  • Enable Dynamic Shadow

  • Enable Hidden Shadow

  • On the rendering section in the static mesh component:

  • Disable Visible

  • Enable Actor Hidden in Game

I was using version 4.22.3


(YourBodyMesh)->bCastHiddenShadow = true;