Download

Replicated Vehicle Physics Implementation

I’ve been working on a networked physics vehicle implementation. I don’t have much experience with UE4, but I have been exploring the AWheeledVehicle, UVehicleWheel, and UWheeledVehicleMovementComponent (+4W) classes. It seems conceivable that I could create a passable vehicle; my concerns are around replication.

The game I’m developing is meant to be played over the network, and I am concerned about the rewind/replay aspect of networked physics using PhysX (which I admit I don’t know much about; I’m planning to learn more). I had client-side prediction issues with Unity’s implementation so I thought I would give UE4 a try. In digging around, I’ve noticed assignments and methods in the aforementioned classes that seem to suggest they support replication and physics simultaneously, and by default, e.g.:

In WheeledVehicle.cpp


AWheeledVehicle::AWheeledVehicle(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
    ...
    VehicleMovement->SetIsReplicated(true); // Enable replication by default
}

In WheeledVehicleMovementComponent.h/cpp there are many references to replication. The replicated vehicle state is established and replicated state values are applied for remote pawns every tick.

Am I heading in the right direction for a networked vehicle physics implementation with client-side prediction? I’ve read here and there that Epic have some vehicle code in the works – will I be rewriting everything in a few months if I go down this path now, or will my work remain relevant? Any guidance or ideas are very welcome. I still don’t have my head around this stuff but I’m planning to start putting a lot of time into it starting as early as tomorrow, and the engine code that I do understand looks promising.

Thanks! Apologies if this post belongs in a different section.

Edit: I asked this as a question on the answer hub in case that’s a better location for this: Questions about Vehicle Physics and Network Replication. - UE4 AnswerHub