New answers tagged

0

Here's one way to go about it. Let's make the HealthBar its own entity and take advantage of the fact that entities can reference the same component instances. So instead of setting up a parent/child relationship between the Player and HealthBar, we'll have them share components, in this case, the Position and Health components as seen below: // create ...


0

One way to approach this is to have some facility for components that don't normally deal with movement to request of the appropriate that a movement occur. If you're using a message-passing approach to talk between components, you'd just fill out a RequestMovement message with information about the desired movement or animation and send it off, and the ...


6

"Manager" classes can be problematic for various reasons. The two key reasons tend to be: the name is unclear (what actually does "management" entail, and is it always the same for every type of thing being managed?) they tend towards being buckets of functionality that violate the single responsibility principle (that is, that a type should do one thing) ...


5

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 development that global variables are evil, and the only alternative is that any data is held by other data. The problem with a class named FoobarManager is that the ...


3

In a classic MVC world, the networking is split into a controller and a view component. Network input is a controller, because it processes commands which then result in changes to the model. The network output is a view, because it translates the model changes which are happening in your game into a network protocol. This is not much different from ...


1

I will trow my implementation too for future generations . void Awake() { if (instance == null) instance = this; else if (instance != this) Destroy(gameObject.GetComponent(instance.GetType())); DontDestroyOnLoad(gameObject); } For me this line Destroy(gameObject.GetComponent(instance.GetType())); is ...


3

I need somehow to delay an initialization of other level's entities Why not add an init() and a terminate() methods to your Level class that does just that? init() populates your level when you're ready to play it, and terminate() cleans everything up when you're done with it. You might want to consider changing your architecture to have Level created ...


0

I encountered a similar problem while working on a project of mine. The player was able to pick up a certain variety of weapons, which shoot different type of bullets. I'll help you to figure out a solution for you by explaining the solution I found for my game. In order to take advantage of inheritance and polymorphism, I managed to work out all the ...


1

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 not "Domain Modeling" is good for games. Is domain modeling good for games? The answer is: sometime it's absolutely fabulous. However, if you're creating a ...



Top 50 recent answers are included