Hide Head But Still Cast Shadow

I want to hide just the head of the 3rd person mesh but I still want the head to cast a shadow. I am trying to attach the camera to the body for a FPS but still be able to see your body.

void AActionCharacter::ToggleCamera()
{
	if (IsFirstPerson)
	{
		GetMesh()->UnHideBoneByName("head");
		FollowCamera->DetachFromComponent(FDetachmentTransformRules::KeepRelativeTransform);
		FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
		FollowCamera->bUsePawnControlRotation = false;
		IsFirstPerson = false;
	}
	else
	{
		GetMesh()->HideBoneByName("head", EPhysBodyOp::PBO_None);
		FollowCamera->DetachFromComponent(FDetachmentTransformRules::KeepRelativeTransform);
		FollowCamera->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, "Camera");
		FollowCamera->bUsePawnControlRotation = true;
		IsFirstPerson = true;
	}
}

This basically works, but then my characters shadow looks like the headless horseman.

2 Likes

Hi.
Did you try OwnerNoSee option on your skeletal mesh component ? This sounds like it could solve the problem.

132945-ownernosee.jpg

Let me know

1 Like

In case anyone else comes here for this:

In construction script drag in the character mesh, drag off and create the node “Hide Bone By Name”, select the head bone and connect to Construction start node.
Duplicate the character mesh and make sure to 1. attach it to the original mesh and 2. rotate it so it matches up with the original mesh.
Then set “Cast Shadow” on the original mesh to false and on the new mesh set it to true. Then on the new mesh find “Owner No See” and set to true.
Now you will have 2 character meshes running the same AnimBP, one is showing the body with no head and no shadow, the other is showing the shadow as a full body but not showing the mesh to the player.
Hope this helps someone!

3 Likes

This was helpful … thanks for the updated instructions. I added mine this way and it also worked. Animating the two skeletal meshes together with Set Master Pose Component did not work because the head bone is hidden in the parent. Getting the anim class from the main mesh and setting it in the character shadow mesh seems to work.

1 Like

Thank you so much :smiley:

Depending on what version of UE you are on there is a parameter called “Hidden Shadow” on actors that will do just this. Allow you to make the actor not visible but still cast a shadow.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.