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 Instance, Game Mode, Player State, Player Controller... For what to use them?

Hello good people :) I need someone to explain some things if possible :D

OK, I think I know basics...

Game Instance is the game itself and it exists until the game is closed. (Correct me if I'm wrong)

Game Mode exists only on the server and clients can not access it, only server can. It is destroyed every time a new level loads.(Correct me if I'm wrong)

Game State is created for every player that joins the server, but it is only a copy of a true thing that runs on server. Server creates Game State, server modifies it and server replicates it to all clients. It is also destroyed after a new level loads. (Correct me if I'm wrong)

Player Controller is created for every client on the server. It is created by the client and it does not replicate. Also destroyed after a new level loads. (I'm so unsure about this, correct me pls)

What I really want to know is for what to use them?

What logic to run on Game Instance and what on Game Mode. For example, where should I create Main Menu Widgets... Where should I put Health, Coins and other.

Where should I create HP widget, Time Remaining widget, Crosshair widget...

PLEASE someone explain, I want to do things the right way...

Thank you very much!!

Product Version: Not Selected
more ▼

asked Jul 24 '18 at 04:53 AM in Using UE4

avatar image

55 2 5 9

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

1 answer: sort voted first

GameMode controls the game, everything related to game rules that are global hence the name Game Mode since game mode program should be in there. GameMode indeed resets with the world so it should keep the rules in scope of single match or level. Game Mode is indeed not replicated

GameInstance is same as GameMode but without tie to world level, everything that should be keeped between the level should be there

PlayerController represents the player (or rether it's controller) it should work same way as GameMode but related to invidual player, Player data inside player pawn dies with the pawn, so controller should keep persistent information beyond player respawn circles. This object is only exists on owner client and server.

GameState and PlayerState are replicable extensions of GameMode and PlayerController, generly it should not have a code just values set by GameMode and PlayercController that will be replicated to all clients

If you use UMG, HUD should be initiated in PlayerController, you can also make HUD class to control that more and have access legacy HUD canvas. With UMG code of UI should be in Widget Blueprint it self and Widget Blueprint should idependly collect all data from other classes to display insted of classes sending it to it. UI should not have any gameplay data either, or else you want to process it in some way for UI use (like value ease in outs etc.)

Stuff like Health should be on pawn since it is health of pawn.

Keep in mind that there not stone written rules where everything should be, place things wherever you think that it plays bigger role in

more ▼

answered Jul 24 '18 at 05:20 AM

avatar image

36.6k 932 169 1111

avatar image TooDear Jul 24 '18 at 05:28 AM

Thank you very much!!!! This helps a lot!

Can you tell me one more thing: Because Player Controller is destroyer every time a new level loads, is it better practice to create Menu Widgets inside Game Instance or not? TNX :D

avatar image Shadowriver Jul 24 '18 at 09:47 PM

You could if viewport not resets, but there really no point :p just initiate UI on level start it cost nothing. Remeber that UI should not contain any game data, insted UI code should get data to display from other classes, so don't duplicate variables it's just waste of memory space

(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