- 27
- 72 465
Obvious Game
Canada
Приєднався 8 лис 2022
Making Game Dev easy for everyone.
How To Improve Your Unity Code: Fixing 10 Common Mistakes
Code review that highlights 10 of the most common mistakes in Unity projects.
Usually, it's nice to get inspired by some Object Oriented principles like S.O.L.I.D or design patterns.
For example the fix for the "Too much in One Class" mistake is an application of the Single Responsibility of S.O.L.I.D (the S).
🔔 Subscribe to the channel for more Unity Tutorials! www.youtube.com/@obviousgame/featured?sub_confirmation=1
#unity #assetstore #gamedev.
--------------------------------------------------------------------
Chapters:
0:00 Intro
0:15 Public Variables
0:51 Excessive Null Checks
2:09 Useless Boolean
3:04 Too Much in One Class
4:18 Vector3.Distance
5:02 Not Using Extension Methods
5:02 Instantiate & GetComponent
6:53 Setting Fields From Outside
7:56 Duplicate Code
8:52 Obscure Naming
9:24 Outro
--------------------------------------------------------------------
- Discord : discord.com/invite/CVhCNDbxF5
- Twitter : obvious_game
- Asset Store Page : assetstore.unity.com/packages/tools/utilities/soap-scriptableobject-architecture-pattern-232107?aid=1100lACyq
Usually, it's nice to get inspired by some Object Oriented principles like S.O.L.I.D or design patterns.
For example the fix for the "Too much in One Class" mistake is an application of the Single Responsibility of S.O.L.I.D (the S).
🔔 Subscribe to the channel for more Unity Tutorials! www.youtube.com/@obviousgame/featured?sub_confirmation=1
#unity #assetstore #gamedev.
--------------------------------------------------------------------
Chapters:
0:00 Intro
0:15 Public Variables
0:51 Excessive Null Checks
2:09 Useless Boolean
3:04 Too Much in One Class
4:18 Vector3.Distance
5:02 Not Using Extension Methods
5:02 Instantiate & GetComponent
6:53 Setting Fields From Outside
7:56 Duplicate Code
8:52 Obscure Naming
9:24 Outro
--------------------------------------------------------------------
- Discord : discord.com/invite/CVhCNDbxF5
- Twitter : obvious_game
- Asset Store Page : assetstore.unity.com/packages/tools/utilities/soap-scriptableobject-architecture-pattern-232107?aid=1100lACyq
Переглядів: 1 696
Відео
5 Essential Tools Every Game Dev Needs!
Переглядів 1,9 тис.2 місяці тому
5 of my favorite tools for Unity game development! Assets Affiliate Links: DoTween Pro - assetstore.unity.com/packages/tools/visual-scripting/dotween-pro-32416?aid=1100lACyq Soap (Developed by me) - assetstore.unity.com/packages/tools/utilities/soap-scriptableobject-architecture-pattern-232107?aid=1100lACyq Odin Inspector - assetstore.unity.com/packages/tools/utilities/odin-inspector-and-serial...
Unity Tips: 10 Things You Need To Know #unity #tips #gamedev
Переглядів 2 тис.8 місяців тому
10 tips and tricks for Unity. #unity #unitytips #gamedev. Subscribe to the channel for more tips! www.youtube.com/@obviousgame/featured?sub_confirmation=1 Chapters: 0:00 Intro 0:04 Recorder 0:53 Material Variants 1:44 Crunch Compression 2:16 Save Presets 2:50 Preset Manager 3:54 Open Recent Scene 4:11 Replace Prefabs 4:27 Camera Rendering Warning 4:46 F HotKey 5:03 EditorOnly Tag 5:23 Outro - D...
How to Improve as a Game Developer : 20 Habits
Переглядів 95510 місяців тому
20 habits that I learned and applied during my game dev career. I wish I knew some of those from the beginning ! Hopefully these can help you to improve your skills, get promoted or simply be a better teammate. #software #developer #gamedev Useful Links: - AI Mind map: www.mymap.ai/map/playground?mid=v68smKgCtml04 - Trello: trello.com - Fork git client: git-fork.com/ Subscribe to the channel fo...
Soap: Game Dev Made Easy (Trailer)
Переглядів 3,4 тис.11 місяців тому
Soap: Scriptable object Architecture Pattern is an easy framework to help you make games in Unity in a fast and easy way. Download on Unity Asset Store: assetstore.unity.com/packages/tools/utilities/soap-scriptableobject-architecture-pattern-232107?aid=1100lACyq - Discord : discord.com/invite/CVhCNDbxF5 - Twitter : obvious_game - Asset Store : assetstore.unity.com/packages/tools/uti...
Unity Pricing Update Explained
Переглядів 823Рік тому
In this video, I explain the new pricing update from Unity. Disclaimer : I tried to simplify the information that can be found online. If I made a mistake, please let me know. The content of this video is my own personal opinion. #unity #unitytips #gamedev Useful Links: - Initial Pricing Update: blog.unity.com/news/plan-pricing-and-packaging-updates - Updates to new Pricing: unity.com/pricing-u...
11 Unity Tips 2024
Переглядів 17 тис.Рік тому
11 tips and tricks for Unity game development in 2024. Most of them are not so obvious! Watch until the end for an extra 12th bonus tips! #unity #unitytips #gamedev Useful Links: - Search tool features: docs.unity3d.com/Packages/com.unity.quicksearch@1.1/manual/index.html Subscribe to the channel for more tips! www.youtube.com/@obviousgame/featured?sub_confirmation=1 Chapters: 0:00 Intro To Tip...
To Pool or Not To Pool, that is the question
Переглядів 1,2 тис.Рік тому
To Pool or Not To Pool, that is the question
Implement Object pooling in your Unity Game
Переглядів 5 тис.Рік тому
Implement Object pooling in your Unity Game
How to make a Roguelite Game with Soap. Part 2: Scriptable Events
Переглядів 2,6 тис.Рік тому
How to make a Roguelite Game with Soap. Part 2: Scriptable Events
How to make a Roguelite Game with Soap. Part 6: Game Foundation
Переглядів 1,7 тис.Рік тому
How to make a Roguelite Game with Soap. Part 6: Game Foundation
Use AI to Create a 3D Model in 56 seconds
Переглядів 2,1 тис.Рік тому
Use AI to Create a 3D Model in 56 seconds
How to make a Roguelite Game with Soap. Part 5: Abilities
Переглядів 1,7 тис.Рік тому
How to make a Roguelite Game with Soap. Part 5: Abilities
How to make a Roguelite Game with Soap. Part 4: Weapon and Pickups
Переглядів 1,6 тис.Рік тому
How to make a Roguelite Game with Soap. Part 4: Weapon and Pickups
How to make a Roguelite Game with Soap. Part 3: Scriptable Lists
Переглядів 2,1 тис.Рік тому
How to make a Roguelite Game with Soap. Part 3: Scriptable Lists
How to make a Roguelite Game with Soap. Part 1: ScriptableVariables and Bindings
Переглядів 7 тис.Рік тому
How to make a Roguelite Game with Soap. Part 1: ScriptableVariables and Bindings
Soap: Scriptable Object Architecture Pattern - Features
Переглядів 4,1 тис.Рік тому
Soap: Scriptable Object Architecture Pattern - Features
there is no negative prompt, did they remove that now?
Maybe it has been a few months!
Nice video! I know it has been a while since the video was posted and hopefully you see my comment. I see that you wrote a function in a ScriptableObject, but I have seen it lately in another tutorial and into unity forums that should be avoided as the main purpose of SOs is to hold data/properties. Do you have any knowledge on this? I am actually asking as I am currently struggling a little to create my own ability system due to the complexity I want to apply and I believe it could help if there is no overhead/less performance on SO functions.
Rules are meant to be broken! I have used this pattern in many games, it works well when you have a single class that is using the SO (for example a single player game). Of course, many programmers hate this approach, as they can't comprehend why would you do logic and data in the same file. Well, I mean, that is up to personal preferences. I find it convenient to have a single concept wrapped in a single file, it makes it easy to add /modify these parts. I guess what I am trying to say, is that there are many ways to handle this and I like this way for certain games !
@@obviousgame Thanks for the quick reply man! yeah I see now, it is more about personal preferences and also what you are trying to achieve. Just realized this is a good way of prototyping and if needed, just change the logic and make a skill factory or something alike. Well then it is up to me to educate myself and come up with the solution I like more heheh. Thanks again, keep it up!
4 years spent with unity learnt 1 or 2 things from this video thank you
[SelectionBase] is actually awesome. I recommend just making a script where that's the only thing in it and add it to every object you need it for, instead of adding [SelectionBase] into the top of all your scripts! Genuinely some great tips in this video!
How did u do this water terrain?
Its a plane with a custom shader !
@@obviousgame can you share the shader?
@@Escanor__ maybe , join the discord and ask me there !
@@obviousgame sure :) I have many questions anyway
Cool tip. Is there a way to do it through code on runtime?
Yes, of course, you simply copy the transform properties, destroy the old object and spawn the new prefab, then apply the transform properties to the new.
Is this compatible with online systems like unity or photon networking? Can I make it run?
Not out of the box. My plan is to do a try with NGO in the next update, then expand onto other stacks (photon, fishnet,etc..)
Sneaky way of advertising your own asset, I like it ;) Jokes aside, I just bought soap yesterday, I can't really use it yet since I am a beginner. But I got a job as solo dev for a video game and soap helps me attack the steep learning curve, great asset
Thanks for buying it ! And I was not trying to be sneaky as I really have Soap in all my projects lol ( and I made it because I needed it !). Good luck for the job man , I Hope it can help you learn on solid bases ;) and don't hesitate for questions in Discord!
Excellent!
Isnt just reading value from another script easier than having to create soapvariable, hook up events and drag and drop them?
"Easier" is subjective. It might be easier for a programmer, not for a designer or artist. Also, reading classes from script creates dependency between them. I like to make scripts that can be reused in different context without needing another specific class. Of course, if you are making a single game, then its less important, but I personally had to reuse a lot of things across games and using Scriptable Objects as a bridge was very useful.
few points I'd like to add: - a public method in a script is a good indication of an interface - while utils class is a nice and a common pattern, I usually prefer to extract them utils to separate classes, like the Closest Enemy method, it could go into an enemy manager, grid system or graph or whatever - for the love of god, if you have an if statement and no (else) and nothing beneath it, just use a guard clause it's easier to read - good video and nice tips, well done
I don't know where did you get that information that GetComponent is slower than getting a reference in a private field through a dependency injection, you may be misunderstand them with FindWithTag, FindGameObjectsWithTag or Find which have to search in the hierarchy. GetComponent<T> is as fast as accessing a generic class. having too many variables exposed in the editor is also an overhead for every time you compile.
Hi, thanks for your comment :) ! Well, I am not suggesting dependency injection (especially runtime DI). GetComponent<T> even if its a look up operation could create garbage (in earlier version of Unity) and you could have cache miss. It adds up quickly and you are creating unneeded operations. Concerning the compilation time, I don't think its totally correct (because exposing variable does not affect significantly this), I think you mean the Editor Performance that can be cause of drawing a lot of variables (especially in custom inspectors). However, I would prefer putting the burden of the Editor rather than the Runtime. This is just my opinion though! I do think sometimes its useful and it has its place as well!
@@obviousgame I used to do that too but since Unity 2019 I don't see any performance difference other than the hassle of having to manualy link, also I like to add Required so I just attach the script and it adds all the components automatically, but I just use those mehods in Start or in single execution function
@@everythingcouldbesimplify818 I see, in that case you might love Kyle Bank's scene ref attributes free git hub package. It caches the components on Validate and you can add attributes to specify where its pretty nice !
Very useful tips!
While I am far from an expert dev, I tend to disagree on the last point when it comes to object pooling specifically. If I know the type of game I am making, I want to know if I am pooling or not from the beginning. It changes code where things die, it changes how I handle any projectile spawning mobs I may have. It has some pretty big branching effects that can be a bit messy to go back and change later. Otherwise I agree that you shouldn't optimize prematurely
Interesting, I think it is probably right when you start as a game dev. Personally, I have always find it quite easy to replace with pooling later on. It might due to fact that I know I might need to pool later so I always have clear way of Initializing / Destroying objects even without pooling.
@@obviousgame It probably depends a lot on the game too. I have mainly came up against pooling in RTS style games. If you destroy an object and instantiate a new one you don't have to worry about much. If you are pooling you need to make sure you are resetting stats and flags. And if things ragdoll on death you need to make sure you are setting them back to their non ragdoll state. It is by no means an impossible refactor, but if I am going to have hundreds of the same object, I pretty much know I am going to be pooling. I feel like it is just a wasted step to try it without. But I am sure there are a lot of situations where that doesnt apply
2 things missed in this. 1. Don't use update unless its vital it needs to be done every single frame. If u want to check something continuously just make a Coroutine because once u have checked it u can just stop a coroutine and there are a lot less errors and a lot less resources being utilized for that checking system. Imagine checking continuously then once you find it it will keep on checking degrading the performance. Have it check continuously via the Coroutine once found execute the function have the Coroutine stop then once you need to check again have it start the Coroutine once again. 2. Always make your functions private void unless you need it to be accessed by something. Having just void then the function name is just lazy and doesn't give much help to others trying to use or look at your code.
Good points ;)
In my opinion putting private just adds more useless stuff to read. If it isnt public its private, pretty self explanatory when you're reading it
@@nuin9937 Both are up to preferences, I prefer also having it written (super explicit), but I understand why some people prefer without
really great video thanks😍
Deserialization at runtime is not "zero performant cost", there is of course overhead to it. But yea, deserialization is faster than a GetComponent call.
4:18 nice subs added :)
thanks for the tips, I sometimes make some of the mistakes mentioned in this video while writing scripts. keep going :)
What if you instantiate a prefab from assets then you can't assign scripts from hierarchy to the prefab.
Hum well if you can do a GetComponent, that means the component is on the prefab. Do you mean instantiating it, then adding the component ? Yes that is fine if that is what you want to do ^^.
DRY is a complicated one; The code you used in the example is perfectly fine. I just can't help myself but to say: I DON'T WORRY about repeating code. I think repeating code can be great given the circumstance (example incoming). What you shouldn't do is repeat CONCEPTS. For instance: lets say you are making a web page, and it shows your username at the top corner of the page,.. you can make like a "DisplayUsername()" so that it draws your username and avatar and when clicked allows you to log out and go to your profile and stuff - that's great, and anytime you want to show the users avatar and stuff, just call DisplayUsername() and you're all set. What eventually happens is there is going to be another place in the website, where you need to display the username again... lets say, you are making a comment section and you want to show their username there, so you think "I know DRY, so I'll just use that method I got for this!", so you call DisplayUsername(), but the icon is a little too small for that, and also the name needs to be a little bigger, and also you want to disable the logout and other options when clicked ---- so, as a great programmer that DRYs, you add configuration arguments to DisplayUsername, so now it's DisplayUsername(isTinyIcon, isNameLarger, isLogoutEnabled);... and this method grows and grows and grows.... each time creating a more and more complicated swiss army knife. This works great - one method to do all this stuff - you really pat yourself on the back thinking about how many methods you avoided making and how this one tool is very amazing and much wow.... until.... some changes start messing up other changes... and maybe some options conflict with other options --- and you're getting complaints... or maybe the business logic changes and we need to add stuff... --- all these things now are competing against each other and it makes maintainability almost impossible without going completely bonkers playing whack-a-mole against uncountable bugs and drowning in technical debt. But what did you do wrong --- the username code is all in one place and you didn't repeat yourself a single time.... IN CONTRAST, you could not DRY and just write out what you need specifically in the instances you need them... the username in the comments section is just done DIFFERENTLY with much of the same code, than it does in the top corner, or anywhere else. YES the code might look almost exactly the same, as if you copy and pasted it but just changed a few little things... but that's the strength of it. The reason for DRY is: if you have a requested change for a CONCEPT, you would only need to go to one place in the code to update it... so you don't have multiple places and forget one and then just once in a blue moon, that one specific use case that was missed is run with the old bug in it. DRY is not trying to save lines of code or save amounts of methods in existence it's just for maintainability... the second it's less maintainable to make it more DRY, then that's the second you lost the plot. Dry is one of those 'to the hammer, every problem is a nail' type things... the real quality code understands why and where DRY is important.
I appreciate the attempt at 5:03 to be more performant, but Vector3.Distance reads better. IF there is a real performance consideration (which I doubt), I would definitely abstract that out to a utility class, rather than just assume anyone reading that will know the intent of (x.pos-y.pos).sqrMagnitude ---- because at a glance that doesn't mean anything. Ideally C# would allow for static extension methods eventually, and when they do that's a good candidate for Vector3.QuickDistance(x, y). Until then, either having a helper method in class, or if ubiquitous like in this case, having it in a Vector3Util.QuickDistance() is a good idea, to communicate what the intent is.
It was more to highlight that Vector3.Distance does under the hood. Many people don't know
_ability.Update() and the like are not right. 3:54 You need to choose for ability to be monobehavior or not, if not (and they inherit from object) then maintaining the updates manually like that is correct (create an update method and even passing in the deltaTime is great) - if they are (which was the case in the example where you extend from monobehavior), then you should NOT manually maintain the update for them, and they SHOULD be added as a component on the host game object.
Yes, I was just explaining about splitting the classes and realized after recording that I should have renamed them to OnUpdate for Mono or better remove the update, but then it would not show that the player updates them. The core message is to split and to handle them, but I should have added more explanations.
IsDead is begging to be a guard clause on line 66, if(IsDead) return;//or similar
Yes , indeed, I am only correcting the points I covered, I did not want to mix different concepts together ;)
@@obviousgame that's very valid. Great video by the way, hope my comments help with engagement scores.
@@anonymous49125 What I learned is that instead of rushing, I should explain the code more slowly. Here, I should have taken the time to explain the guard clause (I hate indentation). No need to make a new point, but I should have mentioned it. Thanks for reminding me !
I was going to rag on you for the second one, but you came around to exposing that variable in editor and setting it there - My experience is getcomponent is needlessly slow and shouldn't be used in cases where you can easily set it at compile-time in editor.
The selection base and component container selection when using debug are awesome. Thank you!
Definetely need to try SOAP!!!
How can i preview the image in the inspector like that?
you can expand the preview at the bottom of the inspector, when selecting a texture!
@@obviousgame thanks!!
Thanks. Useful, I already know quite a bit about most of these. But what was so good about your video is that you showed each one in use which is soooo much better than just recommending them. Well done. Good luck with your subscription growth.
good tips thanks!
Would have been good to call out that Soap is an asset you made and perhaps compare it to the alternatives instead of omitting that fact completely. Nothing wrong with promoting your own stuff but it comes off as a bit dodgy here since you don't even mention it.
I did add it in the description. I forgot during the recording, made the video in a rush!
Awesome video! I've used DOTween in almost every project. If you like Odin and SOAP, then I would also recommend a new one called Scriptable Sheets. It makes managing Scriptable Objects a breeze, and without any coding!
Will check it out !
Great video! The synergy section was great. I really appreciate you covering Unity assets. I noticed most if-not all of these assets have been on the store for quite some time. I also noticed you mentioned SOAP for Scriptable Objects. I wanted to recommend a brand new asset (released last week) called Scriptable Sheets. It's available now on the Unity Asset Store, and tailored for Scriptable Objects lovers!
One of the best "tool recommendation" videos! Actually showing their use in a game (both standalone and in the synergies section) makes their benefits much more obvious. Thank you!
Thanks for this
thank you!! Have you tried soap's alternatives? is it really worth it if you know how to design the architecture by yourself? soda seems good as well I'm a huge fan of SA architecture but I always build it from scratch by myself based on Ryan Hipple's 2017 talk.
Well I made Soap lol, and yes I have tried all the alternatives ! I did not like any of them, so I made Soap also from scratch based on that talk :).
@@obviousgame oh lol didn't know that :) gonna buy it to support you, thanks a ton!!
SR Debugger looks great, but unfortunately it seems to be abandoned by the dev. Not updated in over 2 years.
Yeah unfortunate , but it still works though !
The synergies section at the end was a nice touch
В натуре четко. Спасиббо
Odin is nice but the company behind it requires you to sign up and use their website to update instead of just doing it in unity like all other products BEWARE
hum are you sure? I can update from the package manger in the editor without needing to register
Only if you want fast latest update, asset store versions took a while longer to be release. I remember the Unity6 compatible version took way to long to be submitted to the assetstore, I got stuck with the incompatible version for quite sometime. unfortunately their discord didn't help cause I bought mine from humble and I cannot register to their site, so I just have to wait
App?
its was made using warp fusion. Its not an app. It takes a lot of time !
@@obviousgame okay, I understand..
finally a real unity tips i dont know
amazing video, thank you!
Helpful ❤
Cool, I was makign something similar myself. I'm interested in buying it. If I advertise it on my channel can I get a discount?
yeah we can figure something out ! If you can send me an email We can continue the conversation there :)
Fantastic
Actually 12 Tips not 11 😆
Bro how much it costs to remove unity splash screen for 1 game I am new to unity community ,please answer bro.
Yeah you need Unity pro for that , which cost quite a lot! unity.com/fr/products/unity-pro Just keep the splash screen ^^
@@obviousgame thanks for reply bro, Is there any engine which can offer game development without splash screen for my new 2d/simple 3d game, please reply bro
@@g.rajesh-4534 Have you tried Godot ?
@@obviousgame bro I have doubt please answer me , bro I am going to develop 2d and very very simple 3d game, my game size will be very low ,but I have to make it as multiplayer with 4 players, I mean totally 4 players in a simple single map in a room, does godot made games handle this, I mean game is simple 3d with totally 4 players in whole tiny map but I made as many rooms, if 100k people visiting means is there will be 100k / 4 rooms but all rooms contains that same tiny map ,does godot manage that ,(it will not related to godot? or it related to server?) Please answer me
@@g.rajesh-4534 We can have a more productive conversation on the discord ! If you join you can post your questions there ;).
🤯