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"

How to save client variables before joining session and load them back after joining session

Let me explain what I want to do first. I'm writing with blueprints

(1) I'm writing a 2 player fighting game which has four heroes. The player has to choose a hero first then will be loaded into a map.

(2) Server player chose the hero, hosts the game and loads into the map. Everything is ok.

(3) The client player has to choose the hero before joining the session. Then joins the session and loads into the map of server player.

(4) To store which hero is chosen by client, I stored the index of hero into a variable named P2Hero in playerState blueprint.( This step occurs before joining the session )

(5) After joining the session, and onPostLogin event, I want to get back the saved P2Hero variable from client's playerState blueprint but it seems like it is getting the variable from another playerState blueprint and just gives the default value of the variable 0.

(6) My main point is how to save datas of client before joining the session and how to load them back after joining the session.

Someone pls help me. I'm having a really big trouble. I've tried saving the data in gameInstance, gameMode, playerController. All of them just gives the default value like mentioned above. May be the whole logic of mine is wrong. If wrong pls point me how to solve this problem. Thanks.

alt text

alt text

Product Version: UE 4.9
Tags:
pic1.jpg (778.6 kB)
pic2.png (285.6 kB)
more ▼

asked Apr 21 '16 at 07:18 PM in Blueprint Scripting

avatar image

Thura Oo
1 1 4 5

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first
more ▼

answered Apr 21 '16 at 07:50 PM

avatar image

CriErr
1.2k 57 19 55

avatar image Thura Oo Apr 22 '16 at 08:27 AM

Thank you for your advice. I think there must be another better way. But I'm current using your advice and it works. Thanks.

(comments are locked)
10|2000 characters needed characters left

Did you ever find a "proper way" to do this? I'm having the exact same problem.

more ▼

answered Mar 24 '17 at 03:45 PM

avatar image

D_Ack Design
30 2 3 7

avatar image mightyenigma Oct 28 '17 at 04:50 AM

I am facing the same problem, as well.

avatar image CriErr Oct 28 '17 at 05:59 PM

If steam "advanced session plugin" and use unique steam ID. If non-steam, generate random int on server, send those to clients to store and on login compare the int on server stored one to find which player is which.

avatar image mightyenigma Nov 01 '17 at 01:55 PM

Using Savegame slot was very simple and effective. It's my opinion that it is a "proper" way to do this, and there may be many "proper" ways. As a bonus, the data persists between closing the game and starting it up again (from the client perspective of course)

(comments are locked)
10|2000 characters needed characters left
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