Posted March 16, 2024 by Bjornoid
Problem:
One thing I tackled this week was to refactor the base interactable class and all its child classes. One of the issues we were having before was that it had bad and messy code because it was not correctly replicated. Because of this, there were weird work arounds in place that caused warnings to popup in the logs and caused noticeable client side latency. Out of the three child interactables: Buyable Door, Weapon Wall Buy, and Revive, the Revive had the most issues. It had the worst latency when the client player was reviving the server player.
Solution:
The Solution when refactoring was to first make all interactables spawn on the server and be set to replicate, and also have Net Load On Client checked if it needed to be dragged in the level. Once this was the case, all the logic for being interacted with by the player through the IIneractable interface was now run on the server. This makes it more smooth and warning free, and also has noticeably less latency while reviving. It also enabled me to delete some of the old work around functions and clean up everything to be more readable.