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.
Any ideas on what I’m doing wrong?
Thanks,
-Eric