x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Pawn Controller Rotation in Multiplayer

Hello,

I am currently creating a rolling ball game in which the player controls a physics based pawn in a third person perspective and can roll around using AddForce.

I am attempting to implement multiplayer functionality using a listen server, however i am having difficulty getting the pawns rotation to actually work. Here is how i have the entire thing set up.

For now i have 1 function to control the Vertical movement Movement of the pawn (forward) which takes in a float value (obtained from the inputaxis). From here i am using Controller->getControlRotation() to obtain the current rotation of the controller and then multiplying it by the axis value and of course the roll speed of the ball. (This moves the ball in the direction the camera is facing). This function is running server side. In order to get this to update to the clients, i have a client side function that runs in the tick event and simply sets the ActorsTransform based of what the server has calculated it should be. This works on multiplayer perfectly without any issues.

However, when attempting to set up my MouseX function (the function to rotate the controller via AddControllerYawInput()) in the same manner, it just doesn't work. If i have the function set to run on the server, the player cannot control the rotation (It just doesn't move). If i set it to NetMulticast/Client the client can control the rotation but the Forward Vector isn't effected by the rotation.

How would i go about setting this up correctly?

GIF with explanation Below: https://puu.sh/BhFvQ/ea78a9281a.gif

As you can see from the GIF above, the listen server (Left) can roll around, moving in the direction the camera is facing, it is replicated to the other clients which is perfect. However, when controlling the client (Right), you can see no matter where the camera is facing, it will always roll in the same direction. The movement however, is replicated back to the server which is working perfectly. Its just the rotation aspect that i cannot figure out.

Product Version: UE 4.20
Tags:
more ▼

asked Aug 21 '18 at 01:04 AM in C++ Programming

avatar image

Shadow Nightmare
8 1 2

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Solved this after 2 days of pure headache!

Solution: I created a FRotator variable that stored the controller rotation. I created a overloaded function to set this and called it everytime the MouseX input was used. This function was set to run on the server using UFUNCTION(Server, Reliable, WithValidation) This provided the server with the rotation from the client and the vertical movement was now working correctly!

more ▼

answered Aug 21 '18 at 03:36 PM

avatar image

Shadow Nightmare
8 1 2

avatar image mightyenigma Dec 07 '18 at 06:26 PM

How well does it work over internet with its inherent latency?

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question