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"

Problem with saving Asset Reference in struct in 4.13 (worked in 4.8)

Hi,

I am trying to save a skeletal mesh reference inside a struct of skeletal mesh reference. A kind of inventory system.

So I a created character blueprint with a struct variable that contains a Skeletal Mesh Reference. During game, I edit the struct skeletal mesh reference thanks to the detail panel and I save that struct in a save game slot. I exit game, close UE4 editor and restart the editor. I then load that struct during game and fill my character struct variable with the loaded struct. UE4 editor in play in viewport seems to not be able to read the values saved and won't filled the struct with the Assets References (that are actually visible if I open the savegame file in a text editor). All references are blanked.

The problem is that all this was working perfectly fine in UE4.8. Now that I have upgraded to UE4.13, unreal doesn't seem to be able to read the struct from the save games slots correctly. Or not all the time because it works If I don't close the editor. It saves and loads the references perfectly until I close the editor. A workaround I found but that's not a viable option is that if I load the asset referenced in my struct with the level blueprint before loading the save game slot containing the struct, unreal seems to be able to read the values from that loaded struct. The problem is that I can't load all the assets before maybe make a reference to it in my struct, it's just not efficient in any way.

I spend hours to try to find a solution to this with my good friend google without success. I also tried to change the variable type in my struct from a Skeletal mesh Reference to a Skeletal Mesh Asset ID. If I do so, UE4 crashes when I try to save my game slot containing the struct... I thought that would have worked though because it looks like a Skeletal Mesh Asset ID allows to reference an asset that is not loaded and the Skeletal Mesh Reference might not be able to do so but I might be wrong. Anyway, like I said, if I try to use a Skeletal Mesh Asset ID variable in my struct, UE4 crashes when I try to save my struct to a slot, so I don't really know what to do anymore... I also read stuff about TassetPTR Pointers and Asynchronous loadin but found nothing linked to blueprints and C++ scares me a lot because I don't much about it...

So I hope I have been clear and that someone can please help me because it's driving me crazy. Why does something as simple as that and that was working in 4.8 doesn't work anymore in 4.13...

Basically I am just trying to assign a skeletal mesh reference in a struct during game for my character, save the struct in a savegame slot and reload that struct from the slot after I closed UE4 editor. Right now it only works if I load the referenced asset before loading the struct that references it which is not really a viable option, considering that I would like to be able to pick a skeletal mesh from a big bank of them and can't load all of them before loading my struct from my savegame slot.

Soooo... Is anyone able to save a skeletal mesh reference inside a struct to a save game slot and then load that struct properly from that saved game slot ? If so can you please help me ? Or anyone has noticed this and it's officially a bug ? Because even though I am not an expert, to me it sounds like it since it was working in 4.8...

Merci d'avance,

Vincent

Product Version: UE 4.13
Tags:
more ▼

asked Oct 14 '16 at 06:52 AM in Blueprint Scripting

avatar image

petitbreton
21 1 3 4

avatar image petitbreton Oct 14 '16 at 04:44 PM

So as i am not an expert and my problem could mostly be because I wasn't doing things the right way I tried it in 4.11...

And my setup still works. So it's working perfectly in 4.8 and 4.11 but not 4.13... Grrrr....

I realized that my original question is pretty long and explains what I am trying to achieve but not how so I will make screenshots of my setup to make it clearer as soon as I can.

Still, something that works in 4.8 and 4.11 but not 4.13 seems strange to me. Again, just trying to save a struct containing a Skeletal Mesh reference to a slot and loading it after closing the editor. The loading part won't work properly in 4.13. The Skeletal mesh reference is blanked if I restart the editor, unless I load the skeletal mesh referenced in the struct with the level blueprint before loading the struct.

Anybody on the same boat ?

avatar image petitbreton Oct 31 '16 at 04:54 PM

So if anybody wants to try it and help, here are the files and steps to reproduce my problem in 4.13

https://drive.google.com/file/d/0B_3VFo4aUOd5X3lEV3p6X3pEamc/view?usp=sharing

1- Create a new Thrid Person Template Blueprint Project.

2- Paste the content of the Blueprints folder I posted to \Content\ThirdPersonBP\Blueprints

3- Start the editor, press play in selected viewport

4- Select the ThirdPersonCharacter Blueprint. In the detail panel of the ThirdPersonCharacter, in its default Properties, set its "Skeletal Mesh Reference I Want To Save" to a skeletal mesh asset that isn't loaded at start up or that isn't in the level (like "Hands" for example).

5- Press F to save that Reference to the game slot.

6- Press escape to leave "play in selected viewport".

7- Press "play in selected viewport" again

8- Press G and V. "Hands" reference should be loaded from Slot, printed on screen and in the default property of the ThirdPersonCharacter blueprint, the Skeletal Mesh reference variable "Skeletal Mesh Reference I want to Save" should be set to "Hands" (replacing the default Skeletal Cube value).

9- Escape "Play in selected viewport" and exit the editor

10- Restart the editor, play in selected viewport, press G to load the Save Game slot and V to print the name of the save referenced Asset and fill the "Skeletal Mesh reference I want to save" variable. On my side, nothing is printed on screen and the Skeletal Cube's skeletal mesh reference is set to "none". And that occurs only in 4.13. In 4.8 or 4.11, it totally works...

11- Start 6 to 10 over but instead of "Hands" asset, use SK_Mannequin. "SK_Mannequin" should be printed on screen and fill the "Skeletal Mesh reference I Want To Save" variable in the Default property of the ThirdPersonCharacter blueprint detail panel (replacing the Skeletal Cube's default value). This should work even if you restart the editor, as expected and as with every Skeletal Mesh asset used as a reference in 4.8 and 4.11

avatar image petitbreton Oct 31 '16 at 04:55 PM

If anybody is nice enough to try this, can you please tell me how it goes ? If it goes how I wrote it, to me it indicates that there is a problem in 4.13. If it goes differently please let me know, it might help me understand if I am the only one that witnesses this behavior.

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

3 answers: sort voted first

Hello petitbrenton,

I'm not quite sure why you're receiving this error and you're not exactly saying your process so I can't tell if you're doing anything incorrectly, but I'll explain how I put together, as it works correctly for me.

Firstly, I created a project with the ThirdPersonTemplate. I then created two assets: A struct BP (MyStruct) and a SaveGame BP (MySaveGame). In the MyStruct, I made one value and set it to Skeletal Mesh Reference and called it SkeletalRef. In MySaveGame I created a variable of the MyStruct type and set the default to SkeletalCube (from Engine Content) as it required a default.

I then set up the following actions in my ThirdPersonCharacter blueprint:

alt text

The F action creates a new save game object, casts to my custom MySaveGame class, sets the SkeletalRef inside of it to the current Skeletal Mesh of my ThirdPersonCharacter BP and then saves it to the MySave slot. The G action loads the save in the MySave slot, casts to my custom MySaveGame class and then saves it in a variable. V uses the variable from the previous action to check the currently loaded SkeletalRef and print the name.

To test this, I ran through those actions once and it ended up printing out SK_Mannequin, as expected. I then changed the ThirdPersonCharacter's skeletal mesh to Tutorial_TPP (Also from Engine Content) and saved everything and then closed/reopened the editor. I then hit play and ignored the F action as I didn't want to save again. I pressed G to load the save from the previous session and then V to output it and it continued to output SK_Mannequin.

I hope this explanation/example can help you figure out what might not be correct in your workflow.

more ▼

answered Oct 14 '16 at 06:19 PM

avatar image petitbreton Oct 14 '16 at 11:58 PM

Thank you so much for your help!

The good news is that what I am doing is really close to what you explain.

The bad news is that there is a little thing I don't understand in your explanation.

You wrote :

In MySaveGame I created a variable of the MyStruct type and set the default to SkeletalCube (from Engine Content) as it required a default.

That's what I am doing too. Now I am probably completely wrong but from what I can see in the screenshot it doesn't seem to be what you actually did. What makes me say so is that after creating the save game objet and casting to MySaveGame, you set a variable of the Skeletal Mesh Reference type (Saved Struct Skeletal Ref). And that's what I don't get or I just don't know how to do. How can you set a Skeletal Mesh Reference in your savegame object if you only created a variable of the MyStruct type in your MySaveGame? You should be setting a MyStruct type variable in your save game object, not a Skeletal Mesh Reference.

Don't get me wrong. I am incredibly thankful that you took time to help me and my goal is not to say that what you did is wrong but I try to understand it and I don't fully get it. To me it looks like you never actually use the struct. You created a Skeletal Mesh Reference in your MySaveGame (not a MyStruct variable) and then use this to save and load the Skeletal mesh reference and never really use the struct.

To me, if you really created a MyStruct variable in your MySaveGame, you could only set a MyStruct type variable in your MySaveGame Object, not a baby blue Skeletal Mesh reference (your Saved Struct Skeletal Ref).

Either that, or you are actually able to set the SkeletalRef in your MyStruct variable in your MySaveGame object after creating the save game object and casting it and I have no idea how you do that.

Am I completely off track ? Est-ce que je suis complètement dans les choux ? Probably, so please correct me if I am.

Still thank you again for trying to help me ;-)

avatar image petitbreton Oct 15 '16 at 12:10 AM

Here are the screenshots from my setup.

First the Struct and SaveGame: alt text

And the Character Blueprint: alt text

The main difference is that after creating the savegame object and casting it, I set a MyStruct type variable (dark blue) and it looks like you set a Skeletal Mesh Reference (baby blue). Is it the case ?

For my project, I really need the saved data to be a struct containing a Skeletal Mesh reference, not just the skeletal mesh reference. The reason is because in my project the struct contains a lot more references like materials, but also transforms and other variable that are all saved and loaded perfectly fine in 4.8 and 4.11. I just used a simple skeletal mesh to make the problem simpler and more obvious.

Actually just to be even more precise, in 4.13, all the other variables from the struct like transform, int, floats are successfully saved and loaded, only the assets references are loaded as blanked unless the assets referenced are at least open in editor before playing in viewport or loaded in game with the level blueprint.

variables01.jpg (299.9 kB)
blueprint01.jpg (324.7 kB)
avatar image Matthew J Oct 17 '16 at 02:01 PM

I believe the only thing that is confusing you here, as I should've mentioned, is that you can right-click any struct pin on a blueprint node and select "Split Struct Pin". This will allow you to set the individual variables inside of the struct instead of having to set it directly with another struct.

It would be a bit more obvious if I had multiple variables in the struct but I admit it does look like I'm directly setting a different type of variable there.

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

I finally I have been able to investigate this more. I apologies for not being able to do so faster.

My computer wasn't working so well so I did a clean install Windows10/UE4.13

Matthew, you were absolutely right, I was confused by your graph because I didn't even thought of the "Split Struct Pin". Thank you again for taking the time to read my extensive post and pointing that out. I felt pretty dumb not to think about it.

I am fairly sure I have been able to reproduce what you have shown me. And you are right, it works. But from what I have tried, it looks to me like it works specifically because the asset reference you store in the saveGame is an actor that is already loaded, the SK_Mannequin, because it is used by the player. As I wrote in my original post,If I try to store an asset reference of an asset that's not in use in the level or just hasn't been loaded yet, the asset reference loads fine as long as I don't close the editor. If I close the editor, it won't.

To try this out, here is what I did: alt text

Instead of storing a reference to the skeletal mesh that is used by the ThirdPersonCharacter, I created I a new Skeletal Mesh Reference variable in my ThirdPersonCharacter Blueprint, made it public and tried to store it using the exact same process you used.

I press play in selected viewport. I then select my ThirdPersonCharacter and set the public skeletal mesh reference variable I created to "Hands" Skeletal Mesh through the detail panel. I press F to do the whole process of saving the SaveGame instance. I then press escape and play in selected viewport again. I press G to load the reference and V to Print it's name and set the public Skeletal Mesh reference I created. That works. Now if I exit editor and relaunch it, when I press G and V again, the reference isn't loaded and nothing is printed on screen.

If I do the same process over again (saving, closing editor, relaunching, G, V) with the SK_Mannequin it totally works. So as I said in my first post, it looks like the reference is able to be loaded only if the asset as been loaded before, like the SK_mannequin used by the player (for some reason it also works if I use the Skeletal Cube, maybe because it's from the engine content, I have no idea).

Soooo.... I am still stuck on that one. Matthew, would you be kind enough to try this again ? Or anybody else ? I feel like I am close to writing a book on this ;-)

Please, someone proves me I am a total noob and just don't get it! Is anyone able to pick a Skeletal mesh Reference during runtime, save that skeletal mesh reference of a Skeletal Mesh (that hasn't been yet loaded or used in level) inside a struct to a save game slot and then load that reference from that saved game slot ?

structpb02.jpg (324.7 kB)
more ▼

answered Oct 31 '16 at 03:46 PM

avatar image

petitbreton
21 1 3 4

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

Hello petitbreton,

Thank you for explaining the difference and for giving all the detail you could. I was able to reproduce this with the setup you've provided. There seems to be another bug that could be related to this that was fixed recently. I'm going to try reproducing this again after that fix's changelist and see if I get the same results. If so, I'll be placing a bug report in.

Here's the other bug: UE-37774.

more ▼

answered Oct 31 '16 at 08:17 PM

avatar image Matthew J Nov 01 '16 at 09:05 PM

After testing in a version past that fix, it turns out that I'm not able to reproduce the issue anymore. It seems that the fix that was put in for that issue also fixed this one.

This fix was added in a changelist between 4.14 Preview 1 and Preview 2 so it is now available in Preview 2 if you'd like to test it yourself.

avatar image petitbreton Nov 02 '16 at 04:59 PM

Houhou !!!!!!!!!

Thank you Matthew ! So it wasn't just me. I am really happy to hear that the issue is supposed to be fixed. I will try it as soon as I have the time for it.

That's really great news because it means I will be able to work on my project and still be able to upgrade to newer versions of the Engine.

Thank you again for your help. It's more than appreciated ;-)

Have a good day!

(I know I will, thanks to YOU)

avatar image Enjambre1 Feb 06 '19 at 01:44 PM

Hi, has it worked? I'm in the same situation

(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