AI controlled vehicles stop working when Physics Prediction is enabled

Hey!

In our game we have cars using Chaos Vehicle Movement, ChaosWheeledVehicleMovementComponent, these can be both driven by players and be AI Controlled to drive around themselves. We are currently investigating if we can enable the Physics Prediction in the project settings to improve how the physics feels in Multiplayer.

But we have noticed that when we enable the setting the AI driven vehicles stop working, they are no longer driving around. I have tried looking into why that happens but can’t find specifically why it’s not working. I have seen that some functionality in the ChaosWheeledVehicleMovementComponent is disabledif the project setting is enabled. They are however still working for players when they try to drive around, so might be related to the AI driven vehicles not having a player controller.

How does the chaos vehicle movement change when physics prediction is enabled?

And is this correct, that AI driven vehicles should not work when Physics Prediction is enabled? Or is it something that I can fix?

Some help would be appreciated, thanks!

I believe you are correct that a check for a player controller that may be the underlying cause. I believe it is not a “by design” but rather missed check as the ChaosModularVehicle appears to work with non-player controllers. I can come at this from the AI side of pathfinding and pathfollowing, but I think this is best served with input from our Chaos team for a full fix rather than mirroring the modular vehicle approach completely.

-James

Hi folks.

I’ll loop in our Network developer for Chaos who should be able to help

Geoff

Hi Joar,

Just a quick heads up that the dev I’d like to take a look into this is on holiday at the moment, he is back next week.

Geoff

Hello [mention removed]​ This is a bug with the Chaos Vehicle using the Networked Physics flow indeed, we are not activetly testing AI with networked physics (which is still experimental) at the moment.

One quick fix for now could be to make a change in FChaosVehicleManagerAsyncCallback::ProcessInputs_Internal inside ChaosVehicleManagerAsyncCallback.cpp

AController* PlayerController = VehicleInput->Vehicle->GetController();
if(PlayerController && PlayerController->IsLocalController() && !bIsResimming)

This should allow it to find the AI’s Controller, not just the player controller and enter that if-statement correctly which is most likely the reason the AI can’t move the vehicle.

If your AI vehicles doesn’t have a controller, then this won’t work, instead it needs a more involved approach where it checks NetworkPhysicsComponent->IsLocallyControlled() and NetworkPhysicsComponent->SetIsRelayingLocalInputs(true) also needs to be set on the server (only on the server) for AI controller vehicles.

I’ll try to get a proper fix into an upcoming UE 5.8 release.

Note though that networked physics is a large and complex system, not a plug-and-play feature that makes some smaller improvements on how objects look/feel, it fundamentally changes how the vehicle is networked and how physics in general is networked and replicated. So going that route for your game is a large commitment.

Here is a “tutorial” about the fundamentals of this system: https://dev.epicgames.com/community/learning/tutorials/5E4w/unreal-engine-networked-physics-fundamentals

Alright, I’m relieved that it’s likely not by design.

Are you able to forward the question to the Chaos team?