CORRECTION: The sqrt instruction does not take 1 clock cycle. More like 20-60. It's still pretty fast though, and we don't have to check for distances often enough that this matters. CORRECTION: Combining meshes does not necessarily reduce draw calls. I think Unity does it to improve load times. SO WHY IS THE GAME SLOW? See: ua-cam.com/users/postUgwqYKf598HtLsnKV314AaABCQ I'm sorry for all the mic popping. :( Tried to fix it in post as much as possible, but we couldn't get all of it. About drawcalls: Unfortunately, Unity's frame debugger does not work on linux. -However, pointing the camera at all the students causes the game to render about 2 million triangles, and looking away makes the game render about 200k triangles. Don't need the frame debugger to deduce the problem here.- Apparently there is a lot I don't know about graphics engineering. Sounds like a good topic for another video.... UPDATE: I took a very brief look at the frame debugger on windows, and it pretty clearly explains why looking at students decreases the framerate so much. Here's a summary of what I found: - Students are drawn twice, using 2 different shaders, one without the toon outline, and one with the toon outline. - The student's irises have their own draw calls. Some irises have little shines in them, which are on another iris mesh, with their own draw call. - Each modular part of each student has it's own draw call. I've been working with Yandere Dev to optimize the game and bring the framerate up.
Put the mic on your chin. Leads to constant distance from your mouth. Leads to constant volume. If popping too much: Plosive filter. Can be DIY-ed. Also: Don't swallow the ends of your sentences. And put more effort into annunciation - Structure of video: Put more time into it - Transitions: Use consistent ones, with backgrounds that are less distracting - Text: You put up much more of it than is needed, leading viewers to have to pause often, and search for the difference. Simplify. - Thank you for making this video
I find it hilarious that the biggest file in the game is a model of a toothbrush that he just bought from an asset store and never noticed that it has polygons for every individual bristle.
@Bill Volk When I was in art school (like three years ago exactly), I had a part of a 3D animated shot where I had to build a bathroom scene. I couldn’t be damned to figure out how to make a toothbrush (because I was trying to model it hair by hair along the brush) so I went the easy and efficient route of getting a toothbrush asset. I watch this video and when he shows the toothbrush, it was the EXACT one I tried using in my project. The model shown was one of the results that showed it had tons of downloads by other users, which told me that tons of people found this model reliable, in specs, it said it was game-ready/animation file type, on top of that it was FREE, so I thought of course I would use it. When I loaded the model in, it was bigger than the character model (which are big models when loaded into scene/work environment) which I found strange, so I tried shrinking it. It slowed the program frame rate to a freeze for 3 seconds, for a model that has no animation rig, that said to me this is a REALLY hefty model polygons wise. My teacher saw what I was kerfuffling with and told me to delete the model from the project and we made one with less polygons and it took five minutes, she then told me that models like this are used for commercials, with CGI rendering and good for shots where you have a close up toothbrush and stuff for B-roll; shots where a camera encircles like a helicopter over a giant fucking toothbrush all cool and shit. She told me if I used this model it would take 10-15 minutes to quick compile (basically make a .mov file without rendering textures and stuff, which usually takes 2-3 minutes for a 10 second shot at the LONGEST).
@Bill Volk I just wanted to talk about a fun story coincidentally involving the same toothbrush model shown, but for TL;DR -The toothbrush shown is one I used myself and it was free, but meant for cgi commercials, meaning the problem of accidentally putting this in your project is more likely than you may think, from my personal experience
I’m a senior software engineer, so I feel qualified to say this video is very, very good. It really scratches the itch I have for technical deep dives that are actually entertaining. This video has the quality of video essayists with millions of subs and the code review quality is better than anything I’ve seen in a professional environment. I’ll be sticking around even if I have to wait months between videos.
I only use tools like UAE/UABE/DnSPY to create my own mods or have some fun editing values and seeing what the games do, but I never really got into the actual dev tools to create, just to edit. Even I was able to understand a large portion of this fellas breakdown, which I consider amazing, and I even learned a thing or two.
@Saitama Baldy was that supposed to be an insult to the OP because he dissed yandev with logic and facts, or are you just mad because you can't understand code? /nm
That reminds me of the situation with tinybuild, since he stopped working with them simply because he wouldn't have been able to update the game for a few months, even though it would've surely helped him a lot
@@ccbf1091 I'm pretty sure that's his excuse and the real reason is that he would have had to learn to code in order to work with a proper developer and he didn't like that. Also, TinyBuild was pretty clear about removing the lewd mechanics because they didn't want that on their brand.
He actively sabotaged the games progress in every way he could. Just imagine him not getting his patreon money which was purely for finishing the game. Even today he still gets 1.6 k monthly
Me who learned how to code python and a little bit of java in an online class in grade school but completely forgot everything: "I see, that is indeed correct!"
I don't understand 80% of what you're saying, but I deeply appreciate the polished visuals and editing, your natural charisma and calming voice, and how comprehensive I have to assume all of this is. I didn't even realize I had watched the entire thing until it was nearly done.
Same on the polished visuals; the presentation is top notch. Fun thing for me is it made realize I understand more about the hardcore concepts and details about programming than I thought. Like I thought it was a given that people knew about compilers optimizing conditional statements... Apparently I can humblebrag to myself that I am on the right side of Dunning-Kruger...
I don't know how much of it I understand (I'm a novice programmer), and I have no interest whatsoever in Yandere (whatever the fuck that is), C#, the unity engine or game development, but I found this to be an excellent and compelling technical presentation.
I'm inclined to believe that's because he just copypasted code from different people, but if he did that the code would probably be good so I don't even know
I can not stop laughing over the irony that one of the reasons people complain about framerate..... is that yanderedev implemented the framerate display so poorly that it displays lower frames than it actually has. (48:50)
I'm learning to code specifically for video games, and this video, despite expecting to see a well detailed criticism to YandereSims code, it ended to have a very high educational value for me, it helped me to understand many concepts and "why's" of things that I have only seen in paper, your visual editing adds a lot to understand it better. Thank you so much for this.
Same to me...I clicked this video for entertaining, but it ended up educating me. It taught me that why the things that I did not fully understand in sample codes are used.
He’s wrong tho. The compiler can optimize if there’s less than 5 if else statements. If he did the experiment with 5+ If elses then the results would be much different
@@Drizzle52693 Sure, but that will save how much? 1ms? Most of the problems of fps are in the render updates not in a bunch of if statements and bad coding practices
"The compiler is smarter than you." As an experienced software architect with decades of experience in this, you are 100% correct. I've only met a small number of people who could confidently claim to be smarter than a modern compiler (the compiler design professor at University, for one), but even he touts that modern compilers are so advanced that these minute optimizations are unnecessary. Make it work. Make it fast. In that order.
Sometimes I can write code in assembly that executes faster than the equivalent optimized c code. But I don’t do it often because it takes too long. Also I can almost always massage the underlying c or c++ to help the compiler make it more than fast enough
Just gonna say, as a coder myself this is probably one of the best video about programming I've seen on UA-cam, it's mind bogging that you don't have more content
It actually made me more confident about my own game. My code has lots of if else and switches and i was a litle bit scared of having bad performance. But now i undesrtand that this is something more of architechture than actually performance
Yeah people pay tens of thousands of dollars for deep dive reviews like this. Hopefully the dev will take the constructive criticism because he just got a free gold mine.
@@prithyachan333 Because you can save yourself a lot of time, effort, and headaches by just starting over from scratch completely and implementing everything properly. If you would actually clean up that source code entirely and properly there wouldn't be any of it left anyway.
@@prithyachan333 to be honest the whole "misconceptions about the code" bit seemed cringe, it seems like he was offended abut the elseif screeching when the vitriol against yanderedev primarily hinges on the abysmal development speed, his creepy behaviour, and his inability to take criticism The elseif screeching was nothing but decorative icing on the cake
Holy shit where did you COME FROM!? An hour of A1 editing, incredibly understandable concept presentation, insane amounts of knowledge/info on both Unity and computer science in general. This is crazy. This video has like several years worth of game dev knowledge/analytics shoved into it. You have under 100k subs, 2 videos, like what the hellll?!?! Your transition materials and songs are fucking well-found too. I don't understand where you came from bro, this is nuts.
Pred is that true? or is it just something you've heard with no evidence and you want to believe because you want to jump on the anti-yanderedev propaganda train full of lies and hate and like taking in all the drama, thinking youre actually contributing to something?
I never knew that this was what I've been missing in my life. I went fullscreen on this badboy, lay back in my chair and watched this shit like a nature documentary.
I liked your take on how everyone suggests converting the else ifs into switch statements. The problem isn't the style of large conditional statements, the problem is large conditional statements.
Exactly! And if you refer to Microsoft's documentation, switch statements are effectively syntactical sugar for if/else if/else chains! *A switch statement executes the statement list in the first switch section whose case pattern matches a match expression and whose case guard, if present, evaluates to true. A switch statement evaluates case patterns in text order from top to bottom.* -- Selection statements (C# reference)
@@skvader4187they probably are, but they're also so pretentious that I want to believe they only exist in hobbyist places and outside of workplaces in general..
4 роки тому+2589
The fact that this is the first "YandDev code review" that doesnt start with "I'm not a programmer/I don't use C-Sharp/I havent used Unity" its quite telling on most of the discourse on his code.
@@weakspirit_ compilers are literal magic and can optimize things you never thought about. but they can't fix everything, as seen in the video... and it's still better to try and write "good" code, not because it would run much faster but because it would make more readable and easier to work with. even if you just write something by yourself, if you choose stupid variable names, format stuff shitty, and don't add useful comments, you're not gonna know what is going on in your code if you stopped working on it for some time.
Trained game artist here, retopping the entire game, although a big job, wouldn't take as long as you might think. With a game that's not that detailed, this job wouldn't make a display difference really. I must admit, when you showed the polys on the models walking i just about had a fit. Unfortunately, Yanderedev doesn't pay and gives no credit so i doubt he'll get hold of someone able to retop these models to a decent degree.
Harrison Lane not really?? Most of them are made by some high school/college kid doing the models not knowing what in the candy fuck they’re doing and they optimize them super poorly like someone got ahold of some of the models and they had some baffling design decisions made
Exactly. The only thing we understand that the compiler doesn't is the underlying logic of the algorithm itself and that is what we're supposed to optimize.
It seems as though this game creator is just dragging ass until his devoted fans crowdsource the game into completion for him. Maybe the guy knows more now, but he doesn't seem to have known enough at the game's inception. However, the controversy is more interesting than the game itself, so maybe I shouldn't complain.
The compiler can actually be a pain in the ass leading to incorrect optimisation that breaks code. You then have to dig through the code and tell the compiler not to optimise certain things and stop breaking your code.
@@PeterG00000 1,2 million dollars in crowdfunding, 400 dollars spent on a sex doll and dressed it as a student in the game , a generous 3,5K monthly as his salary. Shit coding
Finally, someone that does know what he's talking about, I've been coding embedded C and assembly for some time now and people didn't seem to understand that some "best practices" things are for code readability not much for performance, since in the end it all gets converted to assembly (in C), and a similar thing happens in programming languages like C# and Java it gets turned into bytecode and something that can be executed by the JVM or C# equivalent.
@Jonathan Gomez Why do people keep saying that Java is slow? Yes, it is far slower than C, C++, and Rust. Sure. But in the grand scheme of things, it's pretty fast. Much much faster than languages like Python, Ruby, PHP, etc. Which are all used professionally. - Java is not a slow language by any means, it's just not a super fast one, either. (Oh, and also, Java can be compiled ahead of time, which would put it on par with C++. Nobody does that, though)
Sure, Java is not slow if you compare it to other slow languages... and systems being in use "professionaly" says little about their performance. The things you see in the field.... Compiling Java does not put it on par with C++ though. The runtime does a lot of runtime checking, and this goes into the build, while C++ does none of that nonsense and just slaps you with an exception when you do something you shouldn't. Java (the JVM actually) also has some greedy resource usage patterns, so it can hide it's low performance, while C++ can be very lean if you don't do anything silly, while still performing properly. On another topic, js is only verbose if you're doing it wrong. It's problem (or what most people starting in it struggle with) is not verbosity, it's the unusual object model (and shooting your own foot with all that type freedom).
Someone actually reverse-engineered the game to retrieve this man's Unity project. How suave. This video is better than the drama, and that is saying something!
This video really is the best in-depth review of the game's code. It's funny seeing all of the people who hopped on the analysis trend and had bona fides of taking a single comp sci class or just playing a lot of video games, so it's nice that there's a video resource out there that actually looks at the game's issue and addresses why they are issues rather than laughing at the length of a function.
You got me hooked in the first minute lol. “But before we begin, I want to make it clear - because the last time _it didn't get through your fucking skulls_ - NO BULLYING.”
about optimizing character models: the way you optimize them is by knowing how to prioritize polygons and use as few as possible without hurting the visuals, the character should be deisgned in a way where basic body parts that dont move (like forearms, thighs etc) have the least polygons while joints and features (elbows, knees, faces, maybe hair or some highlights on clothes) have more polygons to give more realistic animation for bends, twists and turns. They should also be constructed with a clear understanding of edge loops and how to effectively split features apart without "stitching" so it looks natural for arms to bend or strech or expressions to not interfere with other features or look half-baked. there are also several tricks that you can use to artificially make characters look better with textures, normal maps/height maps and shaders togheter with some other neat tricks, most of which can be seen in a+start's low poly series. of course im no proffesional or expert on this, i can be wrong about some things or using the wrong terminology, but its enough to get the point acorss. Making a model for a game is not as simple as making a model, slap some textures and a rig on and call it a day as long as it looks good enough.
@@victornecromancer I change my comment: it's hard to do it *right. It's easy to do *something** in unity, but it's a very different thing to do it right. Also thank you, but I as I said I don't want to make games :D It's boring to me and my creativity isn't the best either. I'll stick to good ol' desktop, web or Android development.
As someone holding a degree in coding i knew since the beginning that most people are just shitting on Yan dev for the sake of shitting on him without any understanding of code optimization and differences. IF statements are not the reason why his game is slow, but people doesn't care about fact checking when they want to cancel someone. .. NOTE: i still Think Yan dev deserves most of the hate due to how childish he handled the drama
Most people hate YandereDev because of his actions and toxic behaviour, not his coding. The "shitting on his code" part is usually to make fun of him, fyi I don't exaggeratedly shit on his code as other people do.
I'm glad I found this video, I had enough of people screaming about the code and not explain g what is actualy wrong with it. Also, I know nothing about coding, but you explained it so I could understand as well. Nice job! Very well made video.
@@caidenbond1988 Congrats you guys set variables! CodingLevelAtStart = 0 , CodingLevelForever = 0, CodingLevelAtEnd = 0 !!! Budding programmers already! You should now be at CodingLevel = 1!
@@RitsuAbyssgard Yeah but "any other person with basic knowledge of coding" only knows about the if-else argument, and only knows about it because they've just read about it somewhere
@@RitsuAbyssgard who said anything about appearance? plus, he showed us his thorough knowledge and experience, which is much more than basic knowledge, and much more than most of the "if else xdddd" circlejerkers.
Me as a game artist trying to understand this smart people wizardry "Oh yeah polygons i get polygons, haha funny fence amirite? haha, yeah, wait... floating poi- what? nopenopenopenope" I'M NOT STUPID! I CAN COLOR INSIDE THE CIRCLES OKAY?!?
You know, I really appreciate you pointing out the real problems with the code. It bothered me to hear people saying nonsense like "the code runs poorly because of elseif statements". I actually wrote the comment before I saw you address this specific point, and I really want to thank you again. As someone who works with code, I hate blind micro-optimisations. It's not the milliseconds of performance that should be chased when refactoring, but hours of development time.
The reason people cling onto that if/else stuff is, in my opinion, because it's the easiest to understand for a layman. The broad audience of criticism channels don't know much of anything about coding, but like to have an opinion and feel like they know something.
"BUT THE IF AND THE ELSE ISNT CLEAN LIKE THE BIG PRO CODERS DO IT. LIKE, I KNOW THERES CLEANER CODE THAN THIS, I DONT EVER SAW IT, BUT IT THERE AND THIS NOT CLEAN CODE!!!"
I mean, it just looks plain nightmarish to read. It's hard to fuck up performance with compilers that are smart, unless it's some sort of ground level thing, like loops within loops within loops doing something.
@@Obyvvatel Yeah, It is really important to keep things readable. I personally am kind of a perfectionist when it comes to this, and love making things more efficient even if the compiler already does it. I basically treat programming like an art form, even if that might sound kind of pretentious, but I find it a lot of fun. However, in this situation, the bad code wasn't the problem when it comes to why the game runs like shit...
Sorry i didnt see this video sooner. I hope you see this comment dyc3; Im a professionally trained 3D artist and i fux wit da unity. You missed some optimization techniques that i think are super important: Unity only culls occlusion outside of the cameras view. So behind the camera. If theres objects behind some objects within the camera cone of view those are not automatically culled out by unity. For that you need a plugin. Some optimizations you didnt mention, and please research: Sectors and portals: effectively unload all assets that are not in your current room or in any of the hallways connected to your room. Thats better than just occlusion culling because occlusion culling checks for mesh object visibility every frame. Sectors and portals disable those objects and their components so they dont have to report every frame. Also disabling colliders, physics objects, skinned meshes, animation controllers and audio sources, which otherwise wouldnt have been culled unless theyre attached to a mesh renderer component, which can make them stutter and create unpredictable bugs. Gpu instancing: unity has a default setting for this but i use a plugin, anyways you can render identical mesh objects with less draw calls using the gpu. It can allow you use just absurd numbers of similar objects on screen without hitting the frames per second. Theres also gpu instancing for skinned meshes (animated characters) which you need a plugin for. Imposters: replace a very far away object like an LOD would, but with a normal mapped super low poly plane which is still light interactive and you can strife the camera in circles around the object and it will still report accurately, updating the billboard as you move, at the full resolution of the mesh with it's shaders no less. Lightmap baking: you only need a few runtime lights at any given time and you can switch off the far away ones. That saves an assload of light calculations, static lights on static objects can be baked which looks just like a real time light except WAY WAY BETTER. and way more preformant. You can still have runtime lights and they'll be even more beautiful also. FixedUpdate(): is better if something can be called from a fixed update rather than an update, youll save a lot of performance because its running each physics frame which called much less frequently than render frames. I've been following all these yandere sim youtube critiques (but not the pedo fuel game itself) and ive been consistently impressed with the content I've seen from the game and its critiques. Unfortunately right now i have to work a real job so i can afford upgrades to my life, but when i get back to making games, i wanna hire you to review my code before release pwease and tank u.
Wow! Thanks for writing this big long comment. I made it a point to *only* talk about optimizations that would help *this game in particular*. The only thing I didn't talk about in the video was draw calls, because the frame debugger doesn't work on the linux editor. I thought Unity did frustum culling before occlusion culling. Is this not the case? It doesn't make sense to do occlusion culling for anything outside of the frustum. Occlusion portals are pretty heavily used already so I didn't mention it in the video. Gpu Instancing: Very cool, would probably be extremely helpful. I found out yesterday that the students are being drawn twice, and there's a seperate draw call for every modular part of the student (hair, iris, hair pins, etc.). Imposters: Also sounds useful, but I'm not exactly sure how practical it is to implement now. This also sounds like it would interfere with mesh combining. Lightmap baking: As far as I can tell, lighting is baked, and while there are 14 instances of UnityEngine.Light, I don't think most of them are enabled, because I can't find them in game. FixedUpdate(): You have to be *really* careful about using fixedupdate because if the framerate is low enough, the frequency of fixedupdate is actually *higher* than update. Not good for fps. According to the Unity documentation, Fixedupdate is made for adding forces to rigidbodies and such, which is not really how Yandere sim's code works. Feel free to DM me on twitter: twitter.com/rollthedyc3
@@rollthedyc3 Btw: I help YandereDev with optimizing the game. The game already does GPU Instancing and Static Batching. It used to do Dynamic Batching but I disabled it when switching from DX9 to DX11 because it was measurably slower. (I didn't try turning it back on after we jumped to Unity 2019.3, though. Maybe it's faster now. Testing that was one of my small items on the backlog.) There are some times when GPU Instancing breaks, though. Sometimes YandereDev adds a new material and forgets to check the GPU Instancing flag. Sometimes the object has a negative scaling, which forced Unity to disable batching and instancing (which I'm assuming is due to the winding order but Unity doesn't say)... but sometimes is big things like per-tree wind. I can fix that by writing a vertex shader instead of using the built-in wind system, but it's one of those "I need to stop YandereDev to implement it, and it needs to be at a time when I'm not helping other projects". But yeah... every dozen trees is 12 trees x 2 materials x 4 shadow cascades (basically cameras for shadow casters) = 96 draw calls... which should be 8 (or 4 if your toon leaves are opaque and just clipped with Alpha To Coverage or something). Lots of room to play in this space... including a low-quality shadow setting that sets shadows down from 4 to 1 cascade. There's a bunch of things that can be tried but it's a time thing... especially things that take a lot of time... especially things that take a lot of time and touch data files that YandereDev will also touch (like SchoolScene and StudentChan)... which means that he'd need to stop working on anything I'd change. Also, most of my tests with standalone builds shows rendering is not dominant (except if shadows are enabled of course). Not really sure why it's hitting you so hard. Also, lighting *is not* baked. That said, it's one directional light and an ambient fill, so it's not any slower than baked lighting. Toon is all about flat lighting because it's emulating an animator filling in a color, so flat, ambient fill makes sense. The extra lights are in the bathrooms, and they have a small range. They're there because Unity doesn't allow you to subtract lighting below the ambient (and you still can't, even in URP and HDRP)... so YandereDev drops the exposure and pushes the point light to compensate... which is why the bathrooms look weird.
@Robin Hoole -- dyc3 is correct. Unity does frustum culling, and then does occlusion culling after that (if you set it up by setting objects to static occluder/static ocludee and then bake the occlusion voxels). Unity licensed it from a company called Umbra back in the Unity 3 days. Unfortunately, it's also kind-of slow and awkward, so there are some assets to replace it.
Thanks for making this, dyc3. I’m a Sr. Software Engineer and all these people pointing at various small refactorings that wouldn’t even be mentioned in a rejected code review was making me frustrated. Sometimes in a production system you need to find the perfect performance to make your code fast enough, but over 90% of code most people write just doesn’t need all of the performance optimizations people were talking about. It’s almost as if they had never written a line of code for a real world software project with specs and deadlines. Sometimes these things just aren’t perfect but are still perfectly acceptable since they work well enough to get the code shipped. Given the amount of time he had, I’d expect things to be a bit better, though... but perhaps YandereDev either was an immature programmer or didn’t actually put a full 6 years worth of full time work into it (I suspect the latter but I don’t want to assume anything.) Anyway. Thanks again for making this. It was really interesting learning more about video game code optimizations in unity.
@Paul Kerrigan Yes, 100%. They do have a point that nested ifs and a ton of ifs everywhere is harder to read, but that's not really the point they make in the various videos. They act like it impacts performance when in the real world nobody cares that much unless it an idealistic thing where they're trying to save every cpu cycle for some strange reason. Like, I wouldn't tell someone it's best practice to not care about how you use your ifs vs switches, but it doesn't affect performance the way they're making it seem like it does.
Yeah it's easy for bedroom programmers to sit there and criticise code not being written perfectly for performance meanwhile in the real world it rarely matters and moving on to implement the next feature is more important.
@@einarengvoll using a lot of if-else statements makes the code look long and ugly (which is why people made fun of it) but it doesn't really make the game slower.
What I got from it is that yan dev doesnt know how to work with phiscal game asets and bones thus making the game slower, and the disorganisation making him take long on simpler tasks
This is one of the most quality code analysis videos I've ever seen. Really hoping you do more of these type of videos. Also a suggestion that would be interesting is Celeste's movement code where there are 5400 lines of code in one file.
as a software engineer student i found this video to be a freaking breath of fresh air. my god, YES, finally someone took some actual effort and looked into real architectural issues without constantly joking about if-else. even though the concept of a technical debt was one of the first thing to be even taught about at my university, i found this video to be really useful. yandev story is just a huge "how not to" in every possible direction. hope this video will bring a lot of people to your channel, you're amazing!
In regards to the IF vs SWITCH argument, this argument was the wrong thing to look at to begin with. It should never have been IF vs SWITCH, but why do you need so many IFs to begin with. Most of the time, you can completely remove long IF ELSE scenarios by using inheritance or programming patterns (like the component pattern). But that would require YanDev to know what classes are, and from looking at his students script, he does not. Thus, an architectural problem does become a performance problem, as "perform a check" is always more costly than if you need to do nothing at all. (That said, I'm not sure how much it would affect the actual performance if most of the long IF ELSE blocks were gone, but it would still speed up the game, even if only marginally.) Great video all around! It was fun and interesting listening to everything you highlighted.
This! A large reason why people always bash on elseif is to not tell yandev to use switch but to use other patterns and code that negates the need to have 50 elseif statements per student at all. You can SEE that the script for this game is taking up alot of the processing time if you go onto the game itself and turn on debug mode actively killing all of the background students besides the main character. The frame rate jumps up to 60fps and higher consistently. This is because the program doesn't have to constantly be doing those else if checks for each of the 100s of student per frame.
Using inheritance just moves the if-else somewhere else. It moves it to the vtable lookup, which *cannot* be optimized or predicted like an if statement can. A switch to inheritance can have benefits if and only if you are comparing the same state variables way more than necessary. If you use inheritance, the code will already "know" its intended behavior and thus won't have to check for what to do. Now for something like YandereSim, I think that yeah, inheritance would probably be the right option. But not necessarily for performance reasons. Architecturally, having a lot of different behaviors represented by just a few base functions is the perfect fit for inheritance. I don't think Components are a good choice here, because I don't see the possibility of modelling students' behavior using a component model. You would have to constantly check what components you have, which would create the convoluted if statements you were trying to avoid to begin with. Component models work best when you have lots of completely unrelated behaviors and data you want to join together.
The problem here (and it's a very huge problem) is purely ARCHITECTURAL. If you write code like that, implementing new features and fixing bugs is going to become a NIGHTMARE, and a really time consuming one at that. YandereDev clearly doesn't know design patterns, he just writes code because "lul I want to see this work!!!!". That's his mentality since he was fucking 15, and he never grew up. Seriously. This is a problem in a game of this scale. This is a problem.
The production value on this video for such a small and new channel is insanely high. I expected to scroll down and see a channel with hundreds of thousands of subscribers (at least!). Great video, you definitely deserve more recognition.
One of the few people that actually knows how to explain programming fundamentals in a concise and comprehensive way. I think if you ever decide to make turorial-like videos on Unity or coding in general they'll be a success.
Me before watching this video: maybe one day I can learn to code and make a game Me after watching this video: that’s going to be a lot harder than I thought
Isn't has to be, you can start without much of these things and learn them along the way, much of the stuff in this video stops being overwhelming once you understand a few key concepts and have some experience coding things
Welp, guess it's time to once and for all cross that one off the list of reasons to dunk on yanderedev (Unfurls 6ft scroll and crosses out a single line)
yeah that's a super cringey CS 100 level take. Obviously a switch statement is nicer to look at from a coding style perspective, but it's not going to improve performance lmao
@@prometheus5218 He literally linked this video in his new blog post and he has made many updates and optimization fixes in recent times. He definitely watched this video so new features will have better practice. Also, he is hiring a professional programmer to redo the code *if* he ever gets to the demo.
51:20 "The ritual used to pull this standard out of some poor engineer's ass" - Engineer dies in background That must be the most obscure TF2 reference ever, even I barely noticed it and had to rewind.
14:15 YES THANK YOU. All that talk about if-else annoyed me so damn much. Of course I didn't expect the other reviewers to go through this insane work you put into reconstructing the whole project, but it was really disheartening to see how much time they focussed onto such a minor formal issue. Sure many of those if-elses (or worse, pure if-concatenations even though the conditions are mutually exclusive) were in bad style, but it should be obvious to anyone with a little experience with optimisation that this is a drop in the bucket compared to the overall structural issues. Much of that branching nightmare could be replaced with polymorphism or state machines, much like the activity classes you propose.
Ok so I know this is essentially your first upload but...please make more of this for other things. Honestly, I find it hard to believe you don't have a second channel where you've done other shit because this video is *really* good and very well edited. I'd love to see more source code analysis, if the time to make this one didn't break you entirely.
hey! just wanted to return to this old video to say it’s truly amazing. i can tell you really know what you’re talking about and also really have a passion for it. your humor is totally great but still doesn’t impede on the technicality, which is really commendable. keep it up, man :-)
thanks for clearing up things, i've had a hard time transitioning from python to c# and it just seems like everyone when talking about yanderedev's code says "switch good elseif bad", and me not knowing much, just took the statement and started passing it around. this really sheds to light the actual workings of the code, and the actual flaws that need fixes
So apparently the dude linked this video so I watched it out of curiosity. Now, I know jackshit about coding, but one thing I've learned is that a lot of people that bitched about the code didn't fully know what they were talking about and just spewed out what other people said regardless if it was true or not. I actually learned something this morning and I thank you for that.
Well in my opinion seeing lots of if statements in an update function in a single unity script file is hard to read and it really can't be skipped if it is a bunch of if statements (unlike with if else statement that will skip the rest once a condition is true in the code block). The aim is to have a simple flow and structure by taking advantage of using object oriented concepts so that others can read it, easily know what things does which. In Jason Weimann's youtube video, I learned of a story he encountered where a game feature is (probably) 10k lines of code made by one guy for inventory system but their team took months to study it of what's causing the problem and it is just so brittle (one small thing changed can make it go fail) so it is simpler to just start from the ground up and divide things to conquer them. (The vid is titled "Why I switched from Unreal to Unity & wont go back"). I'm still new to unity even though I know other simple programming but learning is fun.
@@zamidare9038 like, the code definitely isn't easily human maintainable That's definitely a problem Stuff like that leads to human error and well, bugs. But like, if you try to compare it on runtimes, yeh, an if statement is like, O(1) runtime, this isn't a loop where, you can get something like o(n) 1 means straight through (means pretty fast) o(n) means runs n number if times I mean, every character is running this giant script, sure, but I think as this guy put it, unity has a pretty good game loop to run all this stuff on the update part of the loop Man, like, all these things yandere dev has issues with, architecture wise, these were all things I didn't learn in college, more so got my head bashed in by my project lead when I started my first job, lol. Like, I don't ever really have any motivation to play yandere simulator or lovesick, but ¯\_(ツ)_/¯ honestly it just sounds like the guy got into this without ever working with anyone on coding a game. Architecture stuff is something that would be worked out from a team environment when people start complaining that they can't work with all this stuff too coupled together to add new features I mean, at this point, he probably doesn't want to work on the game anymore considering all the stuff, I don't really care, just, :/ eyeah ¯\_(ツ)_/¯
@@zamidare9038 Same I'm relatively new to coding on Unity. I created a base project to test my code before doing my actual project. It was fun going back and reworking things to look as nice and neat as possible, the objective was to make it as easy as possible to add new content. Now I barely have to code anything when adding on to my game. Yeah, a lot of problems Yanderedev has can be assumed to be caused by bad organization, it works and frame rates will be good. However, it takes really long to add new content. Which can be a reason why his major updates are so slow. A UA-camr by the name of k gon looked through the assets in yanderesimulator, many unused models and the names were confusing, hard to match texture to model. I believe if Yanderedev restarts the project from scratch in the long run his progress might actually be faster, (I don't think he will). Organization is also potentially why Lovesick may progress quicker than Yansim/ how it took them so fast. Neat code may not improve gameplay but it goes a long way in helping yourself and adding new content.
@@FF18Cloud Reading the code of others and being able to know how hard it is to work in a team can only be encountered first hand in a group work (which is the case for me) where we have this guy in a java project in college who don't know what to do (but he can do things, just don't know what or how to contribute) so I just told him to do small things we can do easily and faster but he is a little bit of a bottleneck. While another guy is like brainstorming with me what we can do, add and how we divide the work then combine it later. Even though we're 3 only 2 can do nicely. Maybe if I placed the first guy into debugging instead that might helped more than giving him work to do in smaller easy things. The unfortunate thing is group work in code is probably only common to software engineering students in our university back then. But really in my opinion we've reached an initial point where we prefer faster coding than shorter code blocks for a faster prototype where execution speed wasn't placed into consideration yet which is fine.
@@franst3909 Well if you can barely have to code when adding to your game then that's nice. If it's me I can definitely see myself able to write a single main script that's a long lines of code in unity while the other supporting scripts are short utilities or managers but what I'm envious about from others is their natural capability to divide the working functions into different scripts or modules that will receive / process parameters passed and each will do one clear thing. That's why it's a bit hard since I'm mostly comfortable with C (and the old days of assembly, basic stamp, arduino, visual basic) where multitasking isn't really a main thing while C++ and java dives you into this flexibility of classes which means reusing code and then in C# they're in the form of scripts representing modules. As for your point of restarting the project from scratch in my opinion it is easy to think and reasonably so that that will help in the long run but there are things to consider. We won't know for sure if rewriting the original is faster unless it is tried and compared. Working from a clean state with the aim of converting original code will still need time and effort. Though I know what you mean. The thing that's going to become faster is the addition of new elements.
I remember years ago, when I was really invested in the very beginning of Yandere Simulator, Yandere Dev decided he wanted to query the community about optimizing his game and refactoring it to be better built and engineered, to optimize and refine the architecture and make development ultimately faster. It would take him 2 months of no updates to do it. I voted "yes you've got to do that", but the community overruled it by 66% saying "screw performance, I want features". Just goes to show part of what the POTENTIAL root of the problem of optimization probably was: pressure from the 'stakeholders' to output consumable updates, which just ended up drowning the project in the long term and pissing everyone off more.
funny, this could be an allegory on AAA gaming too in the sense that shareholders (the community) don't care about quality of the project and only want cool new fireworks
This is one of these things where you just DO NOT listen to people who know nothing about how the software is made. Literally had the same problem at my job last year. We got an old crappy codebase and a client who wanted new features NOW, we just ignored them, fixed the architecture and then work has been a breeze. Don't want to know what'd happen if we kept building on top of that pile of garbage.
Yandev is the adult, his fanbase are literal children. He SHOULDN'T ASK. He should ignore them. He's supposed to be in charge and he lets himself be bullied by his community all the time. He's too childish for this project to work
@@MariaLuiza-tp2dc I think inexperienced and unprepared is the fairer qualifier here. Completely agree that he should've just had a spine and known what was best for his project, but it's quite emblematic of the qualifications he did have for this. You've got to have the spine to stare people in the eye and tell them "No", but also the experience/mentorship to know that's required and how.
Let me preface this by saying I have absolutely zero love for Yanderedev. I don't mean that in a bullying way, and I'm sorry if it is interpreted as such. I also have zero knowledge of coding. I may not be able to fully grasp the level of detail that you go into with your analysis, but I think you've done an amazing job, and I think it's great that you are demystifying these myths that are likely made by people that have become sick and tired of Yanderedev, or people with their own beliefs and opinions on coding habits. This does not absolve him of (nor validate) everything, but it is wholly unfair to condemn him on points that are based on misinformation or untruth. Excellent job.
What a lovely video! Instead of the other videos that say that "IF STATEMENTS ARE BAD" but then give no fixes, you actually went in-depth and shown multiple fixes and improvements to the project. Plus, when I heard "The compiler is smarter than you", I mentally kicked myself for not thinking of that. Compilers are designed to be much faster and are more effective at optimizing "human-readable" code vs obfuscated code.
Uh.. dude, I’m surprised you don’t have more subscribers than you do. You have an unbiased outlook and your experience shines through. Hope to see your channel grow. Edit: typo
Went into this with the common "if switch" belief, but showing the tests you did very clearly and speaking unbiasedly, you really have changed my mind. Well done, love the teardown and honest discussion. 10\10
this was the nicest, most constructive, well manered and objective criticism and analyzis he got, i hope he will improve the code now based on this, great work
Man, thanks for this video!. Thanks to you, not only I see Video Game Development different now, but Programming as a whole!. This video is really one of those gems that you find once in your live. Again, thanks for this amazing video!.
As a gamedev it really bothered me watching UA-camrs that don't know much about dev critiquing "if else vs switch" and saying that was the reason the game was slow and "this is programming 101 stuff blah blah" This video is really really well done. Great work!!!
I'm just glad the big, highly edited videos focus more on yandev's behavior as well as the actual game design. Game's still problems, just that the coding isn't the real smoking gun.
As someone learning to code this was a great resource to me. Glad to see someone actually probably taking it all apart and seeing what’s wrong rather than just pointing out if else statements.
2:35 "I also ran hitman 2 a game who problems are similar to yandere simulator" That one phrase compared to the youtube commenters reveals alot about software development culture.
I'm really new to programming so I didn't understand a lot of the stuff in this video but it's really great to see someone knowledgeable explain it and tell people who don't code why it isn't as easy as what a lot of these people suggest all the time. I imagine if these people got to see the source code of some of the biggest games in recent years, they'd be surprised by how "sloppy" it is. It's probably structured better but I guarantee there's some really embarrassing code in many of the games we all play.
42:24 OH, I was *hoping* the last thing in the list would be "dying" again! Also, good video! You definitely have a way better idea of what drops Yandere Simulator's performance than others that just yell "ELSE IF ELSE IF" a lot.
thank you for like... ACTUALLY explaining everything in a very coherent way? i came into this video knowing NOTHING about game coding/coding in general, and came out of it with a better grasp on what gaming coding/coding actually is (and helped me understand what was ACTUALLY going on w yandere simulator) , thank u!
He already has made several videos discussing this. He used most of those as placeholder models. He has already changed almost all assets with original ones from volunteers. In fact, the most infamous model for Ayana is currently being replaced with an original model. In fact the uploader says he is working closely with YanDev rn to optimize. This has promise
@@iandrsaurri625 He refused the help of a indie game company because he didn't want to remade the code from zero, I don't think we should enable his behaviour at this point... He had every opportunity to hire professionals to help him and he just refused.
Ian Drsaurri Wasn’t that video quite old, kinda late. Plus, if you are referring to the video where he showed a picture of Ayano’s new model, that was STOLEN. He refused to credit the artist sometime ago, so she pulled out of volunteering. Yet, he used her model/mock-up in his video.
There's an interesting comparison to be had between Yandere Simulator and Wintergarten's Marble Machine X. Both projects have incurred massive amounts of Technical Debt over the years of their development, but while YandereDev holds onto his precious game code, Wintergarten (essentially) threw away the MMX that he spent years on so he can instead use the knowledge he gained from the first two machines to create a new, better one without the burden of his previous designs. Another interesting thing is that both creators are also the biggest critics of their own projects. YanDev could have done his fabled Kickstarter years ago (and it'd likely be wildly successful), but he doesn't feel like the game is close enough to his vision for that; and Wintergarten could've toured with the MMX and almost no-one would notice a few dropped marbles. Ultimately, I hope both projects come to fruition, but we'll have to wait at least a few more years for that.
I like this. It's very comprehensive with actual evidence. I also do agree with everything on this video. Yes, else-if vs switch is a red herring, but the real problem is the technical debt.
YO, I've been waiting for someone to do this! Like, as a graduating compsci student, i always thought it would be interesting to look at what we can learn, as to what would happen if you don't apply best practices.
Finally someone that went through everything manually instead of taking rumours as facts. Also, good job on debunking claims that were true technically, but didn't change anything in the grand scheme of things.
This video unironicly made me start a degree in Computer Science, half way done and just finished a large exam and passed showcasing understanding of C and a large range of data structures and algorithms :D
CORRECTION: The sqrt instruction does not take 1 clock cycle. More like 20-60. It's still pretty fast though, and we don't have to check for distances often enough that this matters.
CORRECTION: Combining meshes does not necessarily reduce draw calls. I think Unity does it to improve load times.
SO WHY IS THE GAME SLOW? See: ua-cam.com/users/postUgwqYKf598HtLsnKV314AaABCQ
I'm sorry for all the mic popping. :( Tried to fix it in post as much as possible, but we couldn't get all of it.
About drawcalls: Unfortunately, Unity's frame debugger does not work on linux. -However, pointing the camera at all the students causes the game to render about 2 million triangles, and looking away makes the game render about 200k triangles. Don't need the frame debugger to deduce the problem here.- Apparently there is a lot I don't know about graphics engineering. Sounds like a good topic for another video....
UPDATE:
I took a very brief look at the frame debugger on windows, and it pretty clearly explains why looking at students decreases the framerate so much. Here's a summary of what I found:
- Students are drawn twice, using 2 different shaders, one without the toon outline, and one with the toon outline.
- The student's irises have their own draw calls. Some irises have little shines in them, which are on another iris mesh, with their own draw call.
- Each modular part of each student has it's own draw call.
I've been working with Yandere Dev to optimize the game and bring the framerate up.
At least it went well from the early and midway portions. Though as it reached after that, it started to become more noticeable.
you are a god.
Didn't even notice :)
Put the mic on your chin. Leads to constant distance from your mouth. Leads to constant volume. If popping too much: Plosive filter. Can be DIY-ed. Also: Don't swallow the ends of your sentences. And put more effort into annunciation
-
Structure of video: Put more time into it
-
Transitions: Use consistent ones, with backgrounds that are less distracting
-
Text: You put up much more of it than is needed, leading viewers to have to pause often, and search for the difference. Simplify.
-
Thank you for making this video
@MJ you mean the 31 year old coder who linked this video on his wordpress and thanked this dude's help?
I find it hilarious that the biggest file in the game is a model of a toothbrush that he just bought from an asset store and never noticed that it has polygons for every individual bristle.
where/when does a toothbrush even appear in the game ????
@Bill Volk When I was in art school (like three years ago exactly), I had a part of a 3D animated shot where I had to build a bathroom scene. I couldn’t be damned to figure out how to make a toothbrush (because I was trying to model it hair by hair along the brush) so I went the easy and efficient route of getting a toothbrush asset.
I watch this video and when he shows the toothbrush, it was the EXACT one I tried using in my project. The model shown was one of the results that showed it had tons of downloads by other users, which told me that tons of people found this model reliable, in specs, it said it was game-ready/animation file type, on top of that it was FREE, so I thought of course I would use it.
When I loaded the model in, it was bigger than the character model (which are big models when loaded into scene/work environment) which I found strange, so I tried shrinking it.
It slowed the program frame rate to a freeze for 3 seconds, for a model that has no animation rig, that said to me this is a REALLY hefty model polygons wise. My teacher saw what I was kerfuffling with and told me to delete the model from the project and we made one with less polygons and it took five minutes, she then told me that models like this are used for commercials, with CGI rendering and good for shots where you have a close up toothbrush and stuff for B-roll; shots where a camera encircles like a helicopter over a giant fucking toothbrush all cool and shit. She told me if I used this model it would take 10-15 minutes to quick compile (basically make a .mov file without rendering textures and stuff, which usually takes 2-3 minutes for a 10 second shot at the LONGEST).
@Bill Volk I just wanted to talk about a fun story coincidentally involving the same toothbrush model shown, but for TL;DR
-The toothbrush shown is one I used myself and it was free, but meant for cgi commercials, meaning the problem of accidentally putting this in your project is more likely than you may think, from my personal experience
@@kittycat344 protags bedroom I believe.
@@kittycat344 it appears when you enter ayanos room its in senpais "shrine" which consist of shit she stole from him or things he threw away
Yandere's code can turn out to have educational value. His code should be on exams or homeworks and ask students to identify the problems
If that were the case they'd never finish
@@compositeembryo7186 LOL
That be the ultimate punishment of homework
*circles the entire test paper*
Student: Yeah Its...EVERYTHING
My man be lookin like coraline's dad.
Ya winning dad?
Are ya coding Dad?
No bullying >:(
/j
If you're watching this video you probably already look like coraline's dad :(
Prince of hell Elmo Floorgang gang
I’m a senior software engineer, so I feel qualified to say this video is very, very good. It really scratches the itch I have for technical deep dives that are actually entertaining. This video has the quality of video essayists with millions of subs and the code review quality is better than anything I’ve seen in a professional environment. I’ll be sticking around even if I have to wait months between videos.
@Saitama Baldy thankfully no. Never really had acne except for at age 13.
@@HydratedBeans soooooo, do you know animes and the concept of Yandere?
@@brtomassampaio yeah, but just the basics.
I only use tools like UAE/UABE/DnSPY to create my own mods or have some fun editing values and seeing what the games do, but I never really got into the actual dev tools to create, just to edit. Even I was able to understand a large portion of this fellas breakdown, which I consider amazing, and I even learned a thing or two.
@Saitama Baldy was that supposed to be an insult to the OP because he dissed yandev with logic and facts, or are you just mad because you can't understand code? /nm
"If he spent another hour on [this], it would have potentially saved him a couple years of grief."
That's it, that's the game in a nutshell.
That reminds me of the situation with tinybuild, since he stopped working with them simply because he wouldn't have been able to update the game for a few months, even though it would've surely helped him a lot
@@ccbf1091 I'm pretty sure that's his excuse and the real reason is that he would have had to learn to code in order to work with a proper developer and he didn't like that.
Also, TinyBuild was pretty clear about removing the lewd mechanics because they didn't want that on their brand.
@@vraolet i mean it's understandable. _Young_ _girls_ with lewdity is not something I'd want with my company. and yeah, I agree with that first part
He actively sabotaged the games progress in every way he could. Just imagine him not getting his patreon money which was purely for finishing the game. Even today he still gets 1.6 k monthly
@@vraolet also he didnt like the other dev/s "changing his code"
Me who doesn't know anything about coding: "Yeah, you're perfectly right."
Me who knows only a very minimal amount of coding, and only with java and nothing for Unity: "I guess you have a point, huh?"
Me who learned how to code python and a little bit of java in an online class in grade school but completely forgot everything: "I see, that is indeed correct!"
print (“Yandere Sim will never be finished.”)
else
end
end
end)
@envy lua language has end
@envy i mostly code in lua
I don't understand 80% of what you're saying, but I deeply appreciate the polished visuals and editing, your natural charisma and calming voice, and how comprehensive I have to assume all of this is. I didn't even realize I had watched the entire thing until it was nearly done.
Same on the polished visuals; the presentation is top notch. Fun thing for me is it made realize I understand more about the hardcore concepts and details about programming than I thought. Like I thought it was a given that people knew about compilers optimizing conditional statements...
Apparently I can humblebrag to myself that I am on the right side of Dunning-Kruger...
Me
@@computer_toucher l actually had the exact same thought after this video.
I don't know how much of it I understand (I'm a novice programmer), and I have no interest whatsoever in Yandere (whatever the fuck that is), C#, the unity engine or game development, but I found this to be an excellent and compelling technical presentation.
He's like a polished male version of Caroline Konstnar with a skill.
"Inconsistent use of tabs and spaces"
"F-ing pick one"
I felt that
I'm inclined to believe that's because he just copypasted code from different people, but if he did that the code would probably be good so I don't even know
what the fuck is wrong with him?
@@sewerside01142 maybe he was copying the code from stack overflow but, you know, from the questions
@@rayhimmel7167Mainstream C# IDEs run silent formatting passes when pasting code, so it's even more perplexing how he managed that.
fucking*
I can not stop laughing over the irony that one of the reasons people complain about framerate..... is that yanderedev implemented the framerate display so poorly that it displays lower frames than it actually has. (48:50)
LMAO is that fr?!!?
@@etam8099 ig he was trying to predict how slow it would be, thats funny
LMFAO
Ok let’s get to the bottom of this I’m going to run msi afterburner
He gonna cook this dudes code
'sort of implied that he didn't want me to do it'
'so I did it anyway'
You mad lad
Yanderedev will remember that.
Yanderedev is no longer available as a companion
R/madlads
[Everyone liked that]
@@alinagolovach7125 r/Boom boom
I'm learning to code specifically for video games, and this video, despite expecting to see a well detailed criticism to YandereSims code, it ended to have a very high educational value for me, it helped me to understand many concepts and "why's" of things that I have only seen in paper, your visual editing adds a lot to understand it better. Thank you so much for this.
same bro
@Olli Rolli other people made the mistake first so you don't have to do it too, you won't even get a prize for it just a headche
Same to me...I clicked this video for entertaining, but it ended up educating me. It taught me that why the things that I did not fully understand in sample codes are used.
Same, but it turns out dyc3 works for yandev so its ok
Yup, also don't listen to the other UA-camrs who claimed framerates are affected by too many if else statements
“don’t decompile my code”
“Ok, I’ll do it while you don’t watch
"a dark magic ritual known only to the compiler gods"
so like building any cmake project
pfffff, yeahhhhh
Soo... like blast beating in drumming? Cause that’s essentially a ritual in itself.
Till this day. I am not sure how did I manage to build llvm from source.
nah bro, that's easy, you call 'cmake .' and cry if it fails before finishing.
this.
Finally a real analysis of the whole thing! Not just "IF-ELSE bad, SWITCH good!!!"
Yay someone mentions how compilers can fix everything
He’s wrong tho. The compiler can optimize if there’s less than 5 if else statements. If he did the experiment with 5+ If elses then the results would be much different
@@Drizzle52693 Sure, but that will save how much? 1ms?
Most of the problems of fps are in the render updates not in a bunch of if statements and bad coding practices
@@neociber24 most of the fps drops come from his god awful ai pathing, if you disable the ai pathing your fps will jump up by a huge amount.
@@neociber24 even if it were 1 ms, 1 ms every frame is huge.
yo your music slaps, didn't realize you made all of it yourself
i've seen other creators use their own music because of demonetization
Oh dang
wait WHAT? He made all the music in the video himself? Wow...
"The compiler is smarter than you." As an experienced software architect with decades of experience in this, you are 100% correct. I've only met a small number of people who could confidently claim to be smarter than a modern compiler (the compiler design professor at University, for one), but even he touts that modern compilers are so advanced that these minute optimizations are unnecessary.
Make it work. Make it fast. In that order.
Sometimes people's attempts to outsmart the compiler can trip up the compiler so the code runs even _slower_ than "unoptimised" code would do.
"Trust the compiler" is to software what "never trust the autorouter" is to hardware
Make it understandable, but also make it efficient. At some point, a compiler can't turn shitty code into good code.
"The compiler is smarter than you." means you don't need to always try to outsmart the compiler every moment of your programming. People used to write
Sometimes I can write code in assembly that executes faster than the equivalent optimized c code. But I don’t do it often because it takes too long. Also I can almost always massage the underlying c or c++ to help the compiler make it more than fast enough
Just gonna say, as a coder myself this is probably one of the best video about programming I've seen on UA-cam, it's mind bogging that you don't have more content
I feel the same dogsong
considering the way he looks I'm surprised he has any viewers at all
@@firstname4337 considering the way you write, it is hard to believe you can write at all. Is this even a comment ? nice nick btw.
I'd take quality over quantity everytime. 😊 Keep up the informative work!
It actually made me more confident about my own game. My code has lots of if else and switches and i was a litle bit scared of having bad performance. But now i undesrtand that this is something more of architechture than actually performance
Is this... good faith criticism? Coming from knowledge and experience instead of guesswork? That exists?
Rycluse Yes it does exist
Boi i think it is what you say it is.
That's what happens when you're an actual professional, not a manchild joining in a circlejerk.
Yeah people pay tens of thousands of dollars for deep dive reviews like this. Hopefully the dev will take the constructive criticism because he just got a free gold mine.
I mean he does work for YanDev so why would he shame him over Miss Information?
"Painstakingly converted every if statement I could to a switch statement". You absolute mad lad.
A total waste of time.
@@thorham1346 Why do you think so?
@@prithyachan333 Because you can save yourself a lot of time, effort, and headaches by just starting over from scratch completely and implementing everything properly.
If you would actually clean up that source code entirely and properly there wouldn't be any of it left anyway.
@@thorham1346 I see. But they did that only to clear up some misconceptions. So I think they did a pretty good job.
@@prithyachan333 to be honest the whole "misconceptions about the code" bit seemed cringe, it seems like he was offended abut the elseif screeching when the vitriol against yanderedev primarily hinges on the abysmal development speed, his creepy behaviour, and his inability to take criticism
The elseif screeching was nothing but decorative icing on the cake
Holy shit where did you COME FROM!? An hour of A1 editing, incredibly understandable concept presentation, insane amounts of knowledge/info on both Unity and computer science in general. This is crazy. This video has like several years worth of game dev knowledge/analytics shoved into it. You have under 100k subs, 2 videos, like what the hellll?!?! Your transition materials and songs are fucking well-found too. I don't understand where you came from bro, this is nuts.
i think he has got 2 vids because he's more of a streamer, but i agree, the quality is dope and he deserves more subs.
This guy has professnals offering to work on his game for free and says no. No wonder he’s in the pickle he’s in
This ^^^^
THIS ^^^^^^^^
Also the fact he's a massive pedophile and creep
@@Pred. he's a pedo?
His backstories for the characters are quite, let's say, disturbing.
Pred is that true? or is it just something you've heard with no evidence and you want to believe because you want to jump on the anti-yanderedev propaganda train full of lies and hate and like taking in all the drama, thinking youre actually contributing to something?
I never knew that this was what I've been missing in my life. I went fullscreen on this badboy, lay back in my chair and watched this shit like a nature documentary.
Dude same. like, we finally get an UNBIASED look into whats really happening. Thank god i stumbled in this.
As a Unity noob, this was more helpful as a tutorial than many actual tutorials out there
lol
As a Unity noob, I have no clue what is even happening.
@SpyInTheBasement as a unity noob, what's unity?
as a Unity noob, I killed my entire family and am on the run
As a unity Noob, I have commited arson
I liked your take on how everyone suggests converting the else ifs into switch statements. The problem isn't the style of large conditional statements, the problem is large conditional statements.
Exactly! And if you refer to Microsoft's documentation, switch statements are effectively syntactical sugar for if/else if/else chains!
*A switch statement executes the statement list in the first switch section whose case pattern matches a match expression and whose case guard, if present, evaluates to true. A switch statement evaluates case patterns in text order from top to bottom.*
-- Selection statements (C# reference)
@@kylek.3689 if else is great if you need to compare stuffs too
you made me laugh a lot, thank you.
Most people saying that else If statements are bad, are people who are not game devs or programmers.
@@skvader4187they probably are, but they're also so pretentious that I want to believe they only exist in hobbyist places and outside of workplaces in general..
The fact that this is the first "YandDev code review" that doesnt start with "I'm not a programmer/I don't use C-Sharp/I havent used Unity" its quite telling on most of the discourse on his code.
@@weakspirit_ compilers are literal magic and can optimize things you never thought about. but they can't fix everything, as seen in the video...
and it's still better to try and write "good" code, not because it would run much faster but because it would make more readable and easier to work with.
even if you just write something by yourself, if you choose stupid variable names, format stuff shitty, and don't add useful comments, you're not gonna know what is going on in your code if you stopped working on it for some time.
@@weakspirit_ yha most if the drama around him is also bs
I mean it doesn't change the fact that the game runs like trash
@@a.n.l.aantineoliberalismas4504 no. No it's not. Dudes a dick.
DawnPraiser optimizing code doesn’t really help when it’s structure is god awful so awful no one can read it besides Yandere dev
95% of this went directly over my head, but I was still strangely entertained for an hour lol
That is what i call true intertainment
Same. If I understood that shit. I wouldn't be a mall cop.
I'm a programmer, and am still entertained. This guy has a good presentation.
i'm just here like "i made a website in notepad once"
Trained game artist here, retopping the entire game, although a big job, wouldn't take as long as you might think. With a game that's not that detailed, this job wouldn't make a display difference really. I must admit, when you showed the polys on the models walking i just about had a fit. Unfortunately, Yanderedev doesn't pay and gives no credit so i doubt he'll get hold of someone able to retop these models to a decent degree.
It's not just retopping these models. Iirc, entirely new ones need to be made, because these ones are from the unity store.
Harrison Lane not really?? Most of them are made by some high school/college kid doing the models not knowing what in the candy fuck they’re doing and they optimize them super poorly like someone got ahold of some of the models and they had some baffling design decisions made
@@bonelesscommunism4031 The majority of the models still are from the unity store.
@Yeah Itsme There are hundreds on the subject. Just search Model retopology.
@@bonelesscommunism4031 No most of them especially surroundings are just unity store bought assets.
"The compiler is smarter than you."
Completely valid statement.
Every programmer should have "the compiler is smarter than you" as their desktop background :p
Exactly. The only thing we understand that the compiler doesn't is the underlying logic of the algorithm itself and that is what we're supposed to optimize.
Fuck it. Ryzen 4K logo to remind Intel fanboys that i spend less money for equal, sometimes more performance
lol
It seems as though this game creator is just dragging ass until his devoted fans crowdsource the game into completion for him. Maybe the guy knows more now, but he doesn't seem to have known enough at the game's inception.
However, the controversy is more interesting than the game itself, so maybe I shouldn't complain.
The compiler can actually be a pain in the ass leading to incorrect optimisation that breaks code. You then have to dig through the code and tell the compiler not to optimise certain things and stop breaking your code.
@@PeterG00000 1,2 million dollars in crowdfunding, 400 dollars spent on a sex doll and dressed it as a student in the game , a generous 3,5K monthly as his salary. Shit coding
Finally, someone that does know what he's talking about, I've been coding embedded C and assembly for some time now and people didn't seem to understand that some "best practices" things are for code readability not much for performance, since in the end it all gets converted to assembly (in C), and a similar thing happens in programming languages like C# and Java it gets turned into bytecode and something that can be executed by the JVM or C# equivalent.
@Jonathan Gomez Why do people keep saying that Java is slow?
Yes, it is far slower than C, C++, and Rust. Sure.
But in the grand scheme of things, it's pretty fast. Much much faster than languages like Python, Ruby, PHP, etc. Which are all used professionally.
-
Java is not a slow language by any means, it's just not a super fast one, either.
(Oh, and also, Java can be compiled ahead of time, which would put it on par with C++. Nobody does that, though)
@@Yotanido I would even go so far as to say Java is the fastest non AOT language to exist in fact
@@Yotanido JavaScript is Amazing its a highly versatile language used in Buildbox 3 and Construct 3.
@@freelanceart1019 java and JavaScript are 2 different things
Sure, Java is not slow if you compare it to other slow languages... and systems being in use "professionaly" says little about their performance. The things you see in the field....
Compiling Java does not put it on par with C++ though. The runtime does a lot of runtime checking, and this goes into the build, while C++ does none of that nonsense and just slaps you with an exception when you do something you shouldn't. Java (the JVM actually) also has some greedy resource usage patterns, so it can hide it's low performance, while C++ can be very lean if you don't do anything silly, while still performing properly.
On another topic, js is only verbose if you're doing it wrong. It's problem (or what most people starting in it struggle with) is not verbosity, it's the unusual object model (and shooting your own foot with all that type freedom).
Excellent video. A solid in-depth look to this game.
Much appreciated!
You mean, mess. It's not even a game, it's just a walk and kill sim with a ton of messy assets everywhere.
@@G_Ryuji true
a shit video
@@G_Ryuji No you are talking about Lovesick now. We are talking about yansim, kiddo
This guy turned up, made a single million view video, then left. Absolute fucking hero.
Pointing out flaws in his game rendering times and then helping him opitimize them?? You're a true hero
the autocaptions don't know what a "yandere" is and it's very funny to watch them struggle with this word
40:38 when the automation gets it right
Yum dairy
Someone actually reverse-engineered the game to retrieve this man's Unity project. How suave.
This video is better than the drama, and that is saying something!
It's not really reverse engineering, it's just decompiled code
@@BreakTheBeat852 Close enough. 😎
Doesn’t really say something because the drama far from that
Wasn't the source code leaked?
@@fungo6631 Not really, its misinformed... The leaked code that is
This video really is the best in-depth review of the game's code. It's funny seeing all of the people who hopped on the analysis trend and had bona fides of taking a single comp sci class or just playing a lot of video games, so it's nice that there's a video resource out there that actually looks at the game's issue and addresses why they are issues rather than laughing at the length of a function.
You got me hooked in the first minute lol.
“But before we begin, I want to make it clear - because the last time _it didn't get through your fucking skulls_ - NO BULLYING.”
about optimizing character models: the way you optimize them is by knowing how to prioritize polygons and use as few as possible without hurting the visuals, the character should be deisgned in a way where basic body parts that dont move (like forearms, thighs etc) have the least polygons while joints and features (elbows, knees, faces, maybe hair or some highlights on clothes) have more polygons to give more realistic animation for bends, twists and turns. They should also be constructed with a clear understanding of edge loops and how to effectively split features apart without "stitching" so it looks natural for arms to bend or strech or expressions to not interfere with other features or look half-baked. there are also several tricks that you can use to artificially make characters look better with textures, normal maps/height maps and shaders togheter with some other neat tricks, most of which can be seen in a+start's low poly series.
of course im no proffesional or expert on this, i can be wrong about some things or using the wrong terminology, but its enough to get the point acorss. Making a model for a game is not as simple as making a model, slap some textures and a rig on and call it a day as long as it looks good enough.
And that's why I want to avoid game development as much as possible. It's hard man. And to me also boring.
@@matejpesl1 don't give up pal, there's no need to do everything in your game, just call some friends or hire someone that nails it for you
@@victornecromancer I change my comment: it's hard to do it *right. It's easy to do *something** in unity, but it's a very different thing to do it right.
Also thank you, but I as I said I don't want to make games :D It's boring to me and my creativity isn't the best either. I'll stick to good ol' desktop, web or Android development.
@@matejpesl1 in the end, when you delegate functions to other people, you can focus on what you're good at. Anyway, i understand you
@@victornecromancer wtf are you talking about
As someone holding a degree in coding i knew since the beginning that most people are just shitting on Yan dev for the sake of shitting on him without any understanding of code optimization and differences.
IF statements are not the reason why his game is slow, but people doesn't care about fact checking when they want to cancel someone.
..
NOTE:
i still Think Yan dev deserves most of the hate due to how childish he handled the drama
Most people hate YandereDev because of his actions and toxic behaviour, not his coding. The "shitting on his code" part is usually to make fun of him, fyi I don't exaggeratedly shit on his code as other people do.
Imaging caring about someone you have never met and never will.
to be fair, they didn't really have access to the profiler
Yandere dev isn’t gonna fuck you dude
@@lartts7483 yeah the whole segment this dude did on the "elseif criticism" is cringe
I'm glad I found this video, I had enough of people screaming about the code and not explain g what is actualy wrong with it. Also, I know nothing about coding, but you explained it so I could understand as well. Nice job! Very well made video.
This video really sounds like "common mistakes in game developpement" and for me as a beginner programmer it was really instructive
ur an unity wizard, my 7 years developing in the engine now feels like child's play
Unity is pretty hard for beginners considering so many option and version interations to choose from. Amazing but stability wise overwhelming.
@@freelanceart1019 what a weakling. Unity is peace of cake compared to Unreal Engine
@@madaraainna ha! what engine? I only know C, you weakling
@@phitc4242 shame on you, i write everything from scratch in binary. Imagine using pre-cooked languages, pathetic
@@ramster4459 okay okay... my comeback:
I designed my own cpu & cpu architecture MUWHAHA
I have no clue what you said, but I listened to every second of it.
Coding level at the start of the video: 0
Coding level at the end of the video: 0
Coding level forever: 0
@@caidenbond1988 Congrats you guys set variables! CodingLevelAtStart = 0 , CodingLevelForever = 0, CodingLevelAtEnd = 0 !!! Budding programmers already! You should now be at CodingLevel = 1!
@@jmanpolo5611 it's not the god of code status that's important, it's the semicolons we forgot to write along the way.
if (codingLevel == 1) {
console.log("Looks like you've still got a ways to go.");
}
@@TheDwarvenDefender nah do it in python
codingLevel = 1
if codingLevel == 1:
print("ya did it!")
FINALLY BRO someone who actually knows what they're talking about
@@RitsuAbyssgard Yeah but "any other person with basic knowledge of coding" only knows about the if-else argument, and only knows about it because they've just read about it somewhere
@@RitsuAbyssgard who said anything about appearance? plus, he showed us his thorough knowledge and experience, which is much more than basic knowledge, and much more than most of the "if else xdddd" circlejerkers.
@@CH3LS3A
Not gonna lie, that strawman made me laugh from this Anime lad. This person who responded seems like a total blimp in the head.
@@RitsuAbyssgard you are the reason people hate weeaboos
Me as a non coder: Haha lines go 🅱︎🆁︎🆁︎🆁︎🆁︎🆁︎🆁︎
Me, a normie: Haha FBI go 🅱︎🆁︎🆁︎🆁︎🆁︎🆁︎🆁︎
@@Cc99X_YT My man you gotta unsub to yandev bro it's not worth it to follow him anymore
Me, a coder: Oh, that's strange! What you'll find here is££&(-) -) /'/%%%%%@%@%###]]©¥
Me as a game artist trying to understand this smart people wizardry
"Oh yeah polygons i get polygons, haha funny fence amirite? haha, yeah, wait... floating poi- what? nopenopenopenope"
I'M NOT STUPID! I CAN COLOR INSIDE THE CIRCLES OKAY?!?
@@axcel8896 I sub, only to watch him fall.
You know, I really appreciate you pointing out the real problems with the code.
It bothered me to hear people saying nonsense like "the code runs poorly because of elseif statements".
I actually wrote the comment before I saw you address this specific point, and I really want to thank you again. As someone who works with code, I hate blind micro-optimisations. It's not the milliseconds of performance that should be chased when refactoring, but hours of development time.
The reason people cling onto that if/else stuff is, in my opinion, because it's the easiest to understand for a layman. The broad audience of criticism channels don't know much of anything about coding, but like to have an opinion and feel like they know something.
"BUT THE IF AND THE ELSE ISNT CLEAN LIKE THE BIG PRO CODERS DO IT. LIKE, I KNOW THERES CLEANER CODE THAN THIS, I DONT EVER SAW IT, BUT IT THERE AND THIS NOT CLEAN CODE!!!"
@@nates9778 it is a valid reason tho, it's important to keep your code clean if you want to update/modify it.
I mean, it just looks plain nightmarish to read. It's hard to fuck up performance with compilers that are smart, unless it's some sort of ground level thing, like loops within loops within loops doing something.
@@Obyvvatel Yeah, It is really important to keep things readable. I personally am kind of a perfectionist when it comes to this, and love making things more efficient even if the compiler already does it. I basically treat programming like an art form, even if that might sound kind of pretentious, but I find it a lot of fun.
However, in this situation, the bad code wasn't the problem when it comes to why the game runs like shit...
It's a tip of the iceberg type thing. If you make an elementary level mistake like this, who knows what you've done with more advanced functions.
His voice is a mix of ASMR and the nerd in class who only speaks when he's spitting facts
As someone who takes classes with him, you're entirely correct
@@amandaschmitt5019 Prove it
Sorry i didnt see this video sooner. I hope you see this comment dyc3; Im a professionally trained 3D artist and i fux wit da unity.
You missed some optimization techniques that i think are super important:
Unity only culls occlusion outside of the cameras view. So behind the camera. If theres objects behind some objects within the camera cone of view those are not automatically culled out by unity. For that you need a plugin.
Some optimizations you didnt mention, and please research:
Sectors and portals: effectively unload all assets that are not in your current room or in any of the hallways connected to your room. Thats better than just occlusion culling because occlusion culling checks for mesh object visibility every frame. Sectors and portals disable those objects and their components so they dont have to report every frame. Also disabling colliders, physics objects, skinned meshes, animation controllers and audio sources, which otherwise wouldnt have been culled unless theyre attached to a mesh renderer component, which can make them stutter and create unpredictable bugs.
Gpu instancing: unity has a default setting for this but i use a plugin, anyways you can render identical mesh objects with less draw calls using the gpu. It can allow you use just absurd numbers of similar objects on screen without hitting the frames per second.
Theres also gpu instancing for skinned meshes (animated characters) which you need a plugin for.
Imposters: replace a very far away object like an LOD would, but with a normal mapped super low poly plane which is still light interactive and you can strife the camera in circles around the object and it will still report accurately, updating the billboard as you move, at the full resolution of the mesh with it's shaders no less.
Lightmap baking: you only need a few runtime lights at any given time and you can switch off the far away ones. That saves an assload of light calculations, static lights on static objects can be baked which looks just like a real time light except WAY WAY BETTER. and way more preformant. You can still have runtime lights and they'll be even more beautiful also.
FixedUpdate(): is better if something can be called from a fixed update rather than an update, youll save a lot of performance because its running each physics frame which called much less frequently than render frames.
I've been following all these yandere sim youtube critiques (but not the pedo fuel game itself) and ive been consistently impressed with the content I've seen from the game and its critiques.
Unfortunately right now i have to work a real job so i can afford upgrades to my life, but when i get back to making games, i wanna hire you to review my code before release pwease and tank u.
Wow! Thanks for writing this big long comment. I made it a point to *only* talk about optimizations that would help *this game in particular*. The only thing I didn't talk about in the video was draw calls, because the frame debugger doesn't work on the linux editor.
I thought Unity did frustum culling before occlusion culling. Is this not the case? It doesn't make sense to do occlusion culling for anything outside of the frustum.
Occlusion portals are pretty heavily used already so I didn't mention it in the video.
Gpu Instancing: Very cool, would probably be extremely helpful. I found out yesterday that the students are being drawn twice, and there's a seperate draw call for every modular part of the student (hair, iris, hair pins, etc.).
Imposters: Also sounds useful, but I'm not exactly sure how practical it is to implement now. This also sounds like it would interfere with mesh combining.
Lightmap baking: As far as I can tell, lighting is baked, and while there are 14 instances of UnityEngine.Light, I don't think most of them are enabled, because I can't find them in game.
FixedUpdate(): You have to be *really* careful about using fixedupdate because if the framerate is low enough, the frequency of fixedupdate is actually *higher* than update. Not good for fps. According to the Unity documentation, Fixedupdate is made for adding forces to rigidbodies and such, which is not really how Yandere sim's code works.
Feel free to DM me on twitter: twitter.com/rollthedyc3
@@rollthedyc3 Btw: I help YandereDev with optimizing the game. The game already does GPU Instancing and Static Batching. It used to do Dynamic Batching but I disabled it when switching from DX9 to DX11 because it was measurably slower. (I didn't try turning it back on after we jumped to Unity 2019.3, though. Maybe it's faster now. Testing that was one of my small items on the backlog.)
There are some times when GPU Instancing breaks, though.
Sometimes YandereDev adds a new material and forgets to check the GPU Instancing flag. Sometimes the object has a negative scaling, which forced Unity to disable batching and instancing (which I'm assuming is due to the winding order but Unity doesn't say)... but sometimes is big things like per-tree wind. I can fix that by writing a vertex shader instead of using the built-in wind system, but it's one of those "I need to stop YandereDev to implement it, and it needs to be at a time when I'm not helping other projects".
But yeah... every dozen trees is 12 trees x 2 materials x 4 shadow cascades (basically cameras for shadow casters) = 96 draw calls... which should be 8 (or 4 if your toon leaves are opaque and just clipped with Alpha To Coverage or something). Lots of room to play in this space... including a low-quality shadow setting that sets shadows down from 4 to 1 cascade. There's a bunch of things that can be tried but it's a time thing... especially things that take a lot of time... especially things that take a lot of time and touch data files that YandereDev will also touch (like SchoolScene and StudentChan)... which means that he'd need to stop working on anything I'd change.
Also, most of my tests with standalone builds shows rendering is not dominant (except if shadows are enabled of course). Not really sure why it's hitting you so hard.
Also, lighting *is not* baked. That said, it's one directional light and an ambient fill, so it's not any slower than baked lighting. Toon is all about flat lighting because it's emulating an animator filling in a color, so flat, ambient fill makes sense. The extra lights are in the bathrooms, and they have a small range. They're there because Unity doesn't allow you to subtract lighting below the ambient (and you still can't, even in URP and HDRP)... so YandereDev drops the exposure and pushes the point light to compensate... which is why the bathrooms look weird.
@Robin Hoole -- dyc3 is correct. Unity does frustum culling, and then does occlusion culling after that (if you set it up by setting objects to static occluder/static ocludee and then bake the occlusion voxels). Unity licensed it from a company called Umbra back in the Unity 3 days. Unfortunately, it's also kind-of slow and awkward, so there are some assets to replace it.
Is your native language English because the grammar is not the best (just asking)
@@perisleaf I'm impressed
I was waiting a 10 min critisism instead I found a highly educational 1 hour video. I learned A LOT. Thank you and do more of this thing
Thanks for making this, dyc3. I’m a Sr. Software Engineer and all these people pointing at various small refactorings that wouldn’t even be mentioned in a rejected code review was making me frustrated. Sometimes in a production system you need to find the perfect performance to make your code fast enough, but over 90% of code most people write just doesn’t need all of the performance optimizations people were talking about. It’s almost as if they had never written a line of code for a real world software project with specs and deadlines. Sometimes these things just aren’t perfect but are still perfectly acceptable since they work well enough to get the code shipped. Given the amount of time he had, I’d expect things to be a bit better, though... but perhaps YandereDev either was an immature programmer or didn’t actually put a full 6 years worth of full time work into it (I suspect the latter but I don’t want to assume anything.)
Anyway. Thanks again for making this. It was really interesting learning more about video game code optimizations in unity.
He spends most of his time streaming video games on Twitch.
@@Benjy52 wrong.
@Paul Kerrigan Yes, 100%. They do have a point that nested ifs and a ton of ifs everywhere is harder to read, but that's not really the point they make in the various videos. They act like it impacts performance when in the real world nobody cares that much unless it an idealistic thing where they're trying to save every cpu cycle for some strange reason. Like, I wouldn't tell someone it's best practice to not care about how you use your ifs vs switches, but it doesn't affect performance the way they're making it seem like it does.
It's a useful tool, but when used entirely by itself it's fucking nonsensical
Yeah it's easy for bedroom programmers to sit there and criticise code not being written perfectly for performance meanwhile in the real world it rarely matters and moving on to implement the next feature is more important.
Finally a video that doesn't blame the performance issues on if-else statements.
Are those bad?
@@einarengvoll Compilers usually optimize them, so the supposed 'disadvantages' aren't a big deal anyway
@@einarengvoll using a lot of if-else statements makes the code look long and ugly (which is why people made fun of it) but it doesn't really make the game slower.
What I got from it is that yan dev doesnt know how to work with phiscal game asets and bones thus making the game slower, and the disorganisation making him take long on simpler tasks
@@Alesan99 this, so much this! It annoys the hell out of me that people who aren't even programmers keep beating that dead horse.
Finally a review that isn't just "he's allergic to arrays" and "too many if statements" nice and in depth, sexy video
i agree with all, but i agree with the sexy part the most
@@jammiejammed ayyy you get it :)
Funny thing is, the game is crammed full of automatically generated arrays because of all the Drag'n'Drop.
This is one of the most quality code analysis videos I've ever seen. Really hoping you do more of these type of videos.
Also a suggestion that would be interesting is Celeste's movement code where there are 5400 lines of code in one file.
Finally a competent code review
as a software engineer student i found this video to be a freaking breath of fresh air. my god, YES, finally someone took some actual effort and looked into real architectural issues without constantly joking about if-else.
even though the concept of a technical debt was one of the first thing to be even taught about at my university, i found this video to be really useful. yandev story is just a huge "how not to" in every possible direction.
hope this video will bring a lot of people to your channel, you're amazing!
In regards to the IF vs SWITCH argument, this argument was the wrong thing to look at to begin with.
It should never have been IF vs SWITCH, but why do you need so many IFs to begin with.
Most of the time, you can completely remove long IF ELSE scenarios by using inheritance or programming patterns (like the component pattern).
But that would require YanDev to know what classes are, and from looking at his students script, he does not.
Thus, an architectural problem does become a performance problem, as "perform a check" is always more costly than if you need to do nothing at all. (That said, I'm not sure how much it would affect the actual performance if most of the long IF ELSE blocks were gone, but it would still speed up the game, even if only marginally.)
Great video all around! It was fun and interesting listening to everything you highlighted.
This! A large reason why people always bash on elseif is to not tell yandev to use switch but to use other patterns and code that negates the need to have 50 elseif statements per student at all.
You can SEE that the script for this game is taking up alot of the processing time if you go onto the game itself and turn on debug mode actively killing all of the background students besides the main character. The frame rate jumps up to 60fps and higher consistently. This is because the program doesn't have to constantly be doing those else if checks for each of the 100s of student per frame.
Agreed! Multiple nested if-else statements also lead to some DEEP indentations which also messes up code readability that much.
Is there any video/tutorial/infographic that would explain how to escape the IF ELSE IF IF IF IF ELSE IF IF ELSE hell?
Using inheritance just moves the if-else somewhere else. It moves it to the vtable lookup, which *cannot* be optimized or predicted like an if statement can.
A switch to inheritance can have benefits if and only if you are comparing the same state variables way more than necessary. If you use inheritance, the code will already "know" its intended behavior and thus won't have to check for what to do.
Now for something like YandereSim, I think that yeah, inheritance would probably be the right option. But not necessarily for performance reasons. Architecturally, having a lot of different behaviors represented by just a few base functions is the perfect fit for inheritance. I don't think Components are a good choice here, because I don't see the possibility of modelling students' behavior using a component model. You would have to constantly check what components you have, which would create the convoluted if statements you were trying to avoid to begin with. Component models work best when you have lots of completely unrelated behaviors and data you want to join together.
The problem here (and it's a very huge problem) is purely ARCHITECTURAL. If you write code like that, implementing new features and fixing bugs is going to become a NIGHTMARE, and a really time consuming one at that. YandereDev clearly doesn't know design patterns, he just writes code because "lul I want to see this work!!!!". That's his mentality since he was fucking 15, and he never grew up. Seriously. This is a problem in a game of this scale. This is a problem.
The production value on this video for such a small and new channel is insanely high. I expected to scroll down and see a channel with hundreds of thousands of subscribers (at least!). Great video, you definitely deserve more recognition.
One of the few people that actually knows how to explain programming fundamentals in a concise and comprehensive way.
I think if you ever decide to make turorial-like videos on Unity or coding in general they'll be a success.
Me before watching this video: maybe one day I can learn to code and make a game
Me after watching this video: that’s going to be a lot harder than I thought
Watching someone doing code is already overwhelming.
Isn't has to be, you can start without much of these things and learn them along the way, much of the stuff in this video stops being overwhelming once you understand a few key concepts and have some experience coding things
Finally somebody actually debunks to code and not says "iF elSe deCreaSe PeRFormance!!!" like every other person. Thank you for this video.
Welp, guess it's time to once and for all cross that one off the list of reasons to dunk on yanderedev
(Unfurls 6ft scroll and crosses out a single line)
yeah that's a super cringey CS 100 level take. Obviously a switch statement is nicer to look at from a coding style perspective, but it's not going to improve performance lmao
Who cares. Even if you know solutions to improve fps Yandev will not listen at all
@@rburk854 Yeah, it's sad that misconception even resulted to the "if-else" meme, should've just stuck to the cum chalice meme.
@@prometheus5218 He literally linked this video in his new blog post and he has made many updates and optimization fixes in recent times. He definitely watched this video so new features will have better practice. Also, he is hiring a professional programmer to redo the code *if* he ever gets to the demo.
51:20 "The ritual used to pull this standard out of some poor engineer's ass" - Engineer dies in background
That must be the most obscure TF2 reference ever, even I barely noticed it and had to rewind.
me watching as if i know about anything he’s talking about: 👁👄👁
Mood
mood
Mood
Mood
Mood
14:15 YES THANK YOU. All that talk about if-else annoyed me so damn much. Of course I didn't expect the other reviewers to go through this insane work you put into reconstructing the whole project, but it was really disheartening to see how much time they focussed onto such a minor formal issue. Sure many of those if-elses (or worse, pure if-concatenations even though the conditions are mutually exclusive) were in bad style, but it should be obvious to anyone with a little experience with optimisation that this is a drop in the bucket compared to the overall structural issues. Much of that branching nightmare could be replaced with polymorphism or state machines, much like the activity classes you propose.
Ok so I know this is essentially your first upload but...please make more of this for other things. Honestly, I find it hard to believe you don't have a second channel where you've done other shit because this video is *really* good and very well edited. I'd love to see more source code analysis, if the time to make this one didn't break you entirely.
hey! just wanted to return to this old video to say it’s truly amazing. i can tell you really know what you’re talking about and also really have a passion for it. your humor is totally great but still doesn’t impede on the technicality, which is really commendable. keep it up, man :-)
thanks for clearing up things, i've had a hard time transitioning from python to c# and it just seems like everyone when talking about yanderedev's code says "switch good elseif bad", and me not knowing much, just took the statement and started passing it around. this really sheds to light the actual workings of the code, and the actual flaws that need fixes
So apparently the dude linked this video so I watched it out of curiosity. Now, I know jackshit about coding, but one thing I've learned is that a lot of people that bitched about the code didn't fully know what they were talking about and just spewed out what other people said regardless if it was true or not.
I actually learned something this morning and I thank you for that.
Well in my opinion seeing lots of if statements in an update function in a single unity script file is hard to read and it really can't be skipped if it is a bunch of if statements (unlike with if else statement that will skip the rest once a condition is true in the code block). The aim is to have a simple flow and structure by taking advantage of using object oriented concepts so that others can read it, easily know what things does which. In Jason Weimann's youtube video, I learned of a story he encountered where a game feature is (probably) 10k lines of code made by one guy for inventory system but their team took months to study it of what's causing the problem and it is just so brittle (one small thing changed can make it go fail) so it is simpler to just start from the ground up and divide things to conquer them. (The vid is titled "Why I switched from Unreal to Unity & wont go back"). I'm still new to unity even though I know other simple programming but learning is fun.
@@zamidare9038 like, the code definitely isn't easily human maintainable
That's definitely a problem
Stuff like that leads to human error and well, bugs.
But like, if you try to compare it on runtimes, yeh, an if statement is like, O(1) runtime, this isn't a loop where, you can get something like o(n)
1 means straight through (means pretty fast)
o(n) means runs n number if times
I mean, every character is running this giant script, sure, but I think as this guy put it, unity has a pretty good game loop to run all this stuff on the update part of the loop
Man, like, all these things yandere dev has issues with, architecture wise, these were all things I didn't learn in college, more so got my head bashed in by my project lead when I started my first job, lol.
Like, I don't ever really have any motivation to play yandere simulator or lovesick, but ¯\_(ツ)_/¯ honestly it just sounds like the guy got into this without ever working with anyone on coding a game.
Architecture stuff is something that would be worked out from a team environment when people start complaining that they can't work with all this stuff too coupled together to add new features
I mean, at this point, he probably doesn't want to work on the game anymore considering all the stuff, I don't really care, just, :/ eyeah ¯\_(ツ)_/¯
@@zamidare9038 Same I'm relatively new to coding on Unity. I created a base project to test my code before doing my actual project. It was fun going back and reworking things to look as nice and neat as possible, the objective was to make it as easy as possible to add new content. Now I barely have to code anything when adding on to my game.
Yeah, a lot of problems Yanderedev has can be assumed to be caused by bad organization, it works and frame rates will be good. However, it takes really long to add new content. Which can be a reason why his major updates are so slow. A UA-camr by the name of k gon looked through the assets in yanderesimulator, many unused models and the names were confusing, hard to match texture to model.
I believe if Yanderedev restarts the project from scratch in the long run his progress might actually be faster, (I don't think he will). Organization is also potentially why Lovesick may progress quicker than Yansim/ how it took them so fast.
Neat code may not improve gameplay but it goes a long way in helping yourself and adding new content.
@@FF18Cloud Reading the code of others and being able to know how hard it is to work in a team can only be encountered first hand in a group work (which is the case for me) where we have this guy in a java project in college who don't know what to do (but he can do things, just don't know what or how to contribute) so I just told him to do small things we can do easily and faster but he is a little bit of a bottleneck. While another guy is like brainstorming with me what we can do, add and how we divide the work then combine it later. Even though we're 3 only 2 can do nicely. Maybe if I placed the first guy into debugging instead that might helped more than giving him work to do in smaller easy things. The unfortunate thing is group work in code is probably only common to software engineering students in our university back then. But really in my opinion we've reached an initial point where we prefer faster coding than shorter code blocks for a faster prototype where execution speed wasn't placed into consideration yet which is fine.
@@franst3909 Well if you can barely have to code when adding to your game then that's nice. If it's me I can definitely see myself able to write a single main script that's a long lines of code in unity while the other supporting scripts are short utilities or managers but what I'm envious about from others is their natural capability to divide the working functions into different scripts or modules that will receive / process parameters passed and each will do one clear thing. That's why it's a bit hard since I'm mostly comfortable with C (and the old days of assembly, basic stamp, arduino, visual basic) where multitasking isn't really a main thing while C++ and java dives you into this flexibility of classes which means reusing code and then in C# they're in the form of scripts representing modules. As for your point of restarting the project from scratch in my opinion it is easy to think and reasonably so that that will help in the long run but there are things to consider. We won't know for sure if rewriting the original is faster unless it is tried and compared. Working from a clean state with the aim of converting original code will still need time and effort. Though I know what you mean. The thing that's going to become faster is the addition of new elements.
I remember years ago, when I was really invested in the very beginning of Yandere Simulator, Yandere Dev decided he wanted to query the community about optimizing his game and refactoring it to be better built and engineered, to optimize and refine the architecture and make development ultimately faster. It would take him 2 months of no updates to do it.
I voted "yes you've got to do that", but the community overruled it by 66% saying "screw performance, I want features". Just goes to show part of what the POTENTIAL root of the problem of optimization probably was: pressure from the 'stakeholders' to output consumable updates, which just ended up drowning the project in the long term and pissing everyone off more.
funny, this could be an allegory on AAA gaming too in the sense that shareholders (the community) don't care about quality of the project and only want cool new fireworks
This is one of these things where you just DO NOT listen to people who know nothing about how the software is made. Literally had the same problem at my job last year. We got an old crappy codebase and a client who wanted new features NOW, we just ignored them, fixed the architecture and then work has been a breeze. Don't want to know what'd happen if we kept building on top of that pile of garbage.
Yandev is the adult, his fanbase are literal children. He SHOULDN'T ASK. He should ignore them. He's supposed to be in charge and he lets himself be bullied by his community all the time. He's too childish for this project to work
@@MariaLuiza-tp2dc I think inexperienced and unprepared is the fairer qualifier here. Completely agree that he should've just had a spine and known what was best for his project, but it's quite emblematic of the qualifications he did have for this. You've got to have the spine to stare people in the eye and tell them "No", but also the experience/mentorship to know that's required and how.
@@MariaLuiza-tp2dc Absolutely true
Enjoyed this video. It was better than most I've seen on this subject. Your knowledge was really apparent.
As someone said:
Look at
this.dude
lol
fuck you
this.dude
lol
bruh.lookAt(this->dude);
Let me preface this by saying I have absolutely zero love for Yanderedev. I don't mean that in a bullying way, and I'm sorry if it is interpreted as such. I also have zero knowledge of coding. I may not be able to fully grasp the level of detail that you go into with your analysis, but I think you've done an amazing job, and I think it's great that you are demystifying these myths that are likely made by people that have become sick and tired of Yanderedev, or people with their own beliefs and opinions on coding habits. This does not absolve him of (nor validate) everything, but it is wholly unfair to condemn him on points that are based on misinformation or untruth. Excellent job.
But 6 years of eating free money from patreon, yeah. He should be in peison right now
"I'll leave that as an exercise to the viewer"
My guy, I am nothing like you...
:'(
@@oldred890 oic, and here i thought i could rewatch it and think if my surface level coding knowledge would allow me to "solve" it. Guess not XD
I've never coded anything in my life.
@@ona512 i mean, u only need to place another component on top of it so it's probably your lack of Unity knowledge
@@cakeisyummy5755 happy for you
@@instantchaos2385 ur right, i know jack about unity.
I was surprised he responded to your email but then I remembered that's what he does all day instead of coding
What a lovely video! Instead of the other videos that say that "IF STATEMENTS ARE BAD" but then give no fixes, you actually went in-depth and shown multiple fixes and improvements to the project. Plus, when I heard "The compiler is smarter than you", I mentally kicked myself for not thinking of that. Compilers are designed to be much faster and are more effective at optimizing "human-readable" code vs obfuscated code.
Uh.. dude, I’m surprised you don’t have more subscribers than you do. You have an unbiased outlook and your experience shines through. Hope to see your channel grow.
Edit: typo
Dude please start a "Programming tips you might have missed" series! I 've learned so much from this video.
Went into this with the common "if switch" belief, but showing the tests you did very clearly and speaking unbiasedly, you really have changed my mind. Well done, love the teardown and honest discussion. 10\10
this was the nicest, most constructive, well manered and objective criticism and analyzis he got, i hope he will improve the code now based on this, great work
he wont, hes a trash coder, not everyone deserves constructive criticism, some deserve destructive and its good
Man, thanks for this video!. Thanks to you, not only I see Video Game Development different now, but Programming as
a whole!. This video is really one of those gems that you find once in your live. Again, thanks for this amazing video!.
As a gamedev it really bothered me watching UA-camrs that don't know much about dev critiquing "if else vs switch" and saying that was the reason the game was slow and "this is programming 101 stuff blah blah"
This video is really really well done. Great work!!!
I'm just glad the big, highly edited videos focus more on yandev's behavior as well as the actual game design. Game's still problems, just that the coding isn't the real smoking gun.
@@gunswinger3110 you're right. It's the stolen assets and endorsement of pedophilia that are the problem with the game.
I was bothered more by the "this." complaining when most of the early complaints about that was purely due to the decompiler adding them.
As someone learning to code this was a great resource to me. Glad to see someone actually probably taking it all apart and seeing what’s wrong rather than just pointing out if else statements.
2:35 "I also ran hitman 2 a game who problems are similar to yandere simulator"
That one phrase compared to the youtube commenters reveals alot about software development culture.
man, well-edited software dev content on UA-cam that isn't a video of a talk from 2012? amazing
As a student, this review is very useful as a warning and a list of thing I should check out. Thank you very much.
I'm really new to programming so I didn't understand a lot of the stuff in this video but it's really great to see someone knowledgeable explain it and tell people who don't code why it isn't as easy as what a lot of these people suggest all the time. I imagine if these people got to see the source code of some of the biggest games in recent years, they'd be surprised by how "sloppy" it is. It's probably structured better but I guarantee there's some really embarrassing code in many of the games we all play.
42:24 OH, I was *hoping* the last thing in the list would be "dying" again!
Also, good video! You definitely have a way better idea of what drops Yandere Simulator's performance than others that just yell "ELSE IF ELSE IF" a lot.
thank you for like... ACTUALLY explaining everything in a very coherent way? i came into this video knowing NOTHING about game coding/coding in general, and came out of it with a better grasp on what gaming coding/coding actually is (and helped me understand what was ACTUALLY going on w yandere simulator) , thank u!
He didn't make any of the assets so I wouldn't ever count on him optimizing anything, nearly everything is just taken from some asset store.
He already has made several videos discussing this. He used most of those as placeholder models.
He has already changed almost all assets with original ones from volunteers. In fact, the most infamous model for Ayana is currently being replaced with an original model.
In fact the uploader says he is working closely with YanDev rn to optimize. This has promise
Ian Drsaurri who is gonna play this since a better game will came out than yan sim
@@iandrsaurri625 He refused the help of a indie game company because he didn't want to remade the code from zero, I don't think we should enable his behaviour at this point... He had every opportunity to hire professionals to help him and he just refused.
@@iandrsaurri625 it's been placeholders for 6 years. A bit long don't ya think?
Ian Drsaurri Wasn’t that video quite old, kinda late. Plus, if you are referring to the video where he showed a picture of Ayano’s new model, that was STOLEN. He refused to credit the artist sometime ago, so she pulled out of volunteering. Yet, he used her model/mock-up in his video.
There's an interesting comparison to be had between Yandere Simulator and Wintergarten's Marble Machine X. Both projects have incurred massive amounts of Technical Debt over the years of their development, but while YandereDev holds onto his precious game code, Wintergarten (essentially) threw away the MMX that he spent years on so he can instead use the knowledge he gained from the first two machines to create a new, better one without the burden of his previous designs. Another interesting thing is that both creators are also the biggest critics of their own projects. YanDev could have done his fabled Kickstarter years ago (and it'd likely be wildly successful), but he doesn't feel like the game is close enough to his vision for that; and Wintergarten could've toured with the MMX and almost no-one would notice a few dropped marbles. Ultimately, I hope both projects come to fruition, but we'll have to wait at least a few more years for that.
I like this. It's very comprehensive with actual evidence. I also do agree with everything on this video. Yes, else-if vs switch is a red herring, but the real problem is the technical debt.
YO, I've been waiting for someone to do this! Like, as a graduating compsci student, i always thought it would be interesting to look at what we can learn, as to what would happen if you don't apply best practices.
Arent you the guy that got banned from discord or smth?
No wait its just your pfp
This was very educational and not the neverending roast I kinda expected, thank you so much! Very interesting.
For some reason I keep coming back to this video once in a while. Wish you did more code reviews like this one, dude.
I was waiting for someone to make a video like this, not just saying "IF ELSE BAD, SWITCH GOOD". Glad you know what your talking about :)
everyone: *ew yandere sims code is so bad*
me: _doesnt understand it_
also me: _uh huh, yep, wow so bad_
Finally someone that went through everything manually instead of taking rumours as facts.
Also, good job on debunking claims that were true technically, but didn't change anything in the grand scheme of things.
This video unironicly made me start a degree in Computer Science, half way done and just finished a large exam and passed showcasing understanding of C and a large range of data structures and algorithms :D
have fun being passed up on in favor for outsourced devs making 12 cents a day!
ps they smell of curry
Wow great job!!