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"

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:

alt text

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

Thanks!

Product Version: Not Selected
Tags:
more ▼

asked Feb 13 '15 at 05:37 PM in Blueprint Scripting

avatar image

StretchMan
6 1 3 3

avatar image StretchMan Feb 14 '15 at 06:12 PM

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:

https://answers.unrealengine.com/questions/123629/step-by-step-tutorial-for-client-to-server-replica.html

https://answers.unrealengine.com/questions/144222/variable-from-client-doesnt-replicate-to-the-serve.html

https://answers.unrealengine.com/questions/103914/network-replication-from-client-side.html

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

alt text

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

alt text

capture.jpg (135.0 kB)
capture.jpg (85.9 kB)
more ▼

answered Feb 15 '15 at 02:27 AM

avatar image

OpticalShadows
276 23 26 43

avatar image StretchMan Feb 17 '15 at 01:06 AM

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

But the tick I have printing strings of the boolean conversion is still printing "Server" values in the same tick. alt text

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: alt text

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!

avatar image StretchMan Feb 17 '15 at 01:29 AM

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

avatar image OpticalShadows Feb 17 '15 at 03:45 AM

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.

alt text

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.

capture.jpg (42.9 kB)
avatar image StretchMan Feb 17 '15 at 04:51 AM

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:

alt text

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.

avatar image OpticalShadows Feb 17 '15 at 05:17 AM

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.

avatar image StretchMan Feb 17 '15 at 05:51 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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