I wanted to make 2 playable camera pawns move around a space. I created basic movement and made a super simple model from 3 basic meshes. On PIE p2p spawn, 2 players are created fine. the server moves, and its movement is replicated to the client. When the client moves, nothing. I have this in my cpp inherited file:
and i tried to use DOREPLIFETIME but it said that isn’t inherited by the Pawn class. My BP file looks like this:
and every component is set to Component Replicates. I dug through a LOT of forums, and they said to use CMC, the Character Movement Component. Its useless because Im using a rigless pawn with no need for physics. I found in a different forum to use the server to replicate the movement, so i followed the instruction and make a custom event that uses Multicast to set the actor location. Result? Same exact thing.
I just dont understand why everything i read didnt do anything. setting any of the replicates variables, the movement replicates, the multicast event. NOTHING changed anything. Not a single new bug. I thought about creating and spawning a whole new player controller to fix this, but from what i read, a player controller is the machine the player is on, hence why multiple people can have their own window, but a single controller.
I finally found the answer. Heres the in-depth guide to this nonsense:
Character replication in UE45 is automatically handled by the CharacterMovementComponent. SUPER useless if youre not wanting to use a character. Not everyone has to have a body, or obey to physics.
So, the solution is to ensure you have proper replication from client to server is to run the teleport function on the server. You CAN use vectors for smooth movement, but its completely optional. I will provide screenshots for both answers.
In this image, I am taking the Strafe, MoveUp, MoveForward, and Wheel Axis values and passing them through the MovePawn function with the vector i wish the pawn to travel along. I then created a ServerRPCMovement custom event. Its MUST be set to RUN ON SERVER AND NOT BE MULTICAST. The entire pawn can be set to replicate along with all the components, however, its not required for this solution to work.
Validate Camera Position is just a function that deconstructs the position vector and ensure every value is within bounds. I then call SetActorLocation LOCALLY AND THEN finish is off with Server RPCMovement. This is then run on the server and teleports the player.
For acceleration and smoother movement, you may use AddInputVector: