NavGrid icon indicating copy to clipboard operation
NavGrid copied to clipboard

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

Open DrScientific opened this issue 5 years ago • 1 comments

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();
	}
}

DrScientific avatar Jul 10 '18 20:07 DrScientific

I must admin that I have never tested NavGrid with more than one player and I imagine that there are several things that must be fixed in order to make that work.

It will take a few days before I have a chance to look into this. Should you figure something out pull requests are always welcome :)

larsjsol avatar Jul 11 '18 16:07 larsjsol