I cannot compile my Unreal project (error: -WaitMutex -FromMsBuild Code 5). Just for reference: when I closed unreal, I couldn’t open it due to the issue again. I had to delete the C++ files that caused the issue and I also deleted the binary files.
The code that causes the issue is very simple. I have an *AItem *parent class that seems to work just fine (see below) and an inherited class *Explosive *that causes the compilation error. Can someone help me?
Explosive.h
#pragma once
#include "CoreMinimal.h"
#include "Item.h"
#include "Explosive.generated.h"
UCLASS()
class CPPROJ01_API AExplosive : public AItem
{
GENERATED_BODY()
public:
AExplosive();
UFUNCTION()
virtual void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult) override;
UFUNCTION()
virtual void OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex) override;
};
Explosive.cpp
#include "Explosive.h"
#include "Components/PrimitiveComponent.h"
AExplosive::AExplosive()
{
}
void OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
}
void OnOverlapEnd(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex)
{
}
Item.h
UCLASS()
class CPPROJ01_API AItem : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AItem();
UPROPERTY(VisibleAnywhere)
class USphereComponent* CollisionSphere;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UFUNCTION()
virtual void OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
UFUNCTION()
virtual void OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
};
Item.cpp
#include "Item.h"
#include "Components/SphereComponent.h"
#include "Components/PrimitiveComponent.h"
// Sets default values
AItem::AItem()
{
// 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;
CollisionSphere = CreateDefaultSubobject<USphereComponent>(TEXT("CollisionSphere"));
CollisionSphere->OnComponentBeginOverlap.AddDynamic(this, &AItem::OnOverlapBegin);
CollisionSphere->OnComponentEndOverlap.AddDynamic(this, &AItem::OnOverlapEnd);
}
// Called when the game starts or when spawned
void AItem::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AItem::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AItem::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
UE_LOG(LogTemp, Warning, TEXT("OverlapBegin"));
}
void AItem::OnOverlapEnd(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex)
{
UE_LOG(LogTemp, Warning, TEXT("OverlapEnd"));
}