You have an authority check before the “wait for pawn ready” validation. So I guess this code is running on the server? If so, this doesn’t make any sense lol. There is no replication or any network delay on server side.
IMO each actor should be responsible for waiting necessary values / initial replication on their own. What I did for my plugin was create a basic “wait initial replication” system. It looks something like this:
In your actor’s BeginPlay for example, call your custom WaitInitialReplication function.
WaitInitialReplication function continuously calls IsInitialReplicationComplete via a timer.
IsInitialReplicationComplete is an overridable function that returns either true or false. Actors can override this function to basically make a list validation checks for themselves. This is all happening locally!
When IsInitialReplicationComplete returns true, I call a custom OnInitialized event.
Now I can do any actor specific initalization in OnInitialized.
Hi STRiFE.x
Thank you very much for sharing your method.
I’m going to try it.
Yes, I think I did it in the worst possible way.
My idea was all the pawns to notify the GameState through the PlayerState when they would be ready. And then start the game. (the last code was in the PlayerState, this was the file that was corrupted). The strange thing is that I tried it for several hours and it worked correctly until the editor crashed… And from that moment no other blueprint could be edited… it was a terrible experience. Fortunately everything worked again to remove this file.
I will follow your instructions.
You are the only person who has given light to illuminate this path.
I am very grateful to you.
What do you think about it?
Is it correct to do this to differentiate between a player and an AI? Or do you think there is a more correct way to do it?
I’m not 100% sure if what I’m about to suggest is correct, but if a PlayerState starts BeginPlay and resolves the Cast to PawnCharacter(IsValid), you can clear and invalidate the timer by handle. And then proceed with other functions. Executed inside the PlayerState.
AI doesn’t have a PlayerState.
I was thinking for the AIs to communicate directly with GameState since certainly the AIs don’t have PlayerState… GameState generates a Fake PlayerID for the AIs… this works for me perfectly for the scoring system. It only worries me that the pawn components do not load correctly in all their replicas since this could cause a null reference or that it does not load the skin correctly. At the moment the Casting to playerController when it’s an AI fails and that’s good… I just want to make sure that it’s the correct way to do it.
when you look at the 5 minute mark at the chart in the video, you can see that the Pawn and Controller are resolved separately(different branches). That’s what’s to keep in mind. When a pawn has a valid character, the HUD(in the controller part) might not have a valid reference of the character. Atleast that’s how I understood it. It’s almost like two separate top levels.