Out-of-line definition of 'PostInitProperties' does not match any declaration in 'AMyActor'

Following the “Introduction to C++ Programming in UE4” exactly, step by step.

And I’ve got stuck on a section. I’m at the point where I’m adding in the postinitproperties and it’s not compiling in the editor. Code and error message below:

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

#include "WorkThisTime.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;
    
    TotalDamage = 200;
    DamageTimeInSeconds = 1.f;
    
}

void AMyActor::PostInitProperties()
{
    Super::PostInitProperties();
    DamagePerSecond = TotalDamage / DamageTimeInSeconds;
}


// Called when the 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 our height by a factor of 20
    RunningTime += DeltaTime;
    SetActorLocation(NewLocation);

}

Error message:

Info UBT execution time: 10.96 seconds
Info Running Mono...
Info 
Info Setting up Mono
Info /Users/Shared/UnrealEngine/4.7/Engine /Users/Shared/UnrealEngine/4.7/Engine/Binaries/Mac
Info Compiling with Mac SDK 10.10
Info Parsing headers for WorkThisTimeEditor
Info Reflection code generated for WorkThisTimeEditor
Info Performing 3 actions (8 in parallel)
Info [1/3] Compile WorkThisTime.generated.cpp
Info [2/3] Compile MyActor.cpp
Info /Users/russellstephens/Documents/Unreal Projects/WorkThisTime/Source/WorkThisTime/MyActor.cpp:18:16: error: out-of-line definition of 'PostInitProperties' does not match any declaration in 'AMyActor'
Info void AMyActor::PostInitProperties()
Info                ^~~~~~~~~~~~~~~~~~
Info 1 error generated.
Info -------- End Detailed Actions Stats -----------------------------------------------------------
Info ERROR: UBT ERROR: Failed to produce item: /Users/russellstephens/Documents/Unreal Projects/WorkThisTime/Binaries/Mac/UE4Editor-WorkThisTime-2247.dylib
Info Cumulative action seconds (8 processors): 0.00 building projects, 5.07 compiling, 0.00 creating app bundles, 0.00 generating debug info, 0.00 linking, 0.00 other
1 Like

Found it here:

Never mind. Sucks that a tutorial on UE4 doesn’t actually have all the information people need to get started.

1 Like

My project crashed as I was trying to find a workaround and it would not open again… That single bit of code would have been useful in the tutorial lmao

Thanks for the solution guys. Been wasting hours trying to get this stuff working, I don’t understand how Epic expects beginners to follow along when some of their code examples in the Programming Quick Start actually contains errors