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"

Where should I create a manager class : in GameMode or GameState?

Hello,

I'm developing a multiplayer (over network) basket ball game , and I'm wondering where's the best place to keep references to a few manager classes I need to implement.

These managers will be in charge of managing the periods of the game

These managers have a double function : modify the gameplay ( running timers, updating the scores, the statistics of the players, etc...), and as such need to be run on the authoritative machine, and have accessors so that each client can display some informations on the HUDs ( like the remaining time for each period / possession ).

I guess that where I spawn these managers are of little importance, as they will all end in the world. But where I keep a reference to them is important.

What is the usual way of using such managers like this :

  1. Keep a reference (using UPROPERTY) on each of them in GameMode, so I'm sure they won't be used by clients, and have all the infos needed by each client in replicated properties in GameState?

  2. Keep a reference (using UPROPERTY) on each of them in GameState, mark them as Replicated so the clients have access to the accessors functions, and put some conditions all over the functions which update the gameplay to make sure only the server calls them?

  3. Keep a reference (using UPROPERTY) on each of them in GameMode, and add a replicated property TWeakObjectPtr for each of them in the game state, so that everybody can access the functions they are concerned with, with the right level of authorization? (I'm not sure this is possible in fact)

  4. Split the managers in two : 1 class is in GameMode and is responsible of updating the gameplay. 1 class in GameState and is responsible of holding data to be displayed for each client. And the first class, when updating the gameplay, updates the values of the second class.

Any idea or recommandation?

Thanks

Product Version: Not Selected
Tags:
more ▼

asked May 15 '14 at 08:16 AM in C++ Programming

avatar image

Zoubi
172 21 30 35

avatar image Zoubi May 16 '14 at 08:35 AM

Let me bring some input of what I have right now, in the order I implemented it:

  1. I spawn my manager classes in the game state, and hold a reference to them

  2. I marked thoses properties as replicated

  3. I also had to mark as replicated the data I want in the managers

  4. It wasn't working. I figured out I had to set the bReplicate and bAlwaysRelevant attributes to true in the managers.

Is there another way to make this work as intended, or do I have to go through all these steps? (Is it possible to replicate a non actor object?)

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

1 answer: sort voted first

This is a bit confusing to me. UE alread has these 'manager' classes set up for you. All you have to do is use them.

You are tying to make manager classes to do the following:

Modify Gameplay - This should be done in the GameMode class

Update Scores - This should be done in the GameState class

Player Statistics - This should be done in the PlayerState class

Now all of these classes are replicated automatically. Check this out: Link to GameMode Docs.. .you can see that you set these all up for the engine to manage internally... you just use them.

What you are trying to do is implement a system that already exists.

Look at the Gameplay Framework Docs to get a better understanding of this.

Good luck!

more ▼

answered May 16 '14 at 12:58 PM

avatar image

AnxGotta
1.6k 61 45 237

avatar image Zoubi May 20 '14 at 08:16 AM

Thanks for your answer.

I didn't want to put all the logic class straight into the game mode class, and to make it become a huge mess. That's why I wanted to create managers to, well, manager specific parts of the gameplay.

You're answer made me think a bit about all that, and I finally went the simple way:

my playerstate and gamestate are just data holder classes. All the fields are public and replicated (like in the Shooter example) my managers now inherit from UObject instead of AActor, and are created in the GameMode, and update the attributes of the state classes accordingly.

It'w now much more clear and easy to use.

avatar image AnxGotta May 20 '14 at 11:22 AM

That implementation sounds good. Seems like it will keep things organized. =)

(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