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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Saving hidden actors

Hi There,

I've created a collecting system, where once you pick up an item it'll make it hidden in game and I have a Boolean ticked to say it has been collected. But now I've run into the issue of trying to get this now hidden object to save its state. I try to save it in an array but once the level is loaded again, i can't seem to get it to go back hidden.

Has anyone come up with a similar system and if so how did you do it?

Regards James

Product Version: UE 4.12
Tags:
more ▼

asked Jun 21 '17 at 06:33 PM in Blueprint Scripting

avatar image

JamesWolfwood
12 3 2 5

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

3 answers: sort voted first

Hi,

I am using the fact that as soon as actor appears in the scene, its BeginPlay event is fired.

I've created a SerializableActor derived from Actor, which overrides this event and all actors I want to serialize are derived from this superclass.

This actor also has my own overridable function Deserialize, which is being called upon BeginPlay.

Now my actors are basically implementing their specific use of the deserialization, because serialized data are just a string collection and interpretation is up to the specialized class.

Stored data are in my own class derived from GameInstance (which is singleton - so you can rely on it always).

I hope this helps. Feel free to ask if anything is not clear.

more ▼

answered Jun 21 '17 at 08:49 PM

avatar image

metamorphium
107 7 13 23

avatar image JamesWolfwood Jun 21 '17 at 09:50 PM

Sorry to sound like a complete noob, but would it be possible to have some screenshots of your blueprints? if you don't mind, I work better when i can visual see what is happening.

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

Ok. Please keep in mind that I do all my logic in C++, but I've created a mockup simplified solution which can be a bit close to what I am doing. It's untested, but should give you an idea. :)

create a structure to store persistent data - reason being Map in BP can't work with more complex type - it's simply an Array of strings (I called it TestSerializedData)

alt text

In your class derived from GameInstance add a variable ActorStates and define it as Map

alt text

create a method, which takes actor name as string and string of achieved states (those can be anything). If you go C++ route, you can instead use JSON to serialize your states in a more advanced way.

alt text

create also a getter method to query for available states.

alt text

create an Actor class called SerializableActor which will be parent to your child classes.

alt text

Continue in next post because of 5 file limitation.

f01.jpg (25.8 kB)
f02.jpg (81.1 kB)
f06.jpg (12.9 kB)
f03.jpg (44.3 kB)
f04.jpg (64.7 kB)
more ▼

answered Jun 22 '17 at 04:53 PM

avatar image

metamorphium
107 7 13 23

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

[contd]

In your child class override deserialize event so it handles the needs of your actor.

alt text

Whenever anything serializable occurs, simply call the serialized method.

Please note that in streaming levels you might also want to store the level actor is in because of possible naming conflicts, My own solution is actually way more complex as my superclasses serialize many states by themselves, but this should get you started, :)

f05.jpg (44.5 kB)
more ▼

answered Jun 22 '17 at 04:55 PM

avatar image

metamorphium
107 7 13 23

(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