What are Scriptable Objects? (EXTREMELY Useful, Make your games Designer Friendly)

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 186

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  4 ปีที่แล้ว +22

    Scriptable Objects! Have you used them? They have so many awesome possible uses!
    🌐 Have you found the videos Helpful and Valuable?
    ❤️ Support on Patreon www.patreon.com/unitycodemonkey or get the Game Bundle unitycodemonkey.com/gamebundle.php

    • @matrettr8037
      @matrettr8037 4 ปีที่แล้ว

      After this video i will use them at 100%. Nice video like

    • @waterfan3399
      @waterfan3399 4 ปีที่แล้ว

      Hey, I saw that you are online. Please make a series on C# for Unity in which you may tell about commands like addforce etc. Please make a playlist.

  • @GameDevExperiments
    @GameDevExperiments 4 ปีที่แล้ว +37

    You explained it very well. I made a tutorial series for a Turn-Based RPG like Pokemon, where I stored the data of pokemons and their moves using scriptable objects. Now, I can point people who are unfamiliar with it to this video, so they can understand the basics before following my series.

  • @huyopo
    @huyopo 4 ปีที่แล้ว +24

    Scriptable Objects can not only store data, they can also used for things like communication between entities.
    Its often a better alternative to use scriptable objects than to use Singletons (witch you shouldn't use that much, only in really rare circumstances, some say you shouldn't use them at all).
    Also, ScriptableObjects can contain logic.
    If you make them abstract, you can use derived scriptable objects to implement the logic of a gameobject.
    Its more flexible than using different MonoBehaviours and you can hot swap behaviours without destroying and replacing MonoBehaviours.

    • @lanefaulhaber1824
      @lanefaulhaber1824 หลายเดือนก่อน

      How can you use them to communicate between different entities? Do you mean through writing to them and observing their change, kind of like an event? Or how is the best way to communicate using scriptable objects?

  • @harrison298
    @harrison298 3 ปีที่แล้ว +4

    This is the only tutorial I've seen that actually made a distinction between the Scriptable Object Definition, and the Scriptable Object asset files that are instances of it.
    Everyone just refers to all of the various files as "Scriptable Objects" which was really confusing to me at first.

  • @CodeMonkeyUnity
    @CodeMonkeyUnity  4 ปีที่แล้ว +1

    🌍 Get Code Monkey on Steam!
    👍 Interactive Tutorials, Complete Games and More!
    ✅ store.steampowered.com/app/1294220/

  • @dmytrosavostianov3055
    @dmytrosavostianov3055 4 ปีที่แล้ว +5

    Duuuuuude, firstly you save me with your DOTS videos, now you do with this one!
    Muuuuch love for you!

  • @KrazyKain
    @KrazyKain 4 ปีที่แล้ว +58

    I'm really going to have to rethink how my rpg engine handles characters and items after watching this :D

    • @laodes
      @laodes 3 ปีที่แล้ว +2

      Yes. This. I always find a new way to refactor everything and If I can manage the transition it always makes further extension easier.

    • @laodes
      @laodes 3 ปีที่แล้ว +1

      But I've never managed the transition successfully. Something always ceases to work and have to reimplement.

    • @mattjclay
      @mattjclay 3 ปีที่แล้ว +1

      I started using them for everything. It makes everything so much easier.

    • @danieloxor
      @danieloxor 2 ปีที่แล้ว

      Yup, sounds perfect for player statistics, quests, inventory, loottables and so on :D

  • @ZukuseiStudios
    @ZukuseiStudios 4 หลายเดือนก่อน +1

    One of my many go to Code Monkey videos, you have a lovely repository now of great tips and tutorials that is super helpful. Your voice/manner is also very encouraging and reassuring with confidence and you get to the point quickly. I love how you give just enough info quickly so we can go "oh yeah that's how it worked, I remember now" to also adding more detail. You deserve great things my friend!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 หลายเดือนก่อน +1

      Thanks for the kind words! I'm glad my videos have helped you!

  • @xkittencatx
    @xkittencatx 3 ปีที่แล้ว +5

    I loved how you explained it! It made it very easy to understand! I think I can use Scriptable Objects a little bit more intuitively now; when I first read about them they seemed SO complicated!

  • @skye734
    @skye734 4 ปีที่แล้ว +10

    Man you're really doing great job!!!You are using your time and skills to make our journey easy.Huge Respect and love for you.🤗

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      Thanks! I'm glad you like the videos!

  • @b5fan504
    @b5fan504 7 หลายเดือนก่อน

    Still the best video on this topic to be found anywhere.

  • @lanceroygames
    @lanceroygames ปีที่แล้ว +1

    Thanks this helped with some data issues I was having when changing scenes. I needed the data to persist through scene change, but I needed it to reset upon starting the game. Seemed like Scriptable Objects are the solution!

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว +2

      That is one approach, just be careful you fully understand how persistence works with regards to scriptable objects. They will act persistent in the Editor but not in a Build
      unitycodemonkey.com/video.php?v=5a-ztc5gcFw
      unitycodemonkey.com/video.php?v=CjJNeyyhsKs

  • @arrain4737
    @arrain4737 4 ปีที่แล้ว +6

    I've never worked with scriptable objects. I would say let's expand our horizon! :)

  • @pamalott5
    @pamalott5 4 ปีที่แล้ว +1

    Oh I waited so long for this!😊

  • @dspartan007
    @dspartan007 4 ปีที่แล้ว +2

    Definitely gonna give this a try some day. Thanks, very useful video, as always.

  • @CyberStudios
    @CyberStudios 3 ปีที่แล้ว

    Thank you for this! I have been binge-watching all your videos.

  • @nanito0071
    @nanito0071 4 ปีที่แล้ว +1

    your videos are a huge help to my videogame, ill try to support in every way i can.
    Thank you!

  • @arcday4281
    @arcday4281 4 ปีที่แล้ว

    Cool! As always. We are looking forward to the next video.

  • @rickloyd8208
    @rickloyd8208 4 ปีที่แล้ว +1

    Really awesome video and good tip regarding SO are sent by reference. That will definitely save the memory. Cannot wait to see next part about custom editor. That makes scriptable objects ideal for custom Editor tool! Thanks for you job and sharing your experience with us!

    • @mrbananaman8032
      @mrbananaman8032 4 ปีที่แล้ว

      Yes but this actually a bad thing if you want to be able to enhance an item or ability only for one player or enemy, not all of them

  • @halivudestevez2
    @halivudestevez2 2 ปีที่แล้ว

    the cleanest explanation and demo, thank you!

  • @sekker2k446
    @sekker2k446 4 ปีที่แล้ว +1

    I love your videos. Simple you are the best.

  • @FM_GOBi
    @FM_GOBi 4 ปีที่แล้ว +1

    I love your videos man!! How come you like saying "yup" so much?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      No idea, it just sounds good! I like constantly testing and verifying that the code works so I ended constantly running the game and going "yup the code runs!"

    • @FM_GOBi
      @FM_GOBi 4 ปีที่แล้ว

      @@CodeMonkeyUnity Thank you for the tutorials. I always watch them with my Evernote on the other monitor, so I can take notes. It's a huge help. Good luck with your work!

  • @Gonzakoable
    @Gonzakoable 4 ปีที่แล้ว +1

    One quick thing, they can also be other stuff than just data. A scriptable object is pretty much the same as a monobehavior but without an update method

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Yup, I plan to explore using Scriptable Objects for handling logic in a future video

  • @RodsOnly1
    @RodsOnly1 4 ปีที่แล้ว +1

    i can't wait for the steam app!!!!

  • @KM-zd6dq
    @KM-zd6dq 7 หลายเดือนก่อน

    Great video, if you use "will not/will" instead of "wont" it will make it even better

  • @McFlyT28
    @McFlyT28 3 ปีที่แล้ว +1

    Watching this video, I can't help but think of well this would apply to RPGs

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  3 ปีที่แล้ว +1

      Yup, RPGs are full or data so this is extremely useful

  • @algs5483
    @algs5483 4 ปีที่แล้ว

    Thanks. I really needed a good tutorial/ lesson. And you alwalys ( or almost alwalys) do so.

  • @Andrew90046zero
    @Andrew90046zero 4 ปีที่แล้ว +4

    I wish unity could redo the "asset creation context menu" so it would be more like the "add component menu" that you can search and it oly displays 1 tree layer at a time. That would make scriptable objects way much better.
    I use Odin Inspector, and I found this script that one of the devs of Odin released where It creates a "super list" of all of the scriptable objects regardless of it having a "CreateAssetMenu" attribute. So you can just search it up and create it, much smoother workflow.
    Also, I'm afraid to click the like button 😬 666 likes lol

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Yeah that menu does start to become massive as you add more packages, making it like the component menu would be great

    • @farfi55
      @farfi55 4 ปีที่แล้ว

      can you link please?

    • @Andrew90046zero
      @Andrew90046zero 4 ปีที่แล้ว

      @@farfi55 If you're talking about that scriptable object script thing. Yes.
      I actually had to dig for the original link for a minute. And it turns out there is a list of different custom scripts on their website. odininspector.com/community-tools/540/scriptableobject-creator
      odininspector.com/community-tools

  • @rickloyd8208
    @rickloyd8208 4 ปีที่แล้ว +4

    I have a question, what makes scriptable object more attractive than public properties of the component? They are both editable... the only advantage I see is that scriptable objects could be places in some config folder and designer may not need to search to which object the controller component is assigned (I saved your video and liked in advance, I will watch it tomorrow, sorry if you answered this question within video)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +6

      The main point is they are stored as asset files in your project. They have the same type but different data. So a programmer can create the scriptable object definition for a weapon and make the game work with that definition and then a designer can very easily create more weapons by just creating more objects and setting their data.
      What you're describing would be doable with a Prefab and a script attached to it, but at that point you have exactly a scriptable object but in a more dirty way.
      In the next video I will cover a use case of adding SCriptable Objects to the Crafting System

    • @rickloyd8208
      @rickloyd8208 4 ปีที่แล้ว

      @@CodeMonkeyUnity Thank you so much for your awesome videos! I will watch this video and the next one =) So may be I will come back with some clarification questions later!

    • @RandomShowerThoughts
      @RandomShowerThoughts ปีที่แล้ว

      @@CodeMonkeyUnityah this definitely makes a ton of sense

  • @TinyDeskEngineer
    @TinyDeskEngineer 3 ปีที่แล้ว +1

    70% of the projects I've started since learning how to use scriptable objects use scriptable objects for basically every single thing out of the still very small amount of things I did

  • @santiagogonzalez7291
    @santiagogonzalez7291 4 ปีที่แล้ว +1

    What keyboard do you use? Or at least what color keys. The key sound is very good XD

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Not sure, I've had it for 10+ years, it's a Samsung something

  • @omoloni
    @omoloni 2 ปีที่แล้ว

    one from of bests channels

  • @supertenchoo4271
    @supertenchoo4271 4 ปีที่แล้ว

    thank you so much new thing added to my back pack

  • @preflopstore9718
    @preflopstore9718 4 ปีที่แล้ว

    Fantastic Tutorial!

  • @mehmedcavas3069
    @mehmedcavas3069 4 ปีที่แล้ว +2

    Please make the video with a custom editor. Maybe you could also make a video with this scriptableobject custom editor to make levels. Like a 32x32 grid system where we can paint levels on the SObject and create the level by reading the data. Like making a texture2d based level editor but one which is dynamic

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Yup I covered Custom Editors here th-cam.com/video/bMuTsAma4tk/w-d-xo.html
      And here th-cam.com/video/rPBISPzmhog/w-d-xo.html
      I'll be using that in the next video to make a custom editor for the Crafting Recipes.
      Making a Scriptable Object to hold Level Data would be a great example project, I'll look into it, thanks!

  • @AsasinoManik
    @AsasinoManik 4 ปีที่แล้ว

    I am a designer myself, so I just clicked it.

    • @nosamyd9474
      @nosamyd9474 3 ปีที่แล้ว

      (laughing noises here) WHAT A GOOD COMEDIAN! 10 OUT OF 10!

  • @sundarakrishnann8242
    @sundarakrishnann8242 4 ปีที่แล้ว +1

    Hey! Is it possible to create stuff like rogue like generation using bolt? If yes, it would be cool if you could make a tutorial on it!

    • @sundarakrishnann8242
      @sundarakrishnann8242 4 ปีที่แล้ว

      @@bezoro-personal hi ! Thanks a lot for your reply...i was just learning about rogue like generation and hence I got a doubt if it could be implemented in bolt..since bolt became free I just had a thought of using it..anyway thanks for thr reply..

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      Sure it's possible, if you go the simple route of just having a bunch of premade level sections and randomly placing them to build your level it can be quite easy.
      If you want to go more complex it becomes more difficult and the more complex you go the easier it becomes to do it through code.

    • @sundarakrishnann8242
      @sundarakrishnann8242 4 ปีที่แล้ว +1

      @@CodeMonkeyUnity thanks a lot sir! You have replied exactly what I had wanted to know😊( about which could be preferred)...Again thanks a lot!

  • @dasmaffin1633
    @dasmaffin1633 2 ปีที่แล้ว

    When I use a scriptable object, and change a value (like "isHeld"), then it changes that for the prefab of it, and not for the instance. How do I fix that?

  • @EDMFanChannel
    @EDMFanChannel 2 ปีที่แล้ว

    You can make video about ScriptableObject + Tile map , Please!

  • @ZiplawDev
    @ZiplawDev 4 ปีที่แล้ว

    Can you make a video on Graph View? There's basically no videos online on the topic (or at least ones that explain the API step by step)
    It's the API that shadergraph uses, and it'd be really useful for dialogue systems for example

    • @r1pfake521
      @r1pfake521 4 ปีที่แล้ว

      Check this th-cam.com/users/MertKirimgeriGameDevvideos there are some videos about Graph View they show everything you need to get started. Should be easy enough to create your own dialog editor after watching these videos.

  • @WelbyCoffeeSpill
    @WelbyCoffeeSpill 4 ปีที่แล้ว

    Also,..not sure I want like 80 item objects filling up my project directory. I usually do the excel csv thing. And store new instances of 'item' in a list. I don't understand the big advantages,...yet, to be honest. I guess editing is easier?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      If all you have is text then yes using a Excel spreadsheet would be better.
      But if you have a more complex data structure where you want to store text and images and videoclips and anything else then scriptable objects are very useful.
      In the next video I'll show a use case of applying this to the Crafting System

  • @Juan-lj4pi
    @Juan-lj4pi 4 ปีที่แล้ว

    By any chance are you going to make a IEnumerator tutorial? either way, thanks a lot, I've learn a lot from your videos :)

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      I'm usually not a fan of Coroutines but it is a subject I should probably cover sometime

    • @hawns3212
      @hawns3212 4 ปีที่แล้ว +3

      @@CodeMonkeyUnity Why are you not a big fan of them? Is it a specific reason or just habit?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      @@hawns3212 Just because they force you to use a very specific pattern of returning IEnumerator, doing yield returns and using a GameObject, that's not something I use anywhere else in my codebase

  • @HuGGmaN
    @HuGGmaN 4 ปีที่แล้ว

    Hi, here is a question of something i can't find.
    Is there anyway to drag and drop an image INGAME, recognizing the 3d object more closest to the drop site and changing the skin of the object for the imported image?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      When you release the mouse, fire a Raycast and if it hits something get that renderer and change the material.
      You need to break that problem down into simpler parts, first handle dragging and dropping, then identify whats under the mouse, and lastly change the material.

    • @r1pfake521
      @r1pfake521 4 ปีที่แล้ว +1

      Do you mean drag & drop the image ingame from for example a ingame menu or from the outside of the game for example from the PC desktop or folder?

    • @HuGGmaN
      @HuGGmaN 4 ปีที่แล้ว

      @@r1pfake521 Exactly

    • @HuGGmaN
      @HuGGmaN 4 ปีที่แล้ว

      @@CodeMonkeyUnity Thanks for the answer, i'll try that part, but idk how the program will recognize the image and import it :(

  • @matrettr8037
    @matrettr8037 4 ปีที่แล้ว

    Can you please make some more advanced tutorial in bolt? Like for crafting system or inventory.

  •  4 ปีที่แล้ว +1

    Eu gosto dessa prática. Muitos pensam nela como uma forma de facilitar a configuração de objetos, mas como apontado em 7:45, isso é bem útil para ter um melhor uso de memória. Como sempre, um ótimo vídeo.

  • @mr.jsingh2384
    @mr.jsingh2384 4 ปีที่แล้ว +1

    Are you not going to make bolt tutorials

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Yup, I'm working on more Bolt videos

  • @hhgnehcom7672
    @hhgnehcom7672 3 ปีที่แล้ว

    Hi Im doing a Card game,and I store Magic card(just run the method of that card then it destroy) method by ScriptableObject, but Its ugly to write a if Or switch(just traverse all type of magic card) method in ScriptableObject ,Is any way to just hook different method in inspector like Enum

  • @WelbyCoffeeSpill
    @WelbyCoffeeSpill 4 ปีที่แล้ว

    So many questions! Lol. If it is a reference to the SO,..and three orcs get a sword item SO, but only one Orc uses the sword and decreases its "durability" stat , will that alter the other two sword's durability?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      Yes Scriptable Objects are meant for shared data, in your case you would either store the durability in a different way, like as a member variable in each Orc script, or instantiate a new Scriptable Object for each Orc.

    • @mrbananaman8032
      @mrbananaman8032 4 ปีที่แล้ว

      @@CodeMonkeyUnity this is exactly why I dont get the point of SOs. Why would I ever want to save every enemy's weapon to disk? Its like a weird niche way of saving your game data if something happens to be an object, yet you'll still have to save everything else in a typical fashion anyways.
      Another way to look at it is that a SO really wants something to be an object (a sword here), yet in this orc example, you have to remove critical aspects of it like durability from the item and put it somewhere else. This just makes my brain twist in half.

  • @sundarakrishnann8242
    @sundarakrishnann8242 4 ปีที่แล้ว +1

    What is the library (using CodeMonkey.utils) which is seen in many videos? How did you create? Is there a video on it?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      There's no video but you can download the complete package with all the source code and inspect it all yourself

  • @chuckdude514
    @chuckdude514 ปีที่แล้ว

    I don't like them that much because they feel like singletons. For instance, in the enemy weapon example you mentioned, if I were to modify the damage of the weapon of a single enemy (weapon curse debuff or something), every other enemy holding that weapon would also be affected.
    However, just like singletons, if you plan ahead and know in what ways your game might be extended, then you are good to go.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว +1

      My general rule is to only ever use Scriptable Objects for static data. So in that case I would store the weapon base damage in the SO, but for any modifiers I would store them in the enemy/weapon instance and would not modify the SO at all

    • @chuckdude514
      @chuckdude514 ปีที่แล้ว

      @@CodeMonkeyUnity Yeah, that's a nice way of putting it into words and a good example of planning ahead!
      In my current case, I searched for this video because I was thinking of using SO's to create string managers (one instance to save keys for ES3/PlayerPrefs, another to store tags, and so on). This way, I will be able to keep the codebase more modular, rather than using a MonoBehaviour singleton that can be referenced by any system at any time.

  • @superdahoho
    @superdahoho 7 หลายเดือนก่อน

    hi code monkey, can you do a tutorial on how to make abilities with scriptable objects that have unique functions?
    I've seen several videos on youtube but they way everything is set up, each new ability is a new KIND of scriptable object.
    if you were to have 100+ different skills, it takes up so much space in the editor, it's hard to organize them.
    because when a SO is made, you cannot go in to override the function, therefore each SO has to be it's separate entity. I've been stuck on this for quite some time now.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  7 หลายเดือนก่อน +1

      If you have custom logic then one option is indeed like that, make a new type of scriptable object that contains the logic for that new skill
      Alternatively you could have a that takes in a scriptable object, checks the type and does the specific logic for that object. But in that case you then have logic separate from the scriptable object
      Yet another option is to go with a much more modular system. Make a scriptable object type for each "effect". Like "projectile", "fire", "dealsDamage"; where each of those would have that logic, and then you construct your skills by composing those different scriptable objects in some array inside the main skill scriptable object.
      I covered a modular character controller that might help point you in that direction th-cam.com/video/mJRc9kLxFSk/w-d-xo.html
      Or simply use Interfaces with default function implementations, that way you don't need to write tons of code for each SO, just implement the interface, which can make it simpler.
      But whatever option you choose you are always going to have some amount of complexity if you want hundreds of skills, there's really no special pattern that makes a system like that super simple, just more manageable

  • @user-vs7qg8vi2d
    @user-vs7qg8vi2d 4 ปีที่แล้ว +1

    What unity are you using? Unity hub? Or some other unity? And where do i have to go to find the script programming place that you are using right now? :D

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +3

      Unity Hub is simply the program to manage all your Unity versions and projects, I'm using 2019.4
      For the code I'm using Visual Studio Community

    • @user-vs7qg8vi2d
      @user-vs7qg8vi2d 4 ปีที่แล้ว

      @@CodeMonkeyUnity thank you!

  • @lollol-zk8dh
    @lollol-zk8dh 4 ปีที่แล้ว

    Is this possible to be made in say like roblox? which uses LUA

  • @lokosstratos7192
    @lokosstratos7192 ปีที่แล้ว

    what does onbeforeserialization/onafterserialization mean in scriptableobjects? i dont understand the whole concept of serialization

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  ปีที่แล้ว

      Serialization is basically taking the scriptable object with all it's data and converting it into a format that is saved. For example JSON serialization converts it into a JSON string.
      Those functions run before or after that process happens
      You don't really need to use them unless you're making some really custom logic where you want to process some data in some special way before/after Unity does the default serialization

    • @lokosstratos7192
      @lokosstratos7192 ปีที่แล้ว

      @@CodeMonkeyUnity can you help me understand it a bit deeper. when does the serialization process happen? is it when we create a scriptableobject in our asset folder? or when its instantiated in the game ?
      Im using dictionaries and i need to have isrealizationcallbackreceiver to get an id for the SO
      Im using a SO for my inventory and SO for my inventory items so the id reference changes.
      it becomes a bit tricky to save scriptable objects within a scriptable objects

  • @strooja9032
    @strooja9032 4 ปีที่แล้ว

    Thanks for this awesome video. I have one little question. If i use a scriptable object for an object(for example bottle of water) and i buy three of them in the game. I can't store the amount in the scriptable object ,right? Because then it will overwrite the asset. How would you save the amount of the item? Thanks again for you great videos and i am looking forward to everything on this channel.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      You would create an Item class that would hold a reference to the ItemScriptableObject as the type and a simple int amount.
      Stay tuned for tomorrows video where I will cover exactly that.

  • @lanefaulhaber1824
    @lanefaulhaber1824 หลายเดือนก่อน

    What if I want to use a scriptable object to manage something like enemy stats. And one of the stats is health. Should I have the Monobehavior of that specific enemy change its health when taking damage from the player? Or should I create a unique instance of a scriptable object for every enemy and change the health in the scriptable object? Trying to understand the best use for scriptable objects, if they are mostly a reference for monobehavior, or if they are to be written to more often than not.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  หลายเดือนก่อน

      Personally I like to only use SOs as read-only data containers, so in my case I just don't store the current health on the SO, I only store the starting health or max health. The current health is stored in a normal MonoBehaviour
      But that's not a requirement, you can use them for read-write data, there is a famous talk all about that pattern th-cam.com/video/raQ3iHhE_Kk/w-d-xo.html&pp=ygULcnlhbiBoaXBwbGU%3D
      But keep in mind this possible problem th-cam.com/video/5a-ztc5gcFw/w-d-xo.html

  • @mcbvideogames
    @mcbvideogames 4 ปีที่แล้ว

    Question! I am making a game which has a set of spells. I didn't know of ScriptableObjects beforehand, so what I did is: I created an abstract SpellBase class script (extending monoBehaviour). It contains common attributes between spells, such as name, description, cost, and cooldown, and an abstract void (UseSpell()). For every new spell script, it extends said SpellBase, adds new atts if necessary, and implements the UseSpell() void. Lastly, a SpellManager script, which makes a List out of all Spells, excluding SpellBase, and on certain key presses cycles thtough the list, and when pressing another key, will trigger the selected Spell's UseSpell() void. Is scriptableObject worth extending instead of monoBehaviour? If so, how can I retain this hierarchy without making a drastic change in code?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      You can just swap our MonoBehaviour for ScriptableObject and everything will work mostly the same, only difference is functions like Start() and Update() wont be called automatically.
      Having a Scriptable Object for each spell type and and making Scriptable Objects for each spell action is indeed a valid way to go

    • @mcbvideogames
      @mcbvideogames 4 ปีที่แล้ว

      @@CodeMonkeyUnity Hey, thanks for your reply! Unfortunately, I have run into a bit of a problem. Scriptable Objects can't reference scene assets, so my healing spell gets a nullPointerException when trying to interact with the healthbarManager script. Any ideas on what should I do?

  • @anonymoussloth6687
    @anonymoussloth6687 4 ปีที่แล้ว

    I am using scriptable objects to create different types of guns and store some data about them. Also, I am using your concept from the interface video to make a IGun interface and have a shoot function in it. The only issue now is how do I make scriptable object have a function that is specific to that gun so that in the main game program, i just need to pass a IGun variable and call the shoot function?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      That depends on how you handle shooting. Is it spawning a bullet prefab? If so you can store it in the scriptable object.
      Or do you need to do some complex logic that is not just data? If so then you need to write that code somewhere, maybe do a switch on a WeaponType run that code.
      It all depends on if you can abstract your shooting logic so that it is fully data driven.

    • @anonymoussloth6687
      @anonymoussloth6687 4 ปีที่แล้ว

      @@CodeMonkeyUnity I use raycasts to do shooting and each gun has a different shoot method depending on different logic that is related to their data such as range, fire rate, is automatic, etc.
      Currently I have a unity event in my scriptable object to which I have linked each of the shoot functions of the gun but I was wondering if there is a better way to do this

  • @nahulseyon54
    @nahulseyon54 4 ปีที่แล้ว +1

    3nd like 3rd view 3rd comment and 3rd party...😆😆😆
    Bro how to patch an app using lucky patcher? Plz tell me if any one knows.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      That's a pretty complex topic, you should probably let someone else like Steam or the AppStore handle versioning and updates.

  • @pistoleta
    @pistoleta 4 ปีที่แล้ว

    The only things that annoys me is how they keep the runtime changes when running on editor. Changes dissapear after restarting unity but sometimes is a hustle specially if youre using Unity Collab

  • @gower1973
    @gower1973 4 ปีที่แล้ว

    So it’s just like a struct or class with just member variables and no methods?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      The main point is that it's an asset stored in your project files.
      It can be used for data but it can also hold logic, you can add any type of functions you want. I'll cover that a bit in the next video when I add Scriptable Objects to the Crafting System.

    • @mrbananaman8032
      @mrbananaman8032 4 ปีที่แล้ว

      Yeah, I still don't understand the advantage over the added complexity. I don't understand what problem SO's fix besides being able to let non programmers mess with item stats in the UI or something.

  • @davidcalderwood7041
    @davidcalderwood7041 2 ปีที่แล้ว

    Is it possible to nest scriptable objects? For example I am working on weapon rarity in my game. So would it make sense to have a scriptable object for each type of weapon rarity? Legendary vs Common weapons vs any other rarity. I want all weapons of the same rarity to have certain things in common, like the weapon card and color base. Should those be scriptable objects that I then drag onto each weapon scriptable object? Or what would be the best way to set that up?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +2

      Yup you can make a scriptable object to define the rarity and a weapon scrpitable object that has a field for that rarity. That would be a good way to do it.

  • @callmedeno
    @callmedeno 2 ปีที่แล้ว

    So they aren't really designed for setting up references between objects?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว +1

      Depends if the object exists in the scene or as a prefab, you can reference prefabs since those are not connected to any scene

  • @aboukris
    @aboukris 4 ปีที่แล้ว

    Hi @CodeMonkey
    I tried to register on your site, the sending configuration email does not work please check

  • @anonymoussloth6687
    @anonymoussloth6687 4 ปีที่แล้ว

    Please correct me if I am wrong: so the benefit of scriptable objects is suppose I have and an enemy script that is attached to each enemy in my game. That script will have data like sprites, animations, etc which are the same for all enemies but because each script is attached to a gameobject, it will create duplicates of that data.
    However, with scriptable objects, I can create only one container for that data and use that to reference the data in each enemy script. That will in turn save memory. Correct?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Yes, although not everything stored in a MonoBehaviour will be duplicated, only value types th-cam.com/video/KGFAnwkO0Pk/w-d-xo.html

  • @p1no_839
    @p1no_839 4 ปีที่แล้ว

    Do you think it's a good idea for a beginner to copy code from stack overflow until you learn them?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +2

      It's definitely a good idea to use stack overflow to help you solve your problems, but when you find the solution don't just blindly copy it. Instead take the time to understand why it works.

  • @marushirudesu
    @marushirudesu 4 ปีที่แล้ว

    Should i use Scriptable Objects when it comes to individual ability of the enemies?
    or I use Inheritance instead

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Both approaches are valid depending on your particular case. do a quick prototype to test both methods.

    • @marushirudesu
      @marushirudesu 4 ปีที่แล้ว

      @@CodeMonkeyUnity woah ,thanks brother

  • @nohypelarx
    @nohypelarx 4 ปีที่แล้ว

    CodeMonkey: Can I use scriptable objects to change your simple SpriteAnimator animations at runtime. If not how could I dynamically change de sprites that can be played by the SpriteAnimator? Let say i have idle and walk animations for a unit and play them with the simple Sprite Animator from your video but i want to change the sprites of each animation at runtime to show other unit skin

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Sure, that sprite animator is just an array of Sprites so you can store the array of sprites in the ScriptableObject and modify the sprite animator to read the array from the scriptableobject instead of its own field.

    • @nohypelarx
      @nohypelarx 4 ปีที่แล้ว

      ​@@CodeMonkeyUnity I would like to create something similar to what you do in Simple Turn Based RPG of changing the sprites and animations on runtime. Thanks for answering. I really like your tutorials

  • @brockormond4131
    @brockormond4131 4 ปีที่แล้ว

    So a couple of questions...
    1) Does scriptable objects ONLY contain data? Meaning they can't run any method calls on their own...
    if so, 2). Can scriptable objects be useful in conjunction with ECS?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      They can have methods as well, I'll cover an example of that in the next video when I add them to the crafting system.
      Sure, they can be used in ECS, you just need to grab the reference somehow and then you can use them for whatever you want. Although keep in mind they are objects used by reference, not value structs.

  • @watercat1248
    @watercat1248 ปีที่แล้ว

    In my opinion scriptable object is just Data based I don't even know why they called scriptable object
    But i discover recently the nested scriptable object and I'm curious what is the difference and how this new type I will be useful

  • @Igor-rd2fb
    @Igor-rd2fb 2 ปีที่แล้ว

    Greetings. How do I reset ScriptableObjects after each play?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  2 ปีที่แล้ว

      You should never modify them so they should never need to be reset.

  • @silverdragon711
    @silverdragon711 7 หลายเดือนก่อน

    @CodeMonkeyUnity - In your current tutorials you mention always making things private. Is that not true in a scriptable object?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  7 หลายเดือนก่อน

      Yup scriptable objects are the exception, the reason being because I only ever use them as read-only data containers, I never modify them.
      However scriptable objects do not enforce that rule, that's just a personal rule that I follow, if it's public you can write to it which might break all sorts of things.
      So if you don't trust yourself to manually follow that rule or if you work as part of a team and aren't sure if everyone is going to follow it, then you can indeed make them private and expose Get() functions like for normal fields.

  • @r1pfake521
    @r1pfake521 4 ปีที่แล้ว

    Can you make a video about the TreeView Editor with basic editing features (like undo/redo and drag&drop to move the nodes up/down). Or can someone post me a link to some other video which shows these features, because I couldn't find any. Im not even sure about the current TreeView situation because it looks like they will make a new TreeView with the new UIElements API, but im not sure if it is already out or not, because I asked in the Unity forum and they sent me github links which are either dead or private and I didn't get any other answer from them yet.

  • @osmanpekaydn4070
    @osmanpekaydn4070 4 ปีที่แล้ว

    I don't understand differance between structs and scriptable objects

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      A Scriptable Object is an asset that stores data and lives in your project files.
      A Struct can store data in memory

  • @shalihrizal9433
    @shalihrizal9433 4 ปีที่แล้ว +2

    Well, kinda shocked to see the .ass extension at the thumbnail xD

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Oh yeah I guess in some cases the time overlay will obscure the text

    • @bilbostabbins1882
      @bilbostabbins1882 4 ปีที่แล้ว

      @@CodeMonkeyUnity mmmmm
      .ass
      ets, Liked and Subscribed!

  • @giangbuitam4868
    @giangbuitam4868 4 ปีที่แล้ว

    can i change the data of scriptable objects in run time ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Yup, but be careful of the issues I mentioned regarding Editor saving vs Standalone saving

    • @giangbuitam4868
      @giangbuitam4868 4 ปีที่แล้ว

      Code Monkey how can i change data of them ? I don’t know how to do that

    • @Alzimovich2
      @Alzimovich2 4 ปีที่แล้ว

      @@giangbuitam4868 Never used SO, but they are simply scripts with public fields... so I assume SOinstanceName.fieldName = newValue; should do the job.

  • @carlabalos3884
    @carlabalos3884 2 ปีที่แล้ว

    Thanks!

  • @thehacknologist1692
    @thehacknologist1692 4 ปีที่แล้ว

    Can you make a game with bolt in unity.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Sure, Bolt is extremely powerful and you can build anything with it

  • @arcday4281
    @arcday4281 4 ปีที่แล้ว

    Hello everyone Tell me how to make it easier and more practical: data Exchange between scripts. For example: Get position(). Create a script containing all the others-inheritance - get-set...? Use interfaces for each necessary function ? Or are there other options ?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      You could implement an interface, IHasPosition then implement GetPosition() => transform.position
      That's what I used in some scripts on Battle Royale Tycoon

    • @arcday4281
      @arcday4281 4 ปีที่แล้ว

      @@CodeMonkeyUnity Thanks a lot. I'm still surprised by your superpower to respond to all subscribers)) It probably takes so much time...

  • @kingofgame2762
    @kingofgame2762 4 ปีที่แล้ว

    Please tutorial for unity particle system 2d and if the video 2 hours I will watch the video

  • @nosamyd9474
    @nosamyd9474 3 ปีที่แล้ว

    im pretty new to unity i mean by this is posted unity isnt even installed yet! gimme some uhhh idk?

  • @topievan190
    @topievan190 4 ปีที่แล้ว

    Indonesia here

  • @sudhanshlone8284
    @sudhanshlone8284 4 ปีที่แล้ว

    Is using scriptable objects more performant?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว +1

      Really depends on the situation. For example if you have tons of duplicated memory in use and you replace that with Scriptable Object references then yes.
      But in general they are not necessarily more performant by default, it all depends on what you're doing and your implementation.

  • @johnpatrickjuni945
    @johnpatrickjuni945 4 ปีที่แล้ว

    Pls help me I'm just a student and know very little (almost nothing) about programming can you help me where to start, I'm just starting so pls help.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Learn the Basics of Unity here th-cam.com/video/E6A4WvsDeLE/w-d-xo.html
      And C# Basics here th-cam.com/video/IFayQioG71A/w-d-xo.html

    • @johnpatrickjuni945
      @johnpatrickjuni945 4 ปีที่แล้ว

      @@CodeMonkeyUnity thanks

  • @thg1nrediar
    @thg1nrediar 2 ปีที่แล้ว

    Thanks

  • @Naufal12948
    @Naufal12948 4 ปีที่แล้ว

    Why untity not in phone

  • @myelinsheathxd
    @myelinsheathxd 4 ปีที่แล้ว

    another level of json file😉.......

  • @zed538
    @zed538 4 ปีที่แล้ว

    HI there folks

  • @semithegamedeveloper6995
    @semithegamedeveloper6995 4 ปีที่แล้ว

    i want to become a proffesional indie developer. do you believe me?

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 ปีที่แล้ว

      Go for it!

    • @semithegamedeveloper6995
      @semithegamedeveloper6995 4 ปีที่แล้ว

      @@CodeMonkeyUnity You are best youtuber in world. there is no youtuber answering the comments.

  • @JoligonOne
    @JoligonOne 4 ปีที่แล้ว

    Please Dotween video

  • @eduardo-cat
    @eduardo-cat 4 ปีที่แล้ว

    1 view :0

  • @andylockhart257
    @andylockhart257 4 ปีที่แล้ว +1

    Debug.love()

  • @Pedro_Marangon
    @Pedro_Marangon 4 ปีที่แล้ว

    First!

  • @daleodorito
    @daleodorito 4 หลายเดือนก่อน

    I have seen a bunch of stuff about scriptable objects and... I don't fucking get it. Like why should I save that as an scriptable object instead of a prefab? You save memory and it's supposed to be easier to use? How? I don't get it.
    Let's say you want to have a bunch of items that just use a "weapon" class, so they have like name, damage and speed. That seems exactly the use case for a scriptable object. But I could just create a Monobehaviour for that and I would save an object with that script and some default data as a prefab. Why it is better to use a scriptable object there? You are just passing by the same amounts of references, you are either searching for a prefab of that script or the scriptable object. I don't see how you are using any duplicate data there.

    • @CodeMonkeyUnity
      @CodeMonkeyUnity  4 หลายเดือนก่อน

      A prefab doesn't define a "type", it defines an "object". So while technically you can do that it's the same thing as how you can hammer a nail with a proper hammer or with your fist. Both will work but you should really use the proper tool for the job.

  • @y01cu_yt
    @y01cu_yt ปีที่แล้ว

    Thanks!