Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

GridPawn.cpp: State->Grid is NULL when 2 or more players  #8

@DrScientific

Description

@DrScientific

Hi!

I'm attempting to alter the code a bit to make it work for a multiplayer game, but I've been running into this issue when the player count is increased to 2 or more (State->Grid is NULL.) This holds true for the original plugin without any of the edits I've made to it. I'm a bit stumped as to why this error is occurring other than perhaps multiple game states are being made when there is more than one player and one of the states is not being initialized correctly. That seems unlikely though, I would think only one game state is created. Anyway, if you have any idea as to what might be causing this I'd appreciate the input. Thanks!

void AGridPawn::BeginPlay()
{
	Super::BeginPlay();
	auto *State = GetWorld()->GetGameState<ANavGridGameState>();
	check(State && State->Grid);
	Grid = State->Grid;
	SelectedHighlight->SetRelativeLocation(FVector(0, 0, Grid->UIOffset));

	ATurnManager *TM = State->GetTurnManager(TeamID);
	check(TM);
	TM->Register(TurnComponent);

	if (SnapToGrid)
	{
		MovementComponent->SnapToGrid();
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions