Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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 ...
Maximus Minimus's user avatar
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 ...
Kevin H.'s user avatar
  • 498
38 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: ...
CosmicGiant's user avatar
  • 2,094
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's user avatar
  • 6,678
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 ...
DMGregory's user avatar
  • 135k
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 ...
Peter's user avatar
  • 9,925
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 ...
Philipp's user avatar
  • 120k
13 votes

What do I need to consider before making any class singleton?

Do you think you don't need more than one or do you think there must never be more than one? The singleton pattern is mostly useful in situations where the existence of more than one instance of a ...
Philipp's user avatar
  • 120k
13 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 ...
Theraot's user avatar
  • 27k
11 votes

Is Domain Driven Design good for games?

Paradigm As of the time that this answer was written, the other posted answers here are all wrong. Instead of asking whether or not Domain-Driven Design is good for games. You should ask whether or ...
Shawn McCool's user avatar
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 ...
Philipp's user avatar
  • 120k
10 votes
Accepted

Understanding Entity Component System

Can Component hold the logic? or it should not and stay as a bag of data? That's how you like. I suggest to stick with the first implementation and finish your project, then see if it worked out ...
Vaillancourt's user avatar
  • 16.3k
9 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 ...
Cygon's user avatar
  • 222
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 ...
Philipp's user avatar
  • 120k
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 ...
DMGregory's user avatar
  • 135k
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 ...
jjimenezg93's user avatar
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 ...
kabanus's user avatar
  • 181
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 &...
Philipp's user avatar
  • 120k
7 votes

How do I avoid writing Manager classes?

When you read the blog post you linked to in the comments, then you will see that "being a Manager if by another name" is exactly what it wants you do to. It's general consensus in software ...
Philipp's user avatar
  • 120k
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 ...
Cort Ammon's user avatar
  • 1,237
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 ...
Theraot's user avatar
  • 27k
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'...
Patrick Hughes's user avatar
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 ...
Pharap's user avatar
  • 1,627
4 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 ...
aBertrand's user avatar
  • 166
4 votes

How to design a multi-step game menu system?

If you have nested menus, you can use a stack. I'm not familiar with Ruby, I think there is no 'stack' object. Similar behavious can be created using an Array. You only add items to the end (push), ...
Felsir's user avatar
  • 4,067
4 votes

What do I need to consider before making any class singleton?

The book Game Programming Patterns (which you can read free online) has a good overview of considerations for when to use / avoid singletons. The cautionary advice boils down to: A singleton is a ...
DMGregory's user avatar
  • 135k

Only top scored, non community-wiki answers of a minimum length are eligible