What is the best way to make Foliage interactable (aka. chop trees for resources like fortnite) with Multiplayer?

Hello,

I am currently trying to wrap my head around a way to make interactable, replicated foliage in UE5. The approach I have been trying so far, is to replace foliage instances with Actors when a player gets near them. However, I cant get the foliage instances to replicate to the other clients.

So what I would love to know is, what approach other games like Fornite take when it comes to foliage that players can interact with.

Other then the above describes approach, I also tried to use actors as trees, but this has some serious performance issues.

So my ideal solution would be able to:

  • Use the foliage system of the engine as base to get tghe best performance
  • Replicate changes in foliage to all clients
  • Also works for client that late join a session
  • Has a way to persist the changes in some way.

Does anybody here have experience they might wanna share? Maybe some Fortnite devs around? :smiley:

Thank you very much!

Hi, I’m not Fortnite dev but this is kinda a tricky task that I worked on and somewhat accomplished what I desired. I suggest you take a look at the hierarchical instanced static mesh component.

You should make a system where if the player tries to chop a tree, the instanced version gets replaced with the actor which is choppable. I will explain how I did mine. :slight_smile:

So first, make your instanced component:
image

Then head into your foliage types and set all your trees to use that component:

Now for multiplayer, this way might not be the best to do this because I’m still learning networking logic however I got it to work as I wanted:

Even though this works as I wanted it to, it probably won’t work as intended with clients that join a session late. For that I believe you must store the state changes in an array since every instanced foliage actor has the same ID on client and server (I believe).

I’ve found this thread which talks on that specific issue and how to handle it:

Anyway, I hope this helps. Best of luck!

1 Like

Hey.

Thanks for taking the time to answer. I am currently trying you suggested solution. The only issue I am having is, that I cant get my array of instance IDs to replicate. I’m keeping track of it in a Game State Component and when I try to simply replicate a single int, it works. Just not for an array.

Is there some special sauce for replicating arrays?