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"

Passing Variables from Level Load to Level Load

Quick question, I have a player typing in their username on the main menu level. The user then stores the user name as a string variable. Then the client will load the next map, however, it doesn't retain the variable it goes back to default. I am storing the variable in the player controller, but it seems every time I load a new map it recreates the player controller. How can I pass the variable username from map to map?

Product Version: Not Selected
Tags:
more ▼

asked Aug 02 '14 at 07:43 PM in Using UE4

avatar image

El Death Taco
43 7 9 13

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

1 answer: sort voted first

The typical way is to use a SaveGame object to serialize things like this. You'll probably need a game save/load mechanism sooner or later anyway, so this is a great opportunity to start building it.

This isn't very difficult to set up, but involves quite a few steps so you'll have to check the exact details yourself, preferably in the TappyChicken project, which has a saving and loading implemented in a fairly easy to understand manner if I remember correctly.

A rough overview: the basic steps involve creating a BP based on SaveGame, to which you add variables for the data you need to serialize. In this case it would just be a string variable holding the player's username. Then you set up your playercontroller BP so that its construction script checks for saved games and loads them, or creates a new savegame if none was found. Once the user has entered a name, you create a savegame object, write the name to the string variable and save it. With this in place, every time your playercontroller respawns on level load, it will automatically get the saved username.

Sounds complicated, but it really isn't! Check Tappy Chicken for details.

more ▼

answered Aug 02 '14 at 08:50 PM

avatar image

Xenome
2.1k 64 54 120

avatar image El Death Taco Aug 02 '14 at 09:58 PM

Xenome,

Thanks for the quick reply! This is actually why I am trying to get the user name. This is a multi-player game where I will need to save their location, inventory, ect. And I was going to use the username they entered as the save file name. I am currently saving values but it applies to all the clients logged into that server. Pretty much I want a save file for each player, or is there a better way to achieve this?

avatar image Xenome Aug 02 '14 at 10:12 PM

Ah, I don't know much about multiplayer stuff, but for that I presume you would rather use something like a subclass of PlayerState to store and replicate that type of data in a secure way.

(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