Skip to main content
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
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: ...
CosmicGiant's user avatar
  • 2,124
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,738
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
  • 141k
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,955
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
  • 123k
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 ...
Theraot's user avatar
  • 28.2k
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
  • 123k
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 ...
Cygon's user avatar
  • 232
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
  • 123k
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
  • 141k
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
  • 123k
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
  • 28.2k
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 ...
aBertrand's user avatar
  • 176
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

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 ...
Bálint's user avatar
  • 15.1k
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 ...
virtouso's user avatar
  • 2,680
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 ...
Theraot's user avatar
  • 28.2k
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 ...
Vaillancourt's user avatar
  • 16.4k
3 votes

How to create a user-friendly magic spell system?

The default solution (most used, most widespread, most known to players) is a spell slot system. You have a series of visible slots on the UI (between 2 and 10), which are assigned to default keys. ...
Peter's user avatar
  • 9,955
3 votes

How to create a user-friendly magic spell system?

I've played a fair share of multi spell games where you have to be selective out of the roughly hundred spells to your availability. For keyboard only control, I would have LOVED a sort of windows ...
Tschallacka's user avatar
3 votes

How to create a user-friendly magic spell system?

This answer might not be the one you want but I would suggest that you reduce the number of available spells to a number which can be bound to a your available hotkeys. Whats the point in having 100 ...
Vincent's user avatar
  • 91
3 votes
Accepted

How can I make a custom memory allocation for classes with virtual methods?

Take a look at std::allocator_traits that will allow you to use your allocator and construct objects in allocated space. If you don't want to use that you can use placement new: ...
ratchet freak's user avatar
3 votes
Accepted

Single handler vs multiple handlers for the Command Pattern

A single handler would have a lot of dependencies, where as multiple handlers can be better compartmentalized. Personally, I take it one step further, and make the handlers non-exclusive: events may ...
Bram's user avatar
  • 3,744
3 votes

When is the best time to consider performance?

You need to put in enough effort to at least go "is this potentially going to be a bottleneck, and if so, how involved a change will it be to fix it?". Generally speaking, this involves a balance ...
TLW's user avatar
  • 161

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