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"

HUD Replication problem


Im trying to build a small application in which I run a dedicated server and I have two clients with a simple hud.

This hud is made with two buttons.

"Join blue team" "Join red team"

When they press one of the two they will swap their hud to the specific one depending on the blue and the red one.

that is how it should work.

But right now, if I press in one client "red" and in the other "Blue" one of the two clients receive both HUDs and the other none. Also I print one message "Button clicked!" and every time one of the two press it both receive the message.

The code is like that:


 `void SDB_XWidget::Construct(const FArguments& InArgs)
     OwnerHUD = InArgs._OwnerHUD;
     CurrentPlayerController =  Cast<ADB_XPlayerController>(OwnerHUD->PlayerOwner);
     FightContainer = SNew(SHorizontalBox);
                 + SVerticalBox::Slot()
                     .Text(FText::FromString("Blue Team!!"))
                     .OnClicked(this, &SDB_XWidget::HUDDefaultBehaviour, EHUDState::HUD_Construct)
                     .DesiredSizeScale(FVector2D(2, 2))
             + SOverlay::Slot()
                     + SVerticalBox::Slot()
                         .Text(FText::FromString("Red Team!!"))
                         .OnClicked(this, &SDB_XWidget::HUDDefaultBehaviour, EHUDState::HUD_Basic)
                         .DesiredSizeScale(FVector2D(2, 2))

Method that gets called on clicked

 FReply SDB_XWidget::HUDDefaultBehaviour(EHUDState NewHUDState)
     switch (NewHUDState)
     case EHUDState::HUD_Basic:
         CurrentPlayerController->OwnTeam = EPlayerTurn::T_P1;
     case EHUDState::HUD_Construct:
         CurrentPlayerController->OwnTeam = EPlayerTurn::T_P2;
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Button Clicked!"));
     return FReply::Handled();

None of this method is Server / Client only, or anything like that. I believe that may be the issue but I don´t quite understand why since this is a particular thing that only the client should care about.

Can anybody help me with this?


Product Version: UE 4.8
more ▼

asked Jul 14 '15 at 01:24 AM in C++ Programming

avatar image

13 5 14 12

avatar image Grendert Jul 14 '15 at 11:14 AM

Forgot to mention

Im running a dedicated server with two clients.

I havent start replicating anything at all. which means, this HUD functions are not been replicated in any case and no variables are been replicated either. (Which for me it doesn't make sense to be replciated since each hud is completely independent and particular of a specific client/player?)


avatar image Grendert Jul 14 '15 at 12:27 PM

The only thing I can think of is that this call " GEngine->GameViewport->AddViewportWidgetContent(ConstructContainer.ToSharedRef());" adds the widget to a default viewport..or maybe player 0 viewport only... so I must get the viewport from somewhere else..maybe from the own player controller itself... but I dont know if Im just saying stupid things..or that makes sense.. or if I can access to the viewport from the controller and then add the content..

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

0 answers: sort voted first
Be the first one to answer this question
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