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:
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:
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:
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.
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 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.