Good Evening,
I came across a problem when porting my game from 4.9.2 to 4.10. Before I start to explain my problem, let me tell you that this works well in 4.9.2 and does not cause any problem whatsoever.
The issue has to do with the spawning. I have written my own gamemode and overriden “IsSpawnpointAllowed” and “IsSpawnpointPreferred”, as well as created a new class inherited from “APlayerStart”. My class “Coop Player Start” does have a “uint32 checkpoint”.
The idea behind this was that i will simply compare the checkpoint value of the player start and a specifc value in my player-state to determine if the player is allowed to spawn at this position. Of course at the very first beginning both numbers (in playerstate + the default spawn point) are 0. So far so good, but my 4.10 version won’t let me spawn on any custom player start. I can just spawn by using the normal “player start” (and only then when my custom playerstart’s id does not match with the id in my player state).
Even if i increase the numbers and walk to some kind of checkpoint to also increase the value in the player state. Normally if my character dies, it will be respawned at the last checkpoint reached. However if i reach a checkpoint (e.g id=1) and then kill my pawn it won’t respawn anymore at all. I am devastated at the moment because it has to have something to do with the upgrade to 4.10.
I hope that anyone can help me
(I do use in fact nearly the same code to check the spawn points as the shooter example does)
Here are some code snippets (in case this might be helpful)
bool ACoopMode::IsSpawnpointAllowed(APlayerStart* SpawnPoint, AController* Player) const
{
ACoopPlayerStart* PlayerSpawnPoint = Cast<ACoopPlayerStart>(SpawnPoint);
if (PlayerSpawnPoint)
{
ABasePlayerController* PC = Cast<ABasePlayerController>(Player);
if (PC && PC->PlayerState)
{
ABasePlayerState* PS = Cast<ABasePlayerState>(PC->PlayerState);
if (PS && PS->GetSavepoint() == PlayerSpawnPoint->CheckpointNumber)
{
return true;
}
}
}
return false;
}
CoopPlayerStart.h
UCLASS()
class COOPBASIC_API ACoopPlayerStart : public APlayerStart
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere)
uint32 CheckpointNumber;
};
PlayerState.h & cpp
/* id of last savepoint */
UPROPERTY(Transient, Replicated)
int32 LastSavepoint;
//cpp
int32 ABasePlayerState::GetSavepoint()
{
return LastSavepoint;
}
If it helps I can also try to uploade a video of the way it is right now and how it should be.
P.S: If i do have the normal “playerstart” and my own “coopplayerstart” (with id 0) placed in the level, the character doesn’t get spawned and I’m like stuck in the ground and can’t move, like here:
Cheers
Theo
parent game mode: ACoopBasicGameMode
child game mode: ACoopMode
http://puu.sh/lLQEe/3da041e727.png
http://puu.sh/lLQGo/bda0f6c366.png