Latest Articles
Code Design
Entity Component System 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. I design code in terms of layers for quite some time now and, in fact, I have hinted at it several times in
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 of the OOP ones.Being Object-Oriented Programming so popular means that it is not simple
The Quest for Maintainable Code and The Path to Entity Component System design
Premise In this article, I am going to explain why I believe the Entity Component System design is a great paradigm to develop simpler to maintain (and therefore less expensive) codebases and also 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]. This is the most difficult principle to get right. I will take a step back from the previous article I wrote and discuss
The truth behind Inversion of Control – Part III – Introduction to Entity Component System Design
In this article, I will explain the previously introduced Inversion of Flow control, then I will illustrate how to apply it in OOP and how this can be best achieved using the Entity Component System design. While ECS design apparently seems to have nothing to do with Inversion Of Control,
The truth behind Inversion of Control – Part II – Inversion of Control
If you got here from my previous articles, you may have still many questions unanswered, with one possibly being: why is an IoC container called Inversion Of Control Container? The first answer is: because someone chose historically a bad name[1]. The serious answer is: IoC containers take away the responsibility
The truth behind Inversion of Control – Part I – Dependency Injection
There is a wicked truth behind the use of an Inversion of Control container, an unspoken programming tragedy that takes place every day. Firm in my intentions to understand better the severe consequences of using an IoC container in game development, I decided to write this series of articles that
Inversion of Control with Unity – part 2
Note: this article explains the use of Svelto.IoC container in more detail. However, I deprecated it a long time ago, so read this article for knowledge, but know that I now don’t recommend using an IoC container in any project. In my previous article, I briefly introduced the problems related
Inversion of Control with Unity – part 1
Unity is a good game development tool and honestly, I like most of its features. However, the programming 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.4 – Svelto On DOTS ECS update
Introduction Svelto.ECS is a platform-agnostic C# Entity-Component-System framework. You can catch its flexibility in action through the Svelto mini-examples, with applications written for Unity, .Net, SDL and Stride Engine. When using Svelto.ECS with Unity, the user has the option to take advantage of the entire DOTS suite or specific parts,
The new Svelto.ECS Survival Mini Example
Introduction My Xmas gift to the Svelto Community this year was the complete rewrite of the Survival Svelto.ECS MiniExample. This example is used as a reference by all newcomers because it’s the simplest to digest for people who are not in the ECS mentality and still think in terms of
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
Entity Component System 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. I design code in terms of layers for quite some time now and, in fact, I have hinted at it several times in
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 of the OOP ones.Being Object-Oriented Programming so popular means that it is not simple
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
2022 Update I leave this article up for historical purposes, but almost everything written here is not recommended anymore. The publisher/consumer tool especially was designed to let separate EnginesRoots communicate with each other in a thread-safe way. Any other use of it is confirmed to be an abuse, including the
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
Note: this article is now outdated. The new version is found at: https://www.sebaslab.com/the-new-svelto-ecs-survival-mini-example/ Introduction Lately I have been discussing Svelto.ECS extensively with several, more or less experienced, programmers. I gathered a lot of feedback and took a lot of notes that I will be using as starting point for my
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 making
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
20/03/2023 update I wrote a new demo that doesn’t need to use GPUInstancer. Code is now available on github. Note that I also updated the code to use GraphicBuffers instead than ComputeBuffers. For the game I am currently developing, Gamecraft, we are using Svelto.ECS for the game logic, Unity ECS
Zero allocation code in C# and Unity
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. C# wasn’t initially designed for game development, but today, thanks to Unity, ECS and Burst, we can achieve great
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,