#archived-dots

1 messages Β· Page 160 of 1

minor sluice
#

I think it's the thing out there that makes parallel game coding the easiest, also with platform specific low level compiler optimizations in burst, I haven't seen anything like this before

hollow sorrel
#

which isn't really an engine but still

minor sluice
#

and not sure how monobehaviours compare with unreal actors/components, but I didn't think they are slow in comparison

hollow sorrel
#

unreal is designed with OOP in mind so it prob won't ever be as fast as DOD

tardy spoke
#

ECS in unity does have some big advantages.

It seems confusing at first, but imagine it has been around for 10 years how easy the tutorials will be to follow, etc.

Because, unlike monobehaviour coding, ECS basically prescribes a software architecture, and is compartmentalized. That means a lot more people are doing things a similar way.

And tutorials don't really need to interact with other systems rather than they are concerned with, making them clear and concise. Very plug and play.

For me, the hardest part of ECS is definitely just the lack of documentation/examples - but once it has those, I think it'll really take off.

With a monobehaviour the tutorial may work with your current games structure, with an ECS tutorial it almost always will.

opaque ledge
#

entities 0.13 and hybrid renderer 0.7 is up πŸ‘€

tardy spoke
#

AWESOME, I can't wait to relearn everything again.

#

πŸ˜„

deft stump
#

nah, I doubt they'll change much

safe lintel
#

vblanco mentioned unreal was working on their own ecs implementation though by the sounds of it too early to show(although with unitys recent decision are we still at that stage with dots? πŸ˜… )

minor sluice
#

and the other thing is that unity also compiles down to c++ with il2cpp, so I'm not sure if it is that slow, but I don't have a good comparison,
but also appears to me that if there are performance issues in unity, they are often not that hard to tackle, things like batching etc., or making your own managers for handling a ton of individual objects

tardy spoke
#

lmao ECS is definitely too early to show

#

I have a feeling they may not do this again

#

Like release something this experimental again

minor sluice
#

it is also incredible what unity does to handle data and chunks in the background for fast access/cache coherency

tardy spoke
#

Because I think ECS developed a reputation as "extremely difficult to learn" that has really hurt their efforts

#

when realistically when it's finished it will be "not that bad to learn".

hollow sorrel
#

problem with il2cpp is it literally doesn't do any optimizations at all, it's just trying to 1:1 copy your C# output

zinc plinth
hollow sorrel
#

and unity's implementation of mono compiler produces really slow code in comparison to other C++ compilers or .net core

tardy spoke
#

So for the average person they're looking between unity and unreal and being like "well, Unity is moving to a new programming paradigm that is really difficult, and I'm an OO programmer so I'll just go with unreal"

minor sluice
#

I think while it is harder, it wouldn't be that difficult to learn if the resources for it are better, but at the moment, you often have to go through forums to find certain information, the api still changes.

and people here in this channel are super helpful too with it ^^

opaque ledge
#

yeah they do it like that sometimes Torsina

hollow sorrel
#

that's why burst is needed

minor sluice
#

ah interesting, didn't know that for il2cpp

opaque ledge
#

GameFoundation package was like that as well, 0.4 to 0.6

tardy spoke
#

Because I would be concerned they didn't do good job at their keynotes demonstrating that Monobehaviours will still be supported alongside ECS for the forseeable future

zinc plinth
#

@opaque ledge is there any place where we can see the changelogs ?

minor sluice
#

is it reasonable to assume that there might be performance increases when unity switches to net 5?

opaque ledge
#

yeah, from local file

deft stump
#

is it reasonable to assume that there might be performance increases when unity switches to net 5?
yes

#

very

opaque ledge
#

Library/PackageCache/Entities/Changlog

minor sluice
#

awesome

hollow sorrel
#

original reason for il2cpp was to make unity run on systems that couldn't run mono, performance wasn't really a concern at first at least

minor sluice
#

ah, afaik for most platforms you still need il2cpp

#

like consoles and I think mobile too?

deft stump
#

like consoles and I think mobile too?
I think for ios only

#

android can run mono afaik

tardy spoke
#

@minor sluice yeah you nailed it, for someone newer to programming like me the biggest killer in learning ECS is the constant changes to the API and best practices.

#

It's like... imagine you don't know what you're doing... and then it changes. πŸ€·β€β™‚οΈ

#

Hahahah

minor sluice
#

for example, now with 2020.1, they remove a few api approaches again, you don't have ForEach jobs anymore it seems, all is done through entity ForEach queries, but that also makes a lot of libraries unusable, even if the upgrade is easy to do

opaque ledge
#

What API change exactly tho ? i have been developing with ECS for 7-8 months now, and the first system i wrote it still works (only updated to SystemBase but wouldnt matter, it would still work)

minor sluice
#

but I'm glad that unity informs us what is obsolete through docs and intellisense shows that

tardy spoke
#

Oh shit, mine is still all in foreach jobs and I'm on 2020.1 😐

minor sluice
#

oh, they still work? πŸ€”
interesting, because I get this

opaque ledge
#

IJobForEach is deprecated but its still usable i think, no ?

tardy spoke
#

Wait, are the entity queries replacing the for each loops??

minor sluice
zinc plinth
#

I hate so much that you can't even see dependency packages in 2020.1 --'

opaque ledge
#

but thats just green warning, not an actual error πŸ˜„

deft stump
#

being marked as obsolete doesn't mean it doesn't work.

opaque ledge
#

it would still work if you use IJobForEach

tardy spoke
#

ohh IJobForEach is being depricated, not Entities.forEach, gotcha

hollow sorrel
#

@zinc plinth its a setting of package manager now

minor sluice
#

now the entities foreach queries are easy to write, but they are not that verbose for me,
like, how are local variables in the OnUpdate passed for burst compiled jobs,
i can still access them in foreach, I have no idea what happens under the hood

deft stump
#

I hate so much that you can't even see dependency packages in 2020.1 --'
@zinc plinth you still can

zinc plinth
#

where's the option ?

#

ho just saw it

deft stump
#

isnt Entities.ForEeach just Entity Query + IJobForEach under the hood?

opaque ledge
#

0.12 patch notes above 2000 characters πŸ˜„

#

Entities.ForEach is IJobChunk under the hood

#

and i believe EntityQuery is still being used in ForEach->IJobChunk, tho i am not entirely sure

zinc plinth
#

Updated minimum Unity Editor version to 2020.1.0b15 (40d9420e7de8) talk about bleeding edge --'

tardy spoke
#

Are entity queries a new thing, an old, thing, and are they sticking around? Hahah

deft stump
#

laughs in 2020.1.0b16

tardy spoke
#

I've seen them occasionally across tutorials but am not sure where in the ECS timeline they fit in, if they're coming or going

deft stump
#

entity queries are an old thing. and they will be sticking around

#

as they're a part of the whole ecs paradigm in general

tardy spoke
#

Ah k, so they've just become obfuscated by some methods that kind of use them in the background or something?

opaque ledge
#

yeah its an old thing, but it still have its uses

minor sluice
#

VS tells me that entity queries are not deprecated

opaque ledge
#

IJobForEach is the thing that is being deprecated

deft stump
#

Ah k, so they've just become obfuscated by some methods that kind of use them in the background or something?
yes

tardy spoke
#

Gotcha.

minor sluice
#

I liked the IJob syntax though πŸ˜…

that reminds me,
IJobForEach, you could just use an attribute [ChangedFilter] or something and I think the object should only run when unity detected a change with that component?

does anyone know how to implement this with Entites.foreach?

opaque ledge
#

Yeah, .WithChangeFilter<Type>()

#

obviously the type you write has to be inside ForEach query

minor sluice
#

ah, thanks a lot

tardy spoke
#

Hmm, shouldn't that just be always used?

#

Or will it figure out by default if there are no changes for performance

#

I assume it has some intelligence that makes it speedy

#

it's so unintuitive from a programming standpoint to loop through data repeatedly for "performance", hahaha

minor sluice
#

I wonder what happens under the hood? is unity changing a flag or a version number for the component on each change?

I think it makes sense to not use it per default, because that wouldn't be expected behaviour for an "update" system

deft stump
#

it's so unintuitive from a programming standpoint to loop through data repeatedly for "performance", hahaha

#

what do you mean?

tardy spoke
#

Oh, I have a question, haven't really came across this in any tutorial yet.

You know in monobehaviours you can run a coroutine and yield wait whatever seconds, what's the ECS equivalent of that? How is something that updates once every 5 seconds performed? Is there a specific method or is it just done with tag manipulation or something (which seems fairly inelegant but would work?)

deft stump
#

Normally I just use a flag/bool

#

and have another system check the time and manipulate that flag

zinc plinth
#

jobs is also now on 0.4

opaque ledge
#

"Added SystemBase.GetBuffer/GetBufferFromEntity that are patched so that they can be used inside of Entities.ForEach." \o/

tardy spoke
#

so just a component holding a time counter on an entity, and something like if the time is greater than 5 seconds do this and reset to the component to 0?

deft stump
#

imo, it's not that cache friendly, since the CPU is smart enough to cache in future instructions.
and having a flag that says, nope! just hurts the whole cache friendly thing.
but the performance hit is very minpr/ miniscule..

tardy spoke
#

What I said may be dumb, I'll figure it out. Just curious if there was a specific way or not, haha.

deft stump
#

so just a component holding a time counter on an entity, and something like if the time is greater than 5 seconds do this and reset to the component to 0?
@tardy spoke yup something like that

tardy spoke
#

Yesss. I'm getting slowly smarter.

deft stump
#

I have an example code on it

#

lemme get it

tardy spoke
#

Awesome, thanks! Appreciate it.

minor sluice
#

hmmhh, that's an interesting question,
can you maybe also make a system group and have them manually update in a monobehaviour - run the coroutine and just call update on the group or system of the entity manager in there?

deft stump
#

that's a huge performance hit

minor sluice
#

because it is outside the build in system cycle?

#

maybe having the manual loop in the OnUpdate in your specific system is better then

tardy spoke
#

Wouldn't that force withoutBurst, etc?

#

Due to the reference to the monobehaviour

opaque ledge
#

@tardy spoke btw, if you are doing some time stuff, dont reset time to 0, reset time to minus limit, for example if your limit is 5 seconds and when current time reaches 5.2 seconds, then reset current time to 5.2-5 = 0.2, otherwise you will lose the extra time and get weird behaviours

tardy spoke
#

Gotcha. So then it'll run more predictably every 5 seconds instead of having some possible variance

opaque ledge
#

yeah exactly, i lived that so πŸ˜„

tardy spoke
#

I could also see some problems occurring from the Systems stopping and starting at specific times if they are resetting to zero, if somehow the time on the Component isn't starting at 0 that could be a real tricky bug to squash.

minor sluice
#

i think if you have a jobsystem, you just return the input jobhandles if you don't perform an update, and if you detect that an update is due, you regularly schedule your job or entities.foreach

#

oh, I have another question,
how are people usually handling timescale within an ecs world, say if you want to slow the general deltaTime steps down,
do you use a singleton component or something? or a static variable that you read before scheduling a job?

deft stump
#

@tardy spoke
here's the example.

    public class BulletSpawnSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            var delta = Time.DeltaTime;

            Entities
                .WithNone<Prefab>()
                .ForEach((ref GapData gap) =>
                {
                    if (gap.countdown <= 0)
                    {
                        gap.active = true;
                        gap.countdown = gap.timeGap;
                    }
                    else
                    {
                        gap.countdown -= delta;
                        gap.active = false;
                    }
                }).Run();
            Entities
                .WithNone<Prefab>() 
                .ForEach((/*SomeComponentes*/,  in GapData gap) =>
                {
                    if (gap.active)
                    { 
                        //Do stuff
                    }
                 }
        }
    }
tardy spoke
#

@deft stump thanks! That's a pretty easy to understand and concise way to do it. Just my style, hahah.

#

Also I haven't done a lerp yet in ECS.

I take it lerps are pretty much done the same way, just in OnUpdate()? Any weird pitfalls to be aware of vs monobehaviours?

deft stump
#

lerp as in... lerping between points?

tardy spoke
#

sure, let's just say lerping a position

#

or a material hue or something

#

vector1, keep it simple lol

deft stump
#

use math.lerp in OnUpdate.

#

I have example of that too!

#

XD

tardy spoke
#

Awesome, I love examples, hahah.

deft stump
#
    public class MovementOnPanelIndexSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            
            Entities
                .ForEach((ref Translation translation, in EntitiesToPanelData etp) =>
                {
                    var dataindex = panelData[etp.panelDataIndex];
                    if (dataindex.index.x == etp.index.x && dataindex.index.y == etp.index.y)
                    {
                        translation.Value.x = math.lerp(translation.Value.x, dataindex.coordinates.x, 0.5f);
                        translation.Value.y = math.lerp(translation.Value.y, 0.60f, 0.5f);
                        translation.Value.z = math.lerp(translation.Value.z, dataindex.coordinates.y, 0.5f);
                    }

                }).Schedule();

        }
    }
#

@tardy spoke this code just lerps between positions indicated in the EntitiesToPanelData ICD.

#

I know you can make the code shorter, but I just got lazy.

tardy spoke
#

Interesting - I must be missing something, because why does the .forEach not "restart" the LERP each frame causing it to stay in it's initial position? I'm assuming the third argument in math.lerp is the duration of the LERP?

#

IE 0.5F

deft stump
#

yup. that's the duration.

tardy spoke
#

Yeah, I figured that that may have to be extracted out into another System or something to do a LERP, but in your examples it appears that is not the case. Interesting.

minor sluice
#

what's the difference between using system base and returning nothing with a scheduled job, vs JobSystemBase and return the handle of the scheduled job?
system base job runs without waiting for dependencies to complete?

zinc plinth
#

isn't everything but SystemBase deprecated ?

deft stump
#

SystemBase still wait for dependencies to complete

minor sluice
#

so it is all under the hood? interesting

deft stump
#

if you have multiple entities.foreach().schedule() all stacked up in onupdate. Systembase automagically assumes their dependency order.

minor sluice
#

I feel like having the inputDeps passed and having to return a new handle is more explicit

safe lintel
#

inputDeps is now Dependency and is a property of the system, you can still have the old functionality of the JobComponentSystem if you desire(and for certain cases you will need to)

coarse turtle
#

oh when did Unity add the FixedStepSimulationSystemGroup

#

o - i guess I'm 2 versions behind lol

safe lintel
#

eventually physics will be moved into that group right?

#

oh nice it actually updates dependencies now even if you have them already in your manifest(unlike before)

coarse turtle
#

I think physics would be moved there - it would be nice to have it such that you woudn't need to manually construct systems that live in a monobehaviour for a fixed time step

safe lintel
#

ok just read that they do plan to move it there

#

new hybridrenderer seems to be working much better with the latest package manager universal

#

example scene renders properly, still limited to one light but at least it doesnt appear glitchy now

spark glade
#

AoE Heals, AoE Damage, Impact Explosions with Knockback, Damage over Time πŸ₯³

#

Sorry, had to share πŸ˜„

safe lintel
#

how are you handling the particle effects?

spark glade
#

AddHybridComponent

#

No pooling or anything.

safe lintel
#

and its not a significant performance factor?

spark glade
#

It's good enough πŸ™‚

#

One thing I might do is slightly jitter any attacks (like add 5% variance in attack speed/cooldowns), so that they don't all trigger the exact same frame, but instead over 2-3 frames.

safe lintel
#

anyway looks cool, always wanted to make an ability system like dota2

#

did entities skip over 0.12 being public? seeing a number of api changes which apparently exist in 0.12 and not 0.13

coarse turtle
#

that's what I was thinking πŸ€”

#

But i thought I had just missed the update since I wasn't actively looking for updates in the package manager, but I did tune in every now and then to check

safe lintel
#

i committed a bunch of changes without really thinking and then noticed all these little changes that I didnt remember making πŸ˜…

tardy spoke
#

Is this standard practice at all?

I need to reference another entity's location in SystemA.

The Entity is the only one of it's kind, so I'm just writing it's translation values into it's "own" component (that isn't shared with anything else) with SystemB.

Then simply reading that value in with SystemA.

Is that... normal? Haha.

coarse turtle
#

So SystemB -> updates position of Entity X, and SystemA reads the position of Entity X?

tardy spoke
#

I'll clarify, I think I made it more complicated than it is.

Entity X: I have a unique component called MyLocation.

SystemB: I will write Entity X's location to MyLocation component.

SystemA: That's awesome. I shall read that in.

#

But yes, I believe your understanding is correct!

#

I'm just trying to think of if one system could do both of those functions or if the two discrete Systems are required.

rancid geode
#

There is no right or wrong there. Yes, this is a common practice, but do the way that seems more intuitive for you (if you think that splitting between two systems is not giving you anything more than headache, then combine into one and move on)

tardy spoke
#

Yeah, by systems I more meant into one Entities.forEach loop*, but yeah.

deft stump
#

Honestly, imo, i'd recommend that approach

hollow sorrel
#

if MyLocation is just a Translation you could also just use a unique tag component

#

with a regular Translation

tardy spoke
#

I think that's what the plan is?

#

It has a unique tag, is there some fancy way just to grab the translation from that entity from just the tag inside a Entities.forEach?

deft stump
#

WithAll

tardy spoke
#

The one thing I do like about the two system approach is although it's pretty verbose it's explicit with easy logic to follow.

#

Hmm, yeah but if I do WithAll both the trick is if I apply a translation it will affect both entities, correct? Am I missing something?

#

Because I need to apply the one's translation to the other, haha.

#

I'm totally fine with the two system solution, but if anyone knows a way that is better practice just let me know. I was just making sure it wasn't a crazy thing to do before implementing it.

coarse turtle
#

Well you can do WithAll<Translation, UniqueTag>() to uniquely get the entity

#

if it's also a single entity, you can also just grab it by someQuery.GetSingletonEntity() and grab the data on the main thread w/ EntityManager (if it hasn't changed recently GetSingleton and GetSingletonEntity complete read and write jobs from what I remember seeing in the source)

tardy spoke
#

Right! I'll look that up. It'll likely run on the main thread anyway because it's closely tied with the user's input controls, so running a query and getting the entity could be an option. And something cool to try out.

spark glade
#

anyway looks cool, always wanted to make an ability system like dota2
@safe lintel Haha yes, now that I have a flexible ability system I can finally put my personal Dota2 experience to work πŸ˜„ It's pretty cool how AoE and DoT combine into sooo many possibilities. I.e. Lich Chainfrost can be made as a projectile that launches a projectile on impact. Or Necrophos Death Pulse is a AoE launched projectile.

safe lintel
#

make your own ability draft game 🀩 i always loved giving melee characters focus fire

spark glade
#

Interesting idea, I AM planning a "Hero" system to spice up the gameplay πŸ™‚

maiden cape
#

Hey there guys, I have a question regarding level-design when using the DOTS stack.

#

Since using the ConvertToEntity script is quite slow and causes a large startup delay, the only other way I can think about building the world is by manually creating entities in code.

#

Is there a more straightforward way of handling level design with the DOTS stack?

tardy spoke
#

Subscenes?

maiden cape
#

I'm not following, how would subscenes help?

#

My world is quite small, I'm just talking about the initial GameObject placement. (Terrain, Trees, Houses, Water, etc.)

#

I've created all of my Components and Systems and I need to start world building so I can test things outside of a plane.

pliant pike
#

all static environment stuff should probably be subscenes that seems to be Unity's preferred way

maiden cape
#

Oh, I completely jumped to the wrong assumption of additivescenes.

#

Whoops.

#

I'll take a look.

pliant pike
#

they should be converted before it runs in editor mode

#

see if it runs any better

maiden cape
#

Sure thing, and as for Terrain are there any ways to convert this so it will render and work with Unity Physics?

#

Or should I just generate the terrain as a model and bring it in.

tardy spoke
#

Not sure if subscenes convert terrain physics, but they will convert most physics colliders etc, into the new unity physics versions that ECS uses

pliant pike
#

there are physics, its all in beta though so it might be a headache working that all out

tardy spoke
#

so worst case scenario would be bringing it in as a mesh

maiden cape
#

That's fine, I only need very basic physics anyhow.

#

I may end up writing a totally different movement system. My prototype was running a server that didn't use DOTS but I've redone the server using DOTS and left the client using traditional Mono as I build for WebGL, the issue there is my client-prediction for PhysX isn't going to work with Unity Physics so I'll probably end up having to redo that entire system

tardy spoke
#

You could look into Havok as well, I think they released something for Unity recently

maiden cape
#

I'll check it out. I just need to make sure that basic physics work. Can't run through walls. Can jump over flagged walls with certain abilities. Can probably get away with some simple raycasts, just need to test performance.

mint iron
#

i just spent far too long debugging an issue, only to find out that we'd gone back to 1999 and/or present day unity when serializers wouldn't handle dictionaries. 😠

pliant pike
#

oh yeah I found that out a little while ago, that's why I'm avoiding using them

mint iron
#

i know its off topic it just really grinds my gears when i encounter these archaic holdovers and i need to express some rage somewhere. πŸ˜†

pliant pike
#

no worries I know the feeling

deft stump
#

this new visibility changes in the package manager really hurts

hollow sorrel
#

ecs physics are really solidly built already, imo wouldn't even guess it was beta if it didn't say
wether it uses good general-purpose design is debatable, it seems to only be good at the use cases unity is targeting, but it does those use cases very well

#

but i don't think that's going to change in the future since it's baked into the core design

#

like colliders being immutable shared data instead of being able to just modify any entity's collider easily

safe lintel
#

if we fast forward like 5 years, im imagining the community coming up with cool stuff to offset the shortcomings in its design

#

with all the source available

#

already some really impressive ecs physics stuff demoed outside unity physics so i think its a cool space to watch

deft stump
#

So WithDeallocateOnJobCompletion is being replaced by WithDisposeOnCompletion

buoyant aspen
#

May I know if ECS is currently production ready and stable? Or I should stick with Monobehavior for now?

hollow sorrel
#

no it is not

#

use it for learning purposes but if you just want to make game stick with monobehaviors

minor sluice
#

I heard about someone who has an ecs game in production, but I think it is not recommended, you could freeze your unity version and package versions and keep developing with them,
I have no idea about the issues for ecs on different platforms though

hollow sorrel
#

yea there is a couple but they also had to basically make their own engine in unity because there's just the basics for ecs atm

#

which can be fine for some ppl but it's hard to recommend if someone asks about production ready

storm ravine
#

πŸ‘€

#

Weeeeeeel, if you experienced programmer, then you can use it easily (I'm not experienced, but anyway using DOTS in production)CrabPls

vagrant surge
#

ive been keeping an eye on it since day 1 (to hopefully use it on a project)... and i think stuff is still in too bad a state

willow plaza
#

I mean, you don't have to use it for everything in your game. There's the hybrid approach or you can just use jobs for some heavy tasks.

#

And the earlier you get into the dots workflow the better your game will be able to compete on the market when it is actually ready for production and everyone starts using it.

gusty comet
#

For DOTS, do I need any other packages besides com.unity.entities

storm ravine
#

All required packages will be in dependency. Only thing which require separate install - hybrid renderer.

#

Entities 0.13 released, with all related packages

gusty comet
#

Is there a project demonstrating DOTS and unit testing?

willow plaza
#

@storm ravine is it available in 2019.4 or only the latest alpha?

gusty comet
#

it's available in the 2020 releases but you have to edit the dependencies manually to get it to appear.

willow plaza
#

So they've stopped releasing for lts? Are any of the coming dots package updates gonna be supported only on 2020 and higher?

gusty comet
#

From what I understand, Unity wants to proceed with DOTS as a primary focus moving forward.

minor sluice
#

I think I have read that for the upcoming packages related to dots, you need to have unity 2020

gusty comet
#

So like, does Unity with DOTS use components at all on GameObjects? Do GameObjects exist? Looking at the editor with 2020 I still see support for components.

To give you a practical example of what I'm doing, I am doing a tile-based 3D game. A tile contains air with atmospherics. The tiles know their neighbors and on updates they exchange gasses with their neighbors. This isn't all the work of the Tile's component, but other components they are attached to that look for the Tile and then use that to figure out their neighbors.

#

How would I even approach any of this in DOTS? Where would I even begin rigging this in DOTS?

vagrant surge
#

@gusty comet depends on the number of tiles you have

#

if the tiles are in the dozens up to hundreds, you would normally do something similar to what you explained. You have one entity per tile, and they have different components for their data

#

if you are thinking on a full on voxel system where you have hundreds of thousands or more tiles, what you normally would do is to avoid the ECS part to begin with, and write stuff with Native containers + job system

minor sluice
#

there could be a componentData that stores the neighbor entities, and in a system you execute the exchange,
I think it might even be possible to do this in a job by using ComponentDataFromEntity groups

instead of a gameObject with multiple components, you have entities with different components and component types, but it is likely that those components are smaller and more modular to make efficient use of ecs

amber flicker
#

it seems (on latest hybrid renderer) that with a DisableRendering tag RenderBoundsUpdateSystem still does some work - are the bounds used for things other than rendering? I guess maybe related to lod stuff?

scarlet inlet
#

Hello! Hopping in for another question of mine. Does the JobParallelForBatch support nativeThreadIndex as far as you know?

mint iron
#

i haven't used that job type specifically but i think it should work, i think its more tied to the parsing of structs passed in than something job specific.

gusty comet
#

it's very unfortunate that so much DOTS language overlaps Unity language, especially the ECS Components vs. GameObject Components

chilly bobcat
#

How can I install Entities to Unity 2020.1? It's not in the package manager (yes I enabled preview packages), and I also couldn't find anything on google

deft stump
#

yup. it gets confusing when you're trying to explain it to someone who wants to learn DOTS but the language barrier just makes it more confusing to them

#

How can I install Entities to Unity 2020.1? It's not in the package manager (yes I enabled preview packages), and I also couldn't find anything on google
@chilly bobcat for now, unity hid it.
but there is a way.
press the plus icon on the top-left.
then Add package from git URL
then paste this "com.unity.entities"

chilly bobcat
#

Ah thank you!

deft stump
#

yo, 2020.1 is out of beta

amber flicker
#

before 2021! nice! πŸ˜…

deft stump
#

in the future, we'll get unity 2022 in 2023

storm ravine
#

@storm ravine is it available in 2019.4 or only the latest alpha?
@willow plaza 2020.1+. Entities 0.11 was last release on 2019 cycle

willow plaza
#

I see. Thanks. Do they plan to get out of preview in 2020?

storm ravine
#

Entities 1.0 was planned to 2020.1 cycle (which can end in the late autumn and even winter)

willow plaza
#

Isn't 2020.1 out already though? oO

storm ravine
#

Read again

#

(which can end in the late autumn and even winter)

#

2020.1 cycle doesn't mean at 2020.1 release

willow plaza
#

by 2020.1 cycle you mean versions up to 2020.2?

#

otherwise I don't understand what a cycle means><

amber flicker
#

don't suppose anyone here has got livelink to work?

storm ravine
#

by 2020.1 cycle you mean versions up to 2020.2?
@willow plaza yes

willow plaza
#

ah okay.

#

meaning it should be production ready package in 2020 lts i guess?

gusty comet
#

https://ghostbin.co/paste/qp3fx
Here's my code for chemicals in my game I was working on in 2019. These structs are populated with data from an XML file and are referenced by a chemical identifier from scientific database.

I'd like this to be as fast as possible. Everything in the game has to reference chemicals constantly and make determinations about its chemical properties based on temperature. How can I start converting this to ECS?

#

Can I just pull all this into a component and have entities created for each chemical?

amber flicker
#

strings can be a bit of pain but otherwise all your data looks blittable so yea, you can put that in an IComponentData etc - if the data is immutable (chemicals that never change) you may be better off creating BlobAssets of the data and having entities ref those

#

My project's building again with the latest entities+platforms πŸ₯³ - though I'm noticing the exe has frame rate capped at 30fps regardless of vsync & Application.targetFrameRate and with cpu & gpu overhead (60fps+ in editor) - anyone else seen something similar / built with the new pipeline? (cc @craggy orbit aka only person I know who's tried to build their project 😬 )

pliant pike
#

what would be a good way to have an entity component list reference a blobasset, like the base stats, and then adjusted stats, would it be enough to just have both lists in the same order, or would it need more connectivity like the same unique ID on both

amber flicker
#

not sure I really understand but I have no problem with sharing indicies if you're working with something deterministic and simple/explicit - though at that point you might usually put the data in another data structure anyway? Are adjusted stats a mutated version of base stats which is a blobasset?

pliant pike
#

yeah the blobassets are fixed immutable data, I figured I would create entity components for the parts that might change

#

if I keep both arrays the same size it should work fine I guess, if it needs data from the blob then it just looks up its own indice on that

odd cipher
#

Is it possible to set a texture on an entity? I've never really used entities before.

amber flicker
#

I guess it depends a bit on a)if you ever need to reference the base stats, b) how often you access that data and c) by how many systems/different purposes? But what you've described should work I think.

gusty comet
#

Is DOTS not working in 2020.1?

amber flicker
#

it is working (aside from my project crashing on start up with b16 right now)

gusty comet
#

I added the dependency but Unity.Entities isn't defined. I'm reading I might have to add it to an assembly file but I don't see that in my file explorer.

amber flicker
#

my guess is an issue with your manifest file - if you share it on pastebin or similar I'll take a quick look

odd cipher
#

anyone?

amber flicker
#

I don't think what you're asking makes that much sense @odd cipher - if you're talking about sprite renderer's converting to pure entities, that's not a thing yet. You can set up a material on a quad though.

gusty comet
#

I might just have to wait until they release the new entities package for 2020.1.0f1

#

because the latest preview does not support it

#

probably just that

amber flicker
#

I'm using it fine... 0.13 with 2020.1.0f1

tardy spoke
#

I'm also using it fine

gusty comet
#

How did you add it? I tried forcing it into the assemblies definition for the game and it threw more errors

#

I have the package installed

tardy spoke
#

2020.1.0b16

#

What platform are you on?

gusty comet
#

Windows 10 64b

amber flicker
#

so.. you have an existing game and your project already has some assembly definition files correct?

tardy spoke
#

Is your unity project brand new? Like a test?

gusty comet
#

Existing concept from early that I'm trying to upgrade to 2020 and DOTS.

tardy spoke
#

Hmm, if you make a new project, you could try pasting my package manifest.json in?

#

see if that works

#

I'm on a mac but the packages look pretty platform agnostic

amber flicker
#

If you have existing asmdef files you'll need to add appropriate packages - this is mine but you don't need Timeline or Rendering.Hybrid

gusty comet
#

i'll try that first, sec

tardy spoke
#

Yeah I tried installing dots on an existing project and it had a bunch of problems... created a new project in 2020.1 and it installing them went fine. Painful, but a lot of the packages are only having continued development on 2020.1

zinc plinth
#

hol up

#

2020.1 is out of beta ?

ocean cloud
#

yes

opaque ledge
#

what really ? damn

ocean cloud
#

and Entities 0.13.0 just released

opaque ledge
#

i should download it

ocean cloud
#

AppendSystemToPlayerLoopList(): adds a single ECS system to a specific point in the Unity player loop.
Finally

amber flicker
#

yea plus the multiple component add/removes πŸ‘

ocean cloud
#

Is Unity.Scenes gone?

#

Nvm the asmdef renamed from Unity.Scenes.Hybrid to Unity.Scenes

deft stump
#

ecb now has multiple component add/remove?!

amber flicker
#

yea

#

AddComponent(Entity, ComponentTypes) and AddComponent(EntityQuery, ComponentTypes)

#

and same for remove. EntityManager will have them to but atm has the non entityquery versions

ocean cloud
#

Wow

#

There's FixedStepSimulationSystemGroup now

#

every system inside it is updated like in a FixedUpdate

#

0.12.0 got some great feature additions, why did they wait for 0.13.0 to release the update 🀨

craggy orbit
#

no clue, @amber flicker , sorry 😦 i actually can't build right now. Unity can't build at all on the latest mac beta (which im on)

amber flicker
#

appreciate reply - I've found out I don't need to be using the new build pipeline at all (windows desktop)? So unclear about when you need to use it

odd cipher
#

Are entities faster to "spawn/create" than GameObjects?

amber flicker
#

much

tardy spoke
#

If it's already an existing in the system (as in you're making a copy) it should be very quick to instantiate

odd cipher
#

I'm thinking of replacing my chunks with entities. It would probably make them faster to create?

#

since I'm Instantiating each time

tardy spoke
odd cipher
#

I mean like terrain divided into chunks. Minecraft style :p

tardy spoke
#

Right. Hmm, it might be as simple as throwing your terrain under a Subscene (which auto converts to entities and I believe stores everything in some kind of super fast loading binary format). Other people here would know a lot more about that than I would, unfortunately. I'm not sure if Unity Terrain gets along with Subscenes, but I thiiink it does?

#

Unless you mean mesh terrain, then it would be fine for sure.

#

Is the terrain dynamic or interactive or something?

odd cipher
#

The terrain is 2D and all of it is on a texture. It's sort of dynamic I guess? The texture does have some animations

#

A chunk is pretty much just one texture

tardy spoke
#

Interesting. I have a feeling you're likely going to probably want to optimize what you already have if possible, and start researching the applications of ECS with some experiments. To me it would seem fairly challenging to mix ECS/Entities OOP/gameObjects/monobehaviours on existing projects without having things break.

#

As in it may not be a quick and easy performance fix you're hoping for, haha. ECS is super cool though. Definitely play around with it for sure.

odd cipher
#

Yeah I use Jobs and Burst right now. The textures are procedurally generated but each chunk only takes around 0.6ms to generate.

#

aside from instantiating them. Which probably takes longer? I don't know.

tardy spoke
odd cipher
#

Yeah hmm. I don't really know if theres a set amount of time it takes for a GameObject to instantiate. If entities does it faster than yeah performance would be quicker

#

not sure how to find out how much time each one takes though

tardy spoke
amber flicker
#

fyi rough numbers - desktop pc, instantiate 1mil entities ~1ms - that's the order of magnitude - thousands of times faster than GOs. That's why converting and serializing in subscenes is exciting πŸ™‚

odd cipher
#

Hmm yeah not sure how I would make it work though. Because my chunks stay in one scene to another; Forgot what that was called but yeah. Not sure if its possible to do that with subscenes?

amber flicker
#

If the goal was to generate a world through instantiating tiles with certain rules, I think Unity has a procedural dungeon project that's a good reference (or will be). It depends a lot on why you are doing things the way you are - specifically your design goals.

tardy spoke
#

I believe you can't just write some sort of fancy query that reads in the info from both entities but only applies the changes to one - because I think that breaks basic ECS principles and would be potentially dangerous to multi-threaded operations. Is that correct or am I missing something basic?

#

And in actuality the shared component wouldn't literally be the Translation component, but a new shared component like "SharedTranslation".

amber flicker
#

hmm nothing wrong with doing foreach(Entity e, in someData d) SetComponent(e, GetComponent<Translation>(d.someEntity)); if that's what you mean?

#

Be careful with SharedComponents - you very rarely need them - it's for when you deliberately want to fragment your chunks

#

wait, that's not 100% - you can't take in Translation in the foreach at the same time as using GetComponent (unless something's changed)

tardy spoke
#

Hmm, I think something that makes it a little more difficult is the Entity C's translation actually needs to be the negative value of Entity B's

#

so a foreach that affects the translation of BOTH components is a no go

amber flicker
#

you can, it's just that all the usual parallel writing caveats apply - i.e. if you want to do it in parallel make sure you only ever write to unique indicies - in this case if you wanted to change both at the same time, you couldn't do that (safely) in parallel but you could easily enough do it as two jobs

tardy spoke
#

Right, I think I have to look into the "SetComponent" and "GetComponent" stuff you wrote there. That's likely the piece I'm missing. πŸ™‚

amber flicker
#

yes - given you previously mentioned you had time to learn this stuff I would recommend learning about IJobChunk and writing a few of those - it will make some of the more magical things much more explicit

#

Get/SetComponent abstract away ComponentDataFromEntity<>

tardy spoke
#

I was just looking into that and entity queries in the manual! Good idea. Will do.

amber flicker
#

They can still do one thing the lambda's can't - efficient chunk-based logic - writing code that branches based on the presence of a tag for example.

#

They also give a great appreciation for how much less verbose the lambda's are πŸ˜†

tardy spoke
#

That's interesting. I'd probably have to develop a better understanding of the lower level chunk system to really understand the benefits of the branching logic in jobs. I'd probably do more harm than good right now, haha.

#

I'm actually not even sure exactly what the "chunks" are in a literal sense. Are they structs (archetypes) holding arrays (components)? Was wondering that reading the manual, haha. In javascript most people use either an object or an array, but C# has all these cool different types of arrays and lists, etc.

amber flicker
#

Very worthwhile getting your head around it. Some good materials (inc docs), just need to parse them multiple times. An Archetype is defined by a unique combination of types. Consequently an entity that is of Archetype A has an explicit size. A chunk is a contiguous block of memory that stores as many 'instances' of A as will fit (a chunk is typically 64kb) so this tends to fit e.g. hundreds of entities of Archetype A. When you have more than hundreds, another chunk of the same Archetype will be made to accommodate them.

#

Thus you could have e.g. chunk1(ArchetypeA), chunk2(ArchetypeA) & chunk3(ArchetypeB). If Archetype A & B both have a component in common (let's say Translation) then when you want to iterate Translation you will be iterating over chunks 1, 2 & 3.

gusty comet
amber flicker
#

Generally only put them together in an IComponentData when they are somewhat dependent on each other and would never be queried for independently. Thus, usually best to have small ICDs.

gusty comet
#

Is there a way to quickly suss out how many chunks a struct is for complex types like Color?

tardy spoke
#

@amber flicker thanks for the explanation! It all helps everything click, haha.

#

@amber flicker I agree with the small ICDs for flexibility. Kind of interesting even just starting my project I've almost hit the 8 component query limit on some Systems. Will probably end up using the special structure that allows you to do more than 8 for a few systems down the line.

frail seal
#

Does dots currently feel more-or-less finished?

#

Or is it still pretty raw?

safe lintel
#

raw if you are a beginner

#

not finished even if you are advanced but useable

amber flicker
#

@gusty comet the entity debugger has a view for seeing how many chunks there are for a particular archetype

frail seal
#

Is it still not recommended for serious projects?

safe lintel
#

not recommended for production

tardy spoke
#

It feels like being punched in the spine if you are a beginner.

#

To me.

safe lintel
#

doesnt mean you cant start learning it πŸ™‚

#

learn to be punched in the spine πŸ˜„

frail seal
#

I'm not a beginner, but I'm still not familiar with Dots to a huge extent. A lot of holes in my knowledge, since it's hard to learn it while it's constantly in development.

tardy spoke
#

Lol, being uncomfortable is how you grow as a person. I must be growing a lot.

frail seal
#

Methods and classes constantly change

tardy spoke
#

Join the club. We've got jackets.

frail seal
#

But again, are major changes stopping nowadays?

#

Are they getting to the polishing phase or nah?

amber flicker
#

I don't feel like it actually changes that much... but.. it does involve e.g. reading the changelog of every package update

safe lintel
#

if you want to make a product to ship, id advise not using it tbh. use burst and jobs when the need arises but for the rest of it, it will probably hinder you unless your timeline is like +3years

frail seal
#

Well, it is a dream project more or less, so whatever

#

I'll try upgrading to newest Dots version, hope nothing breaks in my old project

safe lintel
#

theres still no real: animation, sound, navigation.
spotty/early: rendering, netcode
physics is shaping up nicely and the basic transform system works well

always backup and use version control

tardy spoke
#

However there is real: pain

#

and suffering

#

implemented from the beginning

amber flicker
#

colon pain? 😬

tardy spoke
#

: pain, correct

#

a child class of other pains

frail seal
#

So, there are no animations/audio/physics/netcode? Oh, then it's all fine.

tardy spoke
#

You can make Zork

frail seal
#

I have couple ideas how I could interface Mirror with Dots

amber flicker
#

moving things are over-rated

frail seal
#

And I'm making my own physics anyway

lusty otter
#

I just learned that if you use IL2Cpp backend you can write native plugins in C++ directly.
Can Job System/Burst use native plugin code in parallel?

frail seal
#

And audio? I could just use gameObjects.

#

Meanwhile animations don't matter, since I'm doing a space game.

tardy spoke
#

They always start so optimistic. πŸ€”

frail seal
#

We sure do

tardy spoke
#

ECS will break you down. Rebuild you.

amber flicker
#

I'm doing my bit to help with animations.. sometime this year I hope

frail seal
#

I've done some stuff in ECS, and it f'ing hurt

#

But I'm that kind of hedgehog, who keeps on eating cactus despite it's needles

tardy spoke
#

I come from Javascript with no OO background, so it's just a treat

#

So an OO layer wrapping an ECS layer

safe lintel
#

@amber flicker what do you mean?

tardy spoke
#

is just... dinner and dessert

frail seal
#

I like Dots for the fact, that it allowed me to have 40 thousand asteroids attracted to star

#

And I could render all these roids via URP

frail seal
#

Although, speaking honestly, my CPU got to 100% load only when I spawned about 4 million of them

amber flicker
safe lintel
#

ooo yes, looking nice!

amber flicker
#

thanks! much appreciated

frail seal
#

So

#

What ECS version should I actually install?

#

Is 0.13 stable enough?

amber flicker
#

what counts as stable enough? will it crash and error sometimes? maybe? like all other versions πŸ™‚

frail seal
#

sigh

#

Oh well, I'll just clench my teeth and brace for the crashes

amber flicker
#

you need to wait if you want something labelled production ready - for the past year I've had almost no crashes but the more you mess around with subscenes, physics & netcode, the more risk is involved

frail seal
#

I will mess with those, but in form of me implementing my own systems

#

It's not like I could use Unity's physics with scale I'm aiming for anyway

#

64bit - 1love

lusty otter
#

I can't even use native containers without crashing, filed a bug report but I don't think it's going to get resolved anytime soon.

#

I was going to use Job System and Burst for performance but I think I'll just have to go native without that being fixed.

#

πŸ˜”

amber flicker
#

is this native containers in static methods? not trying to put them in ICDs I assume

frail seal
#

Oh god, I'm updating 0.1.1 to 0.11.1

#

Wish me luck

#

I'm scared to press the button

lusty otter
#

I'm fairly certain it's not any of my code if you look at the cases that cause crash.

amber flicker
#

that's quite hard to follow tbh - where are the arrays allocated?

lusty otter
#

Once at the beginning, persistent.

amber flicker
#

at the beginning? line/file num plz - nevermind, found it

pliant pike
#

is there no way to get a buffer without getting the entity first?

lusty otter
#

Yeah the project is pretty convoluted because it's a script interpreter.

pliant pike
#

I was hoping I could use GetSingleton with buffers by now

lusty otter
#

But those execution code don't really matter.

#

I suspect it's something really low level, maybe not even related to native containers, but yeah.

#

The techs that are meant to help me focus on the actual game is doing quite the opposite, and I just feel like giving up and going to native plugins and write my script interpreter there instead.

amber flicker
#

looks like it might be coming from one of your easing functions

lusty otter
#

Here's the thing though, only the Constant and Execute branch are ever executed in that switch statement.

#

It's not just easing functions, if you reduce the complexity of the code it just works.

#

You can remove some code that are never executed and it just might fix the crash.

frail seal
#

Are there any good sources to learn about Dots from?

#

If you were to ignore the documentation

#

Well nevermind

#

How do I update this job struct, so it fits with current Dots version?

#

I'm simulating attraction of some particles to attractors

safe lintel
#

use chunk jobs or the ForEach lambda with SystemBase

frail seal
#

Last time I remember trying to do that, I had some difficulties with accessing other entities from within ForEach, especially via int indices.

#

But okay, I'll try once more

dull copper
#

been out of computer for the whole week

#

missed hybrid update πŸ™‚

#

need to catch up now

opaque ledge
#

entities 0.13 as well πŸ˜„

pallid carbon
#

I'd like to play around with the ECSSamples, but whenever I try I'm met with tons of errors. I have an inkling it's to do with imported packages. Is there a certain unity build/packages update I'm supposed to use?

opaque ledge
#

there should be a package manifest file that shows that package that project is using, maybe check that ?

dull copper
#

I see they took my comment about lack of this seriously :D
Added MaximumDeltaTime property to FixedStepSimulationSystemGroup, used similarly to UnityEngine.Time.maximumDeltaTime to control how gradually the application should recover from large transient frame time spikes.

#

well, I can imagine they would have done this regardless

tardy spoke
#

I wish they would take my advice of "You should build it so I can understand it"

dull copper
#

but yeah, it's mandatory to have some sort of fail safe if you do fixed timestepping

tardy spoke
#

maybe that's coming the next version... πŸ€”

minor sluice
#

oh, that's actually a pretty useful addition, nice they included that

#

and even more so if you were the comment or one of the comments on the issue

tardy spoke
#

Hmm, simple time saving thing. If you are creating a new DOTS project, the hybrid renderer's dependencies seem to be pretty much all of the DOTS packages, so you can just install that one package and it basically installs everything you need.

spark glade
#

Uh oh, no I have to update to 2020.1

prisma anchor
#

I'm try to navigate to another scene, without ecs. When I try to destroy the existing entities, system and blob, I get an error. Ideas?

    private void OnDestroy()
    {
        _entityManager.DestroyEntity(_entityManager.UniversalQuery);
       // _world.DestroyAllSystemsAndLogException();

        if (_blobStore != null) {
            _blobStore.Dispose();
        }

        _gameObjectSettings = null;
        _world = null;
    }
craggy orbit
#

i've got a couple of things im confused about when looking at the profiler and im hoping someone here might know.

  1. why is there so much "empty" space? (Sephamore.WaitForSignal, the gray bits with nothing underneath)
  2. im not combining or completing any dependencies in the overarching system, so why is it trying to complete them all?
odd cipher
#

Is combining job handles faster than running both separately

deft stump
#

Sephamore.WaitForSignal is graphics thing

craggy orbit
#

odd that it's running with the rest of the CPU stuff πŸ€” not even in the presentation system group

#

ah never mind. i get it now that i've read what it's about. thanks!

craggy orbit
#

improving some graphics stuff reduced the number of times i see that, so that's good news for me πŸ™‚

tardy spoke
#

There's gotta be some straightforward code along these lines to grab a single entity with a single tag, right? But without the "singleton" system or whatever?

Entity sheepEntity = entityManager.CreateEntityQuery(ComponentType.ReadOnly<Sheep>()).GetSingletonEntity();

shut python
#

Hey guys, Unity 20.1 released but I wasn't able to find information about DOTS in the notes. Is it out of preview now? So can we start building games for production using the ECS now? πŸ™‚

#

If there are any official links for the DOTS release please post them πŸ™‚

opaque ledge
#

there is no DOTS release, DOTS isnt a package, made up with Entities, Jobs and Burst packages, Jobs and Burst packages are out of preview iirc, so they are ready for production but Entities package is still on preview

shut python
#

@opaque ledge so you mean the ECS is still on preview?

opaque ledge
#

yeah

#

yesterday they released 0.13 preview

storm ravine
#

Sephamore.WaitForSignal is graphics thing
@deft stump it’s not graphic thing. This is regular CPU semaphore which indicates that this thread waiting for something like threads synchronization - waiting other jobs, waiting for gpu thread, etc. In his profiler is exactly pure CPU semaphore waiting for other threads done (as called Complete and jobs chain in handle completes and main thread waiting other threads in this case)

storm ravine
#

i've got a couple of things im confused about when looking at the profiler and im hoping someone here might know.

  1. why is there so much "empty" space? (Sephamore.WaitForSignal, the gray bits with nothing underneath)
  2. im not combining or completing any dependencies in the overarching system, so why is it trying to complete them all?
    @craggy orbit 1) because not all things parallelized and can run at the same time, like writing and reading same type at the same time as it can be race condition and safety system prevents you from that, and RW-R jobs then runs in chain, and depends on job type, amount of data for processing etc. threads can idle while another jobs doing their work.
  1. depends on types (or if you manually doing that) systems builds dependency chains,
    under hood systems completes their own previous frame dependency and if it was hard work and wouldn’t fit in to this time range (between this system update calls) - this force complete it. Reason for that (and this is mentioned in source code) is preventing infinite, growing chain. Second reason - EntityManager, as some calls trigger sync point, other calls can trigger dependency complete (for write chain or readwrite, depends on that you’re calling)
gusty comet
#

Is there a guide that helps with converting existing code to DOTS?

vagrant surge
#

@gusty comet not really doable, its a very different programming paradigm

#

at least if you come from heavily oop-d monobehaviors

#

if your code was just algorithms on Lists, you can likely change to jobs on NativeLists and have it just work

gusty comet
#

let me send you something I wrote and where I'm at trying to convert it, it's mostly math and not a lot of OOP-based gameplay so it can be done I think

#

it was almost entirely written for unit testing and not scene testing

vagrant surge
#

uhm, if its stuff easily unit-tested and math-y, you should be able to mostly convert it straight

gusty comet
#

yea that's what I'm thinking, sec

#

DOTS does not compile yet, I'm trying to see fi that's the right idea

#

and I'm wondering where the conversion functions go (the GETs attached inappropriately to the static class)

#

so the chemicals would become entities, I don't need the Cid anymore because of the new entitymanager system, and the conversion functions would just become static functions on the static Chemical class?

vagrant surge
#

you have zero need to split things that much

#

just keep your original struct unchanged

#

it will be simpler for now if you just have that monolythic component

#

later down the line you can split it once you know what you are doing, and if you know splitting will be useful for some reason

gusty comet
#

hi, im creating an entity from a prefab with entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObjectPrefab, settings) and without instantiating it, an entity appears already on the entity debugger. Anyone knows why?

tawdry tree
#

It will and should be visible in the entity debugger.
If you want it to be a prefab entity, make sure it has the Prefab component; this will make it so that systems don't do anything to it (this also includes rendering, so no worries about that)

#

For an entity to exist, it must be in an entity world. Thus, when you make a prefab entity, it must be in an entity world. The Entity struct is just an id for a given entity in a given world.

gusty comet
#

It will and should be visible in the entity debugger.
If you want it to be a prefab entity, make sure it has the Prefab component; this will make it so that systems don't do anything to it (this also includes rendering, so no worries about that)
@tawdry tree Okay, so if I undertood you, the entity created with the Prefab component is mandatory and necessary in order to make instances of it. Also it is just a reference and is not modified by systems. Right?

amber flicker
#

You can instantiate an entity from another entity, whether the entity has a 'Prefab' ICD or not. EntityManager.AddComponentData(convertedEntity, new Prefab()); after your conversion will mean that the convertedEntity is ignored by all other systems in the world (unless a system specifically requires it)

gusty comet
#

Im doing this:
entityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObjectPrefab, settings);
this line creates an entity which is not modified by a system and appears in the entity debugger.
then I instantiate the entityPrefab:
Entity entity = entityManager.Instantiate(entityPrefab);
this one creates another entity and is system sensitive.
my question would be what exactly is the first entity that I do not instantiate.

amber flicker
#
Entity entityPrefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObjectPrefab, settings);
entityManager.AddComponentData(entityPrefab, new Prefab());
Entity entity = entityManager.Instantiate(entityPrefab);``` - this will give you two entities: `entityPrefab` will be ignored by all systems, `entity` will be your instance to do with as you please
gusty comet
#

All right, thanks

vagrant surge
#

@gusty comet they split so much because they are adding and removing them

#

they use them for states and things like that

#

in your example, your molecule never changes

#

and you dont have variations

#

so there is no need to split

gusty comet
#

oh I see, so they're using components as flags

#

right because structs can't change, I get it

#

So the other part of my code is what I call a Jar. A Jar is just a MonoBehavior class which handles the addition, subtraction, and division of chemicals, as well as the math for pressure and temperature. A lot changes in a Jar all the time, but for simplicity's sake, it is assumed all chemicals in a single jar are evenly heated.

So for this property on the Jar <Chemical struct, moles>,

public Dictionary<Chemical, float> Chemicals = new Dictionary<Chemical, float>();

How would DOTS work? Is that a job for IBufferElementData?

gusty comet
#

or I could just add as many as of these as I'd want to the Jar entity?

        public struct JarChemical : IComponentData
        {
            public Entity chemical;
            public float matter;
        }
minor sluice
#

afaik, each entity can only hold one componentdata of a specific type,
I have seen that there are blitable array implementations, but I think the common way might be this,
(although, just started watching the video, so can't say much)
https://www.youtube.com/watch?v=XC84bc95heI

βœ… Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=XC84bc95heI
Let's learn about Dynamic Buffers so we can store multiple values inside our Unity DOTS ECS Components. (Array, List)

Unity DOTS ECS Playlist
https://www.youtube.com/playlist?list=PLz...

β–Ά Play video
amber flicker
#

yes dynamicbuffers are the general solution for arrays of components. Remembering that every entity archetype has to have a fixed/known size, DynamicBuffers work by having a fixed initial size and after that, Unity abstracts away allocating memory on the heap and using that instead. Haven't watched the vid but codemonkey's are usually good

gusty comet
#

He covers the memory allocation in the first 6 minutes

gusty comet
#

Video suggestion on EntityArchetypes please

zinc plinth
#

It's a template of component, that's it nanamiLaceShrug

#

Makes it so that you don't have to have 50 AddComponent when you setup your entity

#

They actively exist in ecs tho, so it's way better if you create them at start and reuse them rather than recreating them everytime

gusty comet
#

okay so just to make sure, in DOTS: singletons are OK

#

because I've thoroughly beat into myself that if I have to use a singleton I'm doing something wrong

#

DOTS seems to suggest singletons are great

low tangle
#

singletons are okay and needed in some systems

pliant pike
#

I use singletons all the time

low tangle
#

use them sparingly as side inputs to systems

gusty comet
#

cheers, saw that video suggestion, I've seen some but not this

tardy spoke
dull copper
#

I pretty much disagree on the paid course

tardy spoke
#

Why?

dull copper
#

1: it's outdated
2: it doesn't teach anything beyond official examples and docs

tardy spoke
#

It's not very outdated? All the code in it would still work I believe even in 0.13 ?

vagrant surge
#

its indeed a bit outdated, but i watched it, and think its great

#

other than the outdated apis (easy fix), its pretty great to explain the flow of using it

tardy spoke
#

No, but the reason it's valuable to myself is because it's basically someone who understands the documentation reiterating it in the proper sequence, etc.

dull copper
#

yet, it doesn't give you more info than the free resources

vagrant surge
#

but its linear and explained

dull copper
#

it also had clear errors

tardy spoke
#

Yeah, it's linear.

vagrant surge
#

vs the scattered stuff with free resources

#

i would say watch it, but dont follow it exactly

#

follow it with the docs + newest apis

tardy spoke
#

Totally agree. I spent two weeks looking up free resources and learned more from that course in one day - BUT, I think a really experienced programmer would likely learn more from things like that DOTSBOTS video, etc.

dull copper
#

anyway, that tutorial doesn't even know about SystemBase, so you end up learning more complex and outdated approach first

tardy spoke
#

The codemonkey videos I find are a little tricky because he shows what he does, but doesn't exactly explain why he does it. Which is more suitable for someone more experienced than myself.

dull copper
#

unless she's updated that

#

well, Penny didn't explain all things on that tutorial set either

tardy spoke
#

Well, yeah but on the other hand if you understand the older approach you understand the system and what's going on under the hood better because the new pattern is just a slight abstraction over the old one

dull copper
#

how I saw it, it was more like recap of existing tutorials quickly put together

#

anyway, that's just my take on it

tardy spoke
#

Well if you learned a bunch from the existing tutorials I could see how it wouldn't be very valuable haha

dull copper
#

I didn't really watch it to learn more, more like watch if it was decent

tardy spoke
#

Yeah, well the other thing is, even if it's slightly outdated, at least it's all taught in the same version of ECS, because the existing tutorials and stuff are all over the place

#

Like I don't care if I learn the cutting edge stuff, I just need to get the concepts down hahah

vagrant surge
#

there is another thing i recomend allways. Forget about DOTS, and attempt to do stuff on entitas

#

mostly to get how "ecs" works

dull copper
#

yeah but with DOTS, things move in fast pace

vagrant surge
#

as a pattern

#

alternatively, snap Flecs or Entt and do some games on pure Cpp with SDL

tardy spoke
#

Yeah, but they'll slow down as it starts to approach it's final form

vagrant surge
#

changing the mindset to ecs/dots is fairly tricky

dull copper
#

you probably weren't here year ago when we still had inject stuff in

#

practically nothing of the old code we wrote works today

tardy spoke
#

Yeah but that was literally 365 days ago

#

lol

dull copper
#

same thing will happen with the things on that tutorial once Unity wipes the deprecated stuff she teaches there

#

and they ARE deprecated already

tardy spoke
#

yeah but programmers aren't memorizing syntax for the most part

#

they're memorizing concepts

#

and luckily the concepts won't change that much. Some parts of them might, like how they're applied, but those are much easier to learn once you have that foundation

dull copper
#

again, how Unity ECS works has changed quite dramatically

#

like, the core concept of systems, components and entities hasn't changed

#

but whole practical usage has

tardy spoke
#

Yeah, totally

#

I agree with that. The application is fairly different.

#

However, the trick is, there is no more up to date course, so the only alternative is... not really learning anything, hahah.

#

And it's not really that out of date. It still uses the system forEach loops, etc, which is still the current paradigm. Maybe the structure of some of the jobs stuff has changed, but I didn't even know what a job was prior, so, hahaha

dull copper
#

if you want to learn thing on that paid tutorial, pretty much just watch this https://www.youtube.com/watch?v=a9AUXNFBWt4 and open the Unity Physics docs and DOTS Examples for physics

In this workshop style video we walk through an example project created by Unity Evangelist Mike Geig on how to script a Pong style game using Unity's Data Oriented Tech Stack (DOTS) including the Entity Component System (ECS). This video covers the latest syntax in Unity 2019...

β–Ά Play video
#

there wasn't really much beyond that on that paid set

#

that Pong tutorial is pretty much what codemonkey "aped" for the roll a ball tutorial

tardy spoke
#

Are you talking about Penny's crash course with the viruses or the full course?

dull copper
#

I'm talking about the DOTS course you linked

#

there are tons of videos, like 70 or so

#

but they don't truly teach you much more than on those mentioned resourses

#

I guess there was like 10 videos on how to use math lerp etc

tardy spoke
#

Yeah, they seem to cover the "how" where as noobs like me need the "why". If you already know the "why" you're good to go.

dull copper
#

but if you don't have programming background, you probably shouldn't touch DOTS in the first place

tardy spoke
#

Hence that video is 55 minutes and penny's course is 13 hours. Yeah, it does cover similar content, but it takes muuuuch longer to explain why you do something than how you do it.

dull copper
#

it's just too raw in general and for a beginner, it would be total disaster

tardy spoke
#

Nah

dull copper
#

right now only people one could recommend DOTS for is technically minded people who don't mind diving into the deep end and being willing to adapt to constant changes

#

it simply isn't ready yet

tardy spoke
#

So your advice is instead of taking a course to learn something... to not even try to learn it? Hahaha

pliant pike
#

its not that bad I'm an idiot and I can just about use DOTS leahWTF

dull copper
#

πŸ˜„

#

again, that's just my opinion on it

tardy spoke
#

Yeah, this stuff isn't exactly rocket science. Sure there's a learning curve, but it's not impossible. Everyone here has done it.

dull copper
#

I would never recommend DOTS for person wanting to learn Unity

#

this has nothing to do with complexity

gusty comet
#

I'm excited for it because I was afraid my systems would be too cumbersome to run and it'd be hard to multithread it

#

now I think it's probably easy to achieve

#

it's a lot of physics math

dull copper
#

current Entitites programming is getting pretty straight forward now with less and less boilerplate

gusty comet
#

I just had some experience with running a Minecraft server and the entire game is single cored

#

it's actually horrific and I can see why Unity is pushing this

dull copper
#

you can still get most of the perf gains without Entities still

#

job system + burst are production ready and you don't have to use ECS

tardy spoke
#

Yeah, you can get a lot of them with the Job system, that has been in Unity since version 4. Penny taught me that. πŸ€”

#

Hahaha just kidding

dull copper
#

job system has definitely not been exposed until recently

#

it's been internally used in Unity for a long time though

pliant pike
#

would it be weird to have a blobasset and a dynamicbuffer on the same entity?

safe lintel
#

No

pliant pike
#

πŸ‘ cool figured that's one way around my problem

tardy spoke
#

It'd be weird not to, bro

wise monolith
#

How does one reference something like a material in dots? I am trying to create a system that changes the material on some entities based on some component's value so I can better debug my systems, but I cannot figure out in the first place how to get the material into my system.

safe lintel
#

rendermesh contains a chunk's material, and needs to be read on the main thread

restive horizon
#

how do i add dots to my project

#

i video said i need to add hybrid renderer and entities packages

#

but no packages by those names exist

tardy spoke
#

Did you enable preview packages? What version of Unity?

restive horizon
#

2020

#

release

tardy spoke
#

You may have to manually add the packages to your mainifest.json file

restive horizon
#

ohh

#

not sure how to do that

tardy spoke
#

I can show you, one sec

#

"com.unity.rendering.hybrid": "0.5.2-preview.4",

restive horizon
#

what about the entities package

#

so i can use ECS

tardy spoke
#

I think it's a dependency of that package anyway so I believe it'll get installed

restive horizon
#

oh okay

tardy spoke
#

If it doesn't it's the same process but with the other packages... adding them to the manifest

restive horizon
#

i dont understand why it has to be a package, why cant it be built into the engine?

tardy spoke
#

Because it's not ready for "prime-time" yet and they basically don't want people to try it and get discouraged since it's not super polished.

#

There may be better ways to do it than this, I'm not sure, but it might help in the meantime.

wise monolith
#

Thank you soarynGood alexwilkinson this does exactly what I need right now and hopefully I will be able to find more elegant solution later.

tardy spoke
#

πŸ‘

coarse turtle
#

So I switched out my really crude 2d physics engine from systems running inFixedUpdate() on a MonoBehavior to the FixedStepSimulationSystemGroup and I'm pretty glad everything pretty much works πŸ™‚

tardy spoke
#

That's awesome man, nice work. πŸ˜„

coarse turtle
#

thnx πŸ™‚

lusty otter
#

Rather that newing a job struct every time, can I simply save it, change fields, and reuse?

coarse turtle
#

The structs need to be localized , so you end up calling the copy constructor if your struct happens to be a field in the class

lusty otter
#

Ah so that would be pointless then.

#

If I'm running a job on main thread, can I just use a field as input and output, rather than a native array?

coarse turtle
#

w/ burst, no, WithoutBurst() sure

lusty otter
#

RIP.

#

Can't be lazy I guess.

#

But you can use a field (of the job struct) as input though, so how does that work exactly?

coarse turtle
#

Got an example?

lusty otter
icy kestrel
#

Can someone help identify what's causing a Unity freeze (like a while true loop). It seems to freeze when I set an item in a native array, but it has space to store it. https://hatebin.com/sdqbwcjphq

coarse turtle
#

@lusty otter oh, yeah that works, since the job struct would likely be a local declaration in OnUpdate() when scheduling - you'd copy the data locally to that job struct

lusty otter
#

Hmm, so result has to be in a native container? Can't just be a plain float field of the job struct?

coarse turtle
#

Or a pointer, if you want to grab that result and use it in another job (probably best to see what the generated code does exactly)

lusty otter
#

I see.

lusty otter
#

Is there any performance benefit or other reasons to declare WriteOnly?

tardy spoke
#

I have become a god. Finally figured out how to reference another Entity's components, hahah. I dunno if this is the "right" way to do it, but it works.

@amber flicker apparently you can do this with the Translation after all.

#

Also, if someone could explain this I have a feeling it would be super helpful in understanding the structure of ECS.

Every Entity has an index (and a "version"), sure, and you can see that here. But you can't access the components or their values this way - I assume this is something to do with how everything is packed into memory? Or because the Entity technically doesn't "exist" yet?

#

It also seems a bit strange to be running the entityQuery and changing it to an array EVERY update, however, when I tried it in OnCreate I think it returned an array length of zero since the Entity may not exist yet? You'd think the Entity would though as it's created in a monobehaviour that I think should instantiate prior to that... I'll have to play around with that.

minor sluice
#

the new entities foreach has a fluent api, you do stuff by chaining method calls,

Run in this case means execute it immediately on the main thread,
the index in the foreach are usually if you have concurrent command buffers and such to pass the index of the entity for operations like adding a component or destroying the entity

#

not exactly sure about the query, but I think you have to use this methods (ToEntityArray) to have them usable in a sychrnonous context, but you could also do the same filtering with entity foreach asynchronously/in a job

(sorry, just saw the message and wanted to comment)

#

whenever you query or generate an array like ToEntityArray, you get data that represent the current state of the world afaik,
if you do it on oncreate, you might get nothing as the entities you look for don't exist yet

#

(also, I mixed something up, I thought about the index passed in things like if you do a IJobForEachWithEntity like foreach query, but you meant it like the index attached to each entity in itself?)

tardy spoke
#

Yeah the index attached to each individual entity

#

Oh, yeah the dispose should've been below run. Changed!

#

But that is cool to know that the command buffers and stuff have passable indexes

minor sluice
#

I actually never accessed the index of an entity like that,
if I wanted to get or set some data or add to an entity, I use an entityManager,
and in jobs you can inject ComponentDataFromEntity with GetComponentDataFromEntity in a system,

that gives you array like acccess where you use the entity as indexer directly

tardy spoke
#

I use whatever works and then change it later when I figure out what the hell I'm doing. πŸ™‚

prisma anchor
#

Hey is there a proper way to shutdown ECS and switch to another scene?

minor sluice
#

same alex ^^
I'm also not that concern about which approach is more efficient or not atm, as long as it works for me.

sorry, don't know

tardy spoke
#

I agree though the entity manager seems like the more proper tool for it. It seems weird to allocate a new array EVERY frame if it can be avoided, haha.

#

Lol, well I know my project is going to take years to complete and I assume nothing I'm writing now is going to stay.

#

Plus ECS will likely have changed into LISP by that point.

minor sluice
#

and you could run your code in an async/parallel job probably, by just passing the float3 position parameter as input and read from it, since all entities get the same position assigned

lusty otter
#
App.GameplayRuntime.activeEntities.Sort(new EntityComparer());
int length = App.GameplayRuntime.activeEntities.Length;
int count = 0;
for (; count < length; count++) {
    if (!App.GameplayRuntime.activeEntities[count].needInitialization) {
        break;
    }
}

I wonder if it's worth making this short piece of code a job and burst it.

minor sluice
#

also, in your example, you don't need to call SetComponent(entity afaik,
translation is already passed by reference,

I would cache the position above
float3 dstPosition = GetComponent<Translation>(physicsFacadePlayerEntityArray[0]);

and in the entity foreach simply do
translation.Value = dstPosition;

#

I don't see any changes that happen in the loops burrito?
or do you only mean the first line?

lusty otter
#

The loop is for getting the count.

#

I think in practice activeEntities is less than 100 in length.

minor sluice
#

so you are only interested in the first occurrence that has needInitialization = false? and stop there

ah, I think then it's probably better to just have it like this, if there are so few entries

tardy spoke
#

@minor sluice yeah I caught that and changed it. Good lookin' out, though. 😎

minor sluice
#

one thing I'm not sure though
App.GameplayRuntime.activeEntities are those simple fields you access or is there anything happening behind the scenes (like a property that runs some logic)? if so I'd cache it
var activeEntites = App.GameplayRuntime.activeEntities;

lusty otter
#

It's just a field and can cache.

#

I do wonder though, because both the sorting and the counting access the native array, so it would do stuffs like boundary check and other C# overhead stuffs?

minor sluice
#

ah okay, the caching should still be faster then, but practically it probably won't make a difference when it is all just fields

#

oh, if that all is a native array, I think there is some overhead when you try to often access it in managed code

lusty otter
#

Oof.

minor sluice
#

but if there are only around 100 entries, shouldn't matter much

lusty otter
#

Thanks, I'll just leave it like this for now and check later.

#

I'm thinking if the job overhead isn't big it might just be worth it, for the occasional 100+ entries situations.

tardy spoke
#

Is there a blittable data type that can be used that is similar to a struct? I think the NativeArrays and stuff can be utilized inside a component, right?

I was thinking you could probably make an interesting quest system by having essentially an array of data in a component and a System that acts as a parser on it to figure out next actions. So it's almost like you're writing your own little scripting language for the quests inside the components. All the dialogue, the type of quest, etc.

minor sluice
#

would that make sense to be in jobs or components?
because strings are also non blittable, or should it just have an index to a text outside?

#

I saw blittable array implementations, but I think a problem is if they can have variable length and for blittable data, their size should be known for memory layout and management reasons

#

there are blobassets to store readonly immutable data for example, and dynamic buffers to make something like a one to many relationship

tardy spoke
#

Well, I guess having a System parsing it could stay no matter what the input storage method ends up being, I was just hoping there was something in ECS that would be able to hold that kind of data.

#

The trick is you just need the component to hold some data to somehow remember the progress on the quest or whatnot.

#

So possibly reading in an instruction set from some external text and holding the progress on a component or something. I bet someone will come up with a pretty eloquent system for doing it at some point. It'd be interesting to see.

#

A component that knows whether the quest is active and what the progress is I think would be all you need and then you could read in an instruction set. πŸ€”

minor sluice
#

maybe possible, but I have no idea how to approach it,
haven't tried the hybrid approach yet, but can't you simply store references to objects/behaviours in a component that you assign to an entity somehow?

to me it just seems like this might be a case where the ecs approach would make it harder than necessary,

you could still synchronously access the logic that manages the dialogue tree in a system update and I don't think there is any good reason to structure that to be usable in a job

#

dialogue decisions and consequences are pretty infrequent and are usually super light in the logic they contain,

I would maybe just reflect the effects in components

tardy spoke
#

Yeah, I'm not sure. In my opinion I'd rather use a slightly harder approach in one system than* split across two easier systems, just because discrete systems can potentially multiply exponentially in complexity

minor sluice
#

if they belong together, I think that's true, but if they can work autonomously from each other, or have a benefit from the modularity, I think the ecs approach can have benefits

tardy spoke
#

Yeah, that's what I meant, if I had to do it I'd like to reflect the effects in components for sure.

#

That'd really limit the scope of the other system and it's responsibilities so it doesn't accidentally become more complex that it needs to be. Basically just acting like a database.

minor sluice
#

I really have no idea how to approach this, or even how a logic structure would look like where the decision logic is implemented in an ecs kind of way,

but.. for example what I could think of, a player entity might either get a decision component attached that has the index of the current dialogue and the index of the answer,
and all entities that have that component are then queried in an OnUpdate, the dialogue behaviour makes its checks and then stores the consequences into a database like structure or write consequences to components of involved entities

tardy spoke
#

I was thinking simpler than that even and just put the branching logic right in the "database" and let the parser (a System) handle it.

So your system is reading in a weird struct or whatever (I'm from javascript land where everything is an object, so I dunno what the best one would be in C#)

and it's kinda like this. I'm sure you could do this with either an object or an array or whatever.

[0]QuestName: "This example quest",
[1]QuestType: Kill X of something
[2]Dialogue: "Hi. I have a quest for you."
[3]Choice: "Sure", "Nah".
[4

#

Woops. I hit enter. But you get the idea, haha.

#

I dunno if that is a super naive way of doing it... without suuuuper sophisticated branching logic it would probably be okay. Branching logic would make that approach pretty difficult.

#

And a "Progress" component might just store the index array for the progress of the quest.

#

and the System looks for some keywords or something of the corresponding [i] in the quest array of the progress component and just parses them and the condition to progress to the next one.

It is pretty hard to imagine what it would end up looking like, I'm sure there's lots of issues with that implementation, but it'd be cool to do some experiments and see what happens.

minor sluice
#

sounds fine to me, but I haven't worked on dialogue systems yet,
like all the database and branching logic related stuff I think don't have to exist in components

tardy spoke
#

Yeah, it's an idea. I'll probably try fiddling with that soon... now that my character can move, he'll need some stuff to do, hahaha.

minor sluice
#

maybe I wouldn't even store any outcome of the dialogue in a component, just leave the result in the database or decision representation structure in that parser/system

tardy spoke
#

I was thinking that the "Progress" component literally is just the current item of the quest array and that's it. I think that's all you need, because you can decide if it is active or not based on instructions in the Quest... object... thing.

#

lol

minor sluice
#

only thing maybe to just store the current dialogue index to identify where the player is atm,
or storing the id for the dialogue lookup of NPCs in their components?

tardy spoke
#

Yeah, the second thing you said I think is the same thing I'm saying

#

except the "quest" contains everything, including dialogue... I think, but I would have to check, that generally every single element of a quest is sequential, so it could work

minor sluice
#

hmhh, yeah,
but I wouldn't probably even store any permanently required/persistent information as component, except as duplication.
so the current mission and dialogue state should still be persistent somewhere, but maybe it can also be in a component if that helps in any way

tardy spoke
#

Oh, yeah, persistency of the data in the components would have to be sorted out for sure.

#

Yeah, I was just assuming persistence and player state is backed up to a server somewhere and the components would somehow get their progress data back. That'd be an interesting problem to solve as well. Guess you would have to somehow reinstantiate all those quest progress components with the correct values, etc.

#

But the nice thing is that's literally ALL you have to do for the entire quest system's state

minor sluice
#

the issue of serializing and deserializing world and quest state from persistent data to the runtime effect representation is a general one I think, not sure what a good way to handle this is,
but maybe the parser system could also have a method that just runs over all the stored consequences and applies them to the world

tardy spoke
#

Lol, i'll find out when I get there. I plan to play around with SpatialOS in a bit but I'm sure any sort of persistent data in my project would be months away

#

Hopefully I'll understand something about ECS by then. πŸ€”

minor sluice
#

ah, sounds interesting,
good luck with all of that,
spatial os seems amazing too, but isn't it kinda expensive to use? with more users etc

tardy spoke
#

I dunno. I'm rich. πŸ€·β€β™‚οΈ

#

Plus the only players for 3 years will probably be my friend who's doing the art assets and I... so... it'd be weird if we went bankrupt

minor sluice
#

ah, okay GWcentralPikaLUL
yeah that shouldn't happen then

#

I just recall that worlds adrift had a problem where the server infrastructure just was so expensive for them, even though they had a lot of players

tardy spoke
#

Lol, that's definitely a "ducks before they hatch" situation. Too many players is definitely the problem you want to have.

#

Because at least you have a problem there's value in solving, hahaha

#

And they were on SpatialOS?

minor sluice
#

yeah,
but also, if that is a project that should bring revenue, there should be a simple calculation of having new/more concurrent players even returns more profit or not,
if not, that sounds like a pretty bad model

#

ah yeah, they used spatial os

tardy spoke
#

Well I mean... I would say they should probably increase the price of their game, but a lot of people are afraid to ask for more money because they think they will lose all their customers... which sometimes happens I guess, but it could easily have been a symptom that they just priced their subscription too low

minor sluice
#

yeah it's tricky,
there are probably other reasons too why the game shut down, but operating at a loss would be a bad idea in any way, except if you are maybe a project that is focused on customer acquirement and have a plan to turn profitable at a specific amount of users and subscriptions

tardy spoke
#

Hmm, yeah the startup model.

#

I think that works better with funding... haha

minor sluice
#

okay, will go now,

good luck with your project further down the road and the dialogue implementation wave

tardy spoke
#

If you can kickstarter a project that would make sense, but if you're just doing something indie you probably want to keep it super lean

#

Cool, thanks for the help! 😎

#

It is appreciated

minor sluice
#

well, am only starting out with ecs too pretty much, so I'm not sure how much of my statements are correct, but I'm trying to learn ^^

have a nice day!

tardy spoke
tardy spoke
vagrant lotus
#

how do I modified the movement phase

#

as in, i want dots physics to calculate all the forces etc

#

but i would like to have custom code for how the forces are translated to translation and rotation

tardy spoke
#

Just looked at your link. Clearly you're trying to do something much crazier. πŸ˜‰

vagrant lotus
#

Yeah

#

Basically tell the system to not calculate movement on its own

#

While a custom code would handle it

tardy spoke
#

@vagrant lotus I noticed at the top it says Note: Hooks for simulation modification are a work in progress. They may be incomplete and the interfaces are very likely to change between releases. The Unity Physics Samples project has one scene for each type of modification and it may be best to refer to those in order to see how the current interface behaves and what the API is. , and I was looking at the cool samples they have out of interest and it looks like they don't have any samples specifically demonstrating that, so I wonder if those hooks are not in yet?

vagrant lotus
#

Yes that's the problem with previews

#

Not enough explanation

#

I was hoping what I want to do is possible with the new 0.4.0 preview

#

Guess I have to wait and see

tardy spoke
#

Weird they would describe some of the potential hooks right under that though if that were the case

vagrant lotus
#

They are adding features every update with dots physics

#

Thought I might try my luck

hollow sorrel
#

physics samples should have some examples on modifying the simulation

#

did you check there?

tardy spoke
#

oh, maybe this one

vagrant lotus
#

`hmm

tardy spoke
#

I posted a video of an idea for an ECS quest system a couple hours ago, but I was thinking, if a System allows it - and I don't see why you couldn't - I wonder if parsing the plain text "quest" file from JSON would be beneficial vs just trying to parse your own little custom script written in plain text. I think it would be, because 1) it ensures the formatting is correct or it won't run, and 2) you have an "object" (whatever C# calls it... a dictionary or something? haha) with proper key value pairs off the bat. There's likely some other benefits to using something more standardized as well, and I don't think it really loses any flexibility since you're still writing the code that interprets what to do with the data it contains. Would be easy to make a tool that the game-designers or whoever could use to make the quests, since it just formats it as JSON.

hollow sorrel
#

are you modifying your json manually

#

and are these scripts modifiable after build or just in editor

vagrant lotus
#

what is the equvilant of vector3.angle with ecs

opaque ledge
#

what does it do ?

#

check Unity.Mathematics and Unity.Mathematics.math static class

#

but you can still use vector3.angle inside your jobs, just need to convert to/from vector3

deft stump
#

what does this error mean?

#

At least one component that derives from IBuildPipelineComponent must be present.

#

I'm trying to build for android

#

Or wait

#

do I need Tiny for this?

dull copper
#

I just read this old post from April: First, the current version of addressables will not "just work" with DOTS at some point. There will instead be an Addressables v2 that depends on DOTS. Second is that we are learning from the current addressables and focusing our energy on making sure v2 will cover all the same use-cases of today's addressables, with minimal amounts of re-learning.

deft stump
#

Hr..m

#

Shit

#

Time to abandon dots

opaque ledge
#

lol

#

what is your use case ?

deft stump
#

Basically, i'm making a gacha game (think call of duty mobile) (my real project; the bullet hell game was just practice to get to understand dots better).

But for this gacha game (better known as, game as a service), the player needs constant internet connection, so they can download new assets from the web using addressables.

So if addressables isnt gonna work on dots, then time to redo my whole game (the 4th time)

#

I mean i know what i was heading into when i converted the game to dots. But maaaan...

dull copper
#

pretty sure there's been people on this channel using addressables with DOTS

#

ask Roycon 😁

opaque ledge
#

you can always run stuff on main thread and without burst which 'supports' Addressables

#

i mean.. systems that you write can always be run on main thread and without burst, you can always do ECS stuff in monobehaviours as well

#

can help more if you give me specific use case

deft stump
#

Hrmmmmm... Time to NOT abandon dots then...

But I still need to build it for android

#

So how do i do that?

opaque ledge
#

to build for android ?

maiden cape
#

So, I've been looking through the Unity.Physics documentation and I'm just wondering if there's any way to manually simulate such as the PhysX Physics.Simulate method. I've been converting all of my code over to DOTS on the server, but I've gotten to the point where it's time to implement client-prediction and reconciliation and I'm completely stumped. Due to the performance improvements of DOTS I've been able to implement some systems that I couldn't before, and I've been super excited to start playing around with some friends online to test them out, but I really don't want to have to enable client authority for the player's local character.

#

I've considered writing a non-physics based movement system that could handle reconciliation, only utilizing rays since they're quite performant when used with the job system, but that seems overkill.

north bay
maiden cape
#

I'll check it out, thanks.

dull copper
#

that char controller sample is not very robust though

#

it would need a lot of extra work to work properly

#

unless your char movement use case is really simple that is

storm ravine
#

Addressables works pretty well with DOTS, whole our assets in game loaded through addressables (not from network but from local bundle, as our game is single player RTS, we using addressables for smooth loading and better memory footprint, and just for more convenient management instead of raw asset bundles)

minor sluice
#

@tardy spoke saw your video. Didn't know you can use classes with IComponentData, although I expect that this would be a problem if you ever have to go into a job context with it (although that isn't necessary here). But nice that you got it to work that way,
with the hybrid ecs approach there should be a way reference reference types with maybe isharedcomponentdata? or something similar that is basically just a wrapper around a regular class instance/monobehaviour. ButI haven't worked with that yet so dunno

tardy spoke
#

@minor sluice Yeah I saw that trick done by the Dotsbots guy here. https://youtu.be/JkiJoAufH9A?t=3966

Agree, there will definitely need to be a standard approach for working with external reference types, and maybe there already is, but that trick should do for now.

#

and are these scripts modifiable after build or just in editor
@hollow sorrel

Manually in JSON, only modified in editor.

#

If I was better at ... comp sci in general.. I could probably have the System create an actual graph/nodes setup based on the JSON's hierarchy, and I believe that would get you fairly close to how traditional quest systems are approached but with an ECS backbone.

gusty comet
#

With this code, I want to have a bunch of methods for combining or exchanging chemicals. Would the logic for this belong on the static class Jar?

#

It used to be a MonoBehavior and I'd just do something like Jar1.EmptyInto(Jar2), but I think with DOTS I'd need to do something like Jar.EmtpyInto(Entiy Jar1, Entitiy Jar2). Does that sound accurate?

tardy spoke
#

Take everything I say with a grain of salt, but that sounds correct to me, haha. :)

You'd probably have two components, jar1 and jar2 and a foreach loop (System) on them that does the required action (pretty much like normal).

#

I don't think you'd need to explicitly "call" a function that does it like you have there, and instead just let the system manage when that happens, etc.

amber flicker
#

nothing wrong with a static method like that... though imo it smells a little OOP - does it matter that it's a jar? Or is it about Chemicals mixing in a volume? When do you call 'emptyInto'? It's likely related to other data - essentially what @tardy spoke just mentioned.

tardy spoke
#

1776 got lucky. I am right once a day.

mint iron
#

yeah you should probably have some system that just transfers anything that needs transferring. so if you need something transferred, you add a component to it or some other way of making it get picked up by the transfer system.

tardy spoke
#

Out of curiosity, does anyone frequently use .withName("System name whatever") on your systems for debugging? You rarely see that in examples and stuff, but it seems useful.

amber flicker
#

I rarely do as I use the profiler timeline view a lot and the system names tell me all I need to know and debug gives me stack trace.. though I think it's useful, I just don't usually think to add it. Will probably add them in as code becomes more polished.

tardy spoke
#

Ah, maybe they changed it so it just does it by default or something now, because it seems to only be prevalent in older tutorials

#

I'm actually not even sure where that name shows up, haha. I should look into that.

And they probably should just make it do it by default unless it causes an odd amount of overhead for some reason? ... would make sense to have it named whatever the System is named... haha.

amber flicker
tardy spoke
#

Interesting

#

I wonder if WithName shows up there or just in the entity debugger

mint iron
#

i havent used it but it makes sense i guess, if you have a few different jobs scheduled in the same system, it cant really identify them well (for profiler)

#

i tend to just go by the system timing in entity debugger, since i assume that takes into account any jobs launched from it, could be wrong?

amber flicker
#

interesting.. apparently the name has restrictions - must consist of letters, digits and underscores only and may not contain a double underscore

#

I think the entity debugger timings is just main thread time? Though I generally don't trust those timings.

tardy spoke
#

Yeah, I just saw that.

Also it appears that the name doesn't show up in the actual entity debugger at all

amber flicker
#

yea I think just system names in the entity debugger & systems window

tardy spoke
#

Yep

#

Super noob question, but how do you get to that thread profiler? I just assumed that was in the regular profiler but I don't see the threads so I must be in the wrong spot or have it not setup correctly haha

amber flicker
#

pick 'Timeline' from the left dropdown that probably says Hierarchy currently

tardy spoke
#

Beauty! Found it. Now the second problem. My ECS project is so sad everything all my systems run on the main thread, making it an exercise in futility, haha. They're all related to player controls so that's not too surprising... but still. Sad.

#

You know what would be super handy is the ability to "turn off" a System/component script. Like how normal game objects have the enable/disable check box. Would make ECS troubleshooting/redoing systems a lot easier.

gusty comet
#

@amber flicker it is about chemicals mixing but jar is just what I called the mono behavior

#

I guess you're right that the concept of a jar isn't necessary without oop

#

like the tile with open space also had a 'jar' attached to it to represent the contents of the tile, i.e. oxygen and nitrogen

#

but I can just attach those chemicals directly to the tile, but the benefit I was going for was that it'd be very easy to take other containers of chemicals (i.e. a bottle of water or a gas tank of helium) and easily combine A into B

hollow sorrel
#

@tardy spoke ah alright, brought up the json questions because pretty much the only reason to use json for serialization is if you're manually editing the files (and thus has to be human readable), other than that pretty much any other serialization format is gonna be more efficient
but if you do edit it manually then nbd

i'm guessing what's preventing you from using jobs is the managed components, would be a big benefit if you could turn your static data (such as the quest textassets) into BlobAssets
seems you are using your quest textassets for scripting? if so then you don't have to put them into your systems as TextAssets, better to parse them into some useful struct/blobasset format and then put them into the system

also regarding the enable/disable, systems have an Enabled property you can use, and a Disabled tag for components is coming in the future, but yea no easy in-editor checkbox like monobehaviours atm

#

but yea the managed components are a crutch, ideally your project doesn't have any managed (ecs) components
not saying you have to convert everything since it takes more work and not gonna assume time is infinite, but is something to strive towards

tardy spoke
#

@hollow sorrel is efficiency really important for quest data? Serious question, haha. I figured since they're loaded/parsed fairly infrequently it would probably be alright to have some inefficiency there

#

Though true - they could become blob assets which would be cool.

#

I'm missing some connections here though -

Would I go to Text file in JSON -> Unity parse that JSON into some sort of object --> Store that object as blob asset?

hollow sorrel
#

is efficiency really important for x
that's up to you. one could argue as long as you are above 60 fps then you don't need to worry about optimizing
usually the cost of optimizing is time, but i think with a lot of these things especially in data oriented design it's more about learning how to structure your data better, which is an upfront cost, but once you learn how then doing things the more performant way is basically free since it takes about same time to implement
personally i like the idea that every part of the game is as optimized as possible depending on time spent, because that means you have more frametime to spend on future things rather than have to spend time at the end of your project trying to patch up parts of your project that you made months/years ago and have to reassess how they work

#

ofc you should prioritize hot paths, if your quest code rarely runs then you shouldn't spend too much time optimizing, but i think it's good to do at the start just to learn how to make better systems in the future

amber flicker
#

There is an easy enable checkbox for enabling systems at least - editing entities is hopefully on its way

tardy spoke
#

Oh yeah, I'll never fight anyone that it's a good idea to use best practices haha

#

@amber flicker where is that checkbox?

amber flicker
hollow sorrel
#

oo nice there is a checkbox

tardy spoke
#

Well, my project is interesting. Basically my buddy who used to do tons of art stuff recently got into 3D modelling, so I'm trying to keep the progress fast enough to keep him motivated, haha. For myself, it's just for the fun of learning so best practices are definitely of interest to me. And BlobAssets do seem useful to be knowledgable about.

hollow sorrel
#

i don't get to see it because no support for manually ticked worlds πŸ™

tardy spoke
#

Is that selection persistent? That'd be handy

amber flicker
#

actually I think they recently changed that? think it was in release notes

hollow sorrel
#

they changed it for entities window but systems still borked

amber flicker
#

ah ok

tardy spoke
#

@hollow sorrel also I definitely have to worry about optimizing because the target platform is Oculus Quest, which requires 72FPS minimum constantly without stressing the hardware and overheating, haha. That's why I asked.

#

If anyone enjoys pain I have another one of my noob questions

hollow sorrel
#

Would I go to Text file in JSON -> Unity parse that JSON into some sort of object --> Store that object as blob asset?
yea i think that sounds about right

#

don't have that much xp with blobassets yet but that's prob what i'd start out with doing as well

tardy spoke
#

So here's the "new" code with the Entity Manager. And it's nice because it's less lines of code, but it didn't "solve" or "change" anything I believe. It's still a fairly naive implementation, I'm sure.

My question is - I'm trying to understand some ECS patterns here.

What patterns would I follow to make this piece of code run:

A) With Burst enabled.

and

B) Multi threaded.

hollow sorrel
#

you should be able to just do GetSingleton<PhysicsFacadePlayer> before your foreach instead of the whole entityquery stuff

#

if it's a singleton

#

(doesn't answer your question, just a sidenote)

minor sluice
#

I think you can try what I wrote yesterday, get the entity before the loop

, store var facadePlayerRotation = GetComponent<Rotation>(physicsFacadePlayer).value into a quaternion variable before the loop,
and then just use
rotation.Value = facadePlayerRotation;

and have
WithBurst().Schedule(); or something

#

this is what I'm not sure about though: how does unity handle OnUpdate local variable access in jobs,
because unlike with real jobs,that isn't really verbose if you use ForEach queries

hollow sorrel
#

i think the codegen just turns it into the same as passing that local variable into the job

minor sluice
#

that is nice!
working with ecs gets more convenient, but the expense that you have to learn more about how the internals work since it isn't as explicit as it once was

tardy spoke
#

Awesome, I shall look into this. :D

Haha, totally. I'm all for ECS style stuff, the steeper learning curve doesn't bother me at all. And I'm not a huge OOP fan so the idea of learning a ton of OOP isn't appealing to me as learning ECS paradigms.

#

Thanks for the help! I shall see if I can make this code not smell so bad.

minor sluice
#

the thing is also, those 2 paradigms are good for some use cases and bad for others,
maybe a complete replacement is possible, but I think it doesn't make sense for every use case,
sometimes it can be convenient to have an inheritance hierarchy or to work with direct references,
although I'm surprised how easy it already is to access a specific component of an entity that is not the current one

tardy spoke
#

Hah, I'm still figuring out how to access specific components on other entities properly. πŸ€¦β€β™‚οΈ

#

Yeah, what (little) background I have in programming is all functional, so OOP is just foreign to me.

minor sluice
#

you'll certainly get there blobOk

tardy spoke
#

Oh, yeah, totally. People can do anything if they put the effort in. My brother and dad are also awesome programmers, so that helps, haha.

#

Also in exchange for all the help if anyone here ever needs help/advice on sound design, like audio recording/mixing/mastering, I am extremely competent at that stuff, haha.

#

My game may run like shit, but it'll sound good doing it.

hollow sorrel
#

unfortunately dots audio system isn't there yet

#

unless you count dspgraph

tardy spoke
#

Yeah, totally that looks neat. But I more meant like help with professional audio in general. Like "hey this dialog sounds lame, how do I process it to sound pro?" or "How do I export stems so I can change the volume of certain instruments dynamically in the game?"

coarse turtle
#

Also I can't believe this is all I had to do πŸ€¦β€β™‚οΈ
@tardy spoke You can also cache the entity query so you don't need to construct it all the time every update step

tardy spoke
#

@coarse turtle totally would love to do that!

coarse turtle
#
EntityQuery query;
public override void OnCreate() 
{
  query = GetEntityQuery(...);
}

public override void OnUpdate() 
{
  var e = query.GetSingletonEntity();  
}
tardy spoke
#

Ah, I was struggling with that since I believe my character is created after OnCreate for some reason, let me try

hollow sorrel
#

GetSingletonEntity<> basically codegens to the same thing far as i know

#

but yea what psuong posted is a good pattern to know when using non singleton entityqueries

tardy spoke
#

Also it looks like this pattern forces it to go back to .WithoutBurst().Run() , which in this case is probably the more performant move than finding that reference to the facadePlayer every frame

coarse turtle
#

You could try RequireForUpdate(query) so the system checks if its dependencies are met before executing

tardy spoke
#

Yeah, also something interesting is this is how the player is instantiated

hollow sorrel
#

should work with burst and schedule if you're getting the singleton outside of the loop

tardy spoke
#

You would think it would run first though

coarse turtle
#

Should be the awake call if it's outside a subscene iirc and using ConvertAndDestroy / ConvertAndInject

mint iron
#

the odd thing about the default singleton setup is that you cant directly use them inside jobs, its just a fetch in the system and pass it in, which is just annoying boilerplate.

#

and if you're never querying on it, or doing anything else with it, its practically no different than calling a system method or static helper for it

#

i guess it shows up in entity inspector which is nice if you want to view it and maybe hopefully in the future edit it; can be loaded in from subscenes too.

#

maybe they could have a wrapper that lets you just Get/Set them within ForEach without the hassle.

coarse turtle
#

I think it's b/c the GetSingleton<T>() call ensures that the read/write fences are completed before actually fetching the singleton (though idk if that had changed in later versions of entities, it's been a while since I looked at it...) πŸ€”

mint iron
#

it would be the same as using GetComponent<T>(entity) in ForEach but with a dedicated singleton entity

tardy spoke
#

@coarse turtle the RequireForUpdate worked

#

Also i'm aware you would probably want to do this on the main thread with .run() since it's related to the player's input, but I like that it CAN at least be scheduled, haha. Makes me feel like I'm doing something right. 😎

coarse turtle
#

@tardy spoke cool πŸ‘
@mint iron oh right, that'd be an interesting change to GetSingleton

tardy spoke
#

There was also a "RequireSingletonForUpdate" or something that seemed pretty interesting, but I couldn't seem to get it to work. Might not do what I think it does, haha.

mint iron
#

you'd think they're almost there because they're already converting it to a GetComponentDataFromEntity. But what would be even is if when iterating the entities, they made a local get first, passed it into each loop call, then save set the component afterwards.

tardy spoke
#

@hollow sorrel I see what you mean about the referenced textAssets vs having them as a blobAsset. Seems like it disables the use of Burst and Schedule for every System that needs to reference them, which could definitely snowball.

hollow sorrel
#

yea managed components can't be used in jobs and burst

#

and secondly you prob also don't want to just put the textasset string into a blobasset because i assume you wanna do other stuff with it

#

instead of just read it

#

i mean if you're just using it for text to display on your ui that's fine

#

but if more than that you prob wanna parse it first

tardy spoke
#

Yeah, probably parse it first I imagine

#

Then throw the object in as a blobAsset

#

I think that makes more sense... then the QuestGiver component holds the progress per quest. BlobAsset is just the read-only instruction set for the whole quest.

#

Would be fun to experiment with some graph stuff and try to store the quests as proper graphs so they can do cool stuff like branch but that's ... a rabbit hole haha

hollow sorrel
#

yea

#

has anyone used it yet?

#

docs seem pretty scarce atm

humble mason
#

hey guys, so, if i want to spawn a 3d entity like a box, say from a prefab or even directly through code, how do I approach uv mapping it? For standard gameobjects I usually edit the MeshFilter.mesh in a script inside awake().

tardy spoke
#

Interesting approach. I take it just UV unwrapping it in Blender or something before import is not an option?

humble mason
#

im completely unfamilliar with blender so I prefer doing everything i can inside unity

#

but if that's no option then i guess i have to look into that

lusty otter
#

What's the best approach to making a "multithreaded bool"?
By that I mean, I want a bool that is false by default, jobs running in parallel can turn it to true.
These jobs don't need to read the bool, and can only make it true.

#

I don't have any good idea other than using NativeQueue and checking the count afterwards, but I feel that's a bit overkill.

tardy spoke
#

@humble mason my experience in 3D is likely pretty dated, but this is pretty much how it used to work.

If you're using primitives like cubes, etc, you may be able to work with the UV maps in Unity since they are so simple, and I believe they come unwrapped in a fairly logical way upon creation.

UV unwrapping anything more complicated than a box in code I believe would become quite complicated. However, if there are tools in Unity itself that allow for "directly painting" on an object the UV unwraps may be able to become simplified, as a "human" doesn't have to be able to paint on them in photoshop, so the unwrap doesn't necessarily need to be laid out logically.

I'm not sure how much sense that's going to make, it's somewhat difficult to explain what I mean there.

Basically if you're texturing something in 3D space the computer maps your brush to the UV's in 3D, so it's figuring out how what you're doing correlates to the 2D UV map.

If you're texturing something in 2D (IE in Photoshop), and it was a bunch of triangles (faces) laid out seemingly randomly, you would definitely struggle.

So if you need to texture them in 2D, like in Photoshop, you will probably end up unwrapping manually with Blender.

If you're texturing them in 3D, some sort of unwrapping done in code may not be too difficult, I'm not sure.

However, Blender I believe can also do that unwrapping/painting in 3D process, which might be the best compromise.

When you learn Blender, you do not learn ALL of Blender. It is an enormous program, like Unity. You learn a part a time. I don't think doing an automated UV unwrap and painting in 3D in Blender would be substantially difficult.

humble mason
#

@tardy spoke im mainly working with cubes since im only working on a prototype/proof of concept right now, and exploring dots through it. I had no trouble uv mapping cubes when I was dealing with gameobjects, I'm just not sure how to do the same to entities

coarse turtle
#

What's the best approach to making a "multithreaded bool"?
By that I mean, I want a bool that is false by default, jobs running in parallel can turn it to true.
These jobs don't need to read the bool, and can only make it true.
@lusty otter you could take an int, and treat it like a bit flag w/ the # of jobs/threads executing (1 << 0, 1 << 1, 1 << n where n is the max number of threads you're executing)

humble mason
#

for example, im creating a new entity when i press a button, i can give it the components it needs (transform, collider, mesh etc) but I dont know how to tackle mapping specifically. In a gameobject i would just do it on awake().

#

@tardy spoke

#

like this

{
   private Mesh mesh;
   private Vector2[] uv;
   
   private void Awake()
   {
       mesh = GetComponent<MeshFilter>().mesh;
       uv = new Vector2[mesh.vertices.Length];

       uv[0] = new Vector2(0.5f, 0.5f);
       uv[1] = new Vector2(1f, 0.5f);
       uv[2] = new Vector2(0.5f, 1f);
       uv[3] = new Vector2(1f, 1f);
       
       uv[4] = new Vector2(0f, 1f);
       uv[5] = new Vector2(0.5f, 1f);
       uv[8] = new Vector2(0f, 0f);
       uv[9] = new Vector2(0.5f, 0f);
       
       uv[16] = new Vector2(0.5f, 0f);
       uv[17] = new Vector2(0.5f, 0.5f);
       uv[18] = new Vector2(1f, 0.5f);
       uv[19] = new Vector2(1f, 0f);

       mesh.uv = uv;
   }
}```
tardy spoke
#

Hmm, I added a texture to a material because I was curious if it would Expose anything in the Entity's RenderMesh component, but it doesn't.

My guess is it's probably actually done the same way you're doing it - the mesh has to have it's UV's manipulated before it's converted into an Entity.

lusty otter
#

@coarse turtle Oh I don't mean to need to know which thread/job set it to true, I just need to know if any of the jobs set it to true.

humble mason
#

okay so then i take it it's impossible to do that for a created-from-scratch entity?

tardy spoke
#

Or actually... hmm

coarse turtle
#

@coarse turtle Oh I don't mean to need to know which thread/job set it to true, I just need to know if any of the jobs set it to true.
@lusty otter oh then maybe just bool* value or NativeArray<bool> w/ 1 element is all you need

lusty otter
#

I assume I'll need to use NativeDisableContainerSafetyRestriction

#

But would it be alright for multiple jobs writing to the same index?

#

I feel like that's a recipe for crashing 😰

tardy spoke
#

@humble mason I'm thinking you're gonna have to grab an entity with the <MeshRenderer> component and see if you can manipulate it's "mesh" in the same way you're doing now. If you can, you can, if you can't, I wouldn't be sure how to do it.

I don't see why it would be different?

#

I think it'll work with the same method you're doing now

lusty otter
#

NativeDisableParallelForRestriction*

humble mason
#

@tardy spoke through a dots system or straight up from a monobehaviour script?

tardy spoke
#

However be aware that your mesh is likely on an ISharedDataComponent and it'll likely manipulate things in bulk, haha.

#

@humble mason through a DOTS system you should be able to execute that code

#

I believe

coarse turtle
#

you could always or to the element if the condition is true and not set it if the condition is false

The bitflag approach can let you selectively write to a particular bit index, and you could always check if the bitflag is > 0 in your next job @lusty otter

tardy spoke
#

I'm pretty sure the "mesh" it's referencing is the same thing, I don't think it's a special "DOTS Mesh". I think a mesh is a mesh in this case, but I'm not sure.

humble mason
#

thank you very much for digging into this! @tardy spoke ❀️

tardy spoke
#

That mesh being ON an Entity may affect how it's accessed though, so I'm not sure it could be accessed with a monobehaviour easily.

#

Yeah no problem, this is all just afaik, so hopefully the hypothesis is correct and it's modified the same way!

humble mason
#

I'll give it a try, hope it works out and won't be overly complicated

#

im not very comfortable with dots yet, or with unity itself for that matter

tardy spoke
#

I'm sure you'll get it, just prepare for a bit of pain. The ECS documentation is... interesting... πŸ™‚

humble mason
#

yea, that's my biggest issue really, how feature discovery is achieved through experimentation instead of documentation rn 😦

lusty otter
#

Hmm

#

I'm using the NativeArray<bool> with just 1 element solution, and in jobs I just set it to true.

#

It doesn't throw errors or anything, I wonder how it deals with two threads trying to write to it at the same time?

tardy spoke
#

@humble mason yeah stick around the channel, I'm in the same boat, haha.

coarse turtle
#

Well potentially a race condition - 1 thread can overwrite the other thread, so if write into the index regardless of whether it's true it could be like true -> false -> false

humble mason
#

thanks again for your insight!

tardy spoke
#

Anytime!

lusty otter
#

But since I'm strictly writing true (and not writing at all otherwise), it's fine?

coarse turtle
#

yea should be