Tackling Building Replication Issues in Unreal Engine 5

Tackling Building Replication Issues in Unreal Engine 5

by Miguel Martinez Olivares

Posted on: 08/04/2023.


The Problem

This week's production tasks led me to deal with an essential problem in our game: the incorrect replication of the building system in Unreal Engine 5. The core of the issue was that when a client player constructed a structure, such as the Dwarven Barracks, it would not appear on the server or any other client's screen, undermining the real-time multiplayer experience of our game. The odd thing was that the problem only occurred when a client player attempted construction, while everything worked perfectly when the server player performed the same action.

This issue significantly affected the end user's experience, halting collaborative gameplay and causing frustration among players who could not see their comrades' contributions to the virtual world. Resolving this problem was of utmost importance, as the fundamental multiplayer experience of our game was at stake.


Problem Solution

    Upon scrutinizing the issue, I found that the root cause of the problem was an ownership issue with the Building Ghost, which is the preview placement of the building. Even though the ownership of the ghost building was assigned from the Player Controller (PC), it needed to be passed through correctly, causing replication inconsistencies.

To address this, I modified the spawning process of the building to be a call inside the player controller. This is a logical solution since each player always owns their controller, eliminating ownership issues and enabling successful calls to a Run-on-Server Custom Event.

The result of this solution was immediately noticeable and cheerful, bringing our multiplayer experience back to its intended, immersive state. The client players can now construct visible buildings for all other players, promoting more collaborative and interactive gameplay. Consequently, this has improved the end user's experience, and the feedback from our testers has been very positive since the fix was implemented. 

[FIXED]
As you can see in this image, the client placed a building, and it can be seen on the server as well. 




Comments

Popular Posts