Obvious Game
Obvious Game
  • 27
  • 67 636
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
zhlédnutí: 1 429

Video

5 Essential Tools Every Game Dev Needs!
zhlédnutí 1,8KPřed 28 dny
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
zhlédnutí 1,9KPřed 7 měsíci
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
zhlédnutí 906Před 8 měsíci
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)
zhlédnutí 3,2KPřed 9 měsíci
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
zhlédnutí 803Před 11 měsíci
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
zhlédnutí 16KPřed rokem
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
zhlédnutí 1,1KPřed rokem
To Pool or Not To Pool, that is the question
Implement Object pooling in your Unity Game
zhlédnutí 5KPřed rokem
Implement Object pooling in your Unity Game
How to make a Roguelite Game with Soap. Part 2: Scriptable Events
zhlédnutí 2,4KPřed rokem
How to make a Roguelite Game with Soap. Part 2: Scriptable Events
How to make a Roguelite Game with Soap. Part 6: Game Foundation
zhlédnutí 1,6KPřed rokem
How to make a Roguelite Game with Soap. Part 6: Game Foundation
Use AI to Create a 3D Model in 56 seconds
zhlédnutí 2KPřed rokem
Use AI to Create a 3D Model in 56 seconds
How to make a Roguelite Game with Soap. Part 5: Abilities
zhlédnutí 1,5KPřed rokem
How to make a Roguelite Game with Soap. Part 5: Abilities
How to make a Roguelite Game with Soap. Part 4: Weapon and Pickups
zhlédnutí 1,4KPřed rokem
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
zhlédnutí 1,9KPřed rokem
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
zhlédnutí 6KPřed rokem
How to make a Roguelite Game with Soap. Part 1: ScriptableVariables and Bindings
Soap: Scriptable Object Architecture Pattern - Features
zhlédnutí 4KPřed rokem
Soap: Scriptable Object Architecture Pattern - Features

Komentáře

  • @anonAcc575
    @anonAcc575 Před 3 dny

    Isnt just reading value from another script easier than having to create soapvariable, hook up events and drag and drop them?

    • @obviousgame
      @obviousgame Před 2 dny

      "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.

  • @spounka
    @spounka Před 5 dny

    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

  • @everythingcouldbesimplify818

    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.

    • @obviousgame
      @obviousgame Před 5 dny

      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!

    • @everythingcouldbesimplify818
      @everythingcouldbesimplify818 Před 5 dny

      @@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

    • @obviousgame
      @obviousgame Před 5 dny

      @@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 !

  • @campiinz
    @campiinz Před 6 dny

    Very useful tips!

  • @EdMechGames
    @EdMechGames Před 7 dny

    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

    • @obviousgame
      @obviousgame Před 7 dny

      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.

    • @EdMechGames
      @EdMechGames Před 7 dny

      @@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

  • @batty251
    @batty251 Před 7 dny

    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.

    • @obviousgame
      @obviousgame Před 7 dny

      Good points ;)

    • @nuin9937
      @nuin9937 Před 7 dny

      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

    • @obviousgame
      @obviousgame Před 7 dny

      @@nuin9937 Both are up to preferences, I prefer also having it written (super explicit), but I understand why some people prefer without

  • @omidnajmi6019
    @omidnajmi6019 Před 7 dny

    really great video thanks😍

  • @juice1884
    @juice1884 Před 7 dny

    Deserialization at runtime is not "zero performant cost", there is of course overhead to it. But yea, deserialization is faster than a GetComponent call.

  • @LoneLuminaryDev
    @LoneLuminaryDev Před 7 dny

    4:18 nice subs added :)

  • @garagebandofficial
    @garagebandofficial Před 7 dny

    thanks for the tips, I sometimes make some of the mistakes mentioned in this video while writing scripts. keep going :)

  • @mikhailhumphries
    @mikhailhumphries Před 8 dny

    What if you instantiate a prefab from assets then you can't assign scripts from hierarchy to the prefab.

    • @obviousgame
      @obviousgame Před 7 dny

      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 ^^.

  • @anonymous49125
    @anonymous49125 Před 8 dny

    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.

  • @anonymous49125
    @anonymous49125 Před 8 dny

    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.

    • @obviousgame
      @obviousgame Před 8 dny

      It was more to highlight that Vector3.Distance does under the hood. Many people don't know

  • @anonymous49125
    @anonymous49125 Před 8 dny

    _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.

    • @obviousgame
      @obviousgame Před 8 dny

      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.

  • @anonymous49125
    @anonymous49125 Před 8 dny

    IsDead is begging to be a guard clause on line 66, if(IsDead) return;//or similar

    • @obviousgame
      @obviousgame Před 8 dny

      Yes , indeed, I am only correcting the points I covered, I did not want to mix different concepts together ;)

    • @anonymous49125
      @anonymous49125 Před 8 dny

      @@obviousgame that's very valid. Great video by the way, hope my comments help with engagement scores.

    • @obviousgame
      @obviousgame Před 8 dny

      @@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 !

  • @anonymous49125
    @anonymous49125 Před 8 dny

    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.

  • @hernandonj
    @hernandonj Před 8 dny

    The selection base and component container selection when using debug are awesome. Thank you!

  • @MalbersAnimations
    @MalbersAnimations Před 15 dny

    Definetely need to try SOAP!!!

  • @cassiusvinicius
    @cassiusvinicius Před 22 dny

    How can i preview the image in the inspector like that?

    • @obviousgame
      @obviousgame Před 22 dny

      you can expand the preview at the bottom of the inspector, when selecting a texture!

    • @cassiusvinicius
      @cassiusvinicius Před 22 dny

      @@obviousgame thanks!!

  • @mattrobb3566
    @mattrobb3566 Před 22 dny

    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.

  • @_MG_01
    @_MG_01 Před 23 dny

    good tips thanks!

  • @mufelo
    @mufelo Před 27 dny

    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.

    • @obviousgame
      @obviousgame Před 27 dny

      I did add it in the description. I forgot during the recording, made the video in a rush!

  • @Jeff-LWS
    @Jeff-LWS Před 28 dny

    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!

  • @lunawolfstudios
    @lunawolfstudios Před 28 dny

    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!

  • @TopShelfCookieJar
    @TopShelfCookieJar Před 29 dny

    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!

  • @KAIMARKCAM
    @KAIMARKCAM Před 29 dny

    Thanks for this

  • @jacobs.7925
    @jacobs.7925 Před 29 dny

    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.

    • @obviousgame
      @obviousgame Před 29 dny

      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 :).

    • @jacobs.7925
      @jacobs.7925 Před 29 dny

      @@obviousgame oh lol didn't know that :) gonna buy it to support you, thanks a ton!!

  • @Smack332
    @Smack332 Před 29 dny

    SR Debugger looks great, but unfortunately it seems to be abandoned by the dev. Not updated in over 2 years.

    • @obviousgame
      @obviousgame Před 29 dny

      Yeah unfortunate , but it still works though !

  • @swoobie
    @swoobie Před 29 dny

    The synergies section at the end was a nice touch

  • @265Den
    @265Den Před 29 dny

    В натуре четко. Спасиббо

  • @SeanBotha
    @SeanBotha Před 29 dny

    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

    • @obviousgame
      @obviousgame Před 29 dny

      hum are you sure? I can update from the package manger in the editor without needing to register

    • @wpdfreedom
      @wpdfreedom Před 29 dny

      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

  • @eliezerrenee
    @eliezerrenee Před měsícem

    App?

    • @obviousgame
      @obviousgame Před měsícem

      its was made using warp fusion. Its not an app. It takes a lot of time !

    • @eliezerrenee
      @eliezerrenee Před měsícem

      @@obviousgame okay, I understand..

  • @alhussienx72u
    @alhussienx72u Před měsícem

    finally a real unity tips i dont know

  • @belindaaskew
    @belindaaskew Před 2 měsíci

    amazing video, thank you!

  • @JayGamerz
    @JayGamerz Před 3 měsíci

    Helpful ❤

  • @PeterMilko
    @PeterMilko Před 3 měsíci

    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?

    • @obviousgame
      @obviousgame Před 3 měsíci

      yeah we can figure something out ! If you can send me an email We can continue the conversation there :)

  • @PeterMilko
    @PeterMilko Před 3 měsíci

    Fantastic

  • @pmak111
    @pmak111 Před 3 měsíci

    Actually 12 Tips not 11 😆

  • @g.rajesh-4534
    @g.rajesh-4534 Před 3 měsíci

    Bro how much it costs to remove unity splash screen for 1 game I am new to unity community ,please answer bro.

    • @obviousgame
      @obviousgame Před 3 měsíci

      Yeah you need Unity pro for that , which cost quite a lot! unity.com/fr/products/unity-pro Just keep the splash screen ^^

    • @g.rajesh-4534
      @g.rajesh-4534 Před 3 měsíci

      @@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

    • @obviousgame
      @obviousgame Před 3 měsíci

      @@g.rajesh-4534 Have you tried Godot ?

    • @g.rajesh-4534
      @g.rajesh-4534 Před 3 měsíci

      @@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

    • @obviousgame
      @obviousgame Před 3 měsíci

      @@g.rajesh-4534 We can have a more productive conversation on the discord ! If you join you can post your questions there ;).

  • @RustyMahkra
    @RustyMahkra Před 4 měsíci

    🤯

  • @RustyMahkra
    @RustyMahkra Před 4 měsíci

    Its no need to be power of 2, just need to be divisible by 4

  • @RustyMahkra
    @RustyMahkra Před 4 měsíci

    Love u!

  • @horeaper
    @horeaper Před 5 měsíci

    It does not reduce memory size, only disk storage size.

    • @obviousgame
      @obviousgame Před 5 měsíci

      Yes , my mistake there. I should update the reel with a correction ;)

  • @jamesmccafferty8869
    @jamesmccafferty8869 Před 5 měsíci

    I didn't know 7/10 of these!! 😅

  • @teaserbd
    @teaserbd Před 5 měsíci

    Perfect for prototyping ! Great video

  • @curiouskid1547
    @curiouskid1547 Před 5 měsíci

    Thanks.

  • @djkale2009
    @djkale2009 Před 6 měsíci

    Cool Man thx

  • @distant1439
    @distant1439 Před 6 měsíci

    I’m very new to game design, like, extremely new. So this may be an obvious question for most but, I have chosen Unreal as my engine to learn on, will this also work on Unreal?

    • @obviousgame
      @obviousgame Před 6 měsíci

      Of course it works in Unreal. The same process, except instead of importing to Unity, you import into Unreal. If you join our discord, you can see a member imported a very cool monster like that in Unreal

  • @doxielain2231
    @doxielain2231 Před 6 měsíci

    sexist clickbait thumbnail

    • @SalmanKhan-dx1ch
      @SalmanKhan-dx1ch Před 6 měsíci

      Eventually, even the thumbnail level quality will be possible as well