*** CLOSED, can’t reproduce the problem in UE4.1 ***
Hello there,
i’m currently trying to spawn 4 pawns during the SpawnDefaultPawnFor call in my custom game mode. All 4 pawns are to be controlled by the same controller sequentially, not concurrently. During runtime, I can successfuly possess each pawn in turn using key input I defined.
However, the first time I possess any of the other pawns Nr. 2 to 4, the orientation and animation cycles are wrong: The pawns remain facing north in the client and seems to be in a walk animation, though they should be idling.
After possessing each of the 4 pawns, they suddenly behave correctly as expected when navigating with them.
If I connect a second client to the session, the navigation and animation of the pawns from the 1st client look correct though, even as they show up wrong in the initial, 1st client’s window.
Also, this behaviour occurs on all maps i’m testing with when a second client is connected too.
Running without the dedicated server handles fine, I can switch between the 4 pawns and they move and turn correctly immediately on first possession as expected. I’m assuming it’s a replication issue, I’m probably missing something I need to set on the ACharacter derived class.
My questions are:
Am I missing some initialization of the pawn when it’s first spawned?
Is it correct to spawn all pawns of the group in the call SpawnDefaultPawnFor of the game mode? At the end of the call, I store the APawn references in the controller class they belong to.
I might have this wrong, but you said that “All 4 Pawns are to be controlled by the same Controller sequentially, not concurrently”, yet your “newPawn->SpawnDefaultController();” is within your for loops, thus you’ll actually spawn multiple controllers, each controlling one pawn, not just one controller possessing each pawn at a time. Could that not be your problem ?
If that’s the case, you should move the “newPawn->SpawnDefaultController();” to just before “return myController->GetActiveTeamMemberPawn();”. That way you’ll only spawn one controller and you can iterate through all your newly created pawns one at a time and posses them.
sadly this variation produced exactly the same result as before. I also tried not calling any SpawnDefaultController() methods in both code variations. My initial assumption was that any controllers spawned for the pawns would be cleared by the possession which probably takes place after the GameMode returns from the SpawnDefaultPawnFor().
What I don’t really understand yet is why the pawns each behave correctly the second time they are possessed at runtime, but my assumption is a missing initialization step which is done automatically later when I change possession.
I’m using UE4 v4.0.2 regular install not built from GitHub code.