Replicating Get Hit Result Under Cursor by Channel

Hi,

I have a character BP setup for aiming my upper body (torso) towards my cursor. However cursor position will not replicate and so each of the spawned players see all other players torso’s aim towards their own mouse and vice versa.

Clearly the cursor hit result is not being replicated on other machines and is run locally only, should I make replicated variables of the X Y Z rotation of the torso and instead use them to “update” player rotations to other clients or is there a simple way to get the host to replicate the clients cursor (Get Hit Result Under Cursor By Channel). I understand that this is very likely a simple and stupid question, but I am only an artist so please bear with me.

Info: I have been stumped by this particular caveat for a lot more time than I would like to admit, aha. That said, I have managed to get everything else working, replicating and mostly (ha) in sync on my Character: Health,damage,movement, stamina, speed, rotation of lower body & animation. And am working on the weapons now. So that only leaves the aiming as a problem. I hope someone can give me some insight or a link to a tutorial that covers replicating a Hit Result By Channel - preferably under cursor. Thanks for enduring my ramble ;).

Okay, so still working on it. I have come think that you cant replicate the cursors position since its a client side variable(?) and variables do not replicate back to the authority only from, but you can replicate events such as move mouse X/Y - this means I need to make another axis of rotation using these inputs and have them replicated instead, and base the current (HitRusultUnderCursor / find look at rotation) system on these axis of movement in order to replicate the Hit Result (and thus rotate the client torso using mouse XY input rather than mouse position)

Am I on the right track anyone? I will literally just base if off mouse inputs instead and use a server side hit result based off its replicated position to orient the clients upper torso (Which is like remaking a mouse input - & not using the raw mouse pos?). Sorry its 2 am and this is a fairly important milestone in my project so please forgive bad English/nomenclature. If there is any way to replicate mouse position without using its inputs I would dearly like to know. Cheers.

Playercontrollers can replicate from client to server because they are owned by the client and have authority. So, use your player controller to store the hit result in a variable. Replicate the variable of the hit to the server and then multicast to all the clients. Then when handling all your other calculations just use the stored (and replicated) variable

Thanks mate, I will try this now.

Okay, Inside of my controller it sets the replicated variable containing the hit result each tick (It does the line trace inside the controller). Then inside my Character Blueprint I get this data with a cast to Controller using a Run On Server event, the calculations carried out therein use this (get controller hit result) and are executed by a multicast in the character blueprint. Currently this is resulting in the Host/Listen Client functioning as expected; except all other clients aim at his mouse in his view port (the authority’s). Meanwhile all clients are stuck aiming at a separate but shared point across all their view ports resulting in a desync between them and the authority but not between each other. The server still cant get the client controller’s Hit Result variable- (named Controller Mouse in the shots below).

I have little experience with casting, having only got it work on my weapons recently - and they still need more fiddling. So hopefully what I have done wrong here will be painfully blatant. :slight_smile: I’m sure I can figure the rest once I can actually get the client variable to be retrieved by the host.