#archived-dots

1 messages ยท Page 276 of 1

late mural
#

the fact i cant attatch it to game objects is a small annoyance, meaning i have to create a new script for each location i want it to be in, but otherwise this is real good!

misty wedge
#

Looks like an angry cloud about to shoot lightning at me

late mural
rustic rain
#

in fact it makes it so much easier to create scenes

#

and lets you reuse authoring components however you want

late mural
#

yup, and i have no idea how to use gameobjects with them, so for now i wont, although tommorrow morning i will learn how to!

rustic rain
#

Any idea whether all jobs are reusable?

#

Can I just assign job to field

#

so I don't repopulate fields again?

#

or is there some kind of codegen that breaks this approach?

karmic basin
#

Never tried. But you can think of a similar approach where you gather your fields in a struct and keep that around

viral sonnet
#

yeah, should work. only handles need to be updated

rustic rain
#

Do jobs have any sort of code gen related to them?

#

except IJobEntity ofc

#

and also ComponentDataFromEntity does it need to be refreshed on each update?

viral sonnet
#

i think for CDFE you need another GetComponentDataFromEntity<T> call. for handles there's Update()

rustic rain
#

yeah

#

It says it gets invalidated

#

by structural change

rustic rain
#

hmm get very weird error

#

and it points to this line

#

And I don't get where it can possibly happen

#

Player 100% has physicsVelocity

#

or maybe it doesn't?

#

๐Ÿค”

viral sonnet
#

maybe the index or version is different

#

i'd say the version is

rustic rain
#

brrrrruuuuuh

#

why they banned code blocks

viral sonnet
#

huh? they did?

#

wtf

#

this is a code block

rustic rain
#

wat

#

they blocked cs code blocks?

viral sonnet
#

they reduced the character limit from what I saw

rustic rain
#

xD

#

I didn't remove it

viral sonnet
#

spam filter?

rustic rain
#

no idea, but it's painful

viral sonnet
#

is this one of the job structs that you are reusing?

rustic rain
#

yeah

#

I'll try to remake it

#

oh wait

#

nvm

#

me dum dum

#

passing Entity.Null

#

as player entity

#

lol

viral sonnet
#

just keep in mind, as soon as you set a new value on the player entity the version changes so your job would have an old player entity. i dunno, reusing a job with entity fields sounds like a bad idea

rustic rain
#

which is triggered by singleton player

#

kek

viral sonnet
#

there could be still a case where OnStartRunning is not triggered and there's a change on the player entity. reusing job structs is really not worth it other than opening up yourself for some weird problems.

misty wedge
#

I currently have some data in a grid that I am storing in a large dynamic buffer on an entity, and then reading in jobs. for example, the height value of a certain position. There's a few other values I plan to store here, such as the biome. However, not all jobs plan to always read all of this data.

Now I'm kind of torn between only putting single values in each buffer (e.g. 1 buffer for height, 1 buffer for biomes), and each job retrieving the buffers it requires, or just putting all of the values in a single buffer (there is some overlap where multiple values are required, e.g. many jobs require the height and biome at once).

viral sonnet
#

the design itself is bad tbh (random access) so it'll not matter if you put 1 or 5 fields in a buffer element when you profile

#

but if you want to continue with this, put as much data as possible in it to at least reduce the amount of random access

#

personally I'd redesign this to a hashmap

misty wedge
#

How does a hashmap make it not random access

#

Also the access inside of a job is spatially related, meaning it will (hopefully) be in the cache after the first access

#

I feel like a hashmap will be even slower, since I will just be mapping all grid positions non-linearly, and require an additional hash calculation for each access

misty wedge
viral sonnet
#

I'm not following. What's your internal buffer capacity? From what you wrote you have a large buffer so it won't be in the chunk.

misty wedge
#

Are buffers handled differently if they exceed the chunk capacity?

#

Basically I'm just caching some data in array form, but it's easier for me to store it on an entity to access in a job. It's also not super huge at ~1024x512

viral sonnet
#

if you don't set any capacity, the default is 8 and will allocate memory in the chunk. if that exceeds or the internalBufferCapacity is set to 0 it'll be a randomly allocated array and work just like a list

#

so, yes, they work very differently when exceeded

misty wedge
#

I mean if I didn't have it on an entity I would be storing it in a nativearray on a system, I don't see how that would be any better

viral sonnet
#

the bad thing about it, even if they are allocated in the chunk, their performance is underwhelming

viral sonnet
#

I don't know exactly, mostly overhead and the sum of things. are we talking about 1 buffer or several?

misty wedge
#

usually 1, max maybe 5 for a single save game

viral sonnet
#

and you have direct access because you know the index?

misty wedge
#

Access is based on world position

#

So e.g. for pathfinding I would access the buffer based on whatever node is currently being searched

viral sonnet
#

and what's the method of finding the correct node?

misty wedge
#

WorldPosition / ChunkSize

#

And then transforming that 2d position to a 1d array index

viral sonnet
#

ok, so the answer is yes, you have direct access by index. in that case, I'm sorry, it's okay what you're doing. to get back to your question, you can put as much data as you want in an element. it's just some pointer arithmetic when you have more fields in the struct. hardly any performance loss. getting to the right memory address though is pretty hefty with lots of access from jobs, so if you stay mostly in the same memory space it nets better performance than splitting up the data in several smaller arrays

#

and if you don't believe me (you shouldn't ๐Ÿ™‚ ) -> profile

misty wedge
#

I don't have massive performance requirements like you, I just like talking about these things to learn and see what others would do

viral sonnet
#

you have enough performance requirements to use dots ๐Ÿ™‚

misty wedge
#

I'm using it because because I wanted to learn something new, and I can write a chapter about it in my masters thesis since it's more interesting than "basic OOP setup #1023"

viral sonnet
#

i never had much success with splitting data in general. splitting data is really only worth it if you can vectorize code through it

misty wedge
#

Also it's much nicer for networking than something like mirror (at least I like it more)

viral sonnet
#

the tighter you pack the memory the less the cpu has to jump around in memory and if you get really low level, this is where it's at

#

we like to think about cache lines and all that but that's mostly machine stuff

misty wedge
#

Since I'm using the same interface to access them

viral sonnet
#

in how they act, they are very different. a nativearray is always just a block of unmanaged memory. pointer and length. a dynamic buffer can be reduced to the same thing that's why AsNativeArray is a thing but a DB has the ability to either store the data in the chunk or outside of chunk memory. it has also the ability to act as a list, that's why you can add more elements which a NativeArray can't do. as long as the chunk can fit the DB data it will stay there, once it exceeds the chunkSize a new block of memory will be allocated, just like a list and copied and moved there. the data that will always be static and stay in the chunk is that a DB has a pointer, capacity and length (like a list).

#

to get a better feel for that. try a [InternalBufferCapacity(n)] tag on an IBufferElementData. set it to 0 and you'll see 144 allocated bytes as minimum in the archetype. pointer, length, capacity and something I forgot. set it to 4, 8 or smth, the additional sizeOf the struct will be allocated. also a reason why I don't like DBs because they take away a huge amount of data from the chunk

misty wedge
#

I guess it's a tradeoff, memory for speed. How else would you store multiples of some data that belongs to an entity?

viral sonnet
#

well that's the thing. you trade memory and speed when the data is in the chunk. you'd think that it's great design that the data of a DB stays in the chunk. sounds really fast! right? well it isn't, because it's using pointer access and that trips up any compiler. it doesn't know that the data is just around the corner. so even the whole cacheline thing won't help. also a reason why many, tertle and me included are suggesting to set the InternalBufferCapacity to 0 when the size is unclear. If it's totally fixed an IComp with pinned ptr to the first element and index access is much faster. arrays belonging to entities is the biggest problem in ecs design. the best solution I've found is to use the same entry point for the array, that's speeding things up by a lot. once the cpu knows that you're accessing the same array over and over again timings go down by a lot.

#

I'm mostly finding reasons for what I've measured btw. even if my reasons are wrong (I don't pretend to know every little detail) the performance characteristics are 100% true

misty wedge
#

Very interesting, thanks for the write up. I assume something like a fixed array would be much faster then

#

Ah you wrote that, I just missed it

#

the best solution I've found is to use the same entry point for the array, that's speeding things up by a lot.
By this do you mean use the same base pointer and then offset from that?

viral sonnet
#

yes

misty wedge
#

Would it be enough to get a DB, cast as native array and index it? Or is it doing something else under the hood

#

e.g. get a pointer to the first element and then index off that (DynamicBuffer.GetUnsafePtr)

viral sonnet
#

there's a lot of overhead to get the DB pointer which can't be optimised that well, so a plain native array would be better. once you have the ptr and length a DB and NativeArray is 1:1

#

also a good idea would be to cache the DB ptr/length in every way possible to reduce this lookup

misty wedge
#

Kind of an issue if the DB can change though

viral sonnet
#

right, I don't mean cache it over many frames. just in one chunk iteration for example or on job schedule

misty wedge
#

Ah, alright

#

I guess for a lot of these things it depends on whether or not you are actually bottlenecking on these things. I don't doubt it's a performance issue, but it feels overkill to do this for every DB

#

But it's nice to know if I ever run into performance issues

viral sonnet
#

I'm 100% sure, the most performance issues in ECS right now are coming from DBs. They are just so convenient to use ๐Ÿ˜„ I've replaced many different kinds of DBs now in my project and I'm 80% sure that every DB can be replaced with another NativeContainer.

misty wedge
#

I mean yeah you could stick an UnsafeList inside a component, I guess the "useful" feature is the automatic cleanup

viral sonnet
#

most recent example, every entity/npc/player needs to know with which entity it is in combat with. could be 0, 1, 250k ๐Ÿ˜„ very basic thing but I need to check with new combat events if the entity is already in combat with the other entity, otherwise I'd have lots of duplicates. my first try was with a DB and calling Contains(Entity) so a linear search. perf tanked to 8seconds a frame. then I used tertles dynamic hashmap, MUCH better, the linear search was now gone but still bad overall. I thought, well, as 250k are attacking 1 target, calling ContainsKey 250k on the boss is expensive but it turned out, the single ContainsKey on the 250k casters was the expensive part due to the random access. I then rewrote it to a hashset and hashmap, slightly more complicated and more involved but that reduced it down by a LOT. sadly I don't remember the exact numbers anymore

misty wedge
#

I don't see how a hashmap removes random access, the data is not linearly laid out (between keys)

viral sonnet
#

it's random but not totally random is my best explanation. like it's local to where the memory pointer is. the cpu knows where to start and then just access the correct index

misty wedge
#

But that should be the same for tertles dynamic hashmap. The block of data where the hashmap is stored (a dynamic buffer) is linearly laid out in memory. At the end of the day both should be storing their data in arrays

viral sonnet
#

no, my solution is one long key/value array. the db hashmap is a fragmented key/value array all over the memory.

misty wedge
#

Why is it fragmented, the dynamic buffer just knows the start of it's memory address, and the length

viral sonnet
#

for the casters, which were so expensive, there were 250k, very small key/value arrays

misty wedge
#

Ah, you meant you had many dynamic buffers before, and moved it to a single hashmap?

viral sonnet
#

which also meant,250k unique random memory access instead of 1

#

correct

misty wedge
#

Yeah that makes sense it would be much faster, I thought you meant you had the single hashmap stored on a dynamic buffer

viral sonnet
#

nope, that was sadly not possible with the design. the single hashmap performed, as expected really well

misty wedge
#

Your original approach would also have been slower even if it was stored as nativehashmaps, and not on a dynamic buffer. close to linear memory access is just much faster than spreading it all over the place

viral sonnet
#

right, and that's the problem when you have many entities and DBs. as long as there are not many entities, all is good but when this reaches a certain point the melting process starts

#

just something to keep in mind. if you know the pros and cons of DBs they work really well

misty wedge
#

I also really depends on how many entities you have ๐Ÿ˜… I don't think very many games require 250k actors

viral sonnet
#

i mean, the whole point of ecs is to keep random memory access down. hehe, certainly not ๐Ÿ˜„ I just saw many devs considering grid tiles as entities with a DB so my alarm bells go off

#

you can basically write OOP code when relying on DBs too much. well, burst helps a little ๐Ÿ˜„

gusty comet
#

i am new to using DOTS but i have a quick question, is turning objects to entities improve the performance? my game is a simple lab room, and i have tones of objects in the room like beakers and lab equipments that are there for the environment style only, if i turn them all to entities, would that help ?

oak sapphire
#

There is no data being changed.

viral sonnet
#

yeah, for graphics and just a small but detailed scene you don't necessarily need entities. at least not right now because the hybrid renderer is still very alpha

viral sonnet
#

can someone eli5 write groups?

#

like, i don't understand their usage. to hijack some entities so another system doesn't process them?

rustic rain
#

you have system that writes to local to world and uses write group filter

#

if you add any component with write group to LocalToWorld

#

system will filter that entity

viral sonnet
#

i see, so does this only make sense when i'm not really the programmer of a system or the system is internal and not changeable?

rustic rain
#

well, it makes sense for a lot of cases

viral sonnet
#

any examples? do you use them?

rustic rain
#

I personally haven't got a chance yet

#

unity itself has an example:
when player invincible he doesn't need health color to be calculated

#

so health calculation system uses filter

#

and if invincible tag is applied to entity it's filtered

#

in case you'll have some other component that will be supposed to disable health color system you just add to it write group filter

#

for example, it can be used to switch into other logic of calculating color

viral sonnet
#

ah thanks, that makes sense

frosty siren
#

should i dispose blob assets manually?

viral sonnet
#

they are disposed automatically

rotund token
#

if you simply create one yourself outside of a blob asset store, nothing is magically disposing it

#

var b = BlobAssetReference<int>.Create(1);

#

for example

#

a common case of this is creating your own physics colliders in a system

#

if you add it to a store

var store = new BlobAssetStore();
store.AddUniqueBlobAsset(ref b);
then when you dispose the store it'll dispose all the blobs

#

during authoring unity gives you that store for you via GameObjectConversionSystem and handles its lifecycle for you

viral sonnet
#

oh damn, that's new. is this also true when using a BlobBuilder?

misty wedge
#

Here I am creating and disposing of all of my blobs manually, didn't know blob asset store exists thonk

rotund token
viral sonnet
#

shouldn't the leak detection tell me about it? ๐Ÿค”

rotund token
#

no

#

blobs don't have dispose sentinel

misty wedge
#

Is there any point to using a blob asset store if I currently already have a system that manages them?

rotund token
#

not really

misty wedge
#

Guess I'll leave it as is then

rotund token
# viral sonnet oh damn, that's new. is this also true when using a BlobBuilder?

if you read the blob builder comment

    /// 1. Declare the structure of the blob asset as a struct.
    /// 2. Create a BlobBuilder object.
    /// 3. Call the <see cref="ConstructRoot{T}"/> method, where `T` is the struct defining the asset structure.
    /// 4. Initialize primitive values defined at the root level of the asset.
    /// 5. Allocate memory for arrays, structs, and <see cref="BlobString"/> instances at the root.
    /// 6. Initialize the values of those arrays, structs, and strings.
    /// 7. Continue allocating memory and initializing values until you have fully constructed the asset.
    /// 8. Call <see cref="CreateBlobAssetReference{T}"/> to create a reference to the blob asset in memory.
    /// 9. Dispose the BlobBuilder object.
    ///
    /// Use the <see cref="BlobAssetReference{T}"/> returned by <see cref="CreateBlobAssetReference{T}"/> to reference
    /// the blob asset. You can use a <see cref="BlobAssetReference{T}"/> as a field of an <see cref="IComponentData"/>
    /// struct. More than one entity can reference the same blob asset.
    ///
    /// Call <see cref="BlobAssetReference{T}.Dispose()"/> to free the memory allocated for a blob asset.```
#

specifically tells you to dispose it

#

but yeah, doing conversion whole thing is much easier as you can just pass it to the store

#

and let the world handle it

misty wedge
#

Wouldn't I still need to call Dispose on the store when the world itself is disposed?

rotund token
#

the store passed during conversion is created and handled by the world

misty wedge
#

Ah I meant a custom store

viral sonnet
#

yep, I've missed that. so I just create a manual BlobAssetStore, throw the blobs in there and call dispose on the store. should be good then, right?

rotund token
viral sonnet
#

thanks for bringing that up then ๐Ÿ˜„ don't want to have a leak

rotund token
#

the big benefit of the store is actually how it works

#

if you pass in a new blob asset that already exists in the store, it disposes what you just created and then returns the existing store

misty wedge
#

Yeah I convert a lot of scriptable object data to blob assets for use in jobs, I guess mass disposing of them when the world is disposed might be faster with a store, but probably not worth it

rotund token
#

so that you don't duplicate memory

#

e.g.

#

ok unity discord

#

i hate you

misty wedge
#

haha

rotund token
#

fine screenshot it is

misty wedge
#

It checks the memory contents to find equality?

viral sonnet
#

are you also having trouble with code blocks?

misty wedge
#

works for me ๐Ÿคท

viral sonnet
#

there's a line limit or smth

misty wedge
#

Looks like the bot only scans new lines though

#

So make a small code block then edit it

viral sonnet
#

lol, that's a really dumb change for such a code centric discord

misty wedge
#

Yep

#

Something I was wondering about since the 0.51 migration is coming up soon for me I guess:

#

How exactly does the subscene workflow generate prefab entities? Are all entities that are referenced by scene objects that have an authoring component that points to the prefab created?

#

I still don't use any subscenes since it was broken a while ago due to some weird UIToolkit error

viral sonnet
#

can you rephrase that question?

rotund token
misty wedge
#

Basically, I want to know under what conditions a prefab is converted to a prefab entity

rotund token
#

then tried to post 6 lines then and discord just would not have it

misty wedge
#

I assume if a subscene component references it

viral sonnet
#

oh, yeah, right. that's so weird

#

i think you should test it, you can view the converted entities in the hierarchy. just make a subscene and put some gameobject in there

misty wedge
#

I guess I can test it now, I never actually attempted to use subscenes again

#

I just remember they broke due to UIToolkit or something

viral sonnet
#

they are just converted at editor stage and the whole scene is saved in a nice format for fast reading. the downside of this is that the entity that is created doesn't match the runtime entity index/version

#

so referencing in that sense won't work unless it goes through patching

#

most cases should work as expected though, just something to keep in mind when wanting references outside of the entity world

#

i.e. some monobehaviour wants the entity index/verison

frosty siren
#

@rotund token thank you for such detailed answer!๐Ÿ˜€

misty wedge
viral sonnet
#

yes

misty wedge
#

Hmm, still kind of annoying since I have some scriptable objects that reference prefabs

viral sonnet
#

yeah, those are a problem. I don't have a real solution for that.

misty wedge
#

Eh, worst case I'll just slap a component on it that maps to the assets guid and then find it that way

viral sonnet
#

I'd be really glad if the editor->runtime would match tbh. It would open up a lot of things that can be done much more elegantly

#

but that's probably a pipe dream and really hard to do out of the box

misty wedge
#

I don't think it would even be possible, since you can load a subscene into the world multiple times

viral sonnet
#

yeah, right. there's so much normal cases that would totally break this. maybe some additional call could be made. i just feel like there should be a solution in place for that problem. especially when this whole hybrid GO thing is here to stay for much longer

misty wedge
#

You mean the conversion workflow or actual gameobjects due to missing features (animation)?

viral sonnet
#

the actual gameobjects. if you stay within entities, references are working great

misty wedge
#

Ah okay

viral sonnet
#

it all relies on spawners now, although I'm pretty sure that's just a personal dislike and it's actually not a real problem. it's just a habit that I want to have the actual enemy in place and not a spawner. I've written a bunch of helpers to draw prefab meshes so spawners can be seen in the world so it gets better with some tools

misty wedge
#

I mean you can still just place entities right? Since a gameobject in the scene is just converted to an in-place (non-prefab) entity

viral sonnet
#

it's about the presentation of the entity, the gameobject with the audio sources, skinned mesh renderer, animations, etc...

misty wedge
#

What does DOTS convert those things to atm?

viral sonnet
#

hm, not much actually. i've not even seen one good example in their repo when it comes to that. the best thing is companionobjects that link the GO and entity but I've not got that working in the authoring stage

misty wedge
#

Hmm, ok

#

I just use gameobjects for all rendering / sound related stuff

viral sonnet
#

unity has us pretty much hanging in the air unless I've totally missed something. from what I know everyone is doing their own thing when it comes to Go presentation for entities

#

everyone does that right now ๐Ÿ™‚

misty wedge
#

Yeah I just never checked if there was some dots native stuff out already

#

I saw that audio library that dreamingimlatios posted

viral sonnet
#

it was promising with the animations package and then it went dark

misty wedge
#

I'm working on a graphically very simple 2D game, so I feel like I really dodged a lot of the difficulties with more complex rendering stuff in DOTS

viral sonnet
#

hm, some what. you still need to make the link and manage, sprites, etc... so in some sense it's very similar

misty wedge
#

How do people handle something like mecanim? Have a monobehaviour that reads the component data and updates the animation controller?

#

Or the other way around? (system that writes values to animation controller from component)

#

I mean I guess it really isn't very different from settings sprites via animations...

viral sonnet
#

pretty much that, i have a animation comp that is written to via burst and then a managed system that copies the values to the animator

#

feels like duct tape overall ๐Ÿคฃ

misty wedge
#

I guess for a 2d game it's at least easier to write a simple animation system that works with burst and jobs

safe lintel
#

mecanim in dots feels like hot potato coding, โ€œno you deal with this data, no you deal with it!โ€ Each system continuously passes the buck til it finally gets to the animator

misty wedge
#

Can you profile timings in burst jobs, or do you need to turn off burst to profile it?

safe lintel
#

i havent actually had luck profiling specific things inside of jobs but that was a while ago

viral sonnet
misty wedge
#

e.g. UnityEngine.Profiling.Profiler.BeginSample

viral sonnet
#

in system: static readonly ProfilerMarker marker1 = new ProfilerMarker("marker 1"); set this in the job then

#

and then you can beginSample, endSample or use auto() instead and measure the thing in brackets

#

works for burst too

rotund token
#

isn't it nice when you just open burst inspector, look at your job

#

and you have 161 lines of simd in a row first try

late mural
#

hey this is probably a stupid question, but do rigidbodies and colliders convert automatically to the entity version of those components, or do you have to replace them with the entity versions manually?

rotund token
#

the physics system includes conversion from existing physic components, so yes they convert automatically

late mural
#

oh ok thank you so much!

rotund token
#

if you use the new physics shape, physics body components though you get new features and control

late mural
#

ooh, id like to try those, how do i find them?

rotund token
#

just add physicshape/body to your gameobject

#

instead of boxcollider etc

late mural
#

how, i tried searching for them in the component menu, they dont appear to be there

rotund token
#

you have unity physics installed right?

late mural
#

i hope so, i just installed hybrid renderer and i thought it auto installed everything else with it, but ill go check brb

rotund token
#

it wont install physics

#

you need to install that yourself

late mural
#

oh ok, well then ill install it manually, thank you so much!

rotund token
#

(and body up top)

late mural
#

thanks!

rotund token
#

body is for dynamic objects

#

if you leave off body it'll be considered a static

late mural
#

ok that makes sense, thank you so much!

remote crater
#

day 9 and over 50 hours of not being able to compile a standalone approaching, no one answering my addressables questions. It should be easy... My game ain't making the .json file.

rotund token
remote crater
#

I know tertle, but no one answers my question for 3 days

#

I'll get the info together as concise as possible. My system is building a build, takes 3 minutes a try

rotund token
#

i don't think we need that much information about building addressables (and honestly if it's more than about 2 sentences I won't read it =D)

#

it's usually 1 button to build them?

#

really just want to check if you're building them the normal way or have a custom build script doing it etc

remote crater
#

I changed build paths along the way because I thought it was putting settings.json in wrong place

#

Here I have no settings.json on my entire computer

#

Its not making the assemblies

#

By default, Unity should have assemblies work, I was using nothing custom at all

#

Error I get: System.Exception: Invalid path in TextDataProvider : 'C:/UnityProjectfiles/StarfighterGeneralOnSteam/Builds/buildme/starfighter_Data/StreamingAssets/aa/settings.json'.

#

Looks like I have to downgrade to: 1.16.15 addressables?

rotund token
#

is there addressables in

#

PROJECT\Library\com.unity.addressables\aa\Windows

#

and if not, when you build addressables what error do you get

remote crater
#

I have no aa directory

#

I get no error building addressables

rotund token
#

that means you've never built it in the editor

remote crater
#

I built it many times

rotund token
#

so it's never going to be included in your build

remote crater
#

Addressables group->build

#

Or am I doing it wrong?

rotund token
#

build, new build, default build script?

remote crater
#

yes

rotund token
#

hmm i'm looking at your addressables

#

is everything in 1 group?

remote crater
#

yes

#

I had 2 groups before

#

but i downgraded to 1, because Unity had problems

rotund token
#

that's going to be problematic for you

#

but thats your future problem

remote crater
#

I want it working now tho

rotund token
#

(it means none of your assets will ever unload from memory)

remote crater
#

If unity can't handle 2 groups, I'll do one. I'm not picky

rotund token
#

anyway click on your group

#

what does the inspector show

rotund token
remote crater
#

I know, I had 2 groups to start

#

1 music, one my droppables

#

But when it didn't work, I thought Unity had an error understanding more than one group.

#

idea

rotund token
remote crater
#

maybe I have to make the directory by hand

rotund token
#

output path seems right

#

can you open advanced options

remote crater
#

Unity never made those directories

#

Maybe it was a bug that it forgot to mkdir

#

I'm gonna make those directories by hand and try

rotund token
#

it should error when you build ๐Ÿ˜

remote crater
#

my build goes through and game plays

#

just sends tons of errors trying to load the addreessables it can't find

rotund token
#

yeah because its clearly never been build

#

because its not in that folder

#

so it's never copied it to streaming assets when building your game

#

so its never been included in your build

remote crater
#

BuildPath for group 'Default Local Group' is set to the dynamic-lookup version of StreamingAssets, but LoadPath is not.

rotund token
#

if it's not in Library\com.unity.addressables\aa\

#

there's nothing to copy to your game

remote crater
#

I never saw the errors on a "Addressables build"

#

Now I see there are ones, it uses the same console unity uses for play.

rotund token
#

what is the final log

#

when you build addressables

rotund token
remote crater
#

Yah, we're getting someplace

#

I'm pretty sure we're striking distance from ending this tech hurdle.

#

ok

#

my build path and load path were set to the same thing, and it can't be like that says: https://l-u-k-e.tistory.com/13

Novike
  1. Must build addreasble asset before build ย It doesn't matter when you play on editor, but the localization asset will not be attached in build when you implement the project to devices. 2. Build..
#

Looks like it is building now. TY tertle, you're a boss who helped me TOOOOOONS. I want to be making the hundred mil a month like other MMOs and hook you up. lol. I personally don't care about money, I'd rather just be gamin or coding.

#

As a UI guy, I'd recommend that if a build fails, and the console window is not visible, that it becomes rendered.

#

I quite literally got no feedback and assumed the build succeeded

#

Addressable content successfully built (duration : 0:04:00.474)

late mural
#

hey stupid question, but how do i get a reference to an entity that the script is attatched to, a bit like how you can use this.gameObject to get the game object the script is attacched to?

remote crater
#

yes

#

okay, simple and useful, let me get you code

#

You want an entity from a monobehavior script or a Systembase ?

late mural
#

monobehaviour would be nice

remote crater
#

I got you my man.

late mural
#

cause i plan on having it attatched to an entity, and it destroys the entity after existing a certain amount of time basically

remote crater
#

Its useful to use entities in some monobehaviors, especially the player controller

#

Wait that should be a system base

#

I have the code for you

late mural
#

ok

remote crater
#

if you use monobehavior for that it slows you down

late mural
#

oh ok, what should i use then?

remote crater
#

Sec, let me get u code

#

If you attach a Bastian to an Entity, it sets it to destroy

#

Let me give you the destroy code

late mural
#

ok nice!

#

thanks so much

remote crater
#

you'll have to edit this radically to get it to work tho

#

Use it as notes

late mural
#

ok i shall, thank you so much!!!

remote crater
#

Basically it cycles through entities with Bastian and destroys them, and or drops loot and or destroys other entities dependent on it

#

Its overkill

late mural
#

ok thank you so much!

remote crater
#

I'll get you a destroy over time too

#

Thats more of a DESTROYNOWNOW

late mural
#

lol

remote crater
late mural
#

ok thank you so much!

remote crater
#

So do you know there's two systembases

#

And two icomponentdatas

#

The systembases processes each

#

It might be a bit unorthodox, uneloquent and such, but this code is tapping into power and early.

#

But hey

#

let me answer your original question

#

how to read and write to an entity from mono

late mural
#

ok, ye ill mess around with both ways, and see what works good for me, considering how i am a bit of a newbie to dots lol (also pasting code doesnt work in this channel, just screenshot or pastebin it)

remote crater
#

You want to do EVERYTHING you can in dots

late mural
#

thank you so much!

remote crater
#

The only thing you do not want to do in DOTS is your player controller, and only if you have a mature game you're expanding to have a dots level

#

Translation entPos =World.DefaultGameObjectInjectionWorld.EntityManager.GetComponentData<Translation>(shootingEntity);

#

That's how to get componentdata

late mural
#

ye luckilly im not doing much with dots, just a large amount of frictionless spheres that would otherwise grind performance to a halt without dots, but ye all you have said shall be very useful, thank you so much!

remote crater
#

Yah, I gave you some stuff to mechanically putz with

#

Its unedited from my current game, so you got ship wreck comments and nonsense constants you can't use

late mural
#

ill figure out some way of making work eventually though, i always do lol

rotund token
#

My character controller is written in dots >_>

remote crater
remote crater
#

I'll tell it again, it's exciting.

#

So say you have 300 levels of games in your GameObjectgame and people loved it for like 5 years.

#

You want to add dots levels

#

But don't want to make a new game.

#

You take your already working Player controller.

#

At the very start, get position/velocity/etc of your player

rotund token
#

well, anyone who is suggesting switching an existing project to dots I have simple advice - don't ^_^'

remote crater
#

Have your player gameobject be invisible and non rendered.

#

Then at the end of the cycle, add the velocity, rotation

#

Boom!

#

Your player is now an entity

rotund token
#

that's just the standard hybrid workflow

remote crater
#

Super super simple

#

Enemies, enviro, items, etc should be all new

#

All new scripts for stuff except the player

#

Having one monobehavior script doesn't hurt dots performance

#

But having hundreds of mono for enemies would.

#

The best part is as you change your player for gameobject land, it auto changes for entity land

rotund token
#

the same controller on my characters is the same controller on my enemies

remote crater
#

You edit once, change twice

#

oooh,

#

You could... Say... Super Mario 64 sequel take over them with a hat

#

Or, get apower up

#

where every move you input

#

gets inputed to them

#

Make a dance party

#

Dad, tell us again how you defeated the bad guys? Oh we taught them how to dance and have fun. Turns out people having fun don't want to take over the world much.

late mural
#

another stupid thing, but couldnt you use a component system on each entity the way you would instantiate, but destroy entities instead of creating them, or is this not a good idea?

remote crater
#

when you do instantiate an entity

#

it has all the components the old one had

#

so the way I datapool

#

is instantiate one entity

#

then save it in a List

#

and then instantiate it by index

#

It generates SOOOOOO fast its basically instant

#

Its better than buffer datapooling in gameobjects

#

Thats one of many things DOTS ECS got right

#

ecb.RemoveComponent<Disabled>(e);
ecb.RemoveComponent<DisableRendering>(e);
ecb.RemoveComponent<DOTS_OBJECT_POOLER>(e);

#

I put a Disabled/DisabledRendering and DOTS_OBJECT_POOLER tag

#

Diabled and DIsabledRendering are UNitys

late mural
#

ooh that is clever, i should probably do that eventually, but for now ill keep using my stupid instantiation script cause it works well enough for now lol, but imma try my odd method of destruction now because even if it aint the fastes i think it may work in a stupid way

remote crater
#

DOTS_OBJECT_POOLER is mine so I don't process it in places

#

Sometimes you gotta get stuff working to do more

#

But DOTS/ECS is the way for all

#

Don't do MONObehavior stuff you want to keep long term

#

I recommend not using it all for destroy

late mural
#

i wont use monobehavior for destroy, i wanna see if i can do it in a component system in a similer way i did the instantiating, but with destruction instead

remote crater
#

Goodnight all, tertle solved all my problems

#

God bless, keep it real.

late mural
#

apparrently Time.time does not exist in a component system, are there any replacments for it?

#

wait im stupid i can just use delta time and do the equation backwards

#

from googling around it seems there is no way to figure out what entity the script is attatched to, atleast not in a component system, surprised there is a this.entity or something like that

#

guessing im missing something obvious though, so any dots magicians feel free to correct my stupidity

drowsy pagoda
#

I just updated Entities to 0.51 (from 0.50) and all of a sudden Newtonsoft disappeared from the face of the earth. I'm getting errors that Newtonsoft namespace cannot be found. I looked at my ASMDEF where they were and they are now greyed out and says None. I can't find it in the UPM either anymore. What's going on?

#

Just downgraded back to 0.50, and Newtonsoft.Json.dll appeared again (even in UPM). What am I missing?

drowsy pagoda
#

Hmm..updated Newtonsoft from 2.0.0 to 3.0.2, and then updated Entities to 0.51 no problem.

rotund token
#

so unless you manually add a reference (e.g. updating it) it won't be included in your project

drowsy pagoda
#

I see. Thanks for that clarification.

#

But why would it disappear from UPM? I was going to add it manually but it wasnโ€™t in the registry. I had to downgrade entities, upgrade newtonsoft and then upgrade entities lol

late mural
rotund token
#

your question doesn't really make sense to me

#

and i'm not sure what you're trying to do

late mural
#

so basically i have a script attatched to an entity, that destroys said entity

#

that is what i want

rotund token
#

so that right there

#

makes no sense

#

because you don't attach scripts to entities

#

you attach components

#

which are just data

late mural
#

oh

drowsy pagoda
rotund token
#

the whole point of entities over gameobjects is to not attach logic to the entity

#

gameobjects have components attached but these contain data + logic
entities have components attached but these only contain data and systems provide the logic

#

that is like the fundamental of ECS and the difference with gameobjects

late mural
#

ok that makes sense, so rather what i should have is each entity having a float for time, that then a loop goes round for all entities and lowers teh time and if any of the entities time is 0 or lower, i destroy that entity, is that more correct then?

rotund token
#

yep

late mural
#

ok, thank you so much!

rotund token
#

you can have a LifeTime component with a value in it

#

and a system that iterates all these components, when it hits 0 (or when it hits X time) destroy the entity

late mural
#

ye that would make sense, i shall start figuring out how to do that!

#

small question though, how do you make components, is it just a regular c sharp script with the data in it that is attatched to the entity

late mural
#

also how do you loop through a list of all entities, all my googling is coming up nothing, i have a bad feeling im missing something obvious

#

and ye i still cant figure out how to add components, it seems that all the info on dots is really well hidden from google, and if you dare add "unity" to the end of any search it automaticallly pulls up stuff about only GameObjects and nothing about entities

graceful herald
late mural
#

also is there any good solution to not have to restart unity every time you add a component, or do anything dots related, cause i have to wait about 10 - 15 minutes each time for unity to start up again

rotund token
#

why are you restarting?

late mural
# rotund token why are you restarting?

because for some reason i just get an error that my scripts cannot be found in the file system, despite me literally dragging my scripts from the file system onto the objects, as such i have to restart to fix this odd bug

#

this happens every time i create a new script, or add dots to an old script

rotund token
#

haven't seen that specific one before

#

that said, entities 0.51 has its problems

#

if you want a more stable experience 0.50 is probably where you want to stick for learning

#

(though you have to stick on 2020.3.3X)

late mural
#

oh that is unfortunate, guessing 0.5.0 does not work on the 2021 lts versions?

rotund token
#

*0.50.1
no 0.51.0 brought 2021 support

late mural
#

oh that is unlucky, i guess for now considering how the rest of my project is built on 2021 and i dont wanna downgrade, im just gonna keep dealing with these odd bugs and hope a patch comes out soon, and also use min max strategies to minimise the amount of restarts i do

rotund token
#

@viral sonnet finally ran into your, GetNativeArray chunk version bumping issue, ^_^
You did something similar to this right?

var original = conditionActiveTypeRead.GetUnsafeReadOnlyPtr();
var updated = this.conditionActiveBuffer.GetUnsafeReadOnlyPtr();

var hasChanged = UnsafeUtility.MemCmp(original, updated, UnsafeUtility.SizeOf<BitArray8>() * this.conditionActiveBuffer.Length) != 0;

if (hasChanged)
{
    var conditionActives = batchInChunk.GetNativeArray(this.ConditionActiveType);
    conditionActives.Reinterpret<BitArray8>().CopyFrom(this.conditionActiveBuffer.AsArray());
}```
rustic rain
late mural
rustic rain
#

Just right click in folder explorer and click reimport

late mural
#

oh ok, ill try that next time

#

also im trying to work out how the for each thing works, and i think i get it, but how do you get the entity, after you have gotten the component?

#

i have a list of all components, and all these variables, and i can change them at will, but no way of getting any entities

#

the samples are very useful in showing how to do all the variables in a for each loop and all that cool stuff, but they show no way of getting a list of entities

#

wait could i do ref Entity thing? that might work!

#

yes it works i think, i just dont know how to use get component on an entity, but otherwise, i have it!

#

ok i figured it out, but now im even more confused, apparrently im not allowed to modify public floats, because they are not variables, how do i make public floats be variables?

#

google aint helping, as per usual, and the samples dont talk about how to make floats be variables either, so im hopeing someone might know the answer here?

tidal gulch
#

aren't you trying to access components in a Entities.ForEach?

rustic rain
#

That means you can't access fields inside

#

But you can store all variables in onupdate scope

late mural
late mural
rustic rain
#

Make local variables

tidal gulch
rustic rain
#

Lambda can read and modify them

late mural
tidal gulch
#

you can add more params depending on components you want

late mural
#

i thought you could only have 1 lol

tidal gulch
#

you can only have 8 in a foreach, but you need a custom delegate for more, and surely you will adjust your systems if you need that many

late mural
#

that will be fine, i only need 2 lol, so thank you so much!

#

also quick thing, just making certain you can have if statements in a for each loop right?

late mural
#

yay, thank you so much!

#

is this a normal warning to receive?

#

ok now this is weird, ive somehow made my performance dance, consistently

#

like it will stay at around 60 fps for about 10 seconds, then for the next 10 seconds it will drop to 10 fps, then the cycle repeats

#

anyone got any ideas why?

#

im guessing my code is quite unoptimised, because i used to get around 100fps with around 500 rigid bodies, and now that i get rid of entities that have been around for too long my game suddenly lags way more, but is more consistent

#

here is my code, incase im majorly messing something up

#

from testing, it seems to be that the line that destroys the entity is the most expensive

#

is there a way of getting rid of, or hiding, an entity that is more performant than destroying it?

tidal gulch
late mural
#

oh ok, i havent heard of those before, ill do some research and try them out, thanks!

runic spire
#

I would think that would give you an error saying that you need to use .WithoutBurst()

late mural
late mural
tidal gulch
runic spire
#

it's pretty simple to set up, you can have it working in a few lines of code, but it does use some long class names

rustic rain
late mural
#

ok, i think im using the buffer thing correctly, just making certain though?

runic spire
#

now that you are using the command buffer, you don't need to run it on the main thread and without burst, so you can get rid of the .WithStructuralChanges()

late mural
#

oh nice!

runic spire
#

it will just queue all your structural changes to execute after you are done processing the entities

late mural
#

should i still use Run() or should i use one of the schedule things

runic spire
#

probably just Run

late mural
#

ok, ill try it out and report back on the performance!

oak sapphire
#

Why not ScheduleParallel?

runic spire
#

well its a pretty small amount of work right now

oak sapphire
#

Yeah that's fair

runic spire
#

I dont see a reason to fully multithread it, but if it's running on tons of entities and has a bit more math involved, then it might be worthwhile

late mural
#

ok, performance is up, it now averages around 20 - 40 fps, which is better, not as good as i would have liked it, but still pretty good

runic spire
#

have you fully profiled it? this is really what's causing the bottleneck?

#

keep in mind that the editor has burst compilation disabled by default, so it will be much slower than if it's enabled or you are in a release build

#

there is also stack trace stuff that gets added into the editor / development builds

late mural
# runic spire have you fully profiled it? this is really what's causing the bottleneck?

i havent fully profiled it, i have been going off of changing stuff and seeing the result, without the entire system thing i get 300 fps for a while, until the entities get to such a great number that performance grinds to a halt at around 1 fps or less, adding the system back but not destroying the entities has the same result as the first test, destroying the entities is the bottle neck as such i would assume

runic spire
#

if you go here you can enable burst compilation in the editor

late mural
#

ok ill try that thanks!

#

enable compilation appears to have been enabled by default

runic spire
#

hmm, okay

#

well if it's really that many entities, you might want to extend your command buffer into a ParallelWriter and use ScheduleParallel then

tidal gulch
#

Well how many systems are there?

runic spire
#

you would just do

EntityCommandBuffer.ParallelWriter parallelWriter = ecb.AsParallelWriter();

and at the end of your OnUpdate you would do

buffer_system.AddJobHandleForProducer(Dependency);
oak sapphire
#

I am highly sceptical that destroying the entities is the bottleneck to be honest.

#

A simple look at the profiler should give you heaps of information

late mural
late mural
late mural
runic spire
#

you would have to click a certain point in time and look through the functions taking up the most computation time

late mural
#

how would i do that, im not very famillier with the profiler sorry lol

oak sapphire
#

We can see the scripts are wrecking you though, so that's nice ๐Ÿ˜›

late mural
#

the green stuff also wrecks me, although less frequently, only about once a minute

#

like this

runic spire
#

wowza

#

something is definitely going wrong lol

late mural
#

yup lol, and i got no clue what

oak sapphire
#

Then you see at the right what % is on which script

late mural
#

oh ok, ill do that brb

oak sapphire
#

You can open those and go all the way to the methods.

#

Also, enable the entities stuff there

#

Then at the bottom you will see this

#

Might be you have several thousands of structural changes every frame

late mural
#

im a little confused on what you mean by any of those, but i got this if this is helpful?

runic spire
#

you can physically move your mouse and click on a time in this graph

late mural
#

im not very clever sorry lol

runic spire
#

it will show you a snapshot of all the collected profile info at that point in time

late mural
#

ok i did that, it did nothing

oak sapphire
#

You can click the arrows by the way.

late mural
# oak sapphire

issue, i dont have the timeline button, it isnt there on mine, and pressing the arrows just shows their children, none of which seem helpful

oak sapphire
#

Like that

late mural
#

yes, it looks like that

oak sapphire
#

Show me a screenshot of your whole profiler

late mural
#

ok!

oak sapphire
#

It's probably hidden at the bottom

late mural
oak sapphire
late mural
#

oh ok

#

so after clicking on that, what do i do next?

oak sapphire
#

Set to timeline

late mural
#

woah that is cool!

oak sapphire
#

Hide the black box ๐Ÿ˜›

#

We can't see the scripts

late mural
#

how?

oak sapphire
#

Don't hover over the function

late mural
#

im not

#

i never was

runic spire
#

click something else then

late mural
#

it opened automaticall

late mural
runic spire
#

lol

late mural
#

lol

runic spire
#

press copy then and maybe it will go away haha

oak sapphire
#

Just click on the timeline again

#

Select a different frame

late mural
late mural
#

im stuck with this box one way or another

oak sapphire
#

Works for me

late mural
#

aha, by selecting all on the heirarchy, i have managed to remove it somehow!

oak sapphire
#

Lots of Job stuff

#

Can you open that one too?

late mural
#

open what one, how can you open stuff here?

runic spire
oak sapphire
late mural
#

oh, i didnt see those...

oak sapphire
#

Profiling is an art ๐Ÿ˜›

late mural
oak sapphire
#

I have never seen anything like that ๐Ÿ™‚

late mural
#

neither have i, although i suspect for different reasons, cause ive never used the profiler before

oak sapphire
#

Isnt it the Run thats wrecking him?

late mural
oak sapphire
#

Does it run all the entities in small jobs now?

late mural
#

i have no clue

oak sapphire
#

I hope Danon5 does

late mural
#

same lol

oak sapphire
#

I always ScheduleParallel my stuff so ๐Ÿ˜›

late mural
#

ill try that, just to see how that affects performance

runic spire
#

I don't think I have looked at the dots job profile section before, so I'm not really sure what it should look like

tidal gulch
#

Run should not ruin performance like that

#

It's something else

runic spire
#

but 12 milliseconds on basically the most simple task ever seems strange

oak sapphire
#

For me it's huge blocks of parallel work

#

On all 12 worker threads

rotund token
#

a) are you creating/destroying entities every frame
b) you are in a fixed update death spiral

late mural
#

yup, very weird, should i go over to the frames when the green stuff takes over and see how the profiler looks then?

late mural
rotund token
#

you can't destroy something that doesn't exist

#

so are you creating entities every frame as well?

tidal gulch
#

Can you show how you are creating entities?

late mural
#

and creating them, although creating them quite efficiently, i get around 100 fps without destruction

late mural
rotund token
#

i assume your entities have physics on them

late mural
#

yup

rotund token
#

i think you're triggering a full physics rebuild every frame

late mural
#

oh, that aint good, how would i avoid that

rotund token
#

can you
a) turn jobs debugger off

#

b) make sure leak detection is off

late mural
rotund token
#

c) turn off physics integrity checks

#

then profile it

late mural
#

do each one individually or all at once?

oak sapphire
#

All at once

late mural
#

ok i shall!

rotund token
#

actually for b) On is fine, just make sure it's not full stack traces (Expensive)

#

but yeah make sure jobs debugger is off (unlike my screenshot) and integrity checks

late mural
#

ok, it crashed my unity trying to turn the integrity checks off, so is it ok if i dont do that one?

rotund token
#

did you turn it off while in play mode

late mural
#

oh

late mural
rotund token
#

odd

#

all it changes is a precompiler flag

late mural
#

well frozen, not crashed

rotund token
#

and triggers a recompile

late mural
#

must be a long recompile then

#

been a minute and a half since it started

#

should i force close unity, or wait for something to happen?

#

it loaded yay!

runic spire
#

lol

late mural
#

ok now i can continue with the steps

#

a nice drop into 4 fps land

#

here is the green domination part, ill do the blue one next

#

here is the blue

late mural
oak sapphire
#

The jobs are still scuffed.

late mural
#

also the green domination that randomly occurs is odd

#

oh well, it seems to have had interestin affects on fps

#

randomly dropping to around 5 fps every 20 seconds or so

#

sometimes getting up to 100 fps, but usually staying at around 30 fps

#

anyone got any ideas what on earth is going on?

oak sapphire
#

If the other people don't have suggestions you can try making a development build and profile that.

rotund token
#

how many entities do you have?

oak sapphire
#

That way it is way better in the Jobs and not a lot of overhead

late mural
rotund token
#

to me it looks like you have a lot of physic colliders really close

#

alternatively can you save your profile and upload it?

late mural
late mural
rotund token
oak sapphire
late mural
late mural
rotund token
#

yeah i think you're literally just killing physics by having too many collisions in a small area

rotund token
#

but that wont happen in build

oak sapphire
#

Would that mess up the Jobs so bad like that?

rotund token
#

its creating a lot of collision event pairs

#

or whatever they call it now

late mural
#

ok that makes sense, but it doesnt match reality, when i dont have the destroy script, i get insanely high fps until the number of entities gets too high

oak sapphire
#

The more you know ๐Ÿ˜›

rotund token
late mural
#

calculates what once?

rotund token
#

this is what happens when you spawn 1000 physics objects in same spot

late mural
#

oh i see

rotund token
#

next frame

#

4 seconds vs 2ms

late mural
#

as a solution, should i rather space out the spawning place for my instantiated entities, like have them randomly spawn in a 10 by 10 instead of a 1 by 1?

rustic rain
#

What system is that that calculates everything?

#

Transform?

rotund token
late mural
#

yup it is definitely the collisions, just from a little bit of a space out, it is doing much better

#

getting around 100 fps now

oak sapphire
#

Didn't know the Physics ones also showed up in Jobs, learned something. ๐Ÿ‘
Problem is fixed then?

late mural
#

also a bit of a math check up, if i use the random.value, and i times it by a number, call it x, it will give me a number between 0 and x right?

rotund token
#

there's a math.Random function

#

for inside jobs

#

but yes your logic is fine

late mural
#

it isnt inside a job luckilly, cause im doing the instantiating very stupidly dont worry

rotund token
#

(though I'd always just use Range() anyway)

late mural
oak sapphire
#

Yeah, but remember it does not include the last number. So Range(-3, 3) = -3, -2, -1, 0, 1 and 2

late mural
#

ok, is there a range but for floats?

oak sapphire
#

Range(0, 1) also is one of those things you think should work but doesn't

#

Yeah there is, google it

late mural
oak sapphire
#

Just 0

late mural
# oak sapphire Just 0

could be useful for claiming a gambling app has a random function, while secretly is still rigged

runic spire
#

yeah, it's just to make it easier to generate a random index

oak sapphire
#

But its possible yeah

late mural
#

wondering how parenting works with dots, let us say i have 1 parent object with a rigidbody, and then the colliders on seperate children gameobjects, where should i place the conver to entity component, and should i put it on all of them or only 1?

rustic rain
#

children have Parent component

late mural
rustic rain
#

parents have Child buffer

late mural
#

ok

#

how do i do any of that?

rustic rain
#

just add Parent component to child

#

Transform system will resolve it for you

late mural
#

ok, so i dont need the child buffer on teh parent then?

#

and i have convert to dots on everyone then?

rustic rain
#

sometimes you do need it, but hopefully you won't face that trouble

late mural
#

i hope so aswell

rustic rain
#

I personally had to write an algorithm that restores child buffers through painful checks

late mural
#

yikes

late mural
rustic rain
#

I think it's Transform namespace

#

not sure

#

Rider solves them all for me xD

late mural
#

what is rider?

olive wagon
#

an IDE

late mural
#

ok

olive wagon
#

like notepad but better

late mural
late mural
rustic rain
late mural
#

why do i need the namespace

#

sorry im quite dumb lol

rustic rain
#

well, you ask about where do you get it

#

I assumed your IDE didn't resolve it for you?

late mural
#

you need a name space to get it?

rustic rain
#

new Parent()

late mural
rustic rain
#

If you convert from GO

#

they are added automatically

late mural
#

oh good

rustic rain
#

through normal transform hierarchy

#

if you want to create children manually through code

#

you add Parent

late mural
#

ok thank you so much

glacial hazel
#

(No intention to interrupt) Hello there! Quick question, is it possible to iterate in parallel (in a job) through the different values per key of a NativeMultiHashMap?
I saw that before there were IJob's dedicated to that kind of collection, but they were removed

#

For example, before existed IJobNativeMultiHashMapVisitKeyValue

late mural
#

im a newbie to dots, but i swear ive seen the exact thing your talking about somewhere in a unity fluid simulation tutorial

olive kite
#

I'm getting a few JobsUtilities errors when upgrading to v.51 using 2021.3.2f1:
'JobsUtility' does not contain a definition for 'ClearSystemIds'
Any idea how this might be fixed?

glacial hazel
late mural
#

it uses hashmaps for something i remember, hope it helps!

glacial hazel
#

Hmm yeah, it just goes through all the values, instead of the keys, with an IJobParallelFor

#

I guess I could do that instead too

late mural
#

welp i wish you luck in finding a solution!

glacial hazel
#

Thank you @late mural !

karmic basin
#

Yeah manual says so

late mural
#

wondering how do you add rigidbody constraints, is it possible to do in the editor, or does it have to be done via code

runic spire
late mural
#

oh thank you so much!

#

woah that stuff is cool looking! I'll try it out soon, thanks a ton!

gusty comet
#

When I first tried DOTS way back when it was just called ECS, the docs were a bit weak and I had to rely on youtube to fill in the gaps. Coming back, it looks like the docs are a lot better, but are there still parts of the workflow that I'll need to learn from third-party? And if so, has enough changed with the 0.50 update to invalidate older youtube content?

rustic rain
#

a lot of things are obsolete now

#

but overall ideas are still legit

#

mostly it's due to ComponentSystem -> SystemBase

#

switch

#

also

#

ECS is part of DOTS

gusty comet
#

That whole thing confused me to begin with so it's probably for the best that I'll need to relearn it

rustic rain
#

DOTS is a lot more then just ECS

#

and each big part can be used independently

gusty comet
#

Yeah I'm aware, it just used to be called ECS before the rest of the packages were developed

rustic rain
#

it's still called ECS

#

but it's not DOTS

#

it's ECS package

#

DOTS contains: Jobs, Burst, ECS

#

all are independent

gusty comet
#

I know... I was referring to the period of time where all of the new systems, including things which do not fall under the ECS label, were just called "Unity ECS" as an umbrella term.

rustic rain
#

ppl tend to call ECS DOTS, because ECS is using all power of DOTS as dependency

misty wedge
#

How fast is allocating a large amount of temp memory? Say I want to speed up my pathfinding by moving from a nativehashmap to a nativearray, I would need to request the entire grid (~5MB) at the start of the job. Also, how big is the temp memory pool?

rotund token
#

at 5MB (per thread) you'll probably be using the fallback allocator

#

it won't be that bad though if you can do it per thread (entity chunk), not per entity

#

you can do something like this to re-use allocations per chunk that ends up on the same per thread (literally wrote this today)

private NativeList<BitArray8> conditionActiveBuffer;

public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
{
    var conditionTypeBuffers = batchInChunk.GetBufferAccessor(this.ConditionType);
    if (!this.conditionActiveBuffer.IsCreated)
    {
        this.conditionActiveBuffer = new NativeList<BitArray8>(conditionTypeBuffers.Length, Allocator.Temp);
    }

    this.conditionActiveBuffer.ResizeUninitialized(this.conditionActiveBuffer.Length);```
viral sonnet
#

@tertle hehe, I knew you would run into it sooner or later. good solution to do a memcmp. i did it on an individual level because I had something like 5+ handles that could or could not change. your solution seems better

misty wedge
#

Also I'm guessing the fallback allocator for temp is just tempjob?

viral sonnet
#

@rotund token oh, what are you using for the var updated (conditionActiveBuffer)? is this a temp array? just wondering how you keep the original and updated around without too much copying

rotund token
misty wedge
#

Why does this work? Does each thread reuse its job struct for all chunks it handles?

viral sonnet
#

oh missed that! quite involved. i just use ref and write to the readonly ptr. then bump the version manually

#

in my case I know when changes happen. something you don't seem to have the luxury of

rotund token
misty wedge
#

Huh, interesting. That would also mean if you write any "state" data to the struct from execute (which you shouldn't anyways I guess), that would not "reset" on the next batch

rotund token
#

so each thread gets their own jobdata struct and just how structs work this means state is preserved yes

misty wedge
#

Cool trick, thanks

#

Another thing, if I request "too much" memory using the temp allocator and it falls back, I'm guessing I still don't need to dispose it manually

rotund token
misty wedge
#

Yeah that would be awfully error prone ๐Ÿ˜…

#

Is this also true for unsafe collections allocated with temp allocators inside a running job? (im guessing they are also automatically disposed for me)

rustic rain
#

hmm

#

rn I started to wonder whether systems check whether they should run every frame

#

or only after structural changes

#

Judging by source code - every frame

#

but this is so inneffective

misty wedge
#

iirc it's every frame

rustic rain
#

literally comparing all queries every frame

rotund token
#

well it compares queries you tell it to compare

rustic rain
#

meanwhile actual state only changes during structural changes

#

feels bad

rotund token
#

by default that's any query in the system

#

but you can restrict this with RequireForUpdate

rustic rain
#

yeah, but I mean

#

it can be done only once

#

on structural change

#

kind of like: make all systems dirty after structural change

rotund token
#

a) how does it know there's a structural change
b) checking a structural change requires a sync point

#

because you can implement b) if you want

#

simply to [UpdateAlways] so it doesnt check any query

rustic rain
#

Structural changes run on main thread anyway

#

meaning you can just add additional code to it

rotund token
#

then do a if(query.IsEmpty) return;

rotund token
#

not change filters

#

ah most systems don't care about structural changes for updates

rustic rain
#

ahem

#

aren't most systems run based on queries?

rotund token
#

yes

rustic rain
#

well

#

then I think that checking whether queries exist every frame is a waste

#

quite large one

rotund token
#

oh you mean if the query is valid?

#

ah you realize unity already caches this right?

#

public bool IsEmptyIgnoreFilter => _QueryData->GetMatchingChunkCache().Length == 0;

rustic rain
#

it's more about

#

hmm

#

It's checking all queries

#

array of them

#

meanwhile everything can be simplified to just boolean

misty wedge
#

Have you profiled if it's actually slow?

rustic rain
#

and be 100 times faster

rotund token
#

it's literally just doing int == 0

#

sure it will be faster

#

but i doubt you'll even profile a difference

#

using chunk caches was one of the big improvements of entities 0.50

#

but even with that, did you notice a performance difference? because it is something like 20x faster than 0.17

#

if profiled independently

#

but when we profiled our entire project, we couldn't notice more than 0.5-1% in real world, well within any error margin

misty wedge
#

I imagine it would be pretty fast to check if any archetype chunk exists even without caching it

rustic rain
#

oh

#

I see

#

but you know

#

it does such checks for all queries

rotund token
#

it doesn't check each query

#

it checks until 1 returns true

rustic rain
#

welp, not sure I understand, but hopefully it's all cached

rotund token
misty wedge
#

You only need a single query that contains an entity to run the system

#

I learned this the hard way when I made a really dumb mistake initially:
I create a LogColor singleton so that each network world (client and server) would print logs in different colors.
I then had a system that inherited from SystemBase that my systems would implement. The color was fetched with EntityQuery.GetSingleton.
This meant that since all of my systems inheriting this class had an entityquery that was always true (the log color singleton always existed), all of them ran each frame. So maybe don't do that...

rustic rain
#

Currently my systems run based of RequireSingletonForUpdate

#

mostly these are state entities

#

hmm, I do wonder though

#

if I add requirment for several singletons

#

they are will be combined requirment, right?

#

and probably same for queries

misty wedge
#

RequireSingletonForUpdate just gets a query for that type and then calls RequireForUpdate

rustic rain
#

yeah, but is it using OR or AND logic when you add it this way?

misty wedge
#

You can add multiple required queries to a system; all of them must match at least one entity for the system to run.

rustic rain
#

ah, yes
I didn't notice

misty wedge
#

More explicitly this is the code that actually checks the required entities

misty wedge
olive kite
#

What about the components "Occluder" and "Occludee" for occlusion culling, are these replaced or just not needed anymore

viral sonnet
#

temp allocated memory in jobs doesn't need to be disposed

misty wedge
#

Since safe containers throw an error it's easy to check for those

viral sonnet
#

hm, good question. I'd say no because it doesn't implement anything for the job to know

#

I'd stick to native containers for any temp allocations

#

they are optimized really well especially in burst jobs

misty wedge
#

What if I need to stick a container in another container inside a job

viral sonnet
#

I'd say rethink your design approach ๐Ÿ™‚

misty wedge
#

But what if I wanna do it

viral sonnet
#

I'd still say the same thing ^^ I mean, it's possible for sure and I'd handle disposing just to be sure

misty wedge
#

TBH I think they are disposed, otherwise it would be impossible to dispose any unsafe containers that use temp memory, since UnsafeUtility.Free is a no-op for temp memory, meaning you could never dispose an unsafe container if it wasn't already being auto-disposed. I don't think the temp dispose mechanism has anything to do with jobs

viral sonnet
#

could be true, there's a mechanism in place that prevents of doing temp allocs outside of jobs

misty wedge
#

That's not actually true, you can alloc temp memory outside of a job iirc

#

You just can't pass it to a job

#

Not 100% sure though

#

This is all it says in the docs:
Allocator.Temp has the fastest allocation. Use it for allocations with a lifespan of one frame or fewer. However, you canโ€™t use Temp to pass NativeContainer allocations to jobs.

viral sonnet
#

ah ok, so yeah, it seems then that temp is just freed every frame

#

and every thread has its own temp memory

misty wedge
#

Yeah, I was just wondering about unsafe collections, but I guess they are automatically freed to, since again, you can't actually dispose them manually since UnsafeUtilities.Free doesn't do anything for temp memory

oak sapphire
#

Hey all, I'm trying to get all the positions of all my FireballTag'ed Entities in a MonoBehaviour .
Currently I have this:

    EntityManager manager;
    private void Awake()
    {
        manager = World.DefaultGameObjectInjectionWorld.EntityManager;
    }
    void FixedUpdate()
    {
        EntityQuery eq = manager.CreateEntityQuery(typeof(FireballTag));
        manager.GetComponentData() <<< No idea what to do here, I want a list or an array of all the fireball positions, or should I use a Job for this and prepare a list in that?
    }

What I am trying to do is put the positions of all the fireballs in a pixel of a Texture2D that is fed to a VFX Graph so I can batch tens of thousands VFX spells in a single graph.
Any tips/links/suggestions would be appreciated. I want this piece of code to be as performant as possible, because I would like hundreds of thousands of fireballs.

viral sonnet
misty wedge
viral sonnet
#

Allocator.Temp appears to be backed by a "bump allocator" that is cleared between every frame. Whether you call Dispose or not, you should only read and write to memory allocated by it during the same frame that you allocated it. Starting with the next frame, you'll either get an exception or data corruption.

misty wedge
#

I tried reading it a frame later and it still worked, but it's definitely not going to always work

#

the safe container threw an exception

viral sonnet
#

sometimes it lingers, guess when the temp memory space isn't exceeded or smth. hard to say what the logic is as we don't have the source code for it

#

or rather, the data lingers because it's not overwritten

misty wedge
#

I mean why wouldn't it linger, it's in the virtual address space of the program that allocated it. As long as nothing wrote over it it won't change

misty wedge
oak sapphire
#

This is working now, but just checking if there is more to be gained.

misty wedge
#

Depends a lot on how you have your project set up. Ideally you aren't using any monobehaviours and are running all your code in jobs with burst enabled

frosty siren
#

how is it fast to read from blob reference? Can i use it like normal component data, or should i cache data from blob to read it faster?

oak sapphire
#

Well currently I'm doing it this way because as far as I know, jobs can't change values in my VFX Graph, and can't change the Texture2D I am using for positions. But maybe I am wrong about that. And the VFX Graph has so much overhead that giving all the Fireballs their own Graph is way less performant then doing it this way.

olive kite
#

I do the same thing to instance my vfx (from positions stored in texture) ๐Ÿ™‚ works well

oak sapphire
olive kite
#

@oak sapphire If I can remember correctly, I do all the calculations in burst but had to set pixels in MonoBehaviour let me look

#

I am using a property binder to the vfx graph to assign the values

#

is that what you are doing, i know this is not what I was answering, pulling it up now

oak sapphire
#

Yeah, I have exactly that. All my entities behaviour via the SystemBase ScheduleParallel method. And the Mono changes the Texture2D and the bindings with the VFX graph.

#

My question was about what would be the fastest way to do this.

#

But if you are doing the exact same thing, it will probably be good ๐Ÿ™‚

misty wedge
olive kite
#

Yeah i remember testing it and it was really efficient , but I'm definitely not an expert on micro optimizing in jobs and burst

misty wedge
#

I would profile it first and see if it's even a performance issue

olive kite
#

Yeah you should be good, looks like your texture isn't too large

misty wedge
#

If you do need more performance, there is a much faster way to write pixel data to textures

olive kite
#

please share

misty wedge
#

You can write to the memory backing the texture by getting a native array to it's color data using Texture2D.GetRawTextureData

#

e.g. Texture2D.GetRawTextureData<Color32>()

#

You can then write the data in a burstable job if you like

olive kite
#

oh duh, yeah that is much better than what I am doing

misty wedge
#

Just note that you aren't supposed to store the native array in any way, the intent is to use it immediately and not dispose it iirc

oak sapphire
#

Depends on what you think a performance issue is.
Currently I have DOTSNET networking working with 1 million entities all updating the rotation and position, while being server and client.
I have an animation system working with 78.804 animated characters at 70 FPS.
And now I want to make those characters shoot VFX entities, and would like to get the most performance possible here too.
Then I will combine them and make a small game, that's my plan.

misty wedge
#

I just mean check if it's actually an issue before trying to optimize it

olive kite
#

yeah, of course, if trying to get product out in the most efficient/effective way, no point in fixing what isn't a problem. Sometimes the use case is "I wonder the absolute most efficient way to do x" which somehow makes it into my project pipeline when it shouldn't or isn't an issue. But still fun sometimes

#

any of you know what might be causing the componentdata to be unknown here? you all know why I might be getting "InvalidOperationException: The previously scheduled job Jobs:CreateRigidBodies reads from the UNKNOWN_OBJECT_TYPE CreateRigidBodies.JobData.PositionType. You are trying to schedule a new job CalculateGroundHeightSystem:Calc_Ground_Height_Job, which writes to the same UNKNOWN_OBJECT_TYPE (via Calc_Ground_Height_Job.JobData.__translationTypeHandle). To guarantee safety, you must include Jobs:CreateRigidBodies as a dependency of the newly scheduled job.

misty wedge
#

The discord recently started blocking large code blocks for some reason