Greetings, everyone.
I am having issues compiling the example under Introduction to C++ Programming using Visual Studio 2013 Community. The game consist of a header file (Actor.h) and a source file (Actor.cpp). It compiles for the generated c++ class. But it doesn’t when I add the UPROPERTIES. See the attachment for the list of compiling errors. I will appreciate any help you may provide me. Thank you.
This is the header file Actor.h:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"
UCLASS()
class CODEPROJECT_API AMyActor : public AActor
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
int32 TotalDamage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Damage")
float DamageTimeInSeconds;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Transient, Category = "Damage")
float DamagePerSecond;
public:
// Sets default values for this actor's properties
AMyActor();
// Support per instace designer set properties
virtual void PostInitProperties() override;
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
};
This is the implementation file Actor.cpp:
// Fill out your copyright notice in the Description page of Project Settings.
#include "CodeProject.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;
}
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 );
}