Download

"Identifier "CreateDefaultsubObject" is undefined"

I’m not sure why I am getting this error but here is my code:

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

// Called every frame
#include “Components/StaticMeshComponent.h”
#include “Components/BoxComponent.h”
#include “Brick.h”
#include “Ball.h”

// Sets default values
ABrick::ABrick()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
SM_Brick = CreateDefaultsubObject(TEXT(“Brick”));
SM_Brick->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
BoxCollision = CreateDefaultsubObject(TEXT(“Box Collision”));
BoxCollision->SetBoxExtent(FVector(25.0f, 10.0f, 10.f));

RootComponent = BoxCollision;

}

// Called when the game starts or when spawned
void ABrick::BeginPlay()
{
Super::BeginPlay();
BoxCollision->OnComponentBeginOverlap.AddDynamic(this, &ABrick::OnOverLapBegin);
}
// Called every frame
void ABrick::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);

}

void ABrick::OnOverLapBegin(UPrimitiveComponent* OverLappedComp, AActor* OtherActor,
UPrimitiveComponent* OtherComp, int32 OtherIndexType, bool BFromSweep, const FHitResult& SweepResult)
{

}

void ABrick::DestroyBrick()
{

}

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

#pragma once

#include “CoreMinimal.h”
#include “GameFramework/Actor.h”
#include “Brick.generated.h”

class UBoxComponent;

UCLASS()
class FIRSTGAME_API ABrick : public AActor
{
GENERATED_BODY()

public:
// Sets default values for this actor’s properties
ABrick();

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

UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
	UStaticMeshComponent* SM_Brick;

UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
	UBoxComponent* BoxCollision;

float SpeedModOnBounce = 1.01f;

UFUNCTION()
	void OnOverLapBegin(class UPrimitiveComponent* OverLappedComp, class AActor* OtherActor,
		UPrimitiveComponent* OtherComp, int32 OtherIndexType, bool BFromSweep,
		const FHitResult& SweepResult);
void DestroyBrick();

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

};

I am getting 3 errors all together in my cpp file, the first I had mentioned and then on the same line (line 15) “UStaticMeshComponent Type name is not allowed” and then the same error on the line below “UBoxComponent Type name is not allowed”

The correct case is CreateDefaultSubobject

Yeah, as @eblade was saying, C++ is case sensitive. That means that CreateDefaultSubobject and CreateDefaultsubObject are entirely different. You need to use CreateDefaultSubobject.

■■■■ did not know that, thanks.