Infallible Code - Unity 3D Gamedev Stream #3

Unity3D game development stream featuring programming Q&A, code reviews, and discussions on game marketing strategies.

Video Information

Title: Infallible Code - Unity 3D Gamedev Stream #3

The stream focuses on Unity3D game development, programming, and code reviews.

The hosts are Charles from Infallible Code and Jason Storey, a prominent game developer.

They discuss the importance of marketing for indie games and the challenges of contacting influencers.

The stream emphasizes the value of creating smaller games to gain experience and avoid feature creep.

There is a discussion on the current trends in game development, such as hyper-casual games.

The hosts provide tips on using WebSockets and REST for Unity multiplayer games.

Mentorship in computing is discussed, highlighting the importance of engagement and providing resources.

The code review focuses on optimizing Unity scripts, caching components, and improving readability.

The importance of using namespaces and adhering to coding standards in team environments is stressed.

The stream encourages submitting code for review and suggests potential future topics like game design document reviews.

Skype won't move out of in front of the chat box Hey look at that mornin got our 0:06 first guest how's it going welcome to the unity3d game development stream I'm 0:12 Charles your host from infallible code and I'm here with Jason's story a prominent game developer and ranter 0:23 known for his his rants about unity3d encoding and it's got a couple games 0:28 under his belt so this is a week three of our weekly game development stream thank you for joining in you're new to 0:36 the stream watching a Nevada or live with us now we're basically going to answer some questions about programming unity3d 0:42 game development and we're going to do a

code review today I actually have one 0:48 lined up we actually have two more I think in discord so we'll see how far we get mm-hmm so if you have any questions 0:57 and you're here with us live feel free to drop those in the chat and if not I 1:02 love his rants there you go if there's no questions in a moment we will get 1:07 right into the code review we're having a pretty good discussion oh my camera 1:13 shut off we were having a pretty good discussion earlier Honda scored if you're not a part of our infallible code 1:19 score server our community feel free to hop on to hop on to

that there's a link 1:24 in the description of this video also I just dropped the clips from last 1:30 week's stream on the channel so be sure to hit like and watch those if you 1:36 haven't already alright sure I make an MMO I'm not taking up this early yeah 1:43 it's too early in the stream his mind is too clear yeah someone says should I make an MMO yeah 1:49 that's basically lately that has been the key rant that we've been hearing because we get a lot of questions about 1:55 mmo's and how to make one in unity can you make a tutorial on how to use multiple scenes in spatial OS oh another

2:02 in the spirit of multiplayer massive multiplayer online games to be honest I 2:08 do not have any spatial OS tutorials lined up just because 2:14 there's the the framework or the engine the platform is still or in its early 2:20 days so I'm kind of waiting for it to get to a better place more stable place 2:25 before I start working on those tutorials but yeah I mean maybe a thanks to you thank you for the suggestion I'll How to contact influencers 2:31 I'll jot it down and you know take a look and see if maybe there's a room for a review or rather tutorial on that how 2:39 should you contact influencers what

I don't know am I an influencer if it's read the game 2:48 development stuff honestly I hate to say it but usually you don't want to and I 2:54 don't mean this in a bad way for the influencer or for your game but um tell the truth the kind of the dirty little 3:00 secret is a lot of influencers will charge you a lot of money to mention your game like it looks very quick and 3:06 sort of hey look I'll just try this new game on it that's thousands that cost you thousands to get your your games 3:11 name on the lips of anybody who's even remotely a popular youtuber um it used 3:16

to be people would do it for fun but it's gotten to the stage that it's just not worth the money for most Indies and what you do instead is you find yourself 3:23 some sort of there's a marketing firms that are out there and I know it sounds 3:28 very go shouldn't people don't really like the idea but people do this for a living like the actual getting your game out 3:34 there is a is a trick that requires a lot of skill and it's not just it's not just one day of sponsors 3:39 you're better off spending two to three thousand it would cost you to hire someone who's perfect professionally 3:45 involved in

advertising your game because at the end of the day if your game is an advertised correctly you're 3:50 not gonna make any sales and it may sound like a lot of money to say only about two or three thousand well if you said your game correctly you should be 3:56 making thirty thousand and if you if you undersell they're not you're gonna put into your advertising your game doesn't 4:01 get sold and you don't even make two thousand so it's a lot of money but realistically if you're if you've 4:06 invested two years your life to make a game invest two or three thousand just to advertise it and so yeah don't do it 4:12

yourself like some people are really better than you can you can learn how to but then you're basically giving yourself another job the long and short 4:18 of it is if you want an influencer to advertise your game they have to want to it has to be popular it has to be like 4:23 deuce game they had to go and pay every youtuber to play ghost that they wanted to because it was a 4:29 cool game everyone's enjoying playing so you you can cheat in some ways some of the influencer 4:35 kind of marketers they know people at different magazines so or they know people at we'll listen magazines I guess 4:41 these days websites

but they know the people at Kotaku and stuff and they will get they can get to kind of bend the ear 4:47 of the right people to get articles written about your game and it's all about contacts so don't bother reaching 4:52 out they're just gonna ignore your emails they got thousands of emails a day about who which game to play instead find someone pay for someone to do this 4:59 job for you with the right contacts and the right people get your game out there and like invest in it you know yeah my 5:06 wife works for a marketing agency and to your point it is a whole separate job 5:11 you know to

to be a marketer and then on top of that to be a marketer for a particular niche like the agency that my 5:18 wife works for they have their own particular niche that they fit into but you're gonna find marketing agencies 5:26 that are specific to game development and they will have the connections the contacts to reporters to influencers and 5:33 and just the right people to get you know your game out and in front of that right eyeballs so yeah unfortunately I 5:40 can't give you good names it's not something I've been doing recently enough to know who the people are but um there are there's other people out there 5:46 or no that's

a lot better than I do and I would say Google is search for it you'll find answers your question yeah 5:52 just want to send you the wrong way yeah and spent and like you said spending money when you think about you know 5:57 creating an indie game if you're an independent developer just because you're an independent developer doesn't 6:02 mean it's all gonna be free I mean you have to put capital into it is it is a business I mean you do want to make 6:08 money from your art and artists in any field whether they be independent 6:14 filmmakers or like ah retains as game developers you know you're gonna have to spend

some money to make some money and 6:20 unfortunately spend some money to get your art out into in front of the public 6:25 so just yeah I mean for example like if you go searching online you'll find lot of advice that says you don't need a 6:31 publisher and that's technically true we live in a world now where publisher is kind of an arbitrary meaningless job 6:36 unless you literally need the money for certain things when people say that what they really 6:41 mean is you can market your game without a publisher but the little asterisks 6:48 there is you have to actually market your game and the way they tend to recommend this is

by social leverage and 6:54 the way you do that is you build communities and you'll see this a lot around starting games where they build a forum or subreddit or something and they 7:02 have they tweet a lot and they get people engaged and they do the whole early access thing and they get people actively shooting for your game 7:08 realistically for a free and that's something you can do but you have to like make that you have to make a 7:13 community to manage the community you have social people doing that stuff that is an option the other option is you get 7:19 a publisher to do it for you now there's a lot

of bad publishers to an awful lot of research do not just pick the first publisher to offer you 7:24 money but there are some really good ones and they will basically they know how to market your game so that's 7:30 another option as you do go over to publisher take the cut on the profits but like have your game marketed 7:35 correctly so you won't make something so there's not options but don't slack in 7:40 the marketing it's kind of the go-to right it's like there's there's think of all the time you spent making it it's 7:45 worth putting in at least a portion of that time and to just getting people to look at

yeah and there and there is a 7:51 difference between marketing and spam - and I'm speaking from experience you know why first got started with YouTube Why YouTube 7:57 I want to get my content out in front of a bunch of people and so my initial thought is well everyone says to go on 8:03 Facebook and Twitter so what do I do I take a video I put it on every subreddit 8:08 Facebook group and and and and I included in every Twitter handle I could 8:13 possibly find but you know that's not the way to do it the real way to do it is to genuinely become involved in a 8:19 community and it's

hard it does take a lot of time like I would say months and 8:25 months of investment to really make an impactful to make an impact for your for 8:30 your game you know because you do have to genuinely be involved in a community where people care about your opinion and 8:36 then all of a sudden it's like hey by the way I'm making a game you know then there's gonna be more true interests 8:42 like oh I like let's say Jason if Jason oh man I'm sorry if Jason's the notes tomorrow I'm making salmon oh yeah 8:50 yeah every would be like are you kidding me you're seriously making them up dude you should

put that on Kickstarter yeah 8:57 you'd have some backers for sure I'd back your ass Astrix later I used to 9:08 play a lot of them when I was younger that's yeah god-husband all kinds I have 9:14 played me though I never played Wow or any of the big bad ones only play a few like Atlantica what's the other one I 9:21 used to play spell force I can't remember either way it's been quite some time but yeah not not my not my sort of 9:29 genre I can to play a lot more of actually as pointed out in the chat there dungeon keeper was my style game 9:34 and then there's that Soul Reaver

and a few others back there that was my kind of thing I used to love obviously Legends of Aria 9:41 runescape 2007 classic but I used to play Ultima Online which was pre World 9:46 of Warcraft and that game was my jam but that's that's a game where it's like total nostalgia because there's a new 9:53 one that just came out called legends of Aria and it's built in unity an MMO built in unity and I don't know it might 9:59 be independent we gotta check into that I was one of the early backers like I'm talking I was a backer in 2016 and yeah 10:07 I mean it's come a long way but you

know when I play it I'm like looking for that that Ultima fix and it just like it's 10:14 not the same guy was a different place in my life you know what I mean I'm just still have the time to sit and enjoy it 10:20 like I like I wish I could yeah these days I'd like time boxed experiences I like like bringing out another Bioshock 10:27 you know just give me give me 810 hours of just solid entertaining code on them and I can move on something else 10:33 yep alright so do you think we should take another question or you want to hop 10:38 into a code review get it we can do

like a staggered yeah exactly we can do a bit about but yeah I think I think we 10:47 covered the basics on them marketing and as people pointed out publishers yeah I think there's pretty scary like they can they can ruin you and you'll there's 10:54 people who will talk about that better than I well I I like I've not published a solo game myself as a developer I kind 11:00 of work in other people's teams I'm one of those diverse types that can gets brought in for consulting into the right systems 11:07 and scripts but I have a lot of friends with make games that are on the store you can buy that have

given me a good a 11:12 good round experience on stuff of how it works in terms of what successful and what isn't and yeah I don't know there's 11:19 there's a lot to say on the issue I would recommend looking to other people who have kind of more hands-on experience like Tom's brush does a 11:26 really good talk on publishers but he's the one who will say you don't need one but they can be useful pretty much the 11:32 kind of thing that I said here so he's certainly more a profession to ask on that specific issue you might even know 11:38 names of good publishers that I wouldn't be able to recommend yeah I

see a good 11:43 question here that I think is you know before we jump into the code of view I think this is a good one a good one to answer would you guys recommend making Smaller Games 11:49 more smaller games one to three months instead of few longer games six to six 11:56 plus months and I think that's he saw a development time like same thing so I'll let you go for stuff this way I would 12:03 definitely suggest picking smaller projects just because there's so much 12:09 value in getting from start to finish you know I mean I'm sure this is pretty 12:15 prevalent are and you know a game development community and

I'm totally someone who's done this I love starting 12:20 projects you know there's nothing like a clean unity project when you're pulling in models everything's clean 12:26 everything's under control and then all a sudden it starts to get to this thing where you're like oh should I add dependency injection like I'm adding a 12:33 lot of classes here should I make a manager and then to me you know that's where it's like it's kind of getting 12:38 like the fun that I had a novelty of a brand new project starts to wear thin 12:44 and that's where you know you tend to just kind of give up or just forget 12:49 about the project or

move on to something else get distracted so having projects that are 1 to 3 months they allow you to see the end goal and so 12:57 when you get to those points and they are inevitable when you get to those points where the novelty of the project 13:02 has worn off and you're and you're trying to figure out things that are just so tedious as an example maybe 13:08 you're like I want to localize my application so that you know it's in multiple different languages or it 13:13 supports multiple different languages that that's no fun I mean come on you become a game developer to learn how to localize your game but it's just 13:19

something that you're gonna have to do at some point so having a game that is short the concept is simple you know 13:26 where the end goal is it'll allow you to push through those moments I believe and get to the end and the end of a project 13:32 is it's really valuable to see that through multiple times because there's gonna be so many things at the end of a 13:39 project when you're wrapping things up getting ready to publish that you you will never see if all you do is start 13:45 projects and I'm speaking from experience there yeah there's a million one good reasons to pick smaller 13:51 projects over bigger ones and

probably the biggest one is this Charles it there and many people will let it go it gets 13:57 something out of your graveyard of of on complete projects that happens all of the time and you really want to avoid that but even more than that if you make 14:04 a small game it solves a couple of problems one of them is it helps find the fun early and I love that phrase find the fun I forgot where I read it 14:11 first but it basically means that an idea means nothing until you do it in practice and you can do really quick 14:16 prototypes and you can make really small projects and you can find

a fun idea and then run it to the goal post okay get it 14:22 as good as it needs to be to prove the idea and move on and that's what game jams are amazing it was many game jams you possibly can but basically you make 14:29 these small games not only that they teach you how long it takes to make a game that sounds kind of obvious but 14:35 like when you make a game you could happily say out budget to spend six months on my game and you'll blink in the years gone by and you're like oh 14:41 okay I guess I guess I didn't if you aim for a small game and

then it doubles in size you're losing less worry in time 14:48 and on top of all of that if you work on smaller games you know whether people like your game and you've earned me a 14:54 better condition to either decide to add more to it later to make a sequel to us or to branch of something else a big 15:00 mistake I see a lot of people do is they'll make a big game and even if you succeed in finishing your big game you 15:06 don't know this is fun or not and what's even worse is it could have been fun to start but people think that people think 15:12 that we released a

game that it's going to match what we originally thought of but you will change your writing ten times there the process you'll come up 15:17 with what the idea is and by the time you hit the end the mechanics that have changed the characters have changed the 15:22 goal of the game has changed doesn't matter because as you play it things will evolve and if you make it smaller you can you can whether those those 15:29 things and you can avoid one of the biggest dangers of bloat so it's not just bloat in terms of adding features but what 15:35 happens is and you'll see this a lot in sort of at when a studio

releases their first game and it took two three years 15:41 to make they'll feel like there's a disconnect between the mechanics and either the art or the story or the 15:46 general feel of the game because what's happened is they went in with the goal of making a fast shooter and then by the 15:53 end of it returning to a cover shooter because they added all these cover and shield mechanics and it's because as they're getting into the end of it 15:58 they're like oh I'll have to speak to I have this feature and this thing is taking eaters debug so I'll add this new feature and then I've lost whatever the 16:04 point of

the story your game or goal was and the game they end up producing will be probably you know it could be for 16:11 different audience or it could be more or less fun in the original starting idea if you keep it small you can remember what the fun of your project is 16:16 and bills to that and keep that fun and keep finding it and you're not in danger 16:21 of sort of turning into a game you didn't start with so small repetitious cycles of games and build a good 16:28 portfolio the more work you're going to get is the more the more project you happen yeah exactly future creep is that 16:34 it's the

kind of specific name but it boiled down to you want you want a large portfolio approving good ideas because 16:40 gaming isn't just writing the code and it's not just building the project is it is it fun and do people I play yeah yeah 16:46 and keeping it short you know you should do that at a project level but you should I believe you should also do it at a development level you should 16:53 iterate you should iterate in small chunks and constantly get feedback from 16:58 anyone who will play your game and give you feedback because you know I think 17:03 game development you know it can be considered an art form in many

respects and the idea behind anything creative is 17:11 that it's gonna change it has to change you know you're gonna have an idea but as you go things that you thought were 17:18 fun on your mind are not gonna be fun and you may inadvertently add a feature to your game that is fun that you'd 17:25 hadn't even expected to be fun and you have to be able to be flexible enough to iterate on that and say well you know 17:31 what I thought this was gonna be you know a cover shoot game whatever the case may be but I like it better as a 17:36 fast-paced shooter so you have to be able to

be flexible enough to to explore that and the way I think you do that is 17:42 to keep your your your development cycle in two short iterations and obviously I'm talking 17:48 about scrum and doing sprints but yeah I mean I think it's very valuable to close that feedback loop and constantly give 17:54 yourself the flexibility to change and maneuver and be more agile someone 17:59 someone give me some corporate sponsorship money here I'm promoting agile and scrum that's a great question 18:07 thank you for that yeah at least this is a collaborative round I didn't feel like 18:13 I was screaming because that's something this is a topic I think is interesting and valuable

and it's not I know it's 18:20 not something to complain people for I think a lot of people take it personally when you say don't do this don't make this kind of game and realistically it's 18:26 more just weathered advice you know like I don't wanna feel like I'm not saying don't make X game all memes decide what 18:32 I really mean in most of these cases is you will cause yourself some harm in some way shape or form if you don't pay 18:38 attention to the advice out there and the main advice is small cycles learn from it and grow from it and if you if 18:43 you do jump into a large project

without the pre record experience you'll just blink one day and realize you've lost 18:49 years of your life on a project that may not go where you thought would go and it may not be as successful as you thought and it's like take a risk fine but don't 18:56 you know don't put all your cards in and one go and hope for the best when you can what's the phrase it's a your look 19:04 is look favors to prepare it or something so you know prepare don't don't gamble with no experience build up 19:11 to the point where you want to be you know yeah one of my favorite quotes I think this is the

same spirit is a luck Luck 19:17 is is when opportunity meets preparation so it's kind of like if you're working 19:23 on the same project if you're if you work on a single project and the only opportunities you're ever gonna get are 19:29 around that single project and obviously it might not be there might not be any 19:34 opportunities especially if it's in John rrah or something that a niche or something a category of game that is no 19:42 longer in fashion you know and that happens you know some games are more fashionable now battle royale games are really popular I think they're so 19:48 popular but uh you know five years ago they weren't

and five years from now they might they might not be so you 19:54 might you might say I'm gonna make a battle royale game it's 2019 you get to work let's say you 19:59 do make it and you do complete it and it takes you two years and and you want to launch it in 2020 to maybe 2023 battle 20:06 royale games may not be fun anymore so you prepared and you created this game but now the opportunity is passed 20:11 by working on many different types of games and and in smaller games you can 20:18 get more out there you're preparing yourself more because you're experiencing more problems and and 20:23 finding solutions to

things that come up as you develop and you're creating more opportunities for yourself like I think 20:29 we talked about this before the guy who made flappy bird he made like like I don't say hundreds but he made tens of 20:36 mobile games that were just small maybe 140 like 30 or 40 like it was quite a 20:41 lotta games quite a lot of games and and yeah and there was just flappy bird happened to hit I don't know why no one 20:47 knows why he doesn't even know what do you think about this Jason what do you think about developing really impressive 20:53 vertical slices I'm like that's your thing you're like hey I'm

not gonna make finished games but I'm gonna make a ah 20:59 that's a great way to get hired as opposed to a true way to make games but it does work like I think I think that 21:08 kind of thing works great at your job is to basically do what we're doing now if your job is to get a portfolio of people 21:13 like mixin Jam is amazing look at mixin Johnny - oh yeah it's it's inside they're basically a channel you know 21:18 picking mechanics and making effectively mechanical vertical slices of games and that's a great way to get people engaged 21:24 in what you're doing but one thing that similar thought you were

saying about genre not being popular anymore is one 21:31 of the best one of the questions was thoughts on hyper casual games versus idle games and that's a very good 21:36 example of what you were saying idle games aren't popular anymore there they're definitely they were five I'm 21:42 not saying they don't exist but for a while with cookie clicker being the predominant leader at the time those 21:48 kind of games really had an explosion where everyone played and personally I'm not a fan but I get why they exist and 21:56 you know they but the point isn't so much whether I play them or not or whether someone else does it's what's 22:02 their

value as a product to make and right now there's not that much interest it's more of a mean game or than 22:07 anything else but the opposite being hyper casual games that's the opposite that's currently super on-trend hyper casual 22:14 games are really popular there I think they're actually three of the top five I'm most outdoors at moment I can't 22:19 remember but um if you want to make money right now hyper casual is the way to go really short find an engaging game 22:25 loop or as someone else also pointed out in the chat steal one from an older game it doesn't matter if you're basically effectively remaking palm or remaking 22:32 Tetris so

we're making breakout put a spin on it you know at a timer change change the the the rotational approach 22:42 of it like even if you just add make it 3d make it doesn't matter what you do if you can make something that can latch 22:47 the people can latch onto it for a few minutes and play one-handed that's how you that's if you want to make games I don't say cynically but that's how you 22:53 can pragmatic about making money from games but so yeah they're they're 22:59 popular now but again just like everything else they're not gonna last forever they're not gonna be the good they're not a new genre per se like

people think there might be but it is a 23:05 new it's a current trend that is a good way to earn money at the moment so yeah 23:10 yeah it's interesting to UM you can almost tell what's what's in style game Hyper Casual 23:16 wise if you watch a lot of YouTube videos and you see sometimes you'll see like unity udemy courses like 23:23 advertisements and and I remember seeing a udemy course advertised that was for that for how to make a mobile game that 23:30 was like was it Sally what was it called like super casual ultra casual Oh 23:35 hi / casual hyper casual yeah yeah it was like make a hyper casual

game take my udemy course so it's like oh I guess 23:40 that's what's popular right now yeah I know I would kind of disagree with the 23:47 idea that they're going to take over I and some people think they do and that's that's fine and a lot of stuff is 23:52 trending that way but in the same way everything's trending to open world right now there's open world fatigue and 23:58 we can all feel this like as bright as breath of the wild waz and as great as it is that these giant open worlds 24:04 there's this push back where people are just not interested in or and hyper casual is really good a while

ago and it 24:10 still got some legs people still like them but there's this sense of losing engagement with content and people are 24:16 getting very socially aware of the dismissiveness of social media now people are not engaging anymore and 24:22 there's gonna be a pushback socially on that too so if I put money on it I would recommend leaning into engaging content 24:29 games going forward maybe now do some hyper casual but like if you if your 24:34 angle is to make a game in two years time I'm one of Best narrative games and really detailed mechanic games are going 24:40 to be what kicks off in two years time and that's something to

add something to bring up no one really knows what the 24:46 next fad is gonna be there are people who have the pulse on the industry and maybe history will sort of repeat itself 24:53 so that kind of can be an indicator but you just don't know what's gonna be popular who knew battle royale games 24:58 were gonna be as popular as they became but the people who hit it first like pub 25:04 G was one of the first I believe don't call me on that yeah well step to the one the popular 25:10 genre yeah so I mean the guy who created that game player unknown I guess he it's 25:17 not like he

knew battle royale games were gonna be big and he was like I'm gonna capitalize on this you know he just really liked making that type of 25:23 game I think it started as a mod and and then he just well he was lucky you know he was prepared and an opportunity rose 25:30 and it they just clashed and boom there you go so and that that's that whole thing would look you know you just and 25:37 creating smaller projects you know the more experience you have making smaller projects you just experiment tried 25:44 different types of styles of games you're gonna be in a better position to take advantage of a fad if it does

come 25:50 up in the future you can say hey look you know what this this thing became popular I actually made a little vertical slice about the same style game 25:57 maybe I can iterate on that and then you'll be one of the first two to hit a fad or a trend so just some food for 26:04 thought not not that you should go around think you know creating games thinking maybe I'll get lucky and just blow up but you know it's just something 26:11 to consider when you when you're like I'm gonna make the next battle royale and it's not gonna come out till 2025 or 26:17 yeah and we know even something that

it falls on Indies literally that's that's 26:23 it you can see the largest cup of the game industry so many other companies are tasting each other's tails like what 26:30 was that one was at sunset overdrive that came out afterwards trying to capture the the fortnight magic and sort 26:35 of lean onto that and it just died to death because it was just too it was too late like the fad is over you can't go 26:41 and develop a game for two years and hope to be on the same type training this is not gonna work yeah definitely I WebSockets 26:48 saw a question come up twice I mean you want to have any more

thoughts on this one no no this is a more low-level 26:57 question just to bring it down to programming just to keep it diverse 27:02 what do you think is WebSockets slash rest suitable for unity multiplayer games in real time you should have some 27:09 feedback on this one Jason since you're working on some api's oh yeah they say I'm running risk stuff performance it's 27:14 not granted it's for more of a mobile app so it's not really to the same sort of question unity multiplayer I don't 27:23 know that's that's a tough question because it's kind of asking different things WebSockets are right I use them for lots 27:29 of stuff mostly I get

a little bit with controlling hardware like you can you 27:35 can do some interesting stuff with creating really small packets of bytes and using it to do some also media 27:40 players there's a DES MIDI player I use at the moment which is desktop Google 27:46 Desktop Media Player I think it's basically the an unofficial desktop client for Google Music and they 27:54 basically use a UDP style connection to to send data back and forth to 28:00 controller which is pretty cool what for multiplayer I don't know like I'm not super familiar with what's 28:06 currently popular and the multiplayer space for networking but I wouldn't on say just wouldn't recommend rolling your 28:12 own

I would like it's one of those areas there's enough research done I'd find something that's more more fleshed out 28:20 than whatever you'd kind of cobble together with your own networking low-level stuff but all that being said 28:26 in general using rest is great in unity I I do it pretty much in every project I 28:33 work on it's always nice to be able to paint some service and store data and get stuff back and there's there's 28:39 multiple restclient stuff you can do everything from the native unityweb 28:44 requests there's also the HTTP to library on the asset store you can 28:50 enroll your own which is kind of what I did for code

for the projects so yeah I mean unity is not you know ever you like 28:58 with networking immunity doesn't the million tools like go for it it's great just specifically to drive your multiplayer I find an actual networking 29:04 solution for that because there's an awful lot of stuff to do with synchronicity that you don't want to be managing yourself they're gonna want 29:10 something done for you in terms of managing the the the kind of what should be network traffic and what shouldn't Mentorship 29:17 you know there's no question here 29:22 actually that come up with few times as well mention right there how do you mentor someone in computing in general I 29:30

do this a lot I am I basically used to tutor at coderdojo back when I had a 29:38 desktop job I basically I worked in a bank and I'd spend my free time teaching 29:44 game dev to there's a nearby college and that bring in the you know between the ages of 12 to I'd say 15 and then we 29:50 teach them scratch and a few other different like JavaScript and a few other different things a similar style 29:57 kind of a to the devil program and a little JavaScript as well so long story short how do you how do you effectively 30:03 tutor someone in this kind of topics in my opinion its engagement

you find something they enjoy 30:09 and that's why games are so easy to tutor people in because basically give them a fun sandbox and let them play with it so what I tend to do is I pick 30:17 something like scratch because it's so easy to get up and running and you can just give something very quick code to 30:22 play with if it's more about how do you mentor or train someone in a kind of more technical capacity then I always 30:29 recommend challenges and tasks so for example I tend to direct people to plural site I'll be there to be on hand 30:35 and answer questions like literally now when people have questions

but I tend to not like hovering over people because 30:41 what you'll find if you tutor people in a one to one session it can be very very 30:47 overwhelming and you'll notice yourself you're learning something if somebody's basically sitting there going I'll be here to answer all your questions and 30:52 I'm hovering over your shoulder ready to answer in pounce you get something wrong and it makes people to learn it self-conscious so 30:58 what I prefer to do instead is I find resources I like and that's why I tend to reference resources a lot so for 31:04 example if you click my name and go to my youtube channel I have a playlist of

good resources on multitude of topics I 31:09 can't appoint people at that and I say here is stuff I'm here to answer questions if you actually have questions 31:15 on these topics so yeah I'm story short tell them to get a plural psych account you hand pick and 31:21 cherry-pick relevant topics that you want them to learn you give that to them and then you answer questions and then when they're done and you're confident 31:27 they understand the course material you up the ante by saying okay can you take that and now change it to do this and 31:33 that way you sort of give them constant engagement and quick wins you know so there's

a long way the question of how I 31:39 personally like the tutor people get them engaged in the topic give them small wins they can do repeatedly and 31:45 move on to different areas with sort of branching out and if you want to see a very good example of this as mentioned 31:51 the previous draft is coding train you know I'll type it in as well because I know people have a bit of trouble understanding when I'm ranting with 31:59 coding training is a YouTube channel where it's it's just fantastic 32:04 incremental steps of learning very complicated topics so that's my recommendation yeah I agree I mean I 32:11 personally don't work well under pressure

so you know in situations when if I try to put myself into the shoes of Tutoring 32:17 the individual I'm tutoring and I can remember back to when I was in university and being tutored and it's 32:22 like it's not it wasn't fun for me to be put on the spot like that and it's funny 32:28 too cuz it's like you you're in a situation where you're not expected to know cuz clearly you're being tutored 32:33 yet you're still like I gotta know this you know like why am I not fast enough why am I not picking this up so that I 32:39 mean personally that's where I I do agree with your approach Jason

where you're just like hey look do this task 32:44 you know then we can talk about it afterwards it's a low pressure situation and I think that it that's more 32:50 conducive to learning so yeah I'm providing resources as well and actually it plays into another 32:56 question out of here is that what you think the right balance is when asking for guidance and doing tasks when mentoring a junior I think it falls into 33:05 the same thing right because if you put yourself in the feet of somebody who's in a junior position it's working under you or new to a team 33:11 they're going to do their best to be helpful they're literally going

to be sitting there going please give me work 33:16 to do I want to do it I want to help but truth be told almost every time you do they're gonna be overwhelmed and when 33:22 you do that they're going to be sitting there in their chair panicked going I can't do the thing I was assigned and I'm looking across my table that the 33:29 person I'm working with and they're really busy and I don't want to freak them out and like take their time away they're important that I'm not and you 33:34 sort of get really stressed about it so you want to avoid that situation for both parties you don't want it you

don't 33:40 want then baptizing your time by asking lots of questions you also don't want them stressed out that they can't ask 33:46 you questions so this comes back to the same thing I recommend giving them guides and other things to work on give 33:52 them a Pluralsight course let me play with it and work on that and then be there to answer questions after they have finished the course if they haven't 33:58 demonstrated they've done the course then they shouldn't need your attention because the material is in the course if 34:03 you can be there to help answer the question in time to time but that's the perfect mix of let them get it

based off of knowledge so you know if they could 34:10 look at the course and you have also completed the course in the past you know what level they should be at which is now a good place for you to propose 34:16 relating that to your current project or kind of expecting a certain level of 34:21 understanding from them so same thing applies is be aware that they're probably either too afraid to ask you 34:26 questions or they'll have a lot of questions for you so give them something they can actually achieve that steps them closer to being 34:32 better and helping you in what you're doing so you're saying do the course first before

you commence the real tutoring 34:39 yeah literally every course that ever recommended every Pluralsight course I've pointed out I have completed myself 34:44 I have I've watched hundreds and hundreds of hours of service I have watched almost every course on c-sharp 34:49 they've done right down to the learning c-sharp on learning you know equality operators and all the kind of 34:56 entry-level stuff because if I'm gonna recommend that the people I want to know what's in it you know yeah yeah definitely cool what do you think about 35:03 before we go to the code review and just to jump off of this what do you what do you think about let's say you're Thoughts on

tutoring 35:09 tutoring a couple of individuals bringing them together and doing like a game jam with them like say hey look no 35:16 pressure on this game jam we're gonna do it together and you know just a bunch of people that you're tutoring 35:22 a year thought about do anything like that I think it could be pretty cool I have but there's a caveat to that the 35:28 careful of is the unfortunate truth is people learn at different rates and you 35:33 want to be careful not to pair people to the point where one person's gonna race ahead one person gonna feel lost so I 35:40 personally don't like giving people a task like that

because what's gonna happen is you're gonna get people one 35:47 person is gonna be really enjoying it and they'll say no no I'll help I'll brush I'll get ahead and we'll do lots of stuff and they'll end up having 35:52 someone feel left out now if you're very confident both people are at the same level of knowledge or similar fine but I 35:58 usually prefer what's a better idea it's give them both the same task then compare and contrast work afterwards and 36:04 then give them challenges relative to what they've demonstrated they can do and if they seem to be on the same page then you can actually take to exactly 36:10 what you said

they both did the task they both did it to roughly the same level now you could say okay now we'll teach you about my programming or even 36:17 just pair programming let's get you working together we'll give you a new task and I'll act as a product manager and I'll throw you 36:23 curveballs with new changes and all what we factor to do this and then get them to work together and problem solving but 36:30 yeah it's it's a it's a tough it's a tough thing to start out with you need to kind of ease people into working together because that's a skill in 36:35 itself ok don't really lifestyle you you could be the

best program in the world but you've never worked in a team and you brought into a team for the first 36:41 time you're gonna have a very hard time working with other people they're there for taking your code there's code reviews there's a sense of ownership of 36:48 who has this you don't know you don't be the guy who over wrote the other guys code it gets really messy and you have to learn how to handle that you know 36:54 yeah yeah definitely people don't realize working on a team it there's a Working on a team 37:00 lot of different personalities some teams just will never work together you know some people just don't work

together the personalities don't match 37:06 so it's it that's a whole art and form in itself trying to get people together and work effectively alright cool so I 37:16 think I saw someone say code review code review so you want to dive into it we've 37:21 been going for yeah so this piece of code I just want to say who it was from 37:26 was from direct see on the discord server so let's give it a look-see 37:34 mm-hmm you see my screen there Jason attended yet all right so we're pretty 37:39 much looking at this for the first time I did pull it up and paste it and just kind of gave it a

glance but I guess I 37:46 think the more of these we do will probably come come up with like a step by step process to looking at code but 37:52 just off the bat I can see writer is telling me a couple things you brought this up earlier yes what's this blue 38:02 line say repeated property access of built-in component is inefficient 38:09 that's that call to this dot transformed our rotation yeah now it's not as bad as it used to be so I will put a copy out Component model 38:15 there and so when they architected the the kind of programming and unity in the 38:22 past they wanted to simplify a lot of

concepts and so one of them is that unity is built on a component model so 38:28 behind the scene do you only think about it when you see monobehaviour behavior as a thing that exists on an object and 38:34 an object it's multiple behaviors and you kind of Intuit this as you use unity but you don't really think about it as 38:40 that an object is a list of behaviors and so what happens is every time you 38:45 write an innocuous statement like Doc transform or dot rigid body or dot 38:51 renderer any of them you have to basically search the object and find the one that you're looking for and so if 38:57 you

write this dot transform dot this dot transform dot every one of those constitutes a small search no it's not a big search and unity if memory serves 39:04 caches some of these now it never did before but it's some of them the cache now transform might be one of them and 39:10 I'm not entirely sure but to be safe I still like to cache the transform 39:15 before I do a lot of work on it I had a look myself it goes to the C++ C it's 39:23 not gonna be able to see the actual and see the call fortunately yeah and again 39:28 same goes for the camera I think we mentioned that before

camera domain that is the horrible call to game object a 39:34 find object with tag maybe have any of those here no yes a little it'll 39:40 actually have to search for it doesn't have the main camera tag it'll throw a null exception and if it does have the if it does have it you're still doing a 39:46 search to find it yeah so long story short if you're if you find yourself writing they start transformed out they 39:52 start transform transform dot even if it's just in the update put a transform catch it once and then use it for the 39:59 duration of what you're doing so we should be able to refactor this

let's 40:04 see let's see if I can do it one shot there's also one other thing to keep note of there is something called transform on the object obviously for 40:10 that we recommend it so cache it with the same naming convention of underscore or something but effect wait okay I true 40:16 that I'm so no I like to see that there's underscores as a little tip for 40:22 people who aren't familiar that indicate back underscore is recommended it's is a indicator that it is a class scoped 40:30 object so it lets you know this thing is a property that exists on this class so 40:36 it's very useful to say this Jenga piece has

an original position if it's not 40:41 using the underscore it's saying this is a property I'm using internally to work with stuff to calculate some other value 40:47 all right so we successfully encapsulated that now I don't know if you guys saw that but I was able to hit 40:52 all eight occurrences of one shot thanks to writer oh that was nice I think you've spoken about this well 40:59 first of all I'm gonna kill this comment because come on really come on yeah by the way last please go Change template 41:06 in and have a look at how to change the template that you can use from other 41:11 papers yes so if there's

I got a video somewhere and I think I'll link to it 41:17 somewhere that you can even search online you can change the template that unity will use to generate new c-sharp 41:22 behaviors so change that file and choose how you want to look get rid of those comments and make a video about that uh 41:29 yeah I have one from two years ago no no we need a 20 by the time I make it a 20 41:34 20 video ID update or refresh and that old video doesn't have my beautiful 41:40 acting skills so we'll see all right so what do you think about this I noticed that he doesn't explicitly put the 41:49

private modifier in front of these I think all yeah I don't like it because I 41:54 think in my mind every new word is it's a piece of information it's kind of 42:00 whether you're saying every keyword should add value write every word you're adding is literally there to elucidate 42:07 some point about an object and private is telling you every single item in this thing is private and that's fine 42:13 but it's an unspoken rule of everything in programming that it's private unless 42:18 it's not so you could less you code in groovy oh yeah I'm not even kidding you 42:25 everything is public by default I mean horrible wrote that language I'm sorry

I 42:31 that can be a random just least you got a rat this time let's go yeah so first 42:41 thing I don't use them I don't use the pre private simply because and if you can into it if you use the language you 42:47 know it's already private so it's not a new information it's just more words to look at your crop so the personal 42:52 preference it's not a be all end all it's just I don't use it yeah my personal preference is to be explicit 43:02 Charlie's a very good point we talked about teamwork earlier if you're on a team hey a standard that everyone uses 43:08 and stick to it I

don't even though that's not my personal style if I start doing half of my code not using it and 43:14 he's using it that way you end up with a really horrible mess of confusion now granted you can you can have you know 43:20 style capitals mentioned in the chat as an option that'll automatically do this for you but you don't to get into this 43:25 weird position where your code is being half or it and automatically by a stack up just you know be a good citizen as 43:31 it's called and follow whatever the convention is anyone else is using and so in this case we're using the privates 43:37 I think yeah I

think op is useful you know when when it's like a really 43:42 obscure styling like if you're on a team that's just like so used to writing like legacy code or something and it's just as obscure like you know it's it's nice 43:50 to have that just to kind of keep you honest but yeah you don't want to have to depend on that yeah all right so next Guard clause 43:57 up I guess that's all that's all pedantic like I wanted me to worried about the stuff we said up to this point here we're getting to our first actual 44:03 worry or first thing to really think about and that would be our good friend

here well actually no we'll do one thing 44:09 first which is right now that little green line on the if statement before we get to that one the if statement the Green Line this isn't 44:15 mandatory but it's another bit of good practice right that's going to tell you you can invert it that's what that green 44:20 line will say so if you if you go over to that if and expand it out it will tell you invert if and it does this now 44:27 what this does is it tells you that you had an if statement where there wasn't the else portion so what you could do is 44:33 it turns into a guard

clause you're basically saying I can take this and I can just exit out because nothing else 44:38 runs past this point if this is not true or in this case if it's the opposite of what you're doing if you shouldn't 44:45 dissemble then ignore don't do anything else beyond this part and that's just a bit cleaner it lets you exit sooner and you don't 44:51 end up with what's called cyclomatic complexity and that's where you have multiple brackets deep and all of a sudden you have to mentally kind of 44:56 zigzag your way through your code so if you if you exit early you can work on cleaner code step by step you know yeah

45:03 so yeah this guard Clause is great I mean obviously you want to make sure so for me the having the guard clause in 45:10 the up in the update method I always feel a little bit like well the update method you might you might update it 45:16 later huh you might change it later and so the update method could do so much more that you you can't predict because it's so 45:22 generic so I always like kind of I don't want they shy away but it always makes 45:27 it always feel like a code smell to me when I see it when I when I put a guard clause into an update but I

mean I think 45:32 in this case well I will in fact actually bring that up I do something about that myself which is whenever I Guard clause in update 45:38 have a guard cause what I do is I wrap everything else in the update and I give it a name so I would in this case call 45:44 this update assembling or or I put it and then you then you have a guard 45:50 clause and then the function that's called and that way you can very clearly see what would happen in the case of it hitting past the guard close got it cool 45:58 all right so we'll probably end up doing that but I'm

not let's see what this thing does well you wanted to talk about this and I think that's yeah this is GetComponent 46:03 this is the first one that everyone should really be aware of right and I say this a lot because I think we need to make a video on this especially I 46:10 don't think people fully understand what a component model is and how it works and that basically means a lot of stuff 46:18 is happening magically by unity to kind of do things for you least of all the update function we have even gotten a 46:24 magic function don't want to get into that right now but this call in particular is well

worth knowing because people don't think 46:30 about it but what that getcomponent does like I said imagine you had a stack of books and you want to get a certain book 46:36 and someone said hey would you hand me that book and then the minute they say well they'll say do you have this book 46:42 and he would then search the list get the book and say yes I have this book then you put it back in the stack and then someone says can I add that book 46:48 you would they go through it again find the book and hand it to them you're doing the same thing twice arbitrarily that's costing extra cycles so

whenever 46:55 you call it get component you want to store the value of that so you can get back at it easier so you would remember 47:00 where it is and you can refer to it so if you ever find get component inside of an update loop what you're basically 47:06 saying is every time update is called walk through all the objects and then every time updates called walk through the objects again as some people might 47:13 say there's only one or two components on this object it's not that much of a walk well the one or two components now 47:18 and somebody might add more later and also if you've got 10 items and

they're all doing a walk of only two steps 47:23 that's still 20 steps you know like you're you're massively scaling that as you go so get component cache them in 47:29 your wake function let's do it let's catch this baby and we'll Charles is Awake Function 47:35 doing that I'll point out why I said awake function here's another interesting point based on the application model they're using a state 47:42 system a life cycle that's very similar to say Android and so what I mean by that is every single script starts with 47:50 there's a series of steps and there's a week and their start and then there's no 47:55 them I don't go to all

of them but the general point is awake happens then start happens and update happens and a lot of people don't realize is a wake 48:02 and start happen once for the lifetime of that object so if we had a wake start on enable update on disable no matter if 48:10 you toggle that object on and off what happens is the start will run once the awake will run once and the enable will 48:15 toggle on and off so it's caching the data for it and then there's using the data as you go forward so what you want 48:21 to do is anytime you want to use objects like this with get components you do it

in awake and the reason you doing awake 48:26 instead of start is every single awake call in your entire application runs before the first start call so if you've 48:33 got 50 scripts and you don't know which things would initialize first and which variables will be set what you want to do is want to make sure 48:40 that all the awake calls run so all of your data is cached and then the next thing the execute will be the start 48:46 function so do all of the the logical bindings in a week do all of your 48:51 configuration and start alright so we 48:57 push that up I was wondering why this was complaining it's

cuz it doesn't like that I called it rigidbody like it 49:03 doesn't understand that word so it'll be probably just a typo oh yeah I'm gonna 49:09 I'm just gonna add it to my user dictionary yes I didn't so thing now I can tell me what everybody is to answer 49:17 the question are there hidden components there can be worth noting transform is a component so you've already got one to 49:23 start with but there's things called display flags and so what you can do is 49:29 you can actually have object and a good example of this is if you use any kind of hierarchy tool so say you're installing cue hierarchy or our arrow

49:36 which hierarchy Pro or I think even master audio a few others do it what they'll do is they'll they need some object of hooking to so when your 49:43 application lifecycle starts so they will create an invisible object in your hierarchy and they will hide it so it's 49:48 actually there but you can't see it and there's a couple of others too so you can actually write a script yourself in 49:53 the editor which will iterate through the objects and toggle all the visibility flags to make them all visible if you're really curious but for 50:00 the most part it just boils down to there will be so many objects as well so yeah

that's worth knowing all right Wow 50:07 could you take a look oh I thought this whole thing was the if statement I was like no with all of that we have first 50:17 of all we've now cache that rigid bodies that's a good start yeah but it would 50:24 have been cool to look at the profiler to see it yeah you did that as an example of some things we'll make a Set Kinematic 50:29 video that demonstrates the difference between call and get component update versus what caching it yeah so next up 50:35 one thing that's worth noting line 32 right there is setting the rigid body to 50:41 kinematic that's fine but keep in

mind right with the whole lifecycle concept we talked about okay happens every frame 50:47 now this isn't a big deal it's not gonna cost you that much but it is going to call that every single up 50:53 what you can do if you're in control of that kinematic state you're better off having some function call that sets that 51:01 you know sets it to kinematic or sets it not kinematic right after what you're doing it's a state it doesn't need to be 51:06 constantly updating now I don't know the context this is in so I wouldn't bother extracting it now but just keep in mind when you're 51:11 designing something you should never really be

constantly updating something into a state disability in flood yeah 51:17 it'd be interesting to see if this is even if this is even needed yeah I wouldn't say it is there's an enable 51:23 physics method there so I would say that probably isn't actually been a necessary call but again it's not gonna break the 51:28 bank I wouldn't be too bothered which you know also goes into the readability of this code you know it's like what is 51:34 this doing why is this here there's no context and I you know I'm really big on self documented code you mean I've 51:42 thought I want to sound mean but no no offensive ever wrote this but

you know if you're gonna write a comment up here over the start method that says this 51:48 gets called the beginning of the frame why wouldn't you know something that's fairly obvious if you're a unity developer why wouldn't you put a comment 51:55 over this tell me what it does yeah in fact I would even go one step further and say this is a bad idea 52:01 mainly because there is a function called set kinematic which leads me to assume you can toggle kinematic on and 52:06 off and because this is being retried every update that's actually a bad idea 52:12 because what's going to happen is someone will say enable physics false they're in

the wait for seconds and that will immediately get reflagged back on 52:18 so enable physics that's actually a bug because if you if you do this enable physics it'll immediately fail again 52:24 outside of the other flag now I can guess what's happening is if you scroll up Charles do that yeah this should 52:31 assemble is meant to gate that so the is kinematics only meant to fire as soon as should assemble but that's something we 52:37 have to intuit by going back and forth realistically what you're saying is is when that when that's true is kinematic 52:43 is true so maybe that is kinematic should be in your should assemble function because that's what

the two 52:48 things are intrinsically tied to it shouldn't be part of the update yeah we 52:53 think about this things in here yeah one 52:58 don't log an update which is a bad idea but put it back for one second I wonder was put out a couple things first things first 53:03 a lot of people don't know this you can actually change just print instead of debug log that's an inherent built-in function exactly 53:08 the same thing just print quotes exactly the same nice a nice little shorthand if you're doing quick tests but began don't 53:14 use it I'm just letting you know it's there that's all it does I didn't adjusted yeah I

know most people that don't use it though let me tell you is 53:21 there cuz I think is interesting what else you can do here's more importantly if you are going to do a debug log it's 53:28 enough often time a hard time to find where that is so write debug log again actually and we'll look at the 53:36 autocomplete it's a debug log and you see there's a whole lot of options but the more I wanted me to point out there 53:42 is if you'll notice if you go to the top one there's an object context and that's really really valuable because what 53:47 happens is if you write a log and you put

an object in there a good example being literally this what will happen is 53:54 when you get the log message and you click it in the console it'll pane in the hierarchy it'll turn yellow and you'll actually see it so it not only 54:01 tells you there was a log but it'll tell you where in your code that log actually happened from so usually you want to put 54:08 the context in there for when you're logging it so but long story short episode of that donor's logs in updation 54:16 and even if you are we can get into stuff later but you want to do you want to create your own logger and you wanna

54:21 be able to toggle all logs off in one go you can even override the energy lager but I don't get into the complexities 54:28 left yeah oh yeah she did a video on that where I was I did a log Fernet 54:34 implementation that was interesting alright so I'm trying to figure out what 54:41 this this code does I think it's Jenga like you in the game Django where you pull the pieces out of the tower and it 54:47 falls down I think basically it's almost like at the end of the game when everything has fallen it it sets like a 54:54 flag to assemble yeah exactly 54:59 so it's interesting that Jenga piece

you see think of a piece and what is a piece 55:06 and the only real functionality in here is that it's responsible for putting itself back yeah and really what you'd Update 55:13 want to do is you have that original position you're probably better off having a call called move to the 55:18 and then in the Jenga tower you'd iterate through all the pieces and you tell each piece to move back and then flag when he's done rap but it's not a 55:25 bad like it's a fine solution the only problem is that because it's an update what's happening is every single update 55:30 you're saying you know move back move back I shouldn't move

back I should move back now okay I'm moving back and back 55:35 oh we're done occasionally it's just like the update is really happening relative to your framerate whenever 55:41 something's an update think about the fact that it's doing a lot of work now again I know we're being a bit pedantic because there are should've sample flags 55:48 but realistically you could have all of this code not in an update on the pieces 55:53 and then the only person who cares is the actual tower goes should I should I every bill to the rebuild no okay I 56:00 will tell everyone to rebuild all of a sudden you've cut out every single piece doing an

update the only person used to 56:05 update is the tower itself yeah so it's it's not a big deal performance wise but it's a nice it's logically more sound to 56:12 say give one person that job and what's what I think is important there is that in it being logically more sound I think 56:19 it makes more sense to a reader you know I when I think of a Jenga piece I don't 56:24 think that it's gonna crawl up and float up back into its own position you know I I would have I would envision someone is 56:31 responsible for gathering up all the pieces and placing them up and and that's where you know

in modeling real 56:36 life I would model a manager or the person who's responsible for putting it all back together at the end of the game 56:42 yeah usually you owned entities to be kind of small enough and in charge of exactly what affects them and things 56:48 like movement it may seem like that's the job of a single piece but somebody else will pick it up it's not really 56:53 like it has no momentum a driving force so yeah I don't point out though as we go forward we're not picking on this 56:59 code it's just a really good example of us go three it's the first thing we picked and we're going through

it very explicitly but 90% of unity devs I know 57:06 kind of code like this this isn't like there's nothing horribly wrong with any but we're saying these are just a few tips and tricks you pick up along the 57:12 way so this we're not we certainly don't mean to be complaining about this is perfectly fine code there are just 57:17 things you can do to improve I want to thank direct sea for allowing us to put it from putting himself out 57:23 there it's not easy and I don't want to think for for taking on your code here 57:29 maybe I should give like a like a promo code or like some unity assets

everyone who whose code so we 57:35 don't feel so bad about it maybe have some ruffle and give off some SS you know to anybody who you know everyone 57:41 everyone who puts the code and gets into a raffle and will get that the prize to somebody like editor console editor Pro 57:48 or something yeah exactly 57:55 all right cool right so I guess other than that I mean kind of one thing you 58:03 could do is well again we're kind of getting into semantics on some of this stuff is all of that code that's running 58:09 inside of an update function as Charles said you need to kind of read through it to parse

what it's doing you can just 58:15 give it a name if it's moved back to starting position make a function called 58:20 move to a certain position put all that code in it and then there's no real illusion as to what it's doing you know 58:26 extract well I take a whole lot even the even the if else you know because it's 58:32 like the whole checking if it's null and stuff you just just put the whole just so that's nice and very clear in the update you know yeah what's interesting 58:39 too is we were talking about how there should be something that manages these pieces if you look at the public 58:46 interface

it has one called set assembly so clearly there is some other script that knows about all the 58:52 pieces and call set assembly on all of them so it's already kind of like 58:58 positioned in a way that someone else is gonna make someone else knows when it's time to reposition so all you really 59:04 need to do is give that particular script some information about the starting positions and then there you go yeah you didn't go one step further and 59:12 have that tower build with the pieces and therefore pass itself in or even have a manager class to do but it's all 59:18 academic I wouldn't get too bogged down with that kind

of thing I mean you can get cute and you can you can define 59:24 different tower structures if you wanted to yeah well we're gonna call this again sorry I said starting research well 59:31 because it's moving move move to start or something like that moved to started positioned or something yeah 59:37 tada so it's a very small change we've done but if you look at it now it should be relatively clear if you shouldn't 59:43 assemble just do nothing otherwise loop starting position you gotta love writer if you all don't 59:49 use writer look at this it knows that we called this function in update so it's 59:54 telling me hey this is kind

of warning you this is called a LOF maybe doesn't need to be very nice alright 1:00:01 so I think for the most part I mean well actually here's something this is a 1:00:06 very good one right here so another little known fact if you look at line 65 especially in the case that this 1:00:13 function is a Co routine so it's been called frequently enough that wait for 1:00:18 seconds so the trick is right I don't get into the whole big thing between declaration and sensation but you create 1:00:26 a variable and then you use your sign AB you sign something to the variable then you use it the key word to that is new

1:00:32 so whenever you see the word new something is being physically nude up it's being created and in this instance there's a new wait four seconds of a 1:00:39 certain duration now this is fine because duration is a variable being passed in every time but a lot of people 1:00:45 don't realize this but you can cash that wait for seconds object so if you're doing an update loop that's in a while 1:00:52 loop or something and it's saying while this wait three seconds to keep waiting three seconds do whatever make a 1:00:58 variable and return the variable that way you're only creating the object once for the duration of all of the updates you're doing

now it doesn't make much 1:01:04 sense of this particular context I was wondering how you could update it no no I think you have to set it once but if 1:01:10 this if this was a duration that happened if it's always four seconds don't write new wait four seconds for 1:01:16 instead cache it and then use the same way ever done yeah that's cool yeah I thought about that please 1:01:22 enumerators are the wait call these coroutines yeah if that's a good man 1:01:27 actually you'd be surprised how much performance that actually Nets you if you're being very specific there's also 1:01:32 a similar one oxygen off a good one if you scroll up as

well to the update function another one it's not important 1:01:39 here because they're actually being interpolated both values the quaternion end or whatever and rotations a training event vector but most people don't know 1:01:45 this too there is a transformed set position and rotation so if you go underscore transform dot 1:01:57 set position it's a position and rotation this does is it literally cut 1:02:02 your calls in half so if you're if you've got some code happening in an update where you're doing position and rotational setting this will do both of 1:02:09 them in one call and it's again small performance net but it's a very useful to have if you're if you're doing that

1:02:17 know funnily enough that used to be an internal function that only unity had access to up until 17 I was brought to 1:02:24 the intention by the developers of inside when they did a talk on 1:02:30 performance issues and they mentioned that that's a private function that should have been made public and so I think they announcing it on stage at you 1:02:36 knife might have been the moment where he goes okay we'll make that one public yeah that's nice very good but again 1:02:44 obviously in this case we're interpolating so I wouldn't do the wouldn't work for what we're doing here yeah so do anything else you're spotting 1:02:56 there Charles except for

what bothers me personally it's the java naming conventions I'm sorry but you're killing 1:03:01 me call the method names the casing oh yeah 1:03:12 gosh didn't oh yeah how come that didn't its pascal case there instead of yeah 1:03:23 yeah it's not the end of the world again a lot of this stuff is nitpicking but it's a matter of consistency someone 1:03:28 else made a joke earlier about the bracketing formats and I don't think he realized he was doing it but Charles was fixing it as he went which is yeah so so 1:03:38 there's there's multiple languages have different patterning styles for brackets and stuff now it doesn't matter which one you use realistically but

if you 1:03:44 work in a certain language the people who are trained in that language will be more likely to use one of the other if 1:03:50 you if you work in Java people are more likely to use Pascal case method names and they're going to use the is it turn 1:03:58 I always forget the names but it's the bracketing case where the last the first brackets on the same line the next ones 1:04:03 but in c-sharp people are more likely to use that they're going to use uppercase 1:04:09 or it's called capital case I always forget but they're gonna basically use 1:04:14 capital letter for their method times it's just something to be consistent

on so go alright let's go Pascal is the starting letters lower I 1:04:20 minutes capital no that's camel case right sorry I'm complete your honor hands up Charles I got this right oh my 1:04:26 god no you gained a lot everyone's 1:04:34 calling you a wizard in the chat I'm just like removing these yeah very 1:04:41 helpful yeah so I call this one start start assembling but it does actually 1:04:46 shouldn't be start assembling it's like set assembling status I don't know what the heck what does it gonna be called 1:04:52 sure cuz it's true or false I'm gonna do 1:04:58 this okay yeah I don't mind starting to 1:05:09 stop assembling yeah actually yeah

sorry they're gonna do that you're gonna do the opposing one that's a good idea so so the reason Charles picked up on that 1:05:15 one is he noticed there was something in there called a flag variable and 1:05:22 basically you want to avoid flag variables because what they basically say is this thing does X if it's a Y and 1:05:29 Y if it's an X you're basically saying do this if it's true do the other thing if it's false and what happens is you 1:05:35 end up with this weird case where you'll have multiple ones of these and you have some method with true true false true or 1:05:41 something of that effect and it

makes no sense because it doesn't matter the what it does can be completely inverted if you change what the truth and false is 1:05:47 do so it's better practice to be very explicit and say do this to start it do this to stop it and then you do the 1:05:53 flags internally and if you want to do if you want to pass in a boolean you're better off actually managing that 1:05:58 yourself it's a small memory cost but saying if is assembling stop assembling else start as I'm going the the power 1:06:06 you get back from the readability of that for an entire team is far better than assembling true assembling false yeah we think

about this 1:06:15 it's an able physics after time out I don't know trying to make this make more sense from from someone who's reading 1:06:21 the code and like yeah it's like it doesn't it doesn't say anywhere that this is seconds you know you're just like oh I pass on a number what is that 1:06:27 milliseconds is it minutes is it yeah just think about all these things I see 1:06:32 this every day and my my day job code that I'm just like okay what is it what what's the end what does it stand for 1:06:37 yeah yeah that can never be a case of a confusion one day I will say this is a

personal thing 1:06:42 poor dick attention so people may really hate this it's something I do myself so this is a you do not take this as gospel 1:06:48 under standard rename that function for a second job that's what here yep do a 1:06:55 refactor rename on it you me dude like it straight up the reason I'm just calling it I'm just typing it oh yeah 1:07:01 it's not being called anywhere so well in that case put the capital C in the front of it 1:07:06 capital C like that yeah lowercase o o underscore no no just underscore it's 1:07:12 you know square oh you do like that now just like that that's how I always

do I know there's a very particular reason I 1:07:20 do this and the reason I do this is you should never call the co routine because when you call it a co routine what 1:07:26 you're saying is this is a piece of code that needs to run in unity inside of a start-over team so what I do is I use Co 1:07:32 underscore for the actual coding and then I make a function called whatever the name is so I might have Co underscore and they will physics and 1:07:38 then I will have enable physics and what is the name of physics do it calls start corroding Co underscore enable physics and that way I 1:07:45

decouple the fact that it's running a co routine from the fact that it has to be run as a code in again personal choice 1:07:51 but I find it's much easier to find out which calls can be called directly versus which ones are which ones are 1:07:56 meant to be rather coding I prefer and I since I'm driving I'm gonna go ahead and I prefer a pending co-routine at the end 1:08:04 of it that's fine that is my just don't like underscores and function it's just like it but the points the same right 1:08:09 we're both saying whenever it's meant to iran as a core routine you should somehow indicate that's a core routine 1:08:15

because people will get confused when they run it and expect you know it's not doing anything oh i forgot and you'll do this yourself 1:08:21 you will call a co-routine and go why isn't it working you'll go back and go I forgot to pass it into a start coding so yeah 1:08:27 for sure looks like it was being cold and I got lazy and didn't use the actual for factoring yeah so it's just it's all 1:08:35 about being verbose you know like what's my favorite well my favorite quotes from I think Martin Fowler is any any dummy 1:08:41 can write code a computer can read but it's it's hard to write code that a 1:08:46

human can read something like that yeah you're mean you're writing code for humans to digest here you know so you 1:08:52 just want to make it as clear as possible yeah coatings are very specific to the unity and you would never use 1:08:58 this function the way it's written in any other context so yeah it's very so like that I normally don't like using 1:09:05 any kind of prefix for for things but something like that sort of it's very 1:09:11 clearly indicates it has to be used in special case yeah in the interest of making stuff read 1:09:18 clearer as well if you happen to be working with dotnet framework version 4 1:09:25 or higher

you have a couple of nice syntactical tools at your disposal to make your code of it you know cooler 1:09:32 looking which Charles is our demonstrator right exactly yeah so this 1:09:37 what's funny is if you do the automated code cleanup it gets rid of that it does it maybe not I shouldn't I wasn't myself 1:09:44 it did it to me once or a couple times and I was like really I like the a whatever I guess I was wrong or maybe 1:09:50 they change it who knows I don't know like it did it back Oh interesting that's maybe you bet your stylesheet' your your style rule set 1:09:57 differently from mine yeah probably I

mean look format selection there's okay this three types strict format 1:10:03 compact format and spacious format yeah if you'd be spacious gosh what do you 1:10:10 think oh that it depends how long as I don't need it as much as you do but it's that's fine I can do that for now what 1:10:19 we're doing we're doing a compromise here yeah I definitely fun so oh look 1:10:28 someone asks what do you think of using summaries are you ready that's what I think 1:10:34 I mean if I was running like an API that I needed some other tool to automate the 1:10:40 creation of the documentation for because a whole bunch of people were gonna

use my API and I needed to make 1:10:46 sure that they weren't emailing me around the clock saying hey what is this - what is that - sure I'll make us I'll 1:10:52 use a summary but only because using that summary will allow me to generate a nice little webpage that you know has 1:10:58 documentation only because I don't want to be bothered by people asking me what it does that's you know that's what I 1:11:04 feel about summaries so yeah yeah personally I don't like I know what's a 1:11:10 cliche thing to say but where do your books go ebook trackers don't use to do 1:11:15 tasks don't write yourself lines tell yourself what

to do in your code where do comments go well your code 1:11:21 should be clear enough to read and if it's confusing you should have any documents associated with it to explain what it does at the point in the day 1:11:29 code is where your code goes and you can put comments in some people are very you know dogmatic about it and I really I 1:11:36 don't care enough it's not evil to put comments in your code it's not over like people who say your code must be self 1:11:42 commenting that's it that can be a bit of a meme when people say that but what they really mean is in theory in an 1:11:49

ideal world your code is clear enough to understand but it's perfectly allowed in the context of something being confusing 1:11:55 to annotate a good example of this is if you're using an algorithm that's not your own if you're calculating some mass 1:12:01 or some you're doing something like oh people you're generating fractal 1:12:08 patterns you might want to put a comment over the function to do that to explain what it is you're doing now you could 1:12:14 call it generate fractals but you might want to put a piece of code in to say you know this uses this particular algorithm things like that might be 1:12:20 interesting to kind of help a team understand what

you're doing so same with using constants like for example 1:12:26 you can create a variable called gravity and you know and use that in your code but if there's certain kinds of 1:12:31 constants which might not be well known to people you might want to explain why it's needed in certain algorithms so comments aren't evil you can use them 1:12:37 but if you're commenting to say this set helped this thing gets the health or this thing sets the hell it's like why 1:12:43 are you writing that it should be called set health to get health works you know comments should give you 1:12:48 information that lives outside the scope of the code you reading totally

agree I 1:12:54 don't know what I'm doing areas I went crazy on this refactor I was trying to 1:13:00 get rid of all these calls - I was trying to be dry but I think this is 1:13:05 kind of overkill you ask me no III tend 1:13:11 to do some other stuff yeah well I think it's sort of like you say I miss bum 1:13:17 position well it's sort of like you say like you know how the private modifiers and how I light you know it's like every 1:13:24 bit of information you add to a class every bit of code you add to it it just makes it that much more you have to read

1:13:31 and internalize and I almost think like this whole generate random position function that it's only job is to 1:13:37 provide variable for the random force vector function which is only used in this fling in random direction I almost 1:13:43 feel like it just takes away from what this Jenga peace class does yeah that's 1:13:49 where I'm like you know if I come and I look at Jenga peace class I don't expect to see generate random position or 1:13:55 random force vector like what the hell is that I'm gonna just be like what is this person doing here maybe fluid 1:14:01 random you know what I mean I'm sorry is this just still stopped as

a small side 1:14:14 note again we're not actually paid by writers despite what some people might think but it just happens to be very 1:14:20 good tool to use and what are the things that could popped into kind of the worth 1:14:26 pointing out there is if you scroll up one of the functions above is not being used and I can tell that at a glance cuz it's grayed out so on sixty-three there 1:14:33 you can tell I gave you all of these because they're it's just a it's just a single script that Charles copied in we're really low in this case we can't 1:14:39 do what does it add component menu is it the

one uh it's context many other 1:14:46 things what you're thinking of yeah it is no no just kind of don't you Scott - 1:14:51 yeah so that's a fun one actually in fact we 1:14:56 can probably demonstrate that yeah might as well take it full story so if 1:15:02 anyone's ever seen this context when you tip before it's really really handy if you want to test your code you can go 1:15:08 and do a whole if inputs get button down fire one run my script and test it or 1:15:14 you can give yourself something to click to actually test a function the the kind 1:15:19 of the long-winded way is you use a custom editor

and make a button and go through all that jazz but it's a lot of work for what basically boils down to I 1:15:25 want to run this code and it's usually not a good idea to have an update call which just does a if button test code 1:15:32 because then you're baking in that test into the script when it's not really part of the script instead you want to expose the ability to run that code 1:15:38 without having to actually make a test and that context menu will let you do is it'll when you create an instance of the 1:15:44 object and you have a script you're actually able to run that function without actually

having to create a 1:15:51 button for it by just using the drop-down menu on your sprouts I'm trying to make a Jenga piece here keep 1:15:58 keeping a thematic I like it dare I dare a let me just make a material to make it look oh god what are 1:16:05 you really scum on that you guys don't want me to design visible this blank 1:16:10 looking block we're programmers you're meant to have developer are it's not meant to look good 1:16:15 I'm gonna call my material this is a 1:16:23 very good question and I want told you to answer this first dress okay let's hear it what is your first best practice 1:16:28 that goes

out the window when you're in a hurry to develop something huh I don't write unit tests 1:16:34 that's that does that is definitely the first I think just because it's in fact 1:16:40 there's a lot of projects that don't warrant the full unit test practicing and we're not on a more granular level on a more practical typing code thing 1:16:47 let's talk about refactoring for example what we factors slash conventions you don't do when you're you know I mean you 1:16:55 sort of saw me do it here sometimes I don't always use the the shortcuts I'll just like rename a function and 1:17:00 everything will break and I'll have to go through piece by piece

and actually hand fix all of them the misspelled you 1:17:07 know method goals but you know that's one of those things where it's like no I guess not everyone is a power user a 1:17:12 writer like we are and so yeah that's one of them I I can think of some more 1:17:18 what do you got sounds like yeah might well my first one came to my mind when I read that was how I bind my objects and 1:17:24 we should cover this as a bob yeah okay someday okay tuck them in the code they're like really deep into the yeah 1:17:30 yeah look good when I'm when I'm doing it the right way I

like to have providers I have separate factories and things like that when I'm in a hurry I 1:17:37 will do what I do is normally I will put the requirements as children to me that 1:17:44 and I'll call the game object not find and it is a hierarchy tree walk what is a tree walk under a guaranteed subset of 1:17:49 a few small objects so it brings back the thing I said before the component system wherever humanly possible I try 1:17:54 to avoid walking the tree if I can pass a reference into an object without having to do any kind of search to find 1:18:00 it it's considerably faster and more efficient than doing any

kind of stepping through code if I'm in a hurry I will use game object I find and I'll 1:18:07 use get component only those two though I won't use find object by type and I won't use find out just in parent those 1:18:13 things can lead to some weird scenarios I'm not saying never use them you might need them in certain cases well I'm in a hurry I'll use either of 1:18:19 those or I'll use just a public field and I'll drag the reference in so yeah 1:18:24 there might there might like quick am in a hurry just just just get component everything just grab it I don't care I'll figure it out later yeah

yeah true 1:18:30 I think I'm getting a little too carry away here so I'm just one of the comments is the over-engineering 1:18:35 starting so I think you're setting a bad record look at that thing this is Jagger 1:18:41 what I see your goldbricks as well so it's it's the fancy rich Jake yeah I 1:18:47 messed up my pre fab here what the heck it's because they I removed this 1:18:52 whatever all right so what's an element ends the rigidbody to right well first of all show the component we have 1:18:58 actually gotten to that bed what yeah I component many of the whole thing you were doing oh yeah yeah all right so 1:19:05

here you can see it's probably really small too and I'll shoot let me move this over oh there he was to actually the assembly 1:19:12 functions already had them didn't even knows we mean start assembling stop something 1:19:19 oh my mistake sorry I thought so we got fleeing in a random direction and start 1:19:25 assembling and stop assemble which are the ones that we just added so I'll switch quickly yeah so quick and dirty 1:19:32 context menus will let you test your code really quickly very handy very useful for throwing things together uh 1:19:38 one of the comments there is do you use camera domain never never use camera 1:19:43 domain do not under any

circumstances can use it in the awake function to cache your camera so the way I tend to 1:19:51 do this just actually make it make it quick script there Charles and I'll show you sort of how I personally favor using 1:19:56 cameras in any script pretty much alright so some some test model behavior 1:20:01 yeah okay awake what I like to do is 1:20:09 yeah at first above that just do a public camera call it camp yeah and then 1:20:17 inside of twelve yeah go camera equals camera no camera equals camera and then 1:20:27 space double do it no do an old propagator equals camera and there we go and then 1:20:42 yeah so it'll

it'll it'll auto change it for you because I think doesn't want you using the null conditional it's the same 1:20:52 thing I personally prefer that syntax but it's a same code effectively what you're saying is if someone using my 1:20:58 script provides a camera to use I will use that camera if they have not provided me a camera to use assume 1:21:03 you're using the main camera so that's my go-to but there is public instead of serialized field well yeah probably 1:21:12 serialized private whatever it's fine I just didn't could it be quick it's not relevant yeah if you're gonna be really 1:21:17 specific fine but it'll be under spare camera and it'll be under

star camera double question mark so if you're gonna do the whole exactly how I write it and 1:21:24 SS - yeah exactly oops so that is literally 1:21:29 how I how I would use camera references and I would hide that warning because I don't care about it myself oh no I by the way I never use 1:21:36 expression bodies for these event functions I try not to yeah they can are you yeah cool so there's there's a you 1:21:45 can hide the inspections that doesn't matter but yeah so basically the point anyway is the fact that you give someone consuming your code the option to 1:21:51 provide an alternate camera otherwise you use camera domain

but you do it in a wake to cache it because if you actually 1:21:57 call camera dot main screen point array painter update you will be calling a 1:22:03 find object with tagged with every single call oh and it's worth noting I'm 1:22:08 that not actually in the hierarchy if you can click the camera mm-hmm am I 1:22:14 playing with a server because they're not gonna be able to see it yeah okay so the words camera dot main literally get 1:22:21 the camera where that tag is equal to main camera if you had that as untagged and you wrote camera dot main dot 1:22:27 whatever it will throw an exception you'll get an old reference

because it won't find it that's project that I ate 1:22:33 yeah it's part of the invisible magic that confuses people so it's not it's not a magic function it doesn't know 1:22:38 anything especially about your code it's literally just finding the thing with that tag called camera so be very 1:22:45 careful using it I only use it in the instance where someone else does not provide me one and even then I tend to 1:22:50 check for null but that should give you a good example of how to sort of use cameras in general yeah I'm putting this 1:22:56 over here all right so the next so if 1:23:02 we're gonna do this it needs to

have like a rigidbody right I think right 1:23:08 sure that's pretty much the only other thing it really needed yeah read your 1:23:14 body yet transform alright so uh let's see if we can make this thing do something cool oh and each one of these 1:23:20 pieces needs an original position that should be cached on the way craft should be created is it yeah I think you're 1:23:27 right okay alright cool perfect so do we have everything wait no I didn't update the original the 1:23:34 prefab oh my gosh I'm confused some confused by this because my defaults messed up what 1:23:41 do you guys think about my my default setup here curious because I

try to 1:23:47 model it after using IDs and blender all right cool so let me see here yeah why 1:23:55 isn't this updating I thought I updated the prefab variant rigidbody yeah okay 1:24:01 and component to the boom someone brings that up in the jabber bar component is a cool script add a fun fact on that one 1:24:07 as well just to be very careful with the invisible magic if you put require component on a script while the script 1:24:15 is already on an object it won't retro actively require that component for you dopes oh yeah I don't know no floor I 1:24:23 think drop gravity write an actual floor 1:24:29 give it a big

rectangle oh yeah uh I'm like screw physics alright who's that 1:24:38 that friend of mine Nick oh nice so yeah I'm gonna get a cooler accent like 1:24:44 you're clean boom you know I got the 1:24:51 planar material now no I'm just kidding I'm not going to see all righty 1:24:59 so now what I should be able to move it look I'm gonna play Jenga 1:25:08 alright so now we can go to one of these components here I think I can I not know just redo do 1:25:17 one tonight prove the point alright so we're gonna do a start assembling yeah oh well that's where the 1:25:25 the kinematic love to all be fling in

a random direction Oh freak oh yeah pretty 1:25:31 cool job and then uh let's put it back right start assembling cha nice okay so 1:25:36 yeah now can you talk can I walk it and do them all but this actually highlights 1:25:42 a very interesting point I gotta do I got a do fling 1:25:48 ooh look at this hey the fun factor I think we found it nice nice yeah okay but wait wait wait 1:25:58 before you okay this brings up an 1:26:04 interesting point that the first the first time you did that there is a small bug which was you picked one piece and 1:26:11 tried to get it to return but what was

happening was it was bouncing off the other stuff which were because the 1:26:17 kinematic things still kinematic so this kind of highlights the point you make conceptually think of each piece as an 1:26:23 isolated piece but the task of building a tower requires all pieces to do their job and so you'll inherently have a 1:26:30 confusing issue where things will clip in and jitter off each other unless they're all kinematic when the bill that 1:26:35 goes to happen so that's that looked exactly like a one piece coming back breaks the other piece so that sort of 1:26:41 proves the point that something like this should be a should be in a tower object that iterates

through make sure 1:26:48 everything's kinetic and runs them all because if you do it on a single piece you're gonna get three both like this 1:26:54 well I'm glad we didn't break it I'm glad the code still works after we after we reflect oh that was never any 1:27:01 question in my mind [Laughter] Wow all right that's great feels good I 1:27:11 think so let's let's do a little recap here so we did some optimizations right by caching the gate component and the 1:27:17 transform people and I always I sometimes forget that the transform is something you should cache we talked 1:27:24 about you know obviously some formatting here like just following c-sharp 1:27:30 Stander's

dotnet standards of putting the curly braces on their own lines it's 1:27:35 a point of contention or conversation or discussion whether or not you want to explicitly put the private modifier I'm 1:27:40 for it Jason's against it you and and of course we've got to talk about the fact that we have to use you know which 1:27:46 casing camel or Pascal which I know and 1:27:52 the most important thing to talk about that is that if you're on a team you should do whatever your team as a whole agrees on because that's clearly the 1:27:59 most important thing I will notice one thing cropped up during this though that didn't get the covers it's worth

mentioning so if 1:28:05 you're using the Unity engine random class you might occasionally hit a 1:28:10 really weird scenario that might confuse you and so delete that there think that line and we'll just explain a target 1:28:16 here because this will completely bad for me actually yeah so what happens is if you try to use random there's 1:28:23 actually two randoms there's a random class which lives in the system namespace part of c-sharp because a 1:28:28 random which lives in the unity engine namespace so what you can do traditionally you can write you know the 1:28:34 engine dot random dot whatever to get it to work but it's worth noting that they are different things

yeah and it's you 1:28:42 don't need to add them is a system 1:28:47 random it's that one's static I forget it no way around so system is the one that isn't static but the unity one is 1:28:53 static oh you get the idea yeah but the 1:28:59 point the point I want to get across here is that it'll usually what you want to do is you're gonna write Unity engine dot random dot range in most cases if 1:29:06 you're to avoid issues when you bring in the system interface or what writer will 1:29:12 do for you automatically which is another thing worth noting is you can use something what's called namespace aliases and it's where

you give 1:29:18 something a new name so a good example of this exactly it's perfect so what 1:29:27 that does is it says for the duration of this class the thing called unity engine 1:29:33 at random will not be known as random and you can do this for anything you like so as a good example you could say 1:29:40 you can you can call her but who you want to yeah and it doesn't just have to be run it can be your own types as well 1:29:47 whatever trust me everybody oh you you 1:29:57 could write say like go on the next line there great using my vector equals 1:30:06 vector three or you know

the engine defect history whichever cuz there's different one there you go 1:30:12 semicolon so now every time you write my vector it's as if you've written no no this is this specifically it's not a 1:30:18 writer thing this is actually a sharp thing so it'll work everywhere even in unity van outside unity the only reason 1:30:25 we mentioned writers still do it automatically for you if it knows that you're doing this with unity it'll it'll do it but you can alias anything you 1:30:31 like a good example of this that I use in practical terms on my code is if you're using an API you might have 1:30:38 something called a user so you're consuming

an API from the web that has a user and in your application you've got something called a user and the one that 1:30:45 you have has different properties and different things so what I like to do is say I'm using a Google API and getting 1:30:50 their users for sign-on so I will I will alias it to Google user and then I'll 1:30:56 have a user in my class and they're both technically called user and the compiler would complain if I tried to use both 1:31:01 things with identical names and go to different things so instead I hate is it to something that'll be easier for me to use yep so yeah I noticed that's

you're 1:31:08 using API is that you're constantly you know adding the model classes and you're like a crapshoot 1:31:13 what else could I call it other than what it is you know what I'm getting so cool well I think we done did it yeah 1:31:21 you got a lot coverage such a small script I have to say I didn't realize the deal would be like this is well so 1:31:29 all right those of you who came in through and are watching the vaad feel free to join her to score server my 1:31:34 camera just went off feel free to join our discord server and and drop your 1:31:39 coat off in a paste bin link

in the code review channel so I think I need to 1:31:47 think of a better way to do that because that for me they kind of get lost yeah yeah so we need to think of maybe a 1:31:53 submission maybe maybe people can post us get up and give that you know publicly making you can actually just 1:31:59 add a gist GIS T and it's just a github link to your individual files so 1:32:04 introducing source code which you should be using source control for your code I should say you you should be able to 1:32:10 give us a link directly to to the ones you want so we'll think of a way to get

these nice or submission process I mean 1:32:18 if you email them to Charles an infallible code comm that I'll definitely see it but you know we'll look in the discord 1:32:24 server before each stream and see what what was posted in the week prior yeah 1:32:29 so one of the comments is do you use namespaces and the answer is yes always 1:32:34 on everything that's a hundred percent that's probably a good thing to mention here too so for people who aren't 1:32:43 familiar with what namespaces really are they're literally everything you're seeing here using system that collection using unity engine using random these 1:32:50 are all namespaces and all the namespaces is think of it

like a folder for a single script but the difference 1:32:57 is the folders distributed across your files so everything in the same namespace all gets lumped into the same box and when you give your code to other 1:33:05 people you're at risk of having collisions with their stuff a good example of this being system dot random 1:33:11 and engaging a random like these are two different systems that exist in isolation that both want to have 1:33:16 something called a random and so it does it does you service and everyone else 1:33:21 who uses your code as service to namespace everything you do and that way people know it's Jason's not random for 1:33:29 everything to

do with that particular thing as for what you could use for a namespace I usually recommend you name 1:33:35 it based on the project or you name it based on what the actual thing is the concept yeah well I just used like 1:33:43 actually it would be it might be infallible code or it might be in this case it would be Jenga system Jenga game 1:33:50 yeah that way everywhere think it'd be honest I'm like well this is a game 1:33:55 first of all and it's in unity unity and it's a game here's an interesting thing 1:34:02 to note two of you guys are right or users you know this bothers the heck out of

me it'll be like hey did you mean project scripts is 1:34:10 that what yeah yeah hey when it does that you can more stop projects that's a 1:34:15 way you can do that is you can in the actual unity Explorer here on the left you can right-click the folder hit 1:34:20 properties and you just uncheck namespace provider and then it will no longer it'll no longer suggest that I 1:34:26 didn't know that I used to what I want you to do is I just turn off the suggestions for my namespace and say 1:34:32 I'll do my own it faces I don't know easier telling you do namespace but that's probably a better approach it 1:34:37

does similar complete that's what I always do I don't know why it's good it says move to global namespace there's good I think there's another way to like 1:34:43 actually say hey what what you want the project to to automatically namespace to but yeah that's yeah that's what I 1:34:49 always do and in the question of namespaces it can be obviously a bit tedious to wrap every single script you write in a namespace and this comes back 1:34:55 to what we said earlier make a new template file make a new base template 1:35:01 for your entire unity instance and every new monobehaviour you create will have a 1:35:06 namespace with your name on it and

sort of cleaner functions I will I will 1:35:12 actually post the link to the old video i wrote i made and i will call put it in the link in this description of this 1:35:18 video i wonder if this will work the i just set the root namespace of this project an in the actual like to go 1:35:24 to the you're gonna give it dangerous here i don't like messing with namespaces for that for all projects 1:35:30 you're gonna end up getting collisions with learn is to fail miserably 1:35:39 i want to call this doesn't like j it doesn't like jinguk as it doesn't it isn't how recognize that there's a word 1:35:45 look this

computer alright now it does a oh there you go well have it let me see if i make a new a new script so unity go 1:35:53 to scripts I'm gonna say add I know there's a model behavior here somewhere behavior C sharp script test script hey 1:36:03 look at did it okay something to explore 1:36:09 well how does you like that so if you go back to unity oh that's a good point make it again yeah I mean agreement I 1:36:17 don't recommend using your actual name for your namespaces I have done in terms of time and I usually do when I'm 1:36:22 releasing it as educational material or something just so that I

have a reference that people know where to go to get more information on it but if 1:36:30 you're a big built a library for people to consume don't put your name sometimes you have a company name you might use 1:36:35 again depends whether it's a product or something that people might want support for but as a general rule name it based 1:36:42 on the project it is so for example my technically my company name is called darker smile and I work with a 1:36:48 a contracting firm for producing projects called fire Panda and so 1:36:53 whenever we make work I will prefix it with fire panda DAF Jenga system and then it would be our

1:37:01 code inside of this particular project it's not complaining about it we'd read 1:37:08 something new today yeah until it until it blows up in your face cool all right well I think this is a 1:37:15 good time to wrap up the stream would we do it yeah I think we got through an awful lot more stuff let's so we're 1:37:22 gonna try I think we're gonna try to make these code reviews a weekly thing because they're they're been very this 1:37:27 was really fun and educational so I haven't picked day of the week yet 1:37:32 to do these streams but eventually I think probably starting in 2020 I'll have a better idea of like

hey look it's 1:37:39 gonna be every Tuesday at 3 p.m. Eastern Standard so keep an eye out for that in the meantime though if you just follow 1:37:44 me on Twitter and fallible code and then if you're on the discord server you will get a ping whenever we we are about to 1:37:50 go live so if we didn't answer your question obviously save them keep them in the tank we were probably gonna go 1:37:57 with the format of starting the stream with questions and then hopping on over to it like a code review and if we have 1:38:03 time we'll go to an either another code review or come back to questions so you should

do a GDD reviews what is that 1:38:11 game design document oh yeah maybe yeah that guy's potential 1:38:19 we'll see we'll see maybe maybe this maybe if you guys can write a small enough game design document that is like 1:38:26 really really small we'll just develop and develop a game based off your design 1:38:31 document just like hell no I mean yeah 1:38:36 of course when we're done you can take it and monetize it and you know just where does your code monkeys just free 1:38:43 contractors right well guys thanks again for coming out and we'll see you next 1:38:48 week for those of you in the u.s.

happy Thanksgiving happy holidays and we'll catch you guys later