Moving Platform category not available after closing and reopening editor

Everything work properly before closing the editor.
When reponing the editor, the Moving Platform category (see pics) on the BP_MyMovingPlatform details was unavailable. When recompiling my c++ file the Moving Platform category becomes available again. Still, once the editor is closed and reponed once more the Moving Platform category is unavailable again I recompiled the c++ once more, and so on…
Not sure what I am doing wrong?

After reopening Editor

After recompiling c++ files

Header file

// 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 OBSTACLEASSAULT_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 Platforme") 
		FVector PlatformVelocity = FVector(100, 0, 0);
	
	UPROPERTY(EditAnywhere, Category="Moving Platforme") 
		float MaxDistanceTraveled = 100;

	FVector StartLocation;
	
};

c++ file

// 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
// DeltaTime tells how long a frame takes to execute, makes the game frame rate independent, for example velocity for moving object
void AMovingPlatform::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	// Move platform fowards
		// Get current location
	FVector CurrentLocation = GetActorLocation();
		// Add vector to that location
	//CurrentLocation.Y = CurrentLocation.Y + 1;
	CurrentLocation = CurrentLocation + PlatformVelocity * DeltaTime; // DeltaTime tells how long a frame takes to execute, makes the game frame rate independent, for example velocity for moving object
		// Set the location
	SetActorLocation(CurrentLocation);
	// Send platform back if gone too far
		// Check how far the platform has moved
	float DistanceMoved = FVector:: Dist(StartLocation, CurrentLocation);
		// Reverse Direction of motion if gone too far
	if (DistanceMoved > MaxDistanceTraveled)
	{
		// If platform is moving very fast it can overshoot the StartLocation, the DistanceMoved is significant greater than MaxDistanceTraveled
		// it is depending of the DeltaTime, in other words, the consequence is that the original starting point can drift over time
		// GetSafeNormal() It returns a normalised vector. It’s a vector going in the same direction but with a magnitude of 1 i.e. it only has direction (-1, 1).
		// The ‘Safe’ in GetSafeNormal just means it protects against a potential divide-by-zero.
		FVector MovedDirection = PlatformVelocity.GetSafeNormal();
		StartLocation = StartLocation + MovedDirection * MaxDistanceTraveled;
		SetActorLocation(StartLocation);
		PlatformVelocity = -PlatformVelocity;
	}
	
}

Thanks

Well I found how to fix it
the Live Coding Issues lecture (Video Reference: 9a_OA_EC5).

:confused:

Did you have any problems with that? If it’s solved please mark your comment as solved.

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

Privacy & Terms