Hierarchical instanced static mesh replication? Problem with tree harvesting system

Hello! I am working on a project where in a large landscape, the foliage is procedurally spawned. I tried making a system where if the player tries to chop a tree, the instanced version gets replaced with the actor which is choppable. It works ALMOST correctly, however I’m having some trouble with the replication.

What I did was, from the player character, on keypress, call a server event, which calls a multicast linetrace (i know its dumb, but only solution that came close to working), which then sets the hit results into variables, then calls a server event which spawns the tree at the instanced one’s location, then finally a multicast event which basically removes the instance.

  • In game, after doing this, replacement logic works. If client tries to chop instanced mesh, it replaces it with a choppable actor. Shows on server.
  • If server tries to chop instanced mesh, replacement works again, however for the client the instanced mesh does not get removed.

Video demonstration:


Edit: OBS scammed me x) Left is server Right is client.

I have digged through the forums and found this post:

Exactly my problem. And the solution doesn’t seem to work for me. I’m not sure what I am doing wrong/missing… Please if you have any idea how I could overcome this problem, let me know. Any tips appreciated!

Try passing the index with with your multicast call to replace tree. It looks like your client won’t know what instance to replace in this situation.

When I do these types of things, I will do the traces on client, if I hit something THEN i will call the server RPC to do a trace and see if I hit something, only on the server. Then if you hit something multicast to all to replace tree. That way you aren’t running RPCs for each attempt.

Edit: make sure these are reliable calls as this requires all objects to stay in sync.

Yeah I just had to pass the index… Thanks for your tip as well, I will be checking it out!