Unity How to use ScriptableObjects for handling Game State - Tutorial

  Рет қаралды 21,083

CouchFerret makes Games

CouchFerret makes Games

Күн бұрын

Пікірлер: 46
@ourteammate
@ourteammate 5 жыл бұрын
A much needed video for Scriptable objects 👏
@andyessien6685
@andyessien6685 Жыл бұрын
Man you're excellent, i like the way you explained this topic.. thanks alot
@BlueGooGames
@BlueGooGames 5 жыл бұрын
Heeey! Great to see you back again my man :) I just used scriptable objects to create different profiles for customizing characters, I also got help from CodeMonkey to merge sprites together. All three you of you are all awesome :) Hope to see you again in IRL in 2020!
@TheCodesnippet
@TheCodesnippet 4 жыл бұрын
Man, u r a great teacher.....very clear explanation thank you!
@mohammednihad6755
@mohammednihad6755 5 жыл бұрын
Happy that you still alive man! :)
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
Thank you! :)
@SergeyKloninger
@SergeyKloninger 9 ай бұрын
You're a tallented teacher, very nice and clean tutorial about ScriptableObject and how to change Data in it during runtime. I have searched for a while, very thank you, bro😊❤ Do you have a tutorial about to write c# Script with core functions, so you can build procedural Things Like fence or Road with spline component?
@s9k_yt
@s9k_yt 5 жыл бұрын
HE LIVES
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
He always does. He's a survival.
@ashcubed404
@ashcubed404 5 жыл бұрын
Very cool, very useful, 10/10 - is going to use in the future 👍🏽
@PeterMilko
@PeterMilko 5 жыл бұрын
"cool cool cool" nice video man
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
Thanks! :)
@generalistprogrammer3233
@generalistprogrammer3233 5 жыл бұрын
Nice way of handling dynamic game objects
@AstralNostalgia
@AstralNostalgia Жыл бұрын
Nice video, however I think you can use this apporach to save states such as "game pause" , what can the player do? if the Game is Pausied... or the time is ended. thx.
@olivierhoogkamer5335
@olivierhoogkamer5335 5 жыл бұрын
Another solid video my dude! Thanks!
@senjos
@senjos 5 жыл бұрын
Hello CouchFerret. A real good tuorial! You're channel is realy great!! May I ask what code-editor you use?
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
Thanks! :) I'm using VS Code, it's like a lightweight version of Visual Studio.
@roguerotkosky6213
@roguerotkosky6213 5 жыл бұрын
Thanks CouchFerret super helpful stuff. I learned so much from the video, I'm very new to Unity so this tutorial series is great!
@serialchiller9183
@serialchiller9183 5 жыл бұрын
Finally! You're back!
@jaysonjdbeck6574
@jaysonjdbeck6574 3 жыл бұрын
what would this do: { "state.buildString" "R5pc_r5-80_J152_CL801289_2021_02_05_16_28" "state.totalMapsFullyConnectedTo" "0" "state.lastTimeStampInMinutes" "3" "state.wasGameRunning" "0" "state.lastMapFullyConnectedTo" "no_map" } idk i just found it in my docs and it said game code
@mehmedcavas3069
@mehmedcavas3069 5 жыл бұрын
Lol I was today on your channel and wondered “why do I get not notifications from him, did I close them?” And saw that you had no new videos. And now you uploaded a new one 😂
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
:DDD Yeah I had a pretty long Christmas I guess :D
@hawdk1102
@hawdk1102 5 жыл бұрын
Game objects? Cool
@Aeroxima
@Aeroxima 4 жыл бұрын
Jeez, how many cameras do you have? lol (Unless you're moving the camera for every shot, that would be exhausting here)
@LeFede
@LeFede 4 жыл бұрын
I know you for an hour now maybe and I think I already love you. New Sub! hope you help me become a real GameDeveloper. Cheers from Argentina :D
@kailastnam9793
@kailastnam9793 5 жыл бұрын
IT’S BEEN TOO LONG!!!
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
I know I know I know :D
@manolov4074
@manolov4074 4 жыл бұрын
в Edit? Where are you from ? Bulgaria Russia ?
@sykoo
@sykoo 5 жыл бұрын
Even though this comment is a bit late; welcome back my dude!!
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
Thank you bro! :)
@demians_world6826
@demians_world6826 5 жыл бұрын
Thank you, this really helped me!
@klarnorbert
@klarnorbert 3 жыл бұрын
This has nothing to do with FSM.
@caglarkutluyigit3238
@caglarkutluyigit3238 2 жыл бұрын
ssssh no one noticed
@shashan5900
@shashan5900 3 жыл бұрын
epic idea !
@shaikhabdulbasit5717
@shaikhabdulbasit5717 2 жыл бұрын
U wanna know what i wanna do?? I wanna kiss that damned black rubber duck, wait I thought it was something else at first nut now i forgot what i realized it to be? Thanx pal, ur explanation for scriptable objects just hit me the right place.
@placebo_yue
@placebo_yue 4 жыл бұрын
Doesn't seem like you need scriptable objects for this. Also you set the value on your gamelogic script, why even bother making a scriptable object then? isn't the point to retreive different sets of values? for example, say you have a pokemon-like game, and you swap stats and sprites simply by swapping the scriptable object with all those values and images in it, but the core structure coding for every pokemon battle is the same
@igz
@igz 5 жыл бұрын
Cute tiny example, but not really scalable. I’ve inherited a medium size project that’s using this architecture to store literally all state. It’s horrible. Better to just use static variables if you need them to be global.
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
Interesting. Could you elaborate more on what was the issue of scaling and how static variables would be better? I've considered static variables, but I've found the ScriptableObject solution essentially the same but with Inspector window support and serialization.
@igz
@igz 5 жыл бұрын
​@@CouchFerretmakesGames Sure thing. In no particular order: 1. The data is global and persists over time. Reusing it requires you to reset it to some default state. 2. You can't use your normal IDE to find references. You have to do a string search of the entire project for the GUID of the ScriptableObject. 3. A lot of manual work with constantly serializing the same ScriptableObjects across different gameplay systems. You can instead serialize them into one Singleton object, but then what's the point of this architecture? 4. Duplicated ScriptableObjects. e.g. Player has a Health SO. If you have four players in the game. Then you need four Health Scriptable Objects. But of course, players have more than just health... Man, this whole thing is just so exhausting. Original programmer got the idea from here: kzbin.info/www/bejne/qJK0ZJx-naqSgc0
@CouchFerretmakesGames
@CouchFerretmakesGames 5 жыл бұрын
@@igz Thanks mate, I really appreciate your critic. 1. Yeah, that's a double-edged sword. After living through a few of its pitfalls, I got used to it. I plan to address these problems in a future video for sure. I now use it to have shared data between scenes, so in this case, it's kinda an advantage to me that it's global and persist over time. However, it won't persist between play sessions and that's good, except in the Unity Editor which keeps it between play modes until you quit the Editor (this was kinda annoying). I just have a ResetToDefault() function for them to make sure they are set. 2. I've tried to find an elegant solution to reference them from code, but I couldn't and that's a legit bummer. So I ended up setting up the references between Monobehaviours and SOs in the Inspector. To make sure that they are set, I tend to set these references for the script asset itself and not on the GameObject's component, so it acts like a default for the monobehaviour script. But yeah, this one isn't IDE friendly but at least designer/artist friendly. And it does have a bit of boilerplate having those references all around the place. 3.Could you elaborate on this? I'm not following you. 4. Having separate SOs for everything is indeed overwhelming. I think having just a few like PlayerState SO and UserState SO is enough instead of having hundreds of SOs like, health, score, level, xp, money,.... but we'll see. Overall, this is not a silver bullet, and just like any system/pattern/structure it can be implemented and used in a bad way if the developers are not paying enough attention. Thanks again man, I like having these kinds of discussions and debates.
@igz
@igz 5 жыл бұрын
@@CouchFerretmakesGames #3 Is about constantly dragging popular SO's into new scripts that you write. It's slow, and sometimes you forget to do it. Honestly, I can see why this architecture can be compelling. If you don't let it get out of hand I think it could be pretty good. Good luck!
@artjom5617
@artjom5617 4 жыл бұрын
i would really appreciate it if you show more of unity than of yourself
@batnikelam-mavzer443
@batnikelam-mavzer443 2 жыл бұрын
gj
Unity How to structure your code with UnityEvents - Tutorial
18:13
CouchFerret makes Games
Рет қаралды 15 М.
Rethink Everything with Scriptable Object VARIABLES
15:28
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
ScriptableObjects, Explained | Unity Tutorial
19:27
LlamAcademy
Рет қаралды 13 М.
3 Interesting Ways Scriptable Objects can fix YOUR Unity3d project now!
24:29
Jason Weimann (GameDev)
Рет қаралды 87 М.
The Ultimate Introduction to Scriptable Objects in Unity
20:45
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 133 М.
CLEAN Game Architecture with ScriptableObjects | Unity Tutorial
13:12
Sasquatch B Studios
Рет қаралды 22 М.
10 mins GameDev tips - Quaternions
10:12
sociamix
Рет қаралды 115 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН