In a multiplayer game I have actors that are not always relevant.
Is there any client-side event that gets triggered if the actor is being replicated again?
Or a server event that could trigger a client-side event?
My imagined program flow:
Players spawns, actor is present
Player leaves area, actor is not relevant anymore
Player enters area again, actor is relevant again (I need an event here!)
On clients, when a replicated actor is no longer relevant it is destroyed on the clients sim.
When it becomes relevant again the “client” spawns a new instance based on freshly replicated data.
Use the End Play Event to see this in action.
That being said you should be able to store relevant states on the servers actor instance per client. So when the actor is spawned again locally you can fire specific events/functions.
Add a sphere collision the same radius as netcull distance. You can scale this via construct if needed.
Use OnBeginOverlap event to RPC the server.
Disable this collision Immediately though. EndPlay takes a few seconds to destroy the actor. Leaving it enabled will skew overlap updates.
You can technically leave netcull distance and re-enter. this will keep the actor alive.
In my struct I have a LastUpdate float I check against before iterating. If I had a purpose for this code I’m sure I’d have a different conditional criteria.