10 Things You NEED to Be Doing in Unity

  Рет қаралды 127,962

Tarodev

Tarodev

Күн бұрын

A collection of vital tips and techniques I use in Unity every day. Some are Unity specific, while some are just good programming practices. Let me know if I taught you anything!
❤️ Become a Tarobro on Patreon: / tarodev
=========
🔔 SUBSCRIBE: bit.ly/3eqG1Z6
🗨️ DISCORD: / discord
✅ MORE TUTORIALS: / tarodev
0:00 Intro
0:08 Serializing components
1:18 Drawing scene gizmos
1:35 Initialization order
2:31 Stop using public fields
4:30 Mod to loop collections
5:04 PlayClipAtPoint
5:55 Limit extern calls with SetPositionAndRotation
6:53 Operator overloading
8:17 Composition
8:56 Don't use lazy naming conventions

Пікірлер: 580
@finn9233
@finn9233 Жыл бұрын
Every programmer should keep this in mind while coding: "Code is read much more often than it is written"
@TheClanFollows
@TheClanFollows Жыл бұрын
And it is written much more often than it is understood 😂
@dominikzawlocki3117
@dominikzawlocki3117 Жыл бұрын
@@TheClanFollows I like this
@zardify_
@zardify_ 11 ай бұрын
Pls someone tell this to my boss...
@prppnd3811
@prppnd3811 7 ай бұрын
Clean Code by Robert C. Martin?
@rickloyd8208
@rickloyd8208 3 ай бұрын
Once I followed the tips from the book you quote, the speed of writing increased significantly! It's kind of less stress on your brain =)
@thracco
@thracco Жыл бұрын
As a hobbyist dev im actually glad you made a video for the naming conventions. It wasn't until way later that i would read the subject from a book and wouldn't pay much attention to it. Also a not so beginner Tarodev tutorial that I understand! Kinda proud of myself!
@Tarodev
@Tarodev Жыл бұрын
You're turning pro ;)
@Shorkiedokey
@Shorkiedokey Жыл бұрын
I'm a bit confused, because I name functions with PascalCase, should I name functions and public variables the same way? What would you say it's a good way to name them? Thanks.
@Tarodev
@Tarodev Жыл бұрын
@@Shorkiedokey function should always be PascalCase 😊
@Tarodev
@Tarodev Жыл бұрын
​@@nikolicd91 I use standard C# conventions. The way unity does it is inferior and has a bunch of convention collisions. Unity should have enforced proper C# conventions from the beginning, but didn't. In addition, Unity uses a wide range of conventions, even in their samples and live events, so you really shouldn't use them as a benchmark for coding conventions.
@RealisiticEdgeMod
@RealisiticEdgeMod Жыл бұрын
I use syntax highlighting instead of these ugly underscores. Just make local vars a different color.
@bike_n_fish
@bike_n_fish Жыл бұрын
I've also a tip for beginner : don't over focus on optimisations, instead make your game. If your game is not optimised, you can do it later. But if your game is not working because you spent too much time implementing good practices and well designed patterns - over commenting your code, you gonna loose precious time and energy. When you are experienced and you know what are the pros and the cons of using a specific method you will automaticly try to use the best of it. Bu when you're a beginner, just make the game.
@hiakofficial8180
@hiakofficial8180 10 ай бұрын
Man you've saved me, I realized i was doing the same thing, i wanna go with the best practice so my didn't have to write the code again
@benjamindameworth5351
@benjamindameworth5351 7 ай бұрын
The only optimization you should do along the way is optimizing the way your code is organized. If you don't organize your code it becomes unreadable for future you
@heyreefes
@heyreefes 7 ай бұрын
My ass looking thru five hundred methods to make the character move so I can have the most optimised and best one
@sewminadilshan7223
@sewminadilshan7223 Жыл бұрын
Your videos have the highest knowledge density. Never fails to amaze me in these short videos.
@Unity3dCollege
@Unity3dCollege Жыл бұрын
Great video! all perfect advice, and reminded me about the serialized properties :)
@stephenkirby6788
@stephenkirby6788 Жыл бұрын
My man rolled out of bed, threw on a shirt with a hole in it and started spitting C#/Unity knowledge. Love it. Great video!
@badscotsman
@badscotsman Жыл бұрын
Great video! Love love love that you covered the naming conventions again and didn't back down! Soooo important for the exact reasons you mentioned. ❤️
@pianoatthirty
@pianoatthirty Жыл бұрын
Dude you are SO INSPIRING! Happy to see you back! You should totally do a 'let's build a small game from start to finish' type course where you implement these good practices! Would instantly buy it.
@Tarodev
@Tarodev Жыл бұрын
Funny you say that... 😉
@DePistolero
@DePistolero Жыл бұрын
Thank you, every second from your every video is pure gold diggin... thank you!!! And thank you for the naming convention, I've had my fair share of confusion, bugs, and misreads due to wrong use of naming convention... Thanks for serializing a property, the mod wraparound thing and operator overloading... so useful, and more importantly so nicely explained... thanks.
@trollgasm
@trollgasm 10 ай бұрын
Thank you for this one. I'm trying my best to get industry standard coding, and stuff this goes above and beyond. You are so far out of the hundreds of youtubers in this category that is unequivocally straight to the point and the most professional. Looking forward to diving into more of your videos.
@PitiITNet
@PitiITNet Жыл бұрын
So nice to see you getting back to releasing videos And on the last point - I think there is a special place in hell for people that say "I code for 35 years and do not use naming conventions" 🤣
@Tarodev
@Tarodev Жыл бұрын
No farm sim, just felt compelled to draw a cute cow for the video, which ended up taking longer than the video itself... I always seem to do that :D Thanks mate!
@anlozge1788
@anlozge1788 Жыл бұрын
@@Tarodev cute indeed.
@Tarodev
@Tarodev Жыл бұрын
@@anlozge1788 Me or the cow? ;)
@PitiITNet
@PitiITNet Жыл бұрын
@@Tarodev BOTH!, So you have drawn it all yourself?! :o That's impressive!
@Tarodev
@Tarodev Жыл бұрын
@@PitiITNet Nope, background was from Adobe Stock + Gaussian. I did draw the cow, with heavy reference art though.
@funlightfactory6031
@funlightfactory6031 Жыл бұрын
OMG! Using the modulus for iteration to avoid overflow is mindblowing. It was so obvious I don't know why I didn't think of it.
@Tarodev
@Tarodev Жыл бұрын
But now we have the problem of overflowing the int :P Only use it if you know it won't (99% of cases it won't).
@shenlong3879
@shenlong3879 Жыл бұрын
One minor issue with the modulo approach to index cycling is the index variable isn't really an index anymore, more like a counter, and related to that you could potentially run into overflow issues with really big numbers (not that it's really all that likely).
@YassineZaroui
@YassineZaroui Жыл бұрын
Isn't the Modulo also a bit slower?
@gregoryfenn1462
@gregoryfenn1462 Жыл бұрын
Absolutely, to give a simplified example of the problem: suppose we have x a uint8_t (unsigned 8 bit int). Then define "i = (x++ % 5)". Starting from x=0 we have i = 0,1,2,3,4,0,1,2, ... but when x is 255 we have i = 0. Then when x increments it goes from 255 to 0. But that means i is 0 again, so the pattern breaks whenever x overflows. Of course in most games we use uint32_t or sint32_t, so this won't happen for a long time. But if the counter goes up several times a frame, it will still overflow after a few minutes or hours which can create a hard to detect bug later down the line. So for me I would always explicitly wrap an integer back to 0 manually rather than rely on modulo operators.
@houtamelocoding
@houtamelocoding Жыл бұрын
@@YassineZaroui Maybe? Branches are also slow so the proper way of knowing this would be benchmarking.
@saniel2748
@saniel2748 Жыл бұрын
@@houtamelocoding Modulus can't be predicted, it's just a very slow operations. Possibly one of the slowest math operations you can have And Mono is also not smart enough to replace '% 2' with '& 1' That said, hundred of modules per frame, most certainly, won't change your FPS in any meaningful way
@thomaskluck4164
@thomaskluck4164 Жыл бұрын
Thanks a lot for those hints. I am a fan of not making it harder than it is. Plus: Programming is the art of making yourself not lose track of the things you are doing. The very first thing I came up with was to separate variable scopes through naming conventions. This makes life a lot easier.
@jamjardavies
@jamjardavies Жыл бұрын
A quick note with the mod to loop collections section. Using mod like that does have 1 bug with it, and that's the clipIndex could wrap once it hits Int.MaxValue, causing it to not loop correctly, and also since the int is signed, it'll eventually crash once it hits the negative values. Instead I would write it as _clipIndex = (_clipIndex + 1) % _clips.Length, then index directly using _clipIndex.
@TheKr0ckeR
@TheKr0ckeR Жыл бұрын
That was question in my head actually. Since the game is very long for example, IDX value will get so much higher values. So in first example, we reset the value to 0 which even if its a long way, still proper way. I was trying to find a better way to reset idx.. But your example seems legit.
@generichuman_
@generichuman_ Жыл бұрын
@@TheKr0ckeR If it's a 32 bit unsigned int, and it's incremented 60 times a second, it'll take about 2.26 years to overflow. That's a long time to run a game.
@sn0man
@sn0man Жыл бұрын
Great video, all helpful tips for beginners and old timers alike. Thanks again and keep doing your thing Tarodev!
@Tarodev
@Tarodev Жыл бұрын
You know what? I will
@iwoMalki
@iwoMalki Жыл бұрын
Great stuff! Thta tip with position and rotation really f'ed me up! Been using unity for years and never knew that function existed!
@ravd123
@ravd123 Жыл бұрын
Another great no nonsense vid :) Took away so many tips from this. Thx
@bluestek
@bluestek Жыл бұрын
Man you are my favorate youtube unity knowledge master! I had no idea they added serialization of get set properties! Keep up the good work!
@Tarodev
@Tarodev Жыл бұрын
Only on properties with a backing field, just be aware 😄
@b4ux1t3-tech
@b4ux1t3-tech Жыл бұрын
I kept typing out comments to add to what you were saying, only for you to go on and say exactly what I was going to say! I'm a software developer by trade, and work in C# on a daily basis, building an enterprise product. Whenever I sit down to learn something about Unity, I end up spending a bunch of time griping about how I don't get the latest c# features, and critiquing (in my head) the actual C# code that's used in many of the tutorials out there (including first party ones!). It's really refreshing to see someone using C# to its fullest, great video!
@Dorbellprod
@Dorbellprod Жыл бұрын
Dude I had no idea that Unity serializes properties, thanks
@Neonalig
@Neonalig Жыл бұрын
I probably knew the majority of these already, but using the [field:SerializeField] attribute to specify that the backing field should be serialised on a property is actually ingenious shorthand. Thank you so much!
@jmarsh411
@jmarsh411 Жыл бұрын
Same!
@eusouoervilha
@eusouoervilha Жыл бұрын
Loved the part on naming conventions. In addition is good to remember always to give useful names for the variables, that also makes all the difference.
@ShinichiKudoQatnip
@ShinichiKudoQatnip Жыл бұрын
I feel so good now that I know I have been doing these for quite some time now, and better to know the things I totally missed, thanks for the heads up 😘😘
@freelancepakistangames7245
@freelancepakistangames7245 Жыл бұрын
I've been using unity for quite a long time and did not know most of the tips in this video. Thank you sir🥰
@Tarodev
@Tarodev Жыл бұрын
Welcome :)
@TaAnderson-Google
@TaAnderson-Google Жыл бұрын
The. Return. of. the. King! Good to see you, Sir. Thank you for the tips, the helpful details, and the easy to understand ways to impliment them. As always, I'm happy to see your video, and I'm looking forward to both your upcoming ones, and your larger projects. Good luck and good health.
@Tarodev
@Tarodev Жыл бұрын
Long time no see!
@ezrahuffman
@ezrahuffman Жыл бұрын
I've been using unity for a while and still learned something, so thanks!
@tobihendrix1324
@tobihendrix1324 Жыл бұрын
Quick note: The "public Type Variable => ReturnValue;" Syntax creates a readonly property, so its not the same as having "public Type Variable {get;private set;}". The difference is, that the readonly property cannot be changed even by the instance itself, it has no setter.
@Tarodev
@Tarodev Жыл бұрын
You're completely right, thanks for the correction!
@bread8176
@bread8176 Жыл бұрын
The value can still be changed by directly modifying the field it accesses, so in *practice* it is the same. (unless you mark the backing field as readonly as well)
@Erkle64
@Erkle64 Жыл бұрын
@@bread8176 Same in what you can do. Different in how you can do it.
@goehlergamedev
@goehlergamedev Жыл бұрын
Coding conventions are so important. Even as a solo dev. This last one is a great tip! Always remember: readability is king. It's SO important for the person who will read your code next. And you SHOULD care about that person - cause 9 out of 10 times, that person is you! 😁
@KonaiNobi
@KonaiNobi Жыл бұрын
100% agree on the Naming Convention point. I personally use the following; public Type variableName (Camel Case) private Type _variableName (Underscore Camel Case) public/private void MethodName(Type value) { var variableName (Camel Case) } This allows instant identification of public variables, private variables, and methods, not just for scope but functionality as well. All function-scoped variables are camelCase as they are easily identifiable as local within the scope of their parent method. While the author, whom I have deep respect for, recommends using PascalCase for public variables & properties, I however, find using PascalCase only for MethodNames makes it impossible to confuse methods with similarly named properties. Just my 2¢. 😁
@ishan9050
@ishan9050 Жыл бұрын
The mod to loop collection was sick Awesome 👍
@1Tasteless
@1Tasteless Жыл бұрын
Agreed. Going to save me so much time in the future.
@pythonxz
@pythonxz Жыл бұрын
That one made me realize that I need to use modulo more. It's an elegant syntax.
@Meow_YT
@Meow_YT Жыл бұрын
Not really. That variable is now unbounded and will wrap around eventually, with possible issues if the compiler has checks on integer overflows not known about?
@ishan9050
@ishan9050 Жыл бұрын
@@Meow_YT interesting point. Definately will have a look. Thanks for the mention
@AetherXIV
@AetherXIV Жыл бұрын
you always teach me a lot and make me a better programmer. thank you Taro
@pasta8026
@pasta8026 3 ай бұрын
You are my favorite gamedev tutorial KZfaqr! All your videos are very helpful for me!
@Tarodev
@Tarodev 3 ай бұрын
And you're my fave commenter of today!
@phee3D
@phee3D Жыл бұрын
great tips, I didn't know many of these even though I've been working with unity for 2-3 years. For naming conventions, I use "m_varName" for private variables, uppercase initials for public variables, underscore for parameters and lowercase for locally scoped vars. It greatly improved the readability of my code for my own sake.
@soverain
@soverain Жыл бұрын
Finally, a new video! And a good one for sure. As a senior dev, you reminded me of the operator overloading and the neat tricks you can do with them. You could do a video on extension methods (like advanced level). I saw some seriously good sh*t with them. Duck typing in C# is a very cool feature.
@Tarodev
@Tarodev Жыл бұрын
I actually have a video on extension methods... Ancient though. Don't remember how advanced I made it
@soverain
@soverain Жыл бұрын
@@Tarodev Yeah, I remember, but that was not so advanced, still very useful.
@sadbuttrue666
@sadbuttrue666 Жыл бұрын
Love it. Thank you very much man. (twenty years of dev and 3 years in Unity here)
@Tarodev
@Tarodev Жыл бұрын
You're very welcome Servaus 🙏
@muammar88
@muammar88 Жыл бұрын
Dude, I can't believe I didn't know most of these! Thanks for sharing!
@shuffle8
@shuffle8 Жыл бұрын
Thank you so much for sharing. It's really informative and helpful 🙂
@JoshOClock
@JoshOClock Жыл бұрын
I like having the convention that every 'prefab' I reference for instantiation is ALWAYS a gameObject then I never worry about having to change it's type and losing all my references. But that's just a personal choice. Great video!
@user-rl2ox1bu4c
@user-rl2ox1bu4c Жыл бұрын
Agree with this one. Good video though.
@firstvf
@firstvf 3 ай бұрын
Thank you so much! your videos are always a treasure trove of incredibly useful information🙂 And serialized get-set property - its awesome!😎
@Tarodev
@Tarodev 3 ай бұрын
That one's my bread and butter
@mailmaxxxx
@mailmaxxxx Жыл бұрын
Love your work. One thing I find hard teaching students is the naming conventions - partly because Unity seems to just randomly capitalise stuff, so my rule is to stick to my naming convention (essentially the C# Microsoft recommendations) and just accept that Unity is different!
@Tarodev
@Tarodev Жыл бұрын
This is my way too Maxy boy...
@BLANKdev
@BLANKdev Жыл бұрын
I was wondering where that naming convention video went, glad to have it back because I coudn't agree more and have been using it myself ever since!
@Tarodev
@Tarodev Жыл бұрын
Fills me with joy to know I converted you
@BLANKdev
@BLANKdev Жыл бұрын
@@Tarodev it really is that much better sorry everyone 😬
@castlecodersltd
@castlecodersltd Жыл бұрын
Great video with some useful tips. Thanks ☺
@MarceloSantos-rk5ee
@MarceloSantos-rk5ee Жыл бұрын
Great tips, thank you!
@seaweeddol8171
@seaweeddol8171 2 ай бұрын
I really appreciated the section about naming conventions! I've been following a lot of tutorials that use the same conventions you mentioned, but I didn't understand why people always used _ in some variables, or capitalized others. I'm definitely going to follow this more now.
@Tarodev
@Tarodev 2 ай бұрын
You'll be happy you did :)
@ZacMarvinGameDev
@ZacMarvinGameDev Жыл бұрын
This channel is always pure GOLD!
@cfingergames
@cfingergames Жыл бұрын
These are always super useful, thank you! keep making them plz. Cheers.
@ErtBaran
@ErtBaran Жыл бұрын
<a href="#" class="seekto" data-time="537">08:57</a> I was confused about this. Now i'm done! Thanks so much for this and the others.
@TheShelfman
@TheShelfman Жыл бұрын
That last tip felt like a direct roast to me😂 and it hurts even more to acknowledge that you're completely right. There's a some great tips in here! Thanks😁
@dizmo..
@dizmo.. Жыл бұрын
I rarely write any comments, but you are just too good. I wanted to thank you for all of your videos, which helped me a lot in game-development. Keep quality of your work on high level, man, thats why we enjoy it! I recommend this channel for every developer i know. Cheers from UA game-dev Community!
@Tarodev
@Tarodev Жыл бұрын
Damn. Thanks dizmo 🙏
@omle8492
@omle8492 Жыл бұрын
There was so many “ohhhh this is so cool” moments
@Tarodev
@Tarodev Жыл бұрын
Mission accomplished
@BenVanTreese
@BenVanTreese Жыл бұрын
Along the lines of naming conventions, one thing I think can be really useful is writing out booleans as lines above the check, for example: var jumpWasPressed = Input.KeyDown("Space") if(jumpWasPressed) { //do jump stuff} The code itself is a comment, and it prevents comments/code from getting out of sync. This is of course a broader topic about variable names in general, but that's one I do that I think would benefit a lot of code since it explains the "why" of the boolean/etc in many cases. Also, if the variable is within a function scope and you're not returning it or etc, it's not allocating (on heap) or etc, so there is no real performance difference.
@WatchingTokyo
@WatchingTokyo Жыл бұрын
This is great advice. This kind of technique allows to clarify what it is we meant to be testing.
@papafhill9126
@papafhill9126 11 ай бұрын
The naming convention thing is pretty smart. I do underscore for local and lowercase for all others, but I'll start testing uppercase for public going forward. Thanks for the tips!
@marcmustermann1676
@marcmustermann1676 Жыл бұрын
Great content as usual. Extra points for the sporty look today.
@Tarodev
@Tarodev Жыл бұрын
Ready for action at all times
@flaschenzuglp9994
@flaschenzuglp9994 Жыл бұрын
The property serialize field thing was new to me thx!
@avg_ape
@avg_ape Жыл бұрын
Thanks for the tips - esp for the naming convention tip.
@Fresch1990
@Fresch1990 Жыл бұрын
Wow... <a href="#" class="seekto" data-time="224">3:44</a> Serialized 'Properties' is huge... I didn't notice that change and I really appreciate you mentioning it. It always bothered me to write a full propery to conform to Unity and C# coding conventions..! Thank You!
@syedmeesumalizaidi2152
@syedmeesumalizaidi2152 Жыл бұрын
Nice to see you back buddy... Great...Mind-blowing
@Tarodev
@Tarodev Жыл бұрын
Thank you Syed 🙏
@quintongordon6024
@quintongordon6024 Жыл бұрын
That serialize property tip. Been waiting for that for a while.
@kevinscaglioni8020
@kevinscaglioni8020 Жыл бұрын
As always, awesome video man. Cheers
@quentinyahia352
@quentinyahia352 Жыл бұрын
Thanks for the video, always a good thing to see we can still learn something. For the code convention, I just notice I don't use the underscore private field just because jet brain color the local as white and the private / public as green (dependends on theme ofc)
@mmokzlrsn
@mmokzlrsn Жыл бұрын
This video is pretty good. I learn a lot thanks to you
@iHeartGameDev
@iHeartGameDev Жыл бұрын
so much KNOWLEDGE! Awesome video, Taro -- I specifically liked the phrasing at the end with coding conventions: "would have gotten along a little bit better" 😆
@Tarodev
@Tarodev Жыл бұрын
Makes it a bit tricker for them to bite back at me 😁 Glad you enjoyed it, Nicky!
@omaralashtar7587
@omaralashtar7587 Жыл бұрын
Good work man . We waiting alot of time ,just dont forget us and upload this great video 😄😄
@msj6894
@msj6894 Жыл бұрын
Your video is always great! Thank you so much :)
@ziccodx
@ziccodx Жыл бұрын
Yes, please follow naming conventions ^^, it's immensely helpful and expediates the process of reading code.
@mehmedcavas3069
@mehmedcavas3069 Жыл бұрын
yesss knew all of them :D great video again :)
@greyfireocelot6140
@greyfireocelot6140 Жыл бұрын
Naming Conventions have always helped me quickly solve coding issues that crop up during projects, I didn't realize so many people didn't use them until I started entering GameJams.
@migcreatesgames2622
@migcreatesgames2622 Жыл бұрын
Excellent Tips! I didn't think about DrawGizmos for spawn points. I been doing the inspector gizmos and complain about the size, but now for sure I will start with drawgizmos instead
@marcusaasjensen
@marcusaasjensen Жыл бұрын
Overriding the + operator is pure genius!
@chris.davidoff
@chris.davidoff Жыл бұрын
I clicked because the thumbnail is so good. I stayed because this is very useful lol
@trashcaster
@trashcaster Жыл бұрын
It's funny because the naming conventions, I've always flipped local and private from what you do, but there is another benefit to doing it your way. If you are in your IDE and you type "_" then your private variables will populate the IntelliSense popup, and not your public, which can be handy for setting variables that no other scripts will have access to, since it will still look pretty on the outside, but remain easy to read and write on the inside. I also did not know about overloading the operators, that is indeed a VERY cool trick. It's a tier above extension methods, which are already S tier. Thank you for making this video, I always look forward to them!
@b5fan504
@b5fan504 2 ай бұрын
+1 for the naming conventions. Thank you.
@BS990507
@BS990507 11 ай бұрын
currently kind of binging your tutorials especially because you are sticking to the MS c# naming convention. Other tutorials or code snippets often dont use them and it can get hard to follow because of this. Thanks for advocating this!
@halivudestevez2
@halivudestevez2 Жыл бұрын
nice tips and trixx, again!
@pythonxz
@pythonxz Жыл бұрын
I'm glad you said that people really need to use inheritance when it fits the situation. Always use the tool that seems the most appropriate. As for naming variables (or really anything in code), do not abbreviate unless it is very obvious what it stands for. I've also seen far too many people leaning on comments to explain a function, when naming the function something more descriptive would do just as well.
@Tarodev
@Tarodev Жыл бұрын
People can get carried away, you know?
@Nullzero98
@Nullzero98 Жыл бұрын
As for naming conventions, I agree that they are quite important! Good on you for pushing them! But I don't find it all that useful, in Unity, to know whether something is public, private, or local via a naming convention. Partly because Visual Studio automatically color codes the different scopes. But mostly because the scope for most component based scripts is so small anyway. Occasionally you get a big 5k line PlayerScript or something... but most other scripts are what... 30-100 lines? So why bother with scope naming. What DO I find useful for naming conventions then? GameObjects, Prefabs, Component refs, types and spaces. GameObjects => "go" prefix. goBullet. goPlayer. goEnemy. No more confusion about what an object is or isn't. Prefabs(onDisk) => "prefab" or "pf" prefix. No more guessing if a GameObject reference is actually a GameObject or a disk reference. Components => "cp" prefix. cpBullet. cpPlayer. cpEnemy. cpAnimator. etc. Just by the variable name, I know which component it is, and which functions I can call on it. Transforms => "xf" prefix. xfBullet. xfPlayer, etc. Types, ie Vector3 vs Vector2 => I put a v3 or v2 in front, respectively. v2PlayerPos for 2D game. v3Direction, etc. And yes, for floats, ints, strings, as well. Spaces, ie WorldSpace vs ViewPort vs ScreenSpace etc. v3PlayerPosWS is a world space position. v2BulletDirXZ is a direction but in XZ axis only (ie, top-down shooter). v2MousePosSS for mouse cursor position in screen space. This will save your sanity. Keep the tips coming! Love it!
@Tarodev
@Tarodev Жыл бұрын
Good write up. I like the idea of prefixing their types. I do it for some things, but not necessarily a prefix, for example: _scriptableUnit _projectilePrefab
@Nullzero98
@Nullzero98 Жыл бұрын
@@Tarodev this is the way, my friend!
@Etherealscorpions
@Etherealscorpions Жыл бұрын
I definitely see where you're coming from with naming by type, but if you're asking for help on forums, or helping people on forums or similar, then the scope naming conventions - or at least, being able to quickly explain your variables' scope to a third party - makes it much easier on everyone involved.
@badscotsman
@badscotsman Жыл бұрын
What you're referring to is called Hungarian notation.
@johnhershberg5915
@johnhershberg5915 Жыл бұрын
A lot of people disagree, but I stopped using naming conventions altogether. I use PascalCase for everything. What I noticed was that it was wasting brain resources thinking stuff like "This serialized field has the health set from the editor, and it's at 100 by default, but on this enemy it's 120, and I'm taking damage which comes from the function parameter which right now is 70, and multiplying it by this locally scoped variable..." etc etc. Instead when I'm parsing logic, all I should care about is the logic. Pretty much never do I care about where it comes from. So what I want to instead be thinking is "Health is 120, and I'm taking 70 damage, and multiplying that by 2". Historically the reason for underscores is so if you need your IDE to show you the top-level stuff (serialized fields in our case) you could just type _ and it'll bring up IntelliSense for those. But in my personal opinion that's a distraction these days. If you're back to reading code after a long time it's probably because something is wrong. You should be focusing on the logic of what's happening in the function rather than where things are coming from. Just my humble 2 cents. It sounds weird, but try it and see for yourself.
@er.unsaid7766
@er.unsaid7766 Жыл бұрын
I'm with you regarding naming conventions.
@Tarodev
@Tarodev Жыл бұрын
And I'm with you
@Bolt3006768
@Bolt3006768 Жыл бұрын
The naming conventions I use were taught to me in my CS courses. Cap class publics, mCap for private class variables, then lower for local variables. I sometimes use a fourth convention specifically for counters which use usually an _ or C_
@Tarodev
@Tarodev Жыл бұрын
As long as there is something in place to save you that extra parsing step, you're doing it right.
@MuhammadHosny0
@MuhammadHosny0 Жыл бұрын
use C99 naming conventions.
@zeiksz
@zeiksz Жыл бұрын
Lot of good stuff here. Thank you!
@zeiksz
@zeiksz Жыл бұрын
I tried this property -> field thing, because that was new to me, but worked only if it was basic like public int Teszt { get; set; }, but once I did something like [field:SerializeField] public int Teszt { get => teszt; set => teszt = value; } int teszt; it no longer showed in the inspector. The goal was to call event in the setter, etc. Any idea, what I did wrong? Or is this a bug/feature?
@samserious5483
@samserious5483 Жыл бұрын
Thanx, very useful!!!
@FyresGames
@FyresGames Жыл бұрын
Naming convention is indeed a good idea. I do try to go a step further by adding some details in the var name itself. so_something for scriptable, go_something for gameobject, etc.
@Tarodev
@Tarodev Жыл бұрын
This is very interesting. I can certainly see this being beneficial
@pythonxz
@pythonxz Жыл бұрын
I add prefixes for my filenames, but that's a good idea too.
@PPSzB
@PPSzB Жыл бұрын
It's called a hungarian notation and many people advise against using it, especially when using modern IDE. One of the downsides is you have to remember to change variable name when you change its type (like in the GameObject and Carrot example)
@calccalccalc
@calccalccalc Жыл бұрын
Your hot tips are always welcome mister tarodev
@kennyRamone
@kennyRamone Жыл бұрын
Well I certainly didn't know we can serialized properties now. Thanks a lot! :D
@MrZtapp
@MrZtapp Жыл бұрын
Great tips
@harshitjoshi3082
@harshitjoshi3082 Жыл бұрын
Great video man 👍
@niclasm4123
@niclasm4123 Жыл бұрын
Excellent tips at a perfect advanced level 😅
@gricchastain6506
@gricchastain6506 Жыл бұрын
Awesome. Thanks
@davidpoussif6944
@davidpoussif6944 Жыл бұрын
Great videos! Would be great to see some videos from you explaining UniRX, Zenject or MVC
@L0upyb0y
@L0upyb0y Жыл бұрын
Something which I don't see listed in the summary is enabling advanced play options in the editor settings. This allows one to choose whether to reload stuff or not on play, which most of the time isn't needed if you're just working on level-design for instance. It'll most likely save most devs precious seconds when entering playmode. Remember to disable it when working on advanced features though!
@Tarodev
@Tarodev Жыл бұрын
I actually have an entire video dedicated to this 😘
@NihongoWakannai
@NihongoWakannai Жыл бұрын
<a href="#" class="seekto" data-time="620">10:20</a> When it comes to naming conventions, people don't really mention a convention for naming function parameters. In my experience, I have personally found it more convenient to tell the difference between an injected value vs a value held or created by this object than anything else. People just lump local variables and function parameters together, but to me I just feel like a variable potentially injected from another class should be distinguished from a local variable, especially when using ref/out. I feel like C# standard naming conventions aren't really made for game development, because it puts more emphasis on identifying public vs private variables when I just don't use public variables for game development. The 3 categories for me are class values, function values and injected values.
@magnusm4
@magnusm4 5 ай бұрын
Composition sounds a lot like the structure in ECS. Where an entity is given components. Rather than inheriting from another entity. I built a similar composition system for my hierarchical state machine. Where I have one state that only holds states. So that I can add a state for camera actions, a state that handles controls etc. Separating actions and features which also hold their own stats to do their own thing. While the core values "transform, camera, rigidbody" called context. Are all on the player for all states to access.
@disrate
@disrate Жыл бұрын
Thank you for this useful video :)
@MAXmillium
@MAXmillium 8 ай бұрын
I just subscribed to you and you pull out the naming convention card right away. I never use naming conventions and do just fine. All my vars are built using only the letters [I, i, l, 1] and i just remember what the vars mean.
@ucagdascoskun
@ucagdascoskun Жыл бұрын
Good content, thanks!
@fleity
@fleity Жыл бұрын
At first I wanted to complain about the title being too clickbaity, I didn't expect to learn much new stuff but wtf get set fields can be serialized?! Your videos never disappoint. This is amazing.
@exceptionaldifference392
@exceptionaldifference392 Жыл бұрын
Good stuff, thanks.
@egegl
@egegl Жыл бұрын
great tips thank you :D
@Tarodev
@Tarodev Жыл бұрын
You're welcome, egegl
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Still to this day, 95% of Unity tutorials on KZfaq use camelCase for all their fields. So back when I eventually learned about proper naming conventions, it confused the heck out of me since no one seemed to be doing it hehe. 🙂 Sorry to hear that people were "hating" on your naming convention video. It is definitely not deserved, and it clearly comes from a place of frustration, since most Unity tutors ignore it... Us who use proper naming conventions for some odd reason are the minority. 😅 Don't let people in the comments discourage. The information you provide is top notch and technically correct, even if some people get upset hehe. 🙂 Your videos are absolutely incredible, and are a must see for people who learn Unity.
@Tarodev
@Tarodev Жыл бұрын
To be fair, I was pretty aggressive in that video. The thumbnail even had big red text "Your naming conventions suck", lol! Us who use conventions know how helpful they are. The only resistance I get is from non-users... funny that. Thanks for the kind words brother 🙏
@Dani_Krossing
@Dani_Krossing Жыл бұрын
@@Tarodev I did the same thing on a video quite a while back, and ended up changing the title, since it was like moth to a flame when it come to "negative" personalities hehe. 🙂
@Tarodev
@Tarodev Жыл бұрын
Some channels flourish in controversy. I don't have the resolve for it 😭
@Dani_Krossing
@Dani_Krossing Жыл бұрын
@@Tarodev And it's healthier in the long run. 😂 The vibe of the content determines the vibe in the chat. And it's just much nicer to wake up to positivity when you check your notifications. 🙂
@Tarodev
@Tarodev Жыл бұрын
@@Dani_Krossing 100% this.
@Fefs-yi1gf
@Fefs-yi1gf Жыл бұрын
hey man, i always love to see your videos. I'm a total beginner, i really don't understand yet 80% of what you're talking about, but being exposed to it and seeing how you solve somethings really helps, and is fun. Is there any source material or tutorials you recommend for beginners? apart from the unity learning page of course. Thanks
@Tarodev
@Tarodev Жыл бұрын
Honestly, when I started learning to program, I just built things. When I became stuck, I searched directly for that information. After a few years of constant grinding, I was in a pretty good place. Alternatively, you can find a good course, but it personally wasn't for me. It most likely would be a faster approach, though.
@Fefs-yi1gf
@Fefs-yi1gf Жыл бұрын
@@Tarodev thanks for the input. Yeah, I think that's the best way, just building something and looking for answers when stuck, have done it for other things, will try it with this subject too. 🙏
Cool Tech You’ll LOVE!
21:41
Snazzy Labs
Рет қаралды 68 М.
Хотите поиграть в такую?😄
00:16
МЯТНАЯ ФАНТА
Рет қаралды 2,5 МЛН
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 551 М.
تجربة أغرب توصيلة شحن ضد القطع تماما
00:56
صدام العزي
Рет қаралды 53 МЛН
100❤️
00:19
MY💝No War🤝
Рет қаралды 22 МЛН
Unity Code Optimization - Do you know them all?
15:49
Tarodev
Рет қаралды 185 М.
You Need To Know These Unity Tips!
8:50
ButWhyLevin
Рет қаралды 26 М.
10 Unity Tips You (Probably) Didn't Know About
8:58
Sasquatch B Studios
Рет қаралды 10 М.
Unity Architecture for Noobs - Game Structure
16:24
Tarodev
Рет қаралды 189 М.
Why you should NOT make everything PUBLIC!
8:26
Code Monkey
Рет қаралды 118 М.
10 Unity Tips You (Probably) Didn't Know About
7:09
Sasquatch B Studios
Рет қаралды 7 М.
How To Render 2 Million Objects At 120 FPS
14:57
Tarodev
Рет қаралды 138 М.
11 Things You (Probably) Didn't Know You Could Do In Unity
13:49
Game Dev Guide
Рет қаралды 149 М.
Хотите поиграть в такую?😄
00:16
МЯТНАЯ ФАНТА
Рет қаралды 2,5 МЛН