#archived-dots

1 messages Β· Page 16 of 1

open shore
#

I just installed Entities, Dots Editor, and Hybrid Renderer in an empty project on Unity's latest LTS version and I'm already getting errors...
Does anyone know what to do?

open shore
#

@rustic rain seems to be fine

#

oh wait, I might've missed a step

#

yeah I did everything listed in there but I'm still getting the error

rustic rain
#

what unity version do you have?

open shore
rustic rain
#

how you install entities?

#

wait

#

dots editor?

open shore
#

yeah it was recommended on some document

rustic rain
#

afaik this is deprecated package

open shore
#

I downloaded them with git url

rustic rain
#

if you want all i one package for base entities

#

just install hybrid renderer

open shore
#

oh I was following an outdated doc page

#

So while I'm at it, I'm gonna ask a question. I just recently started looking into DOTs and as far as I've seen, in order to create entities, most projects either use a conversion component on their game objects, or use a subscene that does the same thing behind the scenes. Surely this isn't the ideal way to build a scene with entities, right?

rotund token
#

Subscenes are entirely the ideal way to build entities

rustic rain
#

subscene is the best
They are built AOT
They are very fast at loading/unloading

viral sonnet
open shore
#

I can see some problems with this, including:

  • Since Unity uses a monobehavior component for the conversion, it is done in realtime when the gameobject loads. It sounds very inefficient.
  • Conversions can lead to unexpected results. I really doubt that every single GameObject in a complex scene will be perfectly converted just as I expect it to.

I think that subscenes are great, it's just the conversion part that I don't like. Why do I have to create a GameObject just do delete it and replace it with a similar Entity? It'd be much faster to just directly create an Entity.

viral sonnet
#

eh, i'm late. ignore me then πŸ˜„

#

subscenes are not converted during runtime

open shore
#

are they converted before I build my project?

viral sonnet
#

it's all happening at editor stage and serialized in an efficient format to load/unload

#

GOs can have very complex authoring scripts attached. it's up to you really.

open shore
#

I'm pretty sure that after you ship your game, the game program contains the game objects and they will be converted whenever you start the game.

viral sonnet
#

the GO itself will be not exist during runtime. there are exceptions, like when you have the subscene open

#

that's not how subscenes work πŸ™‚ there will be no GOs. especially not in a build

rustic rain
rotund token
#

all my authoring components are in editor only assemblies

#

subscenes are converted to giant blocks of binary data

#

and loaded from disk directly into the world

open shore
#

Where can I read more about how the conversion works behind the scenes? Every document I've read and video I've watched done a horrible job in explaining how it works.

rotund token
#

when you build, these subscenes are stored in the StreamingAssets folder in individual files

rotund token
#

as you point out, runtime conversion is slow and should be avoided and this is basically why subscenes exist

open shore
#

My main concern was the performance of converting in runtime, so I'm glad that it's not the case. But I'm still wondering if there are any alternatives to the conversion workflow?

rotund token
#

You should look at the Gdc talk on this workflow in 1.0

rotund token
#

or creating entities in code

#

both bad options

#

i still don't understand why all fresh dots developers instantly have a hate for subscenes

#

and it takes ~6months before they're converted

viral sonnet
#

alternatives for what? what are you looking for? prefabs in the assets folder also work in subscenes. need to be referenced rhough to load

open shore
#

I don't hate subscenes, I hate the fact that I can't directly create entities within the editor. From what I've seen, subscenes have more uses than just converting entities.

rotund token
#

they really are just for creating entities

#

This video covers the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It also addresses a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with...

β–Ά Play video
viral sonnet
#

a subscene is exacty for that. creating entities in the editor πŸ™‚

rotund token
#

watch this to understand what unity is aiming for

open shore
rotund token
#

start at 17:40+ to see 1.0

rotund token
#

all you're doing is creating entities

viral sonnet
#

i'm still on this one
works:```

var updateDurationHandle = new UpdateSpellEffect_Duration
{
SpellEffect_DurationEndTick_ReadHandle = GetComponentTypeHandle<SpellEffect_DurationEndTick>(true)
...
}.ScheduleParallel(mainEffectsQuery_Duration, Dependency);

var removalHandle = new RemoveSpellEffects
{
...
}.ScheduleParallel(mainEffectsQuery_Removals, updateDurationHandle);

Dependency = removalHandle;```

doesn't work:

{    
    SpellEffect_DurationEndTick_ReadHandle = GetComponentTypeHandle<SpellEffect_DurationEndTick>(true)
    ...
}.ScheduleParallel(mainEffectsQuery_Duration, Dependency);

var removalHandle = new RemoveSpellEffects
{
    ...
}.ScheduleParallel(mainEffectsQuery_Removals, updateDurationHandle);

var removalHandle2 = new RemoveSpellEffects_WithStats()
{
    ...
}.ScheduleParallel(mainEffectsQuery_RemovalsWithStats, updateDurationHandle);

Dependency = JobHandle.CombineDependencies(removalHandle, removalHandle2);``` RemoveSpellEffects_WithStats doesn't run because my test effect has no stats. maybe that causes the problems
cunning falcon
#

We upgraded our game project from 2019.4 to 2020.3.38 and it's working fine -- except that builds fail, due to a bunch of errors about Collections, starting with this one:

Library\PackageCache\com.unity.collections@1.4.0\Unity.Collections\AllocatorManager.cs(237,37): error CS0246: The type or namespace name 'AtomicSafetyHandle' could not be found (are you missing a using directive or an assembly reference?)

The rest are similar, pointing to different scripts in Unity.Collections with the same issue. This is very strange since I did some test upgrades of the project and they had no trouble doing builds. Below are the packages installed. I found this thread from 2020 and tried what people suggested, but no help: https://forum.unity.com/threads/missing-references-in-the-collections-package.847027/

Any help would be much appreciated!

thanks
Dave

rustic rain
cunning falcon
rustic rain
#

can you try to turn it off?

cunning falcon
#

delete it? I'll try that

#

darn, the build still fails. Same errors

cunning falcon
rustic rain
#

not for me

#

but pretty sure this define is always on in editor

viral sonnet
rotund token
#

yeah it should not exist in scripting defines

#

because unityengine itself will not include it internally

#

so all the safety will be stripped from unityengine

#

but you are including it in your code which is causing the issues

#

as far as i'm aware no unity library will add this to your defines so it's likely your code or a library you're using adding it

cunning falcon
#

Ah okay! Will look into it. Thanks so much for the help!

viral sonnet
#

something really weird is going on with this sytem and its dependencies. if i combine the updateDurationHandle it complains about another comp from the remove jobs. yet their handles are added. makes no sense. shit

rotund token
#

you've broken something

#

it's likely nothing to do with your handles btw

#

exactly where is the error being thrown from

viral sonnet
#

i can get it working when removing the RemoveSpellEffects_WithStats job

rotund token
#

what does that job look like

viral sonnet
#

ohhh, one step closer. the commandBuffer ```var updateDurationHandle = new UpdateSpellEffect_Duration
{
tick = tick,
SpellEffect_DurationEndTick_ReadHandle = GetComponentTypeHandle<SpellEffect_DurationEndTick>(true),
SpellEffect_Removals_WriteHandle = GetComponentTypeHandle<SpellEffect_Removals>(false)
}.ScheduleParallel(mainEffectsQuery_Duration, Dependency);

        var removalHandle = new RemoveSpellEffects
        {
            LastSystemVersion = LastSystemVersion,
            commandBuffer = commandBuffer.AsParallelWriter(),
            
            Entities_ReadHandle = GetEntityTypeHandle(),
            SpellEffect_Removals_ReadHandle = GetComponentTypeHandle<SpellEffect_Removals>(true)
        }.ScheduleParallel(mainEffectsQuery_Removals, updateDurationHandle);
        
        var removalHandle2 = new RemoveSpellEffects_WithStats()
        {
            LastSystemVersion = LastSystemVersion,
            commandBuffer = commandBuffer.AsParallelWriter(),

            Entities_ReadHandle = GetEntityTypeHandle(),
            SpellEffect_Removals_ReadHandle = GetComponentTypeHandle<SpellEffect_Removals>(true),
            SpellEffect_StatEntityBufferReference_ReadHandle = GetComponentTypeHandle<SpellEffect_StatEntityBufferReference>(true),
            SpellEffect_StatElementIndex_ReadHandle = GetBufferTypeHandle<SpellEffect_StatElementIndex>(true),
            SpellEffect_StatElementBufferIndex_ReadHandle = GetBufferTypeHandle<SpellEffect_StatElementBufferIndex>(true),

            StatBuffer_Changes_ReadHandle = GetBufferTypeHandle<StatBuffer_Changes>(true)
        }.ScheduleParallel(mainEffectsQuery_RemovalsWithStats, updateDurationHandle);

        Dependency = JobHandle.CombineDependencies(removalHandle, removalHandle2);```
#

Unity.Entities.EntityCommandBuffer:AsParallelWriter () is throwing the error

rotund token
#

oh

#

you're re-using the command buffer

viral sonnet
#

yeah, damn. do i need two?

rotund token
#

well in this case yes

#

because you aren't passing the job dependencies between the jobs

#

RemoveSpellEffects_WithStats and RemoveSpellEffects could both use the same command buffer at the same time

viral sonnet
#

i thought this was okay with a parallelWriter

rotund token
#

parallel writer is only safe

#

within the job

#

never with other jobs (nativequeue the exception)

viral sonnet
#

silly me πŸ˜„

rotund token
#

both jobs could use the same index

viral sonnet
#

thanks so much! runs fine now

errant hawk
rotund token
#

not sure i agree

errant hawk
#

no need for a parallel writer with no resizing abilities

rotund token
#

sure there is

#

i use it all the time

errant hawk
#

use what all the time?

rotund token
#

native list parallel writer

errant hawk
#

yeah but you cant resize the list

rotund token
#

so?

#

it'd be very rare not to be able to calculate the upper bound

errant hawk
#

lists are supposed to resize. Of course NativeLists are not parallel-safe without the use of ParallelWriter which is fine. Just need an alternative that can be resized in a parallel job.

errant hawk
rotund token
#

it'd be extremely slow

#

and you can use nativestream in nearly all these cases

errant hawk
rotund token
#

it'd have to lock check

#

every time to see if it needs to resize

#

the same reason parallel nativehashmap

#

is so slow

#

16 threads on nativehashmap parallel writer adding can be slower than single thread for me

#

due to contention

#

and that doesn't even resize

#

it just has a shared buffer

#

there's nothing stopping you adding this container if you need

#

(well except it's extremely difficult to implement without lock)

errant hawk
rotund token
#

yeah

#

so how do you lock the other threads

#

while you resize

#

and move the pointer

errant hawk
#

pointer indirection

rotund token
#

and by lock check i mean interlocked

errant hawk
#

perfect use case

rotund token
#

yes of course

#

but you still have to lock the threads

#

while do do a new allocation

#

remember, you can't use lock in burst

#

and you can't have 2 threads trying to resize at same time

#

and at this point, why not just use a nativequeue/nativestream

#

both which allow resizing

#

because they have per thread buffers

errant hawk
#

I could also do per-thread allocation instead of a single allocation for all threads to access

rotund token
#

you've just invented nativestream!

errant hawk
#

well

#

there we go then lol

rotund token
#

and you want a non-deterministic version?

#

you can use my eventstream

#

which just allows you to write from any thread

#

without having to setup indices

#

or worry about thread safety

errant hawk
#

interesting

#

so you made the eventstream of what specific use case?

#

just those last two changes or what?

rotund token
#

i can just write data arbitrarily from any thread

#

i use this for tooling

#

for example my draw tool from jobs

#

Draw.Line(x,y,z)

#

Draw.Circle

#

etc

errant hawk
#

ah ok I see

#

been meaning to make something that allows for me to draw gizmos a bit easier

#

rn I pass in a NativeList to write to, and then outside the job I append it to a gizmo drawing utility I made.

#

its fairly simple, but I would like to expand on it

rotund token
#

basically same as my own tool

#

but save you weeks of development ^_^'

viral sonnet
#

it's very similar to a nativestream. instead of allocating blocks it uses unsafeLists which can be allocated persistently to reduce some time

errant hawk
rustic rain
#

I assume

viral sonnet
#

don't think that's possible. the safety system complains long before i send anything to the buffer

viral sonnet
#

the unique indices would work. i'm already doing that. the buffers work fine but I'd need to disable the safety system for it. considering how easy it is to just make a 2nd buffer it's not worth it.

robust scaffold
#

Drawing isnt that hard. It's just so tedious to set up

rustic rain
#

@robust scaffold
Did you know about such constraints like
Unity.Burst.CompilerServices.Loop.ExpectVectorized();?

robust scaffold
#

Pretty much the only case where it works is when you're doing A[i] = B[i] + C[i].

open shore
#

I'm trying out the Physics package for the first time. On a blank dots project, inside of a subsystem, I created a ground with the default box GameObject. I then created a default capsule GameObject and gave it a PhysicsShape and a PhysicsBody. According to the tutorials I watched, the capsule should fall down and stop when it hits the ground, but for some reason it doesn't move at all.

#

Did I skip any important steps?

rustic rain
#

show your physics body component

open shore
#

the only thing that I can think of is that I didn't add a Convert to Entity component, but it shouldn't be a problem since I'm using a subscene

#

Just noticed this, maybe that's the problem

#

I'm not sure where to enable it though

#

found it and enabled it - It didn't fix the problem :/

viral sonnet
#

i need to copy a buffer to a commandBuffer instantiated entity that already has the buffer (with a fixed internal capacity in chunk) did anyone already wrote an extension that takes an array instead of a single element like AppendToBuffer?

rustic rain
# open shore

well, first of all make sure your entity indeed exists

open shore
#

they exist, I see them in the dots hierarchy

rustic rain
#

can you show inspector of that entity?

open shore
rustic rain
#

tags included

open shore
#

nothing happens when I manually change the translation component values, the object stays in place

rustic rain
#

feels like smth is missing

#

is your subscene open?

open shore
#

yes

rustic rain
#

close it

open shore
#

closed and reopened, nothing happened

rustic rain
#

why reopen

open shore
#

wait what

#

I left it unchecked and the ball started falling

rustic rain
#

well yeah, because you finally loaded subscene

open shore
#

why doesn't it work when I press play?

rustic rain
#

not sure, maybe physics is incompatible with live conversion

#

on the most basics entities it works normally

#

usually

open shore
#

yeah it worked in every document and tutorial I've seen

#

disabling live conversion doesn't seem to fix it

rustic rain
#

no I mean

#

you gotta close subscene

#

so it gets built

#

and loads as it is meant to be loaded in runtime

#

otherwise it constantly checks for changes and rebuilds entity (could be wrong on some details about that)

#

and when it comes to entities with complex authoring

#

it usually ends up with some mess

open shore
#

so ideally when I'm testing a complex project all of my subscenes should be closed?

rustic rain
#

for example if position is assigned in authoring - entity will be reset with position as soon as you modify it

#

when you test - yes

#

because this is 1 to 1 runtime behaviour

open shore
#

is there a way to make this happen automatically? When the subscene is closed I can't see and modify the objects inside it, but it'd be a chore to disable it whenever I press play and enable it when I finish running the game

rustic rain
#

you can see entities

#

in hierarchy

#

once it's built

#

that's basically all that matters after you close subscene

open shore
#

The current situation is that I need to uncheck the scene to get it to behave properly during runtime, but I have to enable it whenever I want to edit it in the editor.
Is there a way to make unity enable the scene in the editor but automatically uncheck it while the game is running?

rustic rain
#

uugh, that's some overcomplicated problem

open shore
#

sounds like basic UX to me

#

If I have a project with 10 scenes, it is unreasonable to ask me to uncheck all of them everytime I wanna run the game

rustic rain
#

but you don't want to have 10 subscenes open at the same time

#

you only want one you are working with

#

especially if it's large world

open shore
#

Oh yeah that makes sense

#

but that extra step of unchecking a subscene still sounds avoidable

rustic rain
#

probably doable with editor scripts

#

but I personally will most probably find that script inconvinient

open shore
#

which is why I it's weird that they didn't make it a builtin feature yet

rustic rain
#

because open subscene sometimes must be open for some cases

open shore
#

obviously it should be a togglable feature, maybe through the DOTS toolbar at the top of the window

rustic rain
#

so

#

you want to switch one toggle for another? πŸ˜…

open shore
#

absolutely, I probably won't need to toggle that feature very often

#

at least not as often as I'd need to uncheck my scene

rustic rain
#

also selection of what subscenes need that behaviour and etc

#

I really doubt that won't slow down workflow

open shore
#

if people don't want it they can keep it unchecked, but I can imagine that when I'll work on a subscene, I'll run the game every few minutes to see how things have changed. I can only imagine how many times I'll accidently run the game before I uncheck it

pliant pike
#

I don't suppose anyone knows why the DOTS.Physics.Plane doesn't have a Raycast method, how am I supposed to raycast to it then πŸ˜•

pliant pike
#

its a simple technique so you can get the position of a raycast at a specific distance

rotund token
#

every collider has a raycast method in physics

#

if you just mean the regular raycast to plane, why not just use the one you always used

robust scaffold
#

Raycasting isnt collider specific though. Unless you're trying to project a collider...

pliant pike
#

plane doesn't seem to πŸ˜•

rotund token
#

Plane isn't the collider

#

Plane does have SignedDistanceToPoint though

#

is that all you need?

#

oh wait probably not

pliant pike
#

I mean I can just use the normal unity plane I guess but I thought I'd try and figure to use the DOTS one

rotund token
#

or just implement it yourself

#
    {
      float a = Vector3.Dot(ray.direction, this.m_Normal);
      float num = -Vector3.Dot(ray.origin, this.m_Normal) - this.m_Distance;
      if (Mathf.Approximately(a, 0.0f))
      {
        enter = 0.0f;
        return false;
      }
      enter = num / a;
      return (double) enter > 0.0;
    }```
#

all it's doing

robust scaffold
#

Wait, shouldn't a raycast query the world bvh to determine collision?

rotund token
#

he wants UnityEngine.Plane.Raycast method

pliant pike
#

I mean a plane isn't technically something that exists in the world

rotund token
#

which is raycasting to a specific plane

#

you can cast to specific physics colliders with
PhysicsCollider.Value.Value.Raycast()

#

note collider is in local space though

pliant pike
#

hmm maybe it is better to raycast to colliders in the scene though πŸ€”

#

I will need to deal with different heights for the mousecursor

#

I'll try that, thanks for the help tertle πŸ‘

whole gyro
# open shore

Do you have a Physics World Index component? Should be added automatically from a Physics Body but I don't see it in your screenshot.

open shore
#

yes, the screenshot didn't cover everything

whole gyro
#

hmm, physics work fine for me regardless of whether or not the subscene is open.

#

I agree that it would be a pretty bad workflow to have to constantly open a subscene to edit and close it to run with it. That is definitely not the intended workflow for all use cases, although I could see it being beneficial for a large open world kind of project.

viral sonnet
#

can any of you recommend a volumetric fog solution for urp?

safe lintel
#

@viral sonnet if you find a nice one ping me was also looking around for one

viral sonnet
#

will do πŸ™‚

rotund token
#

have you tried Ethereal? only one i've briefly looked at

viral sonnet
#

have you used it? certainly looks like one of the better ones. also on heavy sale right now πŸ™‚

#

i think the stuff from the dev is quite messy/bloated. that's pretty much the reason why i haven't pulled the trigger on this one

safe lintel
#

then you have you use HDRP πŸ₯²

robust scaffold
#

It plays well with their global illumination supposedly.

robust scaffold
rotund token
#

HDRP is great, though kills performance

#

but it's great at realistic graphics

#

it's painful to use it for stylized work

robust scaffold
#

If you're doing volumetric fog, I think performance has long since jumped out the window.

safe lintel
#

the perf has always been really questionable for me

rotund token
#

just installing hdrp in a blank project halves my fps

#

from its overhead with a single plane and 1 directional light

#

now i can start adding a bunch of stuff to the scene without it changing much

safe lintel
#

also enzi was asking about URP

rotund token
#

but the overhead is really rough

rotund token
robust scaffold
rotund token
#

i might acquire them then rewrite them to fit my archetype / design goals

robust scaffold
#

I code it myself or not at all.

rotund token
#

but i find just dumping 3rd party libraries into my project just never quite fits or does what i want unfortunately

robust scaffold
#

Coding things manually also allows me to know the exact limitations of the feature set I'm using. Since I was the one who set them. And if I ever wanted to push those limits out a little bit more, I know exactly where to begin editing / splicing.

rotund token
#

it's a good learning experience as well

#

i don't need to come up with the algorithms myself, but taking someone elses work, pulling it apart and reworking it helps me understand what's going on

safe lintel
#

i also really hate hdrp's asset setting workflow. I honestly find it super confusing

robust scaffold
#

Coding my own 2D physics engine made me really appreciate how smooth and well integrated unity's 2d physics is. Sure it's not deterministic but its ironclad functional.

robust scaffold
#

HDRP is integrated into the settings panel yet URP cant do that? why.

viral sonnet
#

yeah it's all over the place

safe lintel
#

urp is the red headed stepchild but hdrp kinda feels like one too

rotund token
#

yeah thats something that annoys me

#

URP/HDRP teams need to talk to each other

#

and unify things

#

seems like they're both re-inventing the same wheel sometimes

safe lintel
#

feels like my mess of a project, got multiple ecs particles, one based on vfx, one on particlesystem, another one where I used graphics.drawmesh, none talk to each other and all replicate functionality to a varying degree πŸ˜…

robust scaffold
#

Looking at compiled compute shader code makes me wish the guys at burst inspector took a look at making a shader inspector as well

viral sonnet
#

what's cool about it? i never looked at one

robust scaffold
#

The issue is, no comments get transferred over so I'm stuck trying to figure out what line matches what command

viral sonnet
#

oh, that's how you meant it. yeah, that looks bare bones as hell πŸ˜„

robust scaffold
#

That's only for 5 lines of code. Actual shaders is just this blob:

devout prairie
#

Not sure if it's been shared here:
https://www.youtube.com/watch?v=V3UrSEnk5bo

https://prf.hn/l/ERLGO3O - Don't Miss the Unity Innovation Sale!
https://game.courses/beginner/ - Free GameDev Course for Beginners
https://bit.ly/3sKGagG - Game Architecture Course - Advanced Course
http://unity3d.group - Join the Group (facebook)
https://www.youtube.com/channel/UCX_b3NNQN5bzExm-22-NVVg/join - Join the Channel

Talking with Uni...

β–Ά Play video
low hazel
pliant pike
#

he mentioned dots so that's some good news

rotund token
#

tldr: ?

pliant pike
#

I've only watched the beginning part but he mentioned dots briefly as there internal build strategy

#

I mean if there is still any dots doubters it at least means dots is here to stay

devout prairie
devout prairie
#

One point he makes is on potentially commercializing or pushing DOTS a little early, before it was ready - i think hinting at the fact that people have essentially waited in the dark for long period to see more progress and updates from DOTS. However he counters that by saying that looking at the Steam charts 2 out of the top 20 PC games were DOTS games, and in fact 13 or 14 out of the top 20 were Unity games.

rotund token
#

hmm what's the second game *loads up steam charts

#

can't be by player numbers

devout prairie
#

Overarching push for the engine is definitely - asset loading/pipeline performance, UI and stability, big focus on networking and multiplayer, and the render pipelines.

devout prairie
rotund token
#

yeah i know

#

v-rising would have been 1

#

i don't know the other game that uses dots

#

i don't think cult of the lamb uses it

#

at least i see no reference to it

pliant pike
#

maybe the other one is that war game that was posted in the forums

devout prairie
pliant pike
#

ok maybe its still in early access I was thinking Diplomacy is not an Option

rotund token
#

that definitely uses dots but i'm doubtful it made top 20

#

it's done well but currently top 20 is games with 15-20x more sales

pliant pike
#

yeah

rotund token
#

The Long Dark seems to use burst at least

#

was released in 19 though

#

well i've found a few upcoming games on steam that use entities

devout prairie
#

i guess it's possible some games are quietly using dots maybe for small but important workloads ie AI/networking/whatever.. he did mention Unity have literally hundreds of developers working directly with customers so there's a good chance of that i'd think.

rotund token
#

Unoffensible
Operation Valor

#

both use subscenes

#

but definitely not what they were talking about

pliant pike
#

yeah I bet there is loads we don't even know about, dots is way to useful

rotund token
#

oh i'm searching for the subscene folder

#

that gets generated

#

can't hide from me

devout prairie
#

there is some bloody lovely stuff on there. it's these kinds of artists/devs that will propel the upcoming capabilities of unity right up there with the best looking game titles

#

maybe finally get past that whole 'unreal has better graphics' thing

#

she seems to be hinting at stuff that looks to be on a par with for example Death Stranding

rotund token
#

just had a look

#

yeah some of that stuff is really nice

pliant pike
#

its great when something just works and I'm not even sure how

#

just reused some old code and a couple of new lines and I have the new cursor obeying the different heights of objects

pliant pike
#

still confused about the collision filters though πŸ˜•

rustic rain
pliant pike
#

Yeah

rustic rain
#

it's just mask check

#

32 bits vs 32 bits comparison

#

for collision/trigger you need it to be > 0

pliant pike
#

I made two objects with same collision filters and I get different results when using them on a ray cast

rustic rain
#

for objects to collide

#

you need one object to have collides with, which overlaps with belongs to of other

#

if you make both filters everything

#

on both entities

#

they probably should collide

pliant pike
#

Yeah I want the ray cast to ignore certain objects

rustic rain
#

it probably reads belongs to

#

so

devout prairie
#

for raycasts i've just created a static class with some filters that just add to when needed and then grab inside OnCreate..

#

for prefabs etc i try and always use PhysicsMaterialTemplates rather than set layers inside the PhysicsShape component, to keep things as consistent and organised as possible

rustic rain
#

hmmm

#

I'm not sure how collision filter works

devout prairie
rustic rain
#

But I don't think you should define raycast layer

devout prairie
#

that layer is only ever used for raycasts, so i can set up the raycast knowing for sure i'm only going to get results from the CollidesWith mask

rustic rain
#

raycasts are smth that don't actually exist

#

and they don't modify physics

pliant pike
#

I'll have to try it that way, thanks midnightcow

#

Are you adding those collision filters to entities in code then

devout prairie
#

With the exception of the static in the above code called filter_Col_DeadRagdoll which i apply with code

#

For that i clone an existing collider and apply the filter to the clone

pliant pike
#

Interesting, I will definitely have to try that, thanks

devout prairie
pliant pike
#

Yeah I was starting to get confused with creating different special entities to deal with the collision filters

safe lintel
#

did I dream this? I thought not long ago a post was made about the hybrid renderer and it would be renamed Entities Rendering or something like that, but now I cant find it

safe lintel
#

was the thread not pinned or removed?

#

was trying to find it without any luck

robust scaffold
safe lintel
#

thanks, kinda thought I was losing my memory there

robust scaffold
#

I really hope this means that they're just fixing some last minute bugs and not... re-entering development hell.

#

Ugh, I cant do it. mono is pain. Reinstalling dots...

safe lintel
#

heh tried to go back?

robust scaffold
#

I'm gonna have to figure something out for conversion. Since I'm sticking with built in non-dots physics 2d, I wont be using the conversion system as everything will remain GO except for data components.

safe lintel
#

what happened to your physics system?

robust scaffold
#

It functions, just not as well and as smoothly as I prefer. No continuous collision detection. Too complex.

rustic rain
#

Burn out apparently

#

Why not try constrained 3d approach?

robust scaffold
#

I can do it except I just wanna move on ya know. I'm also trying to implement a real time fluid sim as well.

robust scaffold
#

Which is what I'm doing.

rustic rain
#

Bad performance? Hhhm

robust scaffold
#

My physics has phenomenal performance dont get me wrong. It's deterministic and very fast up to simultaneously colliding 15,000 entities. Beyond that it starts to chug a bit. But it's not very smooth

#

No friction. Only forces. No polygon decomposition.

rustic rain
#

I was referring to 3d

pliant pike
#

so do box colliders get auto converted into physics shapes?

safe lintel
#

into a physics collider, yes

pliant pike
#

damn because I need the box colliders but not the physics shapes because they are conflicting with physic shapes on other entities

safe lintel
#

what do you mean?

rotund token
#

you're mixing physics?

pliant pike
#

I'm using the box collider in a weird way I'm converting and using that data as obstacles for a flowfield

safe lintel
#

you could write a conversion system to remove any converted physics components from it

pliant pike
#

yeah or delete it(I don't want to just in case) or I could add a physics shape and then exclude that object from any interactions I guess πŸ€”

#

ok adding the physicsshape doesn't seem to work

stiff mesa
#

Hey everyone! Is there an analogy for Debug class for DOTS? I'm trying to debug systems and I can't make them send any output. I've tried to make a BurstDiscard function and debug from there but that didn't work (the Debug.Log is not called). Is there a debug output method provided by the developer? Or should I implement my own? (or is there someone who solved that problem and have released the code publicly?)

pliant pike
#

Debug.Log should work fine in bursted jobs if your using a string you have to use something likeDebug.Log($"Words here"), though

rotund token
#

static strings are fine (your example would be fine without $)

#

but if you want to output something then yes you need to do it like that ($"Value = {value}")

stiff mesa
#

That's funny, because this Debug.Log("Words here") throws and error

rotund token
#

it shouldn't

#

what version are you using

#

it's been supported for over 2 years

#

and what's the error

robust scaffold
#

Primarily, what's your burst package version

stiff mesa
#

Oh... That's weird. I've just made this again and it worked.

#

No error, and it works fine.

rotund token
#

-_-

stiff mesa
#

Sorry, this is embarrassing))

rotund token
#

you probably did something like Debug.Log(value)

#

where value != string

#

which is not allowed

#

you'd have to log it as

#

Debug.Log($"{value}")

stiff mesa
#

Probably that what it was. Thank you for this information also!

olive kite
#

I am having a slight problem with a memory leak when using a static class to store a NativeArray of floats (for rng) when recompiling or domain reloading. anyone know the correct way to approach this? basically I generate _0to1float = new NativeArray<float>(512, Allocator.Persistent); and then in [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] call dispose but anytime I recompile I seem to get the mem leak from the class

rotund token
#

you should generally avoid statics with entities - especially with native memory

#

so now that I've tried to dissuade you and you'll ignore me and it might come back to bite in the future the easiest solution is just to subscribe to Application.quitting and dispose it in there

olive kite
#

ok i'll just change to non static and initialize differently

#

haha

devout prairie
#

Anybody familiar with this - when placing one object on top of another, the object slides without any force applied?

floral hazel
pliant pike
#

How can a box collider on an object that already has an physicsshape interfere with collisions?

#

is it possible for an entity to have more than one physics shape on it

rustic rain
#

without physics body

#

and it'll be combined shape

pliant pike
#

yeah I don't want to add or combine anything I just have an issue

#

I think if you have both a box collider and a physics shape on an object then it only converts the box collider

rustic rain
#

oh

#

why are you having both?

pliant pike
#

I'm using the box collider for my flowfield

rustic rain
#

πŸ€”

#

can't you use separate entity?

pliant pike
#

no I can't control the collisionfilter on the box collider so I was hoping to add a physics shape so I could control it

rustic rain
#

you can change it

#

during conversion

#

not sure about consequences though, since you might have multiple shapes shared

pliant pike
#

yeah I was just seeing if I could do anything without coding first

#

simplest way is probably to just disable the entity

rustic rain
#

what are you even trying to achieve?

#

maybe you just need to set up game object layer?

#

which corresponds to bit that is what you look for?

pliant pike
#

yeah I'll figure something out, thanks

devout prairie
devout prairie
#

might be easier just to do that than messing around with conversion

safe lintel
#

@devout prairie @floral hazel its because Unity physics is stateless(docs should further explain this), havok doesnt have this problem

devout prairie
safe lintel
#

yeah, can lead to some weirdness like if you move the bottom rigidbody out jenga style, it will continue to float there

#

i think

viral sonnet
#

it does that? that's same class A minecraft physics

stiff mesa
#

Hey everyone! Is there an opposite of RequireSingletonForUpdate function? Like DontUpdateIfSingleton? I can just add

if(HasSingleton()) return;

to OnUpdate, but I wonder is there a scientifically correct method?

whole gyro
#

You can also use RequireForUpdate and pass entity queries instead. These queries still need to match an entity, but you can match against an entity that specifically does not have your optional singleton component

#

Something like this:

        // Run when MyOptionalSingleton is present.
        RequireForUpdate(
            GetEntityQuery(
                new EntityQueryDesc
                {
                    All = new[]
                    {
                        ComponentType.ReadOnly<MyAlwaysSingleton>(),
                        ComponentType.ReadOnly<MyOptionalSingleton>(),
                    },
                }
            )
        );

        // Run when MyOptionalSingleton is absent.
        RequireForUpdate(
            GetEntityQuery(
                new EntityQueryDesc
                {
                    All = new[] { ComponentType.ReadOnly<MyAlwaysSingleton>() },
                    None = new[] { ComponentType.ReadOnly<MyOptionalSingleton>() },
                }
            )
        );
stiff mesa
#

Thank you!

tropic venture
#

is it possible to use unity Starter Assets - First Person Character Controller in ECS? does it need any converting/porting work?

#

or failing that - what would be a good free FPS controller anyone might recommend to use in ECS please

whole gyro
# tropic venture is it possible to use unity Starter Assets - First Person Character Controller i...

No, I don't think that asset was built for ECS. I assume it relies on built-in physics and monobehaviors for everything. Assuming you are trying to make a mostly pure ECS game, you would need to convert it yourself. The only DOTS/ECS character controller on the asset store that I know of is this: https://assetstore.unity.com/packages/tools/physics/rival-dots-character-controller-195567

Get the Rival - DOTS Character Controller package from Philippe St-Amand and speed up your game development process. Find this & other Physics options on the Unity Asset Store.

tropic venture
#

i see

#

wondering - do i need to make a mostly pure ECS game?.... ex; big open world scene with lots of collidable stuff like trees & rocks etc. as well as plenty of other objects & structures like cabins trailers tents beach balls tables chairs and more

#

~lots~ tons

#

i'm trying to target mobile so am hoping ECS might help boost performance for such an open world scene with lots of props & stuff in it

#

@whole gyro ☝️

tropic venture
#

what is more accurate description of dots/ecs functionality:

"port all of your Update() processing off the main thread into worker threads, if you can fenagle all the relevant data into concise streamline-able chunks for blazing fast memory access"

well then if my scenes dont have 70000 moving objects or enemy minions etc., rather has mostly static props/objects/decorations with maybe some fancy vertex shaders at most but no specific Update() processing - then i gain nothing from ECS?

Or - if dots/ecs also does all your Rendering and Physics and other under-the-hood Unity stuff with blazing performance compared to non-ECS, then it will make a significant difference for my game too?

stiff mesa
#

ECS is a great way of programming that makes your code much easier to expand. The increase in performance is just a pleasant bonus.

tropic venture
#

hm πŸ€”

#

working in the "easy for noob (like myself) to understand GameObject hierarchy" is also "much easier" for its own reasons... and if i only have pretty much just 1) player FPS controller, and 2) at most 20 or 30 enemies in scene at a time, and almost nothing else around that is running MonoBehavior Update() scripts at all, then perhaps i really have nothing to gain from ECS?

stiff mesa
#

Probably. ECS is for advanced users and for bigger projects.

tropic venture
#

i'd love to find out that using ECS might give some awesome advantages in like how many graphic decorations i can have in my scene, or how much more i can fill my scenes graphically for Mobile performance, but if ECS's effectiveness is mostly in regards to Update() methods, and i dont have that many of those...

stiff mesa
#

Well, if you mostly use static geometry then yeah

tropic venture
#

i think i might, in this particular project..

stiff mesa
#

But if I'm not mistaken, every dynamic object has an update somewhere

tropic venture
#

"dynamic" as in? anything that's a GameObject with a transform? even if it has no script attached, it still has some Update() under the hood?

#

and if one were to use ECS then it "optimizes" that Update() out?

stiff mesa
#

Well, i'm not sure. Again, how interactive they must be? If you just place them and turn them into a static mode, than they will be very cheep. If they are not set into static mode... Then how exactly they will be interactable? Will they move? Will they have physics?

tropic venture
#

physics yes, but most of them static, as in trees or rocks or huts etc which you cant walk through wood/stone/walls etc

#

maybe a few items to throw around like beach balls or such

#

but mainly the game is just 1) a scene as the playground 2) player 3) enemies, not much else

stiff mesa
#

If I'm not mistaken ECS upgrades physics performance, although ECS physics is still work in progress.

tropic venture
#

ah interesting ok good to know

#

what about rendering, that too?

stiff mesa
#

No. Rendering is just Unity itself (as far as I know)

tropic venture
#

how about maybe using ECS for scene optimization computations/techniques etc? for example if my scenes are gonna be vegetation & prop heavy, loads upon loads of trees & grass etc., maybe i can deploy an army of ECS components+systems to do raycasts or run around the scene calculating occlusion and other culling techniques, enabling & disabling objects to achieve awesome performance optimizations? anything like that make sense to put into ECS processing? or that makes no sense and should only be done in regular scripting

stiff mesa
#

It could be done in ECS, yes. It could be done in regular code also, using jobs, but ECS would do that in a more organized manner (and probably faster)

tropic venture
#

interesting

#

can ECS do a bunch of raycasts for me more performantly than regular FixedUpdate() code might?

#

more importantly: should i move my entire game into ECS for this, or would it be fine and be just as performant to have most of the game world in GameObject hierarchy and the "army of ECS optimizers" operating on them "from the side" so to speak?

rotund token
#

you just end up with the overhead of both implementations and a really awkward interface between them

#

you'd be better off just using jobs/burst to optimize an existing game and ignore the entities side of it

rotund token
tropic venture
#

actually in my case i havent built the game yet

#

still deciding which path to take

rustic rain
# tropic venture actually in my case i havent built the game yet

ECS is cool way to write project. But Unity ECS is alpha/beta state. So almost all thing you'll have to reimplement yourself. Project will be way more advanced compared to classic unity approach.

Performance wise Unity ECS is great. And it's the easiest way to write almost fully threaded project.

But to achieve that: say goodbye to classes and say hello to structs, allocators and pointers

tropic venture
#

i see

devout prairie
#

i would agree with Tertle and Issue above, especially if you are a noob ( i think you mentioned this ) - ecs is a great approach to learn and can catapult performance but it loses all of the benefits that make OOP in Unity so easy and accessible. I would probably suggest build your game in the usual way and then start looking at where you could benefit from jobs and/or ecs

#

I'd love someone ( or myself if i had time ) to do a full writeup of their experience of ECS and some comparisons showing clearly where ECS can potentially be better and faster to write and more organized, but also honest comparisons of areas that are just exponentially more complex and involved - i know both cases exist.

glacial hazel
#

Is there another object like a nativeArray but that can have more than int.MaxValue elements on it? Or I'd have to make like multiple native arrays

amber flicker
glacial hazel
#

I mean it's an array of bytes

#

So it's more than 2 GB

#

Or it could* be more than 2 GB

amber flicker
#

Sorry I don’t know the answer except I’d be very surprised if there’s an existing native container that uses eg a long for the length. You could try and make your own or yea… multiple.

open shore
#

I have some questions about querying and iterating over entities:
I noticed that in many cases, people use lambda expressions over for/foreach loops. I'm used to thinking "lambdas = cool but inefficient", but I'm assuming that the burst compiler is making them as efficient as for/foreach loops?
I also wanted to know how the querying works behind the scenes. If I have a system that iterates over all entities with a certain component every update, how does it cache the queried entities between update calls? Does it save the query result in a separate collection?

rustic rain
#

they are generated into IJobEntityBatch which is fastest

open shore
#

thanks, I'll read about IJobEntity more in the docs

rustic rain
#

Batch

#

at the end

#

it's important

#

IJobEntity is another codegen xD

misty wedge
#

Is there any documentation on how to get the test runner to work for DOTS? I have subscenes that need to be loaded for a playmode test, but loading the scene using the scenemanager in either SetUp or OneTimeSetUp does not seem to load the scene correctly

zenith osprey
#

Hello!! Is there any info comparing between Async and Jobs? What I got from my search is that Async doesn’t stop main thread while Jobs does… is that the main difference?

rustic rain
#

async is just async code running asynchoniously

zenith osprey
rustic rain
#

by default yes, but you can ship process to background thread afaik

#

in short

#

async code is for smth like UI code execution (so it doesn't block game process, while doing smth expensive)

#

while jobs are for game logic

#

and not only

misty wedge
#

async is very similar to Unity's coroutine workflow

#

jobs run on a separate thread

zenith osprey
#

Hmmm I see, I was wondering if there was a way to use jobs asynchronously because of it being multithreaded but still didn’t want to stop main thread while doing it

rustic rain
#

The simplest example to understand async (by my perspective) is:

async void Kek(){
OpenLoadingScreen();
await StartNewGame();
OpenGameScreen();
}
misty wedge
rustic rain
#

so while your new game loads, loading screen will function normally

#

and once it's done open game screen

zenith osprey
#

Whooo that’s interesting!!!

#

Thank you so much for the help you all!!!

#

I’ve been searching but never understood well now I got the grasp of it hahah

rustic rain
#

yeah, understanding async is smth really new to some people

#

TOok me a while after reading microsoft tutorial 10 times xD

zenith osprey
misty wedge
#

It should be !handle.IsCompleted though, I missed an exclamation mark

#

Also since you asked this earlier, if you want to run non-job code outside of the main thread, you can use Task.Run

open shore
#

Is it efficient to add/remove entity components often in runtime?

misty wedge
#

There are more efficient ways, it depends on your requirements imo

rustic rain
#

because every time you do structural change - all caches for all queries that are affected is gone

open shore
#

which ones will be affected if I remove a component?

#

the queries related to the entity or just the ones that are related to that component?

#

I'm thinking about making something similar to a movement state machine where every state is represented by a component

#

Which means that everytime a character jumps or performs an action, I'll need to remove the existing component and create a new one

rustic rain
#

because those queries contain chunk where this entity is

#

or was

misty wedge
# rustic rain as long as it's not every frame

I feel like there are a lot of projects where the simple approach (e.g. bullet = entity) will cause the game to create and dispose entities every frame. I hope unity optimizes entities enough that this works for projects that don't have crazy performance requirements

rustic rain
#

you don't create bullets every frame

misty wedge
#

Depends on the project

#

Anyone use the testing framework for dots extensively?

stone osprey
#

Im using an "unsafelist" in one of my entities components... However, when i remove or add items to it, it only updates for that instance. Is this behaviour intended ?

A unsafelist isnt a value type, so it shouldnt require a .SetComponent operation ?

#

I hope my issue is clear, cant provide an example rn... On my phone

misty wedge
#

An unsafe list is a value type, so you need to pass it as a ref value incase you call functions like Add or Remove, since it contains a length field used to index the pointer to the heap memory

#

If you copy it as a value type, you will only modify the Length property on the copy, not on the original object, while still writing to the same memory location (unless you write so much that the list requires copying your contents to another buffer with more space, at which point both copies of the struct will point to different memory locations)

stone osprey
#

Ah thanks, that explains that mistery behaviour... So i actually need to call .SetComponent once more to make sure the updated list gets passed to the component

safe lintel
misty wedge
#

Yes, my point was that that should be the goal, since it is also what unity kind of alludes to in my opinion, with their demos where they spawn bullets as entities

#

There are lots of workarounds that are more performant, but harder to implement. The "easy" way should be the default one though imo

rustic rain
open shore
#

Are there official opensource repositories for Unity Physics and other first party DOTS-based systems?

karmic basin
open shore
#

oh sorry I should've phrased my question better. I meant to ask if any of these systems are opensource.

karmic basin
#

There 's an old one for animation too, but dots animation is on stand-by

#

Yes ? It's on github so you can explore the source

#

And you can see the packages cached in your Unity project too

#

Is that what you meant ?

open shore
karmic basin
#

Yes

#

You can dig 100% of the source, see how they implemented things

open shore
#

can I fork it and make my own versions?

whole gyro
#

In legal terms, they aren't "open source". They come with the Unity Companion License. But the source is freely available and you can use the stuff in your own commerical games and unity assets.

karmic basin
#

Technically speaking yes, but check Unity licence

#

Yeah Graviton said it better than me

open shore
#

ok ty!

karmic basin
#

By the way, open source !== free

#

But I'm nitpicking probably

whole gyro
#

The two github repos linked by @karmic basin are for samples. The actual ECS, Physics, Hybrid repos are all private now (they changed their mind a year or so ago). Someone has mirrored all of the repos from the package manager into github repos like this one: https://github.com/needle-mirror/com.unity.entities You won't be able to see the issues, PRs, etc., but you can at least browse the code and fork all through github if that is what you are looking for.

GitHub

[Mirrored from UPM, not affiliated with Unity Technologies.] πŸ“¦ The Entities package provides a modern Entity Component System (ECS) implementation with a basic set of systems and components made fo...

karmic basin
#

Oh missed the fact they went private

#

I don't dots these days πŸ˜…

#

You can still inspect local packages files, right ?

open shore
#

I guess but you can't fork them unfortunately 😒

whole gyro
misty wedge
#

Which system handles loading the actual scene? Is it not SceneSystem?

rotund token
#

SceneSectionStreamingSystem

#

scenes are broken into sections

#

this streams them in

misty wedge
#

If I manually tick the world a couple of times it should eventually load the scene right? as long as all systems are present

rotund token
#

yeah

misty wedge
#

are there any other systems I need besides SceneSystem and SceneSectionStreamingSystem?

rotund token
#

probably a few

#

ResolveSceneReferenceSystem at least

#

oh that might only be needed in editor

#

WeakAssetReferenceLoadingSystem

#

there's a lot of stuff in the scenes assembly

misty wedge
#

I think I'll just create whatever is in the scene manually

#

It's for testing purposes, this seems too complicated for that

minor sapphire
#

TIL UnityEngine.Time.time != SystemBase.Time.ElapsedTime sobglasses

#

which was never an issue for me when I was creating worlds on start up lol

#

but became an issue when I deferred world creation and introduced subtle time bugs that took forever to track down πŸ˜„

olive kite
#

is there anything else that needs to be done to add a physicsCollider from an authoring component in script other than just creating a (in this case box) BoxCollider and adding the componentdata to an entity?
var boxProperties = _shape.GetBoxProperties();
var col = Unity.Physics.BoxCollider.Create(boxProperties,filter);
var colComponent = new PhysicsCollider {Value = col};

olive kite
#

ahh yes! thank you i knew i was forgetting something

misty wedge
#

I'm having some issues with collider casts, for some reason it's not hitting the first object even if I have EarlyOutOnFirstHit is true

#

Actually, it seems EarlyOutOnFirstHit is set to false in the closest hit collector. How does it find the closest hit? By overwriting max fraction with the hits fraction until no hits are left, skipping those that exceed the current max fraction?

#

Ok, nevermind, with EarlyOutOnFirstHit set to false it works >_>

stiff mesa
#

Hey everyone! I have a question about System Groups. From what I've read system group has a sync points at the beginning and at the end. Does it mean that I can through my systems into a group using [UpdateInGroup] attribute, and the group will await until all the jobs are done before moving forward?

rotund token
#

SystemGroups don't cause a sync

#

(well technically they would if you added logic into them but generally you don't do that

#

the 3 primary system groups, initialization, simulation, presentation all have commend buffer systems at the start and end of them

#

that if you use, will cause a sync point

stiff mesa
#

So, I have to write my own sync points, right?

rotund token
#

dependencies are automatically handled with jobs/systems

#

if you have a systemA with a write dependency on X, and systemB updates after with a read dependency on X, systemB job will not execute until after systemAs job

#

if systemB dependency was on a different component though that systemA was not using

#

then systemB job is free to execute at the same time as systemAs job

stiff mesa
#

Oh, ok. So, a lot of time I don't need to. I just have a thing where I need a bunch of systems to all finish the execution before proceeding to the next thing, and I couldn't find any other way to ensure that they are all finished except manually syncing them through job.Complete.

rotund token
#

generally you should never need a sync point unless you need to do work on main thread

#

and they should be avoided

stiff mesa
#

Well, I have a bit of logic that should be deterministic so I feel I wouldn't be able to do it all completely without some type of sync point. It's level loading sequence and currently it works a bit like coroutine with multiple "steps", containing multiple systems. The code execution should only move to the next step when all the systems from the previous one are finished. The coroutine will not work continuously. Only on demand.

misty wedge
#

I feel like that all goes out the window as soon as you have entities created or destroyed every frame, which means you need a sync point anyways

rotund token
#

what about the scheduling do you think is non-deterministic?

#

entities is deterministic

stiff mesa
#

Ok. Simpler question. SystemA.Schedule -> SystemB.Schedule -> SystemC.Schedule. I need SystemA and SystemB to finish their logic before the SystemC starts to execute. If I just Schedule one by one, will that work?

misty wedge
#

I feel like for your loading system it might make more sense to just create entities in each step that signal other systems to do work, instead of doing the scheduling manually. but it depends on performance requirements I guess

rotund token
#

or the Update() scheduled in SystemC

#

if you mean job scheduling as long as SystemC has any component dependency on A/B it's job won't start until A/B has finished

stiff mesa
rotund token
#

my first thought is, something smells wrong

#

ECS principles are generally that systems shouldn't need to know about each other

#

as soon as that principle breaks i consider it a flaw in design

misty wedge
#

I mean there are even exceptions in unity's own systems

#

e.g. physics needing to know you are using collision worlds

rotund token
#

by adding a component dependency

misty wedge
#

Ah cool

viral sonnet
#

isn't artem designing a loading mechanic? i think having some system dependency is okay for that

misty wedge
#

I always thought that was weird

misty wedge
rotund token
#

you know how they have the whole this.RegisterPhysicsRuntimeSystemReadOnly();

misty wedge
#

yeah

rotund token
#

all that does is add a dependency

        /// Call in your system's OnStartRunning() method if you only want to read physics runtime data from the default physics world
        /// </summary>
        public static void RegisterPhysicsRuntimeSystemReadOnly(this SystemBase system)
        {
            system.GetSingleton<PhysicsSystemRuntimeData>();
        }

        /// <summary>
        /// Call in your system's OnStartRunning() method if you want to read and write physics runtime data from the default physics world
        /// </summary>
        public static void RegisterPhysicsRuntimeSystemReadWrite(this SystemBase system)
        {
            var cData = system.GetSingleton<PhysicsSystemRuntimeData>();
            system.SetSingleton(cData);
        }```
#

on PhysicsSystemRuntimeData

misty wedge
#

Ah, I see. I never went to check what it actually does

#

Wait, how does this work exactly? Does SetSingleton add a write dependency for the component?

rotund token
#

yes

misty wedge
#

Ah, I thought it just wrote the component as a sync point

rotund token
#

all calls to GetEntityQuery, GetComponentDataFromEntity, GetComponentHandle, GetSingleton etc

#

adds that component to the system dependency list

misty wedge
#

So the physics system has just has a write handle on PhysicsSystemRuntimeData?

rotund token
#

yes

#

on the build system

#

(which is what runs first)

#

i expect in 1.0 you'll be reading the physics world from the runtime component as well

#

instead of getting it from the system

stiff mesa
#

Ok. Now I'm confused. I can't imagine how to implement some forms of sequential logic without making sure previous steps have been finished before the next one have started. Is there any example of full cycle level loader? By full cycle I mean an example where I can order a level loading, the game will save the player's progress, unload old level, clean up all the mess, load other level, load the player's progress and start the gameplay, all using exclusively Job.Schedule and no artificial sync points?

#

Or at least examples of something similar?

viral sonnet
#

take opinions as guidelines and not fact. implement what you think is right. if it works, it works. refine as needed.

rotund token
#

imo this is usually handled by event entities rather than system dependencies

#

i think netcode or the dots shooter has good examples how they handle it

#

but do whatever works for you

misty wedge
rotund token
#

(also I am definitely a purist so take my advice with a grain of salt unless you have a strong strong interest in software architecture)

stiff mesa
stiff mesa
misty wedge
viral sonnet
#

i don't see the parallel problem. a single entity can trigger a system to run and that system processes a set of entities in parallel with another query. (that's expecting that the set of entities that are processed in parallel always exist. if not, and they are created in the loading chain, the single entity to trigger isn't even needed)

misty wedge
#

Since they don't have a write dependency all systems with a read dependency will be scheduled in parallel

stiff mesa
# viral sonnet i don't see the parallel problem. a single entity can trigger a system to run an...

It's more like five systems run their jobs in parallel, but system number six should ONLY start when all five have finished. I've asked this question before, and if I'm not mistaken you've suggested the solution. I'm using singletons and singleton dependencies to manage the sequence, and any time I need to run multiple systems in parallel, I just gather their job handles in a single system, call Complete, and then set the singleton for the next step in a sequence. It works, but I'm looking for more correct ways to write the code in dots. I feel that what I've done is at leas somewhat the way Unity intended it to be done, since I'm constantly see this trick in a lot of examples, including adding dependency to command buffer simulation system.

misty wedge
#

Just create a unique entity for each of the five systems and have system six acquire a dependency on all 5 entities

#

system six will only run once all others are done

viral sonnet
#

yeah, i remember it was one of the suggestions. if you don't want to screw around with creating entities i would just use job handles as dependency. the only real problem is that with more systems, job handles have to be shared.

robust scaffold
#

Ughhhhhh, I really want to return to DOTS but the fact that it doesn't work well with a custom rendering pass is absolute pain

#

Frankly, the main issue I'm going around in circles about is DOTS's support for a hybrid GO/Entities style moving forward.

#

I have to admit, after all these hours, Unity's 2d physics is very very nice. So is their sprite rendering pipeline. But is it worth squishing these two ecosystems together?

misty wedge
#

I think it depends on the project

#

I use the monobehaviour sprite system but use the DOTS physics system

robust scaffold
#

I think for now until 1.0 is released, I'm gonna keep my dots-style monobehavior/GO setup. It'll be relatively painless to convert everything to DOTS when unity reveals their made-for-production hybrid pathway. That or they restart tiny development.

#

Tiny / dots physics 2d has infinitely better potential simply because they can pull the internal collider info from within the engine and not re-invent the wheel when trying to convert composite colliders.

misty wedge
#

Yeah I'm really interested in what 1.0 will bring on all fronts. ease of use, and all the non-code stuff that is still mainly missing (animation, sound, etc)

robust scaffold
#

100%. All that non-code engine features is really key to what I need to do.

misty wedge
#

Yeah I'm pretty happy I have no special rendering requirements or anything, so I haven't really run into that issue

#

I just plan to use the normal sound stuff for sound

#

same for particles and stuff like that

#

Basically everything πŸ˜…

robust scaffold
#

Hopefully this new guy working on the DOTS training samples will update their entities version to the latest internal so I can see what they've improved over the last month

#

particles and graphics is really annoying. render textures can be converted to ints but compute buffers require extern functions and thus must be classes.

misty wedge
#

Sprites are fancy enough graphics for me πŸ™‚

#

The only "fancy" thing I did is a 2D shadow system and that was like 3 lines of shader code

#

(which is where I hit my limits)

#

Pretty happy with how it turned out though

robust scaffold
#

I just converted my light entities into a nativelist<data>. Easy enough to reverse it if DOTS 1.0 comes out amazingly

misty wedge
#

I only needed sun shadows, which not very many shadow systems can do (iirc I couldn't find any on the asset store), so I made a very simple version

#

this looked interesting but I did something else in the end

robust scaffold
#

Interesting. My art style is 2.5D but i've coded my lights assuming top down 2D. Might be interesting to consider.

misty wedge
#

The project I'm working on is top down but the scene is 3D which makes lighting a lot easier

robust scaffold
#

True. And built in global illumination that actually works. 3D is very tempting. Extremely just for GI. But then I would have to use HDRP...

misty wedge
#

I've never thought of using GI in a 2D game

robust scaffold
#

But then I wouldn't have to invent everything myself. But there's no tilemap editor in 3d. Ughhh. So much to consider.

misty wedge
#

I mean you can use the normal tilemap editor as long as it's not truly 3D

#

at which point it would probably need to be mesh based anyways

robust scaffold
#

2D GI can theoretically compute infinite light bounces. That's called 2d Radiosity and there's a lot of neat videos of attempts to code it online

misty wedge
#

I had to learn radiosity for a lecture but I never thought about it in non-3d space

robust scaffold
#

However, realtime 2D radiosity relies on temporal AA as they're all largely raymarching algos and moving the camera is a definite no-no.

#

I've matched the effects of 2D GI soft shadow lighting by simply rendering in 16 or 32 lights in place of 1 point light but imitating wall bounce illumination has so far been the hardest challenge.

misty wedge
#

I like the approach of just putting more light in one place πŸ˜›

robust scaffold
#

Yea. What is a light source other than an infinite amount of point lights?

misty wedge
#

true

#

it's pretty nuts imo

robust scaffold
#

It's mainly this guy I want to copy

#

Issue is, I think he might have kicked the bucket back in 2018. Or fallen completely off the internet then with the radiosity code still locked in his SSD forever lost to time

misty wedge
#

as is usually the case with these hobby projects

robust scaffold
#

At least he released his fluid dynamics code with arbitrary walls. That's the only example of open source fully featured fluid sim I have ever found. Great reference

rotund token
robust scaffold
rotund token
#

oh

#

well then ☠️

#

website taken over

#

yeah not a good sign

robust scaffold
#

Yea. It's frustrating how fantastic his demo videos are and promises to open source it when he's happy with the results. Then nothing...

misty wedge
#

Something I'm also really looking for for DOTS 1.0 is some officially supported way for save states

rotund token
#

what do you mean?

misty wedge
rotund token
#

i wouldn't hold your breath on that one

misty wedge
#

😦

#

imagine not wanting to serialize your current game state thonk

robust scaffold
#

Im fairly certain you can serialize the entirety of a world then load it again.

rotund token
#

gets complicated with blob assets

#

if you ignore blob assets then yes

robust scaffold
#

Yea, as long as you dont use blobs

misty wedge
#

What's the easy way though? just iterate over everything and write it?

robust scaffold
#

Simple enough, dont use blobs.

rotund token
#

it breaks as soon as you make any component change though

misty wedge
#

also this ^

rotund token
#

a single change in any StableHash and your binary data is dead

robust scaffold
rotund token
#

i will probably release my save library come 1.0

#

i've started testing in a more production environment recently - it's holding up well

misty wedge
robust scaffold
#

imagine testing. I just release and say, this may work, this may not. It works on my comp. No support, no fixes other than what I want. Good luck.

viral sonnet
#

but yeah, strange he seems vanished. pretty sick repo/videos

robust scaffold
misty wedge
#

Something I was wondering recently, is there an easy way to "pause" the entire world without manually ticking systems?

rotund token
#

GetExistingSystem<SimulationSystemGroup>().Enable = false

robust scaffold
misty wedge
#

That... makes sense

misty wedge
rotund token
#

pretty much

#

i have unique identifiers per subscene (also a global one)

#

automatically calculated during conversion from unity's GlobalObjectId

misty wedge
#

My setup is so simple I think it should be pretty easy to make a basic serialization system

#

I only have a single subscene that I use, and everything is procedural

#

Main thing to watch out for is how to handle system state stuff

rotund token
#

i require static archetypes like netcode

#

as in, by default you can only save what's on the prefab

#

you could write your own extensions easy enough

#

but my default auto save components/buffers just using the [Save] attribute

#

require this

#

also have migration setup for component changes etc

#

i did a lot of work on this

misty wedge
rotund token
#

well i believe you should have static archetypes to start with

#

and it makes everything super simple

#

and super fast

#

i can save 100k entities in 20ms

misty wedge
#

Yeah, I would do it just for simplicity purposes

rotund token
#

i don't need to double buffer this or anything

misty wedge
#

and since I use netcode it's required anyways, like you said

rotund token
#

i can do it in real time

#

i can do real time rollback

#

which wasn't the intention of the library

misty wedge
#

haha

rotund token
#

i just saw the rollback post on forums and thought, yeah my library could do this

misty wedge
#

could be cool for some time based games

#

on a large scale

rotund token
#

this was an early test

#

i've since significantly improved it

#

i grabbed unitys boids sample

#

increased boid count by 10x

#

and use that as my test now

misty wedge
#

I think youtube recommends your video to me each day

#

it's like a curse

#

which is odd since I already watched it

misty wedge
robust scaffold
rotund token
#

im not writing to disk for rollback

#

but pretty big even after compression at that entity count

#

i wouldn't do more than a minute of data πŸ˜„

#

let's see if this works

#

yeah my bypass no nitro file limit trick πŸ˜„

robust scaffold
#

Ah. I'm doing a large simulation and would love rollback capability. If you somehow magicked together some some or compression, I would've loved to see if it could work with deterministic netcode synchronization but if it's only on memory, oof

rotund token
#

yeah it's literally serializing and just storing each frame in a native array of bytes

#

for rollback sample im not even compressing

robust scaffold
#

yeaaaaaa, that's not gonna cut it for me sadly

rotund token
#

this library wasn't designed for rollback

#

it stores entity, component pairs

#

for every component you're saving

#

instead of entity, all components

#

so it's not memory efficient at all

#

it's designed to be as fast as possible for serializing at the cost of deserializing with only minimal care for file size
rollback demo was just to test real time performance

robust scaffold
#

Im looking at at minimum 21 1000x1000 textures. Possibly up to 3000x3000. Rollback on that would be miraculous.

viral sonnet
#

damn, nativequeue has no UnsafeQueue. can't get a single pointer QQ

robust scaffold
#

well no, that's a stack

viral sonnet
#

no, nativeQueue has 16k blocks

misty wedge
#

just all data for a specific component type?

rotund token
#

it works by simply adding an attribute [Save] to your component

#

if you want to save a component add that attribute

#

you can ignore a specific field on that component with [SaveIgnore]

misty wedge
#

yeah but I meant how are you getting the data from ECS

rotund token
#

to get the data

misty wedge
#

πŸ˜…

robust scaffold
#

reflection?

rotund token
#

DynamicComponentTypeHandle

misty wedge
#

I think there is a native function

#

yeah that one

robust scaffold
#

Oh, yea, those exists

rotund token
#

the only reflection is getting all component types with the attribute in on create

#
            {
                var saveIdx = this.Serializer.AllocateNoResize<HeaderSaver>();
                var compIdx = this.Serializer.AllocateNoResize<HeaderComponent>();

                var entityCount = 0;

                foreach (var chunk in this.Chunks)
                {
                    var components = chunk.GetDynamicComponentDataArrayReinterpret<byte>(this.ComponentType, this.ElementSize);

                    if (components.Length == 0)
                    {
                        continue;
                    }

                    var entities = chunk.GetNativeArray(this.Entity).Slice().SliceWithStride<int>();

                    entityCount += entities.Length;

                    var chunkHeader = new HeaderChunk { Length = entities.Length };

                    this.Serializer.AddNoResize(chunkHeader);
                    this.Serializer.AddBufferNoResize(entities);
                    this.Serializer.AddBufferNoResize(components);
                }

                var headerSave = this.Serializer.GetAllocation<HeaderSaver>(saveIdx);
                *headerSave = new HeaderSaver
                {
                    Key = this.Key,
                    LengthInBytes = this.Serializer.Data.Length,
                };

                var compSave = this.Serializer.GetAllocation<HeaderComponent>(compIdx);
                *compSave = new HeaderComponent
                {
                    ElementSize = this.ElementSize,
                    Count = entityCount,
                };
            }```
#

thats my component serializer

misty wedge
#

And on deserialization you look up if the component exists on the entity from the entire block that was stored? or how does it work

rotund token
#

deserialization writes it all to a hashmap then every entity iterates (within the block) and checks if it has saved data

#

this way you can remove data from an archetype after making a save

#

and it won't break

#

it will just cleanly remove it

#

i expected this type of lookup to be really slow

#

but it actually works remarkably fast for what it has to do

misty wedge
#

nice

rotund token
#

so on deserializing it knows X entities of Y archetype was saved

#

so it creates that many entities

#

remaps the entity ids

misty wedge
#

would you recommend this approach (entity->component) or the other one (entity->componentS) if I'm mainly going for simplicity

rotund token
#

then just looks up data for it

misty wedge
#

without all the extra features (migration, rollback) it sounds simple enough

rotund token
#

entity->component is simplier

#

the reason im doing entity->component is for migration

#

if you make component changes

#

it's much easier to migrate if all components of a single type are stored together

#

i can just iterate that list of components, migrate the data

#

migration was the main thing i wanted to handle in this library

misty wedge
#

I'm guessing it works similar to DB migrations

rotund token
#

no point having a save system if it breaks everytime you release a patch

#
    public class TestComponentForMigrationMigrator : ComponentDataMigrate<TestComponentForMigrationMigrator.Before, TestComponentForMigrationMigrator.After>
    {
        public override ulong From => 1392796844747678277;
        public override ulong To => 17841778420484547873;
           
         protected override void Migrate(ref After newComponent, in Before oldComponent)
        {
            newComponent.Value = oldComponent.value;
            newComponent.NewValue = 5;
        }

        public struct Before { public int value; }
        public struct After { public int Value; public int NewValue; }
    }
#

my slow version of migration

#

but minimal code

misty wedge
#

very cool

#

see this is something I would love to see from unity as part of DOTS

#

it's such a good fit for data oriented games

#

but some of these more complex features (migration, rollback) are difficult to get perfectly right

#

especially with stuff like editor integration

rotund token
#

i have tools for editor as well

#

that store stabletypehashes

#

so you can see what you need to migrate from -> to

misty wedge
#

yeah I remember you showing them a few months ago

#

let me know if you ever release it, it sounds really neat

robust scaffold
#

I just (re)discovered tuples. Holy shit are they fantastic. Love them. Shame they cant be used across main-job boundary

rotund token
#

very convenient

misty wedge
#

I thought you can't use them in burst since they're auto layout-ed structs?

robust scaffold
#

The integrated deconstructor inside of a foreach loop header is so nice.

rotund token
#

i.e. you can't pass in a NativeList<(int, int)> into a job but you could create this in the job and use it

misty wedge
#

Huh, I swear that wasn't possible a year ago

robust scaffold
#

They probably AOT store the actual layout for the job but attempting to cross managed-unmanaged boundary during runtime is not reliable.

rotund token
misty wedge
#

ah

#

That's cool

#

I like them for swapping values with the deconstructor

robust scaffold
#

I think the tuple swap requires no temporary value according to IL code. No clue how they did that.

rotund token
#

i just love this
(a,b) = (b,a)

#

1/3 of the lines

misty wedge
#

yeah, that's what I meant

rotund token
#

yeah

#

i also have no idea how they did it without a tmp value

robust scaffold
#

Possibly through a blend op? I havent actually checked the burst output of a tuple swap.

misty wedge
#

are you sure it requires no temp value? the generated C# code uses one

#

or is this a burst feature

robust scaffold
#

I read it off stack overflow that tuple swap compiles without a temp store var in IL output. And somewhere in my physics code that was actually a problem.

viral sonnet
#

maybe it just creates a new struct?

#

swapping without a tmp value isn't really possible

robust scaffold
#

I dont remember why it was a problem but I know I had to go back to the 3 line swap for a specific section due to no temp variable. Something with pointers maybe.

misty wedge
#

on an unrelated note, something I was wondering about. since blob assets can get pretty big, and you are forced to access the value contained in the blob asset reference as a ref, what happens if you then access another struct inside the ref, wouldn't that copy it to a local value, potentially copying a large chunk of data?

robust scaffold
#

You never copy the blob asset. Only the pointers to the blob are being passed around.

misty wedge
#

I thought the intention was also to not constantly copy huge chunks of data

#

Well yeah, but the struct is stored somewhere

robust scaffold
#

Yea. That's what it's there for.

#

It's stored in persistant allocation in one giant block.

#

All blob assets are stored in persistant in one massive singular byte array

misty wedge
#

So basically what I said earlier is correct, in that if you don't want to copy a large struct inside a blob to a local variable, you would also need to make it available as a ref struct?

viral sonnet
#

do you temp store a struct from the blob? if so it gets moved to stack

robust scaffold
misty wedge
#

e.g.

ref var blobValue = ref blobAssetReference.Value;
var someLargeStruct = blobValue.MyLargeStruct;
viral sonnet
#

yeah that creates a struct on the stack

misty wedge
#

Ok, that's what I assumed

#

What's the correct way to handle this then, read the actual value?

robust scaffold
#
ref var someLargeStruct = ref blobValue.MyLargeStruct;```
Will not
misty wedge
#

or always use refs I guess

viral sonnet
#

depends, you want ro read it at some point

robust scaffold
#

You cant write to the blob but if you want to customize the result of the blob, you need to remove the ref and copy to stack.

misty wedge
#

What do you mean by customize the result?

robust scaffold
#

Actually, I think you can write to blob if you access the pointer.

misty wedge
#

Oh, you mean modify the value

#

My use case is more along the lines of something like this
var myInt = blobValue.MyLargeStruct.SomeOtherValue.SomethingElse.MyInteger

viral sonnet
#

direct access is best

rotund token
robust scaffold
robust scaffold
misty wedge
rotund token
#

start reloading the subscene that you made changes to the blob

viral sonnet
#

modifying a blob is better than creating a new one when you just need to modify one value.

robust scaffold
viral sonnet
misty wedge
robust scaffold
misty wedge
#

Are you sure? I recall having that somewhere

rotund token
#

i believe unity won't throw an error if you go deeper than the Value

misty wedge
#

^

#

It's not ever copying the value to the stack

viral sonnet
#

yeah it just complains on .Value access if it's not a ref

misty wedge
#

But back to my question, is it worth caching the ref value if you plan to retrieve 2-3 values from the blob?

rotund token
#

it was a very common issue people copying Collider to teh stack

#

and losing the per type info

robust scaffold
#

Oh right, I have no wrapping structs around my values so I always direct accessed them

rotund token
#

and breaking/not working properly

robust scaffold
misty wedge
robust scaffold
misty wedge
#

Ah okay, I was just wondering since I usually have a wrapping struct with many values per blob

robust scaffold
#

My component data's are typically single values though or reinterpreted as such so yea, a lot of direct .Value accesses.

misty wedge
#

I mainly use them for storing more complex data layouts, since you can store deep lists and the like without resorting to funky unsafe stuff

robust scaffold
#

My primary blob asset is the polygon vertices of a 2d polygon collider. It's a fixed buffer of float2s and is reinterpreted as a set of float4s when using pointers.

#

Actually, looking at the source again, i have no clue what im doing

misty wedge
#

my use case is equally complex

#

πŸ˜„

robust scaffold
# misty wedge

If itemSettings is the only property of the reference, you can just do BlobWeightedArray<ItemSettings>

misty wedge
#

ItemSettings is a managed type

robust scaffold
#

Ah. Huh.

misty wedge
#

It just stores the GUID to the scriptable object holding the data

robust scaffold
#

Oh, it's a unity object. That makes more sense.

viral sonnet
#

NativeQueue is actually FILO? Dequeue takes the last element. peek reads the last element. what is this. i can do the same thing with a list ...

robust scaffold
viral sonnet
#

that's what i expected ```/// <summary>
/// Removes and returns the element at the end of this queue.
/// </summary>
/// <exception cref="InvalidOperationException">Thrown if this queue is empty.</exception>
/// <returns>The element at the end of this queue.</returns>
public T Dequeue()
{
if (!TryDequeue(out T item))
{
ThrowEmpty();
}

        return item;
    }```
#

is this just worded awkwardly?

misty wedge
#

I think it's a typo tbh

rotund token
#

I think is just English

misty wedge
#

Maybe

robust scaffold
#

No, it's worded correctly. I think... Returning the element at the start of the stack sounds right as well.

viral sonnet
#

"end" is always referenced in other methods too. so not a typo