Replicating pointer to not relevant Actor: what will happen?

I am thinking how to create a minimap for a multiplayer game. While some actors that should be shown on minimap may be not relevant as they are too far away from the player pawn, I still need to display them.

What will happen if in always relevant GameState I’ll place a pointer to an actor on server (into replicated TArray), but on the client side that actor is not relevant due to distance (and therefore it doesn’t exist on client)? Will it:

  1. Automatically make that actor relevant since there is a pointer to it in an always relevant GameState
  2. Or the pointer just won’t be valid?

As far as I know you can’t replicate a pointer.

The pointer points to a memory address on the server machine.

The client has a different machine and cannot access the server’s memory.

So the client can only make copies (replicate) of variables.

In short… I think it won’t work.

In Unreal you basically work with pointers everywhere, you confuse reference and pointer

UPROPERTY(Replicated)
AActor* MyActor;

I don’t confuse it… the reference is the address and the pointer points to that address.

You can if the Actor or Component is set to replicate.

  1. No. Having a pointer to a replicated Actor doesn’t affect relevancy.
  2. Depends. If “Net Load on Client” = False then yes then the pointer is invalid while the Actor is not relevant (because the object doesn’t exist on the client) but becomes valid again when it is relevant again (the object is respawned).
    If “Net Load on Client” = true then the pointer continue to be valid while the object is not relevant, but the object can’t receive any replicating updates while not relevant but normal events and functions will still work.
1 Like

It’s a copy? Or does it actually manage the server memory remotely?

The object is identified with a GUID behind the scenes as a part of the replication framework.

1 Like

Thanks for the clarification

1 Like

Net Load on Client is for actors already existing on the map, so actors that are spawned in runtime on server, but not relevant to client, though referenced in replicated gamestate array, will just be invalid on the client, I guess.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.