Hi
I’ve recently started a new project and I found an error in my code that I’m unable to fix. I have the following actor class for power ups:
PowerUp.h:
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "PowerUp.generated.h"
UCLASS()
class MYPROJECT_API APowerUp: public AActor
{
GENERATED_BODY()
public:
APowerUp();
APowerUp(FString name, float duration);
UPROPERTY(EditAnywhere)
FString name = "";
UPROPERTY(EditAnywhere)
float duration = 0;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
PowerUp.cpp:
#include "PowerUp.h"
APowerUp::APowerUp() {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
}
APowerUpt::APowerUpt(FString name, float duration) {
this->name= name;
this->duration = duration;
}
// Called when the game starts or when spawned
void APowerUp::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APowerUp::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
As you can see it’s very simple. However, when I try to create an actor of this class from another class I’m getting the following error:
‘APowerUp::ApowerUp’: cannot access private member declared in class ‘APowerUp’
I don’t know what I’m doing wrong as this is the first time I find this error