88
votes
Accepted
When is the best time to consider performance?
Engineering for Performance
Follow vendor recommendations.
Use the correct data structures.
Implement the correct usage patterns.
Don't do anything stupid.
Optimization
When already written code is ...
40
votes
Accepted
Why should I always consider creating and using object pools instead of instantiating the new object on the fly?
If you're planning to instantiate many instances of the same prefab, you should definitely think about using object pooling. Calling Unity's Instantiate function is one of the most taxing method calls ...
39
votes
In Unity, how do I correctly implement the singleton pattern?
The best implementation of a generic Singleton pattern for Unity I know of is (of course) my own.
It can do everything, and it does so neatly and efficiently:
...
30
votes
How to create a user-friendly magic spell system?
There's no "best" way. The game design in your case is intimately connected with the UI design.
However, given your setup, I'll lay out (haha get it) some advice.
You're right about the lower-level ...

Almo♦
- 6,708
28
votes
Development pattern for interactive in-game tutorials
The best way I know how to do this is to have a notion of an "action queue".
When you want to cause an effect that might need to be pre-empted by something else, instead of executing the ...
22
votes
When is the best time to consider performance?
If you want to do optimization at the right times, have slow machines and use them. For a small shop, a good option is to use a slow laptop on the commute and a fast desktop in the office. As an ...
21
votes
How to create a user-friendly magic spell system?
Almo's advise to allow the player to assign spells to hotkeys according to their own preference is good. You can increase the number of spell slots if you allow modifier keys like Ctrl and Shift to ...
14
votes
What's the appropiate way to achieve composition in Godot?
I have gone from a monolith player controller, to an state machine, to a behavior tree, to something closer to what you describe.
My current character controller looks something like this in the scene ...
11
votes
Development pattern for interactive in-game tutorials
If you want to completely decouple the tutorial logic from the regular game logic, then you might need to redesign your software architecture to an event-based architecture. You already seem to know ...
10
votes
Do retail games use "inversion of control" and "dependency injection"?
I'm writing this at a time when the accepted answer is by a contributor who strongly opposes the concept and I wish to provide a different view:
Dependency injection is indeed not widely used in game ...
9
votes
When is the best time to consider performance?
No, you don't have to check after every line because not every line is performance-relevant. It mostly depends on how often a line is executed. A code section which takes 1 ms to be executed is ...
9
votes
Accepted
What should be an entity/component, and what shouldn't?
A lot of systems in a game that needs to be updated are things that are not rendered and don't need any input, they simply need a call to their update function every frame. They don't have any ...
8
votes
Accepted
Creating a Robust Item System
I think you can achieve what you want in terms of scalability and maintainability by using an Entity-Component System with basic inheritance and a messaging system. Of course, have in mind that this ...
8
votes
How to create a user-friendly magic spell system?
In addition to the old classic, coming from fighter games - key combos. The better the spell, the longer the combo. This has the added benefit of feeling like casting, and a high level spell actually ...
8
votes
Accepted
Is there some psychological reason for why most game's UI is always the same colors?
When picking a color palette for your game UI, there are several considerations:
Fitting with the theme of the game. If you have a medieval fantasy game, then the UI color scheme should communicate &...
7
votes
Should I store a value for every damage type even if zero, when using the Decorator pattern?
As a general rule, one should never be a slave to any pattern. Be flexible. As for the particular example you give, it's a rather well known case, so I can help a bit with the pros and cons. I can ...
7
votes
Accepted
In an object-oriented game engine, should there be seperate classes for objects with and without parents?
what should the parent of the root Instance in the hierarchy be?
Nothing.
Does Instances without parent make sense?
If you, for example, might want a factory that ...
5
votes
In Unity, how do I correctly implement the singleton pattern?
Here is my implementation of a singleton abstract class below. Here is how it stacks up against the 4 criteria
...
5
votes
What strategies and patterns exist to handle large amounts of game entities?
I would push all those events onto a priority queue (with the priority based on task completion time) and the event carries all the info it needs to perform its task, even to queue up new tasks if it'...
4
votes
Behavior Tree with interrupted sequence
Firslt remember that a decision tree is not the same as a state machine.
You have listed three 'states' but they are not exactly 'states', they are compositions of other actions. Because of this, I ...
4
votes
Accepted
How would one program potions that can change virtually every aspect of the character?
When you have more than just potions which causes effects like that, it can be useful to put another layer of abstraction between the potions and the game mechanics in form of a temporary status ...
4
votes
What strategies and patterns exist to handle large amounts of game entities?
Don't overcomplicate. Thousands of facilities might sound hard to calculate for you, but it really isn't. In the worst case, it's just a bunch of equations. Computers are amazing at that.
If you want ...
4
votes
Accepted
AI Behaviour design pattern which handles lots of diverse behaviours and mechanics?
i think you are looking for a generic way to make an script that works for big range of NPC's.
for making these types of behaviours, there are some techniques. you can research for each of them and ...
4
votes
Is there some psychological reason for why most game's UI is always the same colors?
I'm making an rpg game, I'm making the UI now , and I just noticed that I never played a single rpg game that deviated from the standard rpg ui color
This is intended to ease knowledge transfer. When ...
4
votes
What’s the benefit of breaking code down into other classes?
A lot of design decisions come from the needs of your project, and your experience: e.g. "I've been burned before when I used approach X to accomplish Y, I had to re-write a lot of code to get Y ...
3
votes
Accepted
Observer pattern payloads
It makes sense to have your basic Observer and Subject implementations unaware of higher level data types, but at some point they have to commit to a common contract to be able to communicate.
You ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
design-patterns × 337architecture × 139
c++ × 57
unity × 43
c# × 39
software-engineering × 33
game-design × 29
entity-system × 20
java × 19
component-based × 15
oop × 14
xna × 13
javascript × 12
ai × 10
rpg × 9
libgdx × 8
networking × 7
input × 7
data-structure × 7
databases × 7
memory-efficiency × 7
entity-component-system × 7
turn-based × 7
objects × 7
events × 6