Replicating Boolean on from Client to Server [Blueprint]

I am hoping someone in the UE4 world can help me understand what in the world I am doing wrong. I have an actor blueprint in scene and when I press “t”, I want a boolean to turn true on both the client and the server. If I am setting up a scene without a dedicated server I am having trouble.

My problem is if I press “t” in the server window it replicates to the client. If I press “t” on the client side the boolean never changes on either the client or the server. Here is my basic blueprint:

I am sure I am just replication impaired, but if anyone can give me a clue I’ll be grateful!

Thanks!

well, I’ve been messing around printing strings with a Tick Event and I have some more info. I changed the “talkEvent” and “talkOffEvent” to run on server (if client) and when the client presses “T” it prints:

Client: True
Server: True
Server: False

When I run the scene I am not using a dedicated server. If I run it with three users and no dedicated server the same setup goes:

Client 1: True
Client 2: False
Server: True
Server: False
Server: False

I have no idea what the deal is. If I do multicast the variable doesn’t change at all. All this is being done in a Player Controller. Judging from other similar threads I’ve found:

I’m not alone, but none of these have helped. Feeling pretty dumb… Even if I get this to change on the server, I then need to influence an actor that is not a Player Character to change animations. Feeling the burn of the UE4 learning curve. Maybe I should give up on blueprints and see if C++ is any easier to implement the functionality I am trying to use.

It looks like your talk event is a multicast. Multicast events will only tell all players if the event was called on the server. What I think you want to do in this case is when you press T check if you’re already the server and set your Talk variable accordingly if not call a custom event set to RunOnServer and check Reliable if its super gameplay important. When you release T do the same thing but with a StopTalk event.

Here is a cleaner alternative method to achieve the same effect:

Thank you for the reply! I setup my blueprint in my player controller just like yours:

But the tick I have printing strings of the boolean conversion is still printing “Server” values in the same tick.

30170-screen+shot+2015-02-16+at+7.54.15+pm.png

I am using this boolean to trigger an animation in an actor’s, that is not a player character, animation blueprint. But if I have a 2 person online session setup like this in the editor:

30171-screen+shot+2015-02-16+at+6.33.59+pm.png

The actors animation will change in the server window when the server presses “T” but not in the client, the client and first server value prints false and the second server value prints true.

The actors animation also changes in the client window when the client presses “T” but not in the server window.

The problem is trying to get the animation to trigger in both the client and server windows regardless of who is pressing it. Thanks for the help so far! I think it’s getting closer!

also, here is my animation blueprint on that actor in case that helps at all:

I’m sorry for being so terrible with this, but now the animation isn’t playing at all. I’m totally cool with my state machine and have everything if triggered. To be clear, the actor performing the animation is NOT possessed by player character, I want to be able to walk up to an AI character and press a button to trigger an animation. So here is my new animation blueprint:

I want that animation to not just happen for the client making the command but on the server and where all other clients can see the animation.

I guess I’m a little confused as to your intended setup. From what I gathered you have two players and an AI? If so then you want to have an event on the AI pawn that is called from the server. I could probably help you more if I had a more complete understanding on the setup you are using (Two players talking to an NPC?). If this is the case I can throw together a quick example.

For the animation setup you don’t need to use a for loop. What you want to do is right after update animation you would put TryGetPawnOwner->CastoMyCharacter you want to get the character using the AnimBlueprint. In the anim blueprint, replicated variables dont have any effect here. You should have a setup similar to this: Ignore all the other blue lines, I just threw this together in a project I already had.

Once you have IsTalking (the anim blueprint variable) you can set up your state machine from there. This also brings up the fact that you have to set up your player controller to set is talking on the pawn mesh. OR when you TryGetPawnOwner->CastToMyCharacter you can get controller->CastToPlayerController->CastToMyPlayerController. Its a lot more nodes but will save you the trouble of setting a talking variable in a pawn. If you only use this for animation it would be ok to just set the variable in pawn, but if you use it outside a pawn (not possessed) then you’ll want to have both, or try that long cast method.

I really appreciate the help! You are correct, the setup is two players talking to an NPC. The NPC has an idle and talk animation. When “T” is pressed by either player, the NPC talks. I can’t seem to get the client to make the NPC go into the talk animation on all clients and the server.