84

There are several reasons for that. I'm just gonna touch on a few: It makes your source code a mess. If you have a lot of dialog (trees), a huge part of your codebase is just text that has nothing to do with your actual game code. You'd need to recompile every time you change so much as a single character. The dialog itself is hard to navigate. I imagine ...


77

OpenGL has four different major versions, not counting the versions for mobile devices and embedded systems (OpenGL|ES) and the Web via JavaScript (WebGL). Just like Direct3D 11 has a different way of doing things than Direct3D 8, so does OpenGL 3 have a different way of doing things than OpenGL 1. The big difference is that OpenGL versions are mostly just ...


67

You'd usually use an entity component system (An entity component system is a component based architecture). This also makes creating other entities way easier, and can also make the enemies/NPCs have the same components as the player. This approach goes in the exact opposite direction as an object oriented approach. Everything in the game is an entity. The ...


67

Favour composition over inheritance in your entity and inventory/item systems. This advice tends to apply to game logic structures, when the way in which you can assemble complex things (at runtime) can lead to a lot of different combinations; that's when we prefer composition. Favour inheritance over composition in your application-level logic, everything ...


59

Usually you should separate the logical state of your game environment from the visual representation. The player might only see a small part of it on their screen, but you still keep the state of the whole level in memory and usually also calculate the game mechanics for the whole level. When your world is so huge that this would require too much ram and/...


53

There are ways to make nice 3d graphics with low memory footprint, however that requires you to have the right experience and knowledge. There are games like .kkrieger which is a 3d first person shooter, with the size of a few kilobytes. This is not just compression algorithms. You can't just make a massive game and press a button and suddenly its 100kb, ...


48

By simply only loading those parts of the world into memory which are close to the player. Anything else is suspended to hard drive. When there is a tiny object laying around two kilometers away, then the player can not see it and can not interact with it. So there is no reason to update it or send it to the GPU for rendering. The smaller the object and its ...


43

Use a boolean flag. In the example shown, you'd modify the code to be something like the following: //a boolean flag that lets us "remember" if this thing has happened already bool thatThingHappened = false; void Update() { if(!thatThingHappened && mousebuttonpressed) { //if that thing hasn't happened yet and the mouse is pressed ...


42

Data-driven coding Every thing you mention is something that can be specified in data. Why are you loading aspecificmap ? Because the game configuration says that is first level when a player starts a new game, or because that's the name of the current save point in the player's save file they just loaded, etc. How do you find aspecificmap ? Because it's ...


41

I initialize my services in my main application class and then pass them as pointers to whatever needs to use them either through the constructors or functions. This is useful for two reasons. One, the order of initialization and cleanup is simple and clear. There is no way to accidentally initialize one service somewhere else like you can with a ...


39

As you mentioned, an actor can be literally anything; trees, NPCs, buildings, etc. A similar term is "entity". It doesn't need to have a behaviour in the traditional sense, it can be static. It's just a way to say "an object in the game".


39

When you are comming from non-game application development, then you need to be aware of a couple things. Relational databases have a niche role in game development. You really only need them when you have a massive multiplayer game where most of your players are offline most of the time. There are also some niche applications like online scoreboards or ...


37

You are going at it backwards. You start with the logical state of your game and model that. The whole logical state of the entire world will almost certainly be too much to be held in memory at once, so you break it down in smaller parts that can be loaded and saved independently. These parts are often referred to as chunks. These chunks can form a ...


32

The trick Elite likely uses is that they don't pre-generate the whole galaxy and store it in a database. They likely generate most of the galaxy at runtime when it is needed. I would do this using a pseudorandom but deterministic algorithm which can generate the properties of every object in the galaxy at runtime just from its position. So when a player ...


31

One quick way to get key-value pairs in Unity's inspector is to define a serializable entry class, and then use an array or List<> of them. eg... public class SpellAnimationMap : ScriptableObject { [System.Serializable] public class SpellAnimationEntry { public Spell spell; public AnimationClip animation; } public ...


27

At first you see that your commands are in the form of a list, so your first instinct might be to recreate that structure, and each dwarf will run through that list in sequence. What I suggest though is to break the list into steps, with each step having prerequisite(s), and then you run the entire command in reverse. Let me demonstrate with an example: ...


27

I think not overthinking this issue will give the best results so I would just implement a simple key-value saving system into your game that you store along your other save data and then load on-demand when you need to access a previous state. The flow could look something like this: Load level from file Before placing a tile / object check if it has a "...


26

I've worked quite a bit with Mecanim in Unity, and feel I have a quite good understanding of how it works. Like you say, blend-trees are almost definitely the way to go for doing locomotion. Blend-trees are generally for when you want to continously blend animations to create the final output. Like give the player the control of how fast the avatar is ...


25

A common approach is to have a component-based approach where the base-class "Unit" just implements the most basic aspects all units have in common, while each unit then has a list of multiple component-objects which say what it can do and how it does it. For example, a tank might have the components Mobile, Destructible, Attacker, an immobile turret only ...


22

Should bool flag not suffice or you wanted to improve readability* of the code in void Update() method, you could consider using delegates (function pointers): public class InputController { //declare delegate type: //<accessbility> delegate <return type> <name> ( <parameter1>, <paramteter2>, ...) public delegate void ...


22

You have two very different things to manage: The server must manage the entire world, in an authorative manner. For that, communication with N clients (where N is "massive") is necessary. The client could, in principle, know about the entire world, but it needs not. For the client, it is sufficient to know about what's nearby the player. Assuming for ...


20

Games aren't unique in this; god-classes are an anti-pattern everywhere. A common solution is to break down the big class in a tree of smaller classes. If the player has an inventory, don't make inventory management part of class Player. Instead, create a class Inventory. This is one member for class Player, but internally class Inventory can wrap a lot of ...


20

You got a few nice answers already, but the huge elephant in the room in your question is this one: heard from someone that using inheritance must be avoided, and we should use interfaces instead As a rule of thumb, when somebody gives you a rule of thumb, then ignore it. This not only goes for "somebody telling you something", but also for reading stuff ...


19

That is an interesting question. Mainly because answering it raises the shades-of-grey versus black-vs-white dilemma. is there anything wrong with building a game before I design it? If you think of that question as a yes or no type, the answer can only be: yes, there is. If the answer can be more nuanced, then it changes. Reason: you should never build ...


18

References work well for many situations. However, there are three important situations in which references won't work well: Networking. When sending information about synchronizing the state of entities over the network, references can't be used. You'll need to identify the entity in some way so the remote machines know who you're talking about. Saving/...


18

I won't discuss about the evilness behind singletons because Internet can do that better than me. In my games I use the Service Locator pattern to avoid having tons of Singletons/Managers. The concept is pretty simple. You only have one Singleton that acts like the only interface to reach what you used to use as Singleton. Instead of having several ...


17

As long as you keep your system relatively simple, this should work. But when you add things like temporary skill modifiers, you will soon see a lot of duplicate code. You will also run into problems with different weapons using different proficiencies. Because each skill is a different variable, you will have to write different code for each skill-type ...


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