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 would I save this kind of data?

Hello, I'm quite stumped here,

I am currently making a car game. In this car game, the user can choose between a variety of cars BUT ONLY IF HE'S PURCHASED THIS. Assuming I already have an ingame-currency system setup, how would I store data about what cars a player has purchased or not?

In the past, I made a SaveGame blueprint. In this blueprint, I had a Map variable (dictionary) called VehicleLog. In this data structure, I have a string-key which represents the vehicles named, followed by a struct-value. This struct stores a boolean called "isPurchased?" and a CLASS reference to it's respective blueprint for spawning in.

Then, everytime I load the game, I have my gameinstance store whatever is in the SaveGame file.

Currently, this approach is tedious. What if I want to add more vehicles later on? I would have to go to the SaveGame and add to it's dictionary.

What I tried to do before is create a DataTable to model this. Unfortunately, UE4's DataTables are read-only, so that's unfortunate.

What's another way I can represent this data, such that this proposed method could easily be updated and modified. I'm thinking about using SQL, but doesn't that require an internet connection to a Web Service? This game should be offline available too.

Product Version: UE 4.19
Tags:
more ▼

asked Apr 01 '18 at 10:33 PM in C++ Programming

avatar image

nerdares
6 2 4 9

avatar image BrUnO XaVIeR Apr 04 '18 at 02:21 PM

My employer had the same problem, so I developed this for us: https://www.youtube.com/watch?v=Py4kqPyXnco

However, you say you don't need to save that data in runtime, so I don't think a SQLite database is needed. You are most likely looking for how to use Data Assets in C++: http://www.levelplusgames.com/ue4-c-data-assets/

Or using the SingleTon object class: https://wiki.unrealengine.com/Global_Data_Access,_Data_Storage_Class_Accessible_From_Any_CPP_or_BP_Class_During_Runtime

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

2 answers: sort voted first

i think you just need a function "AddCar" this function will help you add another car into the Map,it will generate a string-key value and insert the value into map.

more ▼

answered Apr 02 '18 at 02:41 AM

avatar image

happymakai
41 1 2

avatar image nerdares Apr 02 '18 at 05:57 AM

This would imply that I’m trying to add more cars in runtime which was not was I was asking sorry haha. I’m basically just trying to make a database of vehicles that a player can purchase. I don’t think I have been doing it correctly though. My SaveGame class served to be my container for all this data, and I did this by using a dictionary. Unfortunately, if I wanted to add more cars, I would have to recompile the class. I feel like this isn’t the correct approach.

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

there is a sql plugin,https://github.com/marshal-it/UE4-Sqlite3-Plugin you can try that! no need network

more ▼

answered Apr 02 '18 at 08:35 AM

avatar image

happymakai
41 1 2

(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