Replication for actor with "exposed on spawn" variables

Hello guys,

I’ve tried many things and look over the web to understand what I’m doing wrong but in vain. Maybe you can help me
What I’m doing is a mechanic where players can chop trees in multiplayer.

Here is what I’m doing :

When the players finish cutting a tree (Actor : Choppable Tree), a replicated actor Chopped Tree is spawned on Server only (Player 1) at the same location of Choppable Tree and the Choppable Tree is destroyed.

This Chopped Tree actor has variables exposed on spawn such as “Chopped Top Mesh” and a Spline mesh component “Added Spline Mesh Top” (which represent the cut part of my tree). This is because I have several types of trees and want to spawn the right mesh depending on the tree which is being chopped.

I tried setting the meshes of my Chopped Tree both in Construction Script and On Begin Play. My Chopped Tree actor is set to replicated as well as all its component “Mesh”.

This is where I’m not managing to do what I want. Everytime my Chopped Tree is spawned, the meshes are not visible for the clients. My error log indicates me that there is “access none trying to read the meshes”. It’s as if the clients does not have the time to get the exposed variables.

What is weird is that when I set the meshes for “Chopped Tree” in the Construction Script, I manage to get one of both meshes correctly but the bottom part is not spawned. This is causing the tree to fall to fast because there is not collision on the bottom part.

When I set the meshes On Begin Play in the spawned actor, the client does not see any of the meshes for the Chopped Tree top part.

I need the spawned actor to be replicated since I set it as a Physic Actor (I want the players to be able to move the chopped tree with a rope).

I managed to do many things in multiplayer using RPC and so on but I’m stuck on this one. Everytime I need to spawn a replicated actor with variables exposed on spawn, the clients never get the same value for the variables.
What is the correct way to set these exposed variables in time for the client when the actor is spawned ?

Thank you in advance for your help !

I hope it’s clear enough.

Sanglard

I think “Expose on spawn” variables aren’t what they appear to be - by that I mean, I think they are really just a shortcut for “spawn the actor and then set these variables on it” (not a magical way to spawn the actor with those variables pre-set).

Does your chopped tree need values changed at all after it’s spawned? If not, then you can probably just use an RPC to spawn it on each client (i.e. turn Replication off on the chopped tree actor), with the RPC passing through all those values.

When you’re doing things with ‘exposed on spawn’ variables, put your logic in the Construction Script, not the Event Graph

have you tried just setting the top tree mesh in construction script, then doing all the other stuff on begin play?