#archived-dots

1 messages Β· Page 219 of 1

remote crater
#

Ok Mr.K, you are a wise one who has answered secrets of the Universe before, I will take your advice and try and learn how to set a tag. I believe God invented Google for that. Thank you God's assistant.

#

Appologies. Been binge watching Mitch Hedberg on youtube.

karmic basin
#

Yes you .AddComponentData, not Set because no values in the struct, it's just a tag

remote crater
#

ty

karmic basin
#

You do it from Entity Manager, or ECB,...

remote crater
#

GameBoardModel.entityManager.AddComponentData<DisableRendering>(GameBoardModel.playerEntity, new Unity.Rendering.DisableRendering());

#

This probably will work, just gotta find the right place to put it. I think UNITY is picky due to order of operations and such, yet I don't want it in an update wasting a loop if only boolean checked to run once.

#

Thanks muchly.

karmic basin
remote crater
#

Ok, I think I set it disabled, but it still shows. I'm in the entity debugger. Is there anyway to see tags applied?

#

It said disabled... hmmm

karmic basin
#

@remote crater should be AddComponent() because it's a tag, sorry

remote crater
#

oooh cool

karmic basin
#

quick example

pliant pike
#

if you get the entity's in a nativearray you can just do EntityManager.AddComponent(nativearry<Entity>()) outside a job

#

that's probably the most efficient way

karmic basin
#

Yeah many ways to add components

wary anchor
#

Okay well I got the same Time getting deleted error in 2020.3.7f1 now as I was in the 2021 versions I was using before, not sure what's throwing this but it's definitely happening when I open my pause menu, but only sporadically.

#

and I can't use the entity debugger after the exception is thrown because that throws a load more (UI related) presumably because of the missing TimeSingleton component

pliant pike
#

how are you pausing things?

wary anchor
#

There's an InGameMenuController that calls SetGamePaused

pliant pike
#

interesting so its not an internal unity thing

wary anchor
#

It happens only very infrequently

#

I'm sure I'm at fault, I just can't work out where!

pliant pike
#

looks pretty much like how I would do it I'm guessing its using a Singleton with requireforupdate in the running sytems?

wary anchor
#

yes

#

Trying to reproduce the bug and I can't, I wish I could nail down exactly when it happens

#

I have a log of when it happened in a build, but that's not helpful either. I'll check the editor logs for this current session

pliant pike
#

sounds like something is using something a singleton in a way it shouldn't

wary anchor
#

lol 85 mb editor log full of NREs related to this

pliant pike
#

my guess is it's something to do with get_TimeSingleton

wary anchor
#

Mmm so one other time it happened in this session and it wasn't the TimeSingleton - it seems to have failed on get_ one of mine (which then had knockon effects, looks like the entire Player was not present, weirdly

#

Well, I just got it after disabling burst as well so let's see what the logs say now 😐

gusty comet
#

oh thats not an enum

#

can i just make new class instance and not change anything? in these settings

wary anchor
#

I'm at a loss with this, with full strack traces on, it still gives me no idea where to look to root out the problem. I'll have to search for every single instance of DestroyEntity and work out if I've done something silly perhaps when changing the order of system execution.

wary anchor
#

Is this warning from burst helpful to tracking down the problem? I've not seen it before but it doesn't appear to point me to anywhere in my code 😦 https://gdl.space/qahaqoreli.sql

pliant pike
#

I'd report that as a bug to be honest @wary anchor , even if it's not necessarily a bug, the fact it isn't reporting to you clearly where the bug means it is a bug

wary anchor
#

Yeah I probably should - I'm in the process of tracking down the exact commit where the errors start in the hope of finding the issue that way. Once I have it found it'll be easier to put together something useful - and I have to find the error and fix it or my entire project is fubar!

nova adder
#

after 3 days, i recreated the math for a 2D Blend Tree in dots.....send help

safe lintel
#

hoping the next release of dots also includes the next animation package, that has statemachines. because it feels like a waste of time trying to implement that stuff in either node graphs or mainthread unbursted systems

remote crater
#

entityManager.AddComponent<DisableRendering>(playerEntity); //did not seem to make it not render...

nova adder
safe lintel
#

yeah made my own blend trees with bool overrides for clip interrupting as well but just felt like a complete waste of time given statemachines should theoretically be right around the corner. if you look at their code they have a framework for it in place already, just no examples, and the visual scripting ui is in the process of being merged with their compositor package.

hollow jolt
#

is there a way to use List.Insert with IJobParallelFor for NativeList ? All i can see is Add(...)

ocean tundra
#

@hollow jolt Native list dosnt even have insert

hollow jolt
#

yes im aware

#

im looking for a similar functionality

ocean tundra
#

oh i see

hollow jolt
#

how to add_item_at_index >

ocean tundra
#

what is index? is it actually a key that maps to something else?

#

you could try a NativeHashMap

hollow jolt
#

hmmm

#

it has to keep the indexing of the upper values + 1

#

when using add At

ocean tundra
#

you could move index into the value as well

#

then do a sort

hollow jolt
#

with hash map ?

ocean tundra
#

oh no sorry the move index idea is still with a native list

hollow jolt
#

so i add ( push ) then i sort ?

ocean tundra
#

that could work

#

what are you actually trying to do?

ocean tundra
#

the issue with these collections is they are all aiming to support parallel code

#

aah some mesh stuff

#

yea i would break that up, so instead of 4 lists, 1 list of struct (Vertex, Uv,Normal,Triangle, Index)

#

then a job that runs after to sort then break up into the 4 mesh lists

hollow jolt
#

was hoping to solve it in 1 , but ill try multiple jobs

ocean tundra
#

you could probably do it all in 1 big job

#

i just like smaller jobs for maintainability

pliant pike
#

small jobs are sometimes more efficient also... depending on what they are doing

vagrant lotus
#

Is it possible to have a system call destroysystem on it self

ocean tundra
#

havnt tried yet

#

i would guess so

#

isnt it world.destorysystem tho?

craggy orbit
#

is there a way to instantiate entities inside of the IConvertGameObjectToEntity conversion method? i'm trying to generate some more entities but i only want to do it once

#

i've tried instantiating to a native array with the entity from conversionSystem.GetPrimaryEntity but it doesn't seem to work. is there a specific allocator i should be using other than Temp?

#

i keep getting this error

DuplicateEntityGuidException: Found 1 EntityGuid components that are shared by more than one Entity
guid = 28788:ffffdad4:00000000, count = 153, obj = ENV_Vector Field Anchor (UnityEngine.GameObject)
coarse turtle
craggy orbit
#

im not getting the error anymore, but it's still not working. any ideas? this is how im trying to create the extra entities

NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
conversionSystem.CreateAdditionalEntity(anchorPrefab, anchors);
hollow jolt
ocean tundra
#

ummm no clue what that is

#

πŸ˜›

ocean tundra
#

hmmm i see

hollow jolt
#

not tested yet , but i gonna try to run this parallel jobs

ocean tundra
#

nooo

hollow jolt
#

y ?

ocean tundra
#

that wont work in parallel

#

if 2 jobs access the same list to write

hollow jolt
#

Parallel for each

ocean tundra
#

if they have their own list each it should be ok

hollow jolt
#

IJobParallelFor -> Execute(int i)

#

NativeList should work with it , isn't that the case ?

coarse turtle
craggy orbit
#

it's not creating more entities

ocean tundra
#

pretty sure the safty system will throw up at you, execute(i) should only access the index of i

hollow jolt
#

eh ? so we can't add to NativeList per Execute i ?

coarse turtle
ocean tundra
#

you would use the parallel version to add to the same list from many concurrent jobs

craggy orbit
#

i'm converting a gameobject within a subscene. the objects im trying to instantiate are prefabs referenced inside the IConvertGameObjectToEntity

hollow jolt
craggy orbit
#

aha!

#

they were in a different section in the Entity Debugger

ocean tundra
#

@hollow jolt no that will turn off the safty checks, and what happens in this example:
2 jobs both with 10 items each both running at the same time
job 1 adds 1, 2, 3, 4,
Job 2 adds 1 ,2, 5,6

#

sorry add should be inserts at

hollow jolt
#

but you can use add normally can't u ?

ocean tundra
#

on the parallel writer version yes

#

OR if your job is only 1 'thread'

hollow jolt
#

how do i use parallel writer ?

ocean tundra
#

this is Schedule vs ScheduleParallel

#

on entities.foreach (if youve used that)

#

just call asParallelWriter on your list

#

and use the result to add too

hollow jolt
#

list.AsParalleWriter.Add ( ? )

ocean tundra
#

But you cant read or insert at pos

#

var listWriter = list.ASParallelWriter()

inside job
listWriter.Add....

hollow jolt
#

ah i c

#

well guess ill just pile them up and sort after the job is complete

ocean tundra
#

unless you can make 100% sure each index is always unique

hollow jolt
#

its writing like 0,1,2 , 0,1,2 , 0,1,2 ... ( inserts in pairs of 3 )

ocean tundra
#

as in each job i maps to a single index in your lists/arrays

craggy orbit
#

regarding my earlier issue with creating a bunch of entities on conversion: all of the instantiated entities have a Prefab tag on them, which afaik treats them as not really existing in the scene. i've tried removing the component but it's not working. it also doesn't convert the prefab entity before instantiating more, so i have to add the components myself, which im pretty sure im not supposed to do.
here's the instantiation code

NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
conversionSystem.CreateAdditionalEntity(anchorPrefab, anchors);
dstManager.RemoveComponent<Prefab>(anchors);
```and the full script <https://pastebin.com/xJXZ2C5e>
ocean tundra
#

@craggy orbit is the main IConvert a prefab?

#

ok so

#

CreateAdditionEntity just creates a empty entity linked to the target you give it

craggy orbit
#

the VectorFieldAnchorAuthoring is a prefab

#

so CreateAdditionalEntity doesn't instantiate from a prefab like i'd hoped?

ocean tundra
#

Creates an additional entity in the destination world. The entity is associated with the given object. New entities should be created using this method since it ensures that the resulting entities have all data required for conversion correctly set up.

#

no

#

that association is for things like livelink i belive

#

so normally i would pass 'this' into the createadd... method

#

then setup the new entity

#

so to confirm your problem, you have a prefab and want to create X of them during conversion?

craggy orbit
#

yes. i've got a base object VectorFieldColliderAnchorAuthoring with a prefab field VectorFieldAnchorAuthoring and i'd like to create X prefabs converted to entities

ocean tundra
#

hmmm

#

so

#

the ability do simply do what you want does seem to be lacking

#

but i think i know a way πŸ˜›

#

first you cant use IConvert

#

need to write a custom conversion system

#

maybe 2

#

First system, loops over all your VectorFieldColliderAnchorAuthoring GO entities, and creates more entities in the INPUT world

#

those entities will have your instance data (eg X Y Z) and a link to your prefab

#

that system has to update in 'GameObjectDeclareReferencedObjectsGroup'

#

(sorry had the wrong group)

#

and i THINK that may work, destionation entitys are created after that group runs

#

wait you need to be creating your source prefab sorry, not adding a link

craggy orbit
#

hm ok... it sucks that the functionality doesn't already exist, but thanks for pointing me in the right direction!

ocean tundra
#

i hope its the right direction πŸ˜›

#

all the info

#

hmm they say to treat the input world as read only

#

what if you do DstEntityManager.Init... with GetPrimaryEntity(Prefab)

#

it wont be setup for livelink and things

craggy orbit
#

i took a little break before switching to a conversion system, but it took only a few minutes! i was able to practically copy and paste from my old authoring component to the conversion system. the only "big" change i made was the entity creation

NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
DstEntityManager.Instantiate(GetPrimaryEntity(input.anchorPrefab), anchors);
hollow jolt
#

how to clone an entity ?

#

( and all its components )

opal lynx
# hollow jolt how to clone an entity ?

Entity newEntity = entityManager.Instantiate(entityThatYouAlreadyHave);

You have to do this on Main Thread
which means

  1. on Monobehaviour
    or
  2. on System in OnUpdate in ForEach.Run()
opal lynx
gusty comet
#

Is there way to use GameobjectConversionUtility and set the entities to disabled at start/during the process?

opal lynx
#

(some stupid saying)

#

(some stupid saying)

gusty comet
#

there is Disabled Component but i dont know

#

how to add it

#

during conversion utility

opal lynx
#

I am sorry.. πŸ˜… I didn't know
I am testing it now

gusty comet
#

oh

#

disabling the prefab does the job

#

Lol!

opal lynx
gusty comet
#

yeah i know

#

its better to just disable the prefab though

opal lynx
#

That's better πŸ‘

wary anchor
#

I recently changed some systems to Schedule that were Run. They're writing work to the EndSimulationGroupCommandBufferSystem and now I've realised a problem I'm not sure how best to get around: at the end of the game I am resetting some public NativeArrays but they were being used by the scheduled job so of course I now get a
The previously scheduled job UpAxisSystem:OnUpdate_LambdaJob0 reads from the --NativeArray--. You must call JobHandle.Complete() on the job before you can deallocate the NativeArray safely.

I can't just move the main menu systems to a later systemgroup as they use many of the same systems as the main game (it's all in one scene). How would you handle this situation?

bright sentinel
wary anchor
#

Okay, how do you complete the dependencies of other jobs? Or would I have to add that into each one?

#

I was thinking about delaying the loading process until the start of the next frame / end of this one to get around it that way

bright sentinel
#

You have to save them somewhere. For example ECBSystems has the AddJobHandleForProducer function that adds the jobhandles that must be completed, which it then completes before. You could have a similar pattern here.

#

The ECBSystem then just saves them to a list

wary anchor
#

I'm sorry, I'm being really slow on this, I don't follow

#

just trying to understand how it worked before I changed from run to schedule so I can see where in the loop it would be okay to overwrite the native array

#

but brain still in shader mode!

#

I think... if I make sure the system that calls the end of game and kicks off that set of loading systems makes sure it runs before any of the Scheduled systems, that should resolve it?

warped trail
#

let your system that resets native array have some public list of jobhandles

#

and every system that touches that native array just add their jobs to that public list

wary anchor
#

k then just JobHandle.CombineDependencies then complete before resetting it yeh

warped trail
#

why do you need to complete if you can just schedule a job that dependant on this jobhandle?

wary anchor
#

because I'm recalculating the values for the array and setting it on the main thread

warped trail
#

in that case you can complete

#

look at physics system they use this strategy to handle external dependency to nativearraysπŸ€”

wary anchor
#

k Cheers will do

#

Okay, so that seems to be working, but I'm adding the dependency every frame which must be wrong, Sorry I'm being ridiculously thick about this

#

I suppose i can just Clear it before scheduling the job and add it after, seems like a janky hack tho

wary anchor
#

Oh man okay no that hasn't fixed it at all, now it goes for the first cycle then there aren't any atoms. I genuinely don't understand why this problem is occurring now. It's all really complicated and of course worked before I switched a system to Schedule - but now I've got all the loading and nativearray stuff happening before the UpAxisSystem, so it should have all the updated values in place before it schedules

#

ahh unless... yeah there are some of the loading systems in a previous group, so they would be waiting until the next frame before they receive their commands.. the lading is complicated and it's several systems chained together with events driving them

#

so I could put a blocking component in after the load is requested and delete it when the load is finished, and just not schedule any of the systems that use the array if that component is present

#

cough or use my existing AllowSystemsToRunComponent cough fail roo

wary anchor
#

Well, I have no idea why it stopped working but I can reload levels fine so I'll just have to rewrite my menu code. I've been through all the diffs for the last few commits so either I didn't notice this in testing because I've been reloading levels all the time & doing shader work, or unity's decided to order the systems differently and that's somehow caused it. It's no bad thing, the menu needed refactoring anyway.

remote crater
#

entityManager.AddComponent<DisableRendering>(playerEntity); //did not seem to work. It is supposed to disable rendering.

karmic basin
#

Works for me. Do you convert your player from a gameobject ?
Do you have a "complex" hierarchy ? I think the component should be on the same level as the RenderMesh. You can double-check with the Entity debugguer. Not sure it disables all hierarchy

remote crater
#

Mr.K, yes I converted my player from a game object. Yes, I beleiev I have a complex hierarchy.

#

It is a game object with many scripts and a child.

karmic basin
#

If the mesh is on the child and you convert the parent, maybe that's why

#

didnt test that case

remote crater
#

Going to aunt's 70th, she's awesome. Be back in a few hours. God bless all of yinz.

jaunty herald
#

Is it possible to add an ECB to run after a scheduled job has executed?

bright sentinel
#

@jaunty herald Then you need to create your own ecb system for it that will run after the job is scheduled. An ECB is always a sync point, so you can't depend on it being completed, but you can complete it before the ECB runs.

vagrant lotus
#
public class BaseMenu : SystemBase
{
    protected override void OnUpdate()
    {
        if (!isActive)
            return;

        var query = EntityManager.CreateEntityQuery(
            ComponentType.ReadOnly<Translation>(), 
            ComponentType.ReadOnly<PlayerRotationData>(), 
            ComponentType.ReadOnly<PlayerTag>());
        var origin = query.GetSingleton<Translation>().Value;
        var pivot = query.GetSingleton<PlayerRotationData>().rotation;
        query.Dispose();

        foreach (var element in elements)
        {
            var config = EntityManager.GetComponentData<UserConfigData>(element);

            var position = origin + math.mul(quaternion.RotateY(pivot.y), config.offset);
            var turned = quaternion.RotateY(pivot.y + config.orientation.y);
            var pitched = math.mul(turned, quaternion.RotateX(config.orientation.x));
            var rotated = math.mul(pitched, quaternion.RotateZ(config.orientation.z));

            if (EntityManager.HasComponent<UserRenderData>(element))
                EntityManager.GetComponentObject<UserRenderData>(element).textMeshPro.transform.SetPositionAndRotation(position, rotated);
            EntityManager.SetComponentData(element, new Translation { Value = position });
            EntityManager.SetComponentData(element, new Rotation { Value = rotated });
        }
    }

    protected override void OnDestroy()
    {
        foreach (var element in elements)
            if (EntityManager.HasComponent<UserRenderData>(element))
            {
                TextMeshPro textMeshPro;
                if ((textMeshPro = EntityManager.GetComponentObject<UserRenderData>(element).textMeshPro) != null)
                    GameObject.Destroy(textMeshPro.gameObject);
            }

        EntityManager.DestroyEntity(elements);
        elements.Dispose();
    }
}
#
[DisableAutoCreation]
public class MainMenu : BaseMenu
{
    protected override void OnCreate()
    {
        var buttonMesh = ResourceLoader.active.LoadMesh("Mesh/Button");
        var buttonMaterial = ResourceLoader.active.LoadMaterial("Material/Button");
        var meshData = new MeshData
        {
            render = buttonMesh,
            material = buttonMaterial,
            collider = ResourceLoader.active.GetCollider(buttonMesh)
        };

        elements = new NativeList<Entity>(3, Allocator.Persistent);
        elements.Add(AddButton(
            EntityManager,
            new float3(-1.1f, -1f, 2f), 0f,
            meshData, ToStartMenu,
            2.5f, "Start"));
        elements.Add(AddButton(
            EntityManager,
            new float3(0f, -1f, 2f), 0f,
            meshData, ToSettingMenu,
            2.5f, "Settings"));
        elements.Add(AddButton(
            EntityManager,
            new float3(1.1f, -1f, 2f), 0f,
            meshData, ToExit,
            2.5f, "Exit"));

        Show();
    }
}
#
[UpdateAfter(typeof(PlayerSystem))]
public class UserSystem : SystemBase
{
    private BaseMenu current;

    protected override void OnCreate()
    {
        current = World.CreateSystem<MainMenu>();
    }
}
#

my problem is

#

after i called CreateSystem in UserSystem

#

the OnCreate function in MainMenu gets called

#

but the OnUpdate function does not get called

#

and MainMenu does not show up as a system in the EntityDebugger

#

could anyone shed me some light on this problem i have?

#

I could directly call function in MainMenu, which means the class instance does exist
Update: not solved but CreateSystem<BaseMenu>() does work properly

#

p.s. ping me

#

thx in advance

opal lynx
vagrant lotus
#

Hmmm, let me fire up unity

vagrant lotus
#

Update: not solved but CreateSystem<BaseMenu>() does work properly

opal lynx
#

What is isActive in the OnUpdate?

vagrant lotus
#

my theory is ecs does not work with subclass

#

but the compiler does not know it

opal lynx
#

before return πŸ˜…
just for check
Debug.Log("Code stopped");

vagrant lotus
opal lynx
#

at BaseMenu

OnUpdate

after
if (!isActive)

#

so just to make sure
the ecs can't run Update

vagrant lotus
#

yeah, i did Debug.Log("hi")

#

nothing showed up

#

let me test this with CreateSystem<BaseMenu>()

#

Update: OnUpdate does work with BaseMenu

#

just not with subclass MainMenu

#

Remarks: problem not solved (for any helper out there)

#

Thx for your effort, as always

opal lynx
#

use
private MainMenu current;

and make OnUpdate, there
and call base.OnUpdate

#

so make
current = create MainMenu

vagrant lotus
#

let me try

#

OnUpdate doesnt work, but MainMenu showed up as BaseMenu in EntityDebugger

#

@opal lynx

opal lynx
#

mine works

#

I made MainMenu
and BaseMenu Updates

vagrant lotus
#

what version of unity

opal lynx
#

2020.3.6f1

vagrant lotus
#

ah

#

let me get that version

#

i heard they started to have compatibility issue with 2021Unity

#

and advised people to switch to 2020LTS

opal lynx
#

also it works, too

#

it still Updates BaseMenu's OnUpdate

vagrant lotus
opal lynx
#

What version were you using?

vagrant lotus
#

2021.1.6f1

#

fingercross my code works with 2020

opal lynx
# vagrant lotus 2021.1.6f1

oh... then some people was right πŸ˜…

I heard the other people still can use ecs in 2021 even Unity said not working

vagrant lotus
opal lynx
#

It doesn't work

vagrant lotus
#

oh no

#

bad news

#

i cant downgrade

opal lynx
#

That's okay

#

I found what you to do

vagrant lotus
opal lynx
vagrant lotus
#

oh wow

opal lynx
#

it works

vagrant lotus
#

you are awesome

#

what search terms did you use to find the answer

opal lynx
#

I can't tell you because it will seems like an advertiser here LOL

vagrant lotus
#

i want to know, but you can keep your secret

#

thanks

gusty comet
#

is there any way to set position of entity

            GameObjectConversionSettings conversionSettings = new GameObjectConversionSettings();
            conversionSettings.DestinationWorld = World.DefaultGameObjectInjectionWorld;
            conversionSettings.

            for (int i = 0; i < 3; i++)
                God.galaxyMonos[g].galaxyPopulation[i] = entityManager.Instantiate(
                GameObjectConversionUtility.ConvertGameObjectHierarchy(populationHandle.Result.prefabs[i], conversionSettings));
        }
#

i know i can SetComponentData

#

as last resort

#

but i thought there would be some parameter

#

for that

amber flicker
gusty comet
#

i see

gusty comet
#

what even is AmbientProbeTag ? its being added automaticaly with gameobjectconversionutility & instantiate

karmic basin
#

It's in the Hybrid Renderer namespace, probably for lighting calculations

#

dunno if probe lights are useful in URP, but i guess they sure are for HDRP

#

I'm not a lighting guru :p

gusty comet
#

probe light is just reflection support irc

#

so indirect light in other words

karmic basin
#

I guess its heavy ?

gusty comet
#

so youre saying that ambientprobetag == converting mesh renderer that had probes not turned off?

#

or you mean that theres a light probe component

#

before conversion

karmic basin
#

I'm not asserting anything :p not my field

gusty comet
#

oh ok

#

do you know why objects with render mesh are in same group? they have different mesh

#

maybe they just did it to not clunk the UI idk

karmic basin
#

You mean why the RenderMesh is a SharedComponent ?

#

Yeah I'll let more knowledgeable people on this field answer. But basically the Hybrid Renderer will add anything needed for your entities to be rendered by the Unity rendering pipeline yo uchose

#

You're trying to get rid of unnecessry things ?

full epoch
#

good news - timjohansson just wrote on netcode forum : "Yes, you can only have ghostfields in 128 different component types right now. The code is changing in netcode 0.8" - so although next version of the netcode is 0.7 they are planning ahead - so we do not have to worry about dots - netcode future πŸ™‚

hollow sorrel
#

yeah nothing ever goes wrong with unity planning PEPW

gusty comet
#

that create during gameobject conversin systems

#

in order to decraese amount of chunks

karmic basin
#

Well I would let the Hybrid Renderer do its thing, and focus optimization elsewhere

#

COpyTransformFromPrimaryEntityTag is surely used by the conversion system to set the transform of the entity in the destination world (?) If I would guess from the name (and you can search in Library/PackageCache to really see what happens)

#

I would be afraid to see things failing if I remove smthg I don't fully grasp

bright sentinel
#

@gusty comet @karmic basin The reason why RenderMeshes have different chunks for each mesh is because it's a shared component. Shared components group entities that have the same value. So that means all entities of the same archetype with the same mesh are in chunks together. This is to optimize rendering multiple of the same object. The reason that it's designed like this is because ECS was always designed for having many of the same archetype.

gusty comet
#

i know that

#

but it was displayed in one group in editor

distant summit
#

It was great to see a huge interest in the DOTS workshop last week. With the support of Unity team, it was nice to see the current state of production-ready and experimental features. Furthermore, it was interesting to see DOTS in action highlighting another part of this technology stack to bring more and more performance.
The recording and repo of this workshop is recently released, you can check here:
https://zt0b1t1jhdi.typeform.com/to/gJCRHuTa

slim nebula
#

oh yay that was the thing I missed wasn't it

#

cool

#

thanks

slim nebula
#

this looks really cool

#
Unity.Physics first and foremost tries to be an out-of-the-box solution and then slowly is working on exposing flexibility.

In constrast, Psyshock tries to be a β€œBuild your own solution” framework and is being designed inside-out. Over time, it will eventually achieve an out-of-the-box status, but that is not the focus. The focus is flexibility with the luxury of drop-in optimized and accurate algorithms and authoring tools.```
#

this is how I want a physics engine to be

gusty comet
#

can anyone tell me why there are two archetypes? all entities that are inside them are made in the same manner and had same components
https://i.imgur.com/gM55iuc.png
I used this

GameObjectConversionUtility.ConvertGameObjectHierarchy(populationHandle.Result.prefabs[i], conversionSettings);
#

i have some ideas why this could happen but generally a person would think there would be just one archetype.

#

unique components/tags i spotted:

  • copyTransformFromPrimaryEntityTag
  • nonuniformscale
  • translation
bright sentinel
# slim nebula this looks really cool

Super interesting! I'm personally not going to use it because it is barebones, but I really appreciate the points he raises. Especially having immutable colliders and the performance issues.

slim nebula
#

ye looks super young but I Like the nature of it

#

it really is impossible to have an out of the box physics solution. every game has it's own requirements

bright sentinel
slim nebula
#

and I like how it's more ECS oriented as far as the interface (or so he says, tho I didn't look to deep into it myself)

#

ie queries instead of the hit collectors

bright sentinel
warped trail
#

@gusty cometyou have nonuniformscale because your gameobject is scaled

#

why you dont't want to use subscene exactly, instead of converting at runtime?πŸ€”

gusty comet
warped trail
#

yes

gusty comet
#

yeah i assumed so too

#

but theres also this other tag

warped trail
#

you can process entities before loading them to main world(offsetting them for example), and there is subsections in subscene, so you can load or unload different parts of subscene(you can load different part based on distance from player)πŸ€”

sour atlas
#

as far as i understood it this is the place to ask burst related questions too, if it isnt though please tell me :b

im not quite sure i understand JobHandle.Complete();
im following this article (https://www.raywenderlich.com/7880445-unity-job-system-and-burst-compiler-getting-started#toc-anchor-001) to get into using burst and im not quite sure what happens when calling that method. does the job get forced to complete or does it force a return early if the job isnt completed ?

raywenderlich.com

In this tutorial, you’ll learn how to use Unity’s Job System and Burst compiler to create efficient code to simulate water filled with swimming fish.

#

furthermore if i schedule a job once in create that i dont need to run constantly (only once) wouldnt it be unnecessary overhead to check if it completed every update ? or does the compiler just ignore it after i dispose of it ?

gusty comet
#

and in second archetype its not there

safe lintel
#

@sour atlas it does force complete the jobs associated with that jobhandle. i assume they call it in lateupdate or something after starting the job in update

sour atlas
safe lintel
#

tbh im not sure about jobs from monobehaviour but generally you dont want to make a job in an update and immediate complete it in the same update because you can have hiccups if there are other jobs that might get force completed

sour atlas
#

oh does it force all jobs to complete ?

#

id have imagined it forces all jobs the handler scheduled to complete

safe lintel
#

well as I said im not sure about use from monobehaviours

sour atlas
#

ah, no worries.

safe lintel
#

but its easy enough to profile and see the effect of jobhandle.Complete(), worth actually doing it the "wrong" way to see the effect in action. I could potentially see it being useful in certain cases if you know you have a lot of data to process and could potentially do it faster with a parallel job with complete than doing it mainthread only

sour atlas
#

yeah well thats actually kind of what im doing id assume

#

for all practical purposes i need a gradient but as a float array so i thought parralellizing that would make a lot of sense lol

warped trail
#

@gusty cometI guess it has something to do with sub meshesπŸ€”

gusty comet
#

what is submesh?

#

theres just one mesh object

#

no child

#

is child what u mean

warped trail
#

this component is added in ConvertToMultipleEntities(...) in RenderMeshConversionContext.cs

#

you have more than 1 material on your GO

#

thats why copyTransformFromPrimaryEntityTag is added

gusty comet
#

that makes no sense

#

i see no reference to material in the name "copyTransformFromPrimaryEntityTag "

#

yeah theres 1-4 mats

#

do entities help with rendering or gpu usage anyhow?

#

or anything beside hybrid renderer

#

im also wondering if hybrid renderer v1 is improving anything or just letting GOs and entities to be rendered at same time but without improving anything

bright sentinel
#

@gusty comet So for some reason, Hybrid Renderer creates a copy of your entity for each material. That may be what you're seeing.

gusty comet
#

i think entities are not optimized for deactivation/deinstantiation, as doing that will trigger structural change/syncpoint

#

deactivation is a matter of adding/removing Disabled component = that changes archetype = moves entities to different chunks = syncpoint

#

according to this logic whether i deactivate or deinstantiate i will have syncpoints in every second, if i want to have some dynamic mechanism for eg stopping unseen entities from rendering

bright sentinel
gusty comet
#

are you referring to some not-yet-released feature

gusty comet
#

oh well, i am in bad situation then, cause unity's camera wont disable rendering of unseen entities
OR maybe it does actually..

opal lynx
amber flicker
gusty comet
gusty comet
amber flicker
gusty comet
#

yeah i toggle lot of meshes basing on distance

amber flicker
#

It's not very easy to see your sync points until you have a lot of work but the Timeline view in the profiler with Show Flow Events enabled is very useful. I believe rendering anything has a sync point - as all the transforms need to be up to date before uploading to gpu. But it's possible I'm wrong about that.

#

Are you familiar with the entity command buffers? These are buffers you use that are designed to run at dedicated sync points.

gusty comet
#

i heard about them but didnt use

amber flicker
#

That's how you e.g. destroy/instantiate/add/remove components at dedicated sync points.

#

The hard part for you will be how you store or evaluate which entities you want to change, without e.g. adding a tag.

#

One way is to use an ICD with a bool flag that you set and then check at a sync point. Another way is to simply queue an entity command buffer (which can be done in parallel + burst) that then executes at a sync point.

gusty comet
#

oh ok thanks will look into it

hollow jolt
#

how to read and modify physics* colliders ?

hollow jolt
#

thanks , any idea if its possible to read raw convex hull collider data ?

deft stump
#

what's the underlying code for transform.translate?
I want to put it in a job

hollow jolt
# warped trail https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/U...

i think i got it

unsafe
{
    var phy_collider = manager.GetComponentData<PhysicsCollider>( hit.Entity );
    //collider.ColliderPtr->GetLeaf( hit.ColliderKey , out ChildCollider leaf );
    ConvexCollider* collider = (ConvexCollider*) phy_collider.ColliderPtr;
    BlobArray.Accessor<float3> verts = collider->ConvexHull.Vertices;
    var l = verts.Length;
    var v = verts[ 0 ];
}

had to expose ConvexHull so i changed it to public

warped trail
#

but be aware that entities share same colliders

#

for example if you instantiate 1k entities and change collider like in this code, you basically changing all colliders

hollow jolt
#

interesting didn't notice this before , im looking for the vert data so i can slice them up and spawn 2 new colliders

warped trail
#

im not sure, but if you create collider yourself you will have to manage it's memory yourselfπŸ€”

hollow jolt
#

seems like convex collider makes them for us

#

ConvexCollider.Create(ConvexHullBuilder builder ...

#

that whole unsafe scope , arrow syntax which i assume are pointers and UnsafeUtility makes me wonder when my editor will start crashing

hollow jolt
#

didn't take long to show me some obscure errors

bright sentinel
deft stump
#

I like how simple it is

bright sentinel
#

Well yeah, it's just adding two vectors, there really isn't much to a translation

deft stump
#

is TransformAccessArray Persistent?

#

or temp?

deft stump
#

@bright sentinel doesn't seem to work I think.
my objects are going south

#

not where I'm pointing

#

code

[BurstCompile]
public struct RegularMoverJobTransform : IJobParallelForTransform
{
    [ReadOnly]
    public NativeArray<float2> Directions;

    [ReadOnly]
    public float Speed;

    [ReadOnly]
    public float DeltaTime;

    public void Execute(int index, TransformAccess transform)
    {
        transform.position = Translate(transform.position, Directions[index] * Speed * DeltaTime);
    }
    private float3 Translate(float3 current, float2 direction)
    {
        return current + new float3(direction, 0);
    }
}
bright sentinel
#

Well could be that your directions are wrong

deft stump
#

Or... I should rotate it

#

just realized it now

hollow jolt
#
var component_types = entity_manager.GetComponentTypes( entity );
foreach ( var comp_type in component_types )
{
  System.Type type = comp_type.GetManagedType();
  //...

Why is type.BaseType is System.ValueType and not IComponentData ? ? ? ? It result in an error when I'm trying to make a generic method like so :

  //...
  var methodInfo = entity_manager.GetType().GetMethod("GetComponentData");
  var genericMethodInfo = methodInfo.MakeGenericMethod( type );
#

That's the error I'm seeing

ArgumentException: Invalid generic arguments
Parameter name: typeArguments
System.Reflection.MonoMethod.MakeGenericMethod (System.Type[] methodInstantiation) 
bright sentinel
hollow jolt
#

actually it was working until the look reach the Child component which isn't a IComponentData

#

( Child : ISystemStateBufferElementData, IBufferElementData )

gusty comet
#

how would you use impostors with dots?

#

oh well, i guess i have to somehow convert amplify imposts to be dots compatible, or depending how it works, i may have to store impostors mesh and then just load it with dots

#

but from what ive seen its changing the mesh all the time πŸ˜›

bright sentinel
#

Never heard of impostors, what are they even?

gusty comet
#

theres few impostor assets/engines

#

i especially need it for objects that are a bit further (if not for all) from player, i hope its easily convertable πŸ˜›, will soon attempt it
if i wont be able to convert it, however, it would be ironic cus id be getting more gains from it than from DOTS.. πŸ˜›

bright sentinel
#

Oh, so billboard sprites. Well ECS doesn't really have 2D support, so I don't think you can do that

karmic basin
#

You could make quads

#

If you already have a LOD system it could be max level

gusty comet
#

theyre still rendered with meshfilter

karmic basin
#

yeah but it's only 2 triangles

#

or you could hack your way through the vfx system but dunno how much more efficient it would be

#

I would start with a LOD system, then quad billboards if further needed

gusty comet
#

im fine with rendermesh component

gusty comet
#

the asset is nice and works unnoticeable at big distance but each model data is minimum 5mb lol i wonder how much memory will it eat with 500 models..

opal field
#

does it pregenerate the images for impostering?

gusty comet
#

yeah

hollow jolt
#

how to access child parent relation in ecs ? i see there is the Child and Parent

#

but only the Parent is inherited from the IComponentData

#

and looking at one of the entities i got - it contains the child component in it

opal field
# gusty comet yeah

i guess it allows to limit the number of angles it generates and maybe their quality. that should reduce the memory footprint

#

i wonder if it does the correct angle texture selection in the shader

hollow jolt
#

Utilizes max performance using Jobs and Burst

#

how to access entity child ?

#

it doesn't like var item = entity_manager.GetComponentData<Child>( my_entity );

#

since child doesn't inherits IComponentData but does IBufferElementData instead ? __ ?

#

ah nvm i got it

var childBuffer = entity_manager.GetBuffer<Child>( hit.Entity );
foreach( var well_buffed_child in childBuffer )
{
    Entity child_entity = well_buffed_child.Value;
}

just need to use a buffer

dusty shuttle
#

Hello guys, I m actually starting using dots, I m using Unity 2020.3.8 with every package needed. I tried to create a system who manipulate a transform, but that 's doesn't work as expected lol.
I create a struct : private struct Group : IComponentData with a Transform, then in the OnUpdate I get every Entity (or GameObject) with :

        Entities.WithAll<Group>().ForEach(
            (ref Group Group)=>
            {
                var position = Group.Transform.position;

                position += (Group.Speed.Value * DirectionHelper.GetDirectionalValue(Group.PlayerInput.DirectionValue)) * DeltaTime;

                Group.Transform.position = position;
            }
        );```

But it seems that I can't get a Transform on the OnUpdate anymore, it says that transform is not primitive nor blittable.

Any idea how I can go through this difficulty ? πŸ™‚
For information, I m looking for a ECS Hybrid implementation.
jaunty herald
#

Does EntityManager.CreateArchetype() require something specific for DynamicBuffers?

#

It tells me the buffer doesn't exist on the entity, even though it is in the list of components...

sour atlas
#

hey so i have a 1d array that i need to turn into a 2d array

ideally id like to parallelise this and as far as i understand i can use a job to do that however the 2d float array is not thread safe as far as i understand and that means changing it in a job doesnt actually overwrite the actual array, is that correct ?

jaunty herald
#

Why not just remap indices @sour atlas ?

warped trail
#

@dusty shuttleyou can't put managed types in IComponentData

jaunty herald
#

Actually you can, as long as it's a class, not a struct. But it probably shouldn't be used

sour atlas
dusty shuttle
#

Alright, so what the good way do without the struct IComponentData to you guys? Thank you for your help

Seems like the Entity package works really differently than before ahah

sour atlas
#
        heightmap = new float[size, size];
        for (int i = 0; i < size * size; i++) {
            int x = i % size;
            int z = (int)(i / size);
            heightmap[x, z] = heightmapBuffer[i];
        }
        heightmapBuffer.Dispose();
        terrainData.SetHeights(0, 0, heightmap);

since the Parallel for job only takes an index i should be able to use this except as a job, but i cant override the original heightmap array from the job as far as i understand it

#

or is it possible to pass the reference to my array ?

jaunty herald
#

Do jobs support arrays now? I thought they didn't

sour atlas
#

NativeArrays only i think ? im really new to jobs so i dont have much of an idea πŸ˜›

jaunty herald
#

Yeah, I don't think they support any kind of managed array

#

Your best bet is probably using a direct memory copy

#

You'll need to make sure your array is properly aligned though

sour atlas
#

i need 1d to 2d though

jaunty herald
#

The reverse is also possible :)

sour atlas
#

oh, alright ill look into that, thanks!

jaunty herald
#

Ideally whatever is processing the array in your terrain code should use a 1d array, as it's simply faster

sour atlas
#

oh right now its being read from a render texture

jaunty herald
#

@dusty shuttle I would look at the ECS docs, they have a good introduction

sour atlas
#

which is written to by a shader

jaunty herald
#

It feels like that shouldn't be happening...

warped trail
#

@jaunty heraldi don't get this errorπŸ€”

jaunty herald
#

Very strange, it seems you aren't allowed to statically define archetype component arrays, even as a property.

#

Basically, something like this doesn't work:

public static ComponentType[] WorldCellArchetype => new ComponentType[]
    {
        typeof(SerializeEntity),
        typeof(WorldCellData),
        typeof(WorldCellNeighbour),
        typeof(WorldCellEdge),
        typeof(NetworkIdentity)
    };
#

Changing it to a field will even throw an error on compile-time

#

Never read anything about this before...

#

I guess typeof() is somehow being overwritten and only works during runtime?

#

Still not sure why a property wouldn't work then however, since that is also during runtime...

#

Not even a method works thonk

#

But inplace it works for some reason, very strange...

warped trail
jaunty herald
#

Try it as a field, it throws an error for me on compilation

warped trail
#

i declared ComponentType[] as a field, assigned it in Start method and it works fineπŸ˜…

jaunty herald
#

Very strange, your example works in a standalone project.

#

Very odd, @warped trail . Maybe I'm just missing something simple 🀷

#

If I put the array in the class itself, it works. So I assume this is some kind of static initialization / caching issue

warped trail
#

oh, maybe it has to do with this fancy fast enter playmode?

jaunty herald
#

No, I don't have that on.

warped trail
#

i remember it has some problem with statics

jaunty herald
#

It still seems like a bug. I feel like EntityManager.GetComponentTypes() shouldn't be returning types that aren't actually accessible at that time?

fallen pilot
#

Any idea how to use native array instead of native list

jaunty herald
#

Exactly like an array @fallen pilot

fallen pilot
#

I am using an A* algorithm for Pathfinding and instead of native list I want to use native arrays

jaunty herald
#

Then you need to find an upper bound for the amount of nodes in your queue / path, which is probably the reason why it uses a list in the first place.

#

Ideally, just use a list and initialize it with a high value, or replace the lists with arrays and check if the array is big enough before accessing indices. It's probably not worth it and very error prone however...

#

Since you will need to memcpy anyways if the array is too small

sour atlas
# jaunty herald The reverse is also possible :)

alright checked up on it and it seems thats not possible using the NativeArray class unless i am missing something. Itd be possible if i convert the native array to a managed array first and then use block copy but that seems like its going to be unnecessary overhead, any ideas ?

jaunty herald
#

Why wouldn't it work? Nativearrays even have a copy from / to method for managed arrays

warped trail
#

he has multidimensional array

jaunty herald
#

Yeah, convert the multidimensional array to 1d, then copy

sour atlas
#

well it does work but converting to a managed array seems unnecessary given that ill be doing 3 copies that way, likely going to be faster to just iterate at that point ?

jaunty herald
#

I doubt it, but you can just try

#

memory copy is very fast

#

Obviously depends on the sizes you are dealing with :)

sour atlas
#

hrm. depends on how fast the internal conversion is id argue

#

ill try it

jaunty herald
#

There is no conversion, it's copying memory

sour atlas
#

its relatively large at 4097x4097

sour atlas
jaunty herald
#

I feel like it should somehow be possible to create a nativearray from memory somehow, but that would probably be unsafe. Never tried it 🀷

sour atlas
#

never really managed to find out how unsafe works in unity πŸ˜›

jaunty herald
sour atlas
#

also surely it should be possible to pass a job the reference to an array and then work with that ...

jaunty herald
#

Not sure what you mean by reference to an array. Jobs cannot use managed arrays at all iirc

sour atlas
#

as far as i understood it they can but itll never overwrite the original array and instead use an internal copy or something ? but i might have misunderstood

jaunty herald
#

Hmm, haven't heard that before. But I haven't been looking either, I always just use the native collections for everything 🀷

sour atlas
#

hrm. ill just go ask a friend, they use burst a lot so im hoping they know

jaunty herald
#

Good luck! :) And let me know if you find out about managed arrays in jobs, that sounds interesting

warped trail
#

Burst documentation says "Managed arrays are not supported by Burst" and "Burst supports reading from readonly managed arrays loaded only from static readonly fields"

sour atlas
#

read it here :

Restrictions of the Native Container

You cannot pass references to a job because that would break the job’s thread safety. That means you can’t send in an array with the data you want as a reference. If you pass an array, the job will copy each element from the array to a new array within the job. This is a waste of memory and performance.

https://www.raywenderlich.com/7880445-unity-job-system-and-burst-compiler-getting-started#toc-anchor-001

raywenderlich.com

In this tutorial, you’ll learn how to use Unity’s Job System and Burst compiler to create efficient code to simulate water filled with swimming fish.

#

also where do i go to get help with unity hard crashing ?

sour atlas
hollow jolt
#

How come when I'm using

var component_types = my_entity_manager.GetComponentTypes( my_entity_target );

It contains the ChunkWorldRenderBounds type , but when I'm trying to read it with GetComponentData it throws me the following error ?

ArgumentException: A component with type:ChunkWorldRenderBounds has not been added to the entity.
#

and in the same time

entity_manager.HasComponent( my_entity_target, comp_type );

is true o_O

robust scaffold
hollow jolt
#

what's a managed component ?

robust scaffold
# hollow jolt what's a managed component ?

An IComponentData that is declared as a Class. You can place managed properties in it like strings or regular arrays. Downside is: you can not use them in a regular burst or multithreaded job.

hollow jolt
#

ChunkWorldRenderBounds is a struct

robust scaffold
#

If you dont use them, dont worry about it. Just check if it's a shared component.

#

Alright, so regular IComponentData. Then hrm, HasComponent() returns true but immediately after it says not added to entity? With the same entity?

hollow jolt
#

wait what's the difference between shared and managed ?

#

i do checks for shared components

hollow jolt
#

interesting

robust scaffold
# hollow jolt yes

The name ChunkWorldRenderBounds implies either a shared component or a chunk component. Probably the latter. Try using EntityManager.GetChunkComponentData() for that component.

hollow jolt
#

is there a way how to check if it is a chunk component or not ?

#

don't seem like its possible

#

ill try HasChunk ...

robust scaffold
# hollow jolt

Typically you know what component it is since you create the archetype. But if it's coming from HybridRenderer, no clue.

hollow jolt
#

hasChunk worked , i don't get any more errors and can finally parse the entity

robust scaffold
hollow jolt
#

thanks but approach doesn't use jobs much

#

not sure how cursed it is but it seem to do the trick

robust scaffold
hollow jolt
#

well i just need to modify the physics colliders

#

already found a way to read vertex data from the Collider Ptr with some unsafe code

#

now im trying to clone an entity

robust scaffold
#

Oh alright, good luck then. Why not use EntityManager.Instantate?

hollow jolt
#

will it copy all the component data as well ?

robust scaffold
#

Yea

hollow jolt
#

sigh ...

#

lol

#

what about the children ?

robust scaffold
#

Hrm, no clue. DOTS emphasizes flattening your hierarchy so I've never tried to see if Instantate copies children. Probably not.

hollow jolt
#

in my case i would need to modify both the phyiscs collider and the mesh vertex data which exists on 2 different entities

robust scaffold
#

Children is just a DynamicBuffer of Entities so 99% no, Instantate will probably not create a child entity.

hollow jolt
#

well it does save me a lot of efford tho

#

i can just loop them kids and glue the parent value

#
  • if using EntityManager.Instantate
robust scaffold
#

Yes it does clone children entities so long as it's using a LinkedEntityGroup dynamic buffer of entities.

hollow jolt
#

LinkedEntityGroup that;s a new one as well for me

robust scaffold
#

Honestly DOTS is an absolute mess. I dont recommend on using it unless you want to spend months doing the wrong thing until you stumble upon the correct way to code then throw the previous months work out the window.

hollow jolt
#

sounds like you suffered for some time now

#

can i dm u ?

robust scaffold
#

I've been working with dots for a few years now. Do you need something specific? This channel is good enough. It's very quiet and more public information on DOTS is good.

hollow jolt
#

~~doesn't seem to be happy when im trying to clone its children ~~

ArgumentException: A component with type:Child [B] has not been added to the entity.

~~at the second line : ~~

foreach( var child in entity_manager.GetBuffer<Child>( entity ) )
  var copy_child = Instantiate( entity_manager, child.Value );
#

nvm that i had some recursion issues

robust scaffold
hollow jolt
#

that's what i ended up with and seems to work so far

#

just need to figure out why the physics constants ( joints ) are not being cloned

robust scaffold
#

Times like this makes me regret knowing DOTS so well. I am paralyzed with decisions. I have a Company entity that issues 100 shares. These shares are distributed among People entities. Do I throw efficient chunk layout out the window and create a DynamicBuffer of Entities (Entity struct is 8 bytes wide) resulting in an 0.8 kB memory utilization. This doesnt include the numerous other Components and Buffers also attached to the entity. Already, that's a max chunk size of 20 entities or less.

#

Another option is instead store an Entity reference on the People entities themselves. That brings into question whether a Top-Down iteration process is more efficient than a Bottom-Up connection. I've done far too many tests and it's still a toss-up on that.

#

Furthermore, I am struggling with the decision to use shared components to fragment my entity chunks and use chunk components. It'll simplify a lot of the value aggregation systems for various calculations but I'm concerned with all those warnings about over-use of shared components leading to inefficient chunk utilization.

deft stump
robust scaffold
#

I have a 1000 line system where I test out various Entity hierarchy structures and data summation/aggregation systems to test performance. Very simple sum the value of 5000 entities grouped by a identifier property. I still have not attempted deliberate chunk fragmentation via shared components because I'm terrified of the warnings from Unity.

deft stump
#

God(Unity) has forsaken us

hollow jolt
#

if u r looking for optimal performance why not use something like gadot ?

deft stump
#

Gadot? or Godot?

hollow jolt
#

2nd one

deft stump
#

also no, godot isn't as performant as you think.

robust scaffold
#

If it's Godot, Godot is not performance friendly. Burst and the Job system outstrips anything out there by orders of magnitude. I'm talking about microsecond improvements via rearranging Entity component structure.

deft stump
#

compared to dots

robust scaffold
#

Anyways, I'll just post the various results I got from testing in this channel. Time values obtained from the Profiler and eyeballing the times so they're not the most accurate of values

hollow jolt
#

what about something like this https://www.youtube.com/watch?v=tInaI3pU19Y

Comparison between one of Unity's sample ECS/DOTS projects, and a "from scratch" cloned implementation using C++ and OpenGL. Bringing some data to the game engine discussions. Custom game engine vs Unity DOTS!

Unity sample project repo: https://github.com/UnityTechnologies/AngryBots_ECS

C++ clone source: https://github.com/ntcaston/AngryGL

Yo...

β–Ά Play video
solar spire
#

That's a super unfair comparison that doesn't really have much real-world impact

hollow jolt
#

but it does reach optimal performance for an edge case

robust scaffold
#

Hrm, Im not using hybrid renderer. Personally, I think HybridRenderer was a mistake.

robust scaffold
#

If you need anything done graphically that needs entities, just do it in ComputeShaders

hollow jolt
#

true it would be faster

robust scaffold
#

And roll your own solution with a bunch of arrays.

solar spire
#

Just write it in assembly and then you get all the benefits

deft stump
#

we need to go lower.
input 1's and 0's

#

write your game in binary.

hollow jolt
#

0x796573 ( yes )

#

once i get a neuralink* implant

robust scaffold
#

Anyways, the entity relationship is as follows:

Entity People
  Component int Quantity
  Component Entity Province
Entity Province
  Component int Survey
  Component Entity Country
Entity Country
  Component int Census```
Provinces sum the `Quantity` of People entities that contains the corresponding Province entity component into `Survey`. Countries do the same with Province `Survey`s into `Census`.
This exact structure changes between tests which I'll describe per result.
solar spire
#

The comparisons between different things like this do not make sense practically, that video is comparing an old entry-level ECS implementation without any acceleration from burst or jobs. It's a surface level clickbait comparison of two things with completely different capabilities, one's an ecosystem enabling fast and varied code, and the other is a specific implementation authored to do one exact thing.

robust scaffold
#

The first attempt was Bottom-Up iteration structure.
Each Person Entity used their Province entity component to query and set the Survey component using GetComponent() and SetComponent() in a singlethreaded Schedule(). The same with the Province -> Country.
Result: ~ 0.11 ms to 0.13 ms. Occasional spikes to 0.3 ms+.

hollow jolt
solar spire
#

Sure, but that's not what 90% of the people watching the video are there for

#

it's just a great avenue for complaining

hollow jolt
#

i think its a very cool proof of concept for performance

#

and click-bait ofc

robust scaffold
#

Second attempt was another Top-Down iteration structure.
There was an external NativeMultiHashMap where a first stage per Person entity ForEach would populate the native container using Province Entity. A second stage using Provinces and Countries (with a dynamic buffer of all related Province components) scheduled with ScheduleParallel() and in parallel with each other using manual dependency handling.
Result: ~ 0.1 ms to 0.5 ms depending on cache miss. Using external native containers such as NativeMultiHashMap seems to massacre performance. What I learned is to be very hesitant on using them.

#

It could be something I was doing wrong with the NMHM but the random read write parallel performance was not good.

#

Third attempt was the extreme version of Bottom Up iteration.
It denormalized the entity relationship to which the People entity would contain references to both the province and country it resided in and used a singlethreaded add to both the Survey and Census quantity of both Province and Country entities.
Result: ~ 0.13 ms to 0.5 ms in a single job thread. Definitely not good.

hollow jolt
#

quick question , when inspecting chunks in the EntityDebugger does it mean those are unique entities ?

robust scaffold
#

The fourth was a Top-Down iteration.
Each Province and Country would contain a DynamicBuffer<Entity> of the related children entities. Using a rotating buffer of Read-Write access, it queried the childs' int quantity component and summed it.
Result: ~ 0.08 ms. The best result yet. Why? I am still trying to find out.

hollow jolt
robust scaffold
hollow jolt
#

can an entity exist inside multiple archetypes ?

robust scaffold
#

It's like a Class of entity.

#

An object can only have 1 class. Multiple objects can have that same class but an object can only be of one class.

#

Unlike a object, you can add or subtract different properties to that class at runtime, resulting in a different class or completely new class. Replace all class with Archetype and that's DOTS.

hollow jolt
#

so a chunk is a list of similar archetypes ?

robust scaffold
#

A chunk is a list of Entities with exactly the same Archetypes

hollow jolt
#

ah ok

#

thanks

robust scaffold
#

It's like an array of objects. That array can only be of one class (ignoring interfaces). If you add a new component to that Entity, it must move to a different array or create a new one.

hollow jolt
#

if you add a new component type that is ?

robust scaffold
hollow jolt
#

yep

#

i think i got the jist of it

#

gonna clone them joints now

robust scaffold
#

Good luck. DOTS physics API is very raw. I'm personally holding off until the next release of DOTS packages (probably in a year or two, thanks Unity) before experimenting with it.

hollow jolt
#

its an open source engine which is good

#

mine is already slightly modified

robust scaffold
#

Good luck. I couldn't understand a single line of the source. If I ever get to the point where I need my own physics engine, I'll throw myself at the research papers of GPU side physics rather than languish in CPU hell.

hollow jolt
#

oh man that's like the dream

robust scaffold
#

I mean, how hard can it be. The GPU already has vertex data due to needing to render it. Simply do physics as well. Yea.

hollow jolt
#

there are few attempts on the web so far ( unity )

#

nothing that is stable / easily usable

#

mainly been looking at water simulations

#

but those aren't bidirectional ( it only reacts to the normal physics )

robust scaffold
#

Yea, mainly abandoned projects or proof of concepts. I mean, I technically roll my own screen based raycasting system onto a sphere but that's simple mathematics.

hollow jolt
#

there is a Gpu based raycaster repo

#

not sure if its the same as u did

#

https://github.com/staggartcreations/Graphics-Raycast

robust scaffold
#

Probably not. I display the UV of a sphere as the texture of the ball. Then sample it both to display texture in post processing and calculate clicked location.

hollow jolt
hollow jolt
#

is there a way to use Entities.ForEach outside of SystemBase and in IJob ?

hollow jolt
#

i think i found it but its obsolete .. ?

solar spire
#

It tells you what to use

hollow jolt
#

reading IJobChunk now

hollow jolt
#

not sure if im doing it right , but the amount of code it takes to do a simple search is ridiculous

    public struct JointBodyPair
    {
        public PhysicsJoint joint;
        public PhysicsConstrainedBodyPair bodyPair;
    }

    JointBodyPair[] FindTargetJointFor( Entity target )
    {
        NativeList<JointBodyPair> result = new NativeList<JointBodyPair>( Allocator.TempJob );

        EntityManager entity_manager = World.DefaultGameObjectInjectionWorld.EntityManager;

        var job = new CloneJointsJob() 
        {
            Handle_Joint = entity_manager.GetComponentTypeHandle<PhysicsJoint>( false ),
            Handle_Pair = entity_manager.GetComponentTypeHandle<PhysicsConstrainedBodyPair> ( false ),
            target = target,
            output = result
        };

        var query = entity_manager.CreateEntityQuery(new EntityQueryDesc()
        {
            All = new ComponentType[] 
            {
                ComponentType.ReadOnly<PhysicsJoint>(),
                ComponentType.ChunkComponent<PhysicsConstrainedBodyPair>()
            }
        } );

        job.Schedule(query).Complete();
        //job.ScheduleParallel( query ).Complete();

        var data = result.ToArray();
        result.Dispose();
        return data;
    }
#
    public struct CloneJointsJob : IJobChunk
    {
        [ReadOnly] 
        public ComponentTypeHandle<PhysicsJoint> Handle_Joint;
        public ComponentTypeHandle<PhysicsConstrainedBodyPair> Handle_Pair;
        [NativeDisableParallelForRestriction] public NativeList<JointBodyPair> output;
        public Entity target;

        public void Execute( ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
        {
            var value_joint = chunk.GetChunkComponentData( Handle_Joint );
            var value_pair = chunk.GetChunkComponentData( Handle_Pair );

            var data = new JointBodyPair
            {
                bodyPair = value_pair,
                joint = value_joint
            };

            if (value_pair.EntityA == target || value_pair.EntityB == target ) 
                
                output.Add( data );
        }
    }
robust scaffold
hollow jolt
#

what i need is a way to iterate all chunks of PhysicsJoint & PhysicsConstrainedBodyPair

hollow jolt
#

whenever i do dots i have an odd feeling that somebody wanted to over engineer the framework for some reason

robust scaffold
# hollow jolt as u suggested

Hrm.... yeaaaa. Such is life. I'm doing something similar because I'm trying to do some summations into a chunk component and thus have to use miles of boilerplate IJobChunk structs. Fun.

robust scaffold
hollow jolt
#

its like giving us a half baked abstraction layer for multi threading without the actual access to the low level stuff ...

robust scaffold
#

On the flip side, if you use IJobChunks everywhere, you can use ISystemBase and go all in on the structs and BurstCompile everything.

hollow jolt
#

bursting all sounds promising

#

funny i just realized the code above runs without errors but also returns zero results ...

robust scaffold
#

Kinda, the catch is that the only nativecontainer you can use is NativeArray and Entities.

#

I want to use a native multi hash map but it's so fucking hard. Why Unity...

hollow jolt
#

doing grids ?

robust scaffold
#

Nah, just parallel summation.

hollow jolt
robust scaffold
#

Burst is amazing, but also very dumb.

hollow jolt
#

lol

robust scaffold
#

Oh fuck, never mind. Hrm

hollow jolt
#

SystemState is something in dots ?

robust scaffold
#

Yea, it's the various functions available in SystemBase. Since structs can not extend anything, it's all storied in SystemState

hollow jolt
#

also i think i see why it didn't look for all the elements, but now i wonder if those arrays would be aligned or not ... πŸ€”

robust scaffold
#

Oh yea. Since you're not using a lambda function, you'll need to guarantee component alignment manually.

hollow jolt
#

O_o

#

is that even possible ?

hollow jolt
# hollow jolt

in the debug dialog those look like they are already aligned

robust scaffold
#

It is, Unity does it somehow. The Entities.ForEach() lambda function is translated to a simple IJobChunk at compile time.

#

Anything you can do with a ForEach you can do in a IJobChunk, just with a lot more code.

hollow jolt
#

i see , so i guess those arrays are already aligned

#

time to trial and error again

robust scaffold
#

Yep, that's what we all are doing. And what i'm trying to do with this.... and Unity crashed. Fun.

hollow jolt
#

rip

#

a day without a crash is a day when i didn't dig deep enough

amber flicker
#

Fyi (earlier post I saw), Instantiate can also take an array of entities - in case you don’t have a linkedEntityGroup and it correctly replaces inter-entity references- pretty useful

robust scaffold
#

Alright, this does work. Do not remove the ref anywhere. Burst will cause Unity to crash if removed.

amber flicker
#

Can you make that nmhm persistent instead?

robust scaffold
amber flicker
#

I think as long as you use a ref it’s fine?

robust scaffold
solar spire
#

Does anyone know how to schedule a NativeList.Sort after a job that uses the list? It appears to me like using the dependency JobHandle from the prev job does nothing as the unsafe pointer is accessed when Sort is called

robust scaffold
#

Or are you using struct based jobs?

solar spire
#

I am not using Entities

amber flicker
robust scaffold
robust scaffold
north bay
#

The problem is that the Sort utility expects a pointer to the data but the List could reallocate the buffer anytime you add a element to it. Your best bet is to write your own job to which you pass the NativeList and then call Sort yourself. I think someone at Unity just missed that...

solar spire
#

Seems pretty silly to have a dependency-based system you can't usefully use

amber flicker
#

that would make sense as it's the dispose sentinel I think that is the managed part of the default collections

robust scaffold
# solar spire <https://hatebin.com/ukjvjnnoni>

Hrm yea, as Script said, if you add or subtract anything to that list, it invalidates the list reference. Consider instead using IJobParallelForDefer and then rolling your own sorting algo.

north bay
solar spire
#

I'll give it a shot, thanks πŸ™‚

robust scaffold
#

Or that. Makes it simplier.

robust scaffold
amber flicker
#

Yea, it's a pain. Wouldn't it be nice if the dispose sentinel was unmanaged in the next update. Wondering how that doesn't break everything though.. guess they'll have to introduce a new collection of collections? πŸ€”

#

Might not be worth switching to unsafe but if you're measuring times of 0.08ms, I'm guessing creating the hashmap is a note-worthy part of that.

robust scaffold
robust scaffold
amber flicker
robust scaffold
#

This however seems internal and not something I can fix.

robust scaffold
#

I could add a check and then do a burst-discard to recreate the NMHM if the capacities are different.

robust scaffold
#

From 0.08ms to 0.07ms. A 12.5% improvement

#

The offset job scheduling takes as long as the job itself. I haven't found a way to reduce that other than using read-write buffers and attempting to merge the scheduling, which doesnt work with a MHM being passed between the two.

amber flicker
#

Yea, job scheduling and dependency chaining is a killer right now unless you're scheduling a tonne of data.

#

The dependency chaining is esp frustrating when nothing else changes. I Know it's cool to be stateless but there feels like so much of the same work done every frame when nothing changes.

robust scaffold
amber flicker
robust scaffold
# amber flicker That's unrelated to e.g. dependency = blah

Yea, the scheduling is questionable at times. I had a long writeup where I experiemented with entity component structures and manual dependency scheduling to get minimal job sync points. The main problem I found was the enforced "sync" point between system boundries. Jobs from one system must be finished before the next system jobs can run even if the various read-write dependencies dont clash. So turning of JobsDebugger and manually scheduling across systems was required.

#

I can understand why Unity did that. The order of systems are not guaranteed at runtime if there is no [UpdateBefore/After] tags but it would be nice if the automatic dependency handler would recognized when two jobs scheduled one after another can be run in parallel without having to manually use JobHandler.CombineDependencies().

#

I mean, if you read the documentation, it makes it seem like the automatic dependency handler is magic:

#

But if you check the profiler in practice, it's absolute shit.

amber flicker
# robust scaffold I can understand why Unity did that. The order of systems are not guaranteed at ...

I kind of agree with that (though in the context of a 'full' game or app I can see how that becomes less relevant). The part I'm talking about is the work done to a) distribute work to workers and b) evaluate those inter-job dependencies. It's the same every frame, despite often nothing changing. I understand knowing when to invalidate cache then adds a lot of complexity and it's probably smart not to have that complicate things while trying to build the core libraries.. but I hope it isn't the case forever.

robust scaffold
robust scaffold
#

All the system boundaries have giant and obvious gray gaps. Makes me feel sad.

amber flicker
#

As e.g. whether a job is running can change every frame, I think their preferred approach is currently to get burst working for everything - then if that work still happens fresh every frame it's no big deal. That probably is a better solution if it ever gets there/fast enough.

robust scaffold
#

Oh fuck, look at the time. It's almost morning. Time to sleep.

abstract flume
#

does DataFlowGraph with ECS allow doing stuff like multithreaded recursion with thread internal state?

coral nest
#

Hey! whats "dots"

low hazel
simple falcon
#

easier to read and reuse my ass

#

what a crock

karmic basin
#

It's more atomic, so yeah easier to read and reuse πŸ˜›

slim nebula
#

agree

karmic basin
#

But yeah for a new in the team who doesnt know yet all the systems....

slim nebula
#

there's def more boilerplate but... we just skim that

#

they still advertise that dotssample there tho

#

which I'm pretty sure doesn't run even with the specific version they say because their package store sends junk instead of the correct package versions when you try to load it

simple falcon
crude sierra
#

hey guys, if I have entities with collision filter in their physics shape that states "Belongs To: 24", how do I make the same collision filter in script?

new CollisionFilter
{
  BelongsTo: 24
}

doesn't work for some reason?

karmic basin
#

or maybe (uint) (1 << 24) just to be sure

crude sierra
#

my understanding here is lacking, if I want the raycast to only hit certain objects, do I specify here their layer or their collision filter?

karmic basin
#

you specify the layer

#

there's BelongsTo but also CollidesWith IIRC

crude sierra
#

so let's say I have a layermask, my collision filter should look like:

new CollisionFilter
{
  CollidesWith = (uint)HostileMask.value
}
``` ?
#

(this doesn't work either, btw 😦 )

karmic basin
#

Well hard to debug on discord, do a test in a simple scene with an easy setup ?

crude sierra
#

yes i'm doing that

#

and it should work

crude sierra
crude sierra
karmic basin
#

yup

#

All examples I've seen use Default and I didnt try filtering yet. Or maybe I did in the past but I dont remember sorry

crude sierra
#

it would make sense if collision filters referred to other entities collision filters when filtering, rather than their LayerMask

karmic basin
#

it does smthg like that with the CollisionFilter.GroupIndex

crude sierra
#

I fixed it

#

!

#
var collisionFilter = new CollisionFilter()
        {
            BelongsTo = ~0u,
            CollidesWith = 1 << 24,
            GroupIndex = 0
        };
karmic basin
#

If they are equal and > 0 they collide, if negative they never collide

crude sierra
#

had nothing to do with LayerMasks

karmic basin
#

Nice

crude sierra
#

just needed to specify the other parameters.. pff

karmic basin
#

Isn't it what I told you ? more or less :p

crude sierra
karmic basin
#

Oh I see they are not facultative :p

#

IIRC same thing if you generate collider shape from code, need at least to pass quaternion.identity if you dont need some specific rotation. Or smthg along these lines, it was a long time ago not sure I remember well

versed quest
#

Is dots stable? If not, when will it be

amber flicker
versed quest
#

Will dots support f#?

#

Natively, with functional logic, not OOP

hollow sorrel
#

no

robust scaffold
#

Reevaluating what data is actually being used and reorganizing the entity component structure results in over 50% job run time reduction

#

Solid green, it's beautiful.

slim nebula
#

that is beautiful

robust scaffold
#

Right, verified that all the values are changing as expected. Here's how I achieved that performance: Rotating read-write buffers and manual dependency handling.

#

A lot of my entities depend on the components changing in other entities. Normally, this would require GetComponent<>() and a series dependency chain. But do entities really need to know what the component value is this frame? Introducing: Read-Write buffers. Parent entities would write into a WriteOnly HashMap<Entity, Component> and Child entities would read from a ReadOnly similar hash map.

#
        private UnsafeMultiHashMap<Entity, int> _censusRead, _censusWrite;
        private UnsafeHashMap<Entity, float> _budgetRead, _budgetWrite;```
#

At the end of the frame, the variables are swapped and the write buffer is cleared. That results in a delay of 1 frame before the child entity reads and recognizes changes to the parent entity component but that I believe is acceptable since now everything can be scheduled into a single "block".

#

And strangely enough, ParallelWriter has better singlethreaded WriteOnly performance than the base NativeContainer.

#

It also somehow signals to the job scheduler to merge the GetChunksAndOffset job to run in parallel with the other jobs. Otherwise, it would schedule like this:

#

No clue why, nothing changed other than the removal of AsParallelWriter() for a singlethreaded job

robust scaffold
hollow jolt
#

how to debug inside a job ?

slim nebula
glacial bolt
#

@gusty comet @hollow jolt There's no memes or other off-topic media

hollow jolt
slim nebula
#

Not sure then. Maybe someone else knows

solid rock
#

Is 0.15.0-preview.21 a recent version of Unity.Collections?

#

I'm trying to foreach a NativeArray (not in a job, it's part of my saved game system) and getting this:

Unity.Collections.NativeList`1[T].System.Collections.Generic.IEnumerable<T>.GetEnumerator () (at Library/PackageCache/com.unity.collections@0.15.0-preview.21/Unity.Collections/NativeList.cs:661)
SadnessMonday.DiscIndustries.Data.World.SystemData.PopulateFluidBuffers (System.Collections.Generic.IEnumerable`1[T] fluidBuffers) (at Assets/Scripts/Data/World/SystemData.cs:46)```
hollow jolt
#

is there a way to find out how much data does a query holds ?

#

that's what i tried so far

hollow jolt
solid rock
#

As it is - it makes my code a bit awkward, and leaves me exposing the NativeArray directly in places I'd rather not expose it.

hollow jolt
solid rock
hollow jolt
#

how do i get existing archetypes ?

hollow jolt
#

so i tried Entities.ForEach , then* i tied IJobChunk via EntityQueryDesc but still was receiving 0 results

#

in the end i just used entity_manager.GetAllEntities(); inside mono and scanned them manually

#

which seems to do the trick

karmic basin
hollow jolt
#

When setting component data "Parent" it takes the child buffer some time before it auto regenerates, is there any way to know exactly when does this would happened ? rn im waiting for next frame to continue the operation ( yield return null inside a coroutine )

warped trail
#

@hollow jolti believe it happens in endframeparentsystemπŸ€”

remote crater
#

So... for all you guys who want premade DOTS/ECS with a hybrid reference to the player so you can move it via monobehavior scripts and keep proper design patterns, this is da bomb! http://crystalfighter.com/bin/wumbla.zip

#

I just did it for a guy who came on my stream, only took 3 hrs.

#

Its a basic project DOTS/ECS, but also the ability to touch DOTS/ECS via Monobehaviors and singletons

#

So... for all you guys who want premade DOTS/ECS with a hybrid reference to the player so you can move it via monobehavior scripts and keep proper design patterns, this is da bomb! http://crystalfighter.com/bin/wumbla.zip

I just did it for a guy who came on my stream, only took 3 hrs.

Its a basic project DOTS/ECS, but also the ability to touch DOTS/ECS via Monobehaviors and singletons.

Its totally missing documentation:
Basically the magic is in:
Movement Data Authoring Script for Data
Identifier == 1 is the only one linked.

Identifier takes the entity and shoves it in a Singleton to reference. This is because Unity Engineers in their grand wisdom can't simply link indexes to Entities so you can drag and drop GameObjects to be converted into Entities directly into Entities.

DOTS_ID_LINKER.cs is where you manually link the number to a public static Entity in GameBoardModel(singleton)

DOTS_MATRIX.CS processes the job on the Movementdata.

ProperHyrbid/playerControls.cs shows the proper data pattern for taking a player controller on an already working game, and controlling an ECS player!!!! Just do if statements for the gametype running. This is proper design pattern, instead of many functions, write one, instead of many player controllers, write one, and branch if statements based on game mode, gameObject or Entities! This is amazing!

Of course all your enemies and other things should not be in monobehaviors, but the ECS jobs... But some things reaaaaaly need Monobehavior still, like aiming your camera, etc etc, and this shows you how to do this too.

I think this is the CORE starting place for many game devs who wanted to get into DOTS but couldn't get anything to work... This has all the packages and stuff already linked which is no trivial task.

amber flicker
# remote crater So... for all you guys who want premade DOTS/ECS with a hybrid reference to the ...

disclosure: I'm heavily skeptical about this being useful or a good idea and I'm not about to download a random zip file - that said, can't simply link indexes to Entities so you can drag and drop GameObjects to be converted into Entities directly into Entities - just checking you know that if you reference a GameObject with the GenerateAuthoringComponent, it will automatically be converted to a referenced Entity. The idea being e.g within a subscene you can have references between GameObjects like normal (drag & drop). Might not be related to whatever this is but sounded like some overlap.

pliant pike
#

yeah I was going to say surely its better to use an open github or some other similar for something like this, random zips are highly risky

pulsar jay
#

Does anybody know what DotsRuntimeBuildProfile is good for as it does not seem to be used at all. The ECSSamples build configs just use the ClassicBuildProfile (or in case of BaseBuildConfig none at all)

warped trail
#

@pulsar jayits for Tiny

#

probablyπŸ€”

pulsar jay
wary anchor
#

Where do you begin trying to debug this warning? I looked at the docs but they don't help me track down the cause of the warning 😦


 at Unity.Entities.SystemBaseRegistry.CallForwardingFunction(Unity.Entities.SystemState* systemState, int functionIndex) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:307)
 at Unity.Entities.SystemBaseRegistry.CallOnUpdate(Unity.Entities.SystemState* systemState) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:346)
 at Unity.Entities.SystemBase.UnmanagedUpdate$BurstManaged(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBase.cs:464)
 at Unity.Entities.SystemBase.Unity.Entities.UnmanagedUpdate_00000F27$BurstDirectCall.Invoke(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails)
 at Unity.Entities.SystemBase.UnmanagedUpdate(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBase.cs:445)


While compiling job: System.Boolean Unity.Entities.SystemBase::UnmanagedUpdate(System.IntPtr,Unity.Entities.SystemDependencySafetyUtility/SafetyErrorDetails&)
at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:line 307
#

Oof wall of error lol

amber flicker
wary anchor
wary anchor
wary anchor
#

If only it gave even just a system to look within it would help :(

robust scaffold
wary anchor
#

Yes, it only appears on build though

amber flicker
wary anchor
#

@amber flicker nope 😦

robust scaffold
robust scaffold
# wary anchor Yes, it only appears on build though

Wait hrm, I build using Debug release because I use virtual texturing and HDRP does not properly compile virtual textures in release or master builds so no clue. Have you tried building in Debug mono/il2cpp versions? Attempt Mono first as that does not strip code.

robust scaffold
#

Unity Plz: Reinterpret method for NativeArrays.

#

GetDynamicComponentDataArrayReinterpret The fuck is this? No documentation at all but it may be what I want.

robust scaffold
#

The method's code looks fairly complex but I trust unity to have optimized it to hell and back for Burst.

#

Yea, it's what I expected it to be. Probably what is used in the generation of the Entities.ForEach code. But my god my eyes bleed looking at the giant method name.

#

In fact, chunk.GetDynamicComponentDataArrayReinterpret() has the exact same backing code as chunk.GetNativeArray(), just the type is obtained from different places.

#

And thus by the power bestowed upon me by Bill Gates himself, I say Fuck You Unity and rewrite the method name:

#
public static NativeArray<T> GetArrayReinterpret<T>(this ArchetypeChunk chunk,
    DynamicComponentTypeHandle handle) where T : struct
{
    return chunk.GetDynamicComponentDataArrayReinterpret<T>(handle, UnsafeUtility.SizeOf<T>());
}```
untold night
#

There is a Reinterpret<T> method for native arrays. No need to jump thru hoops:

var previousData = batchInChunk.GetNativeArray(PreviousCharacterCollisionDataHandle).Reinterpret<CharacterCollisionData>();

Normal ComponentTypeHandle<T> and everything

robust scaffold
#

Arg, making me get out of bed and squint at the bright computer monitor just to see if that is true...

untold night
#

it's also on DynamicBuffer<T> too. For the exact same reasons

pulsar jay
#

Does anybody have experience with creating custom build pipelines. At first it seems to be extensible as you could derive from ClassicNonIncrementalPipelineBase and build your own pipeline from a list of build steps. But then there is no way for it to be 'selected' easily as they just use an instance of the first found class derived from ClassicNonIncrementalPipelineBase

#

It looks to me like the only way to use a custom pipeline is to also create a custom build profile (IBuildPipelineComponent) and a custom BuildPipelineSelector which would be mostly copy/paste

#

It seems to be even more annoying as all the existing build steps are private. So I cannot even use them in a custom pipeline 😣

north bay
#

The post was made on the 23 April that's quite a big jump from the time of setting the forum public lol

karmic basin
#

That's a 2-sprints latency πŸ˜›

#

or anticipation, I dunno πŸ€”

amber flicker
wanton plank
#

can you use unity dots jobs with the build in renderer or is that only available to urp / hdrp ?

deft stump
#

u can

robust scaffold
#

Hrm. I can't say if half a year to annual release schedule is "landing all the time" but whatever you say Unity.

safe lintel
#

landing all the time but only gets released with the main entities package it appears

robust scaffold
safe lintel
#

id rather have frequent updates πŸ€·β€β™‚οΈ

robust scaffold
#

I would settle for even less. Someone from Unity to finally recognize DOTS existence again.

#

Also note: DynamicBuffers have terrible performance. I'm half convinced it's just a thin wrapper around a component with an UnsafeArray property.

safe lintel
#

well you got your wish, updates are really slowing down from once every other week, to once a month and now its looking to be once or twice a year

wanton plank
hollow sorrel
#

@robust scaffold terrible performance compared to what?

robust scaffold
robust scaffold
# hollow sorrel <@!262065945936134144> terrible performance compared to what?

Which is why I'm convinced that DynamicBuffers are just a fancy version of a regular component with a UnsafeList pointer property. Best practice is to avoid using UnsafeX as properties in components because they wreck the cache alignment since they're pointers to distant places in the memory and not nearby in the various CPU level cache.

hollow sorrel
#

it depends what you set as capacity

robust scaffold
#

InternalBufferCapacity(0) and a TrimExcess() on creation. Nothing in the buffer.

hollow sorrel
#

so you're not fetching any elements? just fetching the dynamicbuffer itself is slow?

robust scaffold
#

The job just checks if the buffer IsEmpty. No elements. IsEmpty is a property on the DB.

hollow sorrel
#

oh that's weird

robust scaffold
#

Well, it doesnt even branch, if or if not it IsEmpty, it returns.

hollow sorrel
#

wonder why that'd be slower than a regular component

#

btw checking if an UnsafeList on a component is empty should be just as fast as a regular component too

#

you wouldn't need to go outside the chunk for that

robust scaffold
untold night
#

it's not an unsafe list internally per-se, but it's not far off.

It'll use the internal capacity buffer list on the component itself, and then when exceeded will swap to a dynamically allocated buffer.

setting the capacity to 0 forces it to be dynamically allocated ALL THE TIME

hollow sorrel
#

yea but the length should still be a struct field so if you're just checking isempty should be the same

robust scaffold
#

Hrm yea, but I'm not adding anything to the buffer in the first place.

untold night
#

also, if you're measuring in the editor, make sure the leak detection setting is either on or off, not full.

You may also be getting overhead from the container safety checks

robust scaffold
#

Nah, it's just plain on but this is a bursted system. Leak detection is automatically off.

untold night
#

leak detection is not automatically off in a burst system in the editor

#

you have to manually disable it as a global setting

#

and DynamicBuffer is treated like NativeArray and has safety checks

robust scaffold
#

Doesnt seem to have changed anything with it off.

#

Still averaging ~0.03 per thread for doing nothing but accessing.

#

Hrm, that may just be overhead

untold night
#

they have said there's some job and data access overhead they're working on optimizing out now that burst is fairly stable.

Also the safety system currently uses managed objects at various points, I know they said somewhere they wanted to make it purely unmanaged.

That overhead should dissappear outside the editor

#

as the safety checks and additional editor overhead doesn't exist in a built player

north bay
#

Anyone knows if DOTS Netcode already supports ghost ownership transfers?

robust scaffold
#

Yea, it's the buffer access. Hm. Well, I really cant do anything about it. I need a dynamic resizable list and I would imagine Unity at least attempted to optimize DynamicBuffer rather than just porting over UnsafeList.

#

Well, technically I could go around malloc myself a fixed sized struct to use as a "list". I know FixedList<> is one of them.

untold night
#

I mean, if it's really bothering you, you could put this stuff in an ISystemStateComponent that contains an UnsafeList<T>, alloc when the ISystemStateComponent is added, dealloc when ISystemStateComponent goes out of scope.

I've played with this before and it seems to work ok. You just HAVE to make sure you clean everything up properly.

#

FixedList would work but it could bloat your component size and cause fragmentation

#

depends on capcity size

robust scaffold
#

True, although I may be going counter to best practices. I actually want boated size as I need my chunks to fragment. I'm currently using a chunk component as a "regional" bank and already fragmented my entities using a shared component so the chunk utilization is already awful.

untold night
#

ultimately the best approach may be to try all of them and measure it out.

#

ah

robust scaffold
#

Still, the performance is amazing. Memory usage, not so much.

#

Still the memory usage pales in comparison to the four 16k x 8k textures I have plastered on the screen at all times.

#

What I have to ask is: Why Unity does the FixedLists go from 128 to 512. I need more than 15 elements but not 63 of them. What's wrong with 256?

robust scaffold
karmic basin
north bay
# karmic basin You mean on connection lost ? Never saw anything about that, think you have to i...

In my case a stationary weapon that can be entered by a player who should then start predicting it.
My current approach for this has been to create a separate predicted entity that gets instantiated once a player enters it and despawns when he leaves it.
I was just wondering if Unity already allows for changes to the GhostOwnerComponent after spawn. I know that wasn't possible a year ago and I haven't checked it since.

robust scaffold
#

Nothing in the changelogs to indicate the situation has changed within the last year

north bay
#

Yea.. It's probably still determined when initially spawning the ghost

robust scaffold
#

Not good. Although I need to compare to a DynamicBuffer with size 16.

hollow sorrel
#

that's a lotta dividends

robust scaffold
#

Just slightly worse.

#

It's about 12k entities, each with a dynamic buffer of size 16.

karmic basin
north bay
robust scaffold
#

I swear I read this somewhere but a dynamic buffer containing an entity reference (entity property) will have that element destroyed when the entity it references is destroyed. All I can find is HasEntityReference on the ComponentType but nothing uses it.

north bay
#

That would be a crazy design choice and break a lot of stuff I'm doing in my code base

#

It's only the LinkedEntityGroup that destroys it members when being destroyed

robust scaffold
#

Hrm, guess not then. Huh.

warped trail
#

@robust scaffoldthere is chunk.GetUntypedBufferAccessorπŸ˜…

#

and this accessor has GetBufferLength() methodπŸ€”

deft stump
robust scaffold
#

Why is ISystemBaseStartStop Internal?

#

I suddenly realized the existance of unmanaged OnStartRunning and OnStopRunning yet Unity made it internal. Why?

deft stump
#

I should start practicing my dots again.

I haven't touched my dots project in so long

coarse turtle
robust scaffold
coarse turtle
#

Ah...that's a shame

untold night
#

ISystemBase is apparently going to be ready for use in the next release

whenever that happens to be

robust scaffold
#

Exactly, whenever that happens

#

Also, damn. My bigbrain shared component filter job scheduling is not so big brain.

safe lintel
safe lintel
untold night
#

honestly, I feel enable/disable is probably farther out than ISystemBase

#

ISystemBase implementation gets immediate gains to scheduling performance and System overhead.

They've already done a lot of the lead work by converting more of the EntityManager and EntityQuery stuff to structs instead of value types.

enable/disable is more of a "nice-to-have" that happens to have the bonus of being familiar to most existing Unity users, and it's main perf benefit is fewer structural changes & being able to skip disabled entities for processing.

safe lintel
#

the current rate of updates makes it hard for me to judge how things are shaping up now tbh

#

also the original estimation was 3weeks to 3months last year at this time(welp), im not upset that its taking longer, just that everything seems to be slowing down (from my perspective)

minor sapphire
#

Oh man same. They clearly have messed something up cadence/compatibility wise. Makes you wonder how many years it will be until we get past experimental and preview on the core, let alone the surrounding features like animation/audio/particles/vfx

north bay
#

I always wondered if it wouldn't be simpler to make a DOTS branch of Unity to begin way.
That way compatibility issues would be instantly visible when merging new engine features and the DOTS packages could be shipped in lockstep with a version they know works.

#

The release cycles have slowed down like crazy since the last year which is pretty frustrating when Unity staff tells you they fixed something but you still have to wait 4 months before you can try the fix out..

mint iron
#

agreed Script, this has been the biggest problem from my experience, matching editor versions with package versions. There is no way to know which editor you need for a specific version of the packages or dependency packages. Which works fine if you're always on the cutting edge latest version, but that's not always practical.

frosty siren
half jay
#

Does Entities.ForEach().ScheduleParallel will parallel by Chunk ?

amber flicker
pliant pike
#

is there some weird rule with EntityManager.AddComponent() that if the entity already has that component then it just picks another entity to add the component to, by incrementing or decrementing

amber flicker
pliant pike
#

yeah I don't then I must have some weird case where entityquery arrays arent aligning, I guess I'll stick to a boolean then, thanks

amber flicker
#

don't forget that if you make any structural changes (e.g. add component), queries won't return the same entities in the same order

pliant pike
#

that's probably why then

pliant pike
#

another basic question but are you only able to change components with setcomponent now

#
GridSpaceOccupied temprgid = new GridSpaceOccupied();
temprgid = tempGridocced[tompvool];
temprgid.boolValue = false;
tempGridocced[tompvool] = temprgid;```
#

you can't do something like that to set a component πŸ˜•

#

well nevermind setcomponentdata doesn't work at all either

warped trail
#

can you show more?πŸ˜…

pliant pike
#

dots really is annoying sometimes, the simplest things I cannot get to work sometimes

#

have to go to work now, will have to try and figure it out later, thanks for the offer though

north bay
#

Make sure you are not overwriting the value somewhere else

robust scaffold
#

Some good tips from Unity themselves in this thread. Even if you're not using Hybrid Renderer but still would like to profile Entities like me.

boreal bobcat
#

Hello, does anyone know what causes this EditorOnly DisposeSentinel thingy and how I can disable it? I'm scheduling a job in Update (MonoBehaviour + Burst (no ECS)). In that Update I'm also creating 2 native array which are most probably the performance hit

#

It seems like this thing only happens in the editor, hence why it's called like that lol