I’ve made a UWorldSubSystem child class to hold all the grid positions of my map to do some position verifications for the player movement. But I struggling to get the instance of that class in the player script, all tutorials I’ve found shows only how to get a GameInstance and the way I’m doing is getting me null. Any help?
The SubSystem class
UCLASS(Blueprintable)
class DUNGEONCRAWLER_API UMapGridInstance : public UWorldSubsystem
{
GENERATED_BODY()
public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
UFUNCTION(BlueprintCallable)
void AddNodePosition(ANodePosition * nodePosition);
UFUNCTION(BlueprintCallable)
int GetGridSize();
bool CheckForPosition(FVector position);
class ANodePosition* GetNode(FVector position);
void SetNeighbours(class ANodePosition*);
private:
TMap<FString, class ANodePosition *> gridPositions;
TArray<FVector> direction;
};
UMapGridInstance* GameInstanceRef = Cast<UMapGridInstance>(GetOwner()->GetWorld()->GetSubsystem<UWorldSubsystem>());