Download

Unable to hide 3rd person mesh while in 1st person view

Hey guys, very new to UE4 and not a whole lot of C++ experience here…

I’ve been following a beginner’s Tutorial to create a FirstPersonShooter from scratch and I got stuck on this C++ code.

Snippet of the relevant code…

P.S. - The code below is from an Ancestor class called LuxCharacterBase.cpp. I later use a LuxCharacterPlayer_BP which is attached to a LuxCharacterPlayer.cpp/h which is inheriting from LuxCharacterBase.cpp.

ALuxCharactersBase::ALuxCharactersBase()
{
 	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

    CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
    CameraComponent->SetupAttachment(GetRootComponent());

    MeshFirstPerson = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("MeshFirstPerson"));
    MeshFirstPerson->SetupAttachment(CameraComponent);
    MeshFirstPerson->SetOnlyOwnerSee(true);
    MeshFirstPerson->SetOwnerNoSee(false);
    MeshFirstPerson->SetCastShadow(false);
    MeshFirstPerson->SetReceivesDecals(false);

    GetMesh()->SetOnlyOwnerSee(false);
    GetMesh()->SetOwnerNoSee(true);

}

// Called when the game starts or when spawned
void ALuxCharactersBase::BeginPlay()
{
	Super::BeginPlay();

    GetMesh()->SetOnlyOwnerSee(false);
    GetMesh()->SetOwnerNoSee(true);
}

The two lines (Duplicated in the constructor and BeginPlay()) to focus on are…

GetMesh()->SetOnlyOwnerSee(false);
GetMesh()->SetOwnerNoSee(true);

They are suppose to go into a Blueprint to find the 1st person Mesh to hide. But it doesn’t seem to be working. I’ve duplicated it in both the Constructor and BeginPlay as I wasn’t sure if one or the other would work. But seeing as how its not working, I’m not quite sure what to do.

Images of the issue…


Trying to dig into it myself, I can’t seem to get the Debugger to break on this line, because of compiler optimizations. I’ve set my Project to DebugGameEditor as I’ve read that they disable a lot of them in this configuration. But I must be missing something else as well?

Here is an image of the Blueprint and I’ve highlighted the mesh that I hoped GetMesh() would see and hide.
image

Any ideas on what I’m doing wrong?

Thanks,

-Eric

Hello,

You can look inside the blueprint itself and check if Mesh (CharacterMesh0) has Owner no see ticked in it’s details, in the details panel

Hey,

So I went into the BP to toggle the “Owner No See” on the “Mesh” and I’m not seeing any effect.

But If I toggle “Owner No See” on the “Mesh First Person” it affects both the “Mesh” & “Mesh First Person”.

Have I possibly linked the two together in some way? This behavior is very strange.

-Eric

What’s the SkeletalMesh under Mesh First Person? Is that actually your 3rd person mesh?

Hey,

After reviewing this again, I think everything was actually working as expected.

What I thought I saw as being the 3rd person mesh being visible in 1st person view was incorrect. What I was looking at, was actually the first person mesh, but it was clipping against the camera. (I thought since I copied the Translate/Rotation transforms from the example FirstPersonBP UE4 project, as well as the Camera properties. Everything should of lined up properly, but apparently it is not.

So in actuality, the code is actually working as intended. While I am in 1st person view, the 3rd person mesh is being hidden as expected.

I had wrongly assumed that the mesh that I thought I saw was the 3rd person mesh, when it was not. :blush:

I will close this out thread out!