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"

replicate static mesh rotation

i have a cube inside my character that rotates towards the mouse location with this function alt text

my player and the cube has replication enabled but currently the server is the only one replicating his rotation... with this i mean that the clients get the rotation of the host, but they don't get the rotation of the other clients

how do i solve this?

Product Version: UE 4.20
unr.png (217.0 kB)
more ▼

asked Aug 26 '18 at 02:08 AM in Blueprint Scripting

avatar image

73 3 7 14

avatar image Nico_Pucho_27 Aug 26 '18 at 02:20 AM

also the host is not getting the rotation of the clients

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

1 answer: sort voted first

Replication always only happen from the server to the clients never from a client to a server. If you set a replicated variable client-side the server never knows about it because a client can't replicate things on itself. What you have done is fine you just need to send the rotation through a RunOnServer event and also set it on the server. Then if the cube component is set to replicate and the Character it lives on is also set to replicate + replicate movement then the server will finish the replication back to the other clients.

more ▼

answered Aug 27 '18 at 07:51 PM

avatar image

656 2 4 6

avatar image Nico_Pucho_27 Aug 27 '18 at 08:09 PM

so i can do this with a RunOnServer and a multicast(i could even disable the cube replication this way) but what about the send rate? if i send this rotation every client's tick then wouldn't that saturate the server? like what would happen if the client haves 600fps, it would be calling that function 600 times per second?

avatar image GarnerP57 Aug 27 '18 at 08:38 PM

Yes you should not send the updates more often than needed however if you got the bandwidth it is the simplest way of doing it. If you want to do it a more bandwidth friendly way you would have the CPU predict the rotation between server updates. It quickly becomes very complicated as you can see in the CharacterMovementComponent that does a lot of work to make it as smooth as possible.

avatar image Nico_Pucho_27 Aug 27 '18 at 08:58 PM

so what would be the best approach to set a fixed send rate for the rotation?

have a float variable that increases with deltaTime and when it reaches a number set it to 0 and send the data?

having an infinite while with a delay node?

use a timer?

avatar image GarnerP57 Aug 27 '18 at 09:22 PM

You could use a looping "Set Timer By Event" node and have it send the RunOnServer RPC if there is any significant change since the last sent rotation. You could pause it when no movement is happening and immediately wake it up again (set + resume) when movement is detected.

avatar image mightyenigma Dec 07 '18 at 02:53 AM

And you can always lerp the rotation between its current rot and the rot received in the replicated variable or multicast. That way the rotation is happening smoothly on The clients even though the updates of where it should rotate to only happen every 1/4 second.

(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