#archived-dots

1 messages · Page 153 of 1

safe lintel
#

look into the gpu part of the profiler maybe something is amiss 🙂

tawdry tree
#

Check also task manager

#

If the GPU isn't near 100% in any category, that is a sign of something not being right.
On the other hand, if it is 100% (somehow), then you have your answer.

deft stump
#

Oh yeah task manager... I forgot about that

#

Oooooookay....

#

I'm just standing

#

not pressing anything

#

and my gpu went 100% on it's own

#

XD

#

wait... is there a delay with task manager though?

tawdry tree
#

Shouldn't be a significant one, at least.
As in, should be sub-second.

deft stump
#

hrmmmm

#

then... AAAAAAAAAh

#

for now I'll believe whatever fraps said.
and this is me moving spamming my directional keys

#

since the min didn't go to the 30 fps range

tawdry tree
#

Fraps adds some overhead, but I don't think it uses the 3d-part of the GPU that much - it should mostly be using the video encode.
If you have a tool for that, you can check if the unity program actually changes between frames - it could very well be that your overall FPS is higher than the specific one of the game window

safe lintel
#

huh did anyone notice this before?
https://packages.unity.com/com.unity.timeline.dots

safe lintel
#

it also has a samples package(inside the package), just tested it and it works though animation spits out conversion warnings in the editor

amber flicker
#

Can you send a screenshot? Does it do anything clever or with queries etc?

safe lintel
#

yeah theres stuff done via quieries

warm panther
#

How do I process only a few entities of a certain archetype every frame? (e.g. pause a job for a while akin to Thread.Sleep etc., or only iterate a limited number of entities, and resume next frame)

I would like to spread out some o(n²) processing loads, and I'd like some kind of rolling buffer system that just updates a couple hundred per frame, instead of tens of thousands of decisions.

#

I could do it with a shared component data, but that only works for one such "buffer" builder/consumer, and it is also an abuse of that system.

zinc plinth
#

use a system just for it and keep your data inside the system as properties

#

stateful systems are really common

#

@warm panther

#

you can't stop jobs that you already scheduled, but you can spread your scheduling manually

warm panther
#

Hmmm but some of the entities might get removed etc. But I'll think about it.

safe lintel
#

could you have just a counter that forces a job to ignore any work beyond a certain count?

warm panther
#

Yeah and next frame? 🙂 And I'd still have to "return" for each entity I want to do no work for.

safe lintel
#

oh i thought this was somethign where you would destroy or remove them from the query

ocean tundra
#

@safe lintel I'm guessing 0 docs for the timeline package?

ocean tundra
#

@warm panther Throw all your entities into a native queue and then use a job to process instead of a ForEach?

#

Are unmanaged systems supported yet? I'm seeing alot of references to them in the core entities code

opaque ledge
#

nope, at least its not released

ocean tundra
#

hopfully soon

#

tho all it would give us is faster systems right?

#

also are generices completely not allowed in SystemBase?

opaque ledge
#

its, but generics are not allowed in bursted jobs

#

and yeah, faster systems, at least 0.04 ms faster 😄

ocean tundra
#

what about manual jobs? can they have generics?

opaque ledge
#

idk, never tried it, you should search in forums

#

i mean.. burst is very important for ECS, so i never tried to schedule a job without it, except when on main thread

ocean tundra
#

yea

#

well no compile errors

opaque ledge
#

it works on Editor, it wont work in build

#

in Editor it works as JIT, while in build it works AOT

ocean tundra
#

hmm

#

will make a test then

#

i think actual jobs should work

#

How do you manually Create systems?

#

Im trying to new up a group and add a bunch of systems to it

#

making group seems happy, i just have to call OnCreate before i start using the new group

#

but systems dont have a public OnCreate

ocean tundra
#

🤦‍♂️

#

Got to use World.CreateSystem instead of just creating one with new...

deft stump
#

what are unmanaged systems?

opaque ledge
#

bursted systems

#

when Unity is calling your systems there are some checks being done, this is why systems can take 0.04-0.04 ms while real job takes 0.01 ms

#

so with bursted systems we will avoid that downtime

deft stump
#

Oh...OH!

opaque ledge
#

😄

#

thats the idea anyway

deft stump
#

I want that

#

Gimme that unmanaged bursted system

opaque ledge
#

not sure if 'unmanaged system' is a thing

#

its called bursted system i think

warm panther
#

Is there an equivalent to "PostUpdateCommands" in SystemBase?

opaque ledge
#

no, you should use command buffers now, or run in main thread/without burst and use EntityManager directly

warm panther
#

Ok.

#

I now have a weird error.

InvalidProgramException: Invalid IL code in Jovian.Systems.Control.BindDummyManualAiming/Jovian.Systems.Control.<>c__DisplayClass_OnUpdate_LambdaJob0:OriginalLambdaBody (Unity.Entities.Entity,Jovian.Components.Focus&): IL_008d: endfinally
#
namespace Jovian.Systems.Control
{
    public class BindDummyManualAiming : SystemBase
    {
        private EntityCommandBufferSystem _ecbs;

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

        protected override void OnUpdate()
        {
            var batteries_and_guns = GetBufferFromEntity<EntityListElement>(true);
            var ecb = _ecbs.CreateCommandBuffer();

            Entities.WithAll<SingleTargeting>().ForEach(
                (Entity entity, in Focus focus) =>
                {
                    foreach (var battery in batteries_and_guns[focus.entity])
                    {
                        foreach (var gun in batteries_and_guns[battery.entity])
                        {
                            ecb.SetComponent(gun, new TargetProvider()
                            {
                                entity = entity
                            });
                        }
                    }
                }
            ).Run();
        }
    }
}
#

Is this nesting invalid?

#

(the error occurs at runtime)

#

creeping suspicion is that it's the foreach...

#

Ok it works with for loops. This is a tad disgusting; I don't even have Burst enabled.

#

Interesting, does AddComponent not fail if the component is already there?

#

SetComponent fails in the case there's no such component.

#

(I like it, but I'd like to have all 3 options, really)

storm ravine
#

You have burst enabled. It enabled by default.

warm panther
#

Also, it's an IL error, not a native code error.

storm ravine
#

Ah you disabled it for whole project, yep then disabled.

warm panther
#

```C:\Projects\protojovian\Assets\Jovian\Systems\Control\BindDummyManualAiming.cs(27,59): Burst error BC1037: The try construction (e.g foreach/using) is not supported

#

Yeah with Burst it rejects the construct.

#

hopefully they add that.

storm ravine
#

Yep it always was the thing with burst, only error was less user friendly 🙂

warm panther
#

I submitted a bug report, without burst it should work.

#

OR throw an error.

#

Not at runtime, though.

#

That said, I really like SystemBase, it makes the boilerplate competitive with MonoBehaviours.

#

I think they should rename EntityCommandBuffer(System) to CommandBuffer(System), because they already are in namespace Unity.Entities 🙂

#

I program on a portrait screen and man, does ECS strain my line break and indentation discipline with its long identifiers, initializers, parameter lists, and lambdas.

#

Moar Questions 🙂

#
namespace Jovian.Systems.Weapons
{
    public class PickTargetsFromProviders : SystemBase
    {
        //Aiming Entities observe TargetProviders as subjects and pick their favourite target
        protected override void OnUpdate()
        {
            var targets =  GetComponentDataFromEntity<SingleTargeting>(true);
            var lists = GetBufferFromEntity<TargetListElement>(true);
            
            Entities
                .ForEach((ref Aim observer, in LocalToWorld localToWorld, in TargetProvider provider) =>
                {
                    //Reset Aim positions...
                    observer.position = localToWorld.Position + localToWorld.Forward;

                    //Try to find targets and write fresh aim positions
                    
                    //Trivial case.
                    var target = targets[provider.entity];
                    observer.position = target.position;

                    //List case
                    //var list = lists[owner.entity];
                    // ... then do some selection math...
                    
                }).ScheduleParallel();
        }
    }    
}
#

This says "InvalidOperationException: <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.targets is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type."

#

Targets is readonly. How do I properly declare it as such?

#

Figured it out, maybe: Entities.WithReadOnly(targets)

opaque ledge
#

yep

warm panther
#

Yes system works, now to figure out why my raycast system stopped hitting stuff since the Unity.physics update x.x

storm ravine
#

I think they should rename EntityCommandBuffer(System) to CommandBuffer(System), because they already are in namespace Unity.Entities 🙂
@warm panther naming is completely fine for ECB. Moreover they already have graphic CommandBuffer in core module.

warm panther
#

Nah.

#

Then they should rename that to GraphicsCommandBuffer 😛

#

See? That's what namespaces are for.

storm ravine
#

Same naming even in different namespace inside same product - always terrible idea.

#

I maybe agree with GraphicCommandBuffer as now with entities it will be suitable.

warm panther
#

Then... Commands or something. EntityCommandBufferSystem makes me reminisce my time as a Java developer

#

I mean, My System.TimeFactory.TimeProvider.Reminisce(DeveloperProvider.Java)

#

Anyway, I'll focus more on coding and less on ranting, I'm having a good time with ECS really.

#

Thanks for your kind help ^^

lime summit
#

Hey, quick question, does Console.WriteLine() not work out of a system?

scenic oracle
#

What's the most efficient way to get Entity's data fed to Monobehaviours ?
I'm doing a massive army thing, and each unit must play animation/sound/particle/whatever depending on what they are currently doing.
My bottleneck (by a large margin) is the various GetComponentData I need to extract just to read what's the unit current status.
Is there some much faster way to exchange data between what's happenning in Entity world and apply it to Monobehaviour world ?

zinc plinth
#

how would you go about doing non-singleton inventory in dots ?

#
  • from items that are scriptable objects
#

wouldn't it need some codegen of some kind ? :/

toxic mural
#

@scenic oracle maybe .WithChangedFilter() would help

scenic oracle
#

Didn't knew about that one. Will look into it, although google doesn't seem to have much about it.

toxic mural
#

Oh sorry, its WithChangeFilter, not Changed with a D

#

Even so theres not much about it, even in the api docs

#

I think conventional wisdom used to be, if its not documented by Unity, its kind of internal and we're not supposed to use it

#

ECS is kind of an exception to that of course

scenic oracle
#

Yeah, I really wish there was some proper doc for ECS.
Especially since they change stuff constantly so the example you find on the net tend to be massively obsolete ...

toxic mural
#

I have a conspiracy theory they are keeping ECS hard to learn for now, so they only hear from devs with a minimum level of proficiency

#

and they are not wasting their time on people trying to debug their first Hello World but using ECS

scenic oracle
#

Wait, .WithChangeFilter is something you can only slap on your Entities.ForEach.
There is a way to use that inside a Monobehavior ?

#

'cause that's where I need to read the data to apply the proper response to my Animator/AudioSource/etc.

toxic mural
#

Your MonoBehaviours can access EntityManager and make calls I believe

#

I assumed you were working from Entities to Monobehaviours

#

How are you currently getting your entity data to put into monos?

#

My approach would be, create a SystemBase that schedules Entities.ForEach queries that use WithChangeFilter, so whenever an entity moves (or whatever changes), the query picks it up, uses EntityManager.GetComponentObject() to get the monobehaviour, and set the new data

scenic oracle
#

... I was probably doing this the super wrong way then.
My current setup for all my "GameObject System", is to keep a list of all the Entity that will be concerned (grabbing them during the conversion phase), and then just do a regular loop inside a Monobehavior on that, calling GetComponentData for each one to get my data.

toxic mural
#

That sounds like it would work too

#

Unless each unit is a gameobject with the monobehaviour, and the monobehaviour loops through ALL entities to find the matching one?

scenic oracle
#

It does, but it's super slow due to the GCD.

toxic mural
#

I suppose Monobehaviour.Update() is on the main thread so it could be that

#

If there are like 1000s of GCD per frame

scenic oracle
#

3000s actually. 1000 units, with around 3 different components I need to extract for everything >_<

toxic mural
#

Oh yeah that could maybe be too many

#

There is also something called liek a GameObjectCompanionSystem that I think automatically propagates changes in ECS space into a managed component, maybe

deft stump
#

Is it a DOD-way of approach to have multiple entities refer their data from a dynamic buffer that is being held by 1 entity? Sort of like having a look up table.

safe lintel
#

@ocean tundra yeah no docs(just the package manager template :D) but there are a few samples. it seems a bit crash happy and anim package gives warnings in editor but it works

#

ive honestly never used timeline so i really cant tell how far along this is or even how to use it 🙃 i should probably have learned it by now..

deft stump
#

no wait...

#

I'll just use blobasset

vagrant surge
#

@deft stump both blobasset plus looking up some entity work fine

#

tho when reading data from global-ish entities like that, make sure you grab the component data outside of the loop/job or similar

#

GetComponentDataFromEntity() is quite expensive to call

deft stump
#

okay...
so am I doing this right?
I want to set the stuff I need first in the inspector then convert it to a blobasset.

coarse turtle
#

looks right

deft stump
#

could be better?

coarse turtle
#

can't really think of any way for it to be better, it's been a while since I used blob assets extensively 🤔

scenic oracle
#

Anyone know if it's possible to execute ICollisionEventsJob in parallel somehow ?

scenic oracle
#

Or if anyone has any idea how to solve dependencies for <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.PhysicsWorld.CollisionWorld.m_Bodies.
I have several jobs that apparently use it, and I can't find a way to make all of them happy outside of having most them use .Run() - and I really need all of them to use .ScheduleParallel for performance reason. At best I can manage to get one in parallel without everything exploding, but the docs about dependency doesn't really give any examples to figure what I need to do to have everything work as expected.

lusty otter
#

Is there still no way to do NativeArray inside of NativeHashMap?

opaque ledge
#

you can use NativeMultiHashMap

#

its key -> Value[]

coarse turtle
#

or nativehashmap & unsafearray

opaque ledge
#

@scenic oracle you have to add to EndFramePhysicSystem's input dependencies, i think it should be .AddToInputDependency()

scenic oracle
#

I can't find anything about either (well EFPS has a small article confirming that it exist, but that's it), neither on Google nor in Unity's ECS/Dots samples.
Do you have any examples about that ?

north bay
#

I think it's called AddInputDependency and was added in the latest version

#

Before that you had a List to which you could add your handles

onyx mist
#

how did you guys learn how to implement save/load in DOTS? info seems scarce

ocean tundra
#

@onyx mist yea save load is annoying

#

@onyx mist Heres my save bit

object[] clientReferenceObjects;
            NativeArray<EntityRemapUtility.EntityRemapInfo> remapArray =
                world.EntityManager.CreateEntityRemapArray(Allocator.Temp);

            using (var clientWriter = new StreamBinaryWriter(worldFilePath))
            {
                SerializeUtility.SerializeWorld(world.EntityManager, clientWriter,
                    out clientReferenceObjects, remapArray);
            }
#

the issue is clientReferenceObjects will contain a bunch of Unity.Objects, things like Mesh's and materials

#

also entity names are not saved, as they dont exist at runtime, so i save those cause they make debugging WAYYY easier

#
 var allEntityies = world.EntityManager.GetAllEntities(Allocator.Temp);
            List<EntityName> entityNames = new List<EntityName>();
            foreach (var entity in allEntityies)
            {
                var targetEntity = EntityRemapUtility.RemapEntity(ref remapArray, entity);

                if (targetEntity != Entity.Null)
                    entityNames.Add(new EntityName()
                    {
                        Entity = targetEntity,
                        Name = world.EntityManager.GetName(entity)
                    });
            }
deft stump
#

since blob assets are allocated. I also need to dispose them right?
where do I dispose them gracefully?

ocean tundra
#

i guess if you can tell when your done with them just call dispose wherever

#

but otherwise im not sure

#

theres that blob asset store if your converting at runtime

#

you can dispose that on game quit or something

untold night
#

blobs allocated during conversion belong to the scene their in, no need to delete them manually if you don't need to.

Not sure about ones made purely at runtime

deft stump
#

So if I use the GameObjectConversionSystem to build my blob. It's fine if I dont dipose of them?

tawdry tree
#

Ehh, just try - you should get a warning if you don't dispose when you should?

deft stump
#

but it's persistent. I get the feeling that it wont throw me a warning because of it

deft stump
#

Oh... it does throw me an error when i play it again.

pliant edge
#

I have asked about net code in #archived-networking but this could be a better place to ser my question because of the dots!
Hello guys im trying to figure how can i connect to my server build from a client

I followed the manual of NetCode, but i ca get it working using my game as client and server,
What i want to do is to have a server build so connect from different clients,
but i am not able to figure how to do that

Also the networkEndPoint let you et the port but not a custom IPV4 Address, so i will not be able to set my server in a custom ip

the manual doesnt explain anything about server builds
just that can be done!

what i just want to do is to be able to move a cube throug a client that connects to the server, and be able to connect other clients to it and each of them move a cube

fringe sinew
#

What is the performance overhead of scheduling a job via the Run() function?

undone torrent
#

is there a way to use ecb on editor mode ?

fringe sinew
#

How much time does it take between calling Run() and having the job's burst code to start executing?

deft stump
#

from my testing... scheduling takes 0.10ms than Run

#

on run. my systems run around 0.08ms.
on job. it runs on 0.18ms.

undone torrent
#

is there a way to use ecb on editor mode ?
@undone torrent someone knows ?

deft stump
#

entity command buffer in editor?

undone torrent
#

yep

deft stump
#

not that I know of

lime summit
#

stupid question, but how the f*** do i get a mesh from code only working?

Entity bla2 = entityManager.CreateEntity(typeof(Translation), typeof(RenderBounds), typeof(RenderMesh));

        RenderMesh rm = new RenderMesh();        
        rm.mesh = new Mesh();
        rm.mesh.vertices = new Vector3[] { new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 0) };
        rm.mesh.triangles = new int[] { 0, 1, 2 };
        rm.mesh.RecalculateNormals();
        //rm.mesh.subMeshCount = 1;
        //rm.subMesh = 1;
        //rm.layer = 1;

        entityManager.AddSharedComponentData(bla2, rm);
#

the entity is there with the RenderMesh component, but bounds and mesh are not set or visible

tawdry tree
#

Do you need localtoworld or some other extra component?
Have you checked which components the render system uses?

lime summit
#

i have plugged localtoworld in also

#

and i dunno where to check which components are used/needed

tawdry tree
#

Should be in the system list in entity debugger

lime summit
#

halelulja

#

i got i

#

i dislike the random interactions in ecs

#

for meshes to render, you need the LocalToWorld (as stated int the wiki), but you also need a Translation

#

as otherwise LocalToWorld doesnt calculate its values

deft stump
#

argh... I'm so confused.
How do I go about setting stuff in the inspector first and then convert that into a blobasset?
Should I go scriptable objects on this one?

tawdry tree
#

What are you trying to achieve? Basically a prefab but in pure DOTS?

deft stump
#

are you asking me Hod?

opaque ledge
#

you could use authoring components

deft stump
#

I'm trying though... and I'm following the example from the unity's github... but ugh...

gusty comet
#

mfragger

deft stump
gusty comet
deft stump
#

what what?

gusty comet
tawdry tree
#

Yes, I was referring to you, mfragger. Yours were the most recent question.

lime summit
#

Ok, my nerves....
if i comment that one line in, the RenderMesh isnt setup. Can somebody explain this to me? I cannot add Component and sahred component Data to one entity,?

Entity bla = entityManager.CreateEntity(typeof(LocalToWorld), typeof(Translation), typeof(RenderBounds), typeof(RenderMesh));
        vd = new VoxelData() { Values = new NativeArray<float>(100, Allocator.Persistent) };       
        
      // entityManager.AddComponentData(bla, vd); 
        entityManager.SetSharedComponentData(bla, new RenderMesh {
            mesh = mesh1,
            material = mat1,
            castShadows = ShadowCastingMode.On           
        });     
deft stump
#

Well no. I dont want a prefab in pure dots.
here's the high level:
I want to set a list of stuff i want in the inspector, preferably in my spawner GO that's about to be converted into an entity.
then convert that list of stuff into a blob asset.

tawdry tree
#

"List of stuff" being...?

#

Arbitrary data? Components? Settings for known components?

deft stump
#

a struct of data.

tawdry tree
#

simon, are you saying that it if you uncomment the line, it stops working?
That does sound very strange. Have you tried creating the entity with the ICD and using set+set instead?

lime summit
#

When uncommenting that line, The RenderMesh has no mesh setup etc. and doesnt render

#

not sure what you are telling me with the second part of the sentence

tawdry tree
#

simon:

Entity bla = entityManager.CreateEntity(typeof(LocalToWorld), typeof(Translation), typeof(RenderBounds), typeof(RenderMesh), typeof(VoxelData));
//setup vd
entityManager.SetSharedComponentData(bla, vd);
entityManager.SetSharedComponentData(bla, new RenderMesh /*...*/);
#

mfragger, if its on a GO, then you should be able to (1)use a MB implementing IConvertGameObjectToEntity. That gives you full MB inspector features (including editor script if needed).
(2)In the convert you should be able to convert your data to blobasset as usual.
Am I correct in understanding that your issue lies in step 2?

lime summit
#

vd is not a shared Component, and set shared Component Data also doesnt work with nullables

tawdry tree
#

Ahh, VoxelData is a class ICD?

lime summit
#

yes

tawdry tree
#

Hmm, that might be the cause, but I have no clue why it would do that

#

The docs suggests using class ICDs is primarily for "bridging the gap" when moving from GOs, so in my own project I decided to go with a DynamicBuffer instead of that.

#

Not that that solves your issue 🙁

lime summit
#

thanks for your help

#

im so fed up by this ecs bs

tawdry tree
#

It's a possibility at least.

lime summit
#

yea , i want the class cause it only stores a native array

deft stump
#

my issue lies in step 2.
So you're suggesting in the convert method, i Just do this:

public void Convert(/*API stuff*/)
{
  BlobBuilder blobBuilder =  new BlobBuilder(Allocator.Temp);
  //The rest of the blob making process... 
}
tawdry tree
deft stump
#

Oh Holy...!

#

It worked!

#

WTF!

#

I KEPT O NWATCHING CODE MONKEY FOR A DAY!

tawdry tree
#

Out of curiosity, did you get builder to work, or did ya use the helper?

deft stump
#

I used the helper you gave me

#

well not errors though.

#

Imma see if I can read data from it

lime summit
#

now this becomes more and more akward

#
Entity bla = entityManager.CreateEntity(typeof(LocalToWorld), typeof(Translation), typeof(RenderBounds), typeof(RenderMesh), typeof(VoxelData));

        vd = new VoxelData() { Values = new NativeArray<float>(100, Allocator.Persistent),test = 1 };
        entityManager.SetComponentData(bla, vd);      
        mesh = new Mesh();
        mesh.vertices = new Vector3[] { new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 0) };
        mesh.triangles = new int[] { 2, 1, 0 };
        mesh.RecalculateNormals();
        entityManager.SetSharedComponentData(bla, new RenderMesh() {
            mesh = mesh,  
            material = mat1
        });
#

this works!

#

setting the mesh by hand isntead of using a field and assigning one

tawdry tree
#

Welp

lime summit
#

this is beyond determinism

tawdry tree
#

If nothing else you probably want to make an archetype to clean up the top part a bit...
The setting is a mess though

lime summit
#

fu 😄

#

i did nothing else today except getting this shit to run

tawdry tree
#

Well, at least progress was made

lime summit
#

i need beer now

tawdry tree
#

Whenever I get a day like that, the moment I verify it work I do the mental equivalent of flapping face down on a bed.

spark glade
#

i need beer now
@lime summit The learning curve is so steep...

#

#itgetsbetter ™️

lime summit
#

Whenver you try something new which has to fix your problem but doesnt, it feels like a mini heart attack and i feel the urge to slam my hand through the desktop

#

i will die eraly on a heart attack, im sure

#

The thing is, i dunno what i just learned Nicolas

#

why the fuck does it not work with a default mesh, but with a custom?

#

whats the goddamn relation between sharedcomponent data and an class icd

tawdry tree
#

IZ MAGICK

#

BLAK MAGICK

spark glade
#

I haven't read the full context, but my approach is usually to make a prefab, convert it (live link mode often sufficient) and make sure i generate the same components from code.

lime summit
#

im done with this for today

#

thanks for your help Hodhandr

deft stump
#

Oh okay

#

Now I'm getting native collection error

tawdry tree
#

mfragger, the not disposed error or something else?

deft stump
#

not disposed

#

it waited like a full minute and a half

#

before it threw it on me

tawdry tree
#

You need to either dispose or save the blobreference

#

I suspect you get that error when it gets garbage collected

deft stump
#

Just to be clear...
the Authoring Component gets destroyed because of the convert and destory when converting to entities right?

tawdry tree
#

If you only want to use the blobasset in the method you make it, just plop "using" in front of the variable like using var = new SomeThing(); and it will dispose at the end of the method.

#

It's shorthand for "make a using block for the rest of this scope, but without the extra indentation

#
void SomeMethod(){
  using var blobAssetReference = BlobAssetReference.Create<YourStruct>(yourStruct);
  //other stuff
  //blobAssetReference is automatically disposed here
}
//Equivalent to:
void SomeMethod(){
  using (var blobAssetReference = BlobAssetReference.Create<YourStruct>(yourStruct)) {
    //Unncessary extra indentation
    //other stuff
    //blobAssetReference is automatically disposed here
  }
}
deft stump
#

the "traditional way" also works too

#

But i need a way to dispose the blob

tawdry tree
#

How long should it live?
Just for a method, or for however long the map/scene/whatever exists?

deft stump
#

how long the scene exists

#

when I mean traditional way I mean this btw:

    public class SpawnBulletDataBufferAuthoring : MonoBehaviour, IConvertGameObjectToEntity
    {
        public List<SpawnData> spawnDataList;

        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            BlobAssetReference<SpawnDataBlobAsset> spawnBlobRef;

            using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
            {
                ref SpawnDataBlobAsset spawnBlob = ref blobBuilder.ConstructRoot<SpawnDataBlobAsset>();
                BlobBuilderArray<SpawnData> spawnArr = blobBuilder.Allocate(ref spawnBlob.spawnDataArray, 1);

                spawnArr[0] = new SpawnData { minRotation = 10 };
                spawnBlobRef = blobBuilder.CreateBlobAssetReference<SpawnDataBlobAsset>(Allocator.Persistent);
            }

            dstManager.AddComponentData(entity, new SpawnerData
            {
                spawnDataBlob = spawnBlobRef,
                index = 0
            });
        }
    }
tawdry tree
#

Ah, so using the builder manually with extra boilerplate on top

deft stump
#

if I make the reference static?

tawdry tree
#

Does it "belong" to a system (only used in particular systems?) If so, store it there, somehow.

deft stump
#

Yeah. It'll only be used by one system...

#

So make it static on that that system

tawdry tree
#

I suggest not using static

#

Use dstManager.World.GetOrCreateSystem<YourSystem>() and have a non-static field or method to register it

#

And of course you just dispose it in the system's OnDestroy
systemVariable?.Dispose()

deft stump
#

the operand ? cannot be applied.
so I tried not using that...
run and exit... And it says the BlobReference is null

tawdry tree
#

manually check if it's null then

deft stump
#

GAAAH!

#

still not being disposed

#

I'm going to sleep! I'll get this sorted tomorrow

dry dune
#

I need some help:
i have few units - entities with unit tag
and i have few "task" entities like walk, eat, say those tasks have a reference unit that has to do that Entity TaskTarget , so when i want unit to do something i'm constructing a task entity that has a link to unit and task system reacts on it, animates unit way i need, and when done task is removed by task system

so my units can walk, eat and talk at the same time, but the problem is that units can't do two similar tasks at the same time, unit can't walk to two destinations at the same time, eat something when already eating, or say something when already speaking... so each time new task is assigned i need to check if task of the similar type already assigned to the similar target, and depending on that check to cancel previous task or skip adding new duplicate before previous is finished

so the question is: what is the right way to do that check DOD way?

ocean tundra
#

@dry dune So I made a 'job/task' system for some of my units
A unit has a TastTaker component that says what tasks they can do
and a HasCurrentTask/No Tasks components
Then theres tasks in the world that my unit looks for and takes if they have the NoTask component
A task is a bunch of steps, so theres a walk to task step that moves my unit then they move on to the next step
But I dont have units that can do more then 1 task at a time

#

my inital design was full of generics for each job type, but system base destroyed all that

#

my next design (not done yet) will likly use bit fields to mark job types ect

dry dune
#

yes when there is only one task possible at a time it sounds simple, but in my case i need to allow parallel tasks if all of them have different types, also i need to store that tasks on separate entity not on unit, because those tasks may be inactive (paused, scheduled for later)

ocean tundra
#

a task category enum flag might work

#

i think your unit should have a list of tasks they are doing

#

and when you add/remove to that list you update check the flag

dry dune
#

my inital design was full of generics for each job type, but system base destroyed all that
you still can have generic jobs in SystemBase, but you need to do it using IJobChunk

ocean tundra
#

if its already set error you cant do that

#

Oooo I need to dig deeper into IJobChunk, thats also the fastest way to loop over entities right?

dry dune
#

yes foreach is converted to IJobChunk under the hud

#

i think your unit should have a list of tasks they are doing
and when you add/remove to that list you update check the flag
yes i was thinking about it,
another option I'm considering is a centralized tracker of all active tasks with a possibility to look for active tasks by target/type pair

ocean tundra
#

I wouldnt do a centralized

#

i was thinking of putting more data on my fog of war tile entities

#

so they could have a list of jobs within that tile

#

so that makes the search for new job bit faster as i can just check nearby jobs

dry dune
#

but I'm not yet sure how to implement that centralized tracker way it'll be possible to use it in a job (i'm scheduling tasks creation from a jobs)

ocean tundra
#

if you are going to centralize things, first make it a stuct, and only use more stucts and native collections

#

always pass it as ref

#

and i think you will need to store it on a system not a entity

dry dune
#

yes, sure it'll be stored on a system, and repopulated on game load

deft stump
#
    public class SpawnBulletDataBufferAuthoring : MonoBehaviour, IConvertGameObjectToEntity
    {
        //public List<SpawnData> spawnDataList;

        public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            BlobAssetReference<SpawnDataBlobAsset> something;
            using (BlobBuilder blobBuilder = new BlobBuilder(Allocator.Temp))
            {
                ref SpawnDataBlobAsset spawnBlob = ref blobBuilder.ConstructRoot<SpawnDataBlobAsset>();
                BlobBuilderArray<SpawnData> spawnArr = blobBuilder.Allocate(ref spawnBlob.spawnDataArray, 1);

                spawnArr[0] = new SpawnData { minRotation = 10 };
                something = blobBuilder.CreateBlobAssetReference<SpawnDataBlobAsset>(Allocator.Persistent);
            }

            dstManager.World.GetOrCreateSystem<BulletSpawnSystem>().spawnDataBlobRef = something;
            
            dstManager.AddComponentData(entity, new SpawnerData
            {
                spawnDataBlob = something,
                index = 0
            });
        }
    }
#

I'm still gettng the native not disposed error!

#

okay wait what?

#

I just dispose the blob at OnStopRunning. and it'll work fine

#

Okay Finally... It works now!

spark glade
#

Has anyone dug into the performance penalty of calling methods from a bursted IJobChunk?

#

I just cleaned up the Execute(..) of a IJobChunk by extracting a few methods and now I'm paranoid that there might be a performance impact 🙀

ocean tundra
#

i dont think so, as long as they follow the burst rules

spark glade
#

"burst rules"?

ocean tundra
#

you can try putting the aggressive inline attribute on it

#

like structs only

#

native containers

#

that stuff

spark glade
#

oh yeah ofc

#

has aggressive inlining actually proven to do anything?

ocean tundra
#

😛

#

no clue

#

but i see unity doing it

#

so i copy

#

and i would guess they profiled it

spark glade
#

yeah in the math lib only though, right?

ocean tundra
#

yup

#

but think ive seen it in other places

deft stump
#

so referencing the blob in an ICD seems more "safer" than passing the blob's ref to a system.

spark glade
#

Ability System Update, now with Area Of Effect :)

Propagates all effects of the ability/projectile to a radius around the cast/impact location 🔥

#

Now I have to merge that all back into my own game (or/and turn it into a unity package) 🤔

deft stump
#

aaaah finally

#

my blob now works

spark glade
unborn totem
#

does anyone know if or when the Hybrid Render will support MeshRenderer Priority? I really need it for controling the sorting of individual transparent meshes that are ontop of one another.

#

and in the mean-time, is there another way of doing it or would I have to write my own custom shader?

tawdry tree
#

Sounds to me like a shader-thing, so the shader would need to support it. If GO rendering has it by default (ie. with no packages that affect rendering), I'd expect the hybrid renderer to support it as well, though...

unborn totem
#

GO rendering does support it

#

it's an SRP thing

#

in my case, HDRP

#

There are two possibilities. There's a Shader Property that lives on the material and a Renderer property.

#

As you can see, it's not exposed, so I can't actually do anything with it with ECS as far as I know.

#

at least not with this experimental Hybrid Renderer V2 feature which allows me to set material properties without breaking the chunk system

deft stump
#

yo, converting vfx graph to entities works Yay

unborn totem
#

that's cool

#

I bet THEY have sort priorities! 💢

deft stump
#

nope

#

I'm also struggling with sorting layers with my sprites

unborn totem
#

ah, dang

spark glade
#

yo, converting vfx graph to entities works :Yay:
@deft stump are you using hybrid component with an authoring component? Or just inside a prefab?

deft stump
#

no. I just Convert to Entity it

cursive cosmos
#

I need some tips when working multi threaded.
Is there a way to have a system go through a players location, add coordinates to a list and then loop through that list and fill in which coordinates are missing?
I'm basically trying to make a world chunk spawning system which will work in a fully DOTS manner and only care about players position and the viewing distance for said player.

#

I'm afraid that if I would try to have lists of spawned chunks and change said list it would work badly with multi threaded code. So how would I best store this list of already spawned chunks?

wanton apex
#

Hi, first post here.
I'm trying to instantiate one player per connected device for local multiplayer. So I want to instantiate player based on Prefab. It works, but when I disable Burst Compiling, I get a lot of error comming from the BlobAsset. Does somebody know the right way to use ConvertGameObjectHierarchy ?

        foreach(var item in devices)
        {
            //Entity e = World.DefaultGameObjectInjectionWorld.EntityManager.CreateEntity();
            //GameObjectConversionSettings settings = new GameObjectConversionSettings();
            var blob = new BlobAssetStore();
            var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blob);
            Debug.Log(settings.BlobAssetStore);
            var e = GameObjectConversionUtility.ConvertGameObjectHierarchy(playerPrefab, settings);
            DeviceType type = item is Gamepad ? DeviceType.GAMEPAD : DeviceType.KEYBOARD;
            World.DefaultGameObjectInjectionWorld.EntityManager.SetComponentData(e, new InputComponent
                {
                    InputID = item.deviceId,
                    Device = type
                });
            var player = World.DefaultGameObjectInjectionWorld.EntityManager.Instantiate(e);
            World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(e);
            blob.Dispose();
        }```

I don't understand what I have to do with the blobasset
#

I have lot's of random crash too, is the package instable? I'm using the last version with Unity 2019.4.1. LTS. I did'nt worked with ECS since January, and it looks more instable now. Is it my code or does the package is currently in an instable state?

deft stump
#

okay ahahaah

#

I think I'm pushing what I can do with my system

spark glade
#

I think I'm pushing what I can do with my system
@deft stump same for me. I'm instantiating too many prefabs in a single frame occasionally. Need to figure out how to use the batched calls with "unknown" content.

deft stump
#

@spark glade oh you're spawning too much stuff in a single frame too. XD.
and what do you mean batch calls?

#

Ah I see... Batch calling ECB...

#

@spark glade hook me up if you got that working.

spark glade
#

I'm thinking queuing up a few jobs. One to group by "prefab id", one to allocate, one to instantiate, one to prepare component data, one to clean up. Or maybe just shove it all into one job.

#

Might actually use EntityManager directly, because I'm not sure if ECB does have batch methods. 🧐

#

My alternative is to just jitter the cooldowns of my units by a frame or two, so that the archers just don't all shoot in the very same frame 🙃

#

When ECS gives you lemons, make them a feature 😏

deft stump
#

for me I shoved the instantiate and setting the ICD, since the ICD is already pre-added, into one job.

#

but wow, instantiating 1 stuff, setting their data, then repeat that 100 times is a huge block of an operation

#

I'm looking into ExclusiveEntityTransaction for just my Instantiation.

cursive cosmos
#

Isn't the whole reason you use systems so that you should not do it within a single frame?

deft stump
#

you mean my instantiation system?

cursive cosmos
#

well, DOTS systems in general

toxic mural
#

I dont suppose when you are instantiating/setting data you are having to wait for some resources access? Like maybe reading from disk or unpacking an asset?

deft stump
#

no.
the prefab is already an entity.
I just need to refer to it when I want to instantiate it to the world.

#

Isn't the whole reason you use systems so that you should not do it within a single frame?
@cursive cosmos it depends though... if it's a very large calculation then yes you want to spread it on multiple frames.
but for me, it's a bullet hell game. I need lots of stuff on that frame the moment I need them.
Plus with EM being the thing under ECB's hood, I'll eventually have to go back to the main thread.

cursive cosmos
#

Wait, so what you need is to not instantiate them, you need to move them, no?
You need a buffer of already spawned things that you instead move 😄

deft stump
#

What?

#

um...

#

I tihnk we're not on the same page

cursive cosmos
#

Didn't you say you had a problem spawning these bullets into the view every frame?

deft stump
#

Yes. The problem is it's a giant blocking operation on the main thread.

cursive cosmos
#

Wouldn't it be better utilizing object pooling instead then and let the system only handle the moving of said objects?

deft stump
#

I have a separate system that handles the movement.

#

My instantiation system just spawns the stuff and sets their ICD. It doesn't move them.

cursive cosmos
#

okay, but does it spawn stuff mid game?
As in instantiate the entities?

deft stump
#

during OnUpdate? Yes

cursive cosmos
#

uff, that's rough though, you should probably try object pooling.

deft stump
#

Object pooling in ECS... hrmmmmm... honestly never tried...

cursive cosmos
#

should work just the same, since instantiating the entities might be way heavier than just keeping most of them on screen in a deactivated state

#

worth a try at least if you really want a shit ton of objects on screen

deft stump
#

I do want a shit ton of objects... It's honestly not a bad idea.

cursive cosmos
#

I used it for one of those block breaker games that had a ton of balls spazzing around on the screen, worked quite well performance wise

deft stump
#

when my bullet reaches it's end-of-life... I just transport it back to the spawn point.

cursive cosmos
#

yep, hide it out of line of sight and deactivate any animation or even any visual aspect of it

deft stump
#

I'll also stop the spawner system from spawning too once the first bullet reaches the end-of-life

amber flicker
#

Just to say... pooling isn't much of a thing in pure dots (can try and track down Joachim's post on the forums if interested). You should probably only think about pooling if you have a bunch of managed components like pfx etc.

#

on a desktop you can instantiate in the order of 1 mil pure ecs prefabs in 1ms I believe

deft stump
#

that's also what i thought.
since the prefab is already in memory.

#

I can just create copies of that prefab

amber flicker
#

yes... though you want to be using the batch methods wherever possible

#

.Instantiate(nativearray) is many times faster than N times Instantiate(prefab)

deft stump
#

so I'll have to EM it rather than use ECB to instantiate

amber flicker
#

yea - which I don't think should cause you any issues?

deft stump
#

no issues. Just more rewrites

amber flicker
#

🙂 yea, know that feeling

cursive cosmos
#

oooh, didn't know about the batch methods 😮

#

So really what I should be doing is putting all my entities in a native array after creating them and instantiating them in that manner

deft stump
#

But you are making a sync point with that method

#

For me. Since the movement sys is so efficient, it dont really mind syncing.

amber flicker
#

you pass an empty array to instantiate with the capacity of the number of entities you want to instantiate- it then does a batch memcopy afaik and sets that array to point to that block - it really is very fast

undone torrent
#

what is the diference beetween WithNativeDisableContainerSafetyRestriction(myvar) and WithNativeDisableParallelForRestriction(myvar)

#

i understand disableparallel but i dont know what is new on WithNativeDisableContainerSafetyRestriction(myvar)

spark glade
#

you pass an empty array to instantiate with the capacity of the number of entities you want to instantiate- it then does a batch memcopy afaik and sets that array to point to that block - it really is very fast
@amber flicker That's only on EntityManager though, isn't it?

My issue is that I have a list of mixed prefab entities to be instantiated in one frame. [EnityA, EnityA, EnityB, EnityC, EnityA, ...]

Does it make sense to have a bursted/parallel job to group these, then a WithStructuralChanges job to use the batched entitymanager methods to instantiate the respective arrays and then another job to set the respective component data?

foggy tree
#

Can someone explain me why if the only systems accessing the buffer, are readonly, it is marked as changed with the withChangeFilter? Am I missing something, or what is wrong with this?

ocean tundra
#

@foggy tree So WithChangeFilter applies to the whole chunk

#

not just that 1 entity

#

so that entity is probably fine, buffer isnt changing

#

but another entity in that chunk is having its buffer modified

storm ravine
#

@foggy tree GetBufferFromEntity(ReadOnly) not affect version bumping for chunk, it's only for safety checks. Accessing indexer for BufferFromEntity works different in comparison with ComponentDataFromEntity. It bumping change version even if you just access buffer, as under hood it uses (BufferHeader*)m_EntityComponentStore->GetComponentDataWithTypeRW which in turn uses ChunkDataUtility.GetComponentDataWithTypeRW which in turn bump change version chunk->SetChangeVersion. in other words - just accessing buffer from BufferFromEntity bumps chunk version always. ComponentDataFromEntity works different as it bumps chunk version only in setter. And BufferFromEntity itself haven't setter at all.

foggy tree
#

There is just 1 entity :/ @ocean tundra

#

@storm ravine so what options do I have to read a buffer randomly without triggering withchangefilter?

ocean tundra
#

Oh dam I didnt know that

storm ravine
#

@foggy tree with BufferFromEntity - no way

ocean tundra
#

that must be a bug/oversight?

storm ravine
#

This is not bug, this is how it implemented currently and will be improved

foggy tree
#

Well, I wasn’t expecting this behavior. I did multiple systems thinking this wouldn’t happen 😦

storm ravine
foggy tree
#

@storm ravine thanks. I’m glad I discovered this and found your help before relying too much on this

#

@ocean tundra also thank you

storm ravine
#

If you don't want change your logic and continue to use BufferFromEntity, as simple dirty workaround you can have simple ICD with bool\byte field and use ComponentDataFromEntity setter when you want trigger change on chunk with that buffer type entity and use WithChangeFilter on that type instead of buffer.

foggy tree
#

Yes, that’s exactly what I’m going to do for now. Thanks a lot

storm ravine
#

Also, what purpose of your logic with change filter on buffer in your case (just in abstract description)? Explain your case, as maybe it require different logic.

foggy tree
#

Is just an inventory, and the UI just re draw the buffer if something is modified.

But as you said, with a component for knowing for any changes can work, also I can put more data telling me “how “ it changed

#

Also need chage filter on buffer to calculate weight and volume of the content

storm ravine
#

Yep in that case ICD workaround will be fine

#

Also keep in mind when you destroying entities\removing components it wouldn't bump ChangeVersion on chunks

coarse turtle
#

I wonder if ChunkUtility.GetComponentDataWithTypeRO would work in getting a buffer from BufferFromEntity without changing the version 🤔

foggy tree
#

Also keep in mind when you destroying entities\removing components it wouldn't bump ChangeVersion on chunks
@storm ravine I'll do it, thanks

storm ravine
#

I wonder if ChunkUtility.GetComponentDataWithTypeRO would work in getting a buffer from BufferFromEntity without changing the version 🤔
@coarse turtle problem here not in GetComponentDataWithTypeRO \GetComponentDataWithTypeRW itself as difference is only chunk->SetChangeVersion between them. Problem is how DynamicBuffers implemented in chunk layout currently. By BufferFromEntity you getting BufferHeader* pointer and it's not direct data access in chunk and only used for constructing DynamicBuffer initial memory offset which as result gives you data like native array (in simple words) which is exact data, ComponentDataFromEntity in opposite give you straight reference to exact memory where final data accessed and you can handle it directly in getter setter by just simple reading writing from\to this memory. And after constructing DynamicBuffer in current implementation you can't guarantee that you access it only for reading (this is what their comment mean in this case // TODO(dep): We don't really have a way to mark the native array as read only.) and this is why it RW by default and as result bumping chunk version. But again it's just current implementation and TODO allude changes in that area.

coarse turtle
#

o cool - yea that would make sense

storm ravine
#

And WithChangeFilter still usable when you don't need access it by BufferFromEntity but by in in ForEach, operating through different ECB commands. Especially after adding AppendToBuffer for ECB. Or when you create new buffers, or wrapping BufferFromEntity indexer access in some conditions etc.

ocean tundra
#

hey guys, is it possible to call C++ code (a native dll) from inside a job?

#

Using things like DllImport?

#

Usecase is, I'm using ENet which is a native dll. but looking at the code, alot of it is structs and pointers but with a class based wrapper around it
Was wondering if i could bring it all into the JobSystem for MORE speed!!!

coarse turtle
#

hmm doesnt unity's transport layer use native c bindings

#

if it does you can probably do the same for your own C++ code 🤔

ocean tundra
#

Unity Transport is what i 'should' use but it feels so clunkly atm

coarse turtle
#

iirc they had native bindings that you would include into the project/build

#

I'm pretty sure you can call your own C++ code from job systems

#

if that was the case for transport layer

ocean tundra
#

yea i think transport does have native bindings of some sort

coarse turtle
#

yea - might as well try to include native calls into a job system 👀

#

i'd be interested to see if it works 😅

ocean tundra
#

its all still idea phase for that bit

#

im not sure if i need the performance of moving it to job system yet

#

its already in background threads

#

i need to put better profiling around all these bits so i can tell where the performance issue's are

coarse turtle
#

you could try using VTune to profile the built game

ocean tundra
#

that looks intense

#

i was thinking more about getting automated tests working then profile those

#

probably using the built in profiler

coarse turtle
#

yea that's reasonable

ocean tundra
#

wow unity gets REALLY unstable if your not disposing native collections

deft stump
#

It does

ocean tundra
#

thats what i get for being lazy i guess

deft stump
#

Its a good thing unity is running in node js or we'll have to restart our pc

ocean tundra
#

what?? unity isnt in node??

deft stump
#

what ? unity isn't running in node?
then why do I see a nodejs server running in the background whenever I open unity....

ocean tundra
#

oh thats just the package manager stuff

#

they built their packages on npm packages

deft stump
#

Tf

ocean tundra
#

personally i think they should have used nuget, but as their packages are all source code i guess it makes sense

deft stump
#

when will unity make us batch install packages? sadriba

#

it's a pain in the ass to update your packages 1 after the other...

ocean tundra
#

yea its a pain

#

but also i much prefer to update 1 at a time

#

if i update a bunch and my game dies, which 1 did it?

zinc plinth
#

I wonder what would a burst vs c++ benchmark would look like

#

would almost expect burst to be faster on some stuff ThinkMan

mint iron
#

there's been a forum thread with benchmarks for it, burst can be faster, if C++ isn't compiling as well.

gilded coyote
#

is there a way to query for entities, within a collider?

ocean tundra
#

kinda

#

you can use a collision job to get a callback on a collison

#

or you can use the physics world and do a *cast of some sort

#

finally i think you can use the physics workd and access the collisions there somehow

ocean tundra
#

Is there anyway to log a JobHandle?

#

I'm 99% sure im setting up the handle correctly but as theres a few different worlds involved and i have to copy things around i think its not set right

#

dam this struct vs class, ref thing does my head in

deft stump
#

it's what we get for coding in preview stuff. our brains hurt

ocean tundra
#

haha yup

#

job handles are finally starting to make sense tho

tawdry tree
#

A job handle is a magical work order - you get it when you tell someone (the DOTS systems and jobs) to do something, and you can use it to check if they're done.
You can also give a bunch of job handles to someone else to tell you when all of them are done, and you can pass them around so that people know when they should begin their work, if they need others to finish first.

ocean tundra
#

yup

#

much like the C# async/await task system

tawdry tree
#

it's pretty much the same, but more fit for purpose for high-performance games

ocean tundra
#

tho 1 question, is it ok to keep doing jobhandle.CombineDependencies

tawdry tree
#

Well, minus async/await. Definitely tasks, though.

ocean tundra
#

yup seems more light weight

tawdry tree
#

What do you mean "keep doing" combinedeps?

ocean tundra
#

ummm

#

how to explain..

tawdry tree
#

Combine deps, and then use the result to combine with something else?

ocean tundra
#

i have system A that sets a jobhandle to jobhandle CombineDependencies(old handle, new handle)
Then system B CombineDependencies with that into its dependancy, then schedules its job, then sets that origional dependancy to another combine

tawdry tree
#

Combining deps should be pretty much dirt cheap

ocean tundra
#

oh and system a has that merged with its dependancy

tawdry tree
#

Here system B should probably use AddInputDependency or what it is with system A

ocean tundra
#

i thought about that, but AddInputDependency is something you need to code yourself and 2 they are in different worlds

tawdry tree
#

Ah

ocean tundra
#

so a system should not have access to a system in another world

tawdry tree
#

Wait, how do you make them cooperate over different worlds anyway? And why?

#

Temporary worlds?

ocean tundra
#

no perm ones

#

so server client worlds

#

server builds up a list of messages and 'pushes' those messages to the client

tawdry tree
#

Because otherwise that seems like bad pattern.Different worlds should probably not have deps on each other, unless something like the physics world

ocean tundra
#

in this setup both worlds exist on the same instance as the player is hosting and playing

tawdry tree
#

Ideally you would still want to have them communicate as usual over TCP/IP

ocean tundra
#

yea they will

tawdry tree
#

Just using localhost insted of WAN or internet

ocean tundra
#

but no point doing that when self hosting/single player

#

as theres a cost to serialize the data too

tawdry tree
#

But you need that cost on the server for multiplayer anyway?

ocean tundra
#

for dedicated hosting this wont be a issue as a client world wont exist

#

im aiming to not have dedicated hosting

#

so players host their own games

#

like old rts games

#

so a host is likly a player too

#

(also i relise that was a bad example as rts games were mainly lockstep)

tawdry tree
#

Well, if you have one player who runs both host and client, and the serialization needs to happen anyway (for other players)...
Why make the local player communicate differently from everyone else? The deserialization cost should be miniscule compared to everything else.

ocean tundra
#

maybe your right

#

but what happens when there is no network connection for a pc?

tawdry tree
#

having two methods of communication means two sets of potential bugs

ocean tundra
#

also most rts games are mainly played singleplayer

tawdry tree
#

Even with no connection to the wider net, as long as the computer has the hardware for internet (which in modern times means any motherboard - wireless support not needed), you'll be fine.

#

localhost (127.0.0.1) is a special IP that short circuits the normal routing, but going to the local internet controller, and immediately returning, no inet required.

#

If they have a router, they can use the local WLAN IP to connect to themselves as well as other people on the local are network (LAN).
And if that router is connected to the internet, you can connect outside the LAN.
Program <-> PC network hardware <-> local router <-> the internet™️

#

If you're making a networked game and you're not familiar with how the internet is built, architecture-wise, I advise you to look up the basics of the internet and routing.

ocean tundra
#

it still feels wrong to have a network connection for single player

tawdry tree
#

Many games do it, it's not wrong

#

It's more correct than making a special case for local client ^.^

ocean tundra
#

maybe

#

but i still want to get this working

#

as a quick memcopy seems way better then a whole serialization network flow

#

plus im pretty sure i got it 😛 just need to confirm those job handles wont explode

#

also i have a usecase where i want lots of client worlds

tawdry tree
#

Still only serialize once, so more clients just make my argument stronger 🙂
Well, making it work is more important than making it "correct", so do that first, and if/when you later find that having two methods of communication means extra maintenance and bugs you could look into using just network.

undone torrent
#

Is there a way to use isharedcomponentdata like archeotypecomponent on ijobchunk ?

#

or this is going to crash

#

cause i am getting error when i tried to getNativeArray

#

i just want to get isharedcomponentvalue on chunk

#

thats all

#

so maybe getnativearray is fool i think cause all have samevalue on chunk

tawdry tree
#

Where are you trying to do this?

#

Because jobs have all sorts of restrictions on managed code such as nativearrays

undone torrent
#
   [BurstCompile]
  struct VertexSampleJob : IJobChunk
  {
      [ReadOnly] public ArchetypeChunkComponentType<ProjectionVertex> vertex2;
      [ReadOnly] public ArchetypeChunkComponentType<ProjectedOccluder> archetypeChunkComponentType_occluder2;


      public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
      {
          var vertex_aux_array = chunk.GetNativeArray(vertex2);
          if (chunk.Count > 0)
          {
              var vertex_aux_ = vertex_aux_array [0];
          }
          
      }

      
  };
#

i am getting error while try get nativearray

#

cause syntax is not right

#

Projection Vertex and Occluder are sharedcomponents

#

so i guess there may be other way to get them that i didnt see

#

solved , docs were right xd

mystic mountain
#

It worked with the buildconfigs before, but this time I had to download com.unity.platforms.windows, and it gives me this.

tawdry tree
#

Whyy.... are you making nativearrays, filling them, and then disposing them, all inside the Entities.ForEach?

#

How about declaring and initializing, as well as disposing them outside the ForEach?
Then you can use dispose on complete?

deft stump
#

I dunno! XD

#

I'm just trying things out. And wow my internet is derping me

tawdry tree
#

So my first impression was "wow, block of code. Consider splitting up"
And now that I somewhat think I understand it... Yes, still think that.
Ideally I think it should make the arrays of stuff to spawn, and then spawn either using entitymanager or a separate ECB job, but with that inner loop you suddenly have unknown size...

deft stump
#

well in reality (for now). It's only running the foreach once since it just returns my 1 and only spawner entity.

tawdry tree
#

Maybe use NativeList? Pretty sure NativeArray also automatically resizes on add.
The unknown size here stings, though. You effectively have a 2d collection. No idea how well native collections handle that, but NativeArray<NativeArray<RelevantComponentData>> could work. Or just straight up ECBing it.

#

SpawnerData spawnData here is a collection (DynamicBuffer?) with individual values for each thing it spawns?

#

The entire system (non-ECS meaning) seems like it might benefit from a architectural re-thinking. The way you do things here should maybe theoretically work, but I can't find any ways do to it that doesn't do bad patterns, bad practice, or is bad for performance...

deft stump
#

SpawnerData is an ICD with ref to a blob and an index

#

yeah I give up

opaque ledge
#

What are you trying to do ?

tawdry tree
#

if you're just spawning a certain amount of things, you could do:

  1. Get spawner info
  2. Spawn the things in batch
  3. Possibly randomize the things' ICD values that should be randomized
    where #3 could be done completely separately. So you could spawn all of the things with literally the same ICD values, and some other system (or job) would the randomize the specific values that should be randomized.
    less control at design-time, I suppose, but ehh. Fudge it till it looks and feels good.
deft stump
#

okay I give up on my first attempt

#

lemme show code in here since somehow I'm only able to connect to discord...

undone torrent
#

is there a way to execute a job after ecb complete creating entities ?

deft stump
#

so what I'm trying to do is speed this system up.
looking at my profiler.
if I became too ambitious with this system.
it's a huge main thread block.
What I was trying before was batch spawn and batch set the data of my bullets.

undone torrent
#

is there a way to execute a job after ecb complete creating entities ?
@undone torrent
i.e. job1 ..... AddJobHandleForProducer(job1) ..... job1.complete .... job2 ..... job2.complete

#

job2 is executing before new entities are created, i mean ecb didnt finish the sync point

amber flicker
#

@deft stump there's a unity dots demo somewhere that spawns bullets - wonder if that might be worth tracking down. You can likely make this faster by having a job that just calculates the number of bullets to spawn. That said, how do the 'SpawnerData' components come to exist? Could you instantiate at that point?

mint iron
#

@deft stump yeah its probably not good to instantiate every bullet individually. Is there an overload for batch creation/instantiate in ECB you can use? or you could split it up into a creation system with a tag attached in the prefabs to signify and 'uninitialized' version - which lives somewhere sync-point friendly and just uses EntityManager to batch create. Then another system that can set the data with ECB for every entity with a customprefab tag + uninitialized tag, and remove the uninitialized tag once components are set (should just be an archetype change and so fast). If you have really large numbers you could even use an Entityquery after processing all, to batch remove the uninitialized tag.

deft stump
#

Internet is back

#

Now then...
@amber flicker What do you mean come to exist?

#

@mint iron I'm actually doing that... hold on lemme show it to you...

#

Okay... giant code block, I know

#

I also had to put it in the initialize group.

amber flicker
#

what I meant was how/when are you creating those spawnerdata's?

sharp lance
#

Can I put materials/textures into Asset Bundle? Currently I have all assets inside Resources folder but it's more than 4GB and Unity throws exception

deft stump
#

@amber flicker aaah.
so inside that ICD is a reference to a blob. So I make the blob during conversion, then take the referrence of the blob and assign it to the icd.

amber flicker
#

Ok I see - so e.g. 'how many bullets of what type' kind of config? The code you posted looks to me like it'd be a lot faster - does it work? have you compared?

deft stump
#

it works. i haven't tested the 1K bullets per 0.5 seconds

amber flicker
#

I'm a bit confused though.. if the spawnerdata is created at conversion time, couldn't all these entities too? Or is there some additional event or something?

deft stump
#

what you mean all these assets?

#

like the bulletprefab?

#

it is being converted.

#

here's the components of my spawner entity

amber flicker
#

what are those components on?

deft stump
#

it's on my spawner entity.

amber flicker
#

are these bullets spawned on some event presumably? Like a key press?

deft stump
#

no.

#

in that screenshot.
1000 bullets gets spawned every 0.5 seconds

amber flicker
#

I see

deft stump
#

this is how long EM with CopyFromComponentDataArray spawns my 1K bullets.

amber flicker
#

with burst enabled and safety checks off? that's stupidly long

deft stump
#

safety checks off, jobs debugger off, leak detection off

amber flicker
#

burst on? think that job should say bursted if it is

deft stump
#

burst on of course

#

but it's EM though

amber flicker
#

debug log's or something? is that a bunch of gc there too?

deft stump
#

yup!

#

the reds are gc

amber flicker
#

what from?

deft stump
#

I dunno!
it's gc'ing stuff while it's spawning stuff

amber flicker
#

hmm.. bit hard to remote debug... all I can say is that looks wrong if you're dealing with pure dots stuff. Do you have any particlesystems or mono stuff?

deft stump
#

nope

#

and here's the ECB version

#

like wow

#

I want to know if EntityTransactionManager might help

#

but I dunno how to use the API properly

amber flicker
#

you need to work out what's going wrong first - take a look in the hierarchy view and find the stuff with highest gc

deft stump
#

uhmmmm there's literally nothing in there worth noting

amber flicker
#

the profiler's hierarchy view

deft stump
#

aaah hold on...

#

5K calls!

amber flicker
#

are you doing 5k x 1000 bullets?

deft stump
#

no

#

it's 1K bullets per 0.5 sec

#

expanded it more

amber flicker
#

how about the non ecb version that you pasted the code to earlier?

deft stump
amber flicker
#

what's in Instantiate.Awake?

deft stump
amber flicker
#

that looks odd to me... don't know if anyone else here can shed some light. I would check that a build attached to editor still looks the same.

deft stump
#

maybe because I'm really pushing the instantiate to the limit

amber flicker
#

what does the bullet prefab have on it?

deft stump
mint iron
#

burst on of course
but you're not using it 😄

#

its an interesting setup you've got i havent seen that approach before with CopyFromComponentDataArray

deft stump
#

yeah EM version won't burst it ofc

#

wait... can I?

mint iron
#

but this is why i said two systems, the second stage that sets the data can go in normal ForEach burst/parallal if you want

amber flicker
#

wait isn't systembase burstcompile by default? or is that only lambdas? I thought em.instantiate with batch was burst compatible

mint iron
#

its only in the lamdas, foreach or Jobs.WithCode

amber flicker
#

ah

mint iron
#

but now that you mention it, he can probably put his for loop in a Job.WithCode

amber flicker
#

@deft stump try adding [BurstCompile] above your system

mint iron
#

or did they release new entities with entire systems bursted? maybe im on old info

amber flicker
#

I don't know why the non-bursted one would have so much gc anyway...

tawdry tree
#

Doesn't his code use a ton of NativeArrays?

#

Those are managed

deft stump
#

so [BurstCompile] my EMversion.

mint iron
#

might want to look at the source for CopyFromComponentDataArray it probably has a waited job for each one.

deft stump
#

Oh it didn't crash. hahaha. but its lagging so hard.
restarting the editor!

mint iron
#

and yeah use persistent NativeList system fields and resize instead of new allocated arrays

deft stump
#

isn't it faster to just allocate the arrays specifically?

mint iron
#

no

deft stump
#

whaaat. okay okay... Imma profile the burstcompile one first. then do a branch to replace all the arrays into a list.

mint iron
#

ToComponentDataArray also has a job inside each one and allocates new arrays

#

gotta get rid of all that stuff imo

amber flicker
#

the point about the nativearray being responsible for the gc may be true but I don't think it would take this pattern? Unless there are many spawners. I could be wrong though

deft stump
#

it's just 1 spawner, just to be clear

amber flicker
#

or so you think... jks 😄

deft stump
#

ECS magick, your spawner has now multiplied, good luck garbage collecting

mint iron
deft stump
#

alright so here's the bursted version

#

at this point, I'm just laughing

amber flicker
#

how big's your project? I could take a look if you share it. Also - what Unity version, entities version etc?

deft stump
#

well there's lots of music assets in the project. but they're not being used.
they're just sitting in the project folder.
hell there's literally only 1 scene!

unity ver: 2020.1.0b12
entities ver: latest
hybrid ver: latest
burst ver: latest
jobs ver: latest
unity phyics: latest

#

hold on. lemme push it to github. I have to get rid of lfs and all that stuff too

zinc python
#

I made an MainAssembly.asmdef file in my Assets folder and added Unity.Entities as ref, but I'm getting errors that IConvertGameObjectToEntity and GameObjectConversionSystem can't be found.

#

all the other Entities stuff works

#

I'm on 2020.1 with the latest Entities package. Any ideas?

amber flicker
#

think you might need to add Unity.Entities.Hybrid perhaps? that's from memory but check the namespaces if not sure

zinc python
#

What's the easiest way to figure out what's in what namespace

amber flicker
#

I use find in VisualStudio's ~~project ~~ solution explorer - don't know if that's the easiest

zinc python
#

gotcha thanks

tawdry tree
#

When using asmDefs you need to add references to the assemblies you use - for DOTS this means each of the packages.

#

In general I just add Entities, Jobs, Burst, and Collections to any AsmDef using DOTS. If using physics or renderer, add the relevant ones. And of course link to any of your own assemblies you use.

amber flicker
#

yea... though from memory I think the Unity.Entities.Hybrid is a bit of an odd one out as most top level asmdefs tend to include their children

#

For those following along, I think we tracked down mfragger's issue (though waiting for confirmation) - Bullet prefab has a Sprite Renderer

lime summit
#

just a quick question, is there anything up with debugging dots?

#

my VS and unity keep crashing on a tiny projekt with 1 system when trying to debug it

#

setting a breakpoint inside some entities.forech loop seems to be ultra broken

amber flicker
deft stump
#

Im gonna try it out in ECB version first

lime summit
#

"havn't bothered myself" ?! you are not using the debugger?

north bay
#

2020.1.0b6 always crashes when i start debugging and the newer versions don't even start for me so all my debugging consists of Debug.Log like back in the days in which i didn't know what a debugger is.

coarse turtle
#

i just do print line debugging 👀

safe lintel
#

@amber flicker i would assume hybrid being separate is for tiny right?

amber flicker
#

Yea that’s what I assume too

lime summit
#

print line debugging is like going back to a motorized beer crate, when being used to drive a damn maserati

#

sure, it gets you to the goal, but heck, my time is not that worthless

#

(close though)

amber flicker
#

It’s only recently become possible to use the debugger with bursted stuff and in general I’ve had a very crashy time using VS debug with Unity. Most of the time these days I just use .log. It’s personal pref but crashy combined with hopping around jobs on threads makes stepping pretty unpleasant imo. Maybe one day I’ll learn to use the vs thread debugger stuff properly but I don’t believe I’m bottlenecked by that of all things 😁 - the speed of my brain is my main issue

lime summit
#

i have no understanding what you guys are doing when you are not using the debugger

#

yes, i am a noob and oversse obvious things

#

but the debugger is on the same level than udnerstanding what a type is

#

its super essential

#

print line debugging is no comparrison to being able to check the stack trace

#

or seing what is called when etc

amber flicker
#

Print line does give you the stack trace...

lime summit
#

yes, but you cannot step through the stack trace and chek the locals while executin is halted

#

you have to recompile and start playing over and over and adapt the outpu

#

in comparrison to simply clicking through the paused code at the exact right moment in time

#

you are doing the same stuff just 100x slower

amber flicker
#

I’ve done it both ways. Imo debug log is just as fast in 90% case. Anyway.. pretty sure this is up there with tabs and spaces so... I’ll leave it there.

lime summit
#

if your debugging things which are not written by yourself without the debugger, then its like comparing tabs with whitening pixels by hand

tawdry tree
#

For simple stuff, print line works fine, but if you have a more complex "I need to find out why I get result Y when I expect X for what should be inputs ABC", being able to step through your code is greatly helpful.
And as simon says, debugging code you have no written. I would even extend that to code you haven't worked on recently.
A semi-complex class you haven't touched in a month? What did that do again?
There are habits and styles of code that makes print line debugging easier or harder, though - large chunks of code with more than the most basic complexity quickly become very hard to reason about using just print lines.

lime summit
#

Simon says:
use the debugger! (but not with the current Unity/dots version as its broken af)

amber flicker
#

I don’t disagree strongly. I will just add that this kind of thing often comes along with a programmer elitism I dislike - and I don’t think people should feel like they’re an inferior programmer over this kind of thing.

tawdry tree
#

I think everyone working on a language that supports it, with an IDE that supports it, should know how to use a debugger and step through code.
But like print lines, it's just a tool - and while it can be extremely useful in some cases, it can also be way overkill, or straight up the wrong tool for the task at hand.

toxic mural
#

I have maybe a 30% success rate getting breakpoints to hit, and not stall, and not crash when I try to inspect something, so Debug.Log is kind of the only option

#

I literally have to maneuver my mouse around certain things soas not to accidentally inspect-on-mouseover, its nuts

safe lintel
#

the entire editor freezes(and is non responsive) when hitting a breakpoint with rider debugging so debug.log has been my goto as well.

radiant sentinel
#

hi, i got this error

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

im using HLOD at hybrid renderer. how can i handle it?

safe lintel
#

on the topic of debugging... "aline" by the same guy who made astarpathfindingproject allows for gizmos in burst and ecs

#

arrows are kinda hard to see because im palletizing my colors(also gif) so it should look more legible than that in a normal project

ocean tundra
#

@safe lintel Do you have a link to that project?

#

aline thing?

safe lintel
#

its an asset on the assetstore so its not free unfortunately

ocean tundra
#

i have the a* pathfinding project which that says uses it

safe lintel
#

i saw that, could probably dig into the code and use the methods from it but i thought personally worth giving the full thing a shot

ocean tundra
#

are they both compatable in the same project? im using a* for my pathfinding

safe lintel
#

i would assume they are but I havent tried it

#

i kinda wish he would make a pure ecs version of astarpp. i own a copy but Im using unity's builtin just because its slightly faster to enter play mode with

ocean tundra
#

so the latest betas are all burst and job system under the hood

#

getting some crazy speed ups

#

and things like his local avoidance have been rewriten too

#

but its still not super easy to interface with from ecs

#

as things like paths are classes

safe lintel
#

its kind of sprawling and huge, just from looking into things it feels like it could be better organized but this is also my selfish desires for pure ecs pathfinding 🙂

ocean tundra
#

yea there is ALOT of code there

#

i probably only use like 20% of it

#

1 maybe 2 graph types

#

and i need to rewrite the graph scanning bits so it tests in the unity.physics world and not the default stuff

#

and i never use any of the movement scripts, i just manually get a path and do my own thing with it

safe lintel
#

I used aipath but did have to make fairly extensive modifications. sometimes I wonder if i should just bite the bullet and take a real good stab at learning unreal(or less so unreal but learning c++)

coarse turtle
gusty comet
#

@wary anchor yo i was looking if anyone had a shot into making poisson surface reconstruction in unity and saw you question a year ago, did you manage to get it working?

wary anchor
#

Good grief, I can't even remember what I asked!

gusty comet
#

its about building a mesh from a set of 3d points

wary anchor
#

ahh, I may have done but I can't remember because I ended up ditching that and raymarching my scene instead, so now I have 0 verts 😄

#

Sorry

gusty comet
#

damn, the struggle continues

#

thanks haha

wary anchor
#

💪 GL

warm panther
#

How do I instantiate an entity as a child of another entity? Is that even safely possible (given all the other things, like LinkedEntityGroups, etc...?)

#

I've tried adding child and parent components so far, to no avail.

opaque ledge
#

you should add child to parent's child and LinkedEntityGroup buffer

#

and add the parent to child's Parent and LocalToParent components

warm panther
#

Yech.

#

😄

#

I need to write a streamlined system for that.

opaque ledge
#

idk, i just use ecb 😄

warm panther
#

ah I think they're all buffers, right?

#

well other than the components that go on the child

opaque ledge
#

Child and LinketEntityGroup are buffers, Parent and LocalToParent are components

warm panther
#

Ok I can write those relatively safely.

foggy tree
#

Guys, if I group all my systems with structural changes within a system group, and update it just before EndSimulationEntityCommandBufferSystem, am I effectivelly avoiding extra sync points and so having just one at the end of the SimulationGroup?

ocean tundra
#

yea i would think so

#

why not just use the command buffer tho?

foggy tree
#

but the group doesn't affect in any way?

#

there are a few systems that I require to perform actions at that moment, because it is faster than sheduling to a ECB

ocean tundra
#

as long as nothing in the group is scheduling jobs it should be fine, if you schedule a job and then do something that forces a sync point that will be bad

foggy tree
#

oh perfect, that's what I wanted to hear

#

thanks

ocean tundra
#

what are you trying to do tho?

#

usually being able to do a bunch of work in the job will win out even with the ECB being a bit slower

foggy tree
#

one system is a spawner, but it spawns multiple entities, so I use a nativeArray

#

for everything else I try as much as posible to use ECB

ocean tundra
#

yea thats a tough one, as with low number of entities ECB is probably better, but spawning tons the batch apis are best

#

there needs to be a batch ECB

foggy tree
#

what is that? (sorry If I dont understand all terms used in this context, I'm new to both ECS and unity ECS haha)

ocean tundra
#

ECB = entity command buffer

#

batch apis i was talking about the entity manager apis that use native lists/arrays

#

and was saying that unity should make a batch version of ECB

foggy tree
#

oh yeah, I think the same, actually I wrote the system thinking it does exists, but then I realize it doesn't haha

#

But is ok this way

#

there are not a lot of systems with structural changes, so I dont think it is a problem

deft stump
#

and was saying that unity should make a batch version of ECB
that's why I horrendously tried to convert my spawner system from ecb to em.

#

just to use the batching system

ocean tundra
#

if it becomes more of a issue you could look at exclusive entity transaction (or something like that)

#

allows 1 job to do structural changes

deft stump
#

but doesn't that "lock" the EM into one thread?

ocean tundra
#

yea i belive so

deft stump
#

so for my case, I can't do multi-threaded spawning.

ocean tundra
#

but having 1 job doing all your spawning is still good

#

better then blocking the main thread

deft stump
#

eh. true.

ocean tundra
#

i think the spawn scale would have to be huge to make it worth it

#

probably like 10k + entities

deft stump
#

kek... I might need it

ocean tundra
#

😛

deft stump
#

crap... I dont have nitro anymore :notlikethis:

ocean tundra
#

i feel its one of those things to look at when your profiling and trying to get all the speed

deft stump
#

is it just me, or I can't seem to find platforms ios on my package manager

north bay
deft stump
#

soooooooooooooo

#

EM version spawn time of 1000 bullets in 0.5 seconds.
and properly using rendermesh...

#

is now 2.46ms!

#

:dab:

safe lintel
#

thanks @coarse turtle

deft stump
#

this is actually massive improvement

spark glade
#

nice!

#

I gotta do the same :/

deft stump
#

just not using sprite renderer and using render mesh.
even when ECB is slow.
And I might gain more perf from using EM batching,
it's massive difference

opaque ledge
#

There is a EM batching ? 👀

deft stump
#

there is. I posted the code before on my implementation

#

sadly there's no ECB batching

#

😔

unborn totem
#

Damn, I tried placing my Entities closer/further away from the camera hoping that would fix my draw order problem, but it seems like the Hybrid Renderer is still drawing certain entities ontop of others despite the distance to the camera

tawdry tree
#

That sounds rather strange. Are you using orthogonal view? Special shaders?

unborn totem
#

orthoganal view, yes

#

no special shader

#

it's an HDRP unlit shader

tawdry tree
#

Well that's trippy

unborn totem
#

that big line of holes there should have roof tiles, for example

#

but they are being drawn underneath tiles that are further away from the camera

tawdry tree
#

Any particular reason why things are build 3D with orthogonal view?

#

Just trying to convince it to do the ordering you want?

unborn totem
#

as opposed to just working in Unity 2D?

#

These are 2D graphics on flat planes that face the camera at a geometric angle, most people would refer to it as isometric graphics

tawdry tree
#

In the gif they don't seem to be on a flat plane. I am familiar with isometric 🙂

unborn totem
#

each "tile" is its own flat plane

tawdry tree
#

But the gif is very confusing to look at, probably because of that ordering

unborn totem
#

yes, it only looks good at a very specific angle

#

or it would, if the graphic draw order was happening correctly

tawdry tree
#

With orthogonal camera the distance to camera doesn't matter, so they could be on the same plane, but eh.
Sidenote: Are you using "plane" shapes for the tiles? That's a lot of extra polygons compared to "quad"

unborn totem
#

no, they're quads

#

my gif is just trying to show that my geometry is closer to the camera, but the draw order doesn't seem to care

#

here's another

deft stump
#

that's really trippy

unborn totem
#

it's like that sidewalk art that looks cool, but only at a very specific angle

#

anyway, I don't know if this is a bug with the hybrid renderer or what

#

my unlit shader is transparent

deft stump
#

I think I hit the limit of ecb destroying 10,000 stuff.

tawdry tree
#

Could those particular tiles have a priority or something which overrides the normal distance priority?

unborn totem
#

what kind of priority? I am aware of the "Sorting Priority" that exists on HDRP shaders and "Render Priority" that exists on Mesh Renderers

#

but I've never seen any evidence that the Hybrid Render pays attention to either of those

#

in either case, I haven't changed those values

tawdry tree
#

I am not familiar with those kinds of things, but looks like an override to me. What if you remake the offending tiles from scratch?

unborn totem
#

what do you mean by an override?

tawdry tree
#

It overrides draw order. Why, and on what basis, I have no clue. But it does not do what you'd expect from the default behavior. Thus, override.

unborn totem
#

i restarted the editor and now it's different tiles where it's happening

tawdry tree
#

welp

#

Does it happen with perspective mode on the camera?

unborn totem
#

yes

#

almost makes me feel like something is going on during entity conversion that messes with the draw order

#

i'm using GameObjects and sub-scenes to do the entity conversion

#

yeah if I hit re-import on the sub-scene it produces different results

#

the flashes are when I re-import the sub-scene

tawdry tree
#

wat :o
I think we need someone who really understands this to find out WTF.
Though you can probably bug-report it - if not directly a bug it's unwanted behavior

unborn totem
#

yeah I may make a specific forum post about it.

#

it's almost like the order the entities are being created matters or something

#

I don't have direct control of that when I let subscenes do it for me

#

and if I "Edit" my subscene (which shows game-objects in scene view), the entity draw order goes really crazy in my Game View

#

thanks for talking with me about it

unborn totem
#

here's what it looks like when it's "just GameObjects" and not entities, so yeah definitely think it's something in the Conversion process maybe

#

i think I'll isolate just this building and make an example project out of it

#

I also noticed that when I deleted my other subscenes that were converting 2 million GameObjects into Entities it stopped being inconsistent and now consistently draws the same tiles out of order no matter how many times I re-import

tawdry tree
#

So now it's at least consistent in it's bad behavior!

unborn totem
#

yeah, it's also much less obscene than it was too

tawdry tree
#

But also, holy crap, maybe consider merging some of those to not 2 million GOs/entities?

unborn totem
#

only certain parts are drawing incorrect

#

no deal, I'm using ECS so I can keep every tile separate from one another. 😉

#

and so they can be moved individually at runtime if I want

tawdry tree
#

That's... I'm not sure if that's the proper use case for this, but I mean... if it works...?

unborn totem
#

each sub-scene has 10,000 GameObjects

#

I am pretty sure mega-city was something like 6 million gameobjects

#

when a sub-scene converts it to entities, the GameObjects no longer exist in memory

#

ah it was 4.5M mesh renderers for MegaCity

tawdry tree
#

That's a crazily optimized sample (by people who deeply understand and even built the system), though

unborn totem
#

well, yes, I'm relying on however Sub-Scene gameobject conversion works

#

the 2 million entities run really well even when I render them all simultaneously

#

it's just the draw order that's a problem

#

i should try manually making my entities again sometime and see if that makes a difference

#

i do like the idea of the sub-scene workflow, though

deft stump
#

question... how do I know if a component is a shared component in the entity debugger?

amber flicker
#

@unborn totem might be worth checking that the renderbounds etc are all different on the converted entities- it looks like all pieces may have the same pivot point from the model for example

deft stump
#

@amber flicker you're right. it's my sprite renderer that's making it lag so much

#

and gc'ing it to no end as well

amber flicker
#

2ms still sounds far too long btw 😅😜

#

But it’s progress

deft stump
#

now then... how do I assign a material in a job

unborn totem
#

well, I changed my material to Write to the Depth buffer and turned on Alpha Clipping and it seemed to fix almost all of my problems

#

I swear I tried that before

deft stump
#

Unable to access the managed method `object.Equals(object)` from type `Unity.Rendering.RenderMesh

#

???????

unborn totem
#

still doesn't look like it's fixed all of them, though

deft stump
#

okay so now I'm trying to solve this...

#

that random bullet flickers in that spot

#

I'm guessing because the entity is spawned there first before I set it to the correct spawn point.

amber flicker
#

Yes - either make sure the spawn system finishes setting pos/rot before the transform system or you can manually set the ltw (for the first frame) (I prefer the former)

deft stump
#

welp I put it in the beginSimCommandBuffer.

#

and kek spawning 1000 bullets per 0.5 seconds takes 0.001ms

amber flicker
#

I don’t know if all of it is on the main thread - I suspect it’s taking a bit longer (you can click on the job to see total time) but that sounds more like it!

deft stump
#

FINALLY!

#

NOW I CAN BE AMBITIOUS!

tawdry tree
#

I WILL SHOW YOU TRUE BULLET HELL!

amber flicker
#

Hahah... that first taste...

storm ravine
#

but doesn't that "lock" the EM into one thread?
@deft stump this is why EET used in separate world which wouldn't lock your main world EM and didn't stuck logic and only synch when you MoveEntities from which is very fast. This is how built-in subscenes streaming works.

#

About ECB. EM batched operations of course fastest thing as I described it many times (And ECB has it partially for adding\removing components, destroying entities (EQ version of batched operations), but not for Concurrent version). But don't forget that ECB chain playback now fully goes through bursted codepath, and it gives huge performance improvement, even with sequential commands processing.

warm panther
#

Yesterday, I spawned a few entities from a converted prefabs with point lights on them. (for a muzzle flash on a bunch of cannons)

Normally the lights don't work (Hybrid Renderer V2) ... but I had them in for my authoring workflow anyhow (and for when I figure them out)

But then they did work! And it looked great!

I wanted to verify that I didn't spawn a gameobject instead or something... and then the lights stopped working again.

Now I am back at square one and can't get point lights on entities to work. -.-

#

Anything specific I need to do to a Light Component (monobehaviour) to convert it to an ECS component that acts as a light?

tawdry tree
#

Can you even do that yet?
Convert and inject would do the trick, but of course then you'd still have the gameobjects

warm panther
#

Yeah it's kinda weird. The objects were also removed so they definitely were tied to the entity TTL component I use.

#

I had a convert to entity system on it, maybe I had it set to inject... but somehow I doubt it.

opaque ledge
#

do you have any disabled components in your gameobject ? that sometimes stops monobehaviour (and Unity components) converted properly

deft stump
#

what does blobassetstore do?

#

or... what is it under the hood?

celest oyster
#

Has anybody run into this error while serializing/deserializing the world:
InvalidOperationException: The BlobAssetReference is not valid. Likely it has already been unloaded or released.
IndexOutOfRangeException: Index 1065297994 is out of range of '2' Length.

    {
        EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        using (var writer = new StreamBinaryWriter(_savedWorldFilename))
        {
            SerializeUtility.SerializeWorld(entityManager, writer, out unityMappingTable);
        }
    }

    public void DeserializeWorld()
    {
        World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(World.DefaultGameObjectInjectionWorld.EntityManager.UniversalQuery);

        if (unityMappingTable != null)
        {

            World localWorld = new World("local world");

            var transaction = localWorld.EntityManager.BeginExclusiveEntityTransaction();
            using (var reader = new StreamBinaryReader(_savedWorldFilename))
            {
                SerializeUtility.DeserializeWorld(transaction, reader, unityMappingTable);
            }

            localWorld.EntityManager.EndExclusiveEntityTransaction();
            World.DefaultGameObjectInjectionWorld.EntityManager.MoveEntitiesFrom(localWorld.EntityManager);
        }
    }```
Hopefully it's okay to ask here. I tried on the forums but a mod took it down.
deft stump
#

Okay soooo...

#

I have an new problem...

#

same problem as the guy above. The BlobAssetRef has been released.

deft stump
#

wait... I got past that now...

#

wait wtf

#

there's 4 of them!

#

Oh I got it to work now

mint iron
#

what was the issue?

deft stump
#

I used convserionsystem.CreateAdditionalEntity instead of conversionsystem.GetPrimaryEntity

celest oyster
#

I think I need to remap the entities after deserializing?

safe lintel
#

a mod took it down? what was their reasoning?

celest oyster
#

Not sure. It had the little glasses icon that said mod review and then it disappeared. I don't have any messages or alerts about it.

safe lintel
#

anyway did you manually dispose any of the blobassets before you tried to serialize your world?

celest oyster
#

I am not directly using any blobassets in my script. Stack trace looks like it's coming from the collision world Unity.Physics/Collision/World/Broadphase.cs:749

#

I have also tried disabling the SimulationSystemGroup during serialization but I still get the same error

#
MoveEntitiesFromInternalAll(EntityManager srcEntities, NativeArray<EntityRemapUtility.EntityRemapInfo> entityRemapping);``` same problem as well. This is making me think the problem started before trying to move to World.DefaultGameObjectInjectionWorld.EntityManager
safe lintel
#

oh, i seem to recall disabling physics when I was experimenting with this

#

yeah quick check i had this in my save test system

    private static void TogglePhysicsSystemForSaving(bool enabled)
    {
        var x = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<BuildPhysicsWorld>();
        x.Enabled = enabled;
    }
#

might be related

celest oyster
#

It was a good thing to try, but not it.

    {
         World.DefaultGameObjectInjectionWorld.EntityManager.CompleteAllJobs(); 
        TogglePhysicsSystemForSaving(false);

        if (unityMappingTable != null)
        {
            World localWorld = new World("local world");

            var transaction = localWorld.EntityManager.BeginExclusiveEntityTransaction();
            using (var reader = new StreamBinaryReader(_savedWorldFilename))
            {
                SerializeUtility.DeserializeWorld(transaction, reader, unityMappingTable);
            }
            localWorld.EntityManager.EndExclusiveEntityTransaction();
            CleanUp(); 
            World.DefaultGameObjectInjectionWorld.EntityManager.CopyAndReplaceEntitiesFrom(localWorld.EntityManager);
        }
        TogglePhysicsSystemForSaving(true);
    }

    public static void CleanUp()
    {
        var ents = World.DefaultGameObjectInjectionWorld.EntityManager.GetAllEntities(); 
        foreach (Entity e in ents)
        {
            World.DefaultGameObjectInjectionWorld.EntityManager.DestroyEntity(e);
        }
    } ```
I just don't see where I'm affecting BlobAssets in my code. 🤔
safe lintel
#

any component data that contains blobassets, physics uses them for colliders

#

could just be a bug that needs to be reported 😉

deft stump
#

alright... I have a new problem