Interests from the point of view of optimization. Rummaged on the official unit, but there things are more serious offer to optimize
1 answer
A few years ago I was working on accounting systems, working in particular with Microsoft Dynamics AX. There was a set of Best Practics rules that every self-respecting programmer tried to follow. There, of course, work with objects looks somewhat different, its own specifics, but the rules are good. If the method does not fit on one page, then the method should be split. Each object, and in it the method must perform an atomic task, and the meaning of the action must be clear from the name. If you feel that your component is overloaded and in addition to following the person running, it also writes replicas in quests and writes data to the server, then something is obviously wrong with the solution architecture.
For all I will not say, but I try to do so. I have a task to get control from the user, there is a task to move the character. I make my own component for each task. It will be necessary then to immobilize the character, I will turn off the component with control from the player and voila. We take the task and decide how complicated it is, and then divide it at our discretion. The main thing is not to overdo it.
character controllerand it just cannot by itself to be small - let him be. One file should reflect the essence of its name in fact and nothing superfluous and there is no point in sharing. Usually they make some abstract classes with the basic implementation, interfaces, etc. And in the main scripts they are inherited from them. As a result, a lot of things are being saved. - Alexey Shimansky