I cant Compile

I think I did everything they asked my to do but I got an error
Compiler:

Manual recompile triggered
---------- Creating patch ----------
Running D:\UE_5.0\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.exe -Target="Obstacle_AssultEditor Win64 Development -Project=""C:/Users/User/Documents/Unreal Projects/Obstacle_Assult/Obstacle_Assult.uproject""" -LiveCoding -LiveCodingModules="D:/UE_5.0/Engine/Intermediate/LiveCodingModules.txt" -LiveCodingManifest="D:/UE_5.0/Engine/Intermediate/LiveCoding.json" -WaitMutex -LiveCodingLimit=100
  Log file: C:\Users\User\AppData\Local\UnrealBuildTool\Log.txt
  Building Obstacle_AssultEditor...
  Using Visual Studio 2022 14.34.31935 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933) and Windows 10.0.22000.0 SDK (C:\Program Files (x86)\Windows Kits\10).
  [Adaptive Build] Excluded from Obstacle_Assult unity file: MovingObject.cpp, MovingPlatform.cpp, MovinPlatform.cpp, Obstacle_Assult.cpp
  Determining max actions to execute in parallel (6 physical cores, 6 logical cores)
    Executing up to 6 processes, one per physical core
    Requested 1.5 GB free memory per action, 1.27 GB available: limiting max parallel actions to 1
  Building 2 actions with 1 process...
  [1/2] Compile MovingPlatform.cpp
  C:\Users\User\Documents\Unreal Projects\Obstacle_Assult\Source\Obstacle_Assult\MovingPlatform.h(32): error C2144: syntax error: 'float' should be preceded by ';'
  [2/2] Compile MovingPlatform.gen.cpp
  C:\Users\User\Documents\Unreal Projects\Obstacle_Assult\Source\Obstacle_Assult\MovingPlatform.h(32): error C2144: syntax error: 'float' should be preceded by ';'
Build failed.

MovingPlatform.h:

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

#pragma once

#include “CoreMinimal.h”

#include “GameFramework/Actor.h”

#include “MovingPlatform.generated.h”

UCLASS()

class OBSTACLE_ASSULT_API AMovingPlatform : public AActor

{

GENERATED_BODY()

public:

// Sets default values for this actor's properties

AMovingPlatform();

protected:

// Called when the game starts or when spawned

virtual void BeginPlay() override;

public:

// Called every frame

virtual void Tick(float DeltaTime) override;

UPROPERTY(EditAnywhere, Category="Moving Platform")

FVector PlatformVelocity = FVector(100,0,0);

UPROPERTY(VisibleAnywhere)

float DistanceMoved = -1;

FVector StartLocation;

};
MovingPlatform.cpp:
// Fill out your copyright notice in the Description page of Project Settings.

#include “MovingPlatform.h”

// Sets default values

AMovingPlatform::AMovingPlatform()

{

// 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 AMovingPlatform::BeginPlay()

{

Super::BeginPlay();

StartLocation = GetActorLocation();

}

// Called every frame

void AMovingPlatform::Tick(float DeltaTime)

{

Super::Tick(DeltaTime);

// Move platform fowards

    // Get current location

        FVector CurrentLocation = GetActorLocation();

    // Add forward vector

        CurrentLocation = CurrentLocation + (PlatformVelocity * DeltaTime);

    // Set location

        SetActorLocation(CurrentLocation);

// Send platform back if gone too far
    // Check how far moved

        DistanceMoved = FVector::Dist(StartLocation, CurrentLocation);

     // Reverse direction if gone too far

}

1 Like

Don’t leave a blank line between UPROPERTY line and float variable.

Write like this-

UPROPERTY(VisibleAnywhere)
float DistanceMoved = -1;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms