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"

Game Mode override on dedicated server

Hi everyone, hope you are having a nice day.

I'm trying to do a multiplayer game with a dedicated server:

Basically you have two maps.

  1. Menu

  2. Game

By default we have the game mode that will be used in Menu and then the gameLevel overrides the game mode with another one.

This is my network setup:

alt text

If I run I get access violation as soon as I call one of my functions of the game mode if this function tries to use any of properties, like it never initialized.

 //.h
 
 USTRUCT()
 struct FPlayerInGame
 {
     GENERATED_USTRUCT_BODY()
     UPROPERTY()
         FString playerName;
     UPROPERTY()
         int nWins;
 
     UPROPERTY()
         APawn* pawnRef;
 
     FPlayerInGame() {
         playerName = "UNKNOWN_NAME";
         nWins = 0;
         pawnRef = NULL;
     }
     FPlayerInGame(FString newPlayerName, APawn* player)
     {
         playerName = newPlayerName;
         nWins = 0;
         pawnRef = player;
     }
 };
 
 class MyGameMode...etc
 
 UPROPERTY()
         TMap<uint32, FPlayerInGame> playersInGame;
 
 //CPP
 void AHoldTheBallBattleGM::RegisterPlayerReady(APawn* playerReady)
     {
         UE_LOG(LogTemp, Warning, TEXT("[SERVER] Received Player Ready %s"), *playerReady->GetName());
     
             // PlayersInGame Contains causes access violation
         if (playersInGame.Contains(playerReady->GetUniqueID()))
         {
             UE_LOG(LogTemp, Error, TEXT("[SERVER] Got duplicated!"), *playerReady->GetName());
             return;
         }
 }



Because I'm able to call functions on my game mode it looks like I'm definetly using the right one. but TMap is not properly initialized, and it is when I put it as main game mode. :/

Anybody has any clue on what's going on?

Thank you!

Update: Is not because of the TMap. I've also tried to have an int. initialize it on the constructor and then print it when I call the function and it will show the value properly but it will crash right after.

ICan't show the crash itself because it says I don't have the symbols loaded for it and I have pragma optimize ("", off)

Update2: I forgot to mention that this function is called on BeginPlay of each pawn

If Role == Authority Call Func();

I've seen that if I called after, with "press O and then call func" it works!

is Game Mode BeginPlay being executed after pawns causing the error? then why does not happen if I set the game mode as main?

Update 3: In my main game mode. the one is set on the Project Settings, I have specified a custom player controller that shows a custom widget. Now when I click play on my battle level I can see the widget appearing and dissapearing right after, which means is first trying to use the main game mode and then is being overrided! If the widget is showing up I'm probably going through beginPlay at that point! so that could be the issue.

No clue how to deal with it though.

Product Version: UE 4.15
Tags:
networksetup.png (41.3 kB)
more ▼

asked Mar 26 '17 at 10:10 AM in C++ Programming

avatar image

Grendert
13 5 14 12

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

1 answer: sort voted first

Solved: I didn't do Super::BeginPlay()... and was causing all kinds of issues.

How did I miss that....

more ▼

answered Mar 26 '17 at 11:31 AM

avatar image

Grendert
13 5 14 12

(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