Intro
I've been following Unity3D's DOTS development for a while now and I've been doing a few tutorials on getting ECS going. However, nowhere have I found it to be clear that Unity3D is deprecating their current GameObject/Hierarchy approach and replacing it with the new Entity/ECS approach.
Theories
At present, it seems like a hybrid between the two, so anything that typically belongs in a object pool or could cause memory fragmentation (projectiles, items, respawning units, etc.) uses Entity/ECS, and the rest still use GameObject/Hierarchy.
This seems less than ideal to me since the non-optimal approach will block going to the next frame where the optimal one will wait. Where if only ECS was used, you will get a lot more frames out, which is kinda the point...
On the other hand, having to onboard designers and animators to use something like ECS would just be expensive (at the moment) and much more technical. The current ECS window in the editor is not really intuitive and less a tool than simply a result output.
Question
So my question is, does Unity3D plan to keep the hybrid approach and if so, how do we choose whether to use an entity or a gameobject? Or if they are going with the ECS only approach, will the current entity editor window be changed to accommodate designers/animators?
Related
We are currently making our dream game with thousands fast dying zombies.
Problem is - we are making it for mobile devices.
Hybrid ECS is not enough, cuz even 100-200 low poly zombies is to heavy for render even after ultimate optimization.
Solution is use only pure ECS. Followed this tutorial i can spawn now 2-3k zombies on 40-50fps on low end devices.
But, im stuck on adding behavior. I just cant add it on each entity. By getting this tutorial as example - how to add custom behavior like AI scripts/systems for each cube?
I tried to add "system" on it, but it applies only on GameObject that u use for getting copy's.
P.S. I dont want to use external ECS frameworks, cuz im sure in future Unity built-in ECS will be the ultimate "from box" solution.
You don't. With Unity ECS you register systems. Systems work on entities that have certain components attached. E.g. you can create a system that processes all Zombies (e.g. all entities with a "Zombie" component) and execute some logic for them in each tick. The trick with ECS is that you do not handle each entity separately but you run logic for all entities that share certain criteria. This is why it is so fast, but it requires to let go of the Monobehaviour approach, mentally. I found this tutorial helpful in getting some start of actually implementing logic: http://infalliblecode.com/unity-ecs-survival-shooter-part-1/
It's not 100% up-to-date but it should be enough to get you an idea how things roll with ECS.
I want to create a procedurally generated history system for a game I am making, somewhat similar to Dwarf Fortress even though that's really complex. I have taken a stab at it and it didn't turn out too well. So I was wondering how should I go about creating this system? How do I make civilizations be allies, enemies, trade, go to war, control population, farm for themselves, etc. Again this doesn't have to be realistic, just make an interesting story for the player to discover about the world they are playing in.
Thanks!
You should probably start by looking at graphs: https://en.wikipedia.org/wiki/Graph_theory
Peace/war status mostly depends on competition for resources and their initial proximity to the resources and their skills. You mind find some inspiration in biology (predator/prey).
An already large civ. will negotiate less and assimilate more.
A first step is always to trade, then control more trade, then conquer to completely own the trade (then collapse).
Think about a few real world history cases and try to model according to that. Each civ. ultimately computes a cost score and tries to optimize gains while reducing losses.
I am about to start a project that I hope will some day require the capacity for scaling. The key question for me is: should I invest the effort to design for this eventuality now, or should I cross that bridge when I get there?
I know how these things go: everyone thinks their project might scale, but most projects never do.
Is there a set of best practices that will allow you to scale more easily at a later stage, while not investing too much in something that may never be needed?
Obviously I have no experience with scalable web sites. Currently I am leaning towards Scala / Play! / Akka. From what I can glean from the Akka website, it is very suitable for this kind of project (in that it provides a toolset that allows development on a single machine and scaling out to an arbitrary number of machines).
The project is a consumer-facing web site that involves some user interaction (comments, messages, voting etc.). The main focus is editorial, though. It's no Facebook :)
Not being experienced in any of these technologies (my experience mainly coming from PHP, AS3, Objective-C), I probably have a little too much on my plate right now. But then I am not going to go at it right away. I am aware that I need to get some experience using Scala and Play! first.
Any advice is greatly appreciated.
Start out by simply designing you model, build unit tests for that and then set your presentation layer on top of it. As long as your model is sensible, it will be easy to scale Play out to any number of machines. If you go for the build in JPA support, you can always deal with the question of which DB to go for.
You have larger things on your plate for the time being. So just make sure your design is consistent and sensible, then scaling will not be a problem.
You've got a head start by using a stateless web framework like Play! that won't get in the way when you need to scale. As ExxKA says, keep your model clean and sensible. This will help you keep the advantage of complexity.
Don't consider it a failure when you need to refactor your code - or even rewrite important parts of it. This is a natural part of a growing project, like a snake shedding its skin.
There are inevitably things that you'll learn in the process of writing the project, so don't try to anticipate them all right now.
Today, I had a training on "Microsoft Workflow Foundation".
While I think the idea is neat, I still see it as a Proof Of Concept and not as a real-life solution. Building an entire application without having to type a single line of code (or only a few of them) seems just wrong.
Have you ever used this technology and if so, can it really fit to big company projects ? What drawbacks/advantages have you got using it ?
I don't see it replacing an entire application, but more likely used in the architecture of an application to make it easier to maintain and build, since business logic is separated out.
In previous application I've built, we used our own workflow solution to make our site easier to maintain and also to add new content and controls quickly without recompiling & redeploying.
MWF can definitely have a place in even small applications, depending on it's needs.
Workflow is just a part of a larger application, just like your entire app isn't WPF or ADO. And it is certainly used in real applications and very useful. Things to look for where it is a good fit are items that behave as small projects in an applications like a sales orders, hiring a new person or building a house. All thee have a start, go through multiple steps, have an ending and you are likely to manage multiple in your application. Describe the "project" steps in one or more workflows and start one for each occurrence.
As this is a very common occurrence I believe far more developers could benefit from using workflow in their applications.
Lately I've been using it to replace those parts of the codebase that are really messy as far as the branching and looping logic is concerned. When you can visualize that stuff in a picture, and just create some custom activities to perform your logic, it makes knowing exactly what is going on much easier.
The entire application wasn't rewritten, for example there's really no reason to do any CRUD type operations with workflow, but its been very helpful for some of the "heavy lifting" operations.
Using a IOC container will decrease the speed of your application because most of them uses reflection under the hood. They also can make your code more difficult to understand(?). On the bright side; they help you create more loosely coupled applications and makes unit testing easier. Are there other pros and cons for using/not using a IOC container?
If you're using an IOC container in a simple fashion, reflection is only used on startup - the application is wired up to start with, and then it runs as normal without any intervention from the container. Of course, if you're using the IOC to resolve dependencies after you've started running, that may be slightly different - although I'd still expect it to resolve lazily and cache unless you've got it configured to create new instances each time.
As for making the code harder to understand - quite the reverse! With the dependencies explicitly stated, it's much easier to understand each component, and the configuration file(s) make it clear how the whole application hangs together.
Well I suppose a con I've experienced is that some developers don't seem to be able to grasp IoC. We've had a few people who were against it for no reason other than that they didn't understand them. (Not saying that's a bad reason to be against something, not at all.)
It does add a bit of abstraction that always seems to manage to confuse someone or other, but I'd say the pros far outweigh the cons in most cases.
I think it is fair to say if you have expert understanding of how to use IOC and tend to write good code anyway, then IOC will make your code easier to understand on all but the smallest systems.
However if you are working somewhere where most classes/methods are very large and the concept of refactoring has not yet taken hold, then trying to use an IOC is likely just to make the software harder to understand. The IOC also has to be leant by everyone that programs on the project, so that may be a consideration.
I see IOC as icing on the cake; I like the icing but only on a nice cake. If the cake is not nice to start with, sort out the cake first.
As to the performance overhead of using IOC, I don’t see this as a problem in most cases. The overhead need not be large, and given the speed of today’s CPU most of you run time is likely to be data access anyway. If a IOC proved to slow for a given bit of code I would look at adding some caching of returned object, or removing the IOC just from that bit of code.
I believe the assumption about reduced execution speed is much the same kind of argument as "C is faster than C#/Java". While this statement may be true for specific operations and/or structurally simple tasks it is not the case the moment complexity rises.
The way DI-frameworks let you focus on object creation and dependencies creates more efficient systems when code size increases. For large applications I'm almost certain DI-framework based code will outperform any alternative solution. There's simply so little redundancy in the runtime that it's hard to make it more efficient! Most of the additional overhead is also just at first load.
Advanced DI containers also lets you do "scope" magic that you can only dream of without the container. Using scope-proxies, spring can do the following:
A Singleton
|
B Singleton
|
C Prototype (per-invocation)
|
D Singleton
|
E Session scope (web app)
|
F Singleton
Effectively you can have ten layers of singleton objects and all of a sudden something session scoped shows up.
Stuff like security can be injected in totally different manner than you would otherwise. There's often a classical paradox: Often the GUI layer needs to have intricate knowledge of the security permissions. Quite often the services layer also needs this, but often at a different level of detail (usually less detailed than the gui). The classical approach would be to send it around as parameters, put it on a threadlocal or to ask a service. With spring you can just inject it straght where you need it and no-one else needs to know.
This actually changes application development as a whole. I had a real hard time adjusting to this, but after this pain I see it is truly a lot closer to how things should be (as opposed to how we've learned to do it).
So I think DI frameworks have the potential of changing the way you make programs, with much further reaching implications than just DI. It's not just a glorified way of calling new.
I agree with all the answers so far.
What I'd like to add, is that it creates a bit of overhead, so it isn't really suited for small applications.
Mid-size and larger applications benefit the most from using IoC.
You might also check out this question for more information on pros and cons: Castle Windsor Are There Any Downsides?
In most circumstances you would not even notice performance penalty since for "singleton" objects all the initialization is performed once only. I would also argue that IoC makes it different to understand the code: on the contrary, IoC-style development forces you to create small coherent classes, which are in turn easier to grok.
If you are writing a business application, using an inversion-of-control and dependency-injection container (in conjunction with other agile practices and tools) will help you out in terms of productivity and reliability.
Moreover, your application will probably spend a vast majority of its CPU time waiting for resources or waiting for human interaction and doing nothing useful. Your application should have plenty of horsepower to spare for a few microseconds of reflection.
It seeks to reduce their dependency with IOC by ensuring object instance management within the application. The framework, rather than the developer, is in charge of creating and managing dependencies in your project.
The framework calls and runs our code when we write a block of code, and the entire event of passing control back to the framework is known as the Inversion of Control.
It enables the execution of a method separate from its
implementation.
It enables you to switch between multiple implementations with ease.
increases the modularity of the software
Because dependencies are reduced, it is simple to test and write.