Download

Spline Component replication not replicating contents

Making my spline movement system multiplayer capable, I found, that spline component contents to not get replicated. I have several moving objects (flying birds). All players should see them moving along their splines identically and splines get changed on the fly, e.g. switching from some endless loop towards a path to a navmesh point seamlessly. Works perfect in single player.

Just using Replicate Movement on these actors results in stuttering movement on client side, so I decided to keep movement local and replicate the spline infos to newly joined players along with the spline time.

This works, but I found, that splines are not really replicated as I expected and that I need to do quite some manual work. Took me some time to find out the following:

Spline component added to flying actor using green “Add component” button. Setting checkbox “Component Replicates” and even calling “SetIsReplicated” . Result: new player joins and sees the actor flying along the “default” spline with 2 points, length 100. Same with Spline component added by Blueprint “AddSplineComponent”.

One solution: Just keep a reference to a spline store somewhere else in the spline component variable. (I had this before in a MAP, but for example maps cannot be replicated). So I changed the complete system to local spline components - which seems to be much more straightforward and simpler in code. I do not want to revert back to such a solution again.

The other solution: Copy all relevant content (spline point structure array, spline duration, isClosedLoop) to separate variables and replicate these. In BeginPlay, for remote role copy this information back to the spline component - this works.

Now I wonder, how Spline Component replication is supposed to work. Is it by design, that spline content is not replicated - so what’s the use of it?

BTW: Getting those warnings

LogNetPackageMap: Warning: FNetGUIDCache::SupportsObject: SplineComponent /Game/MpFps/Maps/UEDPIE_0_Level01.Level01:PersistentLevel.BP_Test_2.NODE_AddSplineComponent-0 NOT Supported.

These happen, when I call AddSplineComponent and have replication set for the spline. This makes me believe, that Replication with Spline Components is something not really intended to be used. I mean, just having a checkbox available does not necessarily mean, that it is good to use it at all…

I have the feeling, that my approach of copying all content to extra variables also might not be a good idea and want to avoid a complete rework again later just because doing things too complicated now. Thanks a lot for any thoughts.