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


56

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


36

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


28

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


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


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

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

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


9

So, Mike Hunt, your question so interested me, I decided to implement a full solution. After three hours of trying different things, I ended up with this step-by-step solution: (Please note, that this IS NOT very good code, so I will accept any edits) Creating Content Panel (This panel will be a container for our context-menu buttons) Create new UI Panel ...


9

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 completely irrelevant when it is executed once at game startup, worth watching when executed every frame and must definitely be optimized if executed for every game ...


9

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 requires a bit more mental power. If the mouse is an option then Legend of Grimrock has a nice idea - a 4x4 or 5x5 square board (can't remember). The combos ...


8

For very fast projectiles (such as lasers or bullets), you could use, a Ray. A ray has a start point and an end point. A (very minimal) data structure for a ray is: struct Ray { Vector3f start, end ; } ; Looks like this: (You could also cache the direction vector and length, but I used a very simple defn above). If the ray is a laser beam that ...


8

If you are using an OOP language, this sounds like a good place to employ the Decorator Pattern. When you want to modify how an attack happens just decorate it with the appropriate augmentation. Crude c++ Example: class AttackBehaviour { /* other code */ virtual void Attack(double angle); }; class TearAttack: public AttackBehaviour { /* other ...


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