The answer is...

  Рет қаралды 13,785

Jason Weimann (GameDev)

Jason Weimann (GameDev)

Күн бұрын

Пікірлер: 61
@Un4GivNX
@Un4GivNX Жыл бұрын
I've been using Odin for the past few years, mainly for its serialization system. I ran into a wall when I tried to expose custom serialization on components. I heard about SerializeReference a few months ago. I did a few tests, converted ALL my SerializedMonoBehaviour, SerializedScriptableObject and everything in favor of the good old MonoBehaviour, coupled with the power of SerializeReference. It just worked magically, solved all my problems, wow! Note that I still use odin serialization regarding saving a complex object from/to disk but that's it.
@saeedbarari2207
@saeedbarari2207 Жыл бұрын
the serializeReference is way more expensive though. and it's not exactly bugless. You should try to *not* use it unless you have to, or the alternative approach doesn't worth the time
@shibuyajin_music
@shibuyajin_music Жыл бұрын
I LOVE YOU! just browsing your channel randomly solved a lingering problem for me with inventory items (consumables, weapons, vastly different types of items that still should be considered and listed the same: inventory items) my dum ass was literally feeding empty properties like 0 durability to all items just to fulfill the weapon durability system. It felt very goofy
@Kanon_39_
@Kanon_39_ Жыл бұрын
I just started working on a card game and was wondering how to implement all the card effects and abilities. Using scriptable objects to create cards worked just fine but I didn't even consider doing the same for abilities. Thanks a bunch!
@JayZireael
@JayZireael Жыл бұрын
I am absolutely shocked that your example is exactly how I set up that system in my own game. I feel a little proud, to be honest.
@notlaw1567
@notlaw1567 Жыл бұрын
That's cool! I would like to share something I do a little bit different. Instead of making a virtual method on the base class, I create an interface to apply required methods for the class (i.e: ISpell), and then apply the interface abstractly to the base class. That way it serializes without making the class abstract.
@dreamisover9813
@dreamisover9813 Жыл бұрын
Haven't used SerializeReference yet, but I read up on it and it seems pretty useful. Before I'd usually just make each effect as its own Scriptable object class.
@Un4GivNX
@Un4GivNX Жыл бұрын
Another cool thing is that you could declare [SerializeReference] private List _someList; You'll be able to serialize basically any serializable class that implement IMyInterface.
@newarteest
@newarteest 3 ай бұрын
neat, I think this is even better than having an abstract class (what he mentions in the video)
@mauriciopartnoy2789
@mauriciopartnoy2789 Жыл бұрын
Looks very useful! The headers could be left there to let the user know the Effect type of each member of the collection without having to create custom inspectors. Thanks for sharing, Jason!
@Unavailable8923
@Unavailable8923 Жыл бұрын
For new people, it may be useful to show an Apply() method in Spell that does: foreach (var effect in Effects) effect.Apply();
@EnderElohim
@EnderElohim Жыл бұрын
Inheritance, interface, sub classes are good things to know
@cptant7610
@cptant7610 Жыл бұрын
Wow, thank you so much , I was looking for this for my Finite State Machine and couldn´t get it to work previously.
@saqibbro5297
@saqibbro5297 Жыл бұрын
I lob u, that's a great teacher right there!
@keelanbowker-obrien2222
@keelanbowker-obrien2222 Жыл бұрын
Love the tutorial. I'm kind of curious how you might extend On-hit effects (and other conditional logic) to this framework. Any advice?
@erikm9768
@erikm9768 10 ай бұрын
Actual information starts at 6:50, i'm not kidding
@Betruet
@Betruet Жыл бұрын
Great content 👌
@JayadevHaddadi
@JayadevHaddadi Жыл бұрын
Super cool Jason! I just wish the same would work for non-ScriptableObject's... that would have been very helpful and powerful...
@saeedbarari2207
@saeedbarari2207 Жыл бұрын
it does! you can use SerializeReference on absolutely any class type
@JayadevHaddadi
@JayadevHaddadi Жыл бұрын
@@saeedbarari2207 Hmm... sure one can use it but in the normal inspector you will only see the base class or in the case of SeralizeReference one sees only blank... have u tried it?
@hamzafayyaz9303
@hamzafayyaz9303 Жыл бұрын
@@JayadevHaddadi I have not tried it in the inspector but i think you have to mark ur subclass/derived class as Serializable also.
@JayadevHaddadi
@JayadevHaddadi Жыл бұрын
@@hamzafayyaz9303 i have tried... doesnt work:( will only handle base classes. unless one makes a custom drawer/attribute
@milktea0001
@milktea0001 Жыл бұрын
you can use the factory design pattern for your use case. Jason has a video about it.
@homemacai
@homemacai Жыл бұрын
Very useful stuff!
@damnpete
@damnpete Жыл бұрын
That was a pretty good question. Your implementation is also very interesting. Maybe a minor tweak is to have the SpellEffects also be ScriptableObjects, so you can reuse the same instances of effects in other spells and also allows you to drag and drop the effects without having to create the ContextMenu entries to add effects (without those ContextMenus you aren't able to add effects since it would add the base class to the array if you use the + button)
@alexleonardkrea
@alexleonardkrea Жыл бұрын
Very cool, thanks!
@morybest
@morybest Жыл бұрын
Jason ! Its a bit complicated. But thanks a lot for making this .🤩🤩🤩
@bsdrago
@bsdrago Жыл бұрын
Please, elaborate more about this video! =)
@johncarlogamboa7331
@johncarlogamboa7331 Жыл бұрын
I think the reason why you couldn't make it an abstract class (though it obviously should) is because behind the scenes when the ScriptableObject gets instantiated as an asset, all of its serialized fields needs to be instantiated, objects of abstract class are not instantiatable.
@Steve-dd3pt
@Steve-dd3pt Жыл бұрын
I started with same system but while I expand it this become problematic for example some of spells should deal damage after reach target like fireball. This is depending on needs but I changed whole spell system in my game to one single class Spell and evry spell can have a list of components like deal damage, create effect, targeting or triggering other effects. In this set I can create so far all off spell I can image for example teleport player, create 3 fireballs to closest targets, when they reach targets they will heal a player. Thanks for video!
@inkofthedragon
@inkofthedragon Жыл бұрын
Is what you are describing as Composition?
@dwried
@dwried Жыл бұрын
Where might I go to dig up more interesting (not sure what to call it lol), things in brackets. I get the feeling there's more germs or there to dig up. Good to have a treasure map though, to know where to start digging.
@AschKris
@AschKris Жыл бұрын
Those are called Attributes, you can find them on the Unity Manual, on the Scripting API under both UnityEngine and UnityEditor.
@catafest-work
@catafest-work Жыл бұрын
good work, but scriptable object can be tricky , I think is more good to use delegate in C#. I would recommend for the learning part a video about the special errors that appear in Unity 3D as a result of the changes between the editor and the scripts or differences between the packets and the old implemented source code. Let's see these errors with ThirdPersonController and all definitions: error CS1061: 'StarterAssetsInputs' does not contain a definition for 'analogMovement' and no accessible extension method 'analogMovement' accepting a first argument of type 'StarterAssetsInputs' could be found (are you missing a using directive or an assembly reference? How about this issue?
@MrTsilipe
@MrTsilipe Жыл бұрын
Very nice video. All the variables it is in public. Can the "class" return each value and the variables to be privet?
@Octamed
@Octamed Жыл бұрын
So this is basically the same as using a whole GameObject with the spell base class as a monobehaviour and just adding the spell chunks as components? Then saving each spell combo as a prefab or prefab variant. Other than the slight overhead of making everything monobehaviours, what are the benefits?
@Un4GivNX
@Un4GivNX Жыл бұрын
One benefit is that you could create, edit and access your content in scriptableObjects. You will not have to instantiate your whole gameobject structure just to read some values. The overhead is almost non-existent.
@Octamed
@Octamed Жыл бұрын
@@Un4GivNX Prefabs do that though? I can just read them directly, like an SO
@Un4GivNX
@Un4GivNX Жыл бұрын
@@Octamed Probably because you're not using AssetReference and reference public GameObject myGo directly? That mean that this gameobject is implicitly loaded in ram, including his textures, audio, animations, materials, and so on. That is overhead :)
@Octamed
@Octamed Жыл бұрын
@@Un4GivNX Why would SO be any different? At some point the SO needs to reference real FX like particle systems etc.
@spikebor
@spikebor Жыл бұрын
You can think of Prefab and SO are the same, since they live in the project. But MonoBehaviour carries too many bloat variables and methods that if you don't use them, why bother? Regarding performance overhead, the only way to find out is do a stress test, if you're curious.
@christomanosanastasiou5601
@christomanosanastasiou5601 Жыл бұрын
Is it like polymorphism?
@saeedbarari2207
@saeedbarari2207 Жыл бұрын
quick tip. the SpellEffect class could've been an 'abstract' class, with abstract functions. meaning no class will be able to directly instantiate the root SpellEffect itself, and has to choose from one of the children. definitely makes the codebase so much neater, if that's something the team cares about
@Hazzel31337
@Hazzel31337 Жыл бұрын
good one again, thank you :)
@GiftedMamba
@GiftedMamba Жыл бұрын
And when you suddenly rename class all your serialization in Editor will be broken. You can use a workaround with MovedFrom attribute, but it is a pain. And you can forget then about cool things like automatic namespace refactoring in IDE. So does anyone know normal way to deal with renaming and moving to another namespace in case of SerializedReference? Because of this problem I stopped to use this feature. When you suddenly rename something and forgot to add MovedFrom attribute, it is such a pain.
@abhishekjha3750
@abhishekjha3750 Жыл бұрын
First again??...... Supppp!! 😂
@MrMagicznyMAG
@MrMagicznyMAG Жыл бұрын
Shift + F6 changes variable name
@arcday4281
@arcday4281 Жыл бұрын
The topic is more complicated than it seems, you first need to think through the structure and sequence of events in your head, and only then build a script... personally, my spells are divided into types and are inventory items like any other objects, the projectile is assigned a type when called, then the behavior is determined through enum...
@harddev9181
@harddev9181 Жыл бұрын
bro u r just getting older and older i will cry if a legend like u saids quits. :( like u r work. :)
@erikm9768
@erikm9768 10 ай бұрын
Dude learn to get to the point, 6 minutes into a 7 minute video you still have not talked aboutj SerializeReference, the whoel reason we are here. Learn to value your subscribers time, gamedev is time consuming as it is!
@DiujLopez
@DiujLopez Жыл бұрын
Man... You're using AI images now. Bummer.
@scort623
@scort623 Жыл бұрын
Could you speak more slowly buddy, not everyone who accompanies you is fluent in English. Thanks
@GameDevNerd
@GameDevNerd Жыл бұрын
If he speaks English slowly then the video would be unsuitable for English-speaking viewers ... impossible to cater to both. What you should have done was ask him if he will look into subtitling his videos in some way so you can hear what he's saying and read what it means in your native language, so it's a win-win.
@GameDevNerd
@GameDevNerd Жыл бұрын
Hell, Jason, you can use AI to subtitle the videos in English then translate to every other supported language pretty much instantly. KZbin has some helper services built in as well.
@pa_de_queijo
@pa_de_queijo Жыл бұрын
I agree, but you can .75x speed
@Octamed
@Octamed Жыл бұрын
It has subtitles that can auto-translate
@scort623
@scort623 Жыл бұрын
Aaron Carter, I think quite the contrary, even those fluent in English can have difficulty understanding the content of the video. Follow several other programming channels that speak more slowly and even so the content continues to be of extreme quality even for those who are fluent in English.
@GameDevNerd
@GameDevNerd Жыл бұрын
I like some of the new types of videos you're doing here lately, a bit more episodic and more randomness but very much cool. 🙂 By the way: [field: SerializeReference] public PropType PropName { get; set; } = default; // set an appropriate default
Events or UnityEvents?????????
15:43
Jason Weimann (GameDev)
Рет қаралды 105 М.
Do these 7 things for EVERY game!
14:53
Jason Weimann (GameDev)
Рет қаралды 87 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 10 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 141 МЛН
路飞做的坏事被拆穿了 #路飞#海贼王
00:41
路飞与唐舞桐
Рет қаралды 25 МЛН
Be CAREFUL with Scriptable Objects!
8:27
Code Monkey
Рет қаралды 85 М.
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 136 М.
Rethink Everything with Scriptable Object VARIABLES
15:28
Game Events - Power & Simplicity in Unity3D
17:15
Jason Weimann (GameDev)
Рет қаралды 73 М.
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 131 М.
The 6 Design Patterns game devs need?
24:20
Jason Weimann (GameDev)
Рет қаралды 373 М.
11 Things You (Probably) Didn't Know You Could Do In Unity
13:49
Game Dev Guide
Рет қаралды 156 М.
3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!
24:29
Jason Weimann (GameDev)
Рет қаралды 87 М.
Unity Devs, don't forget THESE if your game has animation!
9:41
Jason Weimann (GameDev)
Рет қаралды 11 М.
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 10 МЛН