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"

How do I initialize and keep track of game states?

I'm doing a simple puzzle game (no multiplayer) and I'm trying to understand how to initialize the game itself. I read about gamemode&state but most of the people refer to it talking about multiplayer games, so I'm bit confused. When the game/level starts I need to instantiate some pawns (i use AIController to manage them), keep track of fired bullets, player's score and so on. I will use this information to increase/decrease game difficulty at runtime or end the game. Can you give me some hints or a basic example? Thank you

Product Version: UE 4.21
more ▼

asked Mar 26 '19 at 03:34 PM in C++ Programming

avatar image

3 1 2

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

1 answer: sort voted first

You can use the same principles as you'd for a multi-player game, here is a great description for networking if you'd really like to understand GameMode, GameState, PlayerState, etc: http://cedric-neukirchen.net/Downloads/Compendium/UE4_Network_Compendium_by_Cedric_eXi_Neukirchen.pdf

For single-player, it doesn't really matter, you can organize your code any way it's comfortable for you. The nicest is of course if you keep the same principles as you'd do for multi-player, but in practice, you can get away by storing everything in the PlayerController, and never using GameState or GameMode. I don't suggest it for bigger projects, but for fast prototyping or gamejam-size projects it really doesn't matter.

more ▼

answered Mar 26 '19 at 05:06 PM

avatar image

1.1k 4 5 7

avatar image MThaste Mar 27 '19 at 11:35 PM

Thank you for your answer and the incredible resource. I read the first part quickly. If I understood correctly because my game is not a complex and it is single-player i can use only the gamemode or gamemode + gamestate. In the first case my actors need to access gamemode to update its variables. Otherwise if i use gamemode + gamestate i can force actors to access only gamestate and leave to it the task of communicate with the gamemode.

avatar image KristofMorva Mar 28 '19 at 12:57 PM

For single-player, it's totally your decision if you want to use those classes at all, how are you communicating between them, etc. It's your choice if you want to stick to the original networking concept of those classes, or if you totally ignore them. Whatever fits your project the better :)

(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