So I spent the better part of a day and a half tearing my hair out trying to solve this problem. Now that I have it working somewhat reliably, I would like to share the pitfalls I ran into.
My goal was to set the player loc and rot to a specific place once the game start. My game has two players sitting in a chair so I decided to use an extra scene component on my chair actor to decide where the player sits / looks at. Trying to set the position at the beginning was trivial, however setting the rotation was a bit more difficult to figure out.
When replicating you must set the player position on the server. When setting the player rotation this must be done through the Player Controller, however, the server’s client Player Controller (PC01) DOESN’T control any pawn’s. Therefore, since Player Controllers are only local to a players machine and not shared with other players, you must rotate on client and NOT on the server. This was my first issue with this, there is another problem that took me most the day to fix and I still don’t completely understand why.
Above is my current solution to finding an open seat and then setting our players seat transform variable. Initially I was using the random node to pull a random item from the Out Actors array of my Get All Actors Of Class, but I was having issues with the players sitting in the same seat. I starting trying to use the Random Integer In Range after spending hours not being able to get the Random node to work. It wasn’t until later that I realized when you string the output of a random node or a random integer in range to multiple locations it will roll each time. That’s why you must set it to a variable as soon as you roll and only use that variable. However I still have issues with the random node, even now, I still have occurrences where the client will randomly spawn in the same loc/rot as the host. Below is how I tried this setup after thinking and writing this out, but it still sometimes teleports the client to the host’s loc/rot.
Any thought’s on why this isn’t working would help soothe my brain, otherwise, hope this helped someone.
Edit: Updated first two pictures to make it flow better by setting SittingTransform after getting our transform. Didn’t update 3rd pic because you can see what changes have been made to main process.
Edit 2: Just found out that the same method applies to setting the clients camera transform. You can’t do this through the server, your flow needs to check if the character is an owning player instead of looking for authority. Clients have to change their own loc and rot for the camera and rot for their character actor.