I’m running into a strange issue. I have some code experience (mostly C# and Java) and I am following the tutorial and I’m on this step: 3 - Write and Compile C++ Code | Unreal Engine Documentation
I have my code the exact same way as shown but I am getting - Error: no default constructor exists for class “AActor”
Header file:
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
/**
*
*/
UCLASS()
class BEGINNING_ONE_API AMyActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMyActor() = default;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
float RunningTime;
};
And .cpp file:
#include "Beginning_One.h"
#include "MyActor.h"
// Sets default values
AMyActor::AMyActor()
{
// 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;
}
//Called when game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 20.0f; // scale height by a factor of 20
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
}
The build errors are:
Error 1 error C2511: ‘AMyActor::AMyActor(void)’ : overloaded member function not found in ‘AMyActor’
Error 2 error C2228: left of ‘.bCanEverTick’ must have class/struct/union
Any ideas? As far as I can see its the exact same as the tutorial except for project names.