Capsule Component Missing when Dragging Class into Unreal

I am currently working through the Toon Tanks project, and am at the “Constructing the Capsule” lesson. I have built the BasePawn, Relaunched, Refreshed the VSCode Project in Unreal, and am not using Live Coding as that has caused issues in previous lectures. When I drag the BasePawn Class from the Content Browser to the Map, following the video, the BasePawn instance does not have a Capsule Component attached (see included screenshot).

Here is the BasePawn.h:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "BasePawn.generated.h"

UCLASS()
class TOONTANKS_API ABasePawn : public APawn
{
	GENERATED_BODY()

public:
	// Sets default values for this pawn's properties
	ABasePawn();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

private:
	UPROPERTY()
	// Using Forward Declaration, I don't need to include the required header file at the top to use the UCapsuleComponent.
	// I will only need to include the header file in BasePawn.cpp.
	// Only Include Header Files where needed!
	class UCapsuleComponent* CapsuleComp;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

};

Here is the BasePawn.cpp:

// Fill out your copyright notice in the Description page of Project Settings.


#include "BasePawn.h"
#include "Components/CapsuleComponent.h"

// Sets default values
ABasePawn::ABasePawn()
{
 	// 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;
	CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule Collider"));
	RootComponent = CapsuleComp;

}

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

// Called every frame
void ABasePawn::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

// Called to bind functionality to input
void ABasePawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

}

If you create a blueprint from this class does it show up there?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms