#archived-dots

1 messages · Page 146 of 1

analog horizon
#

Oh shoot wait I totally forgot that its all open to us

#

Hehe time to get stealing I suppose!

#

I think this should work, if I get stuck can I ping you?

ocean tundra
#

sure

mystic mountain
ocean tundra
#

@mystic mountain are you using NetCode?

mystic mountain
#

Yes

ocean tundra
#

i saw something about a max size for packets/rpcs somewhere

#

that would be my guess

#

but im not using NetCode and havnt seen anything else that could give any hints

#

it might have been related to the number of rpcs... but i could me making things up :/

mystic mountain
#

Hmm ok, I pinned down it to come from send system, but you might be right, I wonder what is causing it though, because I'm not really sending much.

ocean tundra
#

lots of RPCS? or maybe lots of data

mystic mountain
#

Not really... I haven't even connected yet.

ocean tundra
#

@mystic mountain maybe its building up a buffer of data for some reason, but cant send it as its not connected?

mystic mountain
#

Can't tell yet. I've pinned it down to be from my CharacterGhost by disabling it in the collection. But I don't even get into the OnUpdate of the SendSystem, so I'm a bit confused x)

mystic mountain
leaden hatch
#

in unity's guide for using entities.foreach they give an example of modifying a native array in entities.foreach and then reading the array in a job.with code. surely you'd have to pass the entities.foreach's job handle into the job.withcode for this work?

private EntityQuery query;
protected override void OnUpdate()
{
    int dataCount = query.CalculateEntityCount();
    NativeArray<float> dataSquared
        = new NativeArray<float>(dataCount, Allocator.Temp);
    Entities
        .WithStoreEntityQueryInField(ref query)
        .ForEach((int entityInQueryIndex, in Data data) =>
        {
            dataSquared[entityInQueryIndex] = data.Value * data.Value;
        })
        .ScheduleParallel();

    Job
        .WithCode(() =>
    {
        //Use dataSquared array...
        var v = dataSquared[dataSquared.Length - 1];
    })
        .WithDeallocateOnJobCompletion(dataSquared)
        .Schedule();
}
mystic mountain
#

Ok, so removing the duplicates of ComponentDataFromEntity<AbilityStateData> solved it for now.

leaden hatch
#

it says in the job dependencies section: "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"

#

dunno if ithis is a mistake or I'm misunderstanding job handles

storm ravine
#

@leaden hatch It's in SystemBase?

#

If yes - SystemBase track it automatically. It has Dependency property and if you not specify different behaviour, it will put all ForEach\WithCode in dependency chain

leaden hatch
#

so they will depend on each other in order top to bottom if you dont specify a dependency? @storm ravine

storm ravine
#

Yes

leaden hatch
#

Ok thankyou

sour ravine
#

is it too late to float the idea that implicit dependency management is a really, really bad idea

#

considering the frequency of this particular question

stiff skiff
#

Yeah I'm not a fan of all the hand holding

#

I rather have to do it myself, and have tools to help me understand it, and debug any issues

sour ravine
#

crap like this is why statics are such a problem too

stiff skiff
#

I'm not a fan of all the recently added "Magic"

#

For example, trying to use a NativeQueue<T>.ParallelWriter in a job, and using the WithDeallocateAfterJob thingy.

#

Only to have it complain that you aren't using the thing you're trying to deallocate. Even though the use case is fine, and it will work fine, but the "magic" wont let me

viral sonnet
#

anyone familiar with a custom ComponentSystemGroup used for command buffers? it's slow and I'm not sure why

opaque ledge
#

So i am getting error about native list being disposed

#
        Debug.Log(attackerFleet.Length);
        Debug.Log(defenderFleet.Length);
        Debug.Log(currentFightStatistics.attackerShipsStart.Length);
        Debug.Log(currentFightStatistics.defenderShipsStart.Length);

        currentFightStatistics.attackerShipsStart.AddRange(attackerFleet);
        currentFightStatistics.defenderShipsStart.AddRange(defenderFleet);
#

Debug.Logs works fine but at first AddRange it gives that error

#

These are being called from monobehaviour

#

all of them are native lists

mint iron
#

must be being disposed elsewhere, the logs reading the length wouldnt trigger the error since its just reading a field.

humble falcon
#

Hi guys. Have you ever encountered flickering problem in dots. I have a very strange problem. Up until now everything is working fine. I did than only change the texture size and suddenly the entities are still being rendered but it flickers. So I went back to an older version, where I have not done any changes at all, but the flickering problem remains... Any ideas?

opaque ledge
#

okay so, instead of Temp allocation i did Persistent and dispose them later on

storm ravine
#

Hi guys. Have you ever encountered flickering problem in dots. I have a very strange problem. Up until now everything is working fine. I did than only change the texture size and suddenly the entities are still being rendered but it flickers. So I went back to an older version, where I have not done any changes at all, but the flickering problem remains... Any ideas?
@humble falcon explain further, what flickering? Rendering itself or shadows or something else?

safe lintel
#

ah new packages!

deft stump
#

an update?

#

to the docs!

safe lintel
#

not the biggest of updates(notes dont appear online yet)

## [0.11.0] - 2020-05-25

### Added

* Added `ArchetypeChunkComponentObjects<T>.Length`

### Changed

* Updated package `com.unity.burst` to version `1.3.0-preview.12`.
* Improved `ComponentType.ToString` names in DOTS Runtime to provide the full type name when available, and if not, default to the StableTypeHash.
* Updated minimum Unity Editor version to 2019.3.12f1 (84b23722532d)
* `EntityManager.Version` and `EntityManager.GlobalSystemVersion` will throw if the manager is not valid instead of returning 0.

also new hybrid package

#

i wont spam chat further than that more notes under deprecated, removed and fixed

deft stump
#

hrmmmmmm let's see if they made any breaking changes

#

me: making an actual game in dots.
also me: breaks my game because dots is still in preview. thus making dev time longer

safe lintel
#

ah hybrid is one of those updates 🙃


## [0.5.1] - 2020-05-25

### Changed

* Updated dependencies of this package.
* Updated minimum Unity Editor version to 2019.3.12f1 (84b23722532d)

deft stump
#

so it's just the entities package

viral sonnet
#

@safe lintel any link to the changes?

viral sonnet
#

thank you

amber flicker
#

‘Deprecated system sorting via virtual functions and direct modification of system list’ hmm

storm ravine
#

it will be replaced to better thing for bursted systems.

#

And as you can see [UpdateXXX] extended

amber flicker
#

I'm wondering what the implications are (if any) for creating system that run at edit-time without a subscene being open.

timber rivet
#

Is the performance in any way dependent on the order of shared component filters when I have multiple of them? For example, if I have an entity query and want to apply one filter that I expect to return most of my entities and a second that will only return a smaller fraction, should I expect a difference in performance based on which I do first or nah?

#

Or doe queries/filters not work like that at all

deft stump
#

supposedly, there shouldn't.
although doing a query within a query to get a subset from the first set is a code smell imo.
why can't you query the entities that you really want the first time?

timber rivet
#

There's no reason I can't, I suppose. I wasn't sure if SetFilter/WithSharedComponentFilter allow multiple arguments

storm ravine
#

supposedly, there shouldn't.
although doing a query within a query to get a subset from the first set is a code smell imo.
why can't you query the entities that you really want the first time?
@deft stump Not at all. It's absolutely valid, useful and recommended approach if your data divided by SCD. Moreover, you can't query by EntityQuery values with exact SCD. And this EQ can contain a different count of subsets which divided by SCD. The only way for that is SCD filter (or manual chunk iteration with SCD index).

deft stump
#

Oh so it's a valid approach.

storm ravine
#

@timber rivet why you decided order affect performance in your case? What profiler told you?

timber rivet
#

I haven't tried either way yet, I was just wondering as I'm figuring out how to iterate over these entities the way I want to

#

I have otherwise identical entities of which some need slightly different calculations, so I gave them a type component that differentiates them, and I'm also filtering so that only a fraction is updated every frame and each individual entity basically updates every N frames... but at that point, come to think of it, it's probably easier to just give them different components in the first place and have only one query filter each

dull copper
#

oh, full Burst 1.3.0 (no more preview)

opaque ledge
#

any new stuff ?

stiff skiff
#

What changed in the .12 patch that made it a requirement?

#

Is it the PerformanceTracker api?

storm ravine
#

Engine Internals. Also entities .11 is latest version which will officially support 2019.3 all next packages will require 2020.1+

low tangle
#

2020 bugs prevented me from updating awhile ago

storm ravine
#

Fine for us, using it from alpha releases.

low tangle
#

Yeah

stiff skiff
#

@zinc drift Where is that written?

#

Also, engine internals? But its a patch release?

storm ravine
#

@stiff skiff I guess this questions to me? 🙂

stiff skiff
#

.. I have no idea why it tagged wrongly, sorry

#

But yes, if you could

#

I've been trying to keep up with the entities stuff, but packages releases are not announced, bintray is no longer updated, and there is very little information about the future of the package. Which is making it very hard to work with

storm ravine
#

It's what guys from DOTS team told me (not only to me) about 2020.1. About .12 - patch also change internals and usually fix something (in this case it fix some issues which allow .11 use 2019.3.12 I guess)

stiff skiff
#

Is there a communication channel with this information that I could join?

storm ravine
#

Well, I was invited to Unity slack and got access to dots internal repo (but of course I can't and wouldn't speak about something in that repo because of NDA) because of my forum and beta test activity and our project, thus I don't know with whom you should speak about that, because I did not ask anyone. Mostly in that channels are influencers (YouTubers, ambassadors), Unity partners, and different studios.

knotty radish
#

Hey everyone, I was going to ask how to have a container that I can iterate on in order to remove duplicates but also use it as a Queue (order needs to be preserved) but then I saw this:

  • Added RemoveAt and RemoveRange to list containers in collections. These methods remove elements in a list container while preserving the order of the list. These methods are slower than RemoveSwapBack methods and as shuch, you should use RemoveSwapBack if you don't want to preserve the order inside *List container.
#

It was added today to the Collections package

stiff skiff
#

@storm ravine Thanks for the info. I'll just hope they make their public communication a little better in the future.

storm ravine
#

Well current communication good IMO. DOTS team very often check forum and answer the questions.

zinc drift
#

@stiff skiff I guess that question was not for me? 🙂

stiff skiff
#

Haha sorry, it seems @eize auto completes to you

#

@storm ravine Maybe, I'd still like to have a better way of following package updates then keeping an eye on the discord, of refreshing the package manager 😉

deft stump
#

Okay... I've been pulling my hair out... and I'm probably suffering some short sightedness right now.
So i'm trying to make make a grid movement system similar to megaman battle network in dots.
right now though, I've had the movement completely independent from the grid. (but i dont like this approach, since what if there's 1 cell that's missing? I'll simply float over it)
can someone suggest me another approach I can do?

pliant pike
#

I dont know if this would help @deft stump

deft stump
#

lemme see

#

oh

#

grid movement

#

I'll read about it and internalize it as i sleep

viral sonnet
timber rivet
#

@viral sonnet I got nothing but that does sound like your jobs are getting in one another's way. You could try handling the dependencies manually and see if that helps?

#

Speaking of grid movement, I have a large number of entities in an evenly spaced rectangular grid with known coordinates and another set of entities moving freely within that grid, so that whatever my moving entity's position is, I can calculate which four grid entities are closest to it just from its position relative to origin.
Is there a good way to get exactly those four grid entities out of a native array or something, if I want to be able to loop over my mobile entities in a job, get the closest four grid entities, and update the mobile entity based on those without having to iterate over all the grid entities?

ocean tundra
#

@timber rivet Grid map entities seem to be a very common thing, and there are a few different ways 😛

timber rivet
#

Like saying each "cell" of the grid bounded by four grid point entities is an entity itself? I was thinking of that, but having trouble figuring out how I get from there to the four entities that make up a cell

ocean tundra
#

My preferred way is using a native collection of some sort, native hash map can be <int3, entity> or even just a native array (you need a fixed world size) and you can take your int3 pos and do some maths (i can never remember this sorry) to turn a x,y,z into a index in the array

#

and build up that collection 1ce at start, and then perferably never change it

#

but theres tones of options

timber rivet
#

Native hash map, huh

#

I haven't looked into those yet, so I should

ocean tundra
#

each cell entity could have a buffer set at 4, with each index being a direction (0= north, 1 = left ect)

#

you could have a component actually instead of a buffer

mint iron
#

the map to array is to round the position to int coords

ocean tundra
#

@mint iron yup

#

need int pos's

timber rivet
#

Yeah, the math to get from world position to grid coordinates is easy, I already have that figured out

#

Just need to get from the grid coordinates to the entities

mint iron
#

if you're using int coords you'd want just a NativeArray<Entity> or struct with Entity + whatever else you need.? then you use the int as array index with map 2D or 3D >> 1D indexing. If you're using a hasmap your key could be anything.. but it will be slower than a direct access.

timber rivet
#

Fair enough, yeah, integer coords can map to just a single integer too. In fact I have a native array of the entities already when I instantiate them, but I'm not sure if it's possible to pass that array to a system that needs it?

mint iron
#

you can have a public member and save the system as a field, i mean its not great but its fast.

#

if you feel purest you can stuff it in a singleton entity as a dynamic buffer

#

and then retrieve it and reformat back into your array in whatever system needs it

timber rivet
#

Good point. I wasn't sure if it's possible to have an array of entities as a component value

#

If I did that, I could just make the entity, then in my job get that one entity and just grab the correct entities from the array in its component

#

Does it need to be a dynamic buffer even if I know I won't be adding or removing any entities?

mint iron
#

there's a few ways, you can use GetSingletonEntity<SomeTagComponent>() and then grab a dynamic buffer from it. or use a component with a pointer in it, or an UnsafeList etc.

#

the advantage of a dynamic buffer is that Unity will take care of deallocation.

timber rivet
#

ah

mint iron
#

you could just have whatever system that created it, dispose it in OnDisable() or whatever the method name is for systems.

#

i've found a cleaner way to do it, is to have a system that manages such data, it owns and destroys what its created, and then add an extension to world to make a class wrapper accessor for them. So like. World.GetOrCreateProvider<MyStuff>(); which returns a class storing a ptr or whatever exposing "Value" property for MyStuff. At least that is if you want to be passing custom native objects (databases etc) into burst jobs and share them between systems.

ocean tundra
#

@mint iron that sounds usefull, but you can share native containers already

#

but i guess thats a nicer API for it

#

rather then go GetExistingSystem.....().listofstuff??

mint iron
#

yeah pretty much; isolates it from the other things you might do with the system and is a little clearer on its intention, forces consistency when you have a lot of them to use the same interface.

ocean tundra
#

sounds useful

#

@mint iron would you mind sharing any of that? currently my "database" of reference stuff is a ugly scriptable object i inject into systems after loading

mint iron
#

sure, i can find it in an hour so when i get off work

ocean tundra
#

i want to clean it up lots but unsure exactly what to do with it

#

as i have tons of managed refereces to things (strings, unity game object prefabs (used during conversion then never again) references to other bits

timber rivet
#

That might be a bit overkill for my usecase where I only anticipate having to do this with this one grid, but maybe worth looking into anyway
https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/dynamic_buffers.html
So if I read this right, I would define my buffer value as public Entity gridEntity, rather than as an array of entities, and the InternalBufferCapacity needs to be set to... the number of entities in my grid?

mint iron
#

depends on how big your grid is, unity will try to keep the DynamicBuffer within the chunk until it exceeds InternalBufferCapacity, then it moves it to a new heap allocation. If you have a massive grid, you probably wouldn't want that in the chunk, especially if its just a singleton sitting in its own chunk - its not like you're gaining anything there.

timber rivet
#

It's going to be very big, which is a reason I want to go out of my way to just find the specific entities I'm looking for as much as possible

#

So if I set it to a number less than the number of entities in the grid, it will just allocate extra memory in different chunks and it won't make much of a difference?

ocean tundra
#

it effects performance

#

but thats such a tough thing to worry about so early

#

i think go with what ever gets you going quickly, and when you have more gameplay in watch the profiler for a bit

#

see if its actually causing issues

timber rivet
#

Fair

mint iron
#

it won't split it between chunks, its either inside or elsewhere in some malloc'd space.

#

dynamicBuffer just has a ptr in it, it goes either relative space within chunk or somewhere else entirely

timber rivet
#

The last thing I'm not clear on is how I set the individual buffers to my entities. I assume it's not with SetComponentData, since the buffer isn't a ComponentData. Do I just go like

Entity entity = entityArray[i];
MyBufferElement buffer = entityManager.AddBuffer<MyBufferElement>(bufferEntity);
buffer.gridEntity = entity;
ocean tundra
#

basicly

#

but its buffer.Add(new MyBufferElement...

timber rivet
#

ah

ocean tundra
#

you can also use dynamic buffers in the foreach

mint iron
#

or if you already have the data for some reason you can GetUnsafePtr and memcpy it

ocean tundra
#

how are people handeling prefabs these days?
Currently i have a bunch of addressables, i load them at runtime and then call GameObjectConversionUtility....
but i've learnt that thats not really a good idea, performance wise so im thinking some sort of sub scene prefab setup but have no idea

#

do i just dump all my prefabs into subscenes and then load those?

mint iron
#

i was doing something similar to you, addressables download, instantiate a GO, triggers a conversion, that conversion creates all the referenced entity prefabs. But it turned out to be a nightmare when instantiating parent/child setups that also needed to run conversion scripts, and we were told runtime conversion like that isn't supported.

ocean tundra
#

its not??

#

what have you done instead then?

mint iron
#

you can still use IConvertEntityToWhatever script, but it should be used within a SubScene. Better yet is to write a conversion system for your MB type (and use in SubScene).

#

But the catch is that many people have experienced a lot of bugs with working with SubScenes

ocean tundra
#

yup the one time i tried it i hated it

mint iron
ocean tundra
#

but also arnt subscenes for spawning things in directly, not prefabs

mint iron
#

no, a subscene is compiled into a big blob, so it can be efficiently put into a world, you don't spawn things into subscenes. Its like a container for stuff that needs to be converted and you want to load together. There is livelink but thats a whole nother thing.

ocean tundra
#

ok cool

#

so how to add prefabs into subscenes?

mint iron
#

drag the prefab into the subscene

ocean tundra
#

but that will spawn it when i load the subscene

mint iron
#

if you slap a Prefab component on it, then it disapears and becomes a prefab

#

hopefully they intend something easier to use than all these hacks lol

ocean tundra
#

hmm

#

looks like a good start

#

just need a new way to link my data to a entity

#

instead of a gameobject

timber rivet
#

So I've successfully made a buffer entity and added a dynamic buffer of all my grid entities to it and now I've got the buffer in my job like

                DynamicBuffer<GridBuffer> buffer = lookup[gridEntity];```If I'm reading the documentation right, now I just get the entities I want with `buffer[index].gridEntity`?
#

Looks like it

viral sonnet
#

Huh, my biggest optimization in DOTS now is creating different ComponentSystemGroups and updating them manually. Seems dependencies can go very very very wrong. I was hunting a performance problem and an unrelated system had a dependency on many other systems, forcing them to wait for completion and screwing scheduling totally up.

#

I'm still puzzled how this system ever entered the dependency chain of those other systems

#

since I've implemented the fast-forward feature it's clear that getting data isn't a trivial task and in most cases takes longer than the actual job itself. data layout, chunk utilization and occurance of structural changes is rarely talked about, but right now, it's more important than the code itself

mint iron
#

what i find amusing is 99% of my code runs faster with Run() or Jobs.WithCode, i dont even bother scheduling anymore, wouldn't even consider parallel unless i had a really good reason. The scheduling overhead is just too high.

north bay
#

Same, basically all my simulation code uses run. The overhead is very noticeable when you have to run the same system multiple times a frame, in my case mostly rollback/prediction.

#

And i try to structure my systems to be very small and have a distinct purpose which is not helping.

viral sonnet
#

yeah, same here .... Run > Schedule. quite a problem when the system is only operating on a few entities. what's funny is that ECS screams when you use an ECB and Run.

viral sonnet
#

Entities 0.11 throws an error in a build. Does anyone else have this problem? MethodAccessException: Method Unity.Jobs.IJobBurstScheduableExtensions+JobStruct21[Unity.Entities.EntityDataAccess+DestroyChunks].Initialize()' is inaccessible from method `__JobReflectionRegistrationOutput__2052323622..cctor()'
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_throw_method_access(intptr,intptr)
at __JobReflectionRegistrationOutput__2052323622..cctor () [0x00000] in <029ebe95a77f49b7900bcf94cb43398a>:0
Rethrow as TypeInitializationException: The type initializer for '__JobReflectionRegistrationOutput__2052323622' threw an exception.

#

don't upgrade to 0.11 yet - still works fine with 0.10

ocean tundra
#

@viral sonnet theres 0.11???

#

its only really bug fixes

#

i was hoping the component enableing stuff would be in this one

ocean tundra
#

Hi all, wheres the best place to have all my custom world and system creating (also includeds loading a bunch of data (json) loading subscenes and gameobjects) currenty its in a monobhaviour start method
Also I would prefer it if its bound to a scene but the more I research the more i think i cant

stiff skiff
#

It has lots of internal changes for some sort of struct based Systems

eager jungle
#

hey I noticed that doing GetEntityQuery(SomeComponent) in OnCreate of one system makes it run Update every frame no matter what. Is that expected behaviour?
(if there is at least one SomeComponent somewhere)

#

how does calling RequireForUpdate or not calling it is different?

wary anchor
#

how are you guys handling sounds within your ECS projects?

minor sapphire
#

is the entities package compatible with the 2020.1 beta?

#

can't find the package

deft stump
#

There's a new way to enable preview packages.
I think it's in project settings iirc. (my laptop is in the middle of a repair)

minor sapphire
#

oh right ok thanks I'll take a look

dull copper
#

they hid that on 2020.1 already?

#

I thought it was 2020.2 change only 🙂

#

but I admit I haven't used 2020.1 in a while

minor sapphire
#

Yeah I found it in project settings thanks 🙂

dull copper
#

I just use the search functionality on project settings for this

minor sapphire
#

How is .2 in alpha when .1 isn't even released haha

dull copper
#

I never remember where it is there

minor sapphire
#

the roadmap for .2 is just like "A new UI thing"

dull copper
#

just write "preview" on the search and it lists like 2 things

#

well, my logic is that 2020.1 is going to be unsupported once 2020.2 gets released, so it's existance is totally pointless, I couldn't care less of x.1 now

#

and 2020.2 will become 2020.3 LTS

#

I kinda feel that Unity did fail a bit on TECH releases, mainly because the support period is so tiny for anything but last tech release (and this year there's only two)

#

LTS thing is nice but with current model, it's the only actual "full" release

minor sapphire
#

.2 could get into beta while .1 is still in beta? 😄

dull copper
#

I expect 2020.1 to release soon

minor sapphire
#

I don't get it... but the roadmap for .2 had like nothing on it so what's in .2??

dull copper
#

for me, faster DX12 and most importantly rock solid deltatimes

#

right now the DT fix is only for DX11 but next alpha should support DX12 as well

pseudo pollen
#

similar what is in visual studio for prevew things

minor sapphire
#

hmm maybe I should skip .1, I'm trying to choose between them but the roadmap was missing all the info haha

dull copper
#

I don't even have 2020.1 installed here 😄

#

as for the roadmap, they mostly cover packages there and I don't think there's specifically that many new package related things for 2020.2

minor sapphire
#

how long is .1 expected to be released before .2 comes out

dull copper
#

like, sure, there will be improvements that only work on 2020.2 API, just like there are things for most Unity versions on currently evolving packages, but I can't remember any major thing

minor sapphire
#

I've never seen this kind of alpha/beta overlap before

dull copper
#

this years situation is new and it makes it harder to predict

minor sapphire
#

what is the latest unity presentation talk thing with ecs content?

#

I read they were going to be at GDC but pulled out

dull copper
#

like, they now removed one TECH stream, so there's only two TECH streams, which could mean they launch first one later or 2020.1 is just delayed because of covid-19

minor sapphire
#

hmm

dull copper
#

I'd expect 2020.2 to be out in fall/winter like 20xx.3 used to be

#

looking at last year, they really struggled to keep up with the releases on 3 TECH release setup, which I can imagine being partly a reason why they stripped one out

#

I personally feel they could just have gone with one tech release for whole year

#

current tech releases are problematic as many now just stick with 2018.2 and 2019.2 and get left out of all support

#

2018.2 -> 2018.3 update amount was absurd

#

many just had to skip it because the way prefabs changed

#

also PhysX 3.4 update brought some changes for physics side

minor sapphire
#

Well I'm downloading it now haha

dull copper
#

almost forgot... there's one major change on latest 2020.2 alpha: new splash screen (I dunno if they updated it to latest 2020.1 betas too)

minor sapphire
#

editor splash screen or build splash screen?

#

I saw a new editor splash screen, but I wouldn't consider that a feature haha

dull copper
#

editor

tame sigil
#

20.1 as a new one too

minor sapphire
#

yep they both have it

minor sapphire
#

I have a completely new project, just importing packages and already having trouble with versions lol. DOTS Editor is complaining when I import it

#

I figured they'd have a slightly better handle on packages by now 😄

odd cipher
#

So I'm creating 2 jobs per chunk generation, all 100 chunks are generated at once. thats 200 jobs, and I'm guessing creating that many jobs could become a problem?

graceful mason
#

I would think it could be

#

im doing similar, after all my equations and populating all my arrays and loading meshes, I think I can do 2-4 15x15x15 chunks per freame

odd cipher
#

Some of the jobs are being put on the Main Thread aswell

graceful mason
#

whjilst keeping like 600 fps or more

#

I spent a month messing with my code to get it all off that, thjink im nearly there but not yet 😄

#

Im also very slow and procrastinator master ;

odd cipher
#

Yeah.. my world generation takes around 26ms, a 200x200 world. 200 * 200 * 64 (2,560,000 pixels)

#

Its a 2D game

#

so its able to set 2,560.000 pixels in 26ms. Though before I added chunks it took around 13ms

graceful mason
#

Burst ParallellFor is insane if you can get it over to that, but it is taking me much longer than hoped for me to get fully into it. Hopefully I get my terrain rendering working finally today after far too long doing the wrong approach 😄

If its a onetime thing with known size, Id probs try to code a loading screen.

odd cipher
#

Yeah, I use Burst IJobParallelFor for all of my world generation.

graceful mason
#

creatring 200 jobs is no problem, you would see the bad FPS as they run or whatnot if you have issues. I creating 1000s of jobs 😄

#

well processing many thousands of entities etc through many systems, not sure if thats the same.

odd cipher
graceful mason
#

Ideas if it possible to simply disable a siystem inside its update? World.DestroySystem(this);

#

ah this.Enabled 😄

humble mason
#

I'm reading project tiny's documentation and it says there that project tiny is not using the "classic" unity runtime, which is able to run in hybrid mode, but the "new DOTS runtime" instead. Am I correct to understand from this that I cannot use UI elements in projects that use project tiny?

amber flicker
#

correct - at least that's my understanding

odd cipher
#

@graceful mason Hey, with your world generation do you have some sort of chunks system?

graceful mason
#

yeah

#

i tried doing it like 10 different ways, finally think i getting to one that works 😄

odd cipher
#

Did you have the tiles stored within the chunks or outside? I am having a little bit of problems about that

#

or do you have any at all

graceful mason
#

no idea 😄 I think as I store my "Terrain" in 15x15x15 chunks, I store it as ints in a buffer, and I preallocate 3375 for this buffer, thats in chunk. Then from that, I make the Verts, Tris and Uvs, which I store in buffers, which have preallocated [0] as I know i store more than the amount you can preallocate in them

odd cipher
#

Yeah our projects are quite different then. As you have to create a mesh and so on I have to create a texture

graceful mason
#

when i sdaid chunk then, i meant ECS chunk 😄

#

but yeah, all my terrain is also stored in chunks, 15x15x15, as a DynamicBuffer<>

odd cipher
#

Oh right. I meant like splitting the world into chunks (like minecraft) :p

graceful mason
#

yeah I do thjat

odd cipher
#

I don't use DOTS so havn't used DynamicBuffer

graceful mason
#

I see, yeah I use that, had a lot of issues as my Mesh needs to know about the neighbours chunks

#

but if that wasnt the case, ECS implementation would have been a breeze

odd cipher
#

same! that's what my current issue is :P

#

my chunk generation needs to know its neighbors, currently it doesnt

graceful mason
#

I think I solved that finally, writing my final code now 🙂

#

for me, as i request way more chunks than i can process at once (aiming for redicuoluos draw distance), I have a queue system, requested= 1024chunks, queued=10 chunks

odd cipher
#

the only way I have thought of is giving it the 8 surrounding chunks tile array and working with that but it seems kinda tedious.

graceful mason
#

It grabs a chunk from the queue, when it does this, iut also create the surrouinding chunks jobs

#

then I have systems to run jobs on all those entities

#

finally my mesh making system, can check each surrounding entity to see if the job on there is finished by seeing a tag value or similar

#

by checking each face, and looking in the hasmap

odd cipher
#

I've never used DOTS so it's quite confusing to me, but it's gonna be a bit simpler than yours since you have to deal with a third dimension :p

graceful mason
#

I create all entities in 1 system

#

then 2nd system, runs on an entity, and looks up the neuighbours

#

variablenames a bit mixed!

#

thenb i just lookup the neighbours buffers / comonents diurectly

safe lintel
#

has anyone used SerializeWorld successfully with Companion Gameobjects?

ocean tundra
#

Hi all, still not sure on loading/initialization code, I'm leaning towards having a Loading world which has a bunch of systems, it can setup all my other worlds, load prefabs,data ect into them
Is anyone doing anything similar?

graceful mason
#

just trying to get a reference to an entity created in a bufffer

ocean tundra
#

😛

#

i didnt read it all

#

but basicly you have a ecb and your creating a entity then wanting to save that entity?

graceful mason
#

yeah

ocean tundra
#

ecb = EntityCommandBuffer

#

cool

graceful mason
#

into a hasmap

ocean tundra
#

so basicly the entity that the ecb returns only exists with that ecb

graceful mason
#

yeah

#

I understamnd that, but i recreate my ecb each frame so no idea how that would work

ocean tundra
#

so what i do is add a new component to my entity

graceful mason
#

thats as far as i understand 😄

ocean tundra
#

then have another system that looks for that entity and adds it to my list

graceful mason
#

i see i think

#

thanks 😄

ocean tundra
#

hope it helps

graceful mason
#

they should really sort htis out 😄

#

got about 3 systems that exiust purely to tag data for other systems

#

and i still working on my 1st system

ocean tundra
#

i also have places where i have 1 existing entity and then spawn another that needs to reference eachother, but as long as i use the same ECB i can add components containing the temp entity and everything gets remapped fine

#

its a fixed limitation of the system i belive, no way to fix that if you want threading

#

what would be nice is a way to get the entity remapping data after the ecb has run

graceful mason
#

yeah

ocean tundra
#

then if you really need to you could manually remap any references you save

graceful mason
#

Im not sure if your way is better than my idea

#

my idea is, create a local var and store all my entities structures I want, adding to it inside inside a parallell for.... then just iterate that loop on main thread on entitity manager getting proper references. There just x,y, tag entities so should be light on main thread

ocean tundra
#

na def stay with ECB if you can

#

your way would create a sync point which reduces performance

#

for greater speed avoid using entity manager

#

🙂

graceful mason
#

ah cool, yeah i never understood how somehthing like that would work

#

but i guess it makes sense, it would sync poiint there, outside the existing ECB Buffersystems that are define

ocean tundra
#

yea that wont actually work

warm panther
#

Hey, I'm trying to run my own PhysicsStep, BuildPhysicsWorld etc systems, but for the entity conversion workflow, I would like to use the existing components (also to make porting changes in the future easier) - so I want the original systems to be inactive.

(end goal is to run multiple physics simulations at the time scale I want to simulate them at)

My idea is to have a trio of systems that (in various jobs) process a number of physics worlds, and a ComponentData (maybe SharedComponentData?) on the Entities contains an index or id, which world the entity is supposed to be Built into in BuildPhysicsWorlds.

ocean tundra
#

so the entities......forach..schedule wont run right then

#

it just gets scheduled

#

so then your foreach tries to run

warm panther
#

I'm currently beginning to port the existing unity systems, and I am wondering:

  • how do I prevent the original physics systems from running? They would still trigger for my entities, which only have an extra component..
ocean tundra
#

but the list will be empty as the entities foreach hasnt run yet

graceful mason
#

ok good to know. I understand your proposed method, so I can go with that 😄

ocean tundra
#

@warm panther find the existing systems with World.GetExistingSystem<TYPE>() and set Enabled to false

graceful mason
#

WorldEntityLoadingSystem worldentitysys = World.GetExistingSystem<WorldEntityLoadingSystem>();

ocean tundra
#

they are something like BuildPhysicsWorld

safe lintel
#

just do somehting like

var x = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<BuildPhysicsWorld>();
            x.Enabled = false;
warm panther
#

Ok, and where do I do that... in awake of a MBehaviour? In OnCreate of my system(s)?

safe lintel
#

wait do you not want the conversion to run or the actual systems at runtime?

warm panther
#

I want conversion to run, but I want to add an additional componentdata that contains a "world id", i.e. which physics world this entity should belong to.

#

So I'd keep all of the conversion code, but the old systems still pick up the entities of course, so I just need to disable them... I guess.

#

I've been considering multiple Worlds (as in ECS worlds), but that's not only more of a hassle, I want to seamlessly move entities between physics worlds. The way Unity Physics currently works, all I need to do is change a few chunk change detection jobs.

#

And of course schedule a job for each world in the Step and Build systems.

safe lintel
#

as to where you put it, id assume it would be fine in awake or start but could also be in oncreate in a system.

warm panther
#

I'll think about it. Probably oncreate is cleanest, because it's literally a replacement.

#
            var replaced_system = World.GetOrCreateSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
            replaced_system.Enabled = false;
#

kind of like this.

#

Ok, works.

#

Unfortunately, all the debug systems also have a hard dependency to BuildPhysicsWorld. Not a deal-breaker, but I had wished I could do without changing these.

safe lintel
#

take it to the forums, let them know its cramping your style 🙂

warm panther
#

hehe

safe lintel
#

i think the dots physics forums have like the highest amount of dev responses on any unity forum ive seen, its pretty cool

amber flicker
ocean tundra
#

Sweet, wonder if it works properly with custom worlds

amber flicker
#

To keep world information manageable, we have hidden the other worlds in the world dropdown list. To enable it again, we have added a setting to show all of the available worlds in the project in the Preferences window

ocean tundra
#

yup

#

i saw that

#

i was thinking more about custom worlds not showing any systems if your not using the default world update stuff

amber flicker
#

yea will check it out next time I open my project.. it's a start at least

#

hmm yea no idea about that - wouldn't be surprised if they didn't appear still

ocean tundra
#

probably

#

ill test it tonight and post a reply if it dosnt

dry dune
#

installing preview 7 🙂

ocean tundra
#

its super annoying

graceful mason
#

argh getting handle on entity from ecb is defo something they shoulda sorted out or at least include in the docs somehow 😄

#

I have your plan but I fked all my codes trying to implement, gonna take a few hours a bit later to resolve lol

ocean tundra
#

@graceful mason I assume some of your other systems are running on your new entities but as your native list isnt setup they are falling apart?

dry dune
#

updated and don't see new systems ui... wtf

ocean tundra
#

@dry dune they said it was under a different UI window

#

not part of the default one

dry dune
#

i don't see a button to open that new window

ocean tundra
#

“Window > DOTS > System Schedule” ??

dry dune
ocean tundra
#

:/

#

well thats a great start

#

restart unity i guess

dry dune
#

restarted

#

i'll restart one more time

#

nope no success... does it work for someone?

ocean tundra
#

i wont be able to try untill later tonight

graceful mason
#

well i tried to rejig it so my lists should all be setup, but i moved it into the next step of the process 😄

#

so the processChunk system, could also add it to a list

#

LoadChunkEntitySystem.JobData.chunkTerrainEntities_ is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.

#

Now I get that as im trying to edit my hashmap inside a paralell

#

so ill write the system properly like you said and it csan run on main thread single threaded

#

just to register the entities

graceful mason
#

but as it failed to write to the dictionary it made 100s of errors and looked scary 😄

dry dune
#

don't know what i did but is see Systems view now, but... not all my active systems listed there...

safe lintel
#

working for me

dry dune
#

what unitiy version you have?

safe lintel
#

i havent done any custom system scheduling on my project though

#

2020.2.a11

safe mica
#

Hello all. I'm just getting started with DOTS. I've got a bunch of Dynamic entites being created and once they settle, I want to turn off their physics step. Make them static or whatever it takes to make them not move and not slow the system down. So when I have 10,000 objects piled up, only the top thousand or so that are still moving matter. In my ChangeToStaticSystem, what Physics component am I looking for? I was looking for something easy like Physics.Type = PhysicsType.Static but I'm not finding it. - Should I just remove the Physics components?

ocean tundra
#

Probably PhsyicsVelocity being the main one

#

maybe mass too

#

oh yea just remove the components

#

in a upcomming update ive see some things about each component have a Enabled flag, but thats not here yet

safe mica
#

Ok thanks. Yeah, I didn't really think about just removing the components until I was typing it all our here. Discord is often my rubber ducky 🙂

ocean tundra
#

yea it works great as that

graceful mason
#

is storing 100 buffers with l;oads of data on 1 entity any worse/better, than making an entity for each?

ocean tundra
#

@graceful mason that is a super duper hard question to answer

#

my advice is to get it working whatever way you can and profile

#

everyones use case is unique

#

also you should look at native collections too

#

my understanding is there is still overhead with entities, so if making a minecraft clone 1 entity per block isnt recommened

safe mica
#

I'm having issues over here....
This method throws an error about "Must use .Run or .Schedule" after the Entities.ForEach. However .Run and .Schedule are not available with ComponentSystem. Also I know ComponentSystem is going away...

public class ChangeToStaticSystem : ComponentSystem
{
    protected override void OnUpdate()
    {
        Entities.ForEach(
            (Entity entity, ref SandPhysics sandPhysics, ref PhysicsCollider physics, ref PhysicsVelocity velocity) =>
            {
                {
                    PostUpdateCommands.RemoveComponent(entity, typeof(PhysicsVelocity));
                    //EntityManager.RemoveComponent(entity, typeof(PhysicsVelocity));
                };
            });
    }
}```
So I try with SystemBase instead, which doesn't have a "PostUpdateCommands" that I see...
```CSharp
using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using Unity.Physics;
using UnityEngine;

public class ChangeToStaticSystem : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach(
            (Entity entity, ref SandPhysics sandPhysics, ref PhysicsCollider physics, ref PhysicsVelocity velocity) =>
            {
                {
                    EntityManager.RemoveComponent(entity, typeof(PhysicsVelocity));
                };
            }).Run();
    }
}```
Doing it this way, Unity says I can't access EntityManager static like this, and I need to use .WithoutBurst and Run but I'm not sure how to do this. I'm just trying to remove a component. How should I be doing this? Thanks All if you can help!
coarse turtle
#

So with SystemBase what you want to use is an EntityCommandBuffer. In fact PostUpdateCommands is a command buffer in ComponentSystem

ocean tundra
#

Theres a few extra steps with SystemBase

safe mica
#

@ocean tundra con and @coarse turtle thanks. that link answers my question well I think.

#

I think a big part of my problem is google searches keep returning Unity Docs refs for older versions!

#

need to make sure I'm always looking at drop 6

ocean tundra
#

this will always take you to latest

feral canopy
#

If I use dots do I have to completely re-think my workflow or design?

ocean tundra
#

@feral canopy probably 😛

#

they are working hard on the workflow to keep it close to normal unity

safe mica
#

I did.. DOTS for me is crazy different. but I'm slowly getting it.

ocean tundra
#

at least in the editor

feral canopy
#

Should I wait for stable release then?

ocean tundra
#

depends on what you want to build

feral canopy
#

Dots will come in stable 2020 release right? Or is it mid?

ocean tundra
#

no clue

#

i think no

feral canopy
#

only looking for 2d. But want to use Dots for its entity system

#

alright gotcha

solar spire
#

I think it's unlikely it will be out of preview any time soon

feral canopy
#

does preview supersede experimental builds?

ocean tundra
#

DOTS core (Entities, Jobs, Burst) may become stable in the 2020.X lifecycle, but i expect 2021

#

and theres TONS of other bits that arnt done, Animations/Physics/any 2d stuff

feral canopy
#

alright ill explore dots on a mini game jam project. thanks for the insight!

ocean tundra
#

if you want to build something big then i recommned it, for a 2d project tho.. probably not

viral sonnet
#

man, it's frustrating when a ComponentSystem only needs half the time of the same system written in Systembase

ocean tundra
#

really??

#

that sucks

#

someone said something about the latest v11 containing some struct based System stuff

#

but def not ready yet

viral sonnet
#

yeah, you really have to pick and choose right now based on data and amount

ocean tundra
#

yup

viral sonnet
#

struct based system stuff? not sure what's that about

ocean tundra
#

I'm still very early, so still inplementing features and not worring too much about performance

#

so ive seen the unity dots team commenting on the performance of SystemBase, they are aware of it and are working on it. From what ive read they want to make SystemBase (or something really close to it) burst compatible

viral sonnet
#

yeah i know and sadly that's the state for a long time now. i waited a long time to rewrite to SystemBase and now it's still a mess. SystemBase, IJobChunk and all that is great when you have thousands of entities to process but with only a few entities, a simple ComponentSystem is still king and for some weird reason it's considered slow when in reality it's not.

ocean tundra
#

its tough

#

for me i dont need the performance yet, so hoping when i get most of my gameplay stuff in unity will have fixed system bases (as i already have sooooooo many)

#

like for every networked thing i have i need 7!! systems

#

and stupid generics dont work

viral sonnet
#

performance issues aside, ECS is pretty great.

ocean tundra
#

yea

#

loving it

#

some annoyances

#

like generices

#

but i worked around that with code gen

viral sonnet
#

wise thing to do. generics in the C# way don't really work

ocean tundra
#

yea i usually get too crazy with them and it all breaks down

#

code gen is still annoying but im building up more and more tools for it

#

will probably be easier in long run

viral sonnet
#

how do you use those?

ocean tundra
#

im using c# tt templates

#

i then pre process the template in rider (but vs should work)

#

and then the class it generated i call from a scriptable object, which makes another class

#

😛

#

the scriptable object is acting as a link to unity, so i can pass unity objects, and use the inspector

viral sonnet
#

cool, sounds pretty complex.

ocean tundra
#

the base setup was actually really easy

#

the annoying bit is when building you want to exclude all the tt and pre processed template files from the build

#

and the scriptable objects too

#

so needed to get tricky with asmdefs

#

which my project is awefully setup for

#

i really need to restructure it

#

@viral sonnet where do you have your setup/start logic?

viral sonnet
#

for ECS or in general?

ocean tundra
#

yea for ecs

viral sonnet
#

i've switched to a ICustomBootstrap recently.

ocean tundra
#

so i looked at that ages ago

#

that runs on a world creation?

viral sonnet
#

no, you create the worlds there, systems and groups

ocean tundra
#

oh thats much better

#

i thought it ran per world

viral sonnet
#

i can only recommend it except you'll never want to update systems manually

#

the most complex ICustomBootstrap is in the dots netcode

ocean tundra
#

yea i already have very complex startup logic

#

but its all in a monobehaviour start

#

ive disabled the default world

#

and create my own

#

and do a TON of stuff

#

i should take a look at the net code one

#

in a built game when does it run?

viral sonnet
#

before scene loading

ocean tundra
#

so before even a main menu?

viral sonnet
#

yep, pretty much the first thing that can happen ^^

ocean tundra
#

hmmm

#

thats not what i want

viral sonnet
#

ICustomBootstrap Initialize does that

ocean tundra
#

i need something on scene start

#

but ideally not a monobehaviour

viral sonnet
#

why not?

feral meteor
#

is DOTS worth converting my entire project to?

ocean tundra
#

i want to work to being Tiny compatible

#

but just for my server component

viral sonnet
#

oh i see

ocean tundra
#

so ideally my core startup not in a monobehaviour

viral sonnet
#

you can create an entity with some init comp

ocean tundra
#

actually,.. i think i could leave the start of it in a monobehavior which can call a static method to start the server stuff, as client will always need monobehaviours

#

and in a dedicated server have some sort of ICustomBootstrap which only exsits there

#

@feral meteor probably not, unless your project really needs it and even then just add it for some small bits
or your crazy like the rest of us

deft stump
#

so ideally my core startup not in a monobehaviour
There is a way... Lemme look at my repo...

ocean tundra
#

@viral sonnet yea that init entity start is something im going to convert too

#

i still need something outside the worlds, to create them and do a few things

#

but then i want as much of my loading code eaither in my main worlds or in a loading world

viral sonnet
#

any of you can build and play with newest entities 0.11? i'm getting core errors

ocean tundra
#

havnt updated yet

#

im still on 0.10

#

i always give it a few days to settle

viral sonnet
#

usually i migrate after the first week a new version releases

#

it's just, sometimes i hope unity does actual testing

ocean tundra
#

hahaha

viral sonnet
#

right 😄

#

1 minute of my sim gets computed in 336ms. i think i can rest now

ocean tundra
#

oh nice

#

whats your sim doing?

gusty comet
#

is dots physics deterministic?

deft stump
#

Is there a FixedUpdate() equivalent in Dots?

hollow sorrel
#

@gusty comet i haven't tested but i think they said it should be deterministic on same cpu architecture atm

#

different cpu architecture determinism depends on a future burst update

#

@deft stump by default simulationgroup and co runs on update but you can make your own systemgroup and check for update interval, or use FixedRateUtils to do it for you, or don't autoupdate world and update it yourself in fixedupdate

safe mica
#

Still very new to this. Appreciate all the help. My System isn't working quite right, and an error says I need to call JobHandle.Complete(). How do I get a jobHandle from my Entities.ForEach? ```CSharp
public class ChangeToStaticSystem : SystemBase
{
EndSimulationEntityCommandBufferSystem m_EndSimulationEcbSystem;

protected override void OnCreate()
{
    base.OnCreate();
    m_EndSimulationEcbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
}

  protected override void OnUpdate()
{
    var ecb = m_EndSimulationEcbSystem.CreateCommandBuffer().ToConcurrent();

       Entities.ForEach(
        (Entity entity, int entityInQueryIndex, ref SandPhysics sandPhysics, ref PhysicsCollider physics, ref PhysicsVelocity velocity) =>
        {
            {
                ecb.RemoveComponent(entityInQueryIndex, entity, typeof(PhysicsVelocity));
                Debug.Log("Removed");
            };
        }).Schedule();

}

}

ocean tundra
#

@safe mica reread that entity command buffer doc

#

theres a line at the end your missing, something like addproducer(Dependancy)

#

cant remember it exactly now

deft stump
#

@hollow sorrel so i have to make one myself. Gotcha

safe mica
#

Ahh I see it now. Thanks again Roycon

hollow sorrel
#

ye and it's weird because they've been saying simulation will be changed to run at fixedupdate by default since like a year ago

#

not sure why they haven't yet

#

lots of ppl complain about physics not running at fixed rate

#

by default

#

ohyea which reminds me making it run at fixed rate is required for determinism too @gusty comet

gusty comet
#

ok i'll look it up

#

thanks

safe mica
#

I made one step forward (thanks again Roycon) but now ran into another snag. I'm trying to update a RenderMesh.material.color inside a system. It's complaining at me that I can't do that... I assume this might be because all my entities share the same material? Is there an easy way to change the color/material of entities in a ForEach?

dry dune
#

you have to use MaterialColor component for that

safe mica
#

ahh ok. Thanks

dry dune
#

and make sure GPU instancing enabled for that maretial

ocean tundra
#

you need the hybrid renderer for that yes?

dry dune
#

yes

ocean tundra
#

V1 or V2?

dry dune
#

both

ocean tundra
#

oh sweet

#

i wasnt sure if it worked in both

dry dune
#

but you need latest preview version of it

safe mica
#

My last question for the night! - Burst error BC1025: Accessing the type `Unity.Physics.PhysicsVelocity` (e.g. using `typeof`) is not supported

...
ecb.RemoveComponent(entityInQueryIndex, entity, typeof(PhysicsVelocity));

Is there a way to make this work with Burst? Or what do I change to make this section not use Burst and get rid of the error?

ocean tundra
#

ecb.RemoveComponent<PhysicsVelocity>(entityInQueryIndex, entity);

#

GENERICS!!!

safe mica
#

awesome.

ocean tundra
#

i believe they are also faster then the type variants

#

tho not sure if thats still true in DOTS

full epoch
#

NetCode : when using Camera that follows spaceship i put it(system that controls camera) in GhostPredictionSystemGroup and also make it update after system that controls player ship update method executes - is this good practice and is there better way to do this and what that way should be? (for Camera i simply set up position and rotation from camera system(ComponentSystem update method) using Camera.main.transform.[position|rotation])

ocean tundra
#

Anyone know if we can put a subscene inside addresables?

dull copper
deft stump
#

I thought you cant do pr's?

#

Or rather, they wont accept pr's

storm ravine
#

This PR from Jussi, he's from Unity (HybridRenderer team)

warm panther
#

Is the "Chunk" in "IJobChunk" the same "Chunk" as in "ArchetypeChunk"?

#

If you know what I mean..?

storm ravine
#

Rizu just wanted to share it here in case someone interested in this fix i guess

#

Is the "Chunk" in "IJobChunk" the same "Chunk" as in "ArchetypeChunk"?
@warm panther IJobChunk has only ArchetypeChunk (And whole ECS data layout use ArchetypeChunks), idk which chunk you mean apart of ArchetypeChunk in this context

#

If your question is - "It's a chunk from core ECS data layout, where all data stores?", the answer is "Yes"

warm panther
#

Ok, so it's not another use of the Word.

#

So basically each IJobChunk works on one Chunk?

storm ravine
#

Which each?

#

Each Execute

#

Or each instance

#

Rephrase your question better 🙂 I can't understand what you want to ask 🙂

warm panther
#

The thing is, I don't understand how IJobChunk knows which entities it works on.

storm ravine
#

You pass EntityQuery as argument to IJobChunk schedule

warm panther
#

.Schedule seems to take an EntityQuery

#

ok.

storm ravine
#

And that entity query tell IJobChunk which chunks should be processed

warm panther
#

What happens when I do this:
job1.Schedule(eq);
eq.SetSharedComponentFilter(...);
job2.Schedule(eq);

storm ravine
#

And if you schedule 2 IJobChunk on same EQ (and use ACCT with write access or one read other write) and not chain them in dependency you'll get error about memory alliasing

warm panther
#

Well I need to schedule them on the same EQ but for a different sharedcomponentdata

#

("want" is better than need, I am trying to figure out a good architecture here)

#

I could just create an array of entity queries.

#

Ideally I would rather just do something like this (pseudocode):

foreach(sharedcomponentdataindex) schedule a job that works on my_datastructure[sharedcomponentdataindex.value]

#

(I have a sharedcomponentdata that contains a "world" id, and I want to simulate multiple physics worlds that all exist in the same ECS world, allowing entities to seamlessly move between the physics worlds by changing their sharedcomponentdata, instead of copying them to a different ECS world)

#

These changes happen occasionally only, but they do happen, and I don't want to build up, maintain, and tear down a new ECS world for every new physics world I create.

#

So I'm porting UnityPhysics's BuildPhysicsWorld, StepPhysicsWorld, ExportPhysicsWorld to operate on a $array_like_datastructure of PhysicsWorlds, instead of one.

#

Hmm I guess I will need to create a $array_like_datastructure of EntityQueries as well then, pity.

#

Probably the best approach is to fully encapsulate these systems into a facade that manages multiples of them. I just need to find a way how to have the jobs operate on the right entities. Ideally, I'd like to do this without "SetSharedComponentFilter", but as far as I understand only that has a limited overhead.

storm ravine
#

For me it's messy. Multiple worlds exist exact for this purpose of separation. You not "copy" to another world, you should "move" to another world, and cost of that moving the same as setting SCD, because it just change data location in chunks layout (memcpy to another archetype).

warm panther
#

Yeah.

#

But creating the separate systems is much more work.

#

The only advantage is that I don't have to keep my own fork of UnityPhysics.

storm ravine
#

Not at all. You have same systems.

#

This systems just run in different worlds

warm panther
#

But I need to keep like a dozen systems running in each world, selectively.

#

maybe I don't understand ECS worlds at all then.

#

(not just that, I need to manually chain the systems so they run in the right order in the new world)

#

(and I haven't been able to find a way to copy an entity from one world to another, or maintain a representation in both, etc)

storm ravine
#

They'll run in same order in all worlds and if you set order by attributes it will work in every world

warm panther
#

Hmm.

#

Where can I read up on this?

#

And how do I, for instance, enable or disable PresentationSystemgroup in one world specifically?

storm ravine
#

You don't need presentation in all worlds

#

It's pointless

warm panther
#

"They'll run in same order in all worlds and if you set order by attributes it will work in every world"

#

But you said the systems run in all worlds

storm ravine
#

You simulate in different worlds and presentation world just show every thing

#

But you said the systems run in all worlds
@warm panther read again what you quoted.

#

Same order not mean World will have all systems

#

If your worlds only have your simulation

#

this simulation will be in same order

warm panther
#

Hmm. So presentation world would require me, when I enter a different simulation semantically and want to present that, to clear every entity in the presentation world, and copy over the ones I want to show?

#

I was going for the multiple physicsWorlds approach also because I want to (probably) in the future use the ClientWorld and ServerWorld stuff that Netcode does.

If I have a dozen ClientWorlds and ServerWorlds, I think that adds a lot of complexity.

#

Not to mention "entities" (I mean systems) communicating across simulation worlds.

#

hmm I could run one big simulation world, but physicsworlds need to feed back into it.

storm ravine
#

Hmm. So presentation world would require me, when I enter a different simulation semantically and want to present that, to clear every entity in the presentation world, and copy over the ones I want to show?
@warm panther CopyAndReplaceEntitiesFrom.

warm panther
#

That sounds brutal. I literally need to move one entity between chunks usually.

#

which is why I was thinking sharedcomponentdata 🙂

#

"EntityManager.CopyAndReplaceEntitiesFrom has been added it can be used to store & restore a backup of the world for the purposes of general purpose simulation rollback."

#

Doesn't sound like that's what I want.

#

(unless I use that to make worlds go "live", but you haven't explained how I can make PresentationSystems only work in one world, and what happens to all my entities that don't belong to my simulated world)

#

Gameplay scenario: Floating Origin Space Game. Ship1 in PhysicsWorld1 sets a waypoint to Station2 in PhysicsWorld2, to get there, it needs to leave PW1, spend some time in an intermediate "travel" world, and then enter PW2.

storm ravine
#

You can have only one presentation world currently that's all 🙂 You have default world which responsible for presentation. And as many simulations as you want. This is what Unity physics does - they have separate simulation world and just synch states.

warm panther
#

"CopyAndReplaceEntitiesFrom" seems to replace all entities, but I would want to keep a lot of entities in my Default World which are unrelated to the Simulation Worlds.

storm ravine
#

You can copy them without replace

warm panther
#

And how do I get rid of the ones that need to go?

#

Big filter operation.

storm ravine
#

It was example of update whole presentation world from simulation

warm panther
#

Where I could literally be memcpying ONE entity and invalidate just two chunks worth of entities.

#

PhysicsWorld is not a World like DefaultWorld.

#

public struct PhysicsWorld : ICollidable, IDisposable

#

doesn't inherit from World

#

It's really just a crutch for the ISimulation

storm ravine
#

It's not matter World it or not, I describes approach. You can write your own world implementation. Point is behaviour.

#

What they do is working on slices of types.

#

You also can go that route

#

But result is the same - you move\copy data between worlds (no matter which worlds is)

warm panther
#

Well for that I first need to understand how to create my own world.

#

And see what the repercussions are.

#

EntityManager MoveEntitiesFrom just dumps out a world. I have no idea how, once they are in the DefaultWorld, they would go back.

#

Also, that would mean that in that other world, the entire PhysicsWorld would have all of its chunks changed.

#

That's pretty terrible.

#

It could work with just 2 changed chunks.

#

(I mean I dont have a lot of static colliders, though, and my physics worlds are spatially rather sparse, but there are usually thousands of entities in them, with hundreds of colliders)

storm ravine
#

MoveEntitiesFrom has many overloads

#

Include query filtering

warm panther
#

I see

#

Sorry, didn't use Rider right.

#

They show now. 🙂

storm ravine
#

Moreover you have all remapping information

warm panther
#

Ok saves me porting work, now I need to understand how to create and tear down my own worlds procedurally, and how to place entities there in the conversion workflow

#

I think I am just googling the wrong stuff

#

"unity create ecs world" gives me forum posts from 2018

storm ravine
#

Nothing changed long time it that area, most posts from 2018 still relevant (exclude renaming Active to DefaultGameObjectInjectionWorld).

#

In our case we using multiple worlds for EET and batch entities creating on worker thread. And process of creating and populating still the same. (exclude some simplifications in groups populating area)

warm panther
#

The multiple worlds thing you linked doesn't show how to instantiate a new world, typical of the current state of the documentation.

#

this might do the trick

#

but man is it clunky

storm ravine
#

Ah that youtube kids.... Read source code and docs.

#
{
    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;
    }
}```
warm panther
#

I mean the post that I linked there.

#

Not the video in the OP

#

🙂

#

So how do the presentation systems know they need to run in the presentation world, but not in the others?

#

"GetAllSystems" strikes me as, you know, All systems.

storm ravine
#

Creating world itself - just 1 row var world = new World("Custom world"); populating a bit harder because you should create systems from new world but put them to defauld world update list 🙂 If you want them update automatically and appear in entity debugger. But if you update them manually, well just create them in world

#

"GetAllSystems" strikes me as, you know, All systems.
@warm panther again you looking not to what you should look. It's code sample of your own "Default" worlds

warm panther
#

but that's exactly what I mean with "it's quite a bit of work to set up a new world and its systems"

storm ravine
#

Just adapt it for not default world

warm panther
#

(and by work I mean, memory allocations etc.)

#

I can cache a few pre-created worlds but... it feels off.

storm ravine
#

Which allocations?

#

You create wolds once

#

That's all

#

Of course world require some stuff for working, but cost - negligible

warm panther
#

like these.

#

in BuildPhysicsWorld system

#

I do not create worlds once.

#

I create them whenever I need a new physics bubble to be created.

#

That's the whole point of this exercise 😄

#

And I realized that I actually have a design requirement that says that two separate physics worlds need to coexist in the same presentation world. (I can maybe work around that, but my port of the physics system would do that seamlessly, at zero added cost)

#

oh no, wait....

storm ravine
#

It's already in same presentation and just different simulation, if you use that worlds just for simulation and default world for presentation FailFish

warm panther
#

how do I link the entities across worlds?

#

without copying over a few thousand entities every frame.

storm ravine
#

It copy at chunk level

warm panther
#

doesnt matter

#

(well it does)

storm ravine
#

DOES matter

warm panther
#

So I actually memcpy all my entities into the presentation world every time.

#

that sounds insane

#

how do I keep the presentation world from simulating my stuff?

#

the physics system by default is in the default world

#

and thats where I copy it from

#

(also, I wonder if that copy your code snippet shows actually creates a new instance of the system, or uses the same system and all its state across worlds - because the physics systems actually contain state)

storm ravine
#

System itself - unique per world it's whole point of worlds.

warm panther
#

k

full epoch
#

In ecs is it good idea to control camera from system class simply by assigning Camera.main.transform position&rotation without converting it(camera) to an entity(if that is currently possible)?

storm ravine
#

@full epoch well, caching Camera.main and using that camera for move\rotate in system that's fine. Yes you can convert camera to entity.

undone torrent
#

hi, where can i find systembase examples ?

#

i mean real code , not just simple examples

sudden comet
#

Is anyone has an idea on how to nest an Entities.ForEach into a static function in an Utilities static class to avoid code duplication ?
Since I change ComponentSystem to SystemBase, I cannot pass the Entities to my function anymore.
I used to do it like this

        public static Entity GetSelectedItem(EntityQueryBuilder entities, Entity playerEntity)
        {
            Entity selectedItemEntity = Entity.Null;
            
            entities.WithAll<SelectedItemComponent>().ForEach((Entity inventoryElementEntity, ref InventorySlotComponent inventorySlotComponent) =>
            {
                if (inventorySlotComponent._owner == playerEntity)
                {
                    selectedItemEntity = inventorySlotComponent._slotContentEntity;
                }
            });

            return selectedItemEntity;
        }
mint iron
#

@sudden comet you can create a wrapper system and put any Jobs.WithCode or Entities.ForEach in it. You can have it disabled on create but the code inside will be compiled and then you can just expose methods to call them.

dry dune
#

omg 😡
i've been rewriting my old huge generic job system from deprecated IJobForEach to IJobChunk
and found a strange bug that sometimes some parts of my code do not invoked as frequently as i expected, and it is took me 5hours to realize that i have return inside for loop where continue should be...

sudden comet
#

@sudden comet you can create a wrapper system and put any Jobs.WithCode or Entities.ForEach in it. You can have it disabled on create but the code inside will be compiled and then you can just expose methods to call them.
@mint iron it seems less elegant and feel it like a workaround, do you think it is the only way ?

coarse turtle
#

the Entities type is internal to the entities assembly in SystemBase iirc 🤔
You could try an assembly definition reference to Unity.Entities and try to create some public facing API

#

then you can try and pass that public facing API to your static function

mint iron
#

@sudden comet a better way would be to use burst functions or wrap IJob/IJobChunk for static methods, but im not aware of a good any way to manually create the magic code compilation that takes place by SystemBase for Entities.ForEach

sudden comet
#

Sure that looks like magic 🙂

#

Thanks for you suggestions

dry dune
#

I'm so happy that my Dots tweener works again
and i can animate any property of any component on any entity like this:
e.Tween<PosY>().FromTo( 0f, 1f ).Duration( 5000 ).Delay( 500 ).EaseInOut( 0.5f ).Loop().Start();

mint iron
amber flicker
#

@dry dune out of curiosity, i' m currently trying to disambiguate e.g. .Tween1().Tween2().Loop() (i.e. Tween2 loops) and (.Tween1().Tween2()).Loop() (i.e. the sequence of Tween1 & 2 loop) with my tween lib - have you encountered this?

dull copper
#

still nothing for crossplatform determinism

#

wonder if Unity wishes people forget about it if they don't mention it anymore anywhere

undone torrent
#

how can i get an scenesection from a scene ?

#

i mean i have to guess which entities have been created by certain subscene

#

an the way to get that is using scenesection

#

i suppose

dry dune
#

@amber flicker i'm doing it this way:

    e.Tween<PosY>().FromTo( 0f, 1f ).Duration( 500 ).EaseIn(),
    e.Tween<PosX>().By( 1f ).Duration( 200 ).EaseOut()
).Loop().Start();

also have a Parallel tween runner
and can combine them in any way
like: Sequence(Parallel(tween,tween), tween, Parallel(tween, tween))

dry dune
#

behind chain interface it creates an entity for each tween, and sequential/parallel sets sets are dynamic buffers, and a bunch of generic systems processes them, and after finishing animation all that can be destroyed

I ended up with chain interface for two reasons:

  • this is almost similar to what DoTween does
  • to construct all those entities by hands is a huge amount of boilerplate
graceful mason
#

is it possible to limit the amount of entitites inside a ForEach?

#

without manually queing them etc

bright sentinel
#

@graceful mason What's your use case? Why would you limit the amount?

hollow sorrel
#

still nothing for crossplatform determinism
@dull copper
they post about it on the forums from time to time so they're still working on it
but also they mentioned same cpu architecture already is deterministic across different OS, so 64bit linux to 64bit windows but not to 32bit
not sure how to interpret it though, does this mean ps4 and pc are already crossplatform deterministic?

#

also across different CPU
Burst does generate deterministic code for x86 between different AMD / INTEL machines.

#

. Unity.Physics is floating point deterministic on the same CPU architecture including between INTEL/AMD. Cross architecture float determinism is not yet supported.

#

afaik ps4 uses an amd cpu so would imagine it's crossplatform deterministic? but not sure

pliant pike
#

I'm presuming math.length is the same as Vector3.magnitude, right?

storm ravine
#

yes

pliant pike
#

cool, thanks 👍

ocean tundra
#

Hi all, I've been looking into subscenes to replace my runtime prefab conversion stuff but due to reasons i would like to convert the same gameobject in the subscene more then once. Anyone know if this is possiable?

dull copper
#

@hollow sorrel same platform means same compiler afaik

#

in this case anyway

#

meaning same windows binary should be deterministic across all hardware that can run that same exe

#

doing ps4, xbox etc require different build so they can't give you cross platform determinism

#

also, there are things on DOTS that are not deterministic

#

some of the collections are, some are not if I remember right

#

I suggested Unity to actually give user a warning if determinism mode for floats is being used and user tries to do something that is known to not be determnistic

#

Joe at least agreed to it on the forums so we'll see

#

IMO it's crucial for users to know if they happen to use something that's not determnistic when they think everything is when using DOTS and the determinism parameter

hollow sorrel
#

ah really? linux doesn't run same exe as windows tho and requires new build, but i think was said to be deterministic already (if same architecture)

#

and ps4 is x64 SSE4 and windows x64 SSE2/4, dunno if the SSE part matters

#

and yea i agree something like that is crucial, esp since it's pretty hard to test if your game is fully deterministic

ocean tundra
graceful mason
#

@bright sentinel just struggling to maintain FPS whilst processing really uninportant jobs :D. New plan is a simple system... it does X jobs at a time as background threads

#

before i was just trying to process them as Entity.ForEach which i guess is locked to frames

dry dune
#

@ocean tundra sounds like a prefab

pliant pike
#

I've got to stop using the Unity alpha versions they are really buggy and barely work at all leahYTHO

ocean tundra
#

sorry ignore my sub scene questions. i dont think ill use them.
My new question is around world serialzation.
If i have a hybrid prefab entity (Entity that has companion monobehaviours, unity engine components) and i serialize the world out, and reload it do those hybrid entities keep/recreate the gameobject/monobehaviour bits?

#

@dry dune yea all of this is for optimizing my prefab loading/conversion stuff

pliant pike
#

I just went into debug mode and I'm getting tons of errors saying it can't find any of the installed packages leahWTF

#

I try again and get a completely different error entities.dll failed leahYTHO

dull copper
#

@hollow sorrel I've seen these mentions but they are not very specific, I wouldn't draw that kind of conclusion myself from it

#

like, if it were 100% deterministic cross-platform on x64 cpus, it would cover most of the targets already except mobile

safe lintel
dull copper
#

basically.. it's not even worked at

#

there's nothing new there

ocean tundra
#

@safe lintel Bumbed it 🙂

dull copper
#

it's been on backburner for a long time now, feels like it's super low prio to Unity or they just don't want to address it yet

hollow sorrel
#

ahh didn't see that post

#

that's disappointing

dull copper
#

"maybe later this year" means definitely not this year

#

they had earlier targets like in few months

safe lintel
#

kinda wonder how much covid and wfh has hampered development

ocean tundra
#

@safe lintel From reading the docs it looks like we might be able to just serialize the list of gameobjects and just recreate them again

#

it will be a pain

dull copper
#

from what I've read on the forums, at least it's harder for them to test hardware specific things

#

I don't think the remote working itself will be a big issue

#

but like, people not having access to all test hw at homes is an issue

safe lintel
#

well in an ideal sense no, but if you got young(or old :D) kids etc at home, probably a less ideal work env than the office

#

@ocean tundra given how painless it is to serialize pure entities, im hoping unity have some tricks in store(probably wishful thinking though but who knows)

ocean tundra
#

agreed

viral sonnet
#

If I have a SystemBase with Run() it seems I can't use ECB. Anyone know how to circumvent this?

ocean tundra
#

I've used ECB with Run before

viral sonnet
#

WithStructuralChanges() disables burst too so I don't think this is an option

ocean tundra
#

show some code

viral sonnet
#

if I change to run this is the error: InvalidOperationException: System.InvalidOperationException: EntityCommandBuffer.Concurrent must only be used in a Job

ocean tundra
#

if your using run you dont need Concurrent

viral sonnet
#

right! 😄 thanks

ocean tundra
#

but im away from my pc so cant confirm

safe lintel
#

ill have to look into that

ocean tundra
#

im probably weeks away from wewriting my loading stuff so i wont be able to confirm

#

but ive asked the Odin devs if that code will work at runtime

#

will let you know

hollow sorrel
#

how do i get systems to show in entitydebugger for a custom world?

#

i think i saw the answer before but forgot

ocean tundra
#

I have that issue, didnt think there was a fix yet

#

try the new systems window?

hollow sorrel
#

ah damn

#

can't test new one right now but would be nice if that works

ocean tundra
#

yup

safe lintel
ocean tundra
#

yes finally 🙂

#

i think i could probably use the features they talked about already to move my server world back into the default update code

hollow sorrel
#

@ocean tundra was able to update after all, new systems window is still empty unfortunately

ocean tundra
#

😦

#

they mentioned something about advanced options hidden in a drop down

safe lintel
#

did you select show all worlds?

hollow sorrel
#

there's no show all worlds in new systems window but yea i tried that in old one

#

and show inactive systems

ocean tundra
#

actually its hidden in the preferences window

hollow sorrel
#

oh huh

#

there's a checkbox there but no idea what it does
seems it only adds a grayed out "LIVE WORLDS" to the list

safe lintel
#

theres a setting in the editor preferences to show more

hollow sorrel
#

yea that's the one i'm talking about

safe lintel
#

ah

hollow sorrel
storm ravine
#

how do i get systems to show in entitydebugger for a custom world?
@hollow sorrel systems from custom world should be in default world player loop inside root groups if you want them in EntityDebugger. Behaviour of Systems window still the same as in EntityDebugger.

hollow sorrel
#

i do have simulationsystemgroup but i just added it to the world directly, is there something else i need to do?

#

oh i don't have an Update group if that matters

storm ravine
#
var simulationGroup = World.DefaultGameObjectInjectionWorld.GetExistingSystem<SimulationSystemGroup>();
simulationGroup.AddSystemToUpdateList(newWorld.CreateSystem<TEST_SYSTEM>());
simulationGroup.SortSystems();```
hollow sorrel
#

right now i have this

#
World simWorld = new World("Simulation World");

        var simGroup = new SimulationSystemGroup();
        simWorld.AddSystem(simGroup);

        var testSystem = new PoopSystem();
        simWorld.AddSystem(testSystem);
        simGroup.AddSystemToUpdateList(testSystem);
#

is it because i don't use defaultworld?

#

is there a way i can get by that without using the whole defaultworld initialization stuff

#

oh wait

#

seems if i add ScriptBehaviourUpdateOrder.UpdatePlayerLoop(simWorld); it does show up

#

so i guess the defining part is letting unity update it

#

but would really like to update it manually

storm ravine
#

seems if i add ScriptBehaviourUpdateOrder.UpdatePlayerLoop(simWorld); it does show up
@hollow sorrel It shouldn't change anything

hollow sorrel
#

that seems to be the only thing that changes it
doing world.update in a monobehaviour's update() - doesn't show
adding it to unity's updateplayerloop - does show

storm ravine
#

Are you sure it's in simulation world? Because It's not how it works. And ScriptBehaviourUpdateOrder.UpdatePlayerLoop(simWorld); wouldn't change it:

#

Your code ```World simWorld = new World("Simulation World");

    var simGroup = new SimulationSystemGroup();
    simWorld.AddSystem(simGroup);

    var testSystem = new TEST_SYSTEM();
    simWorld.AddSystem(testSystem);
    simGroup.AddSystemToUpdateList(testSystem);
    ScriptBehaviourUpdateOrder.UpdatePlayerLoop(simWorld);```
hollow sorrel
storm ravine
#

Show same screens with Show Full Player Loop

hollow sorrel
#

wops i didn't select simulation world on the 2nd screen but it shows empty too

#

aight one sec

#

seems it doesn't get added into the playerloop at all when updating in a monobehaviour

#

i think in your example when you're doing var simulationGroup = World.DefaultGameObjectInjectionWorld.GetExistingSystem<SimulationSystemGroup>(); you're grabbing your existing world's simulationsystemgroup that's already being updated by unity, right?

storm ravine
#

You using UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP and this is only place of your worlds initialisation?

#

Because I see root level groups which you not adding manually from your code

hollow sorrel
#

yeah

storm ravine
#

And I feel like your Simulation World initialized with default world (if look at groups)

hollow sorrel
#

going into ScriptBehaviourUpdateOrder.UpdatePlayerLoop, seems it's adding those rootlevel groups there

storm ravine
#

It does because Sim world in your case created with default world systems and player loop, and with enabled define it shouldn't happen at all.

#

Ah stop

#

No without default world groups, a bit sleeping.

hollow sorrel
#

what do you mean?

storm ravine
#

I just checked that nothing changed in behaviour. Well, because you haven't default world your sim world will use default layer loop - PlayerLoop.GetDefaultPlayerLoop(), but if you create second world and will try to call UpdatePlayerLoop it will override player loop with systems from new created World and all previous world systems will disappear, and wouldn't update

#

You still need to have one common world with one player loop which will be used by every other world systems update (and appearing in debuggers).

hollow sorrel
#

ah

#

but then it wouldn't update manually anymore right

viral sonnet
#

hm, I had a lot of EntityManager.HasComponent and now I lookup through a Dictionary<Entity, ISkill[]>() which is so much faster for some reason

storm ravine
#

@hollow sorrel It will update manually (by calling Update on world or group or system), but wouldn't update automatically by engine, and wouldn't appear in debuggers

hollow sorrel
#

yea

#

so gotta choose between manual update or show in debugger

#

that kinda sucks

viral sonnet
#

it's a pretty huge fail to expect to use the PlayerLoop in all those debug tools

#

and no way to register

storm ravine
#

Well there is ways

#

But with reflection

viral sonnet
#

still interesed 🙂

storm ravine
#

We just haven't convenient API

viral sonnet
#

i found out about UpdateCallback which could solve my problem of having to call a systemgroup multiple times but I haven't got it working yet. with that i could register my world in the playerloop and be done

hollow sorrel
#

i'm poking around in entitydebugger and seems it's always tied to PlayerLoop to get what systems to show

viral sonnet
#

why does unity expect us to even run the game? i don't get that. imagine we can already browse our systems from the editor.

#

and god damnit I need to stop. performance is like a drug ... 2 days ago 1 minute was simulated in 1 sec, yesterday I had it at 500ms, now I'm at 320ms

ocean tundra
#

@viral sonnet Whats your project? as that sounds awesome

#

also i think the old optimize last rules probably still apply 😛

odd cipher
#

Same here, My world generation code used to take around 800ms (without more than one noise maps or any chunks) but now with all those new things it does it all in 40ms

ocean tundra
#

wow

odd cipher
#

there are many more things that I didn't have back then too. Such as tilsets wasn't a thing.

viral sonnet
#

hm, when it started I had to explain it but it's similar to clicker heroes 2. basically an incremental rpg game

odd cipher
#

and back then each tile was 8x8, now they are 16x16.

ocean tundra
#

@viral sonnet sweet, so you can simulate the game super fast for the player?

viral sonnet
#

as time went on it got more crazy, for the longest time performance was holding me back so I never could really make what I wanted. until ecs dropped and I went back to the idea

odd cipher
ocean tundra
#

very cool

#

im still ages away from my map procedural generation

viral sonnet
#

@ocean tundra exactly, I need it for offline progression. so when the player starts the game 8 hours later, those hours are simulated as fast as possible

hollow sorrel
#

noice

viral sonnet
#

@odd cipher pretty cool stuff

odd cipher
#

it used to have a limit of 8,388,608 pixels but since I added the chunking system it can pretty much handle infinite. Though the computer does not like that

viral sonnet
#

i'm only thinking about fast-forwarding the simulation, because previously, (several years now) I wasn't even hitting 60 fps

odd cipher
#

the main bottleneck is the amount of chunks

ocean tundra
#

@odd cipher a chunk is 16 * 16? with a dynamic buffer?

odd cipher
#

I actually don't use Entities

ocean tundra
#

sweet

odd cipher
#

in that gif they were 25x25

#

50x50 brings it down to 30ms

#

I'm really happy with how it works currently though the Chunk part could definitely be done better.

craggy orbit
#

is there a way to have subscenes in a build without initially adding them to a scene? i'd like to load them in at a later point but right now i have to add them all to the scene before hand and delete them on start, which causes a huge lag spike

viral sonnet
#

GetArchetypeChunkComponentType is faster than GetComponentDataFromEntity, right?

hollow sorrel
#

@craggy orbit i don't think you can have them outside of a scene, but you can def load them in at a later point
just disable the auto load scene checkbox on your subscene

#

no need to delete anything

craggy orbit
#

ah good idea! totally forgot about that. thanks!

viral sonnet
#

something weird is going on. I've rewritten my IJobChunk to SystemBase and while the chunk method takes 0.033ms the systembase takes nearly 1ms.

#

okay, i'm just a dummy and have forgotten to add my excludes/WithNone ... lol

craggy orbit
#

works perfectly, @hollow sorrel ! thanks again for that reminder

ocean tundra
#

what are people doing about UI type content like Strings (Name, description) icons (sprites)?
I was thinking of turning my data into a blob asset, most of it ends up in components in some way (eg health) but having the original data available could be useful

Some more context, this is for a RTS and I have all my "prefab" data in editable JSON files for my Unit/Buildings
Its all things like, max health, resource costs, production lists, attack damage, name, description, icon's

#

oh and what happens to blob assets and world serialization?

sudden comet
ocean tundra
#

i dont think you can nest ForEach's

#

also you can check the generated code which may help

#

DOTS > DOTS Compiler > Open Inspector

#

Also your ForEach's have no components or any WithAll's so i think that it will run on ALL entitoes

sudden comet
#

I remove most of the code to isolate the behaviour, but it happen also with filters..
Now, when you strip most of the lines of code, the "bug" does not happen anymore
thanks for you answer, I will look at the generated code.
This system in a new project trigger the "bug"

#

I filled a bug to unity if there could be a "bug" .. but I’ll have to find a workaround.
It seems weird that you cannot nest ForEach .. you never need it ?

ocean tundra
#

i never seem too

sudden comet
#

Anyway I’m glad to know where is the generated code, big thanks to you

ocean tundra
#

if your trying to access data from other entities there GetComponentDataFromEntity

#

or something like that

#

i use that when 1 entity references another and you need to access the other

humble falcon
#

I would just query speaker entity and playerentity and store them in a native container. so that during foreach I can get to the data of the queried entities.

sudden comet
#

thank you .. btw the generated code is not easy 😛

humble falcon
#

Oh I didnt read that Roycon already answered that. But yeah pretty much the same what @ocean tundra suggested

storm ravine
#

oh and what happens to blob assets and world serialization?
@ocean tundra If you serialize world it will serialize blob store with world, and restore on deserialization, but they haven't any merging, thus if you have in current world same blobs (for example built at prefabs conversion after loading through addressables) and deserialize something to your streaming world (loading game) blob store will have blobs duplication (different pointers - same content).

ocean tundra
#

@storm ravine Awesome thats good to know 🙂

sudden comet
#

@humble falcon @ocean tundra It is not related to nested ForEach :-(, I did reproduce the bug commenting out the outer most ForEach 😕

humble falcon
#

@sudden comet well with just the code you showed me, I cant tell you much, why it isnt working. Specify what you want to achieve and maybe I can help you with that 😅

sudden comet
#

Achieving is not really the point here .. but understanding why it isn’t working is..

deft stump
#

What is the system trying to do though? From what i see you're just gettinf entities and assigning them

ocean tundra
#

maybe explain the bug in more detail. all i did was skim the code

storm ravine
ocean tundra
#

I didnt understand the bug

storm ravine
#

This is his bug I guess

#

As he's not changing it between and it should be the same in both Debug.Log

#

@sudden comet this is what you meant?

sudden comet
#

yeah 🙂

ocean tundra
#

:?

#

that makes no sense

deft stump
#

Ah the has interacted bool between the first and second should be true

sudden comet
#

I test it in an empty project with only this file 🙂

deft stump
#

Just a quick test. Can you remove the braces?

storm ravine
#

Yes it will

sudden comet
#

if you remove the brace it start to work

storm ravine
#

Because it will create different local scope, this is why compiler not complains about duplicate Entity interactedSpeakerEntity declaration

sudden comet
#

if I rename it .. it continues to crash

storm ravine
#

What you rename?

sudden comet
#

not crash but "bug"

#

the second interactedSpeakerEntity into ointeractedSpeakerEntity

storm ravine
#

well you just can remove Entity before second usage

#

and reuse previous declaration

sudden comet
#

it seems to work when I put interactedSpeakerEntity out of the braces and reuse it. But it does not feel right, don’t you think ?

storm ravine
#

You shouldn't use this additional braces here

#

They create different scope

sudden comet
#

yes sure .. but I use to have some "if" around those first braces

#

They create different scope
@storm ravine sure but it is not suppose to alter the value of the boolean value

#

do sometime peoples from unity read this channel ?

pulsar jay
#

Did anybody manage to render entities with hybrid renderer in edit mode yet?

storm ravine
#

Problem with bool here I guess can be in codegen (because of nested ForEach), as bool declared at upper scope and shouldn't be affected like this in inner scope (it should change upper scope, but feels like it become local scope instance). I recommend you fill bug report through Unity -> Help -> Report Bug

undone torrent
#

hiii , how can i iterate a nativearray parallel ?

storm ravine
#

It somehow related to local variables capturing from first inner ForEach lambda, as it capture them by codegen which allow you change outer value type variables inside ForEach labdas, and in this case it messing that capturing...

#

I told DOTS team about that, lets wait what they answer, good catch btw @sudden comet

#

hiii , how can i iterate a nativearray parallel ?
@undone torrent Run IJobFor with ScheduleParallel

undone torrent
#

okay thx u man 🙂

storm ravine
#

@sudden comet nested ForEach currently not supported and usually it throw error like this (look at screenshot). But they have different bug, that this check only throw error if your top ForEach capture some local variable outside. For example if you add in OnUpdate some bool test = false and will use that test in your upper ForEach you'll see error about nested ForEach

pulsar jay
#

Does nobody have any experience with ECS in edit mode?

frail seal
#

Can I somehow invoke a delegate in a job?

storm ravine
#

@frail seal FunctionPointers

frail seal
#

@storm ravine Ooh, thanks. Does it also work without Burst-compile?

storm ravine
#

Function Pointers itself always burst compiled, but they not require to be called from bursted job

sudden comet
#

@sudden comet nested ForEach currently not supported and usually it throw error like this (look at screenshot). But they have different bug, that this check only throw error if your top ForEach capture some local variable outside. For example if you add in OnUpdate some bool test = false and will use that test in your upper ForEach you'll see error about nested ForEach
@storm ravine In the last test I made, they are no Nested ForEach anymore

#
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

public class BuggySystem : SystemBase
{
    protected override void OnUpdate()
    {
        int2 playerInteractionCell = new int2();
        bool hasInteracted = false;
        
        Debug.Log($"BEFORE <color=red>FIRST</color> INTERNAL FOREACH : {nameof(hasInteracted)}={hasInteracted}_");
        
        {
            Entity interactedSpeakerEntity = Entity.Null;
            
            Entities.ForEach((Entity speakerEntity) =>
            {
                if (playerInteractionCell.Equals(int2.zero))
                {
                    interactedSpeakerEntity = speakerEntity;
                }
            }).WithoutBurst().Run();
            
            hasInteracted = true;
            Debug.Log($"AFTER <color=red>FIRST</color> INTERNAL ASSIGN : {nameof(hasInteracted)}={hasInteracted}_");
        }

        Debug.Log($"BEFORE <color=red>SECOND</color> INTERNAL FOREACH : {nameof(hasInteracted)}={hasInteracted}_");
        
        if (!hasInteracted)
        {
            Entity interactedSpeakerEntity = Entity.Null;
            Entities.ForEach((Entity entity) =>
            {
                {
                    interactedSpeakerEntity = entity;
                    hasInteracted = true;
                }
            }).WithoutBurst().Run();
        
            Debug.Log($"AFTER <color=red>SECOND</color> INTERNAL ASSIGN : {nameof(hasInteracted)}={hasInteracted}_");
        }
        
        Debug.Log($"BEFORE <color=red>THIRD</color> INTERNAL FOREACH : {nameof(hasInteracted)}={hasInteracted}_");
        Debug.Log($"<color=red>-----------------------------</color>");
    }
}
storm ravine
#

@sudden comet yes, they looking. I just retranslated their note about nested ForEach

amber flicker
#

@pulsar jay some - though I don't claim to be an expert

sudden comet
#

@sudden comet yes, they looking. I just retranslated their note about nested ForEach
@storm ravine thank you, it is awesome to have a so direct contact 😉 I also sent a bug report

pulsar jay
#

@amber flicker I appreciate any input on that matter 🙂 Just figured it might not work because the spawner entity is created by the conversion system. So I guess I will have to create the spawner entity from code in an AlwaysExecute script

amber flicker
#

@pulsar jay If your entities are created at runtime but you wanted them to be created also at edit-time, ExecuteAlways or whatever it's called might work if within an open subscene that's converted (I'm not sure, haven't tried). If it's outside of a subscene though, you'd need to call to create the editor world and add the systems you want to run.

pulsar jay
#

Yes @amber flicker I got the editor world to run with DefaultWorldInitialization.DefaultLazyEditModeInitialize(); The system is also running. It seems like the last roadblock seems to be the GameObjectConversionUtility not working in edit mode. Sth seems to be null. Possibly because the conversion world does not exist in edit mode

amber flicker
#

hmm yea I'm not sure about GameObjectConversionUtility - I use my own GameObjectConversionSystem to convert my custom components after the GameObjectConversionGroup

pulsar jay
#

interesting. Is there any specific advantage to using your own system?

amber flicker
#

well.. timing mostly. In my case I need to run after the game objects have been converted.

#

But it's also nice having specific control over it and it's very simple to write.