I’ve only made small games and helpful programs for personal use. I want to make a large multiplayer game now but i don’t know any of the conventions involved with keeping large games manageable and organised. The game will start small and be fully functional before i start adding additional characters and additional content. It should be very manageable for my current skill level but i have several questions before i end up with a horribly cluttered and poorly designed framework for my game. DotA is a good example for you to imagine when considering these questions.
1: My game has RTS style controls, you click on yourself then right click to move yourself. There will be an option to take control of enemy units and left click then right click to control them as well. (Control is given if your ID matches a variable on the thing you’re clicking.) Should all my units use the same script that includes movement and attacking? I also need to include some spells (additional GetKey functions) for the main character, should it be inside the movement/attack script with some “if==main” lines attached to the spells? Should the spell script inherit from the movement/attack script? Should the spell script be entirely separate? I’m leaning towards it being entirely separate or inheriting since i’m thinking nonmagical units will never be able to gain spells and thus there’s no reason to include the functionality in any way. What would be the most conventional way of handling this when all units on the map move/attack in the same fashion but not all units can do additional actions?
2: What is the best way to handle multiple colliders on the same gameobject? My enemies need a collider for collisions and another collider for triggering their aggro radius. Should their aggro radius be a child with the OnCollision scripts attached to it? Also my players can buy auras that would probably use a collision trigger to know who is inside the radius. Would it be more reasonable to add the component and the script to the player or add a child object with a script.
3: Is it standard practice to slap multiple scripts onto the same gameobject? All my units right now have Health and UnitCapabilities scripts attached directly to the gameobject, in addition to my colliders and rigidbody and navMeshAgent. It just seems like it’s a lot… or that it COULD be a lot but i’ve condensed some things like movement/attack into the same script. How many scripts on the same gameobject is considered reasonable?
4: Most importantly, how exactly do servers work? I’m using photon PUN right now (the free version) and i’ve come to the conclusion that a server is basically just an additional player who doesn’t really do anything and is considered the masterclient. The masterclient is capable of doing some extra options like instantiating scene objects that persist when players disconnect, which is important for a game that is supposed to be played from start to finish without people joining or leaving. Am i right in thinking that the server is playing the game along side you waiting for you to finish then creating another lobby for new players to join a new game? So if i build this entire game with the logic that the master client controls extra things that make the game operate, people can do hackable custom lobbies (if they’re the host) but also i could get servers and set them as the only clients who could create a public lobby. Then the server would be the master client and be in control of the game. Is this right?