Display Enemy Different on Client


I would like to know what’s the best approach to display a enemy different on the client.
Lets say i want to for every client to see his enemies with a red glow.

I only got one idea how to do that:
For every enemy, wait until it has spawned & replicated on the client, and then change his material to a red glow (ofc only local).
I’m not sure where to do that, but i think the PlayerController might be a good place?

Can anyone tell me if there is any better approach for that?

1 Like

Did you solve it yet? Im also working on the same thing

maybe this video will help, tell me if it did.

BeginPlay is always called on the client after replication so it is the best place to put it.
As for the object, you can really do it anywhere but I would recommend doing it on the Pawn itself. You would also need to do a HasLocalNetOwner check to ensure it is another client.

So it would look something like this:

void ASomePawn::BeginPlay()
    if (!HasLocalNetOwner() /* not owned by this client */)
        // Show red glow.

If your game is more than a free-for-all, you may want to look into using a team system to implement this behaviour instead of HasLocalNetOwner. Unreal has one built in called Team Attitudes (but it’s honestly not that great and I would recommend making your own).