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"

GameMode vs GameState

Hey all,

So I'm setting up a GameMode and GameState for my project. After reading online a lot about the differences between the two, I've downloaded the shooter game to get an idea as well.

So I want to see if I had the correct idea... in super laymen terms.

GameMode seems to be the referee, while GameState is kinda of like the assistant ref, just keeping an eye one the clock, who's on what team, what the score is as a whole (PlayerState keeps track of individual scores), and possibly where those players might be on the field if we care about that sort of thing, but mostly TEAM stats - not individual state.

If I hit a player, I don't tell GameState. I tell GameMode and it will decide whether I really hit the player or not. Also, no variables, whether public, private, or protected, should ever changed within GameMode, as those are the rules that are to be set and maintained through the match. If I want rules to change in the middle of a match, whether it's a major or minor change, should I make a separate GameMode and just swap the GameMode?

Thanks in advance!

  • Austin

Product Version: Not Selected
Tags:
more ▼

asked Oct 24 '14 at 07:31 AM in C++ Programming

avatar image

AustinK
215 22 19 28

avatar image cahitburak Oct 24 '14 at 08:39 AM

Simply GameMode is about rules and managing them, GameState is about game statistics, scores. GameState is a part of GameMode. But detailed answer would be helpfull for me too.

avatar image AustinK Oct 24 '14 at 05:08 PM

Yeah. I was just attempting to put it in terms more people may understand... although I'm still assuming the majority of readers will have a basic idea of sports and referees.

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

1 answer: sort voted first

They Are Very Different In Multiplayer Game

Game Mode = Only Exists on the server, and controls how players login to the match, and how player units are spawned. You can stop a player from joining a multiplayer game here, or know when a player has left. And again this actor only ever exists on the server.

Game State = Ideal for managing all aspects of a replicated world, such as world time, world object positions not owned by a player, AOE damage zones, neutral replicated gameplay elements of any kind.

This actor exists for client and server and allows for each client to know stuff about the world.

Again a great example is World time where you want the client to know what what the session / turn / current mission time is as propogated to each client from server calculations that are done in Game State class on the server, and replicated to each client using a replicated Time variable.

The bulk of actual game-time related stuff in multiplayer game has to be done in Game State if it is anything you want clients to know about locally :)

Rama

more ▼

answered Oct 26 '14 at 06:14 AM

avatar image

Rama
10.6k 446 345 1088

avatar image AustinK Nov 04 '14 at 11:39 PM

If I'm working with a single player game, does it still make sense to use GameMode as the decision maker? Even though it's not a "server", it still acts like a server and still makes the decisions/actions a server would?

Thanks!

avatar image cahitburak Nov 05 '14 at 12:44 AM

Yes, it is the common/official way. But there are some other ways of course so you don't have to.

avatar image Enlo Apr 28 '15 at 08:02 PM

This answer should be put into the documentation, in big bold letters!

avatar image Sir Quizalot Nov 02 '16 at 05:55 PM

What's the difference between player state and game state?

avatar image AustinK Nov 22 '16 at 11:23 PM

In short, GameState is replicated across server and client. GameState maintains an array of PlayerStates as well.

GameState would have things like total kills per team, time remaining, which zones are being dominated by which teams, etc. PlayerStates hold things that are specific to the inidividual. i.e. - numKills, numDeaths, shotsFired, numHitsOnTarget, zonesCaptured, etc. Use some of these fields, the client can calculate other data the server doesn't need to waist cycles on (K/D ratio, hit ratio, etc)

avatar image jchen114 Aug 14 '17 at 05:32 PM

I'd like to get the GameState when I'm in the editor. I've tried doing this in my UActorComponent that is supposed to be attached to an AActor..

 auto EditorWorld = GEditor->GetEditorWorldContext().World();
     if (EditorWorld) {
         auto GameState = EditorWorld->GetGameState();
         if (GameState) {
             BMoveSetupComponent = Cast<UBMoveSetupComponent>(GameState->GetComponentByClass(UBMoveSetupComponent::StaticClass()));
         }
 
     }

But my GameState is always null. I'm doing this while the editor is not running though. Is that the issue? I can't get the GameInstance while the editor is not playing?

(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