I’ve been following along with Epic’s C++ Tanks vs. Zombies demo stream on YouTube. There, they define a Child Actor Component for their pawn in C++, and, when they create a Blueprint based off of their C++ code, they can select the Actor to function as the child by selecting the component in the Blueprint Editor Viewport and selecting the desired asset in the Details panel.
However, when I replicate their steps, I do not get a populated Details panel on my Child Actor Component. The panel is empty, and I cannot access the values for the component; so I cannot set it through the Blueprint to the desired actor.
I can find my Get Child blueprint node in the Graph Editor when I search, and it is even under the category I defined it as. Its tooltip shows as the comment directly above my definition of the component, so I’m sure it’s referencing the correct thing.
Still the Details panel is empty, so the Child Actor Component is functionally useless.
Here’s a screenshot.
Here’s my code for your reference.
.h file:
#pragma once
#include "GameFramework/Pawn.h"
#include "PlayerGodPawn.generated.h"
UCLASS()
class PROJECTJUPITER_API APlayerGodPawn : public APawn
{
GENERATED_BODY()
// Constructor declaration
APlayerGodPawn(const FObjectInitializer& ObjectInitializer);
public:
// Sets default values for this pawn's properties
APlayerGodPawn();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
private:
// Declare that we'll use a Scene Component called Dummy Root (it will be used for the root of the Actor)
UPROPERTY()
USceneComponent* DummyRoot;
// Declare that we'll be adding a child actor component, which will have the skeletal mesh for the hand representing the player's position in the world
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Hand", meta = (AllowPrivateAccess = "true"))
UChildActorComponent* ChildHand;
};
.cpp file:
#include "ProjectJupiter.h"
#include "Components/ChildActorComponent.h"
#include "PlayerGodPawn.h"
// Sets default values
APlayerGodPawn::APlayerGodPawn(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
// Default root component needed for C++ classes; Blueprints create one on the fly
RootComponent = DummyRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("RootComponent"));
// Use a spring arm to give the camera smooth, natural-feeling motion.
USpringArmComponent* SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm"));
SpringArm->SetupAttachment(RootComponent);
SpringArm->RelativeRotation = FRotator(-65.f, 0.f, 0.f);
SpringArm->TargetArmLength = 1000.0f;
SpringArm->bEnableCameraLag = true;
SpringArm->CameraLagSpeed = 3.0f;
// Create a camera and attach it to our spring arm
UCameraComponent* Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("PlayerCamera"));
Camera->SetupAttachment(SpringArm, USpringArmComponent::SocketName);
// Attach the ChildActorComponent
UChildActorComponent* ChildHand = CreateDefaultSubobject<UChildActorComponent>(TEXT("PlayerHand"));
ChildHand->SetupAttachment(DummyRoot);
// Take control of the default player
AutoPossessPlayer = EAutoReceiveInput::Player0;
}
// Called when the game starts or when spawned
void APlayerGodPawn::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APlayerGodPawn::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
// Called to bind functionality to input
void APlayerGodPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
}
Am I setting something up wrong?