Hi,
I have this class:
#include "CoreMinimal.h"
#include "Pathfinder.generated.h"
class UPathPoint;
UCLASS()
class MASS_API UPathfinder : public UObject
{
GENERATED_BODY()
protected:
UPROPERTY()
UWorld* World;
public:
UPROPERTY()
TArray<AActor*> IgnoreActors;
UPROPERTY()
int MaxSteps = 10000;
UPROPERTY()
float StepSize = 25.;
UPathfinder();
~UPathfinder();
UFUNCTION()
void GetFlowMap(const FVector2D Start, const FVector2D End, TArray<UPathPoint*>& FlowMap);
UFUNCTION()
bool IsCanWalk(const FVector2D A, const FVector2D B);
UFUNCTION()
void BackTrack(TArray<UPathPoint*>& FlowMap, const FVector2D Target);
UFUNCTION()
bool IsFreeSpace(const FVector WorldPos)const;
UFUNCTION()
FVector2D GetClosestMoveablePointTo(const FVector2D From, const FVector2D Target)const;
};
It compiles, but I got Access Violation Error right at the start of the GetFlowMap function to the StepSize property.
this is the begining of the Pathfinder.cpp
#include "Pathfinder.h"
#include "Engine/World.h"
#include "Ext.h"
#include "PathPoint.h"
#include "Kismet/KismetSystemLibrary.h"
UPathfinder::UPathfinder()
{
this->World = GetWorld();
}
UPathfinder::~UPathfinder()
{
}
void UPathfinder::GetFlowMap(const FVector2D Start, const FVector2D End, TArray<UPathPoint*>& FlowMap)
{
//Ceil positions
FVector2D CeilStart = UExt::CenterToSize(Start, StepSize);
FVector2D CeilEnd = UExt::CenterToSize(End,StepSize);
//Check existing flow map for start location, if contains, then return, it is solved.
if (FlowMap.ContainsByPredicate([CeilStart](const UPathPoint* Point) {return Point->Pos == CeilStart; })) {
return;
}
What did I wrong?