#archived-dots

1 messages ยท Page 129 of 1

vagrant surge
#

ah thats ok then

charred elk
#

Guys sorry for those random questions, how can I fix a entity rotation? Do I have to set the rotation to 0 on a jobcomponent?

sour ravine
charred elk
#

Oh sorry!

sour ravine
#

kinematic bodies can break a lot of things unless you know what you're doing

#

if it's just a visual thing then go ahead

charred elk
#

Think that is about physics then

junior fjord
#

ok, a hopefully last question for the singletons:
If I do

OnUpdate(){
  var globals = GetSingleTonEntity<WaterBuffer>();
  var buf = GetBufferFromEntity<WaterBuffer>()[globals];
  Entities.ForEach(){
     //use buf
  }
}

to what is the depency on WaterBuffer now added? For the entities.foreach job or for the system itself?

dull copper
#

I'm guessing there's no way to get scene view render converted meshes in real time when using DOTS subscene?

#

I just found out that joints work on dots subscene now (but still having issues with some other physics conversion scripts there)

opaque ledge
#

have to check codegen but to system itself most likely @junior fjord

dull copper
#

it's just annoying to have to use debug gizmos on the actual game view, can't view everything as easily (gizmos work on scene view but are pointless unless you can render the meshes on real places)

junior fjord
#

yeah, but I need the depency on the job, not on the system right? I don't want the system to wait until anything finishes, I just want it to run, schedule the job, and the job has to wait until the buffer is free again

opaque ledge
#

actually wait, there is no handling dependecy here, you are accessing the buffer in main thread, so if you were to make another system that access that buffer it will give you an error

#

you have to access the buffer inside your job so Unity can handle dependency

#

its not a problem for me since i am only doing it once in 1 system so it doesnt give me error

junior fjord
#

are there no jobs running while OnUpdate is running?

#

So unity first runs all onupdate and then schedules the jobs?

opaque ledge
#

yeah something like that

junior fjord
#

ok, is there an easy way to check the dependences a system has? I never handled them explicitely before

opaque ledge
#

afaik no

dense crypt
#

SystemBase.Dependency

junior fjord
#

haha ๐Ÿ˜„ ok then I'll just hope unity does the right thing?

#

@dense crypt is that something human readable?

dense crypt
#

Na, but it's the dependency chain

opaque ledge
#

thats just jobhandle, it doesnt give you any information about what stuff that system is currently being depended on

dense crypt
#

New debugger should be able to help you show dependencies

opaque ledge
#

there was a forum topic about an 'analyzer' to inspect dependincies, not sure if it is going to be reality

junior fjord
#

is that new debugger out already?

#

hmm ok, so by using the buffer in the foreach, unity sees that the job also queries the buffer and therefore adds the corresponding read/write depency to that job?

opaque ledge
#

yes

junior fjord
#

is it enough to do it like this

OnUpdate(){
  var globals = GetSingleTonEntity<WaterBuffer>();
  var buf = GetBufferFromEntity<WaterBuffer>()[globals];
  Entities.ForEach(){
     //use buf
  }
}

or do I need to call getbufferfromentity in the foreach for that to happen?

opaque ledge
#

right now you are doing it on main thread so Unity cant 'see' it therefore cant do any dependency stuff

dense crypt
#

No, you do
Entities.ForEach(in/ref DynamicBuffer<YourBuffer> abc)

#

then unity resolves the dependencies automatically

opaque ledge
#
var globals = GetSingleTonEntity<WaterBuffer>();
var buffers = GetBufferFromEntity<WaterBuffer>();
Foreach(()=>{
  var buf = buffers[globals]
})
junior fjord
#

yeah but this is a singleton entity with global data

#

ok, so I actually need to access the BufferFromEntity thing in the foreach for unity to understand it (so in this case buffers instead of buffers[globals])

opaque ledge
#

yeah

junior fjord
#

ok thanks as always ๐Ÿ™‚

opaque ledge
#

its however pretty slow unfortunately, i am hoping that they will give us an easy way to access singletons

warped trail
#

why not get this buffer with EntityManager ?

opaque ledge
#

its a main thread access

warped trail
#

and?

opaque ledge
#

you will get an error if you do the same in a different system..

#

please notice that its not a read only

warped trail
#
var globals = GetSingleTonEntity<WaterBuffer>();
var buffers = EntityManager.GetBuffer<WaterBuffer>(globals );
Foreach(()=>{
  //do your stuff with buffer
})```
opaque ledge
#

buffers is a WaterBuffer, not BufferFromEntity

warped trail
#

but he has only 1 buffer

opaque ledge
#

Yeah but there could be access from different places

#

lets say 1 system writes to it, 1 system reads from it, and they are both accessing it on main thread and schedules a job to access that buffer you will get an error

#

if there is only 1 access, then its fine, but not when multiple

junior fjord
#

reading online it seems that GetSingleton creates a sync point and waits for all jobs to finish

warped trail
#

yes

junior fjord
#

so if I would have
System A -> Gets buffer, schedules job with it
System B -> Gets buffer, schedules job with it

Then the OnUpdate of SystemB will wait for the job scheduled in A to finish?

warped trail
#

Singlton is simply and entity

dense crypt
#

OnUpdate will keep running

#

the job won't run until SystemA's job is done

warped trail
#

as an naรฏve idea, why not use blobasset?

#

you can have blobassetreference in component

amber flicker
#

presumably the data in this case is mutable?

warped trail
#

every entity which need acces to your global thing will have this component

#

if you need to change global thing, you create new blobassetreference and update all components

#

and you can change blobassets๐Ÿ˜…

junior fjord
#

I think the idea of a singleton entity for my global arrays is quite nice, I just noticed that I have no clue of how unity actually does the dependency management between jobs.
Therefore I do not understand what happens if I do some query in on update and then start a foreach job with another query

amber flicker
#

you can but it's just higher resistance right? dunno ๐Ÿ™‚

warped trail
#

you will create sync points when you access your singlton๐Ÿ˜…

#

with my idead you don't need to sync anything

#

you get data straight from job

amber flicker
#

ok.. so there's a bit too much above for me to scan quickly but isn't this what the shared static stuff is for?

junior fjord
#

but until now I am just using static nativearrays for my data, the only reason I wanted to convert is to make use of future (or already existent?) "save all entities" "load all entities" stuff

#

and get rid of the disposing of the nativearrays and stuff

#

yeah either sharedstatic or global nativearray is also an option but people recommended me singleton entities for global arrays, and I actually like the idea

#

I just don't understand the depencies I am creating unfortunately

opaque ledge
#

just access it inside the job...

#

i literally showed you ๐Ÿ˜„

junior fjord
#

so if I would have
System A -> Gets buffer, schedules job with it
System B -> Gets buffer, schedules job with it

Then the OnUpdate of SystemB will wait for the job scheduled in A to finish?
@junior fjord but what about this?

dense crypt
#

OnUpdate never waits

opaque ledge
#

it might not be the 'best' solution or whatever, but it works ๐Ÿคท

dense crypt
#

unless you say .Complete()

junior fjord
#

yes @opaque ledge I know you showed me, I read it and thanks a lot, I just don't get it ๐Ÿ˜„

warped trail
#

it waits if you make structural changes

dense crypt
#

Your job will run on another thread in the background

#

the job that get scheduled last of the two is the one that will wait until the first job is done

junior fjord
amber flicker
#

Am I right in thinking... reading data in a job without sync point, you can do via Shared Static or BlobAsset - this is because both have a very explicit 'I'm not being written to' aspect. Singletons create a sync point but therefore they are less of a faff to write to so nicer to use?

warped trail
#

@junior fjord use thins things < > around your links๐Ÿ˜…

dense crypt
#
Entities.WithName("JobA")
            .ForEach((ref DynamicBuffer<WaterHeight> buffer) =>
            {
                Debug.Log("Hi");
            }).Schedule();
            
            Entities.WithName("JobB")
            .ForEach((ref DynamicBuffer<WaterHeight> buffer) =>
            {
                Debug.Log("Hi again");
            }).Schedule();```
#

This will make JobB wait on JobA. It will not make OnUpdate() wait

warped trail
#

this is not the case we are talking about ๐Ÿ˜…

dense crypt
#

Oh no?

junior fjord
#

yeah no, I understand that case

warped trail
#

our case is like get buffer from first query in main thread and pass it to second query

#

which basicallly will be JobA.Complete()

#

unless you use NativeArrays

dense crypt
#

Hmm ok then I misinterpreted the question

warped trail
#

and this is some sort of solution too ๐Ÿ˜…

junior fjord
#

I am scared of this:

SystemA:
1. Get WaterBuffer from global singletone in OnUpdate
2. Use this buffer in JobA, which it schedules using Foreach.Schedule

SystemB:
1. Get WaterBuffer from global singletone in OnUpdate
2. Use this buffer in JobB, which it schedules using Foreach.Schedule

Now as I understand it, JobA will run, maybe through some magic even understand that its ForEach.Schedule also depends on the WaterBuffer and note in the job depencies that it writes to WaterBuffer.
Now SystemB runs right afterwards and when it does 1. and gets the singleton, it will now wait for the JobA of SystemA to complete. But that is not what should happen, it should schedule its JobB should wait for JobA (not the OnUpdate itself)

#

when I am using nativearrays instead of the global buffers, I don't mind, I do not have this problem, since unity does not care for them and I handle the dependence of the jobs myself (either explicitely or by using tag components s.t. the systems don't run in parallel)

#

I am basically trying to understand if the above case is somehow way more trivial than I am thinking or if I just should stay with my nativearray solution maybe

dense crypt
#

This singleton is the only entity with WaterBuffer?

junior fjord
#

yes waterbuffer is a singleton component

warped trail
#

why not use something like this?๐Ÿค” ```cs
public struct ReferenceToGlobalBlob : IComponentData
{
public public BlobAssetReference<WaterBuffer> Value;
}
Entities.WithName("JobA")
.ForEach((othercomponents, in ReferenceToGlobalBlob reference) =>
{

}).Schedule();

junior fjord
#

yeah that is basically what I am doing, my current setup is

public static class Globals{
    public static NativeArray<float> WaterHeights;
}
public struct WaterHeightsIndex : IComponentData{
    int index;
}
Entities.Foreach((in WaterHeightsIndex id))
#

I don't know what these BlobAssets are, I can take a look into them

#

but seems like a similar way of doing it

warped trail
#

but if you want to change your native array it is not safe and easy ๐Ÿ˜…

junior fjord
#

ok here, ths is my actual setup ๐Ÿ˜„ (I shortened it down a bit):

warped trail
#

you will need to pass jobhandle from system wich changes your native array to every system which uses it ๐Ÿ˜…

junior fjord
#
public static class Globals{
    public static NativeArray<float> A;
    public static NativeArray<float> B;
}
public struct TileID: IComponentData{
    int id;
}
public struct AccessToA : IComponentData {}
public struct AccessToB : IComponentData {}
Entities.Foreach((ref AccessToA _, in AccessToB __, in WaterHeightsIndex id))
warped trail
#

and with my thing it is just cs assetRef = new BlobAssetReference Entities.WithName("JobA") .ForEach((othercomponents, in ReferenceToGlobalBlob reference) => { reference.Value = assetRef }).Schedule();

junior fjord
#

this now writes to A, reads from B and unity will handle it s.t. no other system writing to A or B is run in parallel

#

all I have to now do is check that I only write to A[id] in the for loop, s.t. I don't write to the same place from the same job

#

the only things that bug me about my approach are

  1. Nativearray allocation/disposing
  2. always having to do var a = Globals.A and Entities.WithReadOnly(A) or Entities.WithoutParallelForRestrictions in every systems that use the arrays
  3. that if I have to implement my own saving/loading mechanism for the nativearrays

I wanted to get around 2 by using SharedStatic instead
And I thought singleton entities could get around 1 and 3 even, but it seems they are kind of complicated

#

@warped trail I don't really understand your example code

warped trail
#

what exactly?๐Ÿค”

junior fjord
#

maybe I need to check what blobassetreferences are. But you are just setting all the buffers of your entities to the same assetref that you just created before?

warped trail
#

ReferenceToGlobalBlob is basically component with pointer to blobasset

junior fjord
#

thanks for the video ๐Ÿ‘

#

looks good

#

ok these blobs are pretty cool, pretty much what I implemented with the tileIds I think

#

unfortunate that they are readonly ๐Ÿ˜„

warped trail
#

you can change them๐Ÿ˜…

fallow mason
#

I like Brian Will's videos and usually agree with his points, but that first comment is correct. This is the guy who complained about Unity's naming scheme being too long and descriptive. Think he takes it in way too far a direction using variable names like m,d,e,e2.

warped trail
#

but aren't they really too long?๐Ÿค”

fallow mason
#

yeah, not disagreeing with that premise so much as his proposed replacements in that video.

#

hmm now I can't find that video

junior fjord
#

yeah the videos are great, I just checked his channel

#

it is so unfortunate that you never seem to find stuff like that by yourself

zenith wyvern
#

yes, we're asking what happens if you make the internal storage buffer large enough that it can't fit into a chunk
@sour ravine

If an archetype is too large to fit inside a chunk unity will immediately throw an exception when you press play. Unity includes InternalBufferCapacity for a Dynamic Buffer in this size check

junior fjord
#

if you just search for unity ecs on youtube you don't find him

#

and I am a fan of very describive names ๐Ÿ˜„ all my stuff is way to long

warped trail
#

i am fun of 80 characters per line๐Ÿ˜…

mint iron
#

long descriptive names are typical in the C# business world

junior fjord
#

yeah I don't follow that rule, but I also never have two code windows open side by side

#

ok maybe if I am copying stuff from my webbrowser it would be nice if the code would fit in one half of the screen

mint iron
#

i limit my line widths because im on a shitty laptop without much screen space and my vision is getting worse :S

junior fjord
#

but for me being able to quickly skim stuff and directly understand what is what is more important

fallow mason
#

I've been spoiled with a dual screen setup, so i make my variable name 80 chars long ๐Ÿ˜›

junior fjord
#

what I really hate about C#/Unity is their naming scheme of method members

#

I don't like camel case and I don't like member variables starting uppercase ๐Ÿ˜„

mint iron
#

whats amusing is the mismatch, im fine with it if you go that way 100%

#

but like 30% of it is proper c# naming conventions and the rest is a batshit mix

fallow mason
#

yes, a lot of hungarian notation in samples

#

dont care for that

junior fjord
#

hungarian notation is lowercase camelcase?

fallow mason
#

m_

junior fjord
#

i_like_this_version

zenith wyvern
#

you can change them๐Ÿ˜…
@warped trail

You can't change blobassets, you can replace them but you then need to go and update all references to the original blobasset to point to the new one

warped trail
#

@zenith wyvern you can get unsafe pointer and change stuff๐Ÿค”

#

or am i wrong?

junior fjord
#

but why not work with nativearrays if you are already on that point?

warped trail
#

this is how they change collider size in Physics samples

zenith wyvern
#

I haven't seen it myself, but I guess you would be right then. I remember seeing a unity person say the same thing I just said to someone on the forums wrt Blobassets

#

But maybe I'm misremembering that

warped trail
#

some voodoo * stuff ๐Ÿ˜…

mint iron
#

i've avoided blob assets like the coronavirus, the way they're created seems so annoying.

coarse turtle
#

lol - I've used this mainly in the beginning but after a while I've stopped using it ๐Ÿค”

#

I might pick it up again to store font glyph information

warped trail
#

you can create them once and then serialize them to disk๐Ÿ˜…

vagrant surge
#

๐Ÿ‘€

#

blob assets are an amazing idea, im waiting to see whats cooking

stable fog
#

blob assets?

vagrant surge
#

used by the conversion system, allows you to write some data to binary, and load it back

#

the fun part is that they are crazy fast

#

because its basically just a memory chunk you load and use almost directly

stable fog
#

oh its dots only eh?

vagrant surge
#

common use cases is stuff like navigation meshes, where you just compress the navmesh into a binary array and store that

zenith wyvern
#

Gives a good overview of them

stable fog
#

I'm working on a map editor, was hoping maybe there was a new way to store data that'd be faster than building assetbundles

vagrant surge
#

thats a good example for them

#

you would store most of your map as structs and arrays, as a blob of memory. Loading it doesnt need parsing, it just loads from file into RAM and you can inmediately use it

zenith wyvern
#

I don't think it's dots only really, it's just a big blob of read only memory you can access in parallel in jobs

vagrant surge
#

very important for next gen consoles where that "load file into ram" is suuuuuuuper fast

#

@zenith wyvern + save/load to disk

zenith wyvern
#

Wouldn't it be preferrable to use some kind of compressed file in that case?

#

Depends what you're doing I guess

vagrant surge
#

this is a compressed file

#

binary one

zenith wyvern
#

Oh?

vagrant surge
#

having blob assets automatically get zipped is something very likely to be a thing

#

if its not like that already

#

next gen consoles both have hardware .zip decompressors, and extremelly fast ssds, so you want to make sure that you dont have any parsing

#

so stuff like blob assets, which are just a binary dump of some struct/arrays, are a perfect fit

#

blob assets can be copypasted from disk to RAM and then they automatically work couse its just a binary dump

zenith wyvern
#

Is there any examples or anything of saving and loading blobassets to disk?

vagrant surge
#

there were some of that im sure, they go with the subscenes

#

and get stored alongside the subscene

#

but would need to go look at the specifics

zenith wyvern
#

Ohh I see

wary anchor
#

quick Q, if you have multiple RequireForUpdate(entityQuery) at the same time, do they AND or OR?

zenith wyvern
#

But subscenes are more for editor-time only, I was thinking of using them for procedural stuff

vagrant surge
#

subscens are a serialized group of entities

#

why would you want to use them for proceduralism?

zenith wyvern
#

Not subscenes, blobassets

#

quick Q, if you have multiple RequireForUpdate(entityQuery) at the same time, do they AND or OR?
@wary anchor

They and, the default behaviour from implicit queries is OR

wary anchor
#

thanks!

fringe sinew
#

I have trouble understanding chunk.DidChange and how it works

#

In case if I'm not mistaken, it takes the current iterating system version and compares it against the chunk's LastSystemVersion and that's how it can tell that the chunk actually changed

warped trail
fringe sinew
#

But I don't understand how exactly can such a method even work

zenith wyvern
#

@warped trail Thanks!

fringe sinew
#

It says "LastSystemVersion is updated to match the "GlobalSystemVersion" whenever a system runs."

#

So, alright, I have my systems and each time they have an incremented GLobalSystemVersion compared to the previous frame. Alright.

#

How does it help identifying that the chunks changed though?

mint iron
#

you could always troll through the source code; but i believe the way it works is, whenever anything writes to something in a chunk, the version of the chunk is updated.

fringe sinew
#

Well yeah, that's what I'm trying to do, but I can't make any sense of it

#

Like, here

#

It says that systems that access components from chunks write LastSystemVersion to it

mint iron
#

its saying that it doesnt know if you actually changed the value, if the component used in a job is ReadWrite then its going to mark the chunk as changed.

fringe sinew
#

But that doesn't make any sense. It's just writing the same value over and over then

warped trail
#

with write permission

zenith wyvern
#

Anything that accesses a chunk with write access marks it as changed. Doesn't matter what actually happens

mint iron
#

would you guys do 5 systems that have rarely run, related queries using Entities.Foreach... or have one system with 5 queries that are branched in Update with IsEmptyIgnoreFilter? I guess you could just still do 5x Entities.Foreach and let system base do the same Any RequireForUpdate behind the scenes.

zenith wyvern
#

If all the jobs the system is running are really closely related I would prefer the latter until the system grows pretty big, then go to the former

fringe sinew
#

But then it would mean that if the entity "contains" the component that is being iterated upon at least on one system, then it would be marked with a new version and the check is useless

#

Is that right?

warped trail
#

this is per chunk thing

#

and yes you are right๐Ÿ˜…

mint iron
#

it only really comes into play when you're dealing with huge numbers of entities.

warped trail
#

this is why you should specify read-only access to components whenever possible๐Ÿ˜…

fringe sinew
#

Are there any more fine-grained approaches to discarding chunks from processing?

zenith wyvern
#

Adding more components

fringe sinew
#

I've heard of SetFilterChanged, but it works only with SharedComponentData IIRC

zenith wyvern
#

You can use WriteGroups to override other systems based on the existence of a filter component

#

Just making good use of RequireForUpdate and change filtering can make a huge difference but yeah there's not a lot of simple options for really specific filtering unfortunately

fringe sinew
#

Alright, now I'm confused about the [WriteGroup] attribute

#

How does it really differ from specifying which components to exclude from the EntityQuery?

zenith wyvern
#

It overrides other systems, so you have a system that runs instead of another system based on the existence of one ore more extra components

fringe sinew
#

Yeah I just read that, but I still can't understand how can it be helpful

#

It feels more like a hack for you to silence other systems rather than just go on and refactor your other systems with which you may conflict

zenith wyvern
#

The transform system uses it extensively. There's like 10 different systems that all need to do specific things based on the existence of extra components added on to LocalToWorld. It's a bit old at this point but this video goes over it in detail https://www.youtube.com/watch?v=p65Yt20pw0g

March 23, 1:00pm (San Francisco) - Mike Acton demonstrates best practices for component design to achieve a high degree of parallelism, minimum synchronization, and high performance. He focuses on data layout and uses common examples in games (e.g. spatial queries, logic updat...

โ–ถ Play video
vagrant surge
#

write groups are kinda super convoluted

zenith wyvern
#

It seems like a reasonable way to get polymorphism-like behaviour in ECS

#

Though they are complicated for sure

vagrant surge
#

nah not really, its just automated filtering, in a way

#

chunk iterate witch checking if you have a comp or not

amber flicker
#

For 100k entities... ScheduleParallel() ~1ms, 12ms total over 22 workers.... Run() 3ms main thread... in editor but safety checks off and burst enabled. Makes sense I guess but a shame total time is 4x

warped trail
#

what about Schedule()?๐Ÿค”

mint iron
#

thats an interesting trade off when it comes to CPU usage and battery life, if its doing 4x the work to get 3 times faster.

amber flicker
#

yea... I'll try schedule for comparison - guess I may be hitting memory bandwidth issues or other things I don't understand ๐Ÿ˜…

#

actually tbf.. this was with deep profiling on.. will redo

#

ratio about the same deep profiling off

#

schedule is about the same as run in my case (possibly v slightly faster)

dull copper
#

also please do the profiling on the build ๐Ÿ™‚

mint iron
#

you could do an IJobParallelFor{}.Schedule.Complete and compare it against Job.ForEach.Run with the same work, wrapped with StopWatch. I think it would be a more accurate comparison. You can also then compare different thread counts.

warped trail
#

and what type of work are you doing in jobs?๐Ÿค”

amber flicker
#

work is a lot of CDFE and ifs - wish it could be otherwise but that's what it's doing - no buffers or anything fancy

#

fwiw timings look pretty much the same in attached builds

zenith wyvern
#

That's like the worst case scenario, nothing but random access

amber flicker
#

yup

#

though in theory this is very predictable rand access

zenith wyvern
#

I actually cannot find it

warped trail
#

it works fine for me๐Ÿค”

mint iron
#

Write groups are super interesting, a bit hard to get my head around tbqh. But i learned something there so thanks for the link. The health example with the invincible component was really good.

coarse turtle
#

yea - i was stuck when I was reading the old docs for so long

#

until they have that example in the newest doc version

zenith wyvern
#

That link works for me

warped trail
#

it works only if i refresh the page๐Ÿ˜…

loud matrix
#

So after 3 days debugging an issue I assumed was from my DOTs code, looks like it's just been a issue with Unity that for some reason they keep having break again and again.

mint iron
#

thoughts on project organization of components/systems? in two of my projects now ive grouped systems in a folder and then sub-grouped within that once the counts of related things go beyond 5 or so. Same deal with components. But now that im getting up to around 40 components im starting to think that in some cases it could be clearer to group components into the systems .cs files if they're only used there.

loud matrix
#

I did the same as you when testing before, and found having them contextually separated worked best

zenith wyvern
#

I used to do Systems/Components folders but it got to be too messy for me. I now group related systems and components together in their own folders

loud matrix
#

Only issue was I kept forgetting if id used folder to components or systems or if I'd used naming conventions...

dull copper
#

that'll work

#

as the first link should have as well

mint iron
#

interesting. that reminds me of the old MVC .Net days, where the accepted organization was copy of the same organizational tree for each data type. So ilke.
Components
>> Section
>> Feature
Systems

Section
Feature

vagrant surge
#

almost everyone does separated systems and components folder

zenith wyvern
#

I have no idea why but the first link suddenly works for me now (it wasn't working before even if I refreshed)

#

Who knows

vagrant surge
#

and then split by category on each

#

the ecs samples also do that

dull copper
vagrant surge
#

and of course, copious usage of go-to-definition

dull copper
#

or all vault content in fact

amber flicker
#

More anecdotal numbers for comparison, a v simple job with linear access ~1ms total time Run, ~2ms total time for ScheduleParallel() - a multiplier closer to 2x than 4x - I guess it makes sense that more rand access makes the scaling across threads worse - all 3900x specific of course

zenith wyvern
#

Unity's own packages don't do separated systems/components

dull copper
#

I've done some parser for gdc vault so I've played with their website structure a bit

zenith wyvern
#

They do related systems and components together

#

Well, it's probably not at all uniform across all packages actually

vagrant surge
#

@amber flicker true rand access does indeed not scale well across threads, as it bottlenecks on memory bandwidth

#

and if it was on 1 core, more stuff would fit into the cache, so you would get a better L2-L3 hit rate

zenith wyvern
#

Huh, so if your job is only doing random access it's better to just do it on one thread?

vagrant surge
#

talking about "for loop" type random access

#

if its a linked list, multithreading is a lot faster

#

the thing is that on very simple loops, something like:

for(int c : components)
{
  c.val += components[c.parent].val
}
#

cpus crunch this pretty well

#

as they can pipeline the loops somewhat decently

#

if its a linked list or a graph, where you cant pipeline a thing, there is more stalling

#

so more threads (even hyperthreading) would help

vagrant surge
#

so im checking the sample for Tiny Racing

#

and running it through the profiler to see where time goes

#

looks like something north of 90% is job system overheads

#

the actual time the code inside the for-each lambdas take to run would be something around 0.1 ms total

#

this is the profile capture for the "MoveCar" system in Tiny Racing

#

this is the profile capture, with the "useful" stuff marked

#

checks off

dull copper
#

@vagrant surge you've toggled off the safety checks in the editor?

vagrant surge
#

yes

#

but of course, this is on deep profile, so overheads for days

warped trail
#

are you testing in editor?๐Ÿค”

dull copper
#

also, I'd strongly recommend profiling in the build if tiny supports it

vagrant surge
#

yeah its editor, so not that accurate. but still the sheer delta difference of useful work vs others is huge

warped trail
#

what the point of testing Tiny in editor๐Ÿค”

vagrant surge
#

@warped trail having a pure ecs environment

warped trail
#

it is different thing in build

dull copper
#

ah yeah, that's a good point

#

they have different renderer

#

(on build)

vagrant surge
#

gonna try build and run and see if the delta is still this absurd

warped trail
#

i don't think you can use profiler in tiny build๐Ÿค”

dull copper
#

this is what I'm wondering here as well

#

never tried it

vagrant surge
#

dont worry i cant make package anyway

warped trail
#

it is like no unity in build๐Ÿ˜…

vagrant surge
#

build errors XD on dots packages

#

trying to package for standalone, not really web

#

for what the profile callstack looks, it seems like all that overhead is the logic that checks if stuff can run in parallel or not

dull copper
#

you need the new build tools to package for dots runtime afaik

#

they ship with platforms package now

vagrant surge
#

all foreaches do it, because they are still a job even if they get "Run", on Run is job but on main thread, so it needs to check if there are pending jobs with data hazards

#

this also means that its likely that a ecs build that does Run ONLY is likely to remove a lot of this overhead

amber flicker
#

I'm inclined to believe vblanco's roughly in the right ballpark though.. my simulation group is like 0.5ms processing just one entity - it only starts increasing when I'm near 1000 entities

vagrant surge
#

0.5 ms too much

#

systems here tend to have 0.05 overhead

#

which seems more about right

#

but the more interesting part

#

the more components you have on the for-each, the slower it is

#

and im sure its due to this dependency checking

#

systems that have a lot of components, like this MoveSystem which has 8, take like 0.1 ms

#

systems that only iterate 2-3 comps, are like 0.02

#

so it even looks to be linear

amber flicker
#

0.5ms for all systems - not an individual system.. that'd be bad

vagrant surge
#

also btw, GetSingleton<> is slow as fuck for some reason

#

@amber flicker 10-20 systems?

amber flicker
#

less than 10 but some are run multiple times with .Complete (and yes, I know that's not ideal)

vagrant surge
#

no wonder my cpp ecs is a lot faster. it doesnt do any dependency checking whatsoever xD

#

cant do a build

stone osprey
#

Does dots work with "Adressables" ? Sooo... for example a System which spawns in Prefabs from those adressables ?

vagrant surge
#

guess to do a build you need the exact specific unity version or it doesnt work

amber flicker
#

@stone osprey nope - there's a recent post on the forums I think saying one day they plan to have better interop

vagrant surge
#

without being able to do a optimized build i cant really properly check this stuff ๐Ÿ˜ฆ

#

would like to see what is that checking overhead on a real build

stone osprey
#

@amber flicker uhmm... that sucks... there goes my plan... thought about storing prefabs, icons, whatever in those adressables... and a system which gets triggered by a incoming packet is used to spawn in the certain prefabs by using that adress system

amber flicker
#

@vagrant surge I know it's not 'pure ecs' but a normal unity project should show a similar thing right?

vagrant surge
#

this is just job system stuff

#

but look at the profile capture ive seen

#

see how in the big middle checking thingy there are 8 function calls

#

for a for-each with 8 components

#

wonder why the checking is so slow

zenith wyvern
#

@amber flicker uhmm... that sucks... there goes my plan... thought about storing prefabs, icons, whatever in those adressables... and a system which gets triggered by a incoming packet is used to spawn in the certain prefabs by using that adress system
@stone osprey

You can still use them you just have to do it on the main thread without burst

stone osprey
#

@zenith wyvern You mean the adressables ? Or the system ? Can i somehow allow a system to run on the main thread ? Or disable burst completly ? Im just here for the data oriented part ๐Ÿ˜‰

naive parrot
#

disabling burst is trivial.

#

you can do it project wide or for a specific system with .WithoutBurst( ) construct.

zenith wyvern
#

Yes. You can force jobs to run on the main thread and without burst, and you can even use monobehaviours in your queries if you use ConvertAndInject. So you can have something like

Entities.WithoutBurst().ForEach((Transform t, MyBehaviour b)=>
{
  // Do something with all your MyBehaviours that also have a transform
}).Run();
warped trail
#

you don't need specific version of unity to build Tiny๐Ÿค”

#

you just need windows 10 sdk if you are on windows ๐Ÿ˜…

stone osprey
#

Thanks ! Thats helpfull... so i could basically put all my junk into that adressable system... have one/several systems for spawning those adressables in...

vagrant surge
#

ive allways had huge issues with unity builds

#

the fact that the build system is closed source so i cant see wtf failed is one of the main reasons

warped trail
#

and you have to use new build system

stone osprey
#

Oh yeah... but i also have such problems without dots... especially android builds

#

those are doomed

vagrant surge
#

at least in unreal when my build fails due to android being shit, i can debug it, and see exactly where does the manifest get wrong values or similar

stone osprey
#

Yup and in unity you just get a nonsense message... so you visit the forums, stackoverflow, page 5 on google and still havent found the cause

vagrant surge
#

literally happened to me on a project

#

many tears where shed

#

at the end it was a dumbass store plugin causing conflicts

stone osprey
#

I fell that... happens everytime i do a major version upgrade, third party plugins are pretty awfull too...

vagrant surge
#

the kind of thing that if you can debug the build, you can solve in about 10 minutes

#

you need to setup CI on unity

#

and basically never do engine upgrade

#

make sure the build is buildable from day 1 up to shipping date of the project

stone osprey
#

CI ? Was that git related ? Those automatic builds ? ^^

vagrant surge
#

doesnt have to be git related

#

its just automated builds

coarse turtle
#

yeah - I wish I had CI - I had some issues with Unity build services ๐Ÿ˜…

vagrant surge
#

alternatively, you can press that "build" button as a daily routine

warped trail
#

with tiny build is alternative to play ๐Ÿ˜…

stone osprey
#

Only saw that on git, we had a lecture about CI, but we never were able to integrate it into gitlab... @vagrant surge But thanks, im gonna look into this ๐Ÿ˜„ sounds promising

vagrant surge
#

you can just have a .bat of some sort that runs daily

junior fjord
#

by the way

public static class Globals{
    public static NativeArray<float> A;
    public static NativeArray<float> B;
}
public struct TileID: IComponentData{
    int id;
}
public struct AccessToA : IComponentData {}
public struct AccessToB : IComponentData {}
Entities.Foreach((ref AccessToA _, in AccessToB __, in WaterHeightsIndex id))

this is my approach from today at lunchtime :D
It does not seem to work, since unity does not care for tag components when scheduling jobs?
I.e. two different systems, both having ref AccessToA are scheduled at the same time

#

am I doing something wrong or is that intended behaviour?

zenith wyvern
#

You can't use mutable statics like that inside jobs

#

If it does work now I promise you it won't in the future

junior fjord
#

well it does work ๐Ÿ˜„

stone osprey
#

One more quick questions... is a component allowed to store a gameobject reference in dots ?

junior fjord
#

this is what I am doing all the time, just until now I did not need the AccessToX components, since the systems had other components that managed them not running in parallel

coarse turtle
#

@stone osprey no - an ISCD does (wouldn't recommend for this since it splits chunks), or use a AddComponentObject from the EntityManager

junior fjord
#

now I have new systems that do not have overlapping components but write to the same position, so I thought the tag components would help me out

vagrant surge
#

@stone osprey yes, its possible

junior fjord
#

just unfortunately unity seems to ignore them

stone osprey
#

What exactly is a ISCD ? ^^

vagrant surge
#

but its a specific type of component

zenith wyvern
#

Isn't this exactly what SharedStatic is for

vagrant surge
#

that cant be used from jobs or burst

#

AddComponentObject is deprecated btw

junior fjord
#

@zenith wyvern you can replace the nativearrays by sharedstatic if you want to (it actually is a sharedstatic by now), but that is not the point here

#

problem is that the systems are scheduled in parallel

opaque ledge
#

So i am making a entity query to retrieve a singleton, and do SetChangedVersionFilter on that singleton to make sure my ForEach only runs when singleton value changes, but when i do ToComponentDataArrayAsync, that entity query runs even there is no change in the singleton but gives me array of length of 0 because there was no change, which makes whole idea useless, so should i simply go ToComponentDataArray and check if array length is above 0 or is there a better approach ?

coarse turtle
#

ISharedComponentData` @stone osprey you'll need to implement IEquatable and override the GetHashCode() - im not sure if unity has made this a requirement yet UnityChanThink

zenith wyvern
#

What do you mean by It does not seem to work, what error is it giving you

stone osprey
#

I thought about a component for storing popups for a entity... each entity should have unique popups, we also need a reference to that prefab getting spawned

vagrant surge
#

@coarse turtle massive mistake

#

do not use shared component data for that

coarse turtle
#

Yep - I know - that's why I wrote not recommended in my previous post haha

vagrant surge
#

there is an actual component type that can point to gameobjects now

#

and to normal C# stuff

coarse turtle
#

o

vagrant surge
#

but you cant use it from jobs/burst

stone osprey
#

So we basically can store gameobject references in a component.... but not in that way? PopUpComponent : IComponent { public GameObject spawnInWhenClicked; }

junior fjord
#

@zenith wyvern was that for me? sorry I am loosing the overview here
It gives me the typical You are trying to schedule a job A while job B is still using that nativearray, please add dependency

vagrant surge
#

in exactly that way

junior fjord
#

I can copy the message but unity just crashed, wait a second

zenith wyvern
#

Yes if you're accessing native arrays inside jobs you need to make sure whatever writes to your native array is included as a dependency for other readers/writers @junior fjord

vagrant surge
#

read about the "managed component data" part

zenith wyvern
#

Or always pass them with AsReadOnly

vagrant surge
#
Managed IComponentData
It is helpful to use a managed IComponentData (that is, IComponentData declared using a class rather than struct) to help port existing code over to ECS in a piecemeal fashion, interoperate with managed data not suitable in ISharedComponentData, or to prototype a data layout.

These components are used the same way as value type IComponentData. However, ECS handles them internally in a much different (and slower) way. If you don't need managed component support, define UNITY_DISABLE_MANAGED_COMPONENTS in your application's Player Settings (menu: Edit > Project Settings > Player > Scripting Define Symbols) to prevent accidental usage.

Because managed IComponentData is a managed type, it has the following performance drawbacks compared to valuetype IComponentData:

It cannot be used with the Burst Compiler
It cannot be used in job structs
It cannot use Chunk memory
It requires garbage collection

@stone osprey @coarse turtle

coarse turtle
#

Ah there we go - I was trying to find it in the change log - thanks

stone osprey
#

@vagrant surge Thanks ! So normal components can only use primitive datatypes or why exactly is a Managed IComponent required for storing Unity related stuff ? ^^ Thats a information that blog probably misses...

junior fjord
#

@zenith wyvern exactly, I wanted the dependency management to be automatically determined by using read/write access to the tag components

#

but unity ignores that

#

that is what I came here for

vagrant surge
#

normal components have to be only very primitive structs, because they basically "ARE" C style stucts

junior fjord
#

to understand if that is on purpose

vagrant surge
#

thats how burst handles them, and they get manually allocated on the chunks

#

for the C# runtime, normal components are invisible

#

managed components are basically normal C# stuff, with normal garbage collection, so they can point to other garbage collected stuff

zenith wyvern
#

Yeah I don't think you can do that, there's a hard restriction that if a job has write access to a NativeArray (accesses a nativearray without passing it as read-only) then any other jobs need to include that job as a dependency, or the write-job needs to manually be Complete()ed. If you want to stick with NativeArrays you can disable safety checks on the containers, assuming you know that no two jobs are writing to them at the same time @junior fjord

stone osprey
#

@vagrant surge Well that makes sense... thanks a lot ! ๐Ÿ™‚ The only question left is... are entitys possible with both normal primitive components and managed components attached ?

vagrant surge
#

yes

zenith wyvern
#

Or use DynamicBuffers/BlobArrays/SharedStatic

vagrant surge
#

its a suuuper recent thing

#

was only added like a month back

#

so it doesnt exist in tutorials nor anyone knows it even exists xD

stone osprey
#

Great, coming from a Entitas way of thinking this is totally normal... than i guess i need to move into the planning phase for the data layout ๐Ÿ™‚ @vagrant surge Thanks a lot for your help !

coarse turtle
#

haha - that makes sense

vagrant surge
#

@stone osprey maybe keep to entitas for now

#

ecs is still crazy early

junior fjord
#

@junior fjord yes I know that I have to have dependencies, that fully makes sense. I tried to reach that dependency by having the two systems have
Entities.Foreach((ref AccessToA a)) and Entities.Foreach((ref AccessToA a))
Normally, since both write to the same component, unity now would not schedule them at the same time and include one as a dependency of the other.

But it seems that in the case that AccessToA is a tag component (empty), unity does schedule them at the same time

vagrant surge
#

while entitas actually works and its stable, even if much slower

coarse turtle
#

was wondering when managed component objects were introduced...

vagrant surge
#

also

#

entitas is faster

#

if you have low entity counts

#

due to not having all of this huge job system overheads everywhere

zenith wyvern
#

@junior fjord What do you mean it's scheduling them as the same time? The error is because of your nativearray, not because of the components

#

You can't just work around the dependency, you need to explicitly include the job handle from the job writing to the native array in any other job that accesses the native array

junior fjord
#

@zenith wyvern normally, if two jobs write to the same component, one is included as a dependency of the other. Therefore, they are scheduled to run one after the other
If the component they are writing to is a tag component, unity does not schedule them to run after each other

stone osprey
#

Havent implemented Entitas into my current project :/ Was using OOP before and hell, it almost ruined the whole project... the serverside uses Entitas so far. I guess i need to test both of them to determine whats stable enough for getting implemented ^^

#

Dont even know why they teached us OOP at university... great for small stuf, awfull for scalability

coarse turtle
#

Dont even know why they teached us OOP at university... great for small stuf, awfull for scalability
@stone osprey it's being used in many parts of the tech industry, I learned FP first before I learned OOP - which made it easier for me to transition to DOD a few years ago

zenith wyvern
#

@zenith wyvern normally, if two jobs write to the same component, one is included as a dependency of the other. Therefore, they are scheduled to run one after the other
If the component they are writing to is a tag component, unity does not schedule them to run after each other
@junior fjord

Ohhh I see, I didn't know that actually. That's interesting. You mean this DID work if you weren't using tag components?

junior fjord
#

@zenith wyvern What I am saying is, if you have a component C, and SystemA and SystemB are both writing to C, they will be automatically dependent on each other (unity does that, right?) and I can safely write to the same nativearray from both systems, since I know they have the dependence.

Problem: If C is a tag component (empty component), unity does not do this dependency injection -> I have to do it manually

vagrant surge
#

Entitas is pretty sweet, and you can write entitas in a similar way as you would use unity ECS (low add/remove comps, and not too much spam of reactive systems). This would make it fairly easy to adapt later

junior fjord
#

yes exactly @zenith wyvern

vagrant surge
#

i honestly dont expect unity ECS to get close to entitas usability this year

zenith wyvern
#

I guess since Unity knows you can't be writing to anything inside a tag component it can safely schedule them in parallel, neat

junior fjord
#

haha no not neat at all for me ๐Ÿ˜„

#

I mean what other reason is there to declare write access to a tag component if it is not dependency management

#

this would be a very nice usecase for tag components if they would just treat them as normal

zenith wyvern
#

I guess that's just not how they're intended to be used, to be honest I would be very very confused if I was trying to figure out what was happening in your code if you didn't explain that to me

junior fjord
#

but right now I have another weird error, maybe I should first get rid of that

#

I thought this would be more elegant than always having to manually copy the dependencies between all systems that write to the same nativerrays

zenith wyvern
#

By it's very nature what you're trying to do is a workaround so I guess that's expected

low tangle
#

You are trying to schedule a job A while job B is still using that nativearray, please add dependency
this was just saying you were not inputting your first job into the job input for the second that used the same array

junior fjord
#

yeah but we had a few very long discussions about the intended way here today and yesterday and either I missunderstood it, or the alternatives all have their problems to

#

You are trying to schedule a job A while job B is still using that nativearray, please add dependency
this was just saying you were not inputting your first job into the job input for the second that used the same array
@low tangle I understand the message

low tangle
#

alright

junior fjord
#

it is about why this happens

zenith wyvern
#

I would personally lean towards dynamic buffers. But from what I understand there's no simple way to pass a dynamic buffer from one entity into a job for another entity without causing a sync point or without having to copy the buffer first for every job

junior fjord
#

since both systems write to the same component, it should not happen

#

they should be automatically dependency injected

low tangle
#

no

#

both jobs could run at the same time

junior fjord
#

two jobs, writing to the same component are scheduled at the same time?

#

@zenith wyvern yeah that is what I understood in an earlier discussion too. The nicest way would be a singleton entity but it seems to be kind of complicated to understand what happens if you want to include the buffers of that entity in a job

warped trail
#

@junior fjord unity does not manage NativeArray dependencies between systems๐Ÿ˜…

junior fjord
#

yes but component dependencies

#

that is why I have bo Entities.Foreach((ref AccessToA _)) in both systems, I hoped unity would see that both systems write to the same component and do it for me. But it seems that if AccessToA is empty, unity does not do that

low tangle
#

it does check that actually

junior fjord
#

ok, wait then let me get rid of the disposal messages before and hope that the error message was just some weird follow up ๐Ÿ˜„

#

that would make me very happy

warped trail
#

from docsNote that the system Dependency property does not track the dependencies that a job might have on data passed through NativeArrays or other similar containers. If you write a NativeArray in one job, and read that array in another, you must manually add the JobHandle of the first job as a dependency of the second (typically by using JobHandle.CombineDependencies).

junior fjord
#

yeah I get that I would have to do it manually, I am trying to trick unity into doing it automatically for me by using tag components, thats the point

zenith wyvern
#
        Entity _bufferEntity;

        protected override void OnStartRunning()
        {
            base.OnStartRunning();

            _bufferEntity = GetSingletonEntity<BufferType>();
        }

        protected override void OnUpdate()
        {
            var bufferEntity = _bufferEntity;
            var bfe = GetBufferFromEntity<BufferType>();

            Entities.ForEach((...)=>
            {
                var buffer = bfe[bufferEntity];
            }).Schedule();
        }
#

What about something like that

junior fjord
#

then all I have to do if I read/write from array A is to read/write include the AccessToA tag component

warped trail
#

@junior fjord you can't trick it with components

#

unity treats native arrays and components separately

junior fjord
#

It should work in general, all my systems before access the same nativearrays but have no explicit dependency management from my side. They only have the dependency managament that unity did from the components which is enough before

#

its just a new situation that I have to systems that do write to the same array and do not share any component

zenith wyvern
#

@warped trail He was already tricking it with components. But now he is trying it with tag components and it doesn't work, is what he is saying

#

It doesn't work because Unity doesn't care if you have write access to tag components basically

junior fjord
#

well it seems that it should work, if June is right, I have to get rid of all other errors first and then I'll come back and report

#

But I think unity only checks if there is a dependence between the systems if they write to the same nativearray, not if the dependence is explicitely set by the user or automatically by unity due to components

low tangle
#

I really wish I understood what the hell you were trying to do

#

because it sounds very not in line with how this framework works

#

to look at it a different way

zenith wyvern
#

He wants global mutable shared static data

low tangle
#

automatic dependency management is another way you could call GC

#

and GC is what were trying to avoid, automatic memory management is what were giving up

#

global:sure
shared:sure
static:sure
mutable:nope

warped trail
#

maybe your jobs was in same systems, thats why it worked before?๐Ÿ˜…

junior fjord
#

no, all different systems

#

I have basically 8-9 systems for the simulation of the water flow, most of them accessing at least the water heights array

warped trail
#

because no matter the components write access you should end up in error, if your jobs access same native array without explicit dependencies๐Ÿค”

low tangle
#

make it persistent allocated arrays in a static global class, or use a blob asset and use blob asset refs to get at it
or use that new wonky sharedstatic system with bad syntax

zenith wyvern
#

I would think if your systems are dependent based on component access then unity is just passing the job handle to the dependent system under the hood, so it would be no different than doing it manually

low tangle
#

or use a dynamicbuffer on a entity

zenith wyvern
#

I think it's not a good idea in any way, but I don't see why it wouldn't work

low tangle
#

personally I just default for the most general purpose tool keeping my data as close to entities as possible. idea is to minimize the amount of translation I need to do too and fro entities

warped trail
#

@zenith wyvern but you are the one who posted example that this thing is not working๐Ÿค”

zenith wyvern
#

In my example my two systems did not have write access to the same component so there was no internal dependency

junior fjord
#

Ok, what I am doing
I have a 2d map of hexagon tiles. This is a simulation-heavy game, right now I am simulating waterflow and ground humidity. There are a lot of properties, that each tile has, e.g. waterheight, humidity, water velocity, ....

Approaches to do this
(1) Each Tile is an entity, with WaterHeight, Humidity, .... component. But the tiles often need to lookup their neighbors -> a lot of GetComponentData calls (this is what I did at the beginning). Also here I have to work tricks, if I want a tile and its neighbors to be in the same chunk (if they are not even in the same chunk, then the neighborhood lookup is even more expensive)
(2) Entities for chunks of tiles. Now Each entity has dynamicBuffers for WaterHeight, Humidity, .... Still, the tiles on the border of one chunk, will need to lookup the neighboring chunks -> I always have to check if a tile is currently on the border, maybe get neighboring tiles etc. A lot of branching in the code and lookups again
(3) WaterHeights and Humidities are saved in arrays, the entities just have indices into that array. Now I can make sure, that the arrays are layed out in a way, that data of nearby tiles is nearby in the array, I have no calls to GetComponentDataFromEntity etc.. All entities also have an dynamic buffer of its neighbor ids and can therefore look them up quickly

I started with 1 and then went to 3

zenith wyvern
#

I'm basically doing 2 in my voxel thing I made

low tangle
#

its always the voxel/minecraft/tile chunk problem people do

#

swear its the first thing everyone does

junior fjord
#

haha no this is not the first thing I do unfortunately ๐Ÿ˜„

#

I jump onto a new idea every few months

#

but I think chunks are pretty common in big simulated worlds

vagrant surge
#

2 works very well

low tangle
#

yes you are going to want to group your hot data at some granularity into the same """"chunk""". yes your border data is going to be slow to find. precaching that data is a good idea. just taking the hit is also fine. profiling is also a good idea for each type

junior fjord
#

but as I have it now, I have to never check for the border, so no branching at all from bordering and no complicated find my neighborhood data stuff

formal scaffold
#

Hey, can someone explain to me why the PhysicsVelocity keeps updating even when a Cube(with dynamic Physics Body) just sits on a plane? Shouln't the physics Velocity be still and not change unless something applies force?

junior fjord
#

I actually like most of it very much in how it works, just the dependency management could be tiring if I don't get unity to do it automatically

zenith wyvern
#

In my opinion the workarounds you're having to do to keep your data in native arrays is not worth it. You're working hard against the framework

warped trail
#

@formal scaffold because this is how unity physics works ๐Ÿ˜…

zenith wyvern
#

IMO you should just use dynamic buffers. Yes it's annoying to have to access neighbours but I feel like it's more line with how things are supposed to work in ECS

#

To me anyways

junior fjord
#

well I'll use the framework more for the non-simulation stuff. But for the simulation stuff (I want to simulate the whole world), I think it is worth it that I can pick my own data layout in the arrays

#

and have no border cases (!)

#

I mean I basically just do
waterHeight = waterHeights[tileID]
instead of having waterHeights directly accessible

low tangle
#

yes, you should be packing your own arrays if you feel that a: it will be easier to write or b: you know from profiling that it will be too slow otherwise

hollow sorrel
#

@formal scaffold unityphysics is stateless by design so i'm guessing it is doing a calc for gravity pushing it down and then the collision bringing it back up every frame having a slightly different result every frame
also it has no concept of sleep like physx does, you could add this yourself tho

low tangle
#

I wrote a minecraft chunk and mesh generator in ecs in two hours the other night, it used one entity for holding the voxel data

#

another for holding the mesh arrays of verts etc

zenith wyvern
#

But dynamic buffers are arrays. And unity will handle the dependencies for you, which is the issue you're having right now

low tangle
#

border lookup was just done in the slow way

#

and guess what, the unity mesh creation (using the new api) was still slower than generating the data in the first place

zenith wyvern
#

I found the same thing, mesh uploading was by far the slowest part

junior fjord
#

yeah but I don't do it only because of performance, but also because I don't want to do if(x == 0 || x == chunkWidth || y = 0 || y = chunkHeight) all over the place

#

ok my or statement was made spoiler safe to make it more interesting ๐Ÿ˜„

#

what could I be checking there?

zenith wyvern
#

You can alleviate a lot of that with static functions

junior fjord
#

and I am doing simulation of flowing water which is pretty expensive I think and I want to be able to do it on a as large map as possible

zenith wyvern
#

But yes there's no getting around it neighbour checks are very annoying

vagrant surge
#

in cpp i use fun stuf like iterate_neighbours functions that take a lambda

zenith wyvern
#

You could always embed the edge data in each chunk. I was thinking about doing that but I hurt my brain too much trying to figure out if it would be better than just using random access

junior fjord
#

yeah I think getting around all edge data is worth the bit of effort I am getting due to handling dependence when writing to a handful of arrays

#

but yeah I am no professional and I don't get the games done I start normally so theres that ๐Ÿ˜„

formal scaffold
#

Wierd ๐Ÿง I have a Prefab selected in the inspector, press Play mode and watch the Editor Loop. Mine takes 20+ ms just for rendering the Inspector tab ๐Ÿ‘€ I just read a forum entry where one from Unity points to "something in your project that triggers some infinite repaints of some editor windows"

Does anyone know how I can locate those? Is this even DOTS related?

junior fjord
#

does anyone know why this gives me

public abstract class HumidityData
{
    public static readonly SharedStatic<NativeArray<float>> humiditiesStatic = SharedStatic<NativeArray<float>>.GetOrCreate<HumidityData, HumidityValues>();
    private class HumidityValues {}

    public static void Initialize(int2 widthHeight)
    {
        humiditiesStatic.Data = new NativeArray<float>(30*30, Allocator.Persistent, NativeArrayOptions.ClearMemory);
    }

    public static void Dispose()
    {
        humiditiesStatic.Data.Dispose();
    }
}

a memory leak message? Short after I start the game (I call Instantiate), unity notifies me that a nativearray has not been disposed which was allocated from instantiate

#

I am trying to switch from nativearray to sharedstatic ๐Ÿ˜„

scarlet inlet
#

Hey gents and not gents: a SystemBase Foreach is now translated in to a Job right? ParalleJob per chunk if I got it right. Is a Foreach inside a Foreach still a parallel job with the second Foreach becoming a normal foreach?

#

@junior fjord why doing a static array out of curiosity? It's possible to share arrays inside systems without being static

vagrant surge
#

@scarlet inlet i was looking into it today, depends if you do Run or not

#

its allways done into a job

wide fiber
vagrant surge
#

but how that job runs and what type of job it is depends on how its launched

#

with Run, its main-thread, and it just does a for loop over the chunks

#

with Schedule it puts that job into the workers

#

with ScheduleParallel it does parallel for

scarlet inlet
#

what kind of job?

vagrant surge
#

but need to check scheduleparallel

scarlet inlet
#

and a foreach inside a foreach?

mint iron
#

@junior fjord the way they detect leaks is by putting a DisposeSentinel inside collections like NativeArray. They keep track of all the sentinels that were created. If they go through them and a sentinel hasn't been disposed, then throws a leak exception. What's probably happening is that there is no class holding a reference to your NativeArray, so GC comes along and thinks the class reference to its Sentinel should be disposed, and gobbles it up.

vagrant surge
#

on that one i have no idea whatsoever

scarlet inlet
#

I can think only of the second foreach becoming a normal foreach inside a job

#

it must have been pretty complex to solve all these combinations

vagrant surge
#

its more than just normal foreaches or not, there is a lot of cehcking on the job system

#

even the .Run does a lot of checking to make sure that there isnt a job on the workers editing the same components

junior fjord
#

@junior fjord why doing a static array out of curiosity? It's possible to share arrays inside systems without being static
@scarlet inlet just was the quickest way to do it with the least boilerplate when accessing it, dunno

scarlet inlet
#

@junior fjord in hindsight it wasn't ๐Ÿ™‚

junior fjord
#

what alternative do you have in mind?

scarlet inlet
#

my first choice is always to create entities

#

second choice could be dynamicbuffer or injecting nativearrays by constructor in the system

junior fjord
#

but I have multple systems using the nativearrays

#

@mint iron you mean since the HumiditiesData is an abstract class?

scarlet inlet
#

yes I would inject in all of them, however I understand why it may not seem a good idea to you, it's because Unity still let things to be created automatically

junior fjord
#

so I should save that nativearray somewhere else and then just set it into the sharedstatic?

scarlet inlet
#

which seems like a time saver, but instead hides possible patterns, like injecting data via constructor

junior fjord
#

what do you mean by injection?

#

just getting them from somewhere in the constructor and setting a membervariable to it?

scarlet inlet
#

well I don't wan to confuse you, but my Systems are always marked as [DisableAutoCreation]

#

this because I create them manually, which means I can call the constructor, which means I can inject data

#

however your first choice of data should always be the entities

junior fjord
#

so all your systems would have member variables pointing to the same nativearray?

scarlet inlet
#

if this is what you want, yes

#

but again I would prefer reaching the data through entities

#

I wouldn't use static for this

junior fjord
#

Ok, what I am doing
I have a 2d map of hexagon tiles. This is a simulation-heavy game, right now I am simulating waterflow and ground humidity. There are a lot of properties, that each tile has, e.g. waterheight, humidity, water velocity, ....

Approaches to do this
(1) Each Tile is an entity, with WaterHeight, Humidity, .... component. But the tiles often need to lookup their neighbors -> a lot of GetComponentData calls (this is what I did at the beginning). Also here I have to work tricks, if I want a tile and its neighbors to be in the same chunk (if they are not even in the same chunk, then the neighborhood lookup is even more expensive)
(2) Entities for chunks of tiles. Now Each entity has dynamicBuffers for WaterHeight, Humidity, .... Still, the tiles on the border of one chunk, will need to lookup the neighboring chunks -> I always have to check if a tile is currently on the border, maybe get neighboring tiles etc. A lot of branching in the code and lookups again
(3) WaterHeights and Humidities are saved in arrays, the entities just have indices into that array. Now I can make sure, that the arrays are layed out in a way, that data of nearby tiles is nearby in the array, I have no calls to GetComponentDataFromEntity etc.. All entities also have an dynamic buffer of its neighbor ids and can therefore look them up quickly

I started with 1 and then went to 3
@scarlet inlet this is my kind of lengthy explanation of why I don't have them on entities from before

#

it is not to much boilerplate and I never have to check if a tile is on the border, which I would have to do nearly always in other cases

scarlet inlet
#

I see

#

how do you identify the tiles?

junior fjord
#

through two things, their coorindates int2 and their tileID int. The cool thing is that I can also choose the tileIDs (and therefore in some sense the data layout) myself, and can use a nice spacefilling curve instead of the default y*width + x

#

so the neighboring tiles will be rather close in the array too most of the time

#

but the main thing was that I did not want the border checks all the time and it actually works to circumvent them fully this way

scarlet inlet
#

I mean, my guess is that UECS guys created all the native data structures (also) as workaround to the prolbme that you cannot query an entity other than with the ID provided by unity itself

#

so while it looks quite ugly, why not create a singleton entity or whatever UECS calls it, to hold your native array?

warped trail
#

๐Ÿ˜…

junior fjord
#

yeah but GetComponentDataFromEntity is also rather slow from what I heard. basically if I could do two things, my solution would not be needed:

  1. I would need to be able to set which entity goes to which chunk and in which order (so nearby tile entities would be close, I could choose my own spacefilling curve this way)
  2. GetComponentData to be as fast as an array lookup, which it isn't from what I've heard
scarlet inlet
#

no I didn't mean using GetComponentData

junior fjord
#

and we had the global entity buffer discussion like twice today already ๐Ÿ˜„ this was my most unproductive day in a long time I think ๐Ÿ˜„

scarlet inlet
#

I was literally saying why not query a singleton entity that holds your native array instead to use a static array?

junior fjord
#

the problem is, that if I do

var e = GetSingletonEntity<WaterHeights>();
var buf = GetBufferFromEntity<WaterHeights>(e);
Entities.Foreach(){use buf}

it does not seem to be clear, if the buf thing creates a sync point and in which sense the dependence of WaterHeights is actually added to the scheduled job

scarlet inlet
#

WaterHeights is a component right? cannot you do e.array where array is a antive array?

#

sorry I am not 100% used to UECS

#

I mean I don't use it for this stuff

junior fjord
#

no, components cannot hold array references

coarse turtle
#

you'd need an unsafe array - so what native array is built on top of

scarlet inlet
#

cannot hold native arrays?!

coarse turtle
#

those can be stuck onto components

scarlet inlet
#

hmm ok I thought they could, but ok as @coarse turtle was saying that are many arrays ๐Ÿ˜„

#

there is UnsafeList too

#

that can grow

coarse turtle
#

^ that too

scarlet inlet
#

there is even an unsafehashmap

#

๐Ÿ˜„

dull copper
#

nothing new here tho

#

just confirming that hybrid renderer v1 is not going supported properly

scarlet inlet
#

@junior fjord would that work?

junior fjord
#

what? putting some kind of unsafe pointer into a component?

#

I mean yeah I could do stuff like that but I don't think that is nicer than doing what I am doing

scarlet inlet
#

well it has an interface not too much dissimilar to nativearray

#

is that native array read only?

junior fjord
#

some are, some are not, I have a handful ๐Ÿ˜„

scarlet inlet
#

static means you cannot make them thread safe too

#

so careful in using them inside jobs

#

it's quite a pickle this case though

#

I really don't like the framework forcing you to find these solutions

#

also seems quite a common scenario

junior fjord
#

I actually don't think the solution is so bad, its just a bit to much boilerplate ๐Ÿ˜„

scarlet inlet
#

in an ECS scenario, forcing you to access an array through a static class, is a terrible solution, in the sense that it doesn't scale well

#

however for simple case scenario ok, it was the same thing pre-ecs after all

vagrant surge
#

the normal thing is that ecs have native support for singletons, and you use them for this sort of thing

#

better than the current singletons who cant have native arrays and similar inside

scarlet inlet
#

yeah I guess if you tell to the guy who designed the current ForEach to be super thread safe when using components, that you are putting in the code a global accessible native array, that can be caught by those foreach, he would just start to question all his decision in life ๐Ÿ™‚

junior fjord
#

If they wouldn't plan to remove support for SharedComponents having NativeArrays that would also be fine

#

well you just have to plan yourself s.t. the jobs that write to a nativearray don't run in parallel

scarlet inlet
#

I know but that's why it doesn't scale well as solution in larger teams

#

too many conditions/guidelines to remember

vagrant surge
#

the for-each being hypersafe kinda makes sense

#

after all its the noob-friendly automaticjob thing

scarlet inlet
#

yes but it's so friendly that it can catch that static native array

#

and boom

#

at least the JobDebugger helps!

junior fjord
#

@low tangle I now tested it fully. When I have something in my AccessArray component (e.g. some int), then it will manage the jobs to not run in parallel and does not give a warning about the jobs writing to the same position. As soon as I remove the content, I get all the warnings

#

so yes, Unity ignores tag components for scheduling

#

that is pretty sad

#

would have been the ideal solution and no idea why they would do that

amber flicker
#

scheduling based on tag components sounds like a bad idea? Can you use [UpdateAfter], [UpdateInGroup] etc instead?

low tangle
#

intresting

#

just make em have dummy data then?

#

single int32

formal scaffold
#

Any way to see local variables inside ForEach while debugging? The debugger won't tell me and I'm left with writing Debug.Log which is tedious, Sorry found it*

junior fjord
#

Yes thats the plan, why not a byte?

#

The Rider Debugger Shows them @formal scaffold

#

But it does not do data breakpoints

mint iron
#

mmm never seen this error message before... good to know.

ArgumentException: DestroyEntity(EntityQuery query) is destroying entity Entity(55:1) which contains a LinkedEntityGroup and the entity Entity(93:1) in that group is not included in the query. If you want to destroy entities using a query all linked entities must be contained in the query..
#

thats pretty annoying, i dont know how to resolve it except put the parents tag component also on the children, or iterate the children manually. LIke... isnt that the point of having LinkedEntityGroup, that these things can happen automatically?

zenith wyvern
#

@mint iron I ran into that too, yeah it's pretty stupid. Not sure what the point of LinkedEntityGroup is given the restriction

mint iron
#

Another fun related problem i encountered is if you have a prefab with children, who aren't setup with their own shapes/bodies, then they aren't instantiated with their parent... even though they're part of a LinkedEntityGroup. You have to manually assign the children with a prefab tag. ๐Ÿ˜ข

safe lintel
#

id open that up to the forums, that restriction seems ridiculous

vagrant surge
#

so im talking with one AAA dev who is using a unity style ecs but in unreal, and he has some interesting stuff

low tangle
#

oh yeah my child array I have to delete manually, that is until I shifted to a systemstate pointing at a separate entity which was the list. I only use that for auto cleanup

vagrant surge
#

he is lately adding polymorphism by storing function pointers in components

#

for some very specific things

#

in a way, its like oop, but fully dynamic, as the functions and the data can be changed at will

low tangle
#

pretty neat

#

whats he using it for though

vagrant surge
#

node graph

low tangle
#

just because you can do it

vagrant surge
#

as in blueprint/visual editor

low tangle
#

ah

vagrant surge
#

the concept looks interesting. The function pointers are all the form of (entityID "this", other data)

#

the component that holds the function pointer holds no data, the data is grabbed by grabbing components from the entity id

#

obviously slow as its reinventing virtuals, in a way, but for things like state machines or AI seems legit

low tangle
#

makes sense

vagrant surge
#

for state machines you can just swap the function pointers depending on state

low tangle
#

yep

vagrant surge
#

and if you made those function pointers a "shared component", then iteration is contiguous, so you dont get the normal penalties from virtual dispatch

obtuse swallow
#

Hello, is there a way to quickly get an array of components/components value? For instance if I want to do something with all positions of all entities that have components position&others

coarse turtle
#
query.ToComponentDataArray<T>()
query.ToComponentDataArrayAsync<T>(JobHandle, Allocator) <- I think that's the API

that might work for your needs

mint iron
#

mmm, you could do something similar by reinterpreting a struct inside a component as different things that contain methods. Its a different struct so magically a different function is called. And if you want, stash any params you need in the component.

vagrant surge
#

its more or less equivalent to have a "enum type" on the component

#

and then switching to the actual implementation

#

but obviously, more elegant and less centralized

warped trail
#

i think physics guys doing something similar with colliders, aren't they?๐Ÿค”

vagrant surge
#

indeed

#

physx does almost literally this for collisions

obtuse swallow
#

Thank you. It feels a bit weird that there is ForEach but not the full functional programming suite of Map, Reduce, etc. as they are common tool for easy-to-parallelize tasks.

warped trail
#

im talking about unity physics and their blobassetreference<collider>๐Ÿ˜…

vagrant surge
#

his use case was pretty interesting. He did it to get the info for the input and output of the nodes

#

so basically a "get input" and "get output" on the graph editor nodes

#

the actual data of those nodes is just implemented as other components for most of the stuff

mint iron
#

so maybe its closer to, storing the ptr to another component on another entity, and then calling an interface function on it.

vagrant surge
#

no, this interfaces are called with self

#

and called from ecs systems

#

its not really messaging around like typical oop does, its more to just allow some virtuals but without most of the normal drawbacks

#

the component data is still all stored contiguosly and stuff

#

the fun part is that this interfaces will likely be constant on the same archetype

#

so its still all very contigous in memory and consistent

opaque ledge
#

So, tomorrow i am going to try to make quest/mission system, any ideas ? ๐Ÿค”

coarse turtle
#

@opaque ledge are the quests linear, branching?

If they're linear you can probably have a linear fsm similar to what @vagrant surge was stating with components with a function ptr or what @mint iron was stating with reinterpreting the struct and when the condition is finished you call the function ptr which updates an index and allows you to jump around collection of 'quests'

I imagine with a graph/tree you can likely create a tree like array and do the same

Just from the top of my head - I've no idea how you want to design your quests ๐Ÿ˜…

naive parrot
#

how do we use ICustomBootstrap ?

#

and acutal code doesnt exactly mathc

#

am i missing something?

#

entities 0.8.

solar spire
#

The one you linked was 0.3

naive parrot
#

check the URL above , its the manual from same version.

#

its 0.8 , not 0.3

#

i mean the manual , sorry

#

scripting API doc is same for 0.3 and 0.8

warped trail
#

what exactly do you want to do?๐Ÿค”

solar spire
#

The API doc hasn't changed much yeah, sorry

naive parrot
#

i want to create a world manually then populate it with systems manually as well

#

to better understand the setup instead of going with default world and system initialization

#

the Scripting API doc matches with code found in package , obviously because its auto generated. the Manual is saying something different

#

how come i am seeing 2 different declaration of ICustomBootsrap?

#

vs

#
{
    // Returns the systems which should be handled by the default bootstrap process.
    // If null is returned the default world will not be created at all.
    // Empty list creates default world and entrypoints
    List<Type> Initialize(List<Type> systems);
} ```
#
    /// When entering playmode or the game starts in the Player a default world is created.
    /// Sometimes you need multiple worlds to be setup when the game starts or perform some
    /// custom world initialization. This lets you override the bootstrap of game code world creation.
    /// </summary>
    public interface ICustomBootstrap
    {
        // Returns true if the bootstrap has performed initialization.
        // Returns false if default world initialization should be performed.
        bool Initialize(string defaultWorldName);
    }```
solar spire
#
class MyCustomBootStrap : ICustomBootstrap
{
  public bool Initialize(string defaultWorldName)
  {
      Debug.Log("Executing bootstrap");
      var world = new World("Custom world");
      World.DefaultGameObjectInjectionWorld = world;
      var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);

      DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
      ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world);
      return true;
  }
}```
naive parrot
#

1st is from 0.8 manual , 2nd is from package

naive parrot
#

that means Manual doc is not updated ?

solar spire
#

seems like it

naive parrot
#

argh , this makes things harder

#

auto generated Scripting API doc doesnt help either

#

anyways , thanks. that does help.

#

changelog is the new manual i suppose

warped trail
#

i guess you can create world and systems without hooking them to unity's default update loop

#

but you will not see them in entity debugger ๐Ÿ˜…

naive parrot
#

yea thats what has been bugging me now!

#

is that intentional ?

warped trail
#

i don't know

#

there are rumors that we will get new entity debugger Soonโ„ข

mint iron
#

you can create world and systems without hooking them to unity's default update loop super useful for writing tests.

naive parrot
#

entity debugger is also throwing all kinds of nativearray and rendertexture memory leak exceptions on script recompile! ๐Ÿ˜…

loud matrix
#

I'm stumped, Does anyone know why this would not work?

Entities
    .ForEach((ref Rotation rotation, in PlayerControl playerControl) =>
    {
        if (!playerControl.Value)
        {
            return;
        }

        if (pitch > 0)
        {
            rotation.Value = math.mul(
                math.normalize(rotation.Value),
                quaternion.AxisAngle(math.up(), 50f * deltaTime)
            );
        }
    })
    .Schedule();

If i try and apply pitch my rotation is set to NaN and the test cube I'm working on vanishes. I logged the value of math.normalize(rotation.Value) on load and that returns NaN but just logging rotation.Value.ToString() returns the expected quaternion containing 0f

safe lintel
#

given normalizesafe a try?

loud matrix
#

I hate my life

#

I couldn't find it in the docs and the only reference i found to the issue was someone saying to use math.safeNormalize

#

Thank you

#

I must be looking at the wrong documentation as I still can't see it even knowing its real name.

mint iron
loud matrix
#

Cool, I'll have to have a look

glad condor
#

How complete would be dots netcode as of now?

glad condor
#

anyone who has used it for a game?

remote coyote
#

you can certainly build games with it, but I'm sure it will improve with time

#

but I'd say its rather advanced/complex to use still

glad condor
#

I tried a week back I think and the copy pasted code from the documentation site even had errors ๐Ÿ˜…

#

but I'd say its rather advanced/complex to use still
Yea..

warped trail
#

yeah it is funny that they don't fix Getting Started code ๐Ÿ˜…

amber flicker
#

It's a test ๐Ÿ˜†

gusty comet
#

I'm trying to get subscenes working - I had a scene with a bunch of debug cubes with rigidbodies/colliders that worked all nicely, however if they're moved to a subscene they become completely passthrough and no longer fall

#

can you even use "regular" physics and monobehaviours with subscenes or does it require you to go all-in on ecs?

coarse turtle
#

it should be the latter - since they're live converted to its entity formats (I'm sure that the MonoBehaviour components will not carry over and are stripped)

gusty comet
#

oh that's a shame

#

thanks @coarse turtle

stone osprey
#

Is there a way to download the "Entities" package from a website ? My package manager is buged... it only shows me v. 0.0.12 and i cant even download that one due to a error

bright sentinel
#

That really shouldn't happen. Try closing your project, delete the Library folder and reopen it, see if that fixes it

#

You might also be able to just manually edit the package.json file

#

manifest.json*

stone osprey
#

I regenerated the libs 2 days ago... they are "completly" new :/ where do find that manifest.json ?

coarse turtle
#

YourProject/Packages/manifest.json

stone osprey
#

Alright thanks, just added com.unity.entities@0.8 by myself... the editor is working on something... excited for the result

#

Damn... he tells me that it cant connect to "staging-packages.unity.com", havent a firewall up and also no proxy... i can load other packets easily

#

Whats your registry in the manifest.json ?

mint iron
#

what editor version are you using?

stone osprey
#

2019.3.7f

bright sentinel
stone osprey
#

A huge json file

bright sentinel
#

Okay, so your package manager might be trying to connect to an old URL

stone osprey
#

Oh wait... proberly if we remove the "staging"...

bright sentinel
#

Not sure where to fix it, but I'd bet to just delete the whole Library folder again

#

Also, does your manifest.json have a registry specified?

stone osprey
#

@bright sentinel "staging-packet.unity.com"... i removed the staging part due to the url you posted above... im gonna look what happens ๐Ÿ™‚

thorny vault
bright sentinel
#

@stone osprey Not sure why it would have that in the first place? But that's probably why

warped trail
#

@thorny vault have you figured out how to use CurrentSimulatedPosition and CurrentSimulatedRotation for interpolation?๐Ÿค”

stone osprey
#

Thereeee we gooo ๐Ÿ˜„ Thanks a lot ! Its working now... would have taken years to figure this out without that url above @bright sentinel thanks !

bright sentinel
#

@stone osprey Yeah, you shouldn't have to change the registry unless you're running some very custom package solution

stone osprey
#

I actually didnt changed it, but i migrated from 2018 to 2019, that probably broke the package manager ^^

bright sentinel
#

Maybe, but even then, staging was the old way of doing preview stuff

#

So maybe you did it in the past

#

ยฏ_(ใƒ„)_/ยฏ

stone osprey
#

Really strange :/

thorny vault
#

@warped trail I haven't looked at it yet. I have a client and server connected and passing RPCs. Hoping to get into ghosts more sometime this week.

bright sentinel
#

Are there any examples of RPCs? The docs are... Lacking

loud matrix
#

Is it possible to directly store a reference in one entity to another? Or rather, is it right to?
I'm setting up a simple camera follow system and want to be able to change what the camera is following (or setup multiple camera following different entities).

bright sentinel
#

@loud matrix Yes, that's a decent solution. Components can store Entity references that you can then use GetComponent<T>(Entity) to get the specific component

#

E.g. translation

#

You could also invert the concept, and have a system that queries the object you want to follow, which sets a component for the camera to grab direectly

thorny vault
#

'getting-started.html' does cover them. The way they work seems to be:

  • On the client side, you create an entity and attach your RPC to it as a component
  • A system on the client side deletes it and replicates it on the server side
  • A system on the server side matches on the RPC, acts on it, and deletes it

I guess its a little less RPC and a little more 'just sending a message'.

bright sentinel
#

The question is just where you read and write

#

@thorny vault Well they do, but not in great depth, and there isn't really an example

#

I just wanted to know whether there are any examples that uses them

warped trail
#

GoInGameRequest is an example๐Ÿค”

bright sentinel
#

Oh really?

fallow mason
#

inherits from IRpcCommand

bright sentinel
#

Oh

#

๐Ÿคฆโ€โ™‚๏ธ

#

That's what I get for blindly following the tutorial without thinking about it

warped trail
#

blindly following the tutorial will get you an error ๐Ÿ˜‚

bright sentinel
#

Ah yeah, I at least fixed that

stone osprey
#

Oh well... so i just installed entities 0.8.0, updated the other required packages... and the editor shows me about 199 errors in all kind of folders

naive parrot
#

is it possible to access a chunk component in Entities.ForEach ?

#

Oh well... so i just installed entities 0.8.0, updated the other required packages... and the editor shows me about 199 errors in all kind of folders
@stone osprey i was going through this hell like a day back. what helped me was downgrading to collections 0.6 from latest 0.7

#

then restarting the editor and , letting everything compile then upgrade back to latest

#

its weirds as hell but that worked for me.

bright sentinel
#

"Note: Currently, you cannot pass chunk components to the Entities.ForEach lambda function."

stone osprey
naive parrot
#

so the option is to use IJobChunk and iterate over each enitity ? @bright sentinel

bright sentinel
#

@naive parrot Probably yea

#

@stone osprey Those looks like you have some dependency problems. First check the package manager to see if there are any errors in resolving. After that, delete the PackageCache to make sure they get updated

naive parrot
#

@stone osprey lots of things went haywire for me. multiple inbuilt packages had gone missing due to compile errors. looks similar to what i had , not exact though

#

someone had mentioned the order in which packages are installed matters. this leads lots of dependency based issues i think

#

entitites package has tons of dependencies

#

and is most susceptible to this order based issue

mint iron
#

make sure you have the latest burst and collections, they werent listed properly on the 0.8 dependencies, but you need to upgrade them.

stone osprey
#

Thanks ! Im gonna try to delete the cache first :/ if that does not help, im gonna try that downgrade

naive parrot
#

this seems to common now moving from 2018 to 2019 and using entities package ๐Ÿค”

stone osprey
#

So deleting the cache did not work

#

One more error

#

200 instead of 199

mint iron
#

got 199 problems but the cache aint one.

stone osprey
#

collection downgrade to 0.5.2 brought me back to 196 errors

thorny vault
naive parrot
#

@stone osprey are you using vscode ?

bright sentinel
#

Ah, thanks @thorny vault

stone osprey
#

Nope, editor shows me those 196 errors in the entities 0.8.0 version due to the dependencies :/

naive parrot
#

no i mean vscode plugin

#

from package manager

stone osprey
#

Nope, im not using this, why ?

#

So where the hell does IVisitAdapter come from ? That damn interface is causing 50 errors on its own

warped trail
#

update collections ๐Ÿ˜…

#

or jobs

#

or burst

#

๐Ÿ˜•

stone osprey
#

i just downgraded the collections... damn, thats a real dependency hell... 0.8.0 has real struggles

#

Platforms downgrade brought me down to 19 left errors

warped trail
#

can't they just release small fix?๐Ÿค”

stone osprey
#

No idea... gonna update collections now to 0.7

#

4 left errors

#

NativeList, CollectionHelper are missing

#

3 errors on version 0.6

#

UnsafeHashMap is missing

#

and NativeHashMap

warped trail
#

or is it like, this package is in preview anyway, so who cares about user experience? ๐Ÿ˜…

fallow zealot
#

hi everyone, i am wondering, is dot will give us the ability to have better graphics in our games (higher polycounts for 3d models, higher textures resolution etc ) or it is mostly more effective with a huge count of entities ?

stone osprey
#

0.7 preview 2 on collection works

#

now theres other stuff missing

#

CompilerServices

naive parrot
#

you need latest Burst package @stone osprey

#

for that

stone osprey
#

@naive parrot Thanks ! Wait... gonna try that out ๐Ÿ™‚

#

Perfect, that worked ๐Ÿ˜„

#

two errors left xD but not from burst

#

Anyone here knows why it tells me that "SceneSystem" is missing stuff ? Thats one error

#

And bootstrapfilepath is the other error

naive parrot
#

@fallow zealot DOTS will let you right CPU friendly code but its not a magic pill solution for better gfx out of the box. its upto you as developer to manager the resources efficiently on your target platforms and make the most out of it.

dull copper
#

@fallow zealot it'll not let you fix any of the things that are already gpu bound

#

so no, you can't render higher poly meshes with help of DOTS

naive parrot
#

DOTS is about scalability. hence most of its showcase is usually about tons of identical entities. but it has more passive advantages like lower power consumption , better thermal efficieny on mobile devices , when utilized correctly. @fallow zealot

fallow zealot
#

@naive parrot thank you for the answer. I mean i know that, but what is your thoughts about that, do you think, someone with enought skill and using DOTS can have better performance than an other one using monobehaviour ? When it will be released of course

#

on the graphics side

dull copper
#

easiest use case where you can see the difference is some brute force simulation

#

but most games we see today don't really care much either way

#

I guess doing large streaming worlds will get easier with DOTS eventually

fallow zealot
#

fair enough. So it is mostly for that

naive parrot
#

its a subjective thing. with right effort you can achieve performant results even without DOTS. DOD ( Data Oriented Design ) is what drives DOTS technologies. GPU/Shader pipelines are purely data driven , data oriented. you can achieve same or better performance or scalability for a classical simulation even today using compute shaders for eg.

#

GPU excels at DOD by default. DOTS lets u aim for that level of efficieny on CPU

fallow zealot
#

very clear opinion you give me, and i understand better now

#

and we actually don't exactly the ffuture of it i think, it will depend on Unity adding the right tools for that and developpers to use it properly

stone osprey
#

Sooo... i heard that modifications in the package code are getting reverted each editor restart ? Anything to make sure that modifications of that package code doesnt reset ?

naive parrot
#

out of the box if DOTS brings us Culling ( Frustum , Occlusion ) and LOD calculation today , then sure i think by default we might get 'better' GFX for CPU based rendering task. @fallow zealot i am not fully aware if DOTS based culling & lods are here yet. @dull copper might know better about up and coming stuff ๐Ÿ˜…

mint iron
#

@stone osprey if you want to edit a package you have to copy it into the /packages/ folder, Unity wil then detect its in 'edit mode' and it starts showing up in your VS solution, and is flagged as such int he package manager (and it deletes the package copy from the library)

dull copper
#

occlusion culling support is coming to Hybrid Renderer v2 afaik

#

but I wouldn't expect it to dramatically change things here

naive parrot
#

yea thats what i was wondering. hybrid renderer..

dull copper
#

there's already such tech without dots

#

same with lods

vagrant surge
#

@naive parrot next gen consoles wont do culling and lods on cpu

#

but on gpu

#

(for some cases)

#

like batching but on crack, with culling

naive parrot
#

GPU Instancer on asset store does this i think. Culling on GPU

dull copper
#

you mean those mesh shaders now?

naive parrot
#

RTX intensifies.

dull copper
#

I loved the culling samples they showed on DX12 ultimate stream

vagrant surge
#

thats something ive done myself

dull copper
#

could cull stuff by vertices basically

vagrant surge
#

on opengl

dull copper
#

never render anything extra

vagrant surge
#

indeed

#

but its not generally worth it to cull by verts

#

the guy himself talks that at absolute best you would just be at same speed as th hardware

#

unless you are doing fancy things of course

vagrant surge
#

@naive parrot much stronger than that

naive parrot
#

i see

vagrant surge
#

@naive parrot usually those techniques need dual-dispatch

#

so one shader does the culling, and then cpu reads results a couple frames later

#

or one shader does the culling, and then you use draw-indirect to do it on the same frame (harder, cpu cant see it)

#

mesh shaders are about doing culling with normal drawcalls

#

instead of having a vertex shader, you have a mesh shader, which is a compute shader that can emit triangles

#

so you can do your cull test there, and just "not emit" triangles

obtuse swallow
#

Is there a way to pass a NativeContainer to an Entities.ForEach job?

vagrant surge
#

you can also select which mesh you output by distance (lod)

naive parrot
#

@vagrant surge read about mesh shaders on RTX overview page

#

but thats about it.

vagrant surge
#

next gen consoles have them

#

both of them

#

xbox uses the ones in DX12

craggy orbit
#

im going to assume the answer is "no" based on what i've seen first-hand, but does the Hybrid Renderer (v1) support Texture2DArrays in a Shader Graph?

naive parrot
#

can we do mesh shaders in unity ?

craggy orbit
#

vertex shaders? yes

naive parrot
#

no mesh shaders

vagrant surge
#

no, you cant

craggy orbit
#

oh it's new tech. gotcha

vagrant surge
#

also not in unreal

#

but both of them likely already have them, on their top-secret forks where porting to next gen consoles happens

naive parrot
#

kind of expected i must say. if unity/unreal arent keeping up with bleeding edge gfx tech then who will ๐Ÿ˜…

zenith wyvern
#

Is there a way to pass a NativeContainer to an Entities.ForEach job?
@obtuse swallow

You just assign it to a local variable before the job and pass the local variable in

warped trail
#

the ones who makes exclusives for Microsoft and Sony ๐Ÿ˜…

#

can't wait for another season of fake gameplay trailers for new generation of consoles๐Ÿ˜…

vagrant surge
#

the new generation is stronger than 99% of gaming pcs

#

by steam hardware survey

#

to that, add the "good ol console optimization"

#

PCs are kinda left in the dust for a year or two until we overtake consoles as usual

#

as an example, at the moment its literally impossible to get the level of disk speed (ssd) that consoles have, on PC

#

the only way to reach such speeds is on custom build datacenter tier hardware

#

gpus are about 2070-2080 RTX level

#

cpu is basically a underclocked 8-core ryzen

#

why do you think stuff like blob assets and subscenes are being developed

stone osprey
#

Need one more time your help... I fixed that SceneSystem error and now im getting 81 more errors because SampleGroupDefinition wasnt found in Performance package... any idea what version fixes this ?

vagrant surge
#

the new generation has such stupid fast SSD that if you have to process the loaded data, you will bottleneck on cpu

stone osprey
#

Is that performance package even part of dots รŸ

#

?

naive parrot
#

@vagrant surge there is also apparent shift from offline baked "static" data like lightmaps , navmesh etc. Joacim has mentioned along these lines on forum. everything is going closer to full realtime. i watched HZD GDC talks about procedural placement tech. entire terrain is literally populated on runtime. i think loading times have been serious issue on current gen. even Insomniac one of the GDC talk on spiderman mentions about moving away from disk stored data and calcuating lots of the stuff on the fly

vagrant surge
#

the thing with HZD procedural placement, is that its such a huge amount of data that you cant do it static

stone osprey
vagrant surge
#

its just too much grass

#

the space taken by that would be really huge

#

thats a weakness unreal engine has, it actually does store the vegetation instances (except little grass, which is procedural)

naive parrot
#

vegetation studio pro has been great solution to this. its basically the proecdural placement tech from HZD

vagrant surge
#

its not really that hard to implement

naive parrot
#

and allows for both runtime and baked instances

vagrant surge
#

ive thought of making a cpu based impl myself

naive parrot
#

yea its quite straightforward. but to have fullblown solution what all major minor requirements as small team is sure resource intensive

vagrant surge
#

btw, mesh shaders make this sort of stuff even more powerful

#

because you can do the placement and the rendering at once from the same shaders, bypassing a lot of temporal memory

naive parrot
#

did you give it a go already?

vagrant surge
#

yes

#

but that was mostly my mesh shader experiments to begin with

#

spamming a lot of rng gpu generated stuff, and rendering it, at once

naive parrot
#

where did you get started ?

#

some general resources ?

vagrant surge
#

opengl and documentation, the couple pages from nvidia

#

and reading the extensions

naive parrot
#

i have been going through nvidia pages myself

vagrant surge
#

but opengl mesh shaders, while they are very easy to use (vs the bullshit on vulkan), you cant use a debugger

naive parrot
#

might delve deeper into in leisure , fascinating stuff

#

you mean stuff like RenderDoc wont work?

vagrant surge
#

nope

loud matrix
#

Is it possible to get an entity by name? The only way I can see to get a specific entity is to give it a unique component data and query that.

vagrant surge
#

absolutely nothing will work

#

not renderdoc, not nsight

#

and btw, because on both of them its completly unrecognized commands, the entire debugger wont work

stone osprey
#

Im still struggling with the dots import

mint iron
#

upgrade test framework package perhaps and make sure you also have the performance test package. If you have a unity package in your /packages/ then it will introduce additional dependencies.

naive parrot
#

welp , then what gives? you just go on wits and whims ? trial and error ? @vagrant surge

vagrant surge
#

yup

#

thats why i only did some very basic stuff with them