My massive 3D Snake game (VR) using DOTS ECS + AI (ML Agents). It's all about performance

Hey everyone!

I’ve been working on this a lot and I would love to share my 3D Snake ECS game for VR.

First of all, a huge thanks to the people in this forum who helped me a lot with their answers to my posts. Without them I don’t think I could stick to the tough 72 FPS mission in Oculus VR.

This is the link to the game in Oculus - , you can see photos and read more about it.

The game called “Snakes LTD” and it’s basically have 2 main modes.

1 - Against AI, with AI agents (ML-AGENTS) against you. Your mission is to eat, kill and grow as much as you can. Rendering thousand of entities the the screen. Every time a snake dies, a ton of entities are coming out of it, and it just looks awesome now.

2- Classic Snake mode, Just you and yourself, eating food and growing to length of thousands while avoiding killing yourself.

My game contains thousand of thousands of entities which are rendered perfectly without issues with high FPS .

The main calculations of a cube following cube are all done with ISystem, and without it surely the game would have crash or just wasn’t able to take it.

Just for fun comparison, before I used ECS, my limit was something about:

In 'Agains AI' game mode:

Before ECS:

  • 8 players in the game
  • Total of 600 of moving and following cubes.
  • Total of 2000 food rendered to the map.
  • Non VFX and shaders at all.

Using ECS:

  • 20 players in the game.
  • Total of 3000 of moving and following cubes.
  • Total of 20K food rendered to the map (!).
  • Including VFX and shaders to the game without losing performance.

In 'Classic Snake' game mode:

Before ECS:

  • The game could handle about 750 of moving and following cubes.
  • (Food doesn't affect performance here because it's only a few all the time, just like the classic Snake).

Using ECS:

  • Reaching 5000 of moving and following cubes which is absolutely amazing, and believe me, it's almost impossible stay alive after about length 3000. So, yeah, DOTS is the best.

Before I used ECS I also used Jobs system to calculates the path but it still was too heavy to render more then a few hundreds.

For those of you who worked and published a game to VR, you probably familiar with the struggle of keeping the FPS high as you can because in VR, it's just feel bad when you're interfacing a low FPS. You can actually feel see it.

Little note: I'm about to publish this game to mobiles (IOS + Android), PC and I'm also working on a multiplayer version with friends using Unity network solution.

I will be more than happy to share some of my solutions if someone will need any.

Again, big thanks for the people here, I can honestly say that I couldn’t make the game the way it is without your help. This was the main reason for this post, just to say thanks.

This is the trailer for the game if anyone interested



Great work. It looks fun. Could you say something about what parts are using a lot of CPU/GPU time?

1 Like

It looks interesting, specially considering it is VR + DOTS.

Is motion siknes any issue here, in such type of a game?

1 Like

In general I would say...
There is a lot of open space that should help against motion sickness since stuff does not move fast.
The cockpit should give you enough vision orientation to help. Just increase the amount the cockpit blocks vision in order to make it less motion sickness inducing.
Higher framerate would also help against motion sickness, but 72Hz is a pretty standard value.

But correct me if i am wrong :-)


I can not confirm, nor deny anything, since I don't have oculus VR. But more I am of a curious being :)
Thx for explanations.

1 Like

This comment was more for the OP, in case this game has something special relating to motion sickness. But I agree the wording was not optimal :).

Thanks a lot! Appreciate it.

Well, I used some heavy materials for the snake's body, which when you render 1K + of those materials they will absolutely can ruin the flow of the game.

One interesting solution I did is to use IJobChunk in ISystem, I checked the distance of every object to the main camera, and when it was farther then X, I altered the material to a cheaper one using Material Mesh Info, That surely saved my game with a lot of help to the quick calculations of distances checks.

VFX and shaders was also big consuming in VR, so I had to use a queue for the activation of the VFX for each player, every FixedUpdate just to avoid overheat frames.

Basically whenever I could divide the actions to frames and queues and not executing multiple actions in one frame, (when a players eat, die etc...) the frames were at their finest.

1 Like

Most certainly!

I specified in the "Comfort" section in Meta store that this is "Intense". (If there were a bigger word for sickness I would have used it as well :) )

But there are audience that love extreme games in VR that can challenge their capability.
I am totally aware of that people might not like the sickness and that's ok.

I actually think this game is more suitable for mobile devices. The VR was just a fun idea.


Well, yeah. I added a "Spaceship cockpit" to let your brain think it's ok to fly around space, because you'r flying a spaceship. This kind of solutions are popular in VR games.

There were also some other small tricks to help sickness, like using "Vignette" when rotating the Z axis. ('Vignette' is when most of the screen becomes black except the middle, and by that blocks the view of the whole game rotates, which can lead to serious motion sickness).



Awesome work!
May I ask which version of Unity and other packages you are using? I wanted to dive into ECS for a long time, but had never dared to since it’s still such a novel “technology”.

I look forward to more updates :)

1 Like

Hey there! great job with your game. May I ask your approach for training your ML Agents using ECS? As far as I know ML Agents are gameobjects in the scene, how do you connect inputs and outputs those ML agents and the ECS parts of the game?