I’ve ran into an issue with 4.6 and I’m wondering if you can help me figure out what I’m missing. First of all, this is an issue that only seems to occur in multiplayer sessions.
I’m spawning a pawn at a specified position, but as the game progresses the pawn doesn’t spawn exactly at that position but with an offset that increases with the game duration. I’ve noticed that the initial spawn location is applied correctly: when reading the position in BeginPlay() both server-side and client-side the location matches the location I specified when calling World->SpawnActor(). But within the first tick the actor is displaced with a huge offset, but only in that first tick. During that first tick I get the following warning in the Log which I think is related to the issue:
LogCharacterMovement:Warning: GetSimulationTimeStep() - Max iterations 8 hit while remaining time 26.038601 > MaxSimulationTimeStep (0.050) for 'MyPawn_C_6'
The value 26.038601 is always equal to the duration of the game session. It seems to me that for some reason the CharacterMovementComponent thinks it has 26 seconds of simulation to catch up (as long as the session duration), while it shouldn’t because it was only spawned an instant ago. Does anyone know how to resolve this?
Edit: My code for spawning the new pawn and initializing CharacterMovementComponent below. Nothing special- but am I missing some “init” call that is required for replicated character movement?
In MyPawn class constructor:
UCharacterMovementComponent * CharMove = GetCharacterMovement(); CharMove->NavAgentProps.bCanCrouch = false; CharMove->NavAgentProps.bCanSwim = false; CharMove->NavAgentProps.bCanJump= false; CharMove->NavAgentProps.bCanFly = false; CharMove->NavAgentProps.bCanWalk = true; CharMove->GroundFriction = 0; CharMove->SetIsReplicated(true);
Code to spawn and possess a new pawn mid-game, only executed server-side:
FActorSpawnParameters SpawnParams; SpawnParams.bNoFail = true; SpawnParams.bNoCollisionFail = true; AMyPawn * NewPawn = Cast<AMyPawn>(GetWorld()->SpawnActor(MyPawnClass, &Loc, &Rot, SpawnParams)); if (!NewPawn) return; // Give the player control Player->Possess(NewPawn);