Hello the UE Community,
I’m doing all to learn C++ in Unreal and again I have found a strange problem with the code. I have two files:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "ObjectrRotMover.generated.h"
UCLASS()
class CPPCODE_API AObjectrRotMover : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AObjectrRotMover(const FObjectInitializer &ObjectInitializer);
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
UPROPERTY(VisibleAnywhere , BlueprintReadOnly, Category = "Mover");
class UBoxComponent* ColComp;
//UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Mover");
class UStaticMeshComponent* ObjectComponent;
//UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Mover");
float rotspeed;
float MoveX;
float MoveY;
float MoveZ;
float RotPitch;
float RotYaw;
float RotRoll;
FVector savepoint;
};
and
// Fill out your copyright notice in the Description page of Project Settings.
#include "CPPCode.h"
#include "ObjectrRotMover.h"
// Sets default values
AObjectrRotMover::AObjectrRotMover(const FObjectInitializer &ObjectInitializer) : Super(ObjectInitializer)
{
ColComp = ObjectInitializer.CreateDefaultSubobject<UBoxComponent>(this, TEXT("ColComp"));
RootComponent = ColComp;
ObjectComponent = ObjectInitializer.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Object"));
ObjectComponent->AttachTo(RootComponent);
rotspeed = 100.0f;
// 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 the game starts or when spawned
void AObjectrRotMover::BeginPlay()
{
Super::BeginPlay();
savepoint = this->GetActorLocation();
MoveX = savepoint.X;
MoveX = savepoint.Y;
MoveX = savepoint.Z;
}
// Called every frame
void AObjectrRotMover::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
MoveY += 500.0f * DeltaTime;
RotRoll += rotspeed * DeltaTime;
FVector mover(MoveX, MoveY, MoveZ);
this->SetActorLocation(mover, true);
FRotator rotate(RotPitch, RotYaw, RotRoll);
ObjectComponent->SetRelativeRotation(rotate, true);
}
And I get the error:
1>------ Build started: Project: CPPCode, Configuration: Development_Editor x64 ------
2>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>Project not selected to build for this solution configuration
1> Compiling game modules for hot reload
1> Parsing headers for CPPCodeEditor
1>D:/Unreal Projects/CPPCode/Source/CPPCode/ObjectrRotMover.h(24): error : In ObjectrRotMover: Member variable declaration: Missing variable type
1>Error : Failed to generate code for CPPCodeEditor - error code: OtherCompilationError (2)
1> UnrealHeaderTool failed for target ‘CPPCodeEditor’ (platform: Win64, module info: D:\Unreal Projects\CPPCode\Intermediate\Build\Win64\CPPCodeEditor\Development\UnrealHeaderTool.manifest).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ““D:\Program Files\Epic Games\4.7\Engine\Build\BatchFiles\Build.bat” CPPCodeEditor Win64 Development “D:\Unreal Projects\CPPCode\CPPCode.uproject” -rocket” exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
The problem is that the error is caused by the line:
UPROPERTY(VisibleAnywhere , BlueprintReadOnly, Category = "Mover");
When I switch off the line, all is compiled. The lines with UPROPERTY give the erros. What I do wrong?