In a 2d topdown sprite-based game, I have a procedurally generated tilemap where AI enemy units are spawned in. However, there is an issue (affecting multiplayer only, not Standalone or Listen Server), where the AI is jittery and jumps around periodically on the Client view.
I have uploaded a video of the problem: AI MoveToActor Jitter - YouTube
Any idea what kind of issue could cause this?
The code in question for the AI is very simple:
If the AI is idle → move to actor (player character)
Or, as below:
void AMonsterBasePawnCpp::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (this->HasAuthority())
{
if (this->Controller)
{
if (this->Controller.GetClass()->IsChildOf(AIControllerClass))
{
AAIController *AIController = (AAIController*)this->Controller.Get();
if (AIController->GetMoveStatus() == EPathFollowingStatus::Idle)
{
for (TActorIterator<APaperCharacter> PaperChar(GetWorld()); PaperChar; ++PaperChar)
{
AIController->MoveToActor(*PaperChar);
break;
}
}
}
}
}
}
The actual procedural generation doesn’t seem to matter as I get the same behavior on a premade small tilemap with manually placed units/navmesh bounds. What could cause the AI to have smooth motion in singleplayer but jump around in multiplayer? Note that the above code is the entirety of the AI class other than the constructor. It seems like I’m doing a very basic 101 “move to player” code and it’s not working which almost seems like a bug in Unreal.