# Hierarchical instanced static mesh replication? Problem with tree harvesting system

**URL:** <https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-replication-problem-with-tree-harvesting-system/538566>\
**Category:** Multiplayer & Networking\
**Tags:** Hierarchical-Instanced-Static-Mesh, Replication, unreal-engine, Blueprint, question, UE4-27\
**Created:** [April 24, 2022, 6:00pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-replication-problem-with-tree-harvesting-system/538566 "2022-04-24T18:00:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [April 24, 2022, 6:00pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-replication-problem-with-tree-harvesting-system/538566/1 "2022-04-24T18:00:42Z")

</div>

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/5/0c50ea2ae546cdf2e81e6fc153ae3e38a6bc5756.png)

- 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:

> [@Instanced Static Mesh replication issue](https://forums.unrealengine.com/t/instanced-static-mesh-replication-issue/33429/5):
>
> I am hitting a tree which is a instanced static mesh component, it is supposed to disappear because I am setting scale to 0, and another actor is supposed to appear in the same spot, looking exactly like that tree and immediately fall down (just rotation) because that’s all it does for now. And this is exactly what happens on the server. On a client all the same things happen, except the instanced tree doesn’t get scaled to 0, or to any other value, or moved, or rotated (I tried various things)…

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!

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [April 24, 2022, 6:44pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-replication-problem-with-tree-harvesting-system/538566/2 "2022-04-24T18:44:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![isikdev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/isikdev/32/991020_2.png) [@isikdev](https://forums.unrealengine.com/u/isikdev)\
**Post date:** [April 24, 2022, 7:08pm UTC](https://forums.unrealengine.com/t/hierarchical-instanced-static-mesh-replication-problem-with-tree-harvesting-system/538566/3 "2022-04-24T19:08:42Z")

</div>

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