what is the best way/ structure to write code in unity for a solo indie dev.
How do i code good in unity so i don't fall into the yandev tier of spaghetti code trap?
Other urls found in this thread:
en.wikipedia.org
youtube.com
twitter.com
by getting a comp sci degree and not doing it as a hobby
or by reading a book
If you have to ask this question, you are not skilled enough to complete a game.
go take programming courses, there are plenty of free ones online
but toby fox didn't get a comp sci degree
and toby fox can't code good.
Stay in school user. learning is half the battle
i did stay in school now i want to make a game now i'm out.
did you actually learn programming in school? if not then you need another school.
no we had basic computer science classes in my school, they only started implementing learning programming after i left like teaching kids how to use scratch
Do you know how to use switch statements?
Do you know what enums are and do you use them or other variables instead of using strings as identifiers?
Congrats, you're a better programmer than Yanderedev
oh it's that simple.
then
yes
and
yes
Make every single thing which could be a class into a class and everything that could be its own function, into its own function.
For real, I think most people can easily program at least somewhat properly without even really trying that hard. It takes a special brand of stupid to do the kind of shit yanderedev does
>mfw I don't know what any of this means
I'm retarded, what's the deal with Yandev's code? Is it needlessly complicated or something?
does a math degree count
nothing's actually wrong with it. I'd be surprised if constant string comparisons weren't simplified into hashes (though not SUPER optimal it's nothing to write about) and you can't expect one person to keep a huge codebase maintainable. In C++ (I can't remember what he wrote or what he was trying to do so just off the top of my head) I'd use a set of static const maps to achieve what he was trying to do which ironically would be even less performant but would be a little more maintainable.
Yandev's code is both a mess from a readability standpoint and also from an efficiency standpoint.
He's set up massive trees of if else arguments that he needs to dig through every other time he makes a change so development has slowed to a crawl.
Other than that he also has several blocks of code that are checked in the same way controller inputs are checked, as in every frame. This tanks the performance to sub 20 fps despite being a unity game that ought to run on toasters perfectly.
The biggest problem though is that he refuses to improve or learn better than what he already knows. He's hired others in the past to go over and improve his work, but fired them when he didn't understand how they cleaned up his spaghetti.
Now none of this would matter if he actually released the damn thing, but since he's still working on rival 1 of 7 years after the game was supposed to be done I'm sure you can see what went wrong.
let us not mention there is a game being worked on by another team with the same premise that has achieved more and looks better, and his game could be at that level if only he was humble enough to just accept the help, instead of thinking he always knows better.
all he had to do was then take a directing role and give ideas of what mechanics and stuff he would like and what art direction and story the game should take while his team does most of the work, but he refused that.
if he didn't understand how something worked he could have just asked them how it works and they would have just told him and he would have learnt and grown as a coder while having a good product with a good team to support you.
If he did that, he would quickly lose his patreon bux. Let's not pretend the people capable of working with an "ideas guy" will do so for any length of time.
Keep your functions simple. Just by looking at it you should know what it does. Keep function and variable names as descriptive as possible, doesn't matter if it's too long.
Keep a hierarchy. Generalist classes should call specialized classes, but not the other way around. This one is the harder one to grasp for new programmers.
Make unity tests for mechanics, and unit tests for complex pieces of code.
Learn how to make custom inspectors.
he could have just used the patreon money to keep paying the team to stay, as releasing a finished product into the market would make him more money than his patreon and also give him a net worth of some value.
thanks for the advice guys, i'll take it on board
Also, put comments on everything and be descriptive. You might think you got it now, but when you're debugging months later, it'll be a big help to know what any given code block does.
>nothing's actually wrong with it.
Yes there is you retard
You should literally NEVER use strings as identifiers, and no, it's not for performance reasons
Stop pretending you have any clue what you're tlaking about
Man, you are the reason I earn 6 figures lmao
When you're the only one working on something unit tests are overkill, or you won't have the time to write good unit tests. The only thing worse than no unit testing is bad unit testing.
let's say he hires person A. He gives person A of cut of say 25%.
A few months pass, and profit increases as expected. Next he hires person B. Person B gets 15%, and is thus paid the exact same as what person A was paid when he was hired. He now shared 40% of his patreon monies with his underlings.
Let's say person B finds this unfair, since they are given an equal share of the work. Now he could either
>lower person A to 15%
>give person B 25%
>now he has a structured team, he could cut the shares of both (to say 5%), and hire more people to work part time on the project. This way, he risks giving recognition and a means to people who think they could do better on a competing project. Since they're not getting paid as much- and likely doing the work part time- this is a magnitude more likely than when he was only paying 2 people
either way, he has to give out 50% to only two people or maybe 30%-40% to many people. You may say "just give them a fixed salary"- they will then ask for a raise when the monthly subscriptions increase, since they know EXACTLY how much he's getting. Since there will only be a handful working on the codebase at a time, he can't afford to fire them or for them to quit. Essentially, still a %-based salary, only with more drama. I'm not even going to mention how things will collapse if the profits stagnate. Point is patreon teams don't work.
>and you can't expect one person to keep a huge codebase maintainable
What the fuck are you talking about?
When there's only one dev, that's exactly when it's easiest to keep a codebase maintainable.
Unless you are doing low level stuff like manipulating bits or you have a limitation that forced you to implement thing counterintuitively, you shouldnt use comments at all.
The cleanest code always describes itself through consistent naming and a clear structure.
>When you're the only one working on something unit tests are overkill
If you read again I was referring complex pieces of code.
So much text to say nothing at all... do you use Java?
>i didn't read it so it says nothing
ok can someone actually post it so I know what we're chimping about
no, you'd probably index your arrays starting at 1
if you do it right coding isn't hard
90% of the work has been done for you
why do you think there are so many pajeet code monkeys in the field
en.wikipedia.org
math in comp sci is a joke because it will make you do things that are not okay in coding
What in the actual fuck. The "and" separator nails it.
you would learn more from the internet than learning basic shit from school
this isn't the 80s, boomer
imagine being so fucking insecure that you literally have to have a debunk page that can be easily debunked if you look things up on any search engine
pajeets are smart because they actually sit down and use google, something 70% of the world's population fails at doing somehow
this is wrong. pajeets can't use google at all. they use youtube which can work but inefficient
There's only one way
yeah, this nigga hardcoding every fucking combination as a string
point at him and laugh
What the fuck lmao
Holy shit. Why is he using so many ands? Even if he insisted on doing it like this, he could at least have made there be only like 5 conditions instead of checking for every possible combination.
The trick to programming is knowing how to google your question correctly so that it you find someone who has had the same question you had already. That is what 4 years of a comp sci degree will teach you that is meaningful. I don't know a lot, but I do at least know where to find what I need to know.
Make something simple, like small part of the game or really simple game. It's best way to learn where you make mistakes, how to rewrite it into something better and what to use.
Once again: The problem isn't the comparisons as such (they look like shit, but it'd be perfectly workable if bad practice). It's also not that he's doing string compares, there's times where this is the least-shitty way to do things (this isn't one of those)
The problem is that he's doing this for every NPC on every frame. While most NPCs jump out at the first if, it still tanks the performance since there are so many of them.
If you're solo just don't bother with structure or anything. It's not like anyone else is ever going to look at your code.
>The problem is that he's doing this for every NPC on every frame
how do you know?
Yanderedev's coding is fine. It works in-game which is all that counts.
He used RPG maker and has a lot of experience dicking around with simple shit from his years with Homestuck. There are a lot of routes into coding, but a CS degree is the all around safest bet. Just don't ever, ever, ever, ever, get into the video game industry or waste your time being an indie dev and expect it to make you money or generally be anything other than a hobby time waster
what about development tools (i.e. modelling software)
do they earn money
>how do i code good
read a book on coding. then another one. and another one.
here's some certified pro™ tips™:
>if you want to do a complex thing once, write it all right where you want it done. if you want to do that thing again somewhere else, do NOT copypaste it to the somewhere else, instead make it into a function and reference that function in the two places. this will make it easier to maintain the code in the long run
>use different variables depending on what you want to do. a boolean is really good at being a yes/no flag, different integers have different sizes, floats are a necessary evil, etc.; and don't forget to use arrays.
>don't try to reinvent the wheel, but do try to understand how and why the wheel works when copying code off of certain websites. if you know how your game works it's easier to fix it when it breaks or doesn't do what you wanted it to do.
>Just don't ever, ever, ever, ever, get into the video game industry or waste your time being an indie dev and expect it to make you money or generally be anything other than a hobby time waster
Who are you to tell people not to follow their dreams
>read a book on coding. then another one. and another one.
that's not how you get good at programming
Just stay the fuck away from Unity. There is not a single game on it that doesn't run like shit, is plagued by crashes and bugs, or has to do some ludicrous shit to have stable performance. The Inside Devs had to jump through so many fucking hoops to get a stable framerate in a slow-paced 2D cam 3D game because tbe engine can't handle streaming in levels and the Children of Morta Devs had to write their own asset management tool because Unity's is too fucking slow to generate small 2D levels with. Don't even start with this shit, 2/3rds of the engine are competing tools for the same task in various states of abandonment, disrepair or unfinishedness. They've been trying to rewritr core parts of the engine for three years now and have completely fucked themselves.
If you don't want to give Tim Cook money (lmao @ you for thinking you'll break past 12k a year anytime soon), learn proper programming practices, wait five years and hope that either Godot 3D becomes good, CryEngine unfucks itself or Source 2 finally gets released and is actually workable.
The image used to be bigger and showed surrounding code.
I mean yeah it is. Read material and apply it. You don't just mindlessly read, user.
You get good at programming by doing it, reading books is optional and insignificant