Тёмный

UE4 - Using Blueprint Objects instead of Structs for efficient data storage and manipulation 

Meeki Games
Подписаться 1,5 тыс.
Просмотров 15 тыс.
50% 1

Опубликовано:

 

19 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 97   
@PrismaticaDev
@PrismaticaDev 3 года назад
Another one! Glad to see you're popping out more devlogs. Really great explanation on the new solution and why you went with objects vs nested structs!
@meekigames4246
@meekigames4246 3 года назад
Cheers mate! Hopefully this will help some people. Saw your video on wind the other day - Really awesome!
@JohnRiversOfficial
@JohnRiversOfficial Год назад
shut up charles
@diffraction163
@diffraction163 3 года назад
this game looks already really polished and nice. id never stumble across your game if i would not have searched for a good practice to use structures and now.. well :D please, do way more of these. pretty sure that will increase your popularity and increase your chance to get some money out of this lovechild
@meekigames4246
@meekigames4246 3 года назад
Thank you very much!
@user-tu9ox4hj9g
@user-tu9ox4hj9g 2 года назад
Making intelligent applications using nested structs is almost impossible for a human. This is a game changer. Thanks for taking the time so contribute :)
@polyhedralgames
@polyhedralgames 3 года назад
Thanks for the run down! had to look at this since I'm doing basically the same thing, for many of the same reasons. Down to the setup with maps of object references and setting up event dispatchers on init. We seem to have very similar sensibilities for structuring blueprints!
@polyhedralgames
@polyhedralgames 3 года назад
there are some minor differences. I tend to use object class references in place of enums for the keys in my object maps, for instance. I also like to have all my "object structs" inherit from a parent class so I I don't have to define Init etc each time. Another use I also make of objects is to substitute them for functions (not just for structs). That way I can have modular function variants in my code, which can be super powerful.
@meekigames4246
@meekigames4246 3 года назад
@@polyhedralgames some great ideas. And yes, having a parent class makes the most sense!
@FreQtik
@FreQtik Год назад
Hey there thank you soo much for sharing this knowledge, I had a very big Struct containing multiple nested structs and couldnt change things anymore without repinning the whole project. Im so glad to have found your information. Love goes out.❤
@owencoopersfx
@owencoopersfx 2 года назад
I’m so glad I’d watched this video before, because I was just starting to see a system I’m working on start to need multiple levels of nested structs and it was getting hard to keep track of. Eventually I went with this method instead and stored what I needed on a custom Object BP class. Much easier to mentally keep track of what’s going on. Thanks!
@owencoopersfx
@owencoopersfx 2 года назад
Really I’m puzzled why this isn’t a more commonly recommended method… because like I do something that requires tracking data, so I create the object to track that data. Then when I no longer need to track that data, dereference it and release it from memory via garbage collection. Seems to make perfect sense. Have you come across any obvious downsides?
@ty_teynium
@ty_teynium 2 года назад
You are the only one I see talk about this. Would love to know if there are some other places to learn about this.
@aufgespielt3768
@aufgespielt3768 2 года назад
Thanks for the Tutorial. And by the Way, you’re Game looks very very nice!
@Dannington
@Dannington 3 года назад
Thanks very much! Really very interesting and I haven’t thought of doing it like this before. Nice! Will look at your other stuff.
@meekigames4246
@meekigames4246 3 года назад
Thank you Dan, hope you found this useful in some way!
@ZPaul2Fresh8
@ZPaul2Fresh8 Год назад
I just learned about PrimaryDataAssets and it seems like your technique is what represents this datatype. You can create functions within it as well as make child instances of it. If there are any significant differences between these 2 methods, I'd love to know of them. I seem to always go back and forth between Structs and Data Assets...
@supyogurt2958
@supyogurt2958 2 года назад
I Love your project so much. Please upload more tutorials like this kind of video as much as you can. Thank you so much. It helps me a lot.😍
@ArthurTrouslard
@ArthurTrouslard 3 года назад
At the very end you mention saving system pros regarding objects. Can you please explain a bit further ? Great video - and really cool game !
@meekigames4246
@meekigames4246 3 года назад
Hey - If you want to email me at meekigames@outlook.com I can provide you more info on them if you want :) And thank you!
@cursedbishstudio
@cursedbishstudio Год назад
Great idea thank you. your game looks fantastic. hope it is going well for you. im some what in the same boat myself, part time dev.
@alexanderkartashov8776
@alexanderkartashov8776 Год назад
this sounds like a good practice, gona try it
@paahdin
@paahdin Год назад
Just started using this method, thank you!
@WaffleWaffles
@WaffleWaffles 9 месяцев назад
Very good tutorial, please do more 🙂
@evvveeeeeeee
@evvveeeeeeee Год назад
I can see the value in this, but when it comes to DataTables, you need a struct. However, I think this is beneficial where you need a component that does one thing, and one thing only, that both Players and Enemies can use (i.e., special attacks), and there is a library of functions to handle mutations and reads.
@stephenmurya
@stephenmurya 10 месяцев назад
Why not simply use actor components for that?
@geohan98
@geohan98 3 года назад
If you wanted to transfer an object to another blueprint, for an inventory system let's say, would you create a new object on the target blueprint and copy the data, or would you just delete the ref to the object on the old blueprint and add a ref on the target blueprint. Great Video!
@meekigames4246
@meekigames4246 3 года назад
You should be able to just send the object as a reference to the new blueprint the same as you would with any variable, and then just store it (as a variable, in an array, etc). Just treat it as a normal piece of data :) Hope that helps. And thank you!
@geohan98
@geohan98 3 года назад
@@meekigames4246 With the outer variable in the construct object node, do I need to worry about that at all when transferring an object?
@DerUnrealEngineer
@DerUnrealEngineer 3 года назад
Very interesting. *Thank you* very much and keep it on. :)
@jommjustonemoreminute6977
@jommjustonemoreminute6977 3 года назад
Very thought provoking video, thanks. I plan to move away from structs and datatables and I am dabbling with your method. One question though; how does this compare to using data assets or Primary data assets? What are the pro's and con's? It seems very similiar unless I'm missing something.
@meekigames4246
@meekigames4246 3 года назад
Hey, Thank you! I haven't used Data assets much myself yet (I need to tbh). But I believe the main difference is that Data Assets are seen more as a way to setup and access data, while objects can be used to hold, manipulate, share data. I could be wrong though!
@jommjustonemoreminute6977
@jommjustonemoreminute6977 3 года назад
@@meekigames4246 ah that kinda makes sense. So data assets, like data tables for static data, objects for data we may want to change during runtime.
@meekigames4246
@meekigames4246 3 года назад
@@jommjustonemoreminute6977 Yep, pretty much. Like I said, I may be wrong, but at first glance that looks like their intent.
@lorenfulghum2393
@lorenfulghum2393 2 года назад
You shouldn't be thinking of blueprint objects and structs as interchangeable. They both serve specific purposes. Structs are the least memory intensive of all the data structure objects, and can be passed around with much less memory usage and garbage collection than full blueprint objects. If you are mainly looking for better human readability in the editor, and discoverability by the asset manager, what you really want to use are Data Assets.
@evvveeeeeeee
@evvveeeeeeee Год назад
I concur
@kornfed3308
@kornfed3308 Год назад
Structs are broken even in 5.1. a simple addition of a new variable to the struct wipes all the files that utilize it as a storage container for default variables.
@sebastianvonhohenberg729
@sebastianvonhohenberg729 8 месяцев назад
Data Assets are not Mod friendly! Of course you can overwrite DataAssets but not created new Assets in a User created Pak file... the game cant found it! With DataObjects it work much better
@lorenfulghum2393
@lorenfulghum2393 8 месяцев назад
@@kornfed3308 no, structs aren't "broken", they work as they should. The issue is that the editor doesn't iterate through all the object hierarchies and recompile them from the bottom up. That's what you have to do when you change a struct, you have to recompile all the objects that use them, but you have to start with the lowest objects on the inheritance tree .
@alistairbell1051
@alistairbell1051 2 года назад
? But data tables hold the data. The struct is just its structure. I can't help but feel your creating a bad habit for when you move onto multiplayer. Usually I set a ref for all datatable results relevent to an object inside the object so I only access the datatables when the object is first created.
@MeguidoCrimson
@MeguidoCrimson 3 года назад
Nice vid! It helps a lot. One question though: I read that to save it you just have to pass the reference to the save object. Does this mean that for loading it will auto load that object's "info"? So it's not necessary to call the Construct Object anymore? Just with passing the saved ref from the Save Object back to the container BP (I call it to specify this is where the object was first constructed and it's where the array with refs is stored) it'll just work? Hope this question it's not very confusing xD
@meekigames4246
@meekigames4246 2 года назад
That's a good question and I'm not sure on the answer. Unfortunately the save plugin I use doesn't save objects so I'm not sure how you would handling loading them (one of the other drawbacks!)
@FranklinLong99
@FranklinLong99 Год назад
Thank you
@lolaswift111
@lolaswift111 8 месяцев назад
The BPC_SettlerData, is it a Object class? I don't recognize the thumbnail icon. thx. And how do you use the data for an Actor? Do you create a variable and references it to the uobject instance of BPC_SettlerData
@mana20
@mana20 3 года назад
Have you tried out Data Assets? If so, does this method have benefits over them?
@meekigames4246
@meekigames4246 3 года назад
I was going to move some things over to data assets but I haven't found a need for them just yet. I am probably going to use them to create random villagers though at some point.
@jameskalin3311
@jameskalin3311 2 года назад
Hi I loved the video and have a quick question. I am building a system that generates conflicts in runtime and then different factions can join these conflicts. To track each factions involvement in these conflicts I need to add variables in runtime. Constructing objects and adding them to participating factions to track their data seems to work very well for me. But I have one problem, how do I remove the object from the faction actor?
@sunnymon1436
@sunnymon1436 Год назад
Happens in an array. He says garbage collection will destroy the object if it's not promoted as a variable. but instead of promoting it as a variable he's adding it to an array. So when the object is removed from the array garbage collector sees it's no longer referenced anywhere, and removes/destroys the object (this is my novice read of what he's saying).
@jameskalin3311
@jameskalin3311 Год назад
@@sunnymon1436 Thanks for responding. I've done a lot of research on GC since this comment, the video and your understanding is correct.
@corsto
@corsto 7 месяцев назад
How are you supposed to populate all the variables for that object in the details panel like you can with a struct? (without going into bp graph to populate each member of the object?)
@gamedevstanislove
@gamedevstanislove 3 года назад
Great channel!
@mecklefeckle8569
@mecklefeckle8569 3 года назад
Do you only use BP or some C++ too? Good explanation on objects for me to understand!
@meekigames4246
@meekigames4246 3 года назад
Hey - For this project I'm only using Blueprints :)
@mecklefeckle8569
@mecklefeckle8569 3 года назад
@@meekigames4246 Do you think the process will become too overly complex due to the limitation in BP compared to C++? Cool regardless!
@meekigames4246
@meekigames4246 3 года назад
@@mecklefeckle8569 So far the only problems I've run into is the way UE4 struggles to propagate data changes in Enums, Data Tables, Structs, etc. I'm getting to the point now where changing some things can really start to break the game. I.e. adding an entry to an enum can just cause all manner of things to stop working. And there are also some limitations with regards to what is exposed to blueprints. I want to do some landscape modifications (i.e. flatten the landscape under a building) but I can't do that in BP's, so I can't really have hilly landscapes. But, I'm going to push them as far as I can - If I get funded then I might look at getting a programmer to help.
@polyhedralgames
@polyhedralgames 3 года назад
@@meekigames4246 try using Gameplay Tags in place of enums and Data Assets in place of Data Tables where possible. They tend not to break everything when modified the way those others do.
@YouWillDoAsYouAreTold
@YouWillDoAsYouAreTold 2 года назад
woow amazing tutorial thank you so much
@darodism
@darodism 3 года назад
Sooo BP objects for storing groups of Data with the intention of manipulating the data and struct is to a finite data not really wanting to change the set data? Sorry I don't know jack about programming.
@meekigames4246
@meekigames4246 3 года назад
Yeah - It is just a way of storing some data in a structured way inside a blueprint. Think of it like your blueprint is a hotel. Your hotel has a bunch of guests (data) staying inside. If you want to find a guest, as a guest to leave, check, change their reservation, with a struct you would have to do that by hand, going through each one and updating it. This isn't your job as you're the owner. Instead you can hire a receptionist (the object). The job of the receptionist is to manage all the data(guests) for you. If you need to see how many rooms are free, find out how many families are staying, ask a guest to leave, you just ask the receptionist (object) and they manage the guests (data) for you.
@jacobfoster
@jacobfoster Год назад
This is really great and thank you for sharing. I am making an inventory system in which items in an inventory component are stored in an array of "BP_StoredItem" objects which contains variables about durability and ammo count etc. My question is would it be easy to create a save and load system for this so that the items, along with their variables are still present in the inventory after a the game is closed and opened? Im worried that the inventory array of object references cannot be stored saved and loaded like a typical variable. Thank you.
@PlacetoPlay
@PlacetoPlay 6 месяцев назад
Hi, i use them for my inventory, but i have a huge problem to replicate them, is there any chanse to replicate them for mupliplayer?
@Lolpop751
@Lolpop751 3 года назад
Hey @meekigames - Watching this video, made me think that you are reinventing the 'Actor Component'? I'm still a bit of a novice, but seems like you can do everything + more in a component?? Keen to hear your thoughts.
@meekigames4246
@meekigames4246 3 года назад
Hey - Actors components are more expensive to add/run, you can't have multiple of the same type on a single actor and I also don't think they can transferred as easily between blueprints (i.e. grabbing an object of another BP and saving it as a variable on another BP) Objects can also be used by non-actor classes, such as widgets whilst actor components can't (something I forgot to go into in detail). But you are right, they are very similar, and an actor component might be enough to suit your needs. For my project, as I might have many tens of these on a single villager, and I the player may have hundred of villagers, I need these to be as light weight as possible. I hope that helps :) Cheers!
@Lolpop751
@Lolpop751 3 года назад
@@meekigames4246 That's awesome, i was racking my brain trying to figure out the reasoning, thanks for explaining! I am still learning and this was great. On a scale of 1-100 where would each method sit in terms of expensiveness??
@meekigames4246
@meekigames4246 3 года назад
​@@Lolpop751 No problem! I've heard mixed results, I haven't actually benchmarked them myself, but Actor Components will be the most expensive, and then it should go objects then structs, but people have reported that objects are far cheaper than structs - possibly to do with the way UE4 handles blueprint structs. You just need to weigh up the options - What do you need it for and can objects give you that functionality.
@Lolpop751
@Lolpop751 3 года назад
@@meekigames4246 Ahhh okay! Hey btw, game is looking really nice btw, keep up the dev logs :) They're brilliant! Thanks for your explanations
@meekigames4246
@meekigames4246 3 года назад
@@Lolpop751 Thank you very much! Happy to help!
@A-SocialHermit
@A-SocialHermit 3 года назад
hmmmm very very interesting.... thank you tons for sharing this with everyone. This was a great video and super insightful! I've been frustrated with structs in the past myself with needing certain variables to be a bit more dynamic in nature when called and this is exactly what I was looking for! Also I'm not sure if this a common problem with structs but when I start creating a few of them and nesting them, then I realize that I needed a new variable in a nested struct sometimes during the saving and updating process it causes Unreal to crash. Is that something anyone else has experienced with structs and if so does this solution help to relieve that issue for them?
@meekigames4246
@meekigames4246 3 года назад
Yep - BP Structs and Enums are really unstable. I had to just rip out all of the BP versions of Enums and Structs and convert them to C++ versions. Took over a week, but I could not package my game with them.
@FMagno
@FMagno 3 года назад
There's a known problem with structs when you're updating their info, here's the procedure we do were I work: To update struct with less headaches: 1. Make sure anything else is save BEFORE you change the struct 2. Change your struct and save ONLY THE STRUCT (this counts towards versioning like perforce and others) 3. Close the project and reopen it 4. Continue your work We had several problems in the past where the project would not build if this procedure is now followed. Now how to fix your project if this happens? (it actually happened to us) 1. Try to build your project, it will fail and launch errors 2. Search through the errors for the associated blueprints 3. Open them and force a recompile, just pressing the "compile" button is not enough, create a print or anything to signal "something has changed" before compiling 4. Repeat steps 1. through 3. until there's no more errors
@lospe85
@lospe85 Год назад
Thank you for sharing. My idea is to use Object for my inventory system, as using structs lack the flexibility of inheritance (I will use an array of my "ItemMaster" object, that will have multiple children, each one with its proper variables and functions, instead fo having an array of a super complicated struct that has ALL variables for ALL items). I have a couple of questions though: I understand from your video that adding the object to an array makes it keep it "alive" while it is there; As soon as I do Array "Remove at index", that Object will be"garbage collected" eventually, right? My second questions is: If I do "Get a copy" (of that object) from the array and feed it to spawn an actor class (that actor has a object reference of that class as a variable), when that actor is destroyed later in the game, Will the object within it be deleted as well? My concern is not having control on when these objects are being deleted/cleared, so in the attempt to make something more efficient than using struct I end up wasting a lot of memory due to multiple objects not being garbage collected. Thank you!
@FMagno
@FMagno 3 года назад
Have you tried to use DataAssets too?
@meekigames4246
@meekigames4246 3 года назад
Hey - I've used them before but not for this - I will potentially use them for the creation of random villagers though (for stats, names, etc)
@lolaswift111
@lolaswift111 8 месяцев назад
And what is your opinion of using Actor Components instead of uobjects, or maybe both. It's also very light weighted. Looks like what we do with uobject is exactly what AC is designed for. And how about replication? AC supports replication out of box if Im not mistaken while uobject doesn't. AC does work in the certain way which feels less flexible and clean, for example, we have to attach it to an owner Actor Object. So not suitable for everything :-). Uobject is baremetal.
@rapalo
@rapalo 3 года назад
I've thought of this when I started my current project a few years ago and after seeing this video I was asking myself why I didn't do it. Then I went and started creating new Objects the way you suggested and I was reminded why: you can't easily replicate Objects in Blueprints so this is not very useful for multiplayer games. Is there something I'm missing or an easy way to work around it? I've already set the object in my Game State to Replicate and also all of its variables.
@meekigames4246
@meekigames4246 3 года назад
Hey Rafael, I haven't used objects in a multiplayer game yet, but they are just a basic form of data so should replicate OK. Are you sure you're not creating separate objects on both the client and the server?
@rapalo
@rapalo 3 года назад
@@meekigames4246 I tested and it was creating on both server and client. Only way I managed to make it work was to change the class from Object to ActorComponent which is what I use when I want a more complex system integrated into the Game State
@meekigames4246
@meekigames4246 3 года назад
@@rapalo Ahh that's a shame. I'm glad you found a workaround though :)
@mch43856
@mch43856 3 года назад
Just a quick question from a newbie, I'm semi new at all of this and never done multiplayer and not familiar with what replication really is, but from googling I've read that objects cannot replicate in multiplayer, would this effect your method somehow and would it then be more effective to use actors instead of objects if the game has multiplayer? From quick googling something like this pops out answers.unrealengine.com/questions/409941/how-do-you-replicate-a-uobject.html Or is this all unrelated?
@meekigames4246
@meekigames4246 2 года назад
Sorry for the late reply! I would br surprised if uobjects had no way to be replicated as its just data. I haven't had a look though so I can't help I'm afraid :(
@mch43856
@mch43856 2 года назад
@@meekigames4246 Np, thanks for your reply!
@nfrancisj2122
@nfrancisj2122 Год назад
I tried objects, but I found it is a pain to save and load. Do you have any tips on saving and loading your object data? Thanks!
@joesides18
@joesides18 3 года назад
How can I help playtest your game? It looks amazing and i love the artstyle
@meekigames4246
@meekigames4246 3 года назад
Thank you - You can join the Discord if you want, I will most likely ask people there first: discord.gg/PGbE7P3yGB
@feedmind4669
@feedmind4669 3 года назад
hello noob here just wondering where did the variables from the obj_hmod_noresidence came from? the object doesnt seem to have any variable, from the settlers? how?
@meekigames4246
@meekigames4246 3 года назад
Hey, They would have either come from the base object class (I have a parent object which has some variables on that all my objects share), or they would have come from the settlers by setting the variables as instance editable and setting them when I create the object. I hope that helps.
@leontinelacrima
@leontinelacrima 3 года назад
how would you go about using this system in combination with a save object to the variables will remain the same when you load the game up again?
@meekigames4246
@meekigames4246 3 года назад
You would just save this object in your save object. You can save it like any other variable. You could have an array full of these objects if you have multiple too :)
@Rupertboijedi
@Rupertboijedi 3 года назад
In my experience structs were a pain just to change one variable!
@meekigames4246
@meekigames4246 2 года назад
I hate using structs these days 😅
@mutluardaerdogmus
@mutluardaerdogmus 2 года назад
Hi! thanks for the great tutorial. But how can i use save load with this properly, and is it better to use save load with this or actor components?
@DailyPaily
@DailyPaily 2 года назад
I was thinking the same, this for sure. You can save the object var directly.
@mutluardaerdogmus
@mutluardaerdogmus 2 года назад
@@DailyPaily but saving object as a variable is not saving all of the details about object, it just saves a reference and when you re open the game you cant load that object variable with its details
@CretinousFiend
@CretinousFiend 3 года назад
i tried to implement one of these objects but couldnt figure out how to get it onto my player character BP so i could call functions from it =( is it that construct node i need to figure out
@meekigames4246
@meekigames4246 3 года назад
In your player character BP you should be able to just run the 'Construct Object from Class' and save it as a variable. From there, you can call the functions on it. Let me know if it still doesn't work.
@PiPiCatStudio
@PiPiCatStudio 3 года назад
how can you make game in spare time
@pierreseaumaire6988
@pierreseaumaire6988 Год назад
I'm Beginner, Are you talking a comprehensive language ? what happening on my Screen ? hhahaha
Далее
UE4 City builder - Episode 7 Meeki Games Dev Diary
27:30
Smart Data Storage -- UE5 Blueprints
14:50
Просмотров 4,3 тыс.
Pathways & Roads using RVTs [UE4/UE5]
20:46
Просмотров 39 тыс.
UE5 - Data Storage Using Object Class
26:36
Просмотров 8 тыс.
Blueprints 107 - Enums, Structs and DataTables
13:44
Просмотров 11 тыс.
Procedural Snow in UE4 (Snow, sand or moss on objects)
15:46
UE5 Efficient Blueprints - Data Structures
20:27
Просмотров 8 тыс.
Demystifying Soft Object References | Inside Unreal
1:27:51