Hi was following up this course but attaching UStaticMeshComponent isn’t work… after attaching the Capsule Collider nothing else is attached.
Here is my BasePawncpp class
#include "BasePawn.h"
#include "Components/CapsuleComponent.h"
#include "Components/StaticMeshComponent.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;
capsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Capsule Collider"));
RootComponent = capsuleComponent;
//From here not working
baseMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Base Mesh"));
baseMesh->SetupAttachment(capsuleComponent);
turretMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Turret Mesh"));
turretMesh->SetupAttachment(baseMesh);
projectileSpawnPoint = CreateDefaultSubobject<USceneComponent>(TEXT("Projectile Spawn Point"));
projectileSpawnPoint->SetupAttachment(turretMesh);
}
// 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);
}
And here is my BasePawn.h class
// 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()
class UCapsuleComponent* capsuleComponent;
UPROPERTY()
UStaticMeshComponent* baseMesh;
UPROPERTY()
UStaticMeshComponent* turretMesh;
UPROPERTY()
USceneComponent* projectileSpawnPoint;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
I tried many ways, close, build, close, rebuild… nothing works, the result is a pawn with just the capsule collider
Any idea about what’s going on?
Thanks in advance


