- Home /
Developing an extensible framework for a video game
I realize that this question may be a little broad, but I'm wondering how experienced game developers here might approach the design and implementation of a framework that allows for extensibility of game mechanics and objects.
For instance, let's say we have a space simulator MMO with a comprehensive system in place for starship mechanics such as a power plant, weapon systems, etc. These systems are interdependent and can be upgraded, such as acquiring more powerful projectile weapons or ship components with enhanced functionality.
Would you simply create a main class called "projectile" that could then be implemented various ways as needed?
Are there any examples out there of such a framework? It doesn't have to be space-related of course.
It's not totally clear what kind of implementation details you expect here (which is why this is a comment and not an answer), but it sounds to me like you're describing normal aspects of object oriented program$$anonymous$$g. I recommend you do some reading up on this field of program$$anonymous$$g; you'll find that it serves the extensibility requirements you have quite nicely. Especially parts on polymorphism / inheritance.
I'm on the same boat as CHPedersen. I think what you're asking is outside Unity, even C#, and more on a program$$anonymous$$g practices/design level.
So if im correct you want to make a main class for ex: weaponfire then create childs that define the type of bullets/RoF/type etc.
You might want to look into the UT2004 weapon fire system, it uses the same type of structure that youre suggesting.
Heres a link to the files: http://udn.epicgames.com/Two/USCRIPTDownload.html
Answer by RyanZimmerman87 · Dec 05, 2013 at 12:32 AM
It's all about the way you set up your systems and design your scripts. When I started my project I did the majority of my code specifically for the individual important prefabs with private variables.
Lately I've been trying to write scripts that are easy to work with in the editor using public properties if they are meant to have more broad functionalities which can be used on many different prefabs.
For example I've designed a few systems that allow my artist to work with NPC's directly in the editor with a few of my scripts. So my artist can pretty much set behavior for the NPC's in the editor even though they don't know how to program.
So the NPCs for example can do a wide variety of behaviors/functionalities which are fully customizable in the Unity Editor with the scripts. So my artist can enter strings for text bubbles or animation names. Both of which can be called as desired from other functions which you can assign which number to call from those arrays.
So essentially I created a system that has arrays of strings, bool check boxes, and integers/floats. All of them are public so that whoever is working on them can enter it directly into the editor. These variables control things like:
Which animation should play
How fast should the animation play
How fast is the NPC movement speed
Do they Patrol
What type of patrol do they use (random, circular, back and forth)
When they reach patrol points do they continue or go idle
Do they have a random chance to continue or go idle
How long will they go idle (min - max Random.Range)
Where do they look when Idle
Do they display text bubbles?
Which text bubble string will they display when idle (desired number, random, next one in array, etc)
How long will they display the string, how much of a delay before the string triggers
What kind of trigger or event should start the text bubble string (player collision + distance, scene timer, patrol area collision, etc.)
And all of these behaviors can be modified from there original states if the NPC is patrolling and hit a certain collider in their patrol path. So for example they could start with a move speed of 4 but then they hit a collider by some dangerous stuff and you assign new variables for move speed, animation type, next patrol point, etc.
I think you get the point here, just trying to give as good example as I can for setting up something that I think is related to your question.
Essentially the way I look at it now is can someone who doesn't even know how to program set up complex systems in the game using your scripts? If not what public variables and behaviors would they need to have as much control over everything as possible. If you design all your scripts so you could take any new object throw it in the scene and attach a script or two and customize all the behaviors then I think your on the right track.
You might have to do like a tutorial video for someone to know how to use your scripts to assign all the variables correctly for different behavior, but the point is that you can do everything you need without re-writing any code. All the things you need should be available as public variables for easy editing in Unity.
Your answer
![](https://koobas.hobune.stream/wayback/20220613123427im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A simple quest system[solved] 0 Answers
Looking for advice about changing levels. 1 Answer
Decoupling with a path-finding algorithm 1 Answer
Unity architecture 3 Answers