Hi All. New to the forum so apologies if I’m breaking any etiquette.
I’m developing a player character as part of my university project with basic movement physics. It’s a child of the Pawn class, as I wanted to build it up myself instead of using a lot of the pre-existing Character class functions.
I’m having a problem with declaring a skeletal mesh component. From my understanding, I need to declare the component in the .h file and also in the .cpp file in order to make it appear in the editor, however when I do this I can’t access the attributes in the details panel. I’m assuming this is because it’s inherited but as far as I know this is the only way to go about it. I’m quite new to CPP, but I thought that I was beginning to understand the UE4 structure more.
Am I missing something or am I going in the completely wrong direction?
PlayerPawn.h
#pragma once
#include "GameFramework/Pawn.h"
#include "PlayerPawn.generated.h"
UCLASS(config=Game)
class APlayerPawn : public APawn
{
GENERATED_BODY()
/** Get skeletal mesh component */
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Mesh, meta = (AllowPrivateAccess = "true"))
class USkeletalMeshComponent* PMesh;
/** Get arrow component **/
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = Arrow, meta = (AllowPrivateAccess = "true"))
class UArrowComponent* PArrow;
...
PlayerPawn.cpp
#include "AnimE_01.h"
#include "PlayerPawn.h"
//////////////////////////////////////////////////////////////////////////
// APlayerPawn
APlayerPawn::APlayerPawn()
{
// Reference and create capsule collider set to model size
UCapsuleComponent* CapsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule Component"));
= CapsuleComponent;
CapsuleComponent->InitCapsuleSize(42.f, 96.0f);
CapsuleComponent->SetCollisionProfileName(TEXT("Pawn"));
USkeletalMeshComponent* PMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh"));
= CapsuleComponent;
UArrowComponent* PArrow = CreateDefaultSubobject<UArrowComponent>(TEXT("Player Arrow"));
= CapsuleComponent;