Toggle "bOwnerNoSee" ingame?

Dear Fabrice,

Hi there!

Have you tried

MeshHead->SetHiddenInGame(false);

you might want to also check out, from SceneComponent.h

/** 
	 * Set visibility of the component, if during game use this to turn on/off
	 */
	UFUNCTION(BlueprintCallable, Category="Rendering")
	virtual void SetVisibility(bool bNewVisibility, bool bPropagateToChildren=false);

	/** 
	 * Toggle visibility of the component
	 */
	UFUNCTION(BlueprintCallable, Category="Rendering")
	void ToggleVisibility(bool bPropagateToChildren=false);

My Method for Showing/Hiding Actor Skeletal and Static Mesh Components

I have a multiple-weapon system where I have a whole lot of components that I attach to and remove from my character’s root mesh depending on what weapon they should have equipped.

Since you made your character’s head into a separate component, you made your life very easy in the long run in terms of your goal :slight_smile:


Keeping the Head Shadow

Regarding your goal of keeping the head shadow, perhaps you could experiment with using an alternative head component that is using a completely 0 opacity material? If none of the lower-level workarounds seem to be working?

Then my code below could easily be used to toggle which head component you are using

I know it’s less-low level, but it could be a last resort :slight_smile:


To Make Head Disappear

Detach the component from the root whenever you want to hide it

if(MeshHead) MeshHead->DetachFromParent();

To Make Head Appear

Reattach the component any time!

 if(MeshHead) 
     {
      MeshHead->AttachTo(Mesh);
       //you may have to re-apply your relative loc and rot, or you can use a socket
       MeshHead->SetRelativeLocationAndRotation(FVector(0.0f, 0.0f, -48.0f), FRotator(0.0f, -90.0f, 0.0f))
     }

or

MeshHead->AttachTo(Mesh, FName(TEXT("HeadSocketName")));  

One Function to Set Head Visibility

void AYourCharacter::SetHeadIsVisible(bool MakeVisible)
{
       //always check pointers
       if(!MeshHead) return;
       if(!Mesh) return;

       if(MakeVisible) 
       {
              MeshHead->AttachTo(Mesh);
              MeshHead->SetHiddenInGame(false);
              //you may have to re-apply your relative loc and rot, 
              //or you can use a socket
              MeshHead->SetRelativeLocationAndRotation(
                  FVector(0.0f, 0.0f, -48.0f), FRotator(0.0f, -90.0f, 0.0f));
       }
       else 
      {
           MeshHead->DetachFromParent();
      }

}

Let me know if this works for you!

Enjoy!


Rama