How do I replicate pitch input (no blendspace)?

Hi,

this a question I posted on AnswerHub a few days ago (https://answers.unrealengine.com/questions/223586/how-do-i-replicate-pitch-input-no-blendspace.html). I still didn’t get no answer and I’m pretty much stuck without it. I would be very thankful for any help :slight_smile:

"I’m trying to replicate pitch input over a networked game. For now, only the rotation of the player is being replicated. I tried these setups:

41605-2.png

None of them work. Please note that I’m not using blendspace, but simply put the gun as a child of the FirstPersonCamera:

And it actually works it singleplayer!

I read a few posts regarding this issue but most of them involve using a blendspace. Is it possible to replicate pitch input without it? If so, how?"

Any suggestions are very much appreciated!

In your character blueprint properties, make sure “Use Controller Rotation Pitch” is enabled, then it should replicate just like the yaw.

EDIT:
Actually that would make the whole character rotate (which I’m assuming is not what you want :p) so here is a way you can replicate the camera rotation.

ae0100486c00fb1966ce228c674322d6525713bc.jpeg

(Also you should disable “Use Controller Rotation Pitch”.)

2 Likes

Hey, thank you so much for the quick reply! It works flawlessly :o !
But I’m really confused now. I watched the whole “blueprint networking” series by Epic, but it looks like I still don’t understand how the “switch has authority” is supposed to work.
A.PNG
I thought it stops the execution of the blueprint if the owner is “remote” (in this case - not the server). Why does the client get to the “Multicast Replicate Rot” event, even though he’s not the authority? Could you please explain that to me?

EDIT: For example, this part of my blueprint doesn’t work as intended (only the server can execute, what’s after the event):
A.PNG
I noticed that the Event doesn’t have “Execute on all” written in it’s description and I don’t know how to enable that. Any suggestions?

Simply put: Authority does not (always) equal server :slight_smile: it’s a common beginner mistake to think Authority/Remote as Server/Client but there is a reason we use the term Authority instead of Server :stuck_out_tongue:

In this case, the client has network authority over the pawn it controls.

(I’m probably not the best guy to explain this stuff :p)

That’s interesting. What you said has been said in the video as well, but it sadly wasn’t explained further. I’m really thankful for your help, but I’d like to ask you for one last piece of advice. How would you handle the issue I stated in my post above? Until now I was using a “workaround”. I experimented for some time and a configuration like this worked for the most part:


This way both the server and the client and the server see the shot being fired. I used this “config” (two custom events - one set to “multicast” and one “run on server”) a few times, but I have a feeling this is not the right way to do it… So if you have some tipps, that’d be great :slight_smile:

Very good answer, this question appears everywhere but answers usually do something bad, this works perfect! Thanks

I made a tutorial series on fps multiplayer shooter and there I addressed this pitch replication problem i this episode, here is the link to the video.

Is there a way to replicate the player pitch without a blendspace?

If your entire character will be pitching and not just parts of it like say your arms or just your head, then yes. It will need to be on tick or a timer that loops pretty quickly to get a smooth replicated rotation.

Can you give me an example how to do it? :slight_smile:

I can post an example for you when I get back to my machine a little later. There is a great short little video on YouTube that called How To Replicate Pitch in under a minute I believe it works great if you want to try and find it in the meantime.

1 Like

Hello

I don’t know what I’m doing wrong, but I can’t get my Pawn to replicate Pitch Aim offset.

The client don’t see the server’s pitch movement…

My Set pitch function:

And here is my AnimBP:

Can anyone see, why this won’t replicate from server to client?

No one have a solution for this?

I don’t understand why this don’t work… I basically copied the blueprint from a earlier project, expect the AnimBP which is different.

I can’t give you an answer, I can only say I have the same problem

You need to set your Pitch variable inside of your character blueprint to replicate. You might also need to set the pitch variable inside of the animation blueprint to replicate.

I replicated both for the time being, and it works ok :slight_smile:

I also do the math on the client side before doing the RPC call. Also, the RPC call takes my character class which for now is just ThirdPersonCharacter, and the Pitch float variable.

I then set the ThirdPersonCharacter’s pitch value again on the server side.

Hi , I did the same thing that you did and my client doesn’t see the server AimOffset… I need help please!

Have you set pitch in animBP cast Directly from CharBP? Also (can be overlooked) is CharBP replicate flag ticked?
Mine works with this type of setup but the response is terrible (laggy/jittery)

Okay thanks

You can create a function inside your character blueprint called “ControlRotation” and it should set a replicated rotator variable and should look something like this:

It is important to set the replicated condition to skip owner or you’ll have actors rotating that aren’t supposed to.

ReplicateRotationExample3

You will need to get this variable inside your animation blueprint to set your pitch variable so that everyone can see you rotating. Also noting that here I also have the pitch variable to skip owner and is also replicated. You can carry out your logic anyway you see fit here, but its important to make a few checks to make sure the player is valid otherwise you’ll get a very long list of errors if they are not valid. This is especially true if your character is dead. It will throw them up the whole time your character is destroyed and is waiting for a respawn and becomes valid again.

ReplicateRotationExample

Lastly, call this “ControlRotation” function on event tick in your character blueprint and make sure you have a check in place there so if your character is not possessed so it won’t throw errors there as well. Like a branch that is checking something like “IsDead?”

Since you are presumably doing this over network, you can play with the network update frequency in your character bp to get the most ideal/optimized rotation look in terms of network bandwidth usage, but it looks kind of choppy when its turned down below 60 your character may be jumping around as well if its too low. Running it on a timer, seems moot to me since it will look like terrible on anything less than your typical framerate anyway. The computational expenditure of running this function on tick might knock out a negligible amount of fps, but its a trade off I’ve accepted. I’ve tried it both ways.

I’ve seen some multiplayer games not replicate pitch at all. I’m sure this can save a bit of bandwidth and also framerate if there is just waaay to much going on in the game…

1 Like

Shame you cant see this answer anymore.