Problems getting variable to replicate in animation blueprint
So I have a character controller where I'm grabbing the Axis value of InputAxis MoveForward and InputAxis MoveRight and passing them to a variable which then controls a Blendspace in a Blueprint animation: (Note that I multiply by Walk Speed to better sync with the animation blendspace thresholds)
In the Animation Blueprint, I then cast to my character blueprint and grab the two variables and use them to set speed and direction in my blendspace:
This works fine for single player, but it seems that not matter what I do, I cant get these two variables to replicate on both the server and client.
I'm relatively new to networking but I tried (unsuccessfully):
1.) Setting both variables to be replicated
2.) Grabbing the axis values via a Custom Event set to Run on Server.
3.) Messing with Has Authority to set both variable, with little luck.
Any help or feedback is much appreciated, thanks!
asked May 24 '17 at 12:27 AM in Blueprint Scripting
What is your purpose for replicating these variables to the server? They seem to be only relative for the local client since the server will replicate your actor's location/direction inherently (depending on your setup, but this is the case most of the time). See the "Replicates" property of your actor to determine this.
If you really need them replicated to the server, you should consider replicating them elsewhere than in your controller such as your pawn. Likely the issue you're running into trying to replicate these variables in your controller is that each client has only 1 player controller for their local world. The server is the only entity that knows information about all controllers for each player. This means that if you try to Multicast a function with a controller, it's only going to be called on the owning client and the server, because all other clients do not have the invoking client's controller in their world.
There is of course a work around to this philosophy as you could call an event from a different blueprint (such as your game mode) that emulates the functionality you're expecting by relaying it back to all other player controllers. However, this can quickly become convoluted and I recommend you architecture your flow better than this.
Hope that helps!
answered May 24 '17 at 07:21 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here