#archived-dots

1 messages ยท Page 208 of 1

ocean tundra
#

@shut hare yup

#

Your missing the add job handle bit

#

Would be amazing if unity could make that more automatic

#

System.AddJobHandleForProducer

#

After your foreach

#

Pass in Dependancy

#

But also your using run, you don't need a ecb. Is that cause your testing?

shut hare
#

I'm just trying to figure things out man ๐Ÿ˜„

ocean tundra
#

Yea I get that

shut hare
#

oh i see, i wanted to start without the multithreaded bits it feels easier i thought this line was for the jobs workflow

ocean tundra
#

Ecbs is for jobs

#

But even single threaded they are faster

#

As unity can group all your changes into one big execute

shut hare
#

Sadly it doesn't seems to work ๐Ÿ˜ฆ

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

            Entities.ForEach((Entity entity, in DespawningEntity despawningEntity) =>
            {
                ecb.DestroyEntity(entity);

            }).Run();

            system.AddJobHandleForProducer(Dependency);
        }
ocean tundra
#

It should

#

Maybe just change run to schedule

#

Are you sure your creating that system?

shut hare
#

I'll try that, yeah like this

destroyDespawningSystem = ECSWorld.CreateSystem<DestroyDespawningSystem>();
ocean tundra
#

That's not quite enough to get that system running

#

You'll also need to add the system into a update group

#

Sorry can't help more, g2g. Good luck

shut hare
#

np man thx

dark cypress
#

Is there a way to modify the prefab entities?

#

I want to initialize some data on startup.

#

I must use a system and not the conversion pipeline, because I need many systems to do their own initialization based on what component there is on the prefab.

pliant pike
#

you could convert the data so it's easier to modify

dark cypress
#

Figured it out. .WithEntityQueryOptions(EntityQueryOptions.IncludePrefab)

pulsar jay
#

How can I write to a native queue from multiple threads? As far as I have seen I cannot use AsParallelWriter again when another system is already using a parallelWriter. So I cached the parallelWriter and even added manual dependencies to the systems so that the reader depends on all the writers and completes the combined writer handles before reading. But I still get this error: "The previously scheduled job HitVFXSystem:OnUpdate_LambdaJob0 writes to the Unity.Collections.NativeQueue"

pliant pike
#

I don't think it's possible with a nativequeue

pulsar jay
# pliant pike I don't think it's possible with a nativequeue

From what I have found so far that seems to be the case. If I understand correctly the NativeQueue can be written in parallel from a single job and not multiple jobs. I suppose this is due to the necessity for the writing order to be deterministic?!

#

What I am trying to do is basically building a custom command buffer to spawn pooled VFX effects. It would be great if it was possible to just extend the ECB. Or maybe NativeStream will work for that usecase?

pliant pike
#

why would you want to extend the ecb, do you mean you want to extend its length of running time?

pulsar jay
#

No I am trying to have custom commands

#

You could also call it command or message queue

#

In this case they just use a Dictionary but its obviously neither threadsafe nor burstable

#

but this does not work as soon as more than one job is writing to the NativeQueue

pliant pike
#

yeah I haven't really looked into this stuff yet sorry

pulsar jay
#

Ok thanks anyway ๐Ÿ™‚

pliant pike
#

are there any data types that allow you to write to a single list in multiple jobs ๐Ÿค”

#

that would just be unsafe and result in race conditions surely

pulsar jay
#

Thats what I am currently trying to figure out

#

I think NativeStream might work

#

Thats why I was also looking at extending ECBs as they basically are lists that can be written from multiple jobs

#

Internaly the ECB Systems use a NativeList<EntityCommandBuffer>

#

so its basically a List of lists

pliant pike
#

interesting, I guess an ecb is just queuing up commands so its not likely to conflict

pulsar jay
#

yeah since each writer creates its own unique list there should not be a problem

pliant pike
#

can't you do that yourself create a list in multiple jobs then add them all together at the end

pulsar jay
#

I am currently trying to figure out if this works

#

but if I remember correctly it is not possible to nest native collections

#

yeah I remembered correctly ๐Ÿ˜ฌ "Unity.Collections.NativeQueue`1[VFXSystem+VFXCommand] used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer"

bright sentinel
pulsar jay
bright sentinel
#

Oh

pulsar jay
#

you cannot nest native collections

bright sentinel
#

or contains a type tagged as NativeContainer

#

?

#

Seems like it should work

pulsar jay
#

it works for ECBs as they use some pointer vodoo and are not declared as native containers by unity

bright sentinel
#

Oh, sorry I read that inversely

#

Maybe you can use UnsafeList?

#

Or FixedList?

pulsar jay
#

well I have to see if these are nestable

north bay
bright sentinel
#

Oh yeah lol

north bay
#

Idk how they are going to solve that for ISystembase

#

Probably do some pointer vodoo lol

bright sentinel
#

Or maybe not all systems will use ISystemBase?

pulsar jay
north bay
#

Huh

#

When did they change that

pulsar jay
#

but a EntityCommandBuffer is allowed to be in a NativeList a NativeQueue is not allowed

#

maybe because they made ecbs burstable?

north bay
#

Does the entity command buffer not hold a dispose sentinel anymore?

bright sentinel
#

But couldn't you just use a List<NativeQueue> instead?

pulsar jay
bright sentinel
#

When working with DOTS I also tend to forget managed stuff ๐Ÿ˜‚

hollow sorrel
#

dunno why we still cannot nest nativecontainers

#

other than safety system

#

just because we can shoot ourselves in the foot doesn't mean unity shouldn't let us

north bay
#

Ohhh

            m_PendingBuffers = new List<EntityCommandBuffer>();
#else
            m_PendingBuffers = new NativeList<EntityCommandBuffer>(Allocator.Persistent);
#endif```
north bay
#

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

bright sentinel
#

@hollow sorrel Well you can always disable the safety system

#

So they DO let you

hollow sorrel
#

yea but that's what i mean

#

if we already can disable that

#

why not allow nesting containers

north bay
#

They need to figure out how to get unmanaged leak detection working

#

Tbh

bright sentinel
#

Oh wait so you mean even when safety is disabled you still can't do it?

north bay
#

I think you can, but that gets rid of all safety checks

stone osprey
#

I need some quick help... I receive a packet from my server and i implemented some sort of serializer which converts the packet to a struct. I tried to add that deserialized packet via "manager.AddComponent(entity, deserializedPacket)"... Yeah... it tells me that generic types need to be known during compile time. My deserialized component is not generic... i just dont use the <> when adding that because i dont know what type the deserialized packet is. What should i do now ?

#

How can i add a component without "<>" to an entity ?

pulsar jay
#

Do you convert it to a specific type of struct? Or is the deserialized data an object?

stone osprey
#

Well of course i know the type... by "myDeserializedPacketComponent.getType()"... but i cant use the generics because i dont know what type it will receive ^^ And i also dont wanna write a huge switch statement.

#

Packet -> Deserialising -> MyComponent : IcomponentData{} -> Add to entity | Thats the current flow...

pulsar jay
#

Maybe AddComponent(Entity entity, ComponentType componentType) will help?

#

you can create an componentType from a Type

stone osprey
#

Ok this is getting interessting ๐Ÿ˜„ And how ?

coarse turtle
#

hmm why not just parse the data as bytes into their desired struct types? ๐Ÿค”

#

ofc that assumes you have a schema for the bytes

pulsar jay
stone osprey
#

Thanks im gonna try that out ! hopefully i dont run into the same issue when i wanna update them next ^^

safe lintel
#

man i went down that rabbit hole, got around it using dynamic types and reflection, so I don't think it works out as a performant solution(but my needs were just a runtime editor)

ocean tundra
#

Yea I too have fought with ECS and dynamic loading of types
Was a massive pain ๐Ÿ˜›

#

@stone osprey For my networking, the first thing i send is the type id, i then have a massive switch statement which creates the exact struct and loads data into it, then attaches to entities as needed

#

So nothings dynamic/reflection based

#

and i use code gen to create that switch statement ๐Ÿ˜›

pulsar jay
#

or the one that takes the typeId

ocean tundra
#

it didnt as i was boxing all my structs into a common interface

#

and interfaces are not sturcts

#

or something like that ๐Ÿ˜›

pulsar jay
#

ok I see

ocean tundra
#

i was adding components that had fields too

#

not empty tags

#

honestly was super annoying

stone osprey
#

Thanks everyone... i think "AddCOmponent(entity, type)" did the trick... atleast i dont get errors anymore ^^

#

Right after that i trigger a SetComponent(entity, struct) which works fine without knowing the generic type

ocean tundra
#

i never actually tried that combo... i was too focused trying to get AddComponentData working so its a single opperation

stone osprey
#

wait... or probably it does not work fine at all

ocean tundra
#

:/

stone osprey
#

The typical showcase effect... i run it again and i get weird errors... one moment

ocean tundra
#

my other requirement was to use jobs and burst, so again that would be why i landed on the switch statement

stone osprey
#

Fuckkk... "SetComponent(entity, struct)" does not workkkkk... the same exceptionnnn as i would have used the "AddComponent" without generics

#

Any other ideas ? I clearly dont wanna have a huge switch statement here xD thats too much pain

north bay
#

What exception do you get? Is your struct boxed?

#

There is an internal method called SetComponentDataRaw if you can modify the package source

stone osprey
#

"All Component Type must be known during Compile time"

#

Im using .SetComponent(entity, data) from an command buffer

north bay
#

What is data in this case, an interface?

stone osprey
#

Just an object... for example a HealthComponent or any other component...

#

So basically everything that extends IComponentData

#

Just imagine that i dont know the type, thats why i use IComponentData... that picture was just a test if it works or not.

north bay
#

Ehh idk about entityCommandBuffer but you could do something like that when you use the EntityManager and make SetComponentDataRaw public:

ocean tundra
north bay
#

I didn't test that tho so there might be something I'm missing

ocean tundra
#

hence the massive super switch ๐Ÿ˜›

stone osprey
#

@north bay Thanks, i think that it works fine when i use the entitymanager instead... but i really, really hoped that theres some way to get it working with the CommandBuffers... because it would be perfect for networking :/

ocean tundra
#

ill be happy to share my code gen bits

stone osprey
#

Thanks... but im really searching for a cleaner way ^^

#

Is there any performance impact when we call "EntityManager.SetComponentData()" on the main thread ? Im just using an ECB here because i was told it has better performance

sturdy rune
#

Well did you register the generic components?

stone osprey
#

@sturdy rune Its not even generic... Look at the second pic above ^^ "new Identity()" is not generic. But im casting it to an interface, because i dont know the type during runtime. So i basically try to call .SetComponentData<...>() without knowing the generics. Thats what is breaking my neck right now

sturdy rune
#

Ah got it. Forgive my naivete but why do you not know components vs components associated with a system

stone osprey
#

@sturdy rune Long story, but i basically receive them as packets from a server and need to attach them to the entities.

#

Thats why i dont know their generic type

#

And i dont wanna have a huge switch statement there

sturdy rune
#

Yea I could understand why haha. I would have thought the components would be known on both sides anyway, and you would receive a generic component that indicates what type of component needs to be added i.e. you've serialized the message and now need to deaerialize - why go straight to adding component? Are you that concerned with performance or is there a real reason

#

But I guess there is your problem you don't want a huge deserializing switch

#

Lol

stone osprey
#

The server uses a different language... java... thats why i deserialize them and dont know their generic type. Just lets say theres no other way ok ? ^^ I dont wanna lose the focus on the main problem. I have some object and i know it extends IComponentData and i wanna attach it to an entity. How do i do that without generics ?

#

I see... this is only achieveable by using reflection... damn, i really hope that unity adds such features some day. Every ECS i know supports this

frosty siren
# stone osprey The server uses a different language... java... thats why i deserialize them and...

If i understand you correctly, if you need to add arbitrary IComponentData object then you can have it as IConvertGameObjectToEntity on a separate gameobject. Then you can manually grab this gameobject and entity you want and use convertion utility on them. That way you can build some "Component prefabs" and inject it at runtime. But it is not efficient.
But there is no way to get IComponentData types that entity has on itself at runtime. And i want this feature from i know DOTS.

stone osprey
#

@frosty siren Thanks... but thats not the problem here. I receive plain data from the server which i need to attach on an entity without knowing its generic type at compile time.

#

I cant convert anything... because i only receive plain structs from the server

#

And i need to attach them to an entity without <>...

frosty siren
#

oh, ok, i see

north bay
#

I don't think you can do that without modifying package source

frosty siren
#

all i can imagine is have some mapping that will match value from server and IComponentData type that need to add. But there is no way to get values.

stone osprey
#

That would work... but its very inflexible and if theres one think i hate then its hard coded stuff.... i think the best bet is to go with reflection, even if its much slower

frosty siren
#

you can avoid inflexibility by using a little bit of codegen ๐Ÿ˜„

north bay
#

Your deserialized component is boxed as an IComponentData interface right?

ocean tundra
#

mmm yes code gen ๐Ÿ˜›

north bay
#

Make sure to pin it before you pass it to your reflection method

frosty siren
#

yummi

ocean tundra
#

this is the templating tool i use

#

but what i really want is source generators

stone osprey
#

In fact its pretty easy... the last method inside that method is what i need

ocean tundra
#

will make it all so much better

stone osprey
#

BUT OFCOURSE ITS PRIVATE

#

WHY THE HECK IS EVERYTHING PRIVATE, PROTECTED OR INTERNAL ?

ocean tundra
#

haha

#

yea i know

#

sooo annoying

stone osprey
#

I bet they don trust us to use them properly

ocean tundra
#

i think they only public stuff they are 100% sure is good for us to use

#

as in default high performance

#

and highly tested

safe lintel
#

dots made basic game stuff so easy to avoid spaghetti code but when i need to use more advanced things that are internal or private, my code turns into spaghetti again ๐Ÿฅฒ

stone osprey
#

i hate unity for that mantra

ocean tundra
#

yup

frosty siren
ocean tundra
#

they should do what that scriban templating tool did
they have a optional define that changes things from internal to public

#

sooo good

#

if unity added that, then us crazys who want the internal private stuff could just add that define

frosty siren
#

i tried to fix Companion stuff's performance and i have finished with 1900 new files in project because there is no way for me instead of cache package and edit Unity.Entities package BECAUSE all is private

ocean tundra
#

yea im trying to stay far away from editing unitys packages

#

also i have no clue how to maintain those changes

frosty siren
#

but the real good thing is that it so simple to read code now

ocean tundra
#

like when theres a update, how do you bring in unitys update without losing all your stuff

frosty siren
safe lintel
#

was that by chjance the companion gameobject transform gc allocations?

ocean tundra
frosty siren
safe lintel
#

how complex a fix was it? i think i remember seeing something on the forums but cant find it now

frosty siren
stone osprey
#

Quick question... whats an managed component ?

ocean tundra
#

a class instead of a sturct

stone osprey
#

class ?

#

Ahh ok

#

thanks

ocean tundra
#

but you lose out on all the cool stuff

#

so dont use them :p

#

no burst/jobs

frosty siren
#

(use them if you want to develop a game ๐Ÿ‘ )

ocean tundra
#

๐Ÿ˜›

#

yea im too harsh on them

#

i have to use some for my networking, as i store the connection stuff in one, and somewhere inside that is a unity safty check thing, which prevents use inside a struct IComponent

ocean tundra
#

mmm instant noodles

stone osprey
#

Is there any way to acess "SetComponentDataRaw()" ?

#

Or does this also require reflection ? It tells me its internal :c

ocean tundra
#

edit it to public?

stone osprey
#

xD

#

My hate grows...

ocean tundra
#

yup

#

is the class partial at all?

safe lintel
#

actually you could try the InternalsVisibleTo thing

ocean tundra
#

ive discovered a nice way of extending things via partial

safe lintel
#

I used a ton of reflection to get access to that stuff but that was before I knew that and havent yet refactored

stone osprey
#

Its like... Oh you wanna use the ECS ? Of course... but only in MY WAYYYYYYY angry unity noises

#

@safe lintel InternalsVisible to ?

#

Never heard of that... whats that ?

ocean tundra
#

dont you need to use that inside the Entities package tho?

frosty siren
ocean tundra
#

@stone osprey ooo just checked, entity manager is partial

safe lintel
#

tertle's post explains it in more detail with an example

ocean tundra
#

so you can nicely extend it,
Make a new folder in your project
Put a asmref in their pointing at Entities
then create a cs file, and give it the same namespace as EntityManager
finally give the class the same signiture as EntityManager

#

inside your new class you can make public methods 'wrapping' the internal/private ones from Unity

#

boom, nicely exposed unitys internal stuff without directly editing their package

stone osprey
#

Bless the lord ! Thanks im gonna try that out ^^

#

No more reflection wuuuu

#

party

ocean tundra
#

๐Ÿ˜›

#

let me know how it goes

#

ive just started doing it for some of my stuff which im building into packages

#

but havnt tested on unitys stuff yet

stone osprey
#

@ocean tundra Hmmm... ok first problem ๐Ÿ˜„ Whats an ASMRef ? xD And where do i create one ?

ocean tundra
#

in the create menu

stone osprey
#

Ah the definition file ?

ocean tundra
#

not a asmdef

#

๐Ÿ˜›

#

a asmref

stone osprey
#

Ah in unity ^^ found it, thanks

ocean tundra
#

yea sorry, should have been more clear

stone osprey
#

@ocean tundra Thanks, so that worked so far ^^ the only problem is... my partial class cant find ANY of the internal methods from the EntityManager

ocean tundra
#

oh

#

um

#

are you sure you have the right namespace and class name?

stone osprey
ocean tundra
#

close and reopen editor?

#

and see what unity says

#

asmref is a unity thing, not normal code, so your editor might be unhappy

#

i think it kinda worked tho, your partial EntityManager has a ton of references/usages

#

what code editor are you using?

hollow sorrel
#

if it's private then only works if it's in same assembly

ocean tundra
#

but thats what the asmref is for

#

adds your files to the targeted assembly

hollow sorrel
#

ah

stone osprey
#

So... first of all, it doesnt like the Equatable stuff

#

Tells me that its already implemented

ocean tundra
#

oh maybe your not ment to copy interfaces

#

just rereading this

stone osprey
#

second... it somehow does not find ANY other methods from that class

#

Only those i wrote

ocean tundra
#

    XML comments

    interfaces

    generic-type parameter attributes

    class attributes

    members
#

yea so that would be copied, so dont need the interfaces

#

What does unity say if you ignore your code editor?

#

im thinking your code editor dosnt understand asmref, so it cant merge your files

#

i use Rider and it was confused untill i cleared my caches

stone osprey
#

Another funny side effect is this... Somehow it tells me that theres stuff missing ๐Ÿ˜„

#

Unity is fine... well it shows me all those errors now.

#

Like that Entitymanager has no world anymore

ocean tundra
#

oh it definitly hasnt merged then

#

instead its replaced using your type

stone osprey
#

Yeah :/

#

Hmmm

ocean tundra
#

sorry ill give it a try shortly

#

worked fine for my package and type

#

maybe the folder structure matters?

stone osprey
#

@ocean tundra Not sure... im using rider, this is the current structure ^^

#

All those red underlined stuff only due to the entitymanager error xD

#

Im gonna try invalidate caches and restart now

ocean tundra
#

works for me

#

@stone osprey remove the interface bit

stone osprey
#

Hmmm... weird... what interface bit ?

ocean tundra
#

use this as your class

#

no : IEquatable<EntityManager> bit

stone osprey
#

Oh i already removed that ^^ But well... still those errors everywhere

#

Im gonna try to restart unity and rider... probably that helps

#

This is also interessting

ocean tundra
#

yea for some reason it hasnt merged your partial entity manager

#

instead created a new one

#

is your asmref set correctly?

#

as your using rider your entitymanager partial shouldnt be grayed out like that

#

thats indicating there isnt another partial type

stone osprey
#

Im gonna check that ref again... but im pretty sure that i set it correctly :/

ocean tundra
#

and my folder looks different in rider to yours

#

i have that little unity.entities indicating its part of the entities package

stone osprey
#

Huh ? Why does your folder looks like that ? ๐Ÿ˜ฎ

ocean tundra
#

maybe this:

stone osprey
#

That fits

sturdy rune
#

Do you have your code editor set as rider?

stone osprey
#

Yes

ocean tundra
#

well im very confused

#

it looks like your matching what ive done

stone osprey
ocean tundra
#

close and reopen of both unity and rider did nothing?

#

what unity versions/rider version?

stone osprey
#

Nope :/ 2020.1.6f1 and the latest rider version

#

2020.3.3

ocean tundra
#

im on 2021.1.0b3

stone osprey
#

I bet its some very, very stupid misttake somewhere

ocean tundra
#

but i dont think that would be the cause

#

asmref have existed for a while now

#

my asmref raw:

    "reference": "GUID:734d92eba21c94caba915361bd5ac177"
}```
stone osprey
#

AHHH WAIT

#

I deleted my previous file and added it again... now it looks different

ocean tundra
#

that looks better

#

so weird

stone osprey
#

Oh its not over yet xD

ocean tundra
#

nooo

stone osprey
ocean tundra
#

delete the cs file

stone osprey
#

Probably my folder is at the wrong place

ocean tundra
#

and delete the asmref

#

start clear

#

make a folder

#

and then add the asmref

#

not the cs file

#

then finally after unity has finished compiling add the cs file

#

im thinking maybe you added the cs file first?
which would have triggered a ton of compile errors
and then added the asmref, but that didnt fix them for some reason

#

oh and make sure you start from 0 errors

stone osprey
#

Oh man... yes that was the problem i guess ^^ Im gonna start fresh again... lets see how it goes this time

ocean tundra
#

oh unity.. and its wonderful weird issues

stone osprey
#

Im gonna kill myself

#

Sooo... i did a fresh start

#

Added a folder, added the reference file

#

Waited for unity... then added the cs file

#

Then waited again and replaced the default created class with the entitymanager

#

AND

#

THIS HAPPENS

ocean tundra
#

well

stone osprey
ocean tundra
#

im even more confused

#

whats the name of the cs file?

stone osprey
#

EntityManager

#

Im gonna try to change the name xD

ocean tundra
#

maybe name the cs file something else

#

thats like the only difference i can see now

stone osprey
#

Sooo :

#

ARGH

#

It doesnt even know any of the Unity.Entities stuff

#

Like IComponentData, its missing

pulsar jay
ocean tundra
#

when i click on the cs file it has this

stone osprey
#

Mine has the same :

#

xD

#

What the hell is happening... it cant be that hard

ocean tundra
#

looks like i wasnt the first to even discover this :/ weird your having issues

stone osprey
#

Every single thing from Unity.Entities is missing now xD Interfaces, stuff like EndInitializationSystem... Even the entity struct itself

#

But... i can start it ๐Ÿ˜ฎ

#

No errors shown in unity

ocean tundra
#

so its just rider dying?

stone osprey
#

It looks like its only rider

ocean tundra
#

go File => invalidate caches and restart

stone osprey
#

Oh i did that the fourth time in a row xD the errors stay

ocean tundra
#

JetBrains Rider 2020.3.2?

stone osprey
#

2020.3.3

ocean tundra
#

ill update

stone osprey
#

Thanks ^^

ocean tundra
#

looks like theres 2020.3.4, ill update to that

stone osprey
#

Thats also still interessting... Partial is still grey

#

Oh i see, im gonna update too

ocean tundra
#

yea its all good for me

stone osprey
#

Mine is still updating ^^ well... actually installing... somehow takes ages

ocean tundra
#

yea took loads longer then i thought it would

stone osprey
#

Annnnddd its still the same ^^ wuuuu

ocean tundra
#

got to be something in your caches

stone osprey
#

How does your solution look like ? Mines like this

#

Im gonna clean the solution/rebuild it

#

probably that helps

ocean tundra
stone osprey
#

Well cleaning works... rebuilding fails due to the resharp errors

ocean tundra
#

mine has a library folder

stone osprey
#

Yeah i see... mine has not ๐Ÿ˜ฎ

#

Where are those packages installed by default ?

ocean tundra
#

under library package cache

stone osprey
#

Well its in there... as it should

ocean tundra
#

update unity?

#

im out of ideas sorry

stone osprey
#

Hmmm... i probably should

#

This is also interessting

#

It doesnt... find the .Entities

#

I removed the partial struct in this test here

#

This is also weird

#

That could atleast explain the many errors

ocean tundra
#

yea i dont have that

#

the rest of my project is all sturctured with asmdefs

#

maybe thats it too?

#

i dont actaually have anything in assembly-csharp

#

nope sorry i do, just not much

#

like 3 files

#

and yea they have some .Entities stuff

stone osprey
#

I dont use any asmdefs ^^ just the package manager... The error above only happens when theres a .cs next to the asmref file. Without it... theres one one reference to unity.entities

#

But as soon as i place a .cs file next to the reference file... it starts to throw errors at me

#

It wont find Unity.Entities anymore

ocean tundra
#

any cs?

stone osprey
#

Yep any...

ocean tundra
#

or the partial one

stone osprey
#

Any

ocean tundra
#

maybe theres a bug with asmrefs in older unity...

stone osprey
#

Well... i can run the editor... so im not sure if its really unity. But i also dont know how close unity and rider are coupled

ocean tundra
#

@stone osprey sorry im all out of ideas

#

delete all library stuff/caches and .csprojs manually?

stone osprey
#

Its ok, you helped a lot ^^ Well... im also out of ideas... but i actually dont wanna delete too much stuff, last time i did that the project was completly broken ๐Ÿ˜„

ocean tundra
#

make a new test project

#

and see if its in there as well

#

and maybe update that project to see if its unity?

stone osprey
#

I think im gonna try that new test project stuff tomorrow... im also a bit in fear regarding the unity update... last time i did that i was forced to update the entities package which resulted in a lot of changes xD

sturdy rune
#

I am just so curious about your component design to understand why this is such a challenge lol I feel so naรฏve

ocean tundra
#

yea kinda tough to update

#

but you will need to update at some point ๐Ÿ˜›

sturdy rune
#

I am using dotsnet though and modelled my netcode after the examples there... not sure mine is so complex

stone osprey
#

Well thats right xD im not using dotsnet at all, im using smartfoxserver. Thats why its such a challenge. Besides that, im gonna try that tommorow, its already late here and i should go to bed soon ^^

ocean tundra
#

and im building my own netcode ๐Ÿ˜›

sturdy rune
#

oh boy

#

I am a network engg and I wouldn't dare

ocean tundra
#

yea im kinda crazy

sturdy rune
#

lol

ocean tundra
#

working really well tho

#

but ive ripped it all appart to put into packages

#

having some annoyances with that ๐Ÿ˜ฆ

sturdy rune
#

have done some socket/transport work in the past in c++/python but I uhh, I wouldn't go that far that's for sure

#

lol

stone osprey
#

Me neither ^^ i havent that much freetime :p

ocean tundra
#

im honestly finding the core networking kinda easy

#

not sure if ive done things wrong ๐Ÿ˜›

#

will see when i start stress testing more

sturdy rune
#

I was going to say

#

it's not the netcoding that's a problem

ocean tundra
#

but i generate a ton of code, and im having trouble with bits of my code relying on generated whcih relys on users code

sturdy rune
#

is queuing and message sequencing

ocean tundra
#

im using Unity.Transport, which mostly handels that

sturdy rune
#

ahhhh

ocean tundra
#

and before in my earlier prototype i used eNet

sturdy rune
#

yea the new unity netcode is good too I have just started getting into it

#

dotsnet is awesome though so far

#

easy

#

easier than mirror

ocean tundra
#

yea i really considered it

#

but decided ill make a my own

#

not sure why ๐Ÿ˜›

sturdy rune
#

lol because it's fun

#

and DOTS isn't done anyway

#

that's what I tell myself

ocean tundra
#

yea me too

odd ridge
#

how does one create a new queryable archetype at runtime?

#

for example, if I add the component Group1, it will create a new archetype with the Group1 component, which I can then query all entities of Group1 by querying Group1

#

I use the Group1 component as a way to collect all my entities that belong to that group together

#

but if I don't have a predetermined tag to query, how can I group entities together?

#

the use case is creating groups of RTS units. I want to create groups which when ordered, will move in a formation together

#

I have read about using NativeArray of entities, but iterating those entities would be random access. if I could modify the archetype with a group identifier instead, I could query the archetype with said identifier, and iterate the archetype with no random access

#

tldr, how can I create a collection of entities in dots such that I can iterate the collection with no random access. (the collection being a group of RTS units)

zenith wyvern
#

Then you can filter by group id on the main thread before you run your foreach

#

I don't know if that's the right solution to what you're trying to do, but it's a solution

odd ridge
ocean tundra
#

@odd ridge I'm pretty sure it's actually quite quick

#

As shared component split up your Entitys into different chunks, so the cost is when adding/removing/changing shared components, not when filtering

amber flicker
#

Itโ€™s pretty much the same as adding a tag - if this selection changes often youโ€™ll have the cost of changing the archetype. If itโ€™s for few operations on the selected entities. itโ€™s usually better to iterate all and add to a native container. If they will be grouped over a longer time itโ€™s likely worth the cost if the change in archetype. Itโ€™s all a trade off.

pulsar jay
#

Is it normal for DOTS physics to take this long without even doing anything with physics?

stable siren
#

Does IJobForEachWithEntity have the 6 argument limit too?

#

As in the same as ForEach

small arch
#

hi, does anyone have an example of how to use Unity.Mathematics.noise using shaders?

#

i tried doing it without shaders, but the performance is really bad.

small arch
#

แต–หกหข สฐแต‰หกแต–

half jay
#

What can I use to make something like this
NativeHashMap<ulongNativeHashMap<ulong,InventoryBlockData>>
Using NativeMultiHashMap means that it should be iterate through values and it can be thousands of them

north bay
#

NativeHashMap<ulong, UnsafeHashMap<ulong, InventoryBlockData>>

stone osprey
#

Having a little issue here...

#

I wanna call "SetComponentDataRaw" via reflection ( because i cant manage to set up those stupid asmrefs )... But it requires a pointer... how do i pass a pointer into the method info ? ๐Ÿ˜ฎ

dull copper
#

I'm looking at 2021.1.0f1 release notes here and I'm super puzzled by this entry: Burst: Burst enters RC phase.

#

but it's already been released a long time ago?

#

or do they mean something other than release candidate with RC here?

deft stump
#

must be for another version of burst that's "verified" for 2021

#

still if that would be the case, they would've included a version number

stone osprey
#

I would be very... very glad if someone could look at my issue here : https://stackoverflow.com/questions/66764051/invoke-methodinfo-with-void-as-a-parameter i need to invoke a EntityManager internal method via reflection and i have no damn clue how i pass a void ptr to it... glad for any help, thanks

stone osprey
#

Quick question... does anyone know how we convert an object to an struct ? I passed a struct to an method via a (object) cast. Now i would like to get a ptr to that object, because i know that its a struct at that point. But well... its casted to an object :/ Any ideas how i could get a ptr to that struct easily ?

#
                unsafe {
                    var handle = GCHandle.Alloc(cmp, GCHandleType.Pinned);
                    var adress = handle.AddrOfPinnedObject();
                    var ptr = adress.ToPointer();
                    var sizeOfComponent = UnsafeUtility.SizeOf(type);

                    var parameters = new [] {entity, cmpType.TypeIndex, (object)adress, sizeOfComponent};
                    SetComponentDataRawInfo.Invoke(em, parameters);
                    handle.Free();
                }

Thats my code sofar... but i would love to get rid of the GC handle. Because i now that cmp is an struct that was casted to an object... any ideas ?

north bay
#

Simple answer, you can't.
As soon as GC takes over the memory (which it does by you boxing the value) you have to pin the object to get an address to it.

stone osprey
#

Oh damn... thanks :/

karmic basin
pulsar jay
#

well ok now its down to 0.655 ms ๐Ÿ˜…

odd ridge
#

thanks, I must have missed this in the manual, I'll check it up

odd ridge
#

my concern was that, if I would use a native container, the foreach would have a cache miss on every iteration, because there's no way to tell where in memory those entities are

pulsar jay
amber flicker
#

not really sure why it's much better than adding a 'selected' tag unless there are many groups?

zenith wyvern
#

I would probably prefer just iterating everything and using a native array. IMO you should only resort to shared components if you need to separate by chunk for performance reasons

#

Like if you have a lot of performance intensive work that needs to be done on your groups of entities per frame. Selection groups doesn't sound like it fits that criteria

whole gyro
#

Has anyone made use of RenderingLayerMasks with the hybrid renderer? I have a scriptable render pass that sets the renderingLayerMask on the FilteringSettings passed to DrawRenderers(). This works fine on game objects, but the entity equivalent is not getting filtered correctly. I can see the BuiltinMaterialPropertyUnity_RenderingLayer is set correctly on the entity in the inspector.

#

When I switch the filtering to use traditional layer masks instead, it works great. However, this layer is stored in the RenderMesh shared component, which isn't ideal if I want to turn the render feature on and off on specific entities at runtime.

#

This is the code I'm using to only draw render layer 4 (mask = 8)

uint renderLayerMask = 8;
var filteringSettings = new FilteringSettings(RenderQueueRange.all, -1, renderLayerMask);
context.DrawRenderers(renderingData.cullResults, ref drawingSettings, ref filteringSettings);

But all entities are getting rendered. For example, here is an entity on render layer 7 (mask = 64):

stone osprey
#

Currently profiling my dots project... Is the Behaviour-Update part of dots ? Or does it belong to normal Monobehaviours ?

#

Dont mind the huge blue spike there... thats what im trying to solve... some part of my code produces a lot of script slowdown for some reason

#

And sorry for the tint ( Its the tint color for my play mode )

#

DisposeSentinel is part of dots, right ? Is so... what the heck is wrong with my game ? When do those DisposeSentinels get created ? I have literally hundreds of them flying around for some reason

#

And they are clearly not good for performance... is there any way to see where those are getting created ?

#

Any ideas ?

north bay
#

They are part of leak detection and can be quite expensive if you have full stack traces enabled.
Try to set leak detection to on or off

zenith wyvern
#

It says editor only for a reason

#

You won't see them at runtime

ocean tundra
#

@stone osprey also make sure burst is on, I think for new projects it defaults off

stone osprey
#

Alright thanks ^^ im gonna try to switch them off

#

Well that worked ^^ Oh... i got a weird exception right here : ArgumentException: System.ArgumentException: A component with type:{0} has not been added to the entity. Thrown from job: Unity.Entities.EntityCommandBuffer._mono_to_burst_PlaybackChainChunk

#

It happens inside the Entity Command Buffer

#

Thats the full error... any idea what exactly causes it ? That stacktrace doesnt lighten me up

fluid kiln
#

Turn off burst

#

And run it again

#

You'll get exception details

#

Your ecb is trying to manipulate a component that doesn't exist on the entity

stone osprey
#

Ah ok, thanks... how exactly do i disable burst ? Theres no "one/off" button as far as i can see

#

Or just uncheck every option here ?

fluid kiln
#

Untick enable compilation

stone osprey
#

Alright thanks ^^ im gonna try it again...

#

Alright... i now get a "full" stacktrace of the entity command buffer "Entity has no component type of... exception"... BUT how do i now find the place where i add/set those components that cause this exception ? Is this exception caused by an add or set/remove operation ?

#

Its also quite interessting... that error log does complain about multiple components at the same time... not only one

#

"Identity has not been added... NetworkLocation has not been added..."

fluid kiln
#

In "Uknown"

#

That's weird

#

I've never seen that

#

It's supposed to say the system name

stone osprey
#

Hmmm... probably i call that buffer from the main thread at some point... that could explain the unknown atleast. What could explain the many listed components ? Is that normal ? ( Identity, NetworkLocation, NetworkRotation... not been added )

#

And is this caused by a .SetComponent operation ?

fluid kiln
#

SetComponent or RemoveComponent

stone osprey
#

Hmmm... I delete a bunch of entities once they leave the area of interest... thats a feature from my server framework. So what happens when i buffer .SetComponents() operation for an entity... but that entity gets deleted before the buffer is able to set those components ?

#

Would that explain that error message ?

zenith wyvern
#

If that happened I think the exception would just say "The entity is null"

#

Errors from command buffers are extremely unhelpful in my experience

stone osprey
#

Well such a exception would make more sense... And at the current state i never remove any components. So it why the heck does that happen... and i always call ".HasComponent" before i set one.

#

To make sure that this actually does not happen ๐Ÿ˜„

fluid kiln
#

Impossible to tell from the stack trace

#

Do you use ecb outside of systems?

#

If so, you might want to use Entity Manager instead

stone osprey
#

I use it outside the ecs for networking stuff. One of my scripts receives packets, converts them to components and uses a ECB instance to Add/Set components to an entity. That could be a possible reason. I only use an ecb here because i was told it offers better performance and does not interrupt the game flow

fluid kiln
#

Yeah but operations from ecb aren't executed immediately

#

They are once the ecb is executed later in the frame

#

So if you do an ecb operation followed by a main thread operation, the ecb will not have been executed yet

#

For exemple

HasComponent<D>() //false```
#

From my understanding, at least

stone osprey
#

Alright thanks... im gonna check the logic flow from my code. If that doesnt help im really gonna switch to the entity manager instead ^^

ocean tundra
#

@stone osprey If you can stick with ECB, but maybe you need to make your own networkECBBarrier system

#

the default ECB systems playback at certan points (start/end) of their containing groups

#

For my networking im currently using EndSimGroup, but that does introduce that 1 frame delay

#

im planning on grouping up my networking systems and having a EndNetworkingECB group, that way users can update after that group and there wont be a frame delay

bright sentinel
#

Are you making your own netcode solution?

ocean tundra
#

but of couse there a new sync point i now need to worry about

#

yup

bright sentinel
#

Interesting. How come?

ocean tundra
#

umm cause im crazy ๐Ÿ˜›

fluid kiln
#

Suicidal

#

๐Ÿ˜‚

ocean tundra
#

no mainly cause i want to make huge RTS type games (sims/managements/rts)

#

think rimworld/factorio/age of empires

#

i dont think unitys netcode is up for that yet

#

and the other option DOTSNET looks close

#

but i found some cool stuff about how planetary annihilation does their networking and loved it

bright sentinel
#

That's fair, it was mainly made for 1st/3rd person action games anyways

ocean tundra
#

decided to see if i could make it, that was ages ago now. worked great

bright sentinel
#

Are there specific features your missing from it?

#

*it being Unity Netcode

fluid kiln
#

ADD/REMOVE COMPONENT SYNC

#

PLEASE

#

โค๏ธ

ocean tundra
#

im honestly not too sure, but i dont think it would handel syncing the number of entities i want

#

@fluid kiln ??

fluid kiln
#

For netcode

bright sentinel
fluid kiln
#

That'd be dope

ocean tundra
#

oh

fluid kiln
#

But in RTS anyway it shouldn't be 1 ghost per unity

ocean tundra
#

yea i actually have never needed that

bright sentinel
ocean tundra
#

my sim is Server => Client

#

client only receives the data they need for the things on screen

bright sentinel
#

I've already read that before ๐Ÿ˜„

#

It's very good

ocean tundra
#

netcode 'might' be able to handle it all fine

#

but honestly having tons of fun building this, and when i started the first prototype netcode was like 0.2 or something, so broken

fluid kiln
#

Since all the networking wizards are here, I have a conceptual question. I'm tryhing to make a top/down RPG but with the same combat system as LoL. I have a hard time coming up with what should be in my Input Buffer and how to attack / cast abilities

bright sentinel
#

Yeah it's completely fair, it's your own funeral ๐Ÿ˜„

fluid kiln
#

SO far the only thing in my input buffer is the destination the client wishes to go to

ocean tundra
#

@fluid kiln lockstep or client server?

fluid kiln
#

But now I'm tryhing to code abilities, should their cast be through RPC?

ocean tundra
#

netcode right?

fluid kiln
#

Idek what that means haha, netcode, server authoritative

bright sentinel
ocean tundra
#

yea based on my understanding of netcode, client would send a rpc to server to trigger the ability

bright sentinel
#

Hm an RPC might also be a better solution ๐Ÿค”

fluid kiln
#

But the thing is, when I play with a client not on LAN, some frames of the Input buffer are lost

#

So "buttons" like "InteractedThisFrame" can be lost

ocean tundra
#

lost?

#

as in packet lost?

#

netcode has a reliable pipline (reliable udp)

fluid kiln
#

Not lost, but overwritten

#

I think

#

Like not all the frames in input buffer are guarateneed to be processed I think

#

That's why it's better to put streams like "direction"

ocean tundra
#

when you say not on lan, your talking about client/server in the same host(unity process)? not over the internet?

fluid kiln
#

Different processes yeah, I guess LAN wasn't right

#

I like the idea of RPCs for buttons anyway, but idk I'm in an awkward spot cause I'm trying abstract as much code as possible for players and npcs

#

But like if auto attacking sends an RPC every x second for every attack for the player, how does it work for the npc? I don't want it to send RPCs

bright sentinel
#

Yeah, definitely seems like RPC isn't too good considering how often the data needs to be sent

#

Command stream seems a lot better

ocean tundra
#

yea i built the same bug in my netcode ๐Ÿ˜› client/server both in the same host (player clicks host and plays, no dedicated servers) when i sync stuff from/to local clients I override the whole buffer ๐Ÿ˜›

#

but my buffer is actually a ton of smaller buffers, every 'command' (rpc) is its own

#

something like auto attack would be a state, not a rpc , the rpc would be to enable/disable auto atack

fluid kiln
#

I figured, but since an auto attack is just automatic casting of the ability "Attack", I would need a completely different logic for it than other abilities

ocean tundra
#

hmm yea thats annoying

fluid kiln
#

I'd like it to be homogenous to any other ability

ocean tundra
#

maybe its more that any ablitly could be marked as 'auto cast'

fluid kiln
#

Oooh

ocean tundra
#

99% of abilitlys wont

fluid kiln
#

๐Ÿคฏ

#

Why did I not think of this

ocean tundra
#

but that also enables some cool gameplay things

#

๐Ÿ˜›

fluid kiln
#

I can definitely go off that, thanks!!!

stone osprey
#

So... Thats why i got that weird ecb exception... I have a system removing entities which are outside the players... "Chunk", but those can still receive updates because of the server settings... So that entity is marked for being deleted -> Deleted but still existing because of SystemComponents or however they are called -> Update coming and buffering .Set operation -> ecb tries to set a component to an entity which barely exists... Its alive, but not it components and it gets removed later on. Damn i wish theres a nicer reactive system solution

stone osprey
#

Sooo... i have a bunch of entities i clearly dont want to iterate over by using Entities.ForEach() or queries. Is this somehow possible without adding .Exclude(); on every single query or system out there ? Some automatic tag which makes systems and queries ignore all entities with it ?

fluid kiln
#

Prefab kind does the same thing

#

Idk if there's another component for that

stone osprey
#

Ahhh thats exactly what i want... So theres a "Prefab" component out there by default ?

zenith wyvern
#

There's Disabled or Prefab

stone osprey
#

Thanks ^^ is there any difference between them ?

fluid kiln
#

Prefab is meant for prefabs, you probably want Disabled

zenith wyvern
#

Functionally no. Just about what fits better in context

#

And you can filter for them separately in your queries

#

Actually I guess Prefab is different since Unity will remove the prefab component from the copy if you instantiate a prefab entity

stone osprey
#

Thanks a lot ! Prefab works like a charm in my case ๐Ÿ˜„

#

Thats actually a huge advantage of unitys ecs... some other ecs i used in the past did not support that by default... which means i needed to "hack" myself into some methods for overwriting them

tight blade
#

I forget like everything about dots and programming in unity ๐Ÿ˜ฆ this stuff isn't like riding a bike

ocean tundra
#

@tight blade just takes time to make it stick ๐Ÿ˜›

tight blade
#

and then time to make it unstick, I'm afraid

#

Anyone know how I could grab a reference to a particular game object in a system startup?

fluid kiln
#

TimeToStick > ToToUnstick

ocean tundra
#

I've been programming for years now, i cant imagine it would ever unstick from my head ๐Ÿ˜›

fluid kiln
#

GO or Entity?

ocean tundra
#

You could call GameObject.Find... methods in OnCreate

fluid kiln
#

For GO you need a component with an Entity field and then in the editor you can map the GO in the component's field

ocean tundra
#

but you need to be 100% sure that the scene containing that GO is the first one loaded

#

better to look into the conversion worldflow (subscenes) and use that

tight blade
#

GO. I need to populate a scene object with a compute buffer and then have the system grab the reference that way

stone osprey
#

The hardest thing about using an ECS is to decide if a feature should be implemented as entities, pure data structs or OOP classes.

tight blade
#

err, sorry, compute shader

ocean tundra
#

as pure as possiable is my plan

#

๐Ÿ˜›

tight blade
#

not compute buffer.

#

I haven't come up with any other way to get a reference to a compute shader into a system

ocean tundra
#

especially as im networking, everything server should be pure, but client is where GOs will need to exist

zenith wyvern
ocean tundra
#

oh does oncreate happen before inital scene load?

zenith wyvern
#

You can get the hybrid component inside OnUpdate

#

Yes, ECS has no concept of scenes

ocean tundra
#

yea but i thought that unity would load the initial scene first, then ecs stuff starts

tight blade
#

huh. hmm. actually maybe I could create some kind of convoluted conversion workflow whereby I passed the compute shader reference to another system during conversion?

ocean tundra
#

well the " convoluted conversion workflow " already exists ๐Ÿ˜›

zenith wyvern
#

You shouldn't be passing it to systems, systems can query for it

#

GetSingletonEntity<MonoHoldingMyData>()

tight blade
#

that must be a hybrid concept, because that seems to be an entity query for a monobehavior

zenith wyvern
#

Yeah, that's what hybrid components are for

#

See the link I posted above

tight blade
#

okay, thanks. yeah thats probably easier than what I had in mind. I was thinking that I would assign the conversion system itself a reference to a compute shader which it would take the value of from the first (and only) mono which it converted

#

and then something else would grab a reference to the conversion system

#

and take the reference that way

#

and that's all terrible

zenith wyvern
#

Ideally you should never be referencing anything to do with conversion at runtime

#

You want to convert all your data into ECS friendly stuff during conversion then query for it at runtime

tight blade
#

gotcha. sounds like a hybrid component is the way to go then

zenith wyvern
#

There's a good thread about this discussing possible better solutions. We're stuck doing annoying stuff like that until Unity has a better process for pushing data into systems

tight blade
#

thanks, guys. So glad you folks are still around

fluid kiln
#

Any way to call a method from a burst foreach? Say the method is in the same system and is burstable

#

I tried putting [BurstCompile] but it still says that the method is a reference type

#

I'm just trying to abstract some logic instead of copy pasting in my foreach

#

It can't be static because I need GetComponent and HasComponent

tight blade
#

as I recall, calling methods is not an issue when actually creating the jobstruct longform

ocean tundra
#

must be a static method

fluid kiln
#

Could I pass maybe World to the static method and use World.HasComponent? Is that fine?

ocean tundra
#

try passing entity manager instead into the method

#

EM is a struct now too

fluid kiln
#

EM reference inside a foreach makes it non burstable no?

tight blade
#

you can burst compile with references to EM now?

fluid kiln
#

Oh it's a struct now??

tight blade
#

whoaaaa

#

thats new

ocean tundra
#

you still cant use most bits in burst ๐Ÿ˜›

#

oh wait, has component calls via EM are rewritten via code gen

#

you probably wont get that via a static method

#

so you need to write it manually

#

i think it uses a ComponentDataFromEntity

#

so make that outside the Foreach

#

then pass it down to the static method

fluid kiln
#

I'll try outside the foreach

#

Ha it seems to work

#

Cool ๐Ÿ˜„ So if you create a local variable for EntityManager outside the foreach

#

You can use it within the burst foreach

#

Nice

ocean tundra
#

yea that would make sence

#

i would double check the code gen output

#

make sure HasComponent is rewritten

tight blade
#

blergh... cant quite... So, in this example, AddHybridComponent is doing what with that monobehavior? I notice the example didnt bother to recover the primary entity or anything before calling that

#

is it just creating a singleton entity that I could query for by that monobehavior?

#

I mean that's surely what I'd like it to be doing

#

wohoo! That is precisely what it seems to do!

#

well okay, that was a lot easier than I had expected

#

alright. operation "port my burst jobs to a compute shader" is underway

#

about 6 months deferred from its original planned start date

fluid kiln
#

Let me fill buffers of entities in the editor PLEASEEEE

#

How do you fill a buffer of entities via IConvertToGameObject?

north bay
#

You can get the entity of a converted gameobject by calling GetPrimaryEntity on the conversionSystem.

If the referenced gameobjects aren't part of the conversion process because they aren't inside the same subscene or child objects you have to use IDeclareReferencedPrefabs to hook them into the conversion.

fluid kiln
#

Nevermind I can do it from Children

#

Oooh or maybe that

#

I'll try it thanks

fluid kiln
#

The Unity.Entities.EntityManager has been declared as [ReadOnly] in the job, but you are writing to it.
Bro what the only thing I do is GetComponent and HasComponent ;_;

zenith wyvern
#

You can't use entity manager inside bursted jobs. Use GetComponent/SetComponent

fluid kiln
#

I'm trying to pass it to static methods cause I want to abstract some code

#

Not looking like a good idea so far

zenith wyvern
#

If you're calling these from jobs then you need them to take a command buffer or a ComponentDataFromEntity

fluid kiln
#

Can't GetComponent from ecb can you?

#

Oh a CDFE, okay I guess

zenith wyvern
#

No, if you need to read a component from an entity you need to use a ComponentDataFromEntity

ocean tundra
#

@stone osprey Hey did you ever get the partial + asmref working?

hollow sorrel
#

how do I avoid boxing when using a list of interfaces that are structs?

#

for example

#
IComponentData[] list = new IComponentData[5];
list[0] = new TestComponent(); // this boxes
#

how does unity deal with this? don't they also store a contiguous array of icomponentdatas in each chunk?

dull copper
#

this must have been longest delay in a long time before new entities version.. there probably hasn't been any info about 0.18 yet?

#

0.17 released over 4 months ago

#

still waiting for that dots blog post too ๐Ÿค”

zenith wyvern
#

I think it's only been 2 months hasn't it

karmic basin
#

yeah more like 2 months

odd ridge
zenith wyvern
#

I guess it depends on how it's being used. If you need to store these groups or share them between jobs or systems then you should use dynamic buffers

#

But no, native arrays can't be stored on a component.

#

Only Unsafe ones

golden elk
#

There a how-to guide on diagnosing burst related crashes in standalone players?

#

Analyzing the crash.dmp file wasn't all that helpful

golden elk
#

The crash seems to be a result of burst

ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF9E8FAA0D8)
0x00007FF9E8FAA0D8 (UnityPlayer) (function-name not available)
0x00007FFA1A85C247 (KERNELBASE) UnhandledExceptionFilter
0x00007FFA1CD95070 (ntdll) memset
0x00007FFA1CD7C776 (ntdll) _C_specific_handler
0x00007FFA1CD91F6F (ntdll) _chkstk
0x00007FFA1CD41454 (ntdll) RtlRaiseException
0x00007FFA1CD90A9E (ntdll) KiUserExceptionDispatcher
0x00007FF9ED09154F (lib_burst_generated) Ordinal0
0x00007FF9E91D320C (UnityPlayer) UnityMain
0x00007FF9E91D387F (UnityPlayer) UnityMain
0x00007FF9E91D17AC (UnityPlayer) UnityMain
0x00007FF9E91D280C (UnityPlayer) UnityMain
0x00007FF9E91D18D7 (UnityPlayer) UnityMain
0x00007FF9E91D1BE7 (UnityPlayer) UnityMain
0x00007FF9E91D2D30 (UnityPlayer) UnityMain
0x00007FF9E92BE678 (UnityPlayer) UnityMain
0x00007FFA1C807034 (KERNEL32) BaseThreadInitThunk
0x00007FFA1CD42651 (ntdll) RtlUserThreadStart
#

Though the dmp file points to something else entirely (probably a crash resulting from the burst memory exception, or just happens to be executing at the same time)

#

Doesn't look like they ran out of memory either

  in module UnityPlayer.dll at 0033:e909f254.

40% physical memory in use.
16287 MB physical memory [9723 MB free].
9914 MB process peak paging file [9626 MB used].
4096 MB process peak working set [2509 MB used].
System Commit Total/Limit/Peak: 18767MB/21919MB/31501MB
System Physical Total/Available: 16287MB/9723MB
System Process Count: 178
System Thread Count: 2270
System Handle Count: 85084```
bright sentinel
frosty siren
#

Can't find "ConvertToEntity and Subscene workflow" thread on forum. Does companions works with subscenes? In editor they work, but my build crashes, so i trying to find reason.

safe lintel
ocean tundra
#

@hollow sorrel I dont think you can ๐Ÿ˜ฆ

#

maybe some unsafe pointers somehow but thats still way outside my skills

#

Sorry this was a reply to your boxing question

stone osprey
#

@ocean tundra No i did not solve that problem :/ i just wrote some reflection magic which works fine. Im gonna try it again once i update my unity version ^^

ocean tundra
#

Sweet let me know if it works

#

I had very simlar errors yesterday, and they were caused by a namespace mismatch, but we 100% checked that :/

deft stump
#

in DOTS physics

#

do we have a similar solution to joints?

ocean tundra
#

How are people testing their DOTS stuff

#

specifically automated tests

remote crater
#

I'm loving DOTS. Just had 20x as many fish spawn on boids, and it looked like the Death Star. I have a large monobehavior script for controlling my player. There is a totally different play style with DOTS. As I edit this single monobehavior file, I want it affecting both GameObject Unity and Entity Unity depending on what play style is enabled. My question is: How do I send data from monobehavior to change iComponentData? Thank you.

pulsar jay
remote crater
#

Thank you. ok, then how do you set a variable with that?

pulsar jay
#

you can then manipulate entities e.g. create entitiy queries via CreateEntityQuery

remote crater
#

Lets say I had an icomponentdata of positionX

pulsar jay
#

EntitiyManager can do all the stuff like SetComponentData on an entity

remote crater
#

Thank you

#

Then I should be good to go.

#

One more question: In order to be compliant with the havok engine, how should I set position/velocity/acccleration in DOTS?

pulsar jay
pulsar jay
#

try setting the velocity component value

remote crater
#

Thank you

#

Peaj, you're super super helpful!

#

I needed this to proceed!

pulsar jay
#

glad to help ๐Ÿ™‚

remote crater
#

God bless you, and all you guys here at the Unity forum.

light mason
#

Anyone use Odin with Dots ?

#

Wonder if it compatible with the conversion workflow

half jay
#

Should i dispose UnsafeHashMap as values of NativeHashMap separately or code like this will work correctly and UnsafeHashMap will dispose automatically?

public class UserInventoryController : MonoBehaviour
{
        private void Awake()
        {
            UserInventory.InventoryStorage = new NativeHashMap<ulong, UnsafeHashMap<ulong, InventoryBlockData>>(500,Allocator.Persistent);
        }
        
        private void OnDestroy()
        {
            if (!UserInventory.InventoryStorage.IsCreated) return;
                
                
                UserInventory.InventoryStorage.Dispose();
        }
}
karmic basin
hollow sorrel
#

@half jay you need to dispose them all separately

stable sentinel
#

What should I use instead of JobComponentSystem?

stable sentinel
#

Yeah, found it thank you

#

Can you read the position out from the Translation component?

#

or do people create a Position component?

silent swift
#

using 2020.3.1 lts

zenith wyvern
stable sentinel
#

Yeah that made sense

#

I just found an old code that was made for basic collision

#

and it had Position and JobComponentSystem

#

and I am trying to remake what it did

#

do you know what ToConcurrent() does/did?

zenith wyvern
#

It's the deprecated name for AsParallelWriter. Gives you a wrapper for a container that is safe to use in parallel jobs

stable sentinel
#

Did the input system change?

#

Input.GetMouseButtonDown(0); seems not to work?

#

or it just doesn't work with ecs?

coarse turtle
#

if you're calling it on the main thread, it should work out of the box, but it also depends on whether you have the new input system active or the old one active (or both). I don't think you can call Input.GetMouse(...) on a different thread though

stable sentinel
#

I call it in a ForEach that is using Run()

#

so that should be on the main thread

pliant pike
#

I don't think calling it in a job will work

stable sentinel
#

yeah I could call it outside

zenith wyvern
#

If you use the ForEach WithoutBurst and Run it will work

stable sentinel
#
[BurstCompile]
    public struct CheckRaySpheresIntersection : IJobProcessComponentDataWithEntity<MySphereCollider, Position>
    {
        [ReadOnly] public Ray ray;
        public NativeQueue<Entity>.Concurrent collided;
 
        public void Execute(Entity entity, int index, [ReadOnly] ref MySphereCollider collider, [ReadOnly] ref Position pos)
        {
            if (CheckIntersection(ray, collider, pos))
            {
                collided.Enqueue(entity);
            }
        }
    }```
#
Entities.WithName("Update_Displacement").ForEach((in MySphereCollider collider, in Translation pos) =>
               {
                   if (CheckIntersection(mouseRay, collider, pos))
                   {
                       collidedEntities.Enqueue(entity);
                   }
               }).WithBurst().ScheduleParallel();```
#

How do I get the entity reference in the foreach?

half jay
#

Am im missing something? I have this entity hierarchy. Entity A parent for B. And LinkedEntityGroup of A include Entity B. After destroy A. Entity B still alive

#

I made entities manually not through conversation

zenith wyvern
#

so a should be the first element then b

half jay
#

ahh

stable sentinel
#

@zenith wyvern Sorry, I read that page but somehow I skimmed that I can just have it in the argument

light mason
#

Does anyone use Odin with ECS conversion workflow

north bay
#

I started to very recently

odd ridge
#

is there a small multiplayer dots sample to learn from?

zenith wyvern
stable sentinel
#

do you guys use the physics package for collision

#

or do you have to make your own collisions?

deft stump
#

physics package

stable sentinel
#

is it easy to use with pure ECS?

zenith wyvern
#

What do you mean by "pure ECS"?

stable sentinel
#

I am not using the convert script?

#

I am guessing you can add collider components?

#

for my raycast I used a basic AABB system

#

but probably there is an easier way with physics

zenith wyvern
#

I think it would be very hard if you weren't using gameobject/prefab conversion to handle adding all the correct components to your physics objects

stable siren
#

I am defining 4 native arrays in OnUpdate but I am getting this error. I think I have done the same thing in other systems so I am not sure what the issue is?

odd ridge
#

thanks

zenith wyvern
#

If you enable all safety checks the log should give you an "Allocated from" exception that gives you the exact line of the leaking container. Somewhere your function returns before that container is getting disposed

stable siren
#

Yeah I have burst safety checks on and leak detection full stack traces on also. The error shows the lines which is how I found it was from those declarations. There is only a foreach after. I thought you didn't have to manually dispose native arrays in that case? I am wrong?

zenith wyvern
#

You have to dispose any native container you allocate with TempJob or Persistent. No exceptions.

stable siren
#

ok thank you

light mason
#

@north bay what is the difference between Odin on asset store and the GitHub one. Are you finding it work ok with conversion workflows

stable siren
zenith wyvern
#

It should

#

I thought you said you were using a ForEach though

#

That's an attribute for a job struct

stable siren
#

This is for a different system as I am now going through plugging leaks

zenith wyvern
#

That attribute only works with native arrays, you should prefer just using container.Dispose(jobHandle) after your schedule the job

stable siren
#

Yeah that is what I have done for most of them now. For this issue I am running a main thread system with several sequential forEach's. Do I have to add jobhandles to each and chain them so I can dispose the nativearray at the end?

zenith wyvern
#

You can just pass in Dependency

#

At the end

#

As in the Dependency property, assuming you're not doing anything unusual with your job handles

#

Oh wait if it's a main thread system there shouldn't be any job handles involved

#

If that's the case just dispose it without passing in anything

stable siren
stable sentinel
#

So for physics at least the mesh and the collider is better to be converted?

stable siren
zenith wyvern
#

Can you show the code?

stable siren
#

Ok I warn you that it is very awkward code, It is also long. You mentioned previously a way to share long code?

zenith wyvern
#

hatebin

stable sentinel
#

pastebin?

stable siren
zenith wyvern
#

Copy the linke from your address bar

stable siren
safe lintel
#

click the save icon?

stable siren
#

Yeah I did

safe lintel
#

it should append to the url

stable siren
#

Is this some weird chrome thing

#

They truncate urls in some cases I think?

safe lintel
#

suppose it could be, try pastebin instead?

karmic basin
#

Works on chrome for me

safe lintel
#

oh, its possible chrome does just hide the url but if you click and copy it, it should be the proper thing?

karmic basin
stable siren
#

Yeah doing the same thing in edge for me

remote crater
#

I discovered something weird. An Entity variable cannot be set to null. How do I set it so its 0, null or not there?

karmic basin
#

destroy it ?

#

ECS will recycle it for another entity

safe lintel
#

were you using Entity.Null ?

karmic basin
#

I never check, but I assume it's read-only, based on how ECS works

stable siren
stable siren
karmic basin
#

oOOoooOoh like setting an Entity reference to null xD I read too fast sometimes

zenith wyvern
# stable siren https://pastebin.com/6kHWzV9D

Don't allocate a native container in a system constructor. If you're allocating a temp array for a job you need to do it at the start of OnUpdate and Dispose it at the end of OnUpdate

#

If you need a reusable container to be used every update allocate it as persistent in OnCreate and Dispose in OnDestroy

stable siren
#

Oh right, that makes a lot of sense

#

In that same code I am using if statements to run code depending on if certain entities exist, currently I am doing:

#

but this doesn't work when I don't make the entities, is there a way of checking an entities existence in this sense?

zenith wyvern
#

HasComponent<Whatever> will return false if an entity is destroyed

stable siren
#

destroyed/never instantiated?

zenith wyvern
#

I think so yeah

#

Or there's EntityManager.Exists

stable siren
#

if(Exists(pistonEntity)) ?

zenith wyvern
#

It's an entity manager function not a system function

stone osprey
#

When i use a native/unsafe hashmap... and allocate stuff with ".persistent"... i always need to dispose it by myself right ? Which means if i replace a component with a unsafeHashMap without disposing it... it will create memory leaks ?

ocean tundra
#

yea that sounds right

stone osprey
#

Ok thanks ^^

remote crater
#

I posted this in www.reddit.com/r/unity3d , but it is so cool. Cool Video: https://youtu.be/Ws-7rqluv6w Take the left fish out on the boids example. Then raise the number until your system gets low performance. 2.5 million fish looks crazy, but also just 1fps. 500k looks ok at 7 fps. I'm posting this just because what Unity made as a demo project is soooo cool to tinker with numbers.

ECS DOTS lets you have 10-1000x as many poly on screen by unlocking cores. So as more and more people play these games, they'll buy CPUs with more and more cores. Maybe in 6 years we have 1024 cores and stuff, so then we are able to render 1000x-100,000 more objects.

Download ECS examples that you can import right into your UNITY hub, from th...

โ–ถ Play video
stable siren
ocean tundra
#

@stable siren Can you explain your question more?

#

If you destory a entity .Exists with the same entity will return false

#

that destoried entity is 'gone', and will be reused at some point in the future

stable siren
#

I want to only run certain code if the piston/Diaphragm exist. This was my first attempt, I then tried manager.Exists(pistonEntity) but I don't think that works either

ocean tundra
#

i would probably use both depending on how the setup works

#

if your piston entity or diaphragmEntity starts off 'null' or you destory and recrreate in runtime code
start with the != ENtity.null

#

then if that passes do a Em.Exists

#

(tho this may be unnessessory as EM.Exists probably does a != null check, but i cant look at the code atm

stable siren
#

So this is how I was referencing them

ocean tundra
#

so i think GetSingletonEntity will throw if the entity dosnt exist

stable siren
#

But when I don't spawn them in (I have them starting as a gameobject) then an error is thrown and the logic doesn't seem to work

#

yes exactly

stable siren
#

oh perf

fluid kiln
#

About what percentage of your systems are burst? Because I feel like I'm putting too much effort in writing bad, not reusable code just for the sake of using burst.

#

Should I aim for a high percentage or does it matter not?

safe lintel
#

+/- 90 id guess. burst everything you can, I dont know what bad not reusable code has to do with being burst compatible though

ocean tundra
#

yea same for me

fluid kiln
#

Some things I just have no idea how to do

#

Like dynamic buffer lookups

#

Writing for loop every time?

#

Can't even use a predicate

ocean tundra
#

maybe a bit higher then 90% if you count all the code generated systems

safe lintel
#

i dont know what a predicate is ๐Ÿ™‚

ocean tundra
#

nothing wrong with a for loop

fluid kiln
#

Yeah but like for example I have a dynamic buffer of abilities, each of them have an ID component

#

Because I'm using netcode, everywhere I need to reference an ability I hav eto use its id

ocean tundra
#

pretty sure you can make linq style code compatabile

fluid kiln
#

So every I reference an abiltiy I have to write to same for loop GetComponent<ID>

#

I tried to make linq style extensions

#

But you can't use any form of delegate

#

Because they're oop

#

Also can't have dicitonary components

ocean tundra
#

look at native lists sort

fluid kiln
#

But Id on't think that's burstable

ocean tundra
#

double check that, i think it is

safe lintel
#

is ID part of netcode or your own code?

ocean tundra
#

but not at my pc to see what i did

fluid kiln
#

Well like, because the ability itself is an entity but not a ghost, I can't send it as an entity, I have to reference it by ID

ocean tundra
#

oh so it is burst compatabile

fluid kiln
#

So whenever the client or server receive the ID, I have to loop the buffer....

safe lintel
#

im not using netcode but id be really surprised if it was built into netcode and not burst compat

ocean tundra
#

BUT not a delegate, instead you make a struct and implement ICompare or something like that

fluid kiln
#

ha yeah I understand

#

Yeah I did that with sort

#

But honestly rather than loop through the buffer I should have some way to store a dictionary

#

Where I can just do buffer[abilityId]

#

I could use an unsafehashmap but

#

It's unsafe and that intimidates me ๐Ÿ˜‚

ocean tundra
#

is the ability ID global for everything?

#

you could have a native hash map in a system

fluid kiln
#

No cause an ability is an entity and every character that has this ability has an entity

ocean tundra
#

but if your Ability list is attached to a entity and the id is to something in there its a bit harder

fluid kiln
#

Since things can be added to it such as Cooldown etc

ocean tundra
#

i see so you have
CharacterEntity

  • Child Ablitiy1
  • Child Ablitiy2
  • Child Ablitiy3
    ?
fluid kiln
#

Pretty much yeah, I have another entity to hold the abilities

ocean tundra
#

and the character entity has a buffer linking to them?

fluid kiln
#

Character
Abilities
Ab1
Ab2

#

Yeah

#

Character has a component that references to the Abilities entity

#

THen i can do GetBuffer<Child>

ocean tundra
#

im unsure with netcode but does it sync buffers?

#

and perseve order?

fluid kiln
#

I wouldn't count on it, but yeah maybe I could use index

ocean tundra
#

yea thats where i was going