So I’m trying to extend the ThirdPerson prototype so that the character looks in the direction that the mouse cursor is pointing.
I’ve managed to get everything working fine locally, and I’m now trying to get it functional with multiplayer.
I’ve watched the tutorial videos that were just posted about replication, so I’m pretty confident I have a reasonable handle on the topic at hand.
However, when I try to modify my existing script (by calculating the new rotation and using RPC to send it to the server), I’m only seeing the rotation being updated on the server. This is puzzling, because the Character BP instance I’m editing has the option for replicating movement enabled, so changing the actor’s rotation on the server should then see it being replicated to clients if I’m understanding right. I tried using a RepNotify variable instead, and the Character oscillated back and forth between my new value and what it would be without my script overriding, leading me to think that there’s something in the base class that the BP is based on that is potentially overriding my attempts to set the rotation.
Can anybody shed any light on this, in particular if this looks like an issue in the base class, or is my replication implementation incorrect?
Unfortunately this doesn’t work. Indeed, it *shouldn’t" work. If you note the custom event node in the first screenshot, it is replicated from the client to the server, meaning that that execution wire will only ever be run on the server anyway.
This did remind me - remember how I said in my OP about it feeling like something was overriding things? What was happening was that the server was also trying to calculate the lookAtRotation for all clients, and of course serverside the mouse has no coordinates so it was overriding the client calculations. The solution is, therefore, to just run the LookAtRotation on the client only, then RPC the calculated value to the server.
This brings me to the original issue, from way back before I made this post - this works fine when running with a dedicated server. When we are running a listen server we have a client who technically is also the Authority, in which case this solution won’t actually work, because the client who is hosting will hit the check for authority, say ‘yep I’m authority’ and then not bother to calculate for its owned pawn. Is there a way for me to see if the current controller/character/pawn is owned by the hosting client?
I’m interested in this as well.
Can you go into more detail about your client side setup?
Answer is easy, also drive “Switch has authority” remote node to “Set Actor Rotation”.
Right now your client is only sending that RPC to server, and doesn’t execute it for yourself.
So basically it tells to the server: Rotate my entity, but i don’t care to rotate my own.
Server only replicates movements automatically if you “tick that option”, not rotation.
Hey, I’m trying to implement this type of functionality in a multiplayer game as well, where each player can independently rotate towards their cursor position, and have that rotation replicated across all clients.
Have you found a solution for this?
Has anyone figured out this problem? I am running into the same issue too. However my issue might be different in that all clients’ rotation seem to replicate in such a way so that other clients see them as always pointing at 0,0,0. My guess would be that the server doesn’t know where the client’s mouse is, so when I call ConvertMouseLocationToWorldSpace, it just reports back 0,0,0? I don’t really know.
I’ve had the same thing happen, and that’s my guess as well. The server’s version of each playercontroller isn’t (arn’t?) getting an updating mouse location.
Have a look at my comment below - I partially resolved the matter, but it doesn’t work with a listen server.
I made up a test to see if it is that rotation is not replicated or as twiddle suggested.
I replaced my look section of my blueprint with add rotation and just put in a value or 10 on z axes and hay presto twiddle was right. Both characters were spinning round and round on both client and server.
I’m still no closer to getting it to work though, I just don’t know what nodes I’m meant to be using for this. if anyone solves this please let me know.