90

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 running slow, measure it, find out why, implement what is required to make it fast. Premature Optimization Make assumptions about what is fast or slow ...


42

It depends, but usually I use a third method. The problem with the methods that you used is that in the event that the object is included to begin with, it will not remove them from the tree, and they can still be created by instantiating too many calls, which could make things really confusing. public class SomeClass : MonoBehaviour { private static ...


41

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 you could make. Object pooling is when you instantiate prefabs before they are used. They are deactivated immediately upon instantiation and reactivated only ...


31

Here's a quick summary: Create object Removes scene Global Keep across if not in scene? duplicates? access? Scene loads? Method 1 No No Yes Yes Method 2 Yes No Yes No PearsonArtPhoto No Yes Yes ...


31

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 spells being on the most convenient keys can be a problem. I would recommend something along the lines of Diablo 2 and 3 where you assign spells to keys in an ...


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: ...


23

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 access additional hotkey bars (but keep in mind that when the player has one hand on the keyboard in the typical WASD position and the other hand on the mouse, ...


22

As with everything in software development, there is no ideal solution. Only the solution which is ideal for you and your project. Here are some you could use. Option 1: The procedural model The ancient obsolete old-school method. All items are dumb plain-old-data types without any methods but lots of public attributes which represent all properties an ...


22

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 additional benefit, if you're a one man shop this also forces you to properly back up the entire build environment. By using a slow machine you'll know when you ...


21

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: Create object Removes scene Global access? Keep across if not in scene? duplicates? Scene loads? Yes Yes ...


18

I don't think there's one accepted way of implementing this concept, but I'd really like to share how I usually deal with this in my games. It's a bit of a combination of the Command design pattern and the Composite design pattern. I have an abstract base class for actions which is nothing more than a wrapper around an Update method that gets called each ...


17

TL;DR This answer goes a little crazy. But it's because I see you're talking about implementing your abilities as "Commands," which implies C++/Java/.NET design patterns, which implies a code-heavy approach. That approah is valid, but there's a better way. Maybe you're already doing the other way. If so, oh well. Hopefully others find it useful if that's ...


17

These names vary by region, company and developer. Most of them are made up and are often just synonyms for "thing". Create names that describe the purpose of the code. A frame rate clock is called a frame rate clock. There's no dictionary for these things. You can't have a dictionary if the objects you're describing don't have a firm definition. The ...


17

From an API design perspective, when deciding whether to make multiple separate communicating programs or just one, the question is: can each program function meaningfully without the others? The answer will vary based on your project and preferences. If they can't, it's not worth thinking about. Clearly they're so heavily linked that they're not really ...


16

You totally don't need to hand-code combinations. You can instead focus on the properties that each item gives you. For instance, Item A sets Projectile=Fireball,Targetting=Homing. Item B sets FireMode=ArcShot,Count=3. The ArcShot logic is responsible for sending out Count number of Projectile items in an arc. These two items can be combined with any ...


16

There's no industry standard, but most high-profile studios do create a game design document. Game development, after all, encompasses quite a number of fields, so there will often be a combination of storyboarding, UML for the programming side, a script for dialogue, and so on. That being said, the number one "modelling language" I've encountered: flow ...


13

They're typically not even handled by the same machine, much less the same codebase. The user profile is handing by a service that deals only with users. The simulation server deals with in-game things. There may even be another session server that ties the two together. The simulation server has an ID that corresponds to each user, so its Player class ...


13

Create an engine module/folder/whatever, that contains everything that can be generalized and is 100% independent from the rest of the game. This would include some code, but also generic assets that are shared among games. Put this engine in its own git repository, which will be included in the games as a git submodule That's exactly what I do and ...


13

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 certain class isn't just unnecessary but would actually cause bugs, so you want to avoid at all cost that there ever is a second instance of it. Also consider ...


11

I agree with Jari Komppa that defining card effects with a powerful scripting language is the way to go. But I believe that the key to maximum flexibility is scriptable event-handling. In order to allow cards to interact with later game events, you could add a scripting API to add "script hooks" to certain events, like the beginnings and endings of game ...


11

is it worthwhile to have a separate process that listens for connections and messages from clients and sends the data via local sockets or stdin to another process that runs the actual game server? To answer whether it is worthwhile, you had to first ask yourself, what is the problem you are trying to solve by adding a dedicated queuing service. If it ...


11

If you can make sequences pretty general, there's not much of a spaghetti code. In case of deliveries e.g.: WorkTask operates with a WorkPlan. Workplan says what kind of resource unit must pick, from what kind of house, using which walk animation, using which work animation, time to work and all such details. So in the end WorkTask might look like: Find %...


10

Just make them global until you determine that it's a detriment to your system. Read this: http://c2.com/cgi/wiki?DoTheSimplestThingThatCouldPossiblyWork Don't add complexity unless you're getting some benefit out of it.


10

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 for you or not. If you do that, however, I suggest you drop the concept of System as you described it, as you'll have two lanes of doing things, which will, in ...


9

I gave this problem - flexible computerized card game engine - some thought some time ago. First off, a complex card game like Chez Geek or Fluxx (and, I believe, Dominion) would require cards to be scriptable. Basically each card would come with its own bunch of scripts that may change the state of the game in various ways. This would let you give the ...


9

Most entity systems don't use Data Oriented Design. Note that entity system doesn't necessarily imply DOD, it just means splitting gameplay functionality into different component classes giving entities certain features and behavior. You can (very easily) create a bloated and horribly slow Object-Oriented version of an entity system. So entity systems are ...


9

Note that there is nothing wrong with multiple inheritance. The diamond inheritance issue is... a problem. Plain multiple inheritance with no common bases is quite useful. That said, inheritance at all is generally the wrong approach unless you're implementing functional interfaces. Many class hierarchies, including your own, end up looking too much like ...


9

it is said to be very bad to hard code values and everything should come from databases, but, is that also true for a game Yes. You should read up on data-driven design and use it everywhere it seems to make sense. Ideally your ability system's code should only define the logic of abilities and then data files can define the specific abilities and their ...


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