Making enemies face player in multiplayer

Hello, basically I have enemy characters in my game and multiple player up to 4. I want enemies to face player, but I want each player to see enemies facing towards them. So rotation of an actor would be different on each client. Player 1 should see an enemy facing towards player 1, and player 2 should see the same enemy facing towards player 2.

I tried many things such as changing rotation of enemy actors with Client RPC, Multicast RPC, calling them on regular functions without any RPC etc. But enemy actors are replicated (SetReplicates(true) is called on constructor) and I am unable to “unreplicate” rotations of them. My enemies are PaperActors with 2d Sprites but I am also open to using regular actors.

Up :frowning:

Any ideas?

Is it skeletal mesh?

It is based on “APaperCharacter” class as it is just a 2D enemy. So I don’t think it has skeletal mesh.

Is component that holds sprites replicate?

My class is just a simple class derived from APaperCharacter, and in the constructor I call SetReplicates(true) because I want actor to be replicated (except rotation).

I also tried with and without SetReplicateMovement(true).

Nothing else is done regarding replication.

From back of my head, on begin play of AI, get all actors of class and check if it is locally controlled. If it is save the ref. Use this ref to rotate sprite component (not the actor).

1 Like