Download

Tilemap changes not replicating

I’ve been slowly getting my head around replication for the last couple of weeks, but I’ve run into a bit of an issue.

For context, I’m working on a 2D level generator. The basic way it works is the Listen Server adds in a completely filled tilemap section (actually an actor with a tilemap component). It then determines which room to add and where it needs to go, and then the room is “carved” out of the tilemap by removing/updating the appropriate tiles. This process loops until the level is complete (additional tilemap sections are added as required).

Currently it works great on the server, but I’d like it to replicate to clients. The issue I’m having is that, while the section actors are replicating, the tilemap components appear on the client in their “original” state, i.e. completely filled with no rooms carved out. I’ve tried checking the “replicates” checkbox for both the actor and component. I’ve also tried setting the component to replicate after the tilemap has been updated.

I’m just wondering if tilemap changes actually replicate, and is there something I need to do to make this happen? Or if they don’t, does anyone have any ideas for a workaround?

Just as a followup, in case anyone has any experience with this. I was recommended to add a multicast event for the “set tile” node. This **does **update the tile map for clients, but they generate a different room layout to the server. Which makes me think there is either a bug in my blueprints, or having so many multicast events firing in a loop is a bad idea :slight_smile: It also throws a runtime error:

Blueprint Runtime Error: “Accessed None trying to read property BGTilemapReference”.

(BGTilemap is the name of the actor that contains the tile map)

I would have thought that if the actor is replicated then a multicast event shouldn’t be required, but maybe I’m wrong? Does anyone have any suggestions on this?

Hi, you can only call the same RPC (Multicast, RunOnServer, RunOnOwningClient) twice per frame. Also they might get dropped due to network bandwidth problems, if you do not mark them “reliable”.

Ah that’s good to know, thanks! I’m still at a bit of a loss as to why the tile map changes don’t replicate, but I’m going to try to rewrite it so that it only calls 1 multicast event, rather than multiple in a loop. Hopefully that’ll improve things.