Code Design
ECS abstraction layers and modules encapsulation
Introduction This long due article will conclude the series on Entity Component System Code Design and will explore the idea of Inversion of Control layers applied to ECS. While this is going to be my last article on the topic (at least for a while), I plan to review and
OOP abstraction layer in an ECS-centric application
There are several reasons why programmers have a hard time wrapping their heads around ECS concepts. Having learned to code with an OOP centric language is one of them as ECS reasonings are often at the antipodes from the OOP ones.Being Object-Oriented Programming so popular means that it is not
The Quest for Maintainable Code and The Path to ECS
Premise In this potentially controversial article, I will explain why I believe ECS is a great paradigm to write simpler to maintain (and therefore less expensive) code and I will also try to explore the idea to formalise best practices through the application of the SOLID principles, which at glance
The truth behind Inversion of Control – Part IV – Dependency Inversion Principle
The Dependency Inversion Principle is part of the SOLID principles. If you want a formal definition of DIP, please read the articles written by Martin[1] and Schuchert[2]. We explained that, in order to invert the control of the flow, our specialized code must never call directly methods of more abstracted
The truth behind Inversion of Control – Part III – Entity Component System Design
In the previous article I explained what the Inversion of Control principle is, then I introduced the concept of Inversion of Flow control. In this article I will illustrate how to apply it properly, even without using an IoC container. In order to do so, I will talk about Entity
The truth behind Inversion of Control – Part II – Inversion of Control
Note: this article assumes you already read my previous articles on IoC containers and the Part I Inversion of Control is another concept that turns out to be very simple once it has been fully processed or rather saying “absorbed”. Absorbed as going over being understood and becoming part of
The truth behind Inversion of Control – Part I – Dependency Injection
Note: this article series assumes you have already read my previous articles on IoC containers. There is an evil truth behind the concept of Inversion of Control container. An unspoken code tragedy taking place everyday while passing unnoticed. Firm in my intentions to stop this shame, I decided to stand
Inversion of Control with Unity – part 2
Note: this article explains the use of my old IoC container in more details. However I long stopped using it and its now deprecated, so read it for knowledge, but know that I now recommend to use an IoC container only to develop games as the ECS paradigm doesn’t need
Inversion of Control with Unity – part 1
Unity is a good game development tool and honestly I like most of its features. However the code framework is awkward to use on big projects where code maintainability is of fundamental importance. As you may have guessed, the following considerations in this article do not apply to simple projects
Svelto
Svelto.ECS 3.3 and the new Filters API
among many other features, Svelto.ECS 3.3 introduces a new shiny and finally usable filters API. The previous one had the bad habit to get very awkward very fast with the growth of complexity. The new API learns from the previous mistakes and introduces a ton of sweet features. To recap
What’s new in Svelto.ECS 3.0
Svelto ECS 3.0 Internals: profiling the Entity Collection
Previously, in Svelto.ECS, it was possible to query entity components directly as a managed array, which would have resulted in the fastest way to iterate over the components in c#. Since Svelto.ECS 3.0 and because now the framework supports natively native memory as well, I decided to remove this possibility
Svelto ECS 3.0 Internals: Support Native Memory Natively
With the approaching third major release, Svelto.ECS internals have been overhauled to support Burst and native memory (among other features that I will discuss in different articles). The idea to support native memory in a c# framework is counter intuitive, but Burst is such an incredible piece of technology that
Svelto.ECS Internals: How to avoid boxing when using structs with reflection
I had two interesting problems to solve during the development of Svelto.ECS, which in short are: Set an implemented property of a struct, but only when the struct implements a specific interface, from a generic method and without casting the struct to the interface Assign an object to a field
Distributing Svelto through OpenUPM
The Unity Package Manager is a good effort from Unity to distribute project dependencies similarly to what NPM does. UPM is still in its infancy and some problems are to be addressed, among them the conflicts arising from common .net dll is the problem that annoys me the most. Currently,
Introducing Svelto ECS 2.9
Being busy on multiple fronts, I recently went AWOL from this blog, but Svelto is keeping up well with the new technologies (read Unity DOTS) and we are actively developing it for our new game Gamecraft. I am also spending my little spare time to develop Svelto 3.0, which will
Svelto MiniExamples: GUI and Services Layer with Unity
Introduction: The Svelto.ECS methods designed to implement ECS based GUIs are simple and powerful, following the fundamental principles around the whole Svelto implementation. Their design doesn’t involve use of callbacks, as it relies on the power of Svelto.Tasks (but you can achieve similar results with other patterns like async/await) and
Introducing Svelto ECS 2.8
Welcome back! It’s some time that Svelto ECS 2.8 is actually ready, as it has been used at Freejam for quite a while now (yep, we are developing Robocraft Experiments with it) and as the list of tasks for SECS 2.9 is growing, it was time to write this article
Svelto Mini Examples: The Unity Survival Example
08/04/2019 Note: this article is quite old (pre SECS 2.5) but since I ported the example to Svelto 2.8 (beta version at the time of this note), I updated this article as well, although it is still missing some important details related to the new features that ship with the
Svelto Mini (Unity) Examples: Doofuses Must Eat
Note: this article is not maintained. The mini example Doofuses has a third and final iteration for a long time now and it is what all my new articles refer to when talking about this example. Iteration 3 enhances the code using Burst and Jobs. After finishing writing my previous
Introducing Svelto ECS 2.5
Svelto ECS so far… Svelto.ECS wasn’t born just from the needs of a large team, but also as result of years of reasoning behind software engineering applied to game development(*). Compared to Unity.ECS the main goals and reasons for Svelto.ECS to exist are different enough to justify its on going development (plus Svelto is
Learning Svelto Tasks by example: The million points on multiple CPU cores example [now with Unity Jobs System comparison]
[11/03/2018] : added Unity Jobs System version and updated timings. Please check at the end of the article. With my previous article on Svelto.Tasks and multi-threaded cache friendly code, I failed to show visually the power of Svelto.Tasks because I didn’t know how to upload a huge amount of data
Learning Svelto.ECS by example – The Vanilla Example
Note: this is a seriously outdated article. Some concepts may be still valid, other totally misleading. Be sure you put all the pieces together reading all the articles and give more importance to the latest ones. It’s not simple to learn a new framework and even less shift code paradigm.
Svelto.ECS 2.0 is production ready
This an introductory post to Svelto.ECS 2.0. Other two posts will follow, one explaining the examples line by line and another explaining all the Svelto.ECS concepts in a simpler fashion than before. Therefore this article is written for who already knows Svelto.ECS. Svelto.ECS 2.0 is (at the time of writing
Svelto.ECS+Tasks to write Data Oriented, Cache Friendly, Multi-Threaded code
Note: this article assumes that the reader knows how to use Svelto.ECS and Svelto.Tasks although the findings are interesting regardless. Introduction New exciting features are coming to Svelto.ECS and Svelto.Tasks libraries. As I am currently focused on optimizing Robocraft for Xbox One, I added several functionalities that can help
Svelto TaskRunner – Run Serial and Parallel Asynchronous Tasks in Unity3D
Note: this is an on-going article and is updated with the new features introduced over the time. In this article I will introduce a better way to run coroutines using the Svelto.Tasks TaskRunner. I will also show how to run coroutine between threads, easily and safely. You can finally exploit
Svelto ECS is now production ready
Note: this article is now outdated as Svelto.ECS 2.0 is out. Read it to have a complete picture on the concepts, but the most up to date information can be found now here. Note: in this article you will meet the term Node which has been superseded by the term Entity
Other
How to debug Unity with a native debugger using mixed c++ and c# stack
Note: this is an article dedicated to the windows platform. What am I going to show may or may not apply to other platforms. Those pesky native crashes If you are a long term unity developer, it must have happened to you: Unity suddenly closes itself and shows the dreaded
The #1Millioncubes challenge. How I managed to animate a freakload of cubes on windows using Unity
For the game I am currently developing, Gamecraft, we are using Svelto.ECS for the game logic, Unity ECS for the physic and GPUInstancer compute shader pipeline for the rendering. I have never had the time to benchmark the UECS rendering pipeline against the GPUInstancer one, mainly because I decided directly
Zero allocation code in C# and Unity
I promised myself to not write new articles until Svelto.ECS 3.0 is out, however a recent tweet asking about how to achieve zero allocation code in Unity inspired me to write a short piece about the importance of memory allocation in c# and game development that I previously planned as
Fastest way to set elements in a preallocated array in c#
Finally I found the time to play with unmanaged arrays and Memory<T>/Span<T>. In order to investigate possible improvements of the data structures used by Svelto.ECS, I wanted to know what the fastest way to set elements in a preallocated array could be. Using the very powerful BenchmarkDotNet and with the
C# Murmur 3 hash anyone?
If you need a fast and reliable (read very good to avoid collisions) hashing algorithm (not cryptographic), look no further, Murmur 3 is here to the rescue. Take it from here, it’s compatible with Unity3D. Directly translated from the c++ version. More info on Wikipedia and on this definitive answer on stack overflow
Svelto Inversion of Control Container
If it’s the first time you visit my blog, please don’t forget to read my main articles on the subject before to continue this post: http://www.sebaslab.com/ioc-container-for-unity3d-part-1/ http://www.sebaslab.com/ioc-container-for-unity3d-part-2/ It’s finally time to share the latest version of my Inversion of Control container, which I named Svelto IoC, which I will keep updated
What I have learned while developing a game launcher in Unity
This post can be considered partially outdated as my mind changed quite a bit since when I originally wrote it. First of all, I would never suggest to write a game launcher in Unity now. Use instead .net or the latest version of mono with xamarin. Mono library embedded with Unity 4 is too
What’s wrong with Unity SendMessage and BroadcastMessage and what to do about it
Unity 3D is a well designed tool, I can say that. It is clearly less painful to use than UDK, no matter what its limitations are. However, as I keep on saying, the c# framework is still full of bad design choices, probably unfortunate inheritances from unity script (why don’t
How to compress and decompress binary streams in Unity
recently I needed to compress a binary stream that was getting to big to be serialized over internet. I could not find any way to compress files easily, so eventually I used a 3rd party library that works very well in Unity3D (web player included): SharpZipLib I suppose the following
My First Flash Multiplayer Game with Photon Cloud
For a long time I wanted to make some experiments with Photon Network Engine at home. During my professional experience, I worked on several multiplayer games, therefore I was pretty curious about it. Exit Games provides two versions of Photon Network Engine: the traditional Photon Server edition and the new Photon Cloud
On Commands and Events
Events and Commands are two communication tools that I use really often. I have planned more exhaustive articles on the topic, but now I want to write a short post about one rule I apply when I use them. Sometimes it occurs to me the question: should the listener class know
Develop HTML5 games without JS and DOM for flash developers – Part 2: Jangaroo
The reason why I called the first tutorial of this series Part 1 is because I knew there were other alternatives around to develop HTML5 games, carefully avoiding javascript. However after some researches it turned out that the only really working alternative suitable for actionscript developers is Jangaroo. Let’s talk
Run Serial and Parallel Asynchronous Tasks in Unity3D and C#
Please note, this article refers to an old version of the TaskRunner which is not supported anymore. The latest version is here. Every now and then it is necessary to run a series of tasks in a given order, for example to guarantee that some data has been downloaded before to continue
My First Game
knowing how short my memory is, I saved all my professional life memories in a folder on my HD. Some of those memories are meaningful only to me, but why not sharing my first, completed game (yeahh it was 1997…I think) ? The version I am linking is actually the
Perlin Noise – Notes
Some time ago I collected some notes about Perlin Noise all over the web (sorry I don’t remember the original articles). These notes were finalized to implement a GPU coherent noise based smoke effect. I reckon these notes could be useful for somebody else as well.
Design By Contract Actionscript helper class
I did not plan to write this article, but since I wrote this bunch of classes in few minutes, I thought to share the code with everybody. I did not invent anything, I just ported the useful Kevin McFarlane’s DesignByContract helper class that I use for my c# Unity Projects
Develop HTML5 games without JS and DOM for flash developers – Part I: Haxe
Before I start talking about my first “HTML5” experience, let me say something: after 15 years of c++ game development today I make games at the company where I work and I experiment at home using ActionScript 3, C# (Unity) and Haxe. Do I miss the C++ times? Not really,