Problem With Character rotation on Client

Hey Everyone. I Have been trying to figure this out for about 3 days now and have NO luck. So i’m trying play around with networking with a top down style game. the characters rotation follows the mouse location. The character always faces the mouses direction. It works perfect on the Server and i can see the servers character rotating on the client screen, but I just cant get my clients character to rotate. when playing with a dedicated server I cant get any rotation from any client whats the deal? Below are some blueprints of what i have so far.

I have no idea what i’m doing so if these blueprints are very bad feel free to tell me. id much rather start from scratch then spending another 3 days trying to find the answer. Although i value all of your suggestions and anything would help, if you can provide a blueprint example of the points you are trying to get across that would help me tremendously. Thank you all!

Ouch… 3 days? don’t be shy xD we are here to help :stuck_out_tongue:

The server and client are probably both replicating the mouse location at the same time so seems the server-side pawn (all pawns which have a client, also have a server side) overrides whatever the client tries to send.

If you are going to update the rotation per tick, then it would be a good idea to use the character movement component (which already handles replication) instead of doing all that “manual” stuff :stuck_out_tongue:
I can make an example project for you if are still having trouble with this.

thanks for the quick reply! ill give it a shot and then let you know if i still need a blueprint!

How do i use the character movement component for my rotation?

I found a RotatingMovement Component. is this what I am supposed to use? I guess i am just very unfamiliar with what I’ve gotten myself into haha. I’m not even sure how to use the rotating Movement Component or the CharacterMovement component.

You need your player blueprint to be based on the Character class in order to use the CharacterMovement component (the character blueprints for most of the example projects such as ThirdPerson, FirstPerson, TopDown etc. uses this).

I used the TopDown example as test and I was able to do this by adding this into the TowDownCharacter BP:

Make you have “Use Controller Desired Rotation” enabled in the CharacterMovement component.
Then make you set the camera to be facing directly down (-90 degrees on the Y axis of the spring arm) or else you will probably have to do a trace instead of using FindLookAtRotation.

Also I deleted all the stuff from the TowDownController BP, you only need to enable the mouse cursor in there.

Let me know if you have any problems!

Sorry, I just realized there is a better way… you can simply add this into the TopDownController blueprint instead of my previous example:

And since we are using GetHitResultUnderCursor instead of mouse coordinates we can have any camera rotation we want (no need for it to be directly facing down).

Keep in mind, you still need the character movement in you character blueprint with “Use Controller Desired Rotation” enabled.

Enjoy :slight_smile:

wow… this was much simpler than I expected it to be. It is working just dandy now. THANK YOU! this really helped me!

ok so turns out it has caused my character to move relative to the character instead of relative to the world like id like for it to. for example. I press ‘w’ to move forward 5 meters, then I turn 90 degrees to the left and the pressed ‘a’ to move left 5 meters. I would end up where i started. any idea how to fix this?

This is how I handle movement. I can see how this would cause a problem since i’m getting the control rotation.

EDIT: Well I fixed it. I used a make rot node and just left all of the values at default ‘0.0’. it seemed to solve the problem. seems a little unorthadox though haha. :stuck_out_tongue:

I’m sorry, I know this is a late comment, but the image in your response is down, and can’t find answers for this topic in other places. Is there any chance you bring the image back, please?

Not really, it’s been years mate, the images are gone forever I guess (has happened to a lot of threads, since epic “upgraded” the forum unfortunately).

However I can try and help… from what I can read it seems that I used the TopDown example content that came with the editor and used it to make the character continuously rotate towards the cursor, also probably added the replication stuff so it works on clients.

Is that what you’re trying to do? or what exactly are you trying to accomplish? let me know… and perhaps I could try to recreate that blueprint TopDown example…

1 Like

Thank you very much for your answer and for the pic, I’m sorry I’m so late, work has had me caged lately.
Yeah, it resembles a bit to that(in terms of replication), I came here because of a recommendation from another forum.

I was trying just to add a box(StaticMesh) that follows the camera’s ‘‘orbit’’ around a default 3rdPersonChar. It sounds very easy, but its movement wasn’t replicating in the clients at all.

It kinda goes like this:

  • I have a 3rd person Map by default.
  • I set it to Listen Server +2 clients
  • I changed the default GameModeBase for a GameMode because I’m been told the second one is specially made for multiplayer games.
  • on the (box) StaticMesh component I checked the box for replicating

Then first I made it children of the camera and later, of the spring arm and didn’t work either, even when I marked those to replicate too

After that tried to make the box mesh follow the camera movements via blueprints, didn’t work (that’s how I got here)

Finally and following an idea your pic gave me I tried this and it works, but the movent is very clunky (even marking Teleport of Sweep) and I’m thinking maybe there’s another way more efficient to achieve it, bc [Event Tick] + [Authority Switch], I think I’m making a mess here lol.

Okay so what you want to do in your case is replicate the camera’s location and rotation from the server to the clients.

The clients already seem to send the camera movement to the server by default but the server doesn’t share the camera data to the clients by default.

In order to do that, one method is to make a custom event set to multicast (then make sure you have your box attached to the camera).

1 Like

Yes, what I’m trying to do is something like making the camera movement of everyone visible for everyone in the game.

Your blueprint works like a charm, thank you very much for the help! :smiley: