#archived-dots

1 messages · Page 127 of 1

formal scaffold
#

Anyone else coding with Visual Studio? Is it possible to debug Entities.ForEach loops? In Vscode it works but I loose intelisense there constantly which is why I switched.

mint iron
#

yeah, make sure Burst compilation is off and JobDebugger is on, and you should see 'Attach to Unity' on the attach button; it can get weird if you try to directly attach to the process.

formal scaffold
#

Thanks that works

gusty comet
#

What should i use to store and reference a list of 2d arrays inside jobs?
NativeArray? NativeHashMap or DynamicBuffers?
I'm not sure about their specific use cases. I thought a NativeHashMap would do the work right but it cant take in arrays for its value?

Would it be right setting a DynamicBuffer to an entity to store the arrays for future reference?

safe lintel
#

is anyone using chunk.HasComponent successfully? seems straightforward enough but doesnt appear to be working for me

north bay
bright sentinel
#

@gusty comet Generally you want to flatten all your arrays

#

I actually don't think 2D arrays or nested arrays are even possible in burst

#

But don't take my word for that

#

But I'd make a structure that can help you with that. Like describe where the seperators are and so on

gusty comet
#

Apperantly they need to be fixed arrays to be used in ecs setting. That's fine. But what method should i use to store and reference them?

fallow mason
#

@safe lintel I just started using it again for a system last night. Haven't tested yet. How are you using it? As far as I know you have to declare the archetype component type in the ijobchunk, pass in the type when you schedule the job, and do chunk.has in the execute and you'll get back a bool.

safe lintel
#

i figured it out, was using HasChunkComponent when I needed to use Has(for a not chunk component)🙂

fallow mason
#

Oh yeah. Personally still haven't come across a reason to use chunk components yet.

eager oracle
#

Does anyone know how to Update a PhysicsCollider, once the mesh of RenderMesh has been updated?

warped trail
#

@eager oracle look inside Physics_MeshCollider.cs😏

eager oracle
#

mmmm... lets see if I find it

#

(Yes, i dont have a proper IDE 😛 )

warped trail
#

you can search inside unity🤔

eager oracle
#

Found it

#

Lets see

#

But not sure how MeshCollider relates to PhysicsCollider

#

@warped trail Not really sure what I am supposed to be seeing here... 😕

warped trail
#

you have PhysicsCollider component it has BlobAssetReference<Collider> Value , after you changed your mesh you create new BlobAssetReference<Collider> and assign it to your PhysicsCollider

eager oracle
#

In which file did you see that? In Physics_MeshCollider.cs is not

warped trail
#

PhysicsComponents.cs

eager oracle
#

But even settings s new BLobAssetReference, how do I set the mesh??

#

Like this?

            BlobAssetReference<Collider> blobAssetReference = new BlobAssetReference<Collider>();
            blobAssetReference.mesh = mesh;
warped trail
#

no

#

have you looked at files at all?🤔

eager oracle
#

Yes, but Im not making much sense of it...

#

First of all, BlobAssetReference<Collider> . From what namespace comes that Collider ?

#

Unity.Physics?

warped trail
#

yes

hidden karma
#

Wow theres alot of coding I'm missing out on

warped trail
#

you have methods like this cs // Create a mesh collider asset from a set of triangles public static BlobAssetReference<Collider> Create(NativeArray<float3> vertices, NativeArray<int3> triangles)

hidden karma
#

I'm learning c# and I dont understand none of this

eager oracle
#

Oh, so you mean not using directly the Mesh object, but its values?

warped trail
#

you have all sorts of colliders😅

#

just look inside Unity Physics package

eager oracle
#

Yeah, I am looking. I just dont get much of what is going on...

#

How about this?

            NativeArray<float3> vertices = new NativeArray<float3>(...);
            NativeArray<int3> triangles = new NativeArray<int3>(...);
            BlobAssetReference<Unity.Physics.Collider> blobAssetReference = Unity.Physics.MeshCollider.Create(vertices, triangles)
            EntityManager.SetComponentData(entity, new Unity.Physics.PhysicsCollider { Value = blobAssetReference });

odd cipher
#

so, is there a way to have a NativeHashMap<something, NativeList<something>>?

#

NativeMultiHashMap is slow

#

because of this most likely ```csharp
var valueEnumarator = colorTerrainTypes.GetValuesForKey(name);
int i = colors.Length - 1;
while(valueEnumarator.MoveNext()) {
colors[i] = valueEnumarator.Current;
i--;
}

#

as that loop is done 64 times per terrain which is 40,000 * 64 (2,560,000).. pretty slow

gaunt creek
#

not sure if dots supports Tuples

#

if not you could always write a handler

odd cipher
#

I'm not really good at doing that.. are there any already made that I could use?

gaunt creek
#

hmm, it's hard to give you a solution with the above snippet

#

what I would ask is the colors[] always ending up in the same state (64 indices)?

opaque ledge
#

native container cant have native containers in it, as native container is not blittable

gaunt creek
#

think you can just have a 2d native array though

odd cipher
#

@gaunt creek so I currently have a NativeMutliHashMap<something, Color32> and when I want the specific color32[] array from it with a certain key I have to do that loop

#

which is really slow

#

and no, the color32[] does not end up the same each time

gaunt creek
#

have you tried GetKeyValueArrays?

#

so I guess:

colorTerrainTypes.GetKeyValueArrays(allocator)
odd cipher
#

well how would you put in the key in that?

warped trail
#

in my naïve approach i would make it just big 1d array😅

gaunt creek
#
colorTerrainTypes.GetValueArray(allocator)
#

should give you a NativeArray<Color32>

odd cipher
#

yeah but that would give me the all the values no?

gaunt creek
#

sure but isn't that what you're doing with the enumerator?

odd cipher
#

im trying to grab the correct colors for the key

#

and what I showed before worked for that

#

but was slow

warped trail
#

or BlobAsset if data is not changing🤔

#

or NativeArray of BlobAssetReferences

odd cipher
#

never used BlobAssets, and I'm not using Entities if thats a part of that

#

only Jobs and Burst here

warped trail
#

maybe sacrifice some space and make big 1d array?😅

odd cipher
#

1D to 2D and 1D to 3D calculations hurt my brain 😅

gaunt creek
#

something like this?

#
var x = new NativeMultiHashMap<int, Color32>();
foreach (var key in x.GetKeyArray(Allocator.Temp))
{
    var enumerator = x.GetValuesForKey(key);
    while (enumerator.MoveNext())
    {
        var color = enumerator.Current;
    }
}
odd cipher
#

isnt that pretty much exactly what I had originally

#

yeah it is

#

also the keys are structs so converting them to a 1D array wouldnt really work

fallow mason
#

It would if you had an int id as part of your struct and got the index with that

gaunt creek
#

yeah I was asking if the code sample is right for what you have

warped trail
#

your struct can have int index to big 1d array of Colors32[]

gaunt creek
odd cipher
#

@warped trail @fallow mason well, my struct has 3 IDs

fallow mason
#

Doesn't have to if it's 1D 🙄

#

Oh you mean your variants thing? 3 separate 1D arrays.

odd cipher
#

I just dont know how to make that work

fallow mason
gaunt creek
#

are you using an IJob?

odd cipher
#

IJobParallelFor

#

also, its not a 3D array in the first place

warped trail
#

it doesn't matter😅

#

just don't use z

#
i = x + y * max_x

x = i % max_x
y = ( i / max_x ) % max_y```
odd cipher
#

the more I think about this the more confused I get

warped trail
#

you have one big array[] with everything. You can index it with i, x is your key, y is color32

#

array[key][color32] -> array[key + color32*totalNumberOfKeys]

gaunt creek
#
public int To1D( int x, int y, int z ) {
    return (z * max_x * max_y) + (y * max_x) + x;
}

public int[] To3D(int index) {
    int z = index / (max_x * max_y);
    index -= (z * max_x * max_y);
    int y = index / max_x;
    int x = index % max_x;
    return new int[]{ x, y, z };
}
odd cipher
#

so something like this to convert it to native? ```csharp
nativecolorTerrainTypes = new NativeArray<Color32>(count, Allocator.Persistent);
foreach (KeyValuePair<TerrainSprite, Color32[]> kvp in colorTerrainTypes) {
for (int i = 0; i < kvp.Value.Length; i++) {
nativecolorTerrainTypes[kvp.Key.terrainID * kvp.Key.bitMaskID + kvp.Key.variantID + i] = kvp.Value[i];
}
}

#

I dont think that is what I'm supposed to do but I tried

#

@gaunt creek @warped trail

#

cant figure it out

warped trail
#
int x = 0;
foreach (KeyValuePair<TerrainSprite, Color32[]> kvp in colorTerrainTypes) 
{
    int y  = kvp.Value.Length;
    for (int i = 0; i<kvp.Value.Length; i++) 
    {
        nativecolorTerrainTypes[x + y * colorTerrainTypes.Length] = kvp.Value[i];
    }
    x++;
}``` more like this i guess🤔
odd cipher
#

alright.. now how would I index it with a TerrainSprite struct?

warped trail
#

TerrainSprite is probably has some enum inside?🤔

odd cipher
#

no, just the 3 IDs I talked about

warped trail
#

i guess you will index with your terrainID🤔

odd cipher
#

no i would need to index with all of them

warped trail
#

with your terrainID you will get your Color32[]

odd cipher
#

well I need to use all of them

#

because otherwise it wont work

warped trail
#

what do you mean by all of them?

odd cipher
#

well before I just indexed it with the TerrainSprite itself, but now I need to get the correct one in the 1D array with all the TerrainSprite values

#

i dont even know at this pointr

warped trail
#

each of your TerrainSprite has Color32[]?

odd cipher
#

no.. im want to get the correct Color32[] in the 1D array with the TerrainSprite values

#

I cant do that because I cant have nested arrays

warped trail
#

this is how your 1d array will look like cs 1 2 3 4 [Color32[],Color32[],Color32[],Color32[]]

odd cipher
#

yes but indexing with just terrainID wouldnt work

#

because each terrainID has different variantIDs and bitmapIDs

warped trail
#

variantIDs and bitmapIDs are indexes ?

odd cipher
#

yes thats what ive been saying, all of them are

zinc plinth
#

jackson dunstan's blog doesn't exist anymore ? Wat

warped trail
#

they are pointing to Color32[]?

odd cipher
#

I want to index the 1D array with all those values together

#

i dont know

#

im just getting more confused

warped trail
#

just forget about 1d array for a moment

#

variantIDs and bitmapIDs are indexes to where?

odd cipher
#

the terrainID

#

each terrain has multiple variantIDs and multiple bitmapIDs

warped trail
#

is any information that you need is stored outside Color32[]?

odd cipher
#

I honestly dont know at this point

#

I just somehow need to be able to index it and convert it to 1D in a way where I can index it with the 3 IDs

#

@warped trail I'm just unsure how to do this.

fallow mason
#

@odd cipher like I said weeks ago, I would suggest you really examine what is the real problem you're trying to solve. I can tell you it's probably not that you have 3 ids that need to work together to map to a color. That's a problem with a proposed solution to the real problem.

#

Maybe try taking a simpler approach with just one id for base color and add complexity once you have it working?

odd cipher
#

I'm trying but I'm not sure how to get the 8x8 color array from a 1D array

#

even with just one ID

#

feel like theres just a way better way to do this

odd cipher
#

it seems with a NativeMultiHashMap the more keys you have the more time it takes for the loop for some reason

torn kestrel
#

can I set the name of an entity to something when spawning it via code so they aren't all the same name in the debugger?

safe lintel
#

only with the entity manager, not command buffers

#

SetName

torn kestrel
#

thanks!

digital kestrel
#

what's the difference between localToWorld and Translation

#

oh nvm

grim plinth
#

random question can job system handle a random function?

digital kestrel
#

wdym

grim plinth
#

like using random.range(0,12)

#

I'm just making sure and such I'm jumping to use jobs system for performance

low tangle
#

unity.mathematics.random

grim plinth
#

ty

#

I'm ready to do this

eager oracle
#

Weird issue. Even thought I set my rigidbody to constrain the rotation on all axes, when I convert to Entity, it is still rotating.

#

Dont those settings get converted too?

bright sentinel
#

@eager oracle No, a rigidbody is not the physics representation in ECS

#

I'm not sure about the exact conversion, but you should use the Physics Body and Physics Shape instead, that will have a more clear representation of what is possible in ECS physics

eager oracle
#

Oh, ok

#

Lets see

bright sentinel
#

But even then, the new physics doesn't have those constraints

#

You can get the same behavior though with joints, look at the samples if you want to see how they do it

eager oracle
#

Joints?

bright sentinel
#

Yes

eager oracle
#

Not sure what you are talking about..

bright sentinel
#

You can look at the physics samples to see how they work

#

There isn't much in terms of docs or guides on them

eager oracle
#

Lets see

#

Seems kinda convoluted, to lock rotation, no?

warped trail
#

it is still in preview and is not production ready 😅

eager oracle
#

Yeah, I guess

#

btw, 0.8 is quite advanced. Is there a planned release date?

#

Oh well, I will keep an eye on it. Seems to change every week anyway 🙂

#

Another thing im not sure how to do in ECS is communication between entitites. Like "If Entity 1 jumps, move Entity 2"

amber flicker
#

Probably ComponentDataFromEntity is something to get familiar with

dull copper
#

talking of updates, is Unity going to update DOTSSample at all or will face the same fate as most Unity tech demos?

#

even that old FPS Sample was supposed to be maintained but we all know what happened to that

#

to latest DOTS packages, like maintain it

#
"com.unity.entities": "0.4.0-preview.10",```
#

that's fairly old IMO

#

also MegaCity didn't get ANY updates

warped trail
#

MegaCity is already released 😅

dull copper
#

yeah I suppose, but Unity did say they will update it

opaque ledge
#

I has a problem

dull copper
#

yeah, for DSP Graph and stuff

#

unless I remember that totally wrong

#

it's kinda pity because would be awesome to have more up-to-date projects like that

#

I do get it takes resources, but if Unity doesn't bother updating stuff like that because it's too tedious, they can't really imagine people jumping to DOTS now do the same for their projects

#

(that being said, my own advice would still be to not jump into DOTS for main projects at this point)

opaque ledge
#

I am instantiating entities from a MB, then i add components to it, the weird thing is, when i add around 4k entities, it gives error that some entities are still deferred, and another error saying this entity index is out of entity manager index so it must be corrupted or instantiated in a different entity manager, even weirder thing is when i look at entity debugger, entities are being instantiated instead of instantly, so these errors continue until all of them are instantiated

#

soooo.. any suggestions other than instantiate lower amount 😄

dull copper
#

@digital scarab I stand corrected, I did look into the old forum threads and no such comment was made by Unity. I must have mixed it with the promises of DSP Graph samples themselves which were said to be coming

#

(what was said was that one should just take a look at megacity atm before there are proper samples for the thing)

#

I could have sworn I heard somewhere they would update MC too but can't find ref to that so probably better take it wasn't a thing 😄

low tangle
#

I do remember them saying something like that

#

but I think it was about a version with the new rendering

#

if thats the case I bet it wont show up till a big fancy reveal

#

also I'm likely miss remembering I haven't checked forms in a long time

stone osprey
#

Good evening 🙂 Im looking forward to use Dots for my mobile game... actually i was using normal MonoBehaviours and Prefabs before... all i need to know is the following, i store my prefabs in a self coded internal database made with scriptable objects, it it possible to spawn in prefab references ? And what should i do if a system should not get called every frame... instead once a event was received ? For example, if the server tells me that a mob received damage -> Call System -> Update healthbar ?

dull copper
#

kinda weird that the blog post about Unite Now made it sound like those three days were alone on the first chunk of content

#

and that their Google Calendar listing had content listed for 3 weeks

#

Basically these two:

#

maybe they've not finalized the listings for the next 2 weeks and we'll get some update on it or something

warped trail
#

Mike Acton's talk😔

dull copper
#

tbh, I'd love it if they just did what Epic does with Unreal and they'd just do one stream each week for whatever they feel is relevant

low tangle
#

yeah I like that a lot too

#

streams would be nice anyways for the current climate

dull copper
#

I kinda get the events as they are great way to connect with people. It's also totally different to talk with others in person than be lucky to get one of your questions asked on a streams QA

#

but having these events also does mean they do hoard some content to present there, so would still be nicer to just get updates asap on weekly basis rather if some new thing is suddently out

#

in that way, doing streams all around the year would be more "modern" take IMO

stone osprey
#

Someone into dots who could answer me my question ? 🙂 Im looking forward to use Dots for my mobile game... actually i was using normal MonoBehaviours and Prefabs before... all i need to know is the following, i store my prefabs in a self coded internal database made with scriptable objects, it it possible to spawn in prefab references ? And what should i do if a system should not get called every frame... instead once a event was received ? For example, if the server tells me that a mob received damage -> Call System -> Update healthbar ?

digital kestrel
#

does entitycommandbuffer have a way to addcomponentdata?

warped trail
#

yes

digital kestrel
#

ok what is it

warped trail
#

addcomponent🤔

mint iron
#

@stone osprey

it it possible to spawn in prefab references?
You can convert GameObject prefab references into Entity prefabs for use in ECS, see conversion and implementing IDeclareReferencedPrefabs https://docs.unity3d.com/Packages/com.unity.entities@0.8/manual/gp_overview.html?q=conversion however, i don't think they have a solution for using GameObjects inside ECS yet.

what should i do if a system should not get called every frame... instead once a event was received ?
You can use an EntityQuery or Entities.ForEach lamda to filter to just a set of entities. Therefore, you can create an entity with a specific component that then is used to trigger the execution of other code.

Check the pinned messages for documentation and examples.

stable fog
#

??

#

Is there some kind of thing going on right now?

stiff skiff
#

I'd love to meet the team 😄

#

Quick question, is there a way to remove archetypes from the system?

#

I found that I have 125 archetypes, of which 120 have a ChunkCount of 0. Would love to somehow clear these away

stable fog
#

yeah, I don't think thats true Topher

#

I'm curious why you said that in the first place though

#

I just want to say, I appreciate everything you and your team and everyone's teams at UT for all the great tools and tech ya'll provide and the current staff is obviously amazing as I see Unity continuously moving towards some really excellent smart design.

fallow mason
mint iron
#

is there some event on i dont know about?

stone osprey
#

@mint iron Thanks for your help ! 🙂 Dots looks powerfull and i love data oriented programming... Just wasnt sure how GameObjects and Dots fit together

#

@mint iron Would you actually prefer using dots over gameobjects ?

coarse turtle
#

@mint iron there's a meet the team session on Unite Now happening sometime mid april 👀

sour ravine
#

I solve practical problems

#

"what is DOTS"

opaque ledge
#

How will we know who is Topher when that meet event happens 🤔

bright sentinel
#

Maybe someone will complain about all the stupid users on the community, then we'll know 😄

warped trail
#

so no in depth information about subscenes and conversion😔

mint iron
#

any regulars here live in Montreal ? 😉

stiff skiff
#

Am I wrong in thinking that ECB's batch component adds?

opaque ledge
#

you can make entity queries and do EntityManager.DestroyEntity(entityquery)

#

i think

stiff skiff
#

Yes, but those have nothing to do with ECB's

opaque ledge
mint iron
#

i dont see any batch action going on for Add Component in the ECB source, just one by one per entity

opaque ledge
#

i think its batch, you 'add' one by one, but when its being playback then its a batch

#

probably

stiff skiff
#

Its not batched on playback, so if you add multiple components to a single entity in ECB, you get multiple archetype changes

#

Hench, I now have 120+ archetypes, of which 110 have no entities, and likely never will

#

This was an issue in 0.1.0, I was kinda hoping it would be gone after our upgrade to 0.7.0

opaque ledge
#

🤷 hope you find an answer

stiff skiff
#

I'll have to somehow "dryrun" all the bits that would add a component, then create the entity with the archetype that comes out of this dryrun, then run it for reals and set all data where needed

mint iron
#

what about figuring out all the components you need to add, then use SetArchetype()

warped trail
#

but you can't do this with ecb? 🤔

mint iron
#

true, he's shit out of luck with ECB, have to wait for unity to improve it

bright sentinel
#

My only mission will be to figure out who Topher is 🤔

fallow mason
#

Isn't he that guy from that 70s show?

#

Played Spiderman?

formal scaffold
#

Hey I have a big Archetype Input. It will eventually have alot of components, one for each Key assigned. Is it possible to iterate in a job over this chunk, maybe with IJobCunk, in a certain way.

Let's say I have 20 components, I want my System to create 5 worker threads each checking 4 components for Input from the user.

Is that possible?

bright sentinel
#

@formal scaffold Well first off, with the job system, you don't really control the threads at all.

#

Secondly, I think queries are limited to 8 components

#

Third, having 20 components in one query seems like a design flaw anyways, you might need to rethink your strategy. What are you trying to achieve?

formal scaffold
#

I see the problem with alot of components. My solution is an archetype, then get that archetype and iterate over the entities.
I noticed that my MovementSystem would need the component PlayerInput. And within PlayerInput I store Mouse(float2) and Keyboard(float3) input.
I don't need mouse input when calculating movement and I don't need Keyboard input when rotating the camera

bright sentinel
#

Well why does your system need to use so many components? It seems like you need to split that system into multiple smaller systems

formal scaffold
#

So I thought, why don't I create a component for every type of input. Then systems can cherrypick what they need, instead of loading the whole Input

bright sentinel
#

Wait, can you even get input in jobs? Doesn't that have to be on the main thread?

fallow mason
#

You can set component data on main thread and use the resulting component in jobs

formal scaffold
#

Hmm if I can't then thats out the window 🤔

bright sentinel
#

Yeah that's true, but then you might as well set the input to the useful components instead

#

Like transform input to a direction vector that your movement system then uses, or whatever you need

#

That way your systems are split more into isolated systems

fallow mason
#

That's what I do. Split up the input into related parts and each system grabs the one they're interested in.

bright sentinel
#

Yep

formal scaffold
#

Yeah I'm trying to achieve that

bright sentinel
#

What I have is a FPS System that is run on the main thread which just gathers the input for movement, shooting, sprinting etc. Then it sets the components of each of those things so that their systems can do their thing

fallow mason
#

I have an InputGatheringSystem that listens for all my input events (new input system) and creates or sets Singleton input components.

bright sentinel
#

That's also a solution

#

Something important to remember is that input should only be gathered once in a frame, so it's a really miniscule CPU usage

formal scaffold
#

Thats how I do it, but I wonder if splitting Keys like I(Inventory) ,M(Map), J(Journal) into seperate Components would be useful

warped trail
#

and it is not worth it to schedule job for each input type 😅

formal scaffold
#

😅

bright sentinel
#

I'd keep all your input gathering in one place, and then set the components for each system that needs it

#

You can also do it with a singleton, but imo that's a bit unnecessary

formal scaffold
#

I Thought of a singleton yeah

bright sentinel
#

Although my project isn't very complex yet, so a singleton might have some advantages I don't know about yet

#

Like when splitting between gameplay and UI 🤔

warped trail
#

gather input in 1 place and while this data is hot, copy it to every place this data is needed 🤔

fallow mason
#

I split it up based on relation. For example I have a waypoint input component that has a bool for addwaypoint and removewaypoint and a vector2 for position, because that's all my waypoint queue system needs to do its job.

#

A mouse click maps to addwaypoint, z to remove, and mouse position to position

formal scaffold
#

It's a bit more complicated for me, my player movement (keyboard input) depends on my camera for example. Well but I could just move the camera part out of the movement system and put it into the InputSystem. Feels wrong tho, I don't know.

bright sentinel
#

Well, what I would do then is have an input system that sets the movement input to some player movement component, and also gets the camera data you need. Both of these needs to be done in the main thread, so no reason to separate them, as they're related to each other. Then once you have the necessary data (float3's and whatnot) you move to another system that then actually uses that data.

#

Remember to think data oriented

#

First gather all the data you need. For input that can be e.g. a bool if it's a single keypress. For the camera, it's probably the position and rotation. Once you have that data you can then use it to do the actual behavior

fallow mason
#

yeah my general thought process is that if I find I'm writing to more than one or two components, I probably should split it up into multiple systems.

bright sentinel
#

I agree, except for those one-off things like input or camera stuff, as that doesn't have 100% integration with ECS yet

fallow mason
#

right

formal scaffold
#

Hmm makes sense, so DataCollection should only do what is says, data collection and other systems operate on that data, preferably on parallell if they can.

bright sentinel
#

Well, mostly input, camera and lights are not main thread (and probably a few others)

#

Only main thread*

#

So those are things you should gather from the main thread

#

Everything else should ideally be on components and then gathered through the queries (e.g. Entities.ForEach or queries or whatever)

#

But you've got the gist of it

gusty comet
#

Figured out today that if you write following code
ecb.DestroyEntity(entity); ecb.AddComponent<TestData>(entity);
there is an exception thrown that the entity does not exist.

In complex games components are added and entities are destroyed from different systems. (For example a buff could be added to a player and the player could die in the same frame). So there could be rare random cases where both (Add and Destroy) happen in the same frame.
What is the best practice to avoid this?

Should i use EndSimulationEntityCommandBuffer for Add/Create and BeginSimmulationEntityCommandBuffer for Destroy?

mint iron
#

i believe so; and i was playing with this recently and it seemed like it crashed even if you weren't operating on the same entity, just any destroy and create would do it. So yeah the work around is to have two different ECBs, be it the default Begin/End group ones or creating and managing your own.

bright sentinel
#

The biggest downside to that solution though is that they will still be rendered

gusty comet
#

good to know that there are other people with the same problems 🙂
So maybe the best solution whould be a self created ECB before the EndSimulationCommandBuffer for Adding components?

bright sentinel
#

Probably, you could even extend it to check whether the entity exists before adding/removing components with the ECB

#

Although I believe that is a somewhat expensive check

gusty comet
#

Also looking at unities netcode packages which deletes entity ghosts right after the BeginSimiluationEntityCommandBuffer in the GhostSpawnSystem but with EntityManager

#

Probably, you could even extend it to check whether the entity exists before adding/removing components with the ECB
@bright sentinel i could do that, but in my case the entity is destroyed and manipulated in the same ecb. So a check would always return true.

warped trail
#

system state components ?🤔

bright sentinel
#

I'm not sure what you mean? In the case above it would return true, but in another case where you don't delete the entity first it wouldn't.

#

If you always delete the component and then add something to it, then why even add something to it anyways?

gusty comet
#

Maybe i am wrong but imagine something like this:

System1:
Destroys entity in EndSimulationECB

System2:
Adds buff to entity in BeginSimulationECB

Both System run in the SimulationGroup in the same loop

So a check in System2 if the entity exists would always return true because it is destroyed later in the frame.

bright sentinel
#

Ah, I mean that you could create your own ECB that just runs right before or after the EndSimulationECB that does the check

#

That way you can avoid the rendering of the object in that frame

gusty comet
#

Ah ok now i know what you mean

bright sentinel
#

You could maybe even go and change the source code of the end simulation ECB as well to do that behavior, so you don't have to have two of them

#

I haven't delved into the source yet though, so I can't tell you how to achieve that

gusty comet
#

I am just wondering, because this seems like a general design problem of the ECB usage

bright sentinel
#

Yeah, I agree.

#

I haven't really encountered it myself yet

#

But my project isn't that complex

gusty comet
#

IMO there should be something like a ECB for AddComponents which runs before a ECB which Destroys Entities. But i am not an expert

bright sentinel
#

That's where you could just create your own ECB that runs right before the EndSimulationECB actually

#

They're not that hard to make

gusty comet
#

Yeah i am going to do that, will be the best approach

warped trail
#

maybe destroy entity a little bit later?

#

separate it from any query with writegroups of with disabled component

gusty comet
#

Would be nice to have some sort of best pratices (like the SOLID principles in OOP) for ECS. The system order gives me a lot of headaches

warped trail
#

let this entity exist one more frame

gusty comet
#

let this entity exist one more frame
@warped trail so you mean add something like a "destroy" component?

#

and then destroy it?

bright sentinel
#

Well there are some ECS principles out there, but it's definitely not as developed as OOP given the widespread of OOP. ECS is popping up a lot more now, and with Unity supporting it, I think there might be some better things coming up very soon

gusty comet
#

and all systems which add something dont run on components with that writegroup

#

interesting approach, too

warped trail
#

just add prefab component😂

gusty comet
#

just add prefab component😂
@warped trail this would do the job 😄

stiff skiff
#

@mint iron Sorry for the late response, yeah figuring out all components are using SetArchetype is the plan, the issue is that this is harder then it seems due to the complexity of my systems. But gonna give it a shot

low tangle
#

updated my code snippits for ecs

#

updated all of the class ones to use systembase and added in NewBuffer

#

place the .snippet files into Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets

#

I fixed the imports as well, so it will add using Unity.Jobs etc if there not there already

opaque ledge
#

How can i add child gameobject's entity to a component data when converting ? I have a ship prefab and i have shooting points that are simply empty gameobjects, i want to add those entities(so after childs are converted) to ShootingPoints component data for parent, so when i am creating a shot i will create them at shooting point's translations

#

Right now i am using Transfrom field in my authoring and calculate the vector and add that to component data, but when i am instantiating shot i actually need to calculate the 'real' vector by calculatig scale and rotation as well and since Unity is already doing that(for calculating child entity positions) i rather have it like that

warped trail
#

you want your shooting point to be child of a ship?

opaque ledge
#

Yeah, and when its converted to entity i want to add it to ShootingPoints component of the parent

bright sentinel
#

Well, all it is is really just an offset from the root entity's position. So maybe it would be better to store that offset in your shooting component instead of having a new entity for it?

warped trail
#

i think this will be much more expensive, than just calculating 'real' vector🤔

opaque ledge
#

thats what i am doing it right now, but i dont want to calculate the rotation and scale to find the real offset

#

oh hmm 🤔

warped trail
#

with child you will need to calculate 'real' vector anyway to get current position🤔

#

because your child will have previous frame's data in LocalToWorld and LocalToParent components

#

and yo get real position you will need to make calculation yourself

#

and then this exact calculations will be made in transform system😅

opaque ledge
#

yeah i guess i will stick to current way

#

yeah kinda weird that prefab autoring doesnt respect to Stop script

formal scaffold
#

Anyone noticed that using ConvertGameObjectHierarchy creates an entity with NaN set as render bounds? Using entityManager.Instantiatethen creates a NEW entity with those values set. The "old" entity persists tho. This slightly irritates me because two entitys will have almost the same components. Should I remove that other entity by hand? Not sure if the "ghost" entity will be used by systems

warped trail
#

i guess ConvertGameObjectHierarchy creates prefab entity🤔

formal scaffold
#

It takes in a prefab and converts it into an entity yes, so it makes sense that an entity is created. But it seems that the "Render Bounds" part is missing and is a step of Instantiate

warped trail
#

just check if your "ghost" has prefab component

formal scaffold
#

-_- Unity is slow on HDD have to change that sec

#

Yeah it has the prefab component

stone osprey
#

Uhhh... one more question... lets say i want to use a prototype pattern, that means i define entitys somewhere and "clone" them in for spawning... would this be possible with unity ecs ?

bright sentinel
#

@stone osprey Not exactly sure about a prototype pattern, but that sounds pretty much like a prefab

stone osprey
#

@bright sentinel Its pretty similar, the only difference is that a prototype in that prototype pattern is defined in code... "Entity entity = new Entity(); entity.AddComponent()..." each time we need a new instance of that entity, we simply clone it... so we have the whole entity configurations at one place in our code. So the main question here is if im allowed to create entity instances by myself in dots... "Entity myAwesomeEntity = new Entity(); Dots.AddEntity(myAwesomeEntity);"

opaque ledge
#

you can do that with EntityManager.CreateEntity(), or rather EntityManager.Instantiate() for your case

bright sentinel
#

Yeah that's definitely possible, as Curly said, use EntityManager.Instantiate() and then you can add the components to that entity.

#

Or maybe through a entity command buffer, depending on your needs

opaque ledge
#

CreateEntity just creates an entity that has certain component types, Instantiate however clones an Entity.

bright sentinel
#

Ya, I think those are made with MBs though

dull copper
#

afaik the point is to have a working MB that you then convert to ECS as training excercise

#

each sample has it's own difficulty rating on how hard it's to port

#

Use the originals for reference, but remember we're only trying to achieve the same output. Use ECS and data-oriented design!

#

I kinda wish they would have done few as examples though

bright sentinel
#

Ah I see. Well you can look at some of the branches in there

#

There's the "archived-ported-samples" one

#

Which you can use as a reference

dull copper
#

oh I didn't notice they had other branches there

humble falcon
#

Can someone help me. I have troubles with getting a componentdata from an entity within job. So my problem is the following.

I have a detectionsystem that has a job which updates the bufferelement of an entity. The job interates through an entityarray, which was queried before and now I try to get the position from each entity inside the array. While reading through the manual I come across to the GetComponentDataFromEntity<T> struct so I tried to use it inside the job to get the position value of each entity.

But I couldn't run the application because of this error code:
error DC0001: Entities.ForEach Lambda expression uses field 'psition'. Either assign the field to a local outside of the lambda expression and use that instead, or use .WithoutBurst() and .Run()

I tried to assign the field outside Entities.ForEach. So I put like ComponentDataFromEntity<Translation> position = GetComponentDataFromEntity<Translation>()
still not working. Am I missing something. I mean it really is basic stuff, I maybe just dont get the idea behind dots in general.

opaque ledge
#

Yeah, you have to put "ComponentDataFromEntity<Translation> position = GetComponentDataFromEntity<Translation>()" in OnUpdate method outside of your job, and inside your job you have to query for Entity field and do position[entity] to get the entity's translation.

#

And dont worry about it, we all have been there, most of the people already sufffered enough of those to learn how to do things 😄

#

There are 2 things to note here, if you are only reading translation from CDFE(ComponentDataFromEntity) you have to do .WithReadOnly(position) for your ForEach method, if you are reading/writing in parallel(meaning you are doing ScheduleParallel) you have to do .WithNativeDisableParallelForRestriction(position) for your ForEach method.

humble falcon
#

wow that was a god speed reply . yeah i put the code in the OnUpdate method outside my job. I will try your solution approach 🙂

opaque ledge
#

Other things to note:
If you are only reading from CDFE you have to pass "true" to GetComponentDataFromEntity method.

There are 3 methods called GetComponent, SetComponent, HasComponent in SystemBase inherited classes, you can also use those to read/write from a job, 1 thing to note however, if you want to parallely read/write to a component you cant use SetComponent, then you have to do the "old" CDFE approach, and dont forget to add .WithNativeDisableParallelForRestriction also

#

GetComponent, SetComponent, HasComponent is the way to go btw, they are the new shiny stuff to reduce code boilerplate

humble falcon
#

well my code looks as follow right now. pretty basic:

opaque ledge
#

you can use hastebin for long codes 😄

humble falcon
#

ok i dont know that

opaque ledge
#

simply post your code over here and click save button, it will give you a link

humble falcon
#

something like that?

opaque ledge
#

yep^^ Stop using JobComponentSystem, use SystemBase instead

humble falcon
#

what is the difference?

opaque ledge
#

is more shiny 😄 also reduces some minor boilerplate, also makes you enable to use Has/Get/SetComponent methods, other than that its same

#

you can just do Entities.ForEach.Schedule() for example

#

anyway, you can do entities.Dispose(job)

#

dont forget to do .WithReadOnly(positions) just before Schedule()

humble falcon
#

oh ok nice to know that. The tutorials and samples I am currently watching use all the JobComponentSystem. I didnt know that you can do other than that. Thanks 🙂

opaque ledge
#

Yeah, tho you can still use JobComponentSystem until you get some experience, better if it enables you to follow some tutorials.

#

gl^^

warped trail
#

@humble falcon have you looked at unity's boid implementation? 🤔

humble falcon
#

If you mean the boid Sample from ECSSamples than yes.

#

Well prior I already wrote on steeringbehavior but in classical way (object oriented) But now, I try to rewrite it in dots. It is just, that lots of "easy" stuff is now hard for me to write. I think the boidsample from unity isn't up to date anyway, isn't it?

warped trail
#

they properly maintain it, and it is up to date

ebon narwhal
#

Error while executing command: ...\torment\Library\PackageCache\com.unity.burst@1.3.0-preview.3.Runtime\hostwin\lld -flavor link Does anyone have the same problem with the latest preview of unity. ?

#

sorry 2019.3.7f1

mint iron
#

the boids sample is more of an advanced tech demo and its cool but makes approaching the whole thing scarier and more complicated than it needs to be.

warped trail
#

but he is making boid thing 😅

humble falcon
#

I dont mind getting scarier stuff 😆 and yeah I will look into it

warped trail
#

@humble falcon and as smart guys say, CDFE is slow. I think in your case it is better to get copy of all positions instead of using CDFE🤔

humble falcon
#

so it is better to get a nativelist of positions in the OnUpdate instead of using CDFE inside job? Okay I will try it out

opaque ledge
#

@ebon narwhal restart your unity editor

#

@warped trail really ?

#

i never heard of it 🤔

#

i mean obviously random access is 'slow' but i never heard of copying to native array first to minimize perf loss

bright sentinel
#

You can get a collection of the components using a query

#

I would speculate that's a lot faster than CDFEs

warped trail
#

my bet is 5-6 times faster 😅

opaque ledge
#

hmmm 🤔

#

i probably should do some tests about it, this is the first time i hear about this

#

why no one told me 👀

mint iron
#

if you need to hit multiple components, in first phase you can collect the fields together (in an intermediary struct), then in your next phase you're accessing them close together rather than jumping around to different areas of a chunk. Would be interesting to pref test it.

opaque ledge
#

how are you going to be sure if entity indexes will be same tho ?, like lets say i do CDFE to array, so i have to use entityInQueryIndex to retrieve the same component that entity has right ? so how is that going to work exactly, how can we be sure query indexes from 2 different query will be the same ?

zenith wyvern
#

If two queries are the same the indexes are guaranteed to line up

#

What do you mean by CDFE to array?

warped trail
#

is was talking about accessing other entities components in same query🤔

mint iron
humble falcon
#

@warped trail yeah it was faster. your bet was close enough. it was 4 times faster than before. Thanks for that 😁

opaque ledge
#

huh well then, i gotta rework those 😄

#

Has anyone find a way to cull rendering(render mesh v2) ? I managed to optimize some stuff but 33 ms goes just for the rendering 4k ships

ebon narwhal
#

thanks or the tip CurlyOne

formal scaffold
#

Hey, is there a way to set default initialization values for components? I saw some of it in the ECS Manual but I can't find it anymore

opaque ledge
#

you can make a static method/property that returns 'default' value

#

like Speed.Default => return new Speed {Value = 10} etc.

formal scaffold
#

I gues I can't put there into the struct itself hmm

bright sentinel
#

What is the reason for structs not being able to be initialized with a default value?

opaque ledge
#

you CAN put into the struct itself

#

you cant make a default value like you do with classes

bright sentinel
#

Yeah, that's what I'm wondering why we can't do that

#

Like, why is C# designed so

#

Or structs at least

formal scaffold
#

Thanks @opaque ledge 🙂
I was wondering, been trying to do the following:
Create Archetype -> Set some Component Values -> create the Entity
But it seems it's not possible to set the components and then create the entity

bright sentinel
#

@formal scaffold You could use a prefab entity

#

Just have the original as a prefab, change the values of the components of the prefab entity, then use EntityManager.Instantiate(prefabEntity) (or ECB)

formal scaffold
#

Oh I think thats a great idea, been collecting components unique to AI and the player within a single script. I could just attatch that to any prefab I create

#

Originally I wanted to reduce the script count on my prefabs to make them cleaner therefore I tried using more code

bright sentinel
#

Ah, that's where you would use authoring scripts

#

Like for example, the physics body you attach to gameobjects. When that is converted, it actually creates a few different components

#

Such as PhysicsMass and PhysicsVelocity

#

But there's no actual PhysicsBody component

#

That is purely for editing purposes

#

Generally you can match authoring components 1-to-1 with archetypes

#

But your ECS components can still be split into modular components

formal scaffold
#

Hmm I was wondering if Authoring by hand was still usefull, I understand now why it is. Thanks alot

bright sentinel
#

Yeah. I'm going to do it with my FPS controller soon

#

Like right now it has these components: Movement, Shooting, Grounding, Rotation (and a few more)

formal scaffold
#

Apart from Shooting I have the same plus a CollisionAngle

bright sentinel
#

Movement has a float2 dir and a float speed. But only the speed needs to be shown in the editor. So that's a single float. The same for rotation etc. That could all be put into a single authoring script, and then use IConvertGameObject and attach those components in there

#

It's a good idea to split authoring and runtime. This way you can make it easy to design, while keeping your performance benefits of ECS

formal scaffold
#

I bet you can also save back any changes made during playtime to the prefab, right. That would be the first step for Saving and Loading later

bright sentinel
#

Hm, I'm actually not sure about that

#

Since authoring is a completely different runtime (MonoBehaviours) compared to ECS components

#

It might be possible, but I have no idea 😄

formal scaffold
#

Don't know either, just dreaming again 😅 would be a cool feature tho

bright sentinel
#

It's just my speculation

#

Yeah

#

Actually

#

I think with subscenes it's possible

#

You just put LiveLink in editing state

#

Open the subscene

#

And edit as you please

#

And then you can just save the subscene

#

Since that's saved as an asset, that should persist through playmode

#

Not sure if it works 100%, but it's worth a shot

formal scaffold
#

Hmm Hmm noted for later already 🧐

bright sentinel
#

gonna go test it 😄

eager oracle
#

I bet I can guess the answer, but just to be sure... is it possible to make the normal physics of the gameobject interact with the physics of entites?

formal scaffold
#

Sadly not, my body would pass right through

#

could be wrong tho

bright sentinel
#

Pretty sure no, but also not sure why you would want to mix them

coarse turtle
#

well they're two different physics systems 🤔 so you need one physics system to interop with the other

eager oracle
#

I figured

#

Well, the reason is because a certain part of my game is easier to implement with DOTS and the other with rigidbodies, but well, cant be helped I guess

bright sentinel
#

You could always decide to use one physics systems, and sync your objects that is easier to do in the other system

#

ECS even has hybrid components

#

@formal scaffold So I just tested, seems I can't save a subscene while in playmode 😦

#

Too bad

formal scaffold
#

Hmmm 🤔 dammit. But i'm sure there will be a way. Don't wanna use Databases for simple stats

bright sentinel
#

WEll

#

If you get your data from ScriptableObjects or something similar, then you can just use those

opaque ledge
#

Yeah thats how i do it, then at an authroing component i convert them to entities and stash them in a shared static

eager oracle
#

@bright sentinel how to sync 2 physics systems??

bright sentinel
#

No I mean you would sync the objects

#

Like, say you're mainly using ECS including the physics, but have some things you would like to do with GO's

#

You could simulate your ECS stuff (including physics), then sync the changes needed by your GOs to those, e.g. set the position of a GameObject to the same of that of an Entity. Then the GO can do what it wants, and finally sync back to ECS

#

Your ordering can be anything you want, and can even be interwoven by going from one system to another multiple times, although I don't recommend it

eager oracle
#

Well, im not using "mailny" ECS, im actually using mainly GO

#

But I think I get what you mean

#

Like showing everything in 2 levels

#

no?

#

But to the player, it looks like one

bright sentinel
#

Kind of yeah, except you don't need to do it with everything, just the data you need. And you can do the exact same the other way around

#

It was just an example

eager oracle
#

Kinda complex, but I guess it could work...

bright sentinel
#

Well your usecase is already kind of complex

eager oracle
#

Yes

#

I would really like to use only ECS, but Physics are quite hard still

bright sentinel
#

Hmm, what can you do with GO physics that you can't do with DOTS physics?

eager oracle
#

It is not that it cannot be done, but it cannot be done in a simple way

#

(or at least I cant)

#

for instance, in a rigidbody you have a checkbox for "freeze rotation". That doesnt exist in DOTS

bright sentinel
#

Well you can use joints for similar purposes

#

It's not that hard to set up

eager oracle
#

Yeah, sure, there are ways, just sying that it is not as simple. I wanted to avoid complexity as much as possible

bright sentinel
#

Well, if it's something like that, then it's a lot more complex to sync your objects

#

The simple solution here would be joints 😄

eager oracle
#

I fear I might end up not using DOTS at all. I am too unexperienced yet

opaque ledge
#

Tbh, right now DOTS Physics seems too much trouble, i never do anything with it, i only use trigger jobs, but people that wanted to do stuff with it always encountered bunch of issues, imo stick with monobehaviours if your project is heavy on physics

verbal pewter
#

Hey all! I'm trying to figure out how to access a component in another entity from within a Entities.ForEach loop. I thought EntityCommandBuffer would have that option but it doesn't. I saw that there's a way to do it using ComponentDataFromEntity/GetComponentDataFromEntity, but that seems specific to jobs (while right now I'm just running this system on the main thread). Am I missing something?

bright sentinel
#

No you can definitely use ComponentDataFromEntity

#

Entities.ForEach actually generates a job for you 😉

mint iron
#

if you're on SystemBase just do GetComponent<T>(entity) within the ForEach

bright sentinel
#

And that

verbal pewter
#

Ah nice, that's what I'll go with. Thanks!

opaque ledge
#

you cant do it with Buffers however, you have to do GetBufferFromEntity

verbal pewter
#

Wait, hmmm, I've misunderstood. The system derives from JobComponentSystem so I don't think GetComponent is an option. I guess I have to go the ComponentDataFromEntity/GetComponentDataFromEntity route.

bright sentinel
#

@verbal pewter If you update your Entities, you should have SystemBase instead, which replaces JobComponentSystem and ComponentSystem

verbal pewter
#

Oh, ya, I'm on 0.5.0. Guess I need to update.

#

Thanks for the heads up 🙂

bright sentinel
#

There are bi-weekly-ish updates of Entities and HybridRenderer

verbal pewter
#

Lol ya, I went on a month and a half break and come back to it being 0.8.0 already.

#

But that's the joy of using cutting edge features 😄

eager oracle
#

You know, I am looking at the repo with the "HelloCube" examples, and when I look at this, I wonder...

Entities
    .WithName("RotationSpeedSystem_ForEach")
    .ForEach((ref Rotation rotation, in RotationSpeed_ForEach rotationSpeed) => { ... })
    .ScheduleParallel();

Why would anyone want to call Schedule instead of ScheduleParallel ? Is it not the whole point of this, to run jobs in parallel?

bright sentinel
#

ScheduleParallel has a lot more overhead than Schedule

#

Job tracking and stealing specifically

#

But can still be useful compared to Run if you don't want it to block the main thread

eager oracle
#

But what I mean is... what do they do different? Jobs use multi-threading by default, no? They will run parallel anyway

bright sentinel
#

Not if they're not scheduled parallel 😄

eager oracle
#

mmm... so that means that if I Schedule() a job, it will run in another thread, which is not the main thread, but only one at a time?

mint iron
#

Is it not the whole point of this, to run jobs in parallel? not really, parallel can often be much slower.

bright sentinel
#

Exactly

zenith wyvern
#

A job run with Schedule will only run in a single thread

opaque ledge
#

if you do Schedule a single worker thread will be used

eager oracle
#

so there is a "main thread" and a "job thread"?

bright sentinel
#

No there is a main thread and multiple job threads

#

Well, they're called worker threads

opaque ledge
#

Yeah, you can see those in profiler Jobs

eager oracle
#

ok, let me rephrase it

zenith wyvern
#

It's necessary in some cases, like if you're writing to a container and you can't be sure multiple threads wouldn't write to the same index.

eager oracle
#

so there is a "main thread" and a "main job thread"?

#

😛

bright sentinel
#

No, it just chooses whichever is available

zenith wyvern
#

There's main thread and not main thread.

eager oracle
#

Like, all the jobs scheduled with Schedule will always run in the same thread (or worker)?

zenith wyvern
#

You don't need to worry about which other thread it chooses to use, only that it's not the main thread

#

And no, you can't guarantee any two jobs called with Schedule would use the same thread

eager oracle
#

I see... so if I understood correctly, when I Schedule() jobs, they will be executed in free worker thread, but one after the other., in order, like a queue?

zenith wyvern
#

Just that they won't use the main thread.

opaque ledge
#

it depends on how many cores you have

#

1 thread per core i believe

bright sentinel
#

Remember, Schedule is for a single job, but with ForEach jobs, it will just execute multiple times

#

So 1 job will run all the executions on the same thread in sequence with Schedule

#

But 2 jobs with Schedule might run on different threads

zenith wyvern
#

I see... so if I understood correctly, when I Schedule() jobs, they will be executed in free worker thread, but one after the other., in order, like a queue?
@eager oracle

No. Whether or not they run one after the other would depend on if they include each other as dependencies. There is every possibliity they could run in parallel if they have no dependency on eachother

vagrant surge
#

isnt it that scheduleparallel does parallel-for, while schedule does parallel system?

eager oracle
#

@zenith wyvern so you are telling me that, even thought I am not using .ScheduleParallel() , they will run parallel??

bright sentinel
#

If you schedule multiple jobs that are not dependent on each other, yes

#

But don't confuse the terminology here

#

A job is just a job, but it can execute multiple times

#

Each execution will still run on the same thread with Schedule

warped trail
#

not confusing at ALL 😆

bright sentinel
#

In the same job that is

eager oracle
#

Ok, im totally lost 😄

zenith wyvern
#

Jobs are completely self contains. The "Parallel" part of ScheduleParallel is not referring to other jobs.

#

It's referring to the fact that that job will run parallel across chunks based on the entities it's query matches

vagrant surge
#

so i was right

#

ok, to give an example. Lets say you have 2 jobs

bright sentinel
#

So if you use Schedule() once on a ForEach job, then it will run ALL its executions on a single thread.

If you use Schedule() twice with two ForEach jobs, then each job will run their executions in a thread. They may be the same thread, depending on resources.

zenith wyvern
#

Another job called with Schedule will only run in a single thread across all the chunks of the entities it's query matches

vagrant surge
#

one is for AI (touches AI component), and the other is for physics, touching(Physics) component

bright sentinel
#

If you use ScheduleParallel, then the ForEach job's execution is split into multiple threads

vagrant surge
#

if yo use schedule on both systems, the AI system and the physics system might execute in parallel, across different threads

bright sentinel
#

The Schedule vs ScheduleParallel is only about the executions

vagrant surge
#

if you do ScheduleParallel, you are splitting a single system beetween multiple threads

eager oracle
#

Glad to see everyone is as lost as me

#

🤣

bright sentinel
#

What exactly are you confused about?

eager oracle
#

I think I got lost around...

Jobs that are .Scheduled() can also run parallel

zenith wyvern
#

Based on what you're saying it seems like you might not fully understand how Unity's the safety system works

bright sentinel
#

So the reason for that is that you can use Schedule on multiple jobs.

#

Each job might run in parallel

zenith wyvern
#

It's hard to really explain when you don't understand how the safety system handles depdencies internally

bright sentinel
#

But the individual job will only run ALL its execution on that single thread

warped trail
#

ScheduleParallel() will split your for loop across multiple threads, Schedule() will run your for loop on 1 workerthread

eager oracle
#

@zenith wyvern I do understand how it works (at least I think I know). Besides, hasnt Unity always run single threaded, before DOTS?

vagrant surge
#

not really

#

some parts run MP

eager oracle
#

(of that last thing, im not 100% sure)

bright sentinel
#

Mostly single threaded, yes

#

Physics was multithreaded afaik tho

mint iron
#

hasnt Unity always run single threaded, before DOTS? pretty much, you could use other threads so long as you never called unity core functions / used unity objects

bright sentinel
#

And network stuff ofc

zenith wyvern
#

@zenith wyvern I do understand how it works (at least I think I know). Besides, hasnt Unity always run single threaded, before DOTS?
@eager oracle

// In System A
Entities.Foreach((ref ComponentA a)=>
{
  // Write to a
}).Schedule();

// In System B
Entities.Foreach((ref ComponentB b)=>
{
  // Write to b
}).Schedule();

If you understand how the safety system works it should be clear how these two jobs can run in parallel.

#

Because they have no dependency on one another the scheduler MIGHT let them run in parallel.

bright sentinel
#

Let me rephrase my point here:

if you use Schedule() once on a ForEach job, then it will run ALL its executions on a single thread.

If you use Schedule() twice with two ForEach jobs, then each job will run their executions in a single thread. The two jobs may be on different or the same thread (parallel or not), but the jobs will do all its own execution on the same thread. So by this one job could execute on one thread while another job executes on another thread.

If you use ScheduleParallel() with a ForEach job, then each execution can be split to multiple thread.

#

I think you are being confused by job vs execution

#

They're not the same term

warped trail
#

you can use regular EntityCommandBuffer and access arrays however you like in Schedule(), but not in ScheduleParallel()😅

bright sentinel
#

Really? That doesn't seem right

eager oracle
#

@warped trail please, lets not bring ECB into the mix. It is already confusing enough as it is

bright sentinel
#

😂

eager oracle
#

@bright sentinel Im reading that last message, really slow. 1 moment.

warped trail
#

i think better way of thinking about jobs is in terms of for loops🤔

zenith wyvern
#

In the code I posted if you replace the Schedule with ScheduleParallel it's the same situation. The jobs might run in parallel, but they would each try to use as many threads as possible for the work they're doing

#

Instead of just using one thread each.

warped trail
#

in Schedule() each loop will be one after another, in ScheduleParallel() you can't guarantee order of loops😅

#

Schedule() is IJob and ScheduleParallel() is IJobParallelFor🤔

mint iron
#

in Schedule() each loop will be one after another isnt that only if you've specified a dependency

eager oracle
#

I think part of the confusion is that we are talking about Entities.ForEach(...) as returning a job, when it can actually return many, no?

bright sentinel
#

No

#

It returns a single job

#

A single ForEach job

#

That executes multiple times

zenith wyvern
#

It's a single job. One job called with ScheduleParallel can use many threads to do it's work.

eager oracle
#

Mmm.... ok, that is something I did not understand then. I thought that a ForEach that matches 3 entities, would return 3 jobs

zenith wyvern
#

It seems like you're confusing jobs with threads.

bright sentinel
#

No, it's just a single job. But it executes 3 times

#

So Schedule would schedule 1 job which executes 3 times on a single thread

#

While ScheduleParallel would schedule 1 job which executes 3 times, on multiple threads

#

(Or maybe they're all on a single thread, but that's all up to amount of resources)

#

But generally will be on multiple threads

warped trail
#

if this 3 entities are in 1 chunk, i don't think that job will be executed 3 times😅

bright sentinel
#

I was trying to keep it simple for him 😛

#

One step at a time

eager oracle
#

I think I might need a cheat sheet to conver all cases

mint iron
#

i was just reading the jobs documentation and sadly its lacking on details.

eager oracle
#

How is a single job that executes multiple times different than multiple jobs ?

bright sentinel
#

Terminology

#

I mean, in these simple cases it doesn't make a difference

eager oracle
#

LOL

bright sentinel
#

But once you have more complex cases with multiple jobs interspersed with Schedule, ScheduleParallel, and Run, it's not the same

#

And then you also take into fact that what I'm telling you isn't 100% correct in terms of what happens under the hood, but it's the right concept

vagrant surge
#

important to know that you want to do schedule parallel basically every time you have a decent count of objects

#

there is a small fixed cost due to the extra setup, but then the inner thing executes on many cores at once, reaching bigger parallelism

eager oracle
#

So, lets see if I have understood this correctly:

CASE 1

Entities.ForEach(Foo) // Will meet 5 entities
    .Schedule()

This will execute Foo 5 times , in a single thread, one after the other

CASE 2

Entities.ForEach(Foo) // Will meet 5 entities
    .ScheduleParallel()

This will execute Foo 5 times, each execution parallel in a different thread (if available) in no specific order

CASE 3

Entities.ForEach(Foo1) // Will meet 5 entities
    .Schedule()
Entities.ForEach(Foo2) // Will meet 5 entities
    .Schedule()

This will execute Foo1 5 times , in a single thread (Thread #1), one after the other.
AND
This will execute Foo2 5 times , in a single thread (Thread #2), one after the other.

Thread #1 and Thread #2 CAN different and can execute possibly parallel

warped trail
#

yes

bright sentinel
#

Yes, except that the bottom two can be on the same thread, but just not in parallel then

zenith wyvern
#

ScheduleAll is meant to be ScheduleParallel I'm assuming. Then no, case 2 is incorrect

eager oracle
#

Ooops sorry, Type

#

Let me correct it

bright sentinel
#

It will just take whatever thread is available

zenith wyvern
#

It will schedule in multiple threads only if there are enough entities to cross chunks. Then it will execute across one or more chunks over multiple threads.

bright sentinel
#

But yeah, as I said, what I explained earlier isn't 100% accurate, and what @zenith wyvern is saying now is a more correct view.

#

But it's also a lot more complex to understand

#

Which is why I decided to simplify

#

Then you also have to understand chunking and batching

warped trail
#

just write archetypes instead of entities 😋

#

and you will be correct😅

zenith wyvern
#

An entity is an archetype, they're interchangable in my mind

eager oracle
#

Yeah, I know there is a possibility that there are no available threads. It can also be that there is a single-core CPU. 😛 I want to discuss about the things that MIGHT happen

#

So, I have corrected the cases. Is it correct now?

bright sentinel
#

Case 3 is not

warped trail
#

you can't have 5 archetypes in 1 chunk🤔

bright sentinel
#

Case 3 can have both jobs execute on the same thread

#

But it can also be on different threads

#

Using Schedule with multiple jobs, they don't care whether another job was scheduled before

eager oracle
#

@bright sentinel corrected, how about now?

bright sentinel
#

Seems correct

eager oracle
#

Ok, I am taking this to my grave

bright sentinel
#

Hahaha

#

Next you learn about chunks and realize that this isn't 100% correct 😂

zenith wyvern
#

Case 2 is still not quite correct, it's not about what resources are available, it's only about whether or not your query covers multiple chunks

eager oracle
#

@bright sentinel Shutup

#

😄

bright sentinel
#

Anyways gotta scoot, cya later

eager oracle
#

cya!

mint iron
#

yeah unless you're using your own input with IJobParallelFor its limited to one thread per chunk, so if your data volume is small and all fits in one chunk, impossible to go parallel even if you schedule it with ScheduleParallel().

eager oracle
#

Yeah, well, "Chunks" is a concept I still have to get familiar, so I didnt want to bring it into the mix

#

If I understood correctly, they are group of entities that match in components, that are localed succesively in memory, no?

bright sentinel
#

Yeah, I think we've established it's not 100% correct, but learning two concepts at the same time is harder, so I decided to just simplify it.

zenith wyvern
#

Pretty much yeah, all entities of the same archetype are put into chunks. Only so many fit into a single chunk, so you could have many chunks for a single archetype.

#

You will only get parallel processing from ScheduleParallel across chunks.

eager oracle
#

so ForEach does not return a job that runs on all entities, but on a chunk of them?

zenith wyvern
#

The concept of the chunks are abstracted away in the ForEach

eager oracle
#

Good

zenith wyvern
#

If you want to work with chunk data (which can be a lot faster if you know what you're doing) then you can use IJobChunk

eager oracle
#

So then lets rephase CASE 2 from

This will execute Foo 5 times, each execution parallel in a different thread (if available) in no specific order

into

This will execute Foo 5 times, each execution parallel in a different thread (if certain conditions are met) in no specific order

#

to be more precise, no?

zenith wyvern
#

I would say so yeah

#

Well, each execution is not necessarily parallel I guess...

#

Like I said, it's only parallel based on chunks.

#

Basically if you're using ScheduleParallel it's important to remember you're not getting a single thread per execution. It's not necessary to know any more details than that right now

warped trail
#

@zenith wyvern what about work stealing?🤔

eager oracle
#

@zenith wyvern That is why I wrote "(if certain conditions meet)". Because it is not necessarily parallel

zenith wyvern
#

Fair

eager oracle
#

I deleted that last sentece, it was too confusing 😄

#

I just dont want to think "Ah, this runs in parallel. Must be superefficient" and be wrong.

#

I might still be... but at least for different reasons 😄

zenith wyvern
#

@zenith wyvern what about work stealing?🤔
@warped trail

I'm not sure how that works, does it split up work within a single chunk?

warped trail
#

i don't know, thats why i asked 😅

#

IJobParallelFor is doing work stealing

zenith wyvern
#

I have no idea on that one, you'd have to ask someone smarter than me

opaque ledge
#

thats probably something only Joachim can answer 😄

#

as in, he is the only one who answers stuff for us peasants in forum

mint iron
#

i dunno about you guys experience, but most of the time when i try to use Parallel processing its significantly slower except if i have huge numbers / work to do.

vagrant surge
#

thats common

#

its very common that if you have sub-1000 "simple" iterations, singlethreaded will be faster

mint iron
#

i recently did an IJobParallelFor for my event batches (mostly setting component data) and the threshhold was around 5000 entities before the threaded version overtook. And for very low numbers it was like 100x faster to just WithCode.Run() it.

#

which leaves me with, just use whatever is simple unless you have a good reason to try and make it parallel

pliant pike
#

power usage is one other reason and freeing up the main thread for other stuff I guess 🤔

eager oracle
#

About building a spawner: What are your thoughts about having the spawner as a MonoBehaviour as opposed as an Entity?

pliant pike
#

why would you use a monobehaviour why not use a system?

eager oracle
#

Well, that is the question. What is the advantage?

pliant pike
#

none I don't think, 🤔 if your going dots then go dots fully

mint iron
#

you would have access to the monobehavior events and base methods, depends if you need that.

eager oracle
#

It does make it attractive...

#

just "going DOTS" for the sake of it, is not much of an argument

mint iron
#

if you have it as a system then you can be assured that its instanced per world, and that your intiialization (Create/Running methods) coincide with the rest of your systems. I've had situations with some monobehavior awake/start setups where things weren't ready yet and it was pretty annoying.

eager oracle
#

I see, then I guess a reason to have the spawner as an entity is to ensure system synchronization

#

Ok, that is a valid point

sharp mesa
#

what is "dots"

#

sry im new

mint iron
sharp mesa
#

oohh ok

eager oracle
#

......

twin sonnet
#

so API wise.. this gives us the Unity.Collections namespace? is that it?

bright sentinel
#

Uh no, you get a lot more

#

An ECS based architecture, High Performance C#, Physics and NetCode based on ECS

#

On top of that job system

#

It's essentially a new core of UNity

mint iron
twin sonnet
warped trail
#

Burst compiler, Job system, ECS😅

#

holy trinity🙏

covert raven
#

Has anybody here done something with NetCode + Animation timing? For example, if an animation takes about 2 seconds before the actual ability is done casting, how is that being tracked on the server side? Right now, the way I have it set up to only have a ghost character syncing important data (ability activated, on cooldown, etc) and let the client manage animations that the server doesn't need to know or care about. On a single player without NetCode, we could just make use of Animation Events and have those trigger certain functions, but in this scenario, would we want the client to send a request based on that trigger to the server or just have the server compute it based on ability timings?

bright sentinel
#

@covert raven It depends a bit. Do you want animations to be synced? In something like CS:GO where animations are important because of hitboxes, you probably want the animation to be somewhat synced. In that case, you probably need to sync the whole state of the current animation frame so that the client gets the correct representation (which can also be predicted).

However, if it's not that important, and you just care about the event (e.g. crouching, ability fired etc), then you just need to sync that event, and then let the client handle the animations.

#

The same applies to how the server handles the case. If the hitbox is important, then you want to include that in the server. If not, then your server shouldn't care really.

covert raven
#

Currently I'm syncing the animation using some state machine e.g. CAST, ATTACKING, COOLDOWN, etc. Currently the client is predicting it, but server is authoritative on it. The only part that I'm not happy about is the actual HIT window since it's time (Time.ElapsedTime) based, how much of a "hit window" should provide the server to compute this without missing it. And if that's the wrong approach (Time.ElapsedTime), what's a better way to guarantee an event happens if it takes exactly 2.1seconds to hit but 1.5 seconds to cast, etc.

eager oracle
#

Crap. Now I see that I should not have used so many "Scriptable objects", because I cant use them in my worker threads 😢

opaque ledge
#

you can 'convert' them into components by using authoring

bright sentinel
#

@covert raven I think it's a very complex problem that's not easy to solve, and not exactly DOTS related, so this channel might not net you the best results. If I were you I'd try to research how timings are synced in other games and what the general practices are. You could also try analyzing games yourself, e.g. play WoW with some artificial lag and see how they handle things.

#

However I'm pretty interested in the topic myself, so if you find anything good on it let me know 😄

covert raven
#

Yeah I wanted to see if someone had done something to solve this moving into DOTS haha. But yeah, this seems more of a how to manage timing on server side without consistent timer.

#

Right now what I have is give it a very small window and ensure the event is only acked once so the physics system can do collision checks at the right time.

bright sentinel
#

Well, NetCode does have some fixed time rate stuff you can look into

warped trail
#

there is lag compensation example🤔

#

they have history of collision worlds

#

but i haven't figure out how to use their interpolation rendering stuff 😔

bright sentinel
#

Well, the ghost should be interpolating automatically right?

warped trail
#

i always have jittery movement

bright sentinel
#

I don't 🤔

dull copper
#

isn't the lag compensation example more like finding if the client having possiblity to hit other player by rewinding the data back to state that the client had?

#

or are there other examples?

warped trail
#

@dull copper yes this example

bright sentinel
#

Yeah that's what NetCode calls lag compensation

#

Also known as backwards reconciliation (which I think is a much more appropriate term)

dull copper
#

oh right you were talking about that

#

I just saw interpolation and thought you were talking about it 😄

#

mb 😄

#

as a side note would love to get some always up-to-date DOTS roadmap so could tell what's coming up and when

#

I keep wondering why realtime roadmaps are such impossible task to handle for people

bright sentinel
#

I think it's because everything is moving so fast and they don't know much where they're going

#

Still exploring a lot

warped trail
#

because Unity like to make soft lies 😬

dull copper
#

well they do have some roadmap still

bright sentinel
#

And also because people will get angry when the roadmap inevitably changes

dull copper
#

I guess one issue is the users

#

people want to take these estimates as promises

#

yeah, exactly

warped trail
#

if you have roadmap you have some responsibility to deliver thing

bright sentinel
#

They can be a lot more flexible without it

dull copper
#

just put a huge disclaimer that everything on it may change

bright sentinel
#

Hah, it doesn't matter

#

People will still get angry

dull copper
#

but then you can clearly point out that they are wrong 😁

#

that'll make them happy

bright sentinel
#

Well, from a PR standpoint that's very bad 😛

#

Telling a user that they're wrong is PR suicide

#

At least for that user

dull copper
#

I dunno if the uncertainty of the future of Unity is good PR at all either :p

#

it really pains me at least

bright sentinel
#

True. And given that their focus with DOTS is AAA production, it should probably be planned out

dull copper
#

I totally understand that things take time but you can't make any assumptions how much if there's zero targets known for upcoming things

#

more like wanting to know what year they target for things x kinda thing

bright sentinel
#

But at the same time, given that it's experimental, I can understand them not wanting to publish a roadmap

#

My speculation is that they're aiming for production by 2020 LTS

dull copper
#

well they said already last year that their current roadmap is planned so DOTS would be somewhat usable in 2022

#

and we all know these dates never hold

#

so add year or two unless they've notably added more resources to r&d after that estimate

#

I know that the people doing hybrid renderer v2 are new

warped trail
#

if you watch Unity's presentation videos you might think that DOTS is very usable and almost production ready🤔

dull copper
#

they work here at the helsinki office

bright sentinel
#

Oh, you're an Unity employee? 😮

dull copper
#

ah, I'm not 😄

bright sentinel
#

Ah, just Helsinki based then?

dull copper
#

I meant like they just physically work in the same town

#

yeah

bright sentinel
#

I see

warped trail
#

you spy on them through the window?🤔

dull copper
#

I've actually never visited the local office

#

before this, they mostly had some mobile marketing stuff here I think

#

stuff that I couldn't care less about

bright sentinel
#

Well, I can tell you that they're ramping up QA on DOTS here in CPH. So maybe that's a bit of an indicator that they're in the later phases of getting production ready

#

Or at least trying to get some better quality packages out

dull copper
#

I can see them moving more resources to DOTS for sure as time goes on

#

Unity as engine isn't in nice state atm, so many new things going on that's not properly integrated to work with other new things

#

I wouldn't recommend Unity for new devs at the state it's at atm, unless they want to join the ride

#

so I can see the motive on getting the engine past that state, but it's still going to take years

bright sentinel
#

Ehh, I think the core engine is still really good

#

But the features around it aren't

#

Hopefully that will be better with the packages they have

#

At least it seems like a better structure for it, to separate things like this

opaque ledge
#

i wonder what we will get at 0.9 entities package, been a while i think

#

did i... did i just kill an entire conversation

bright sentinel
#

Haha no, I think there just wasn't much left in it 😛

dull copper
#

it was getting offtopic anyway

bright sentinel
#

But you're completely right

dull copper
#

and yeah, there should have been new entities package by now

#

I'm guessing the covid-19 thing has messed up the schedules now somewhat

#

there's been like update every 2 weeks or so

bright sentinel
#

Or just some bug that came up late in release

dull copper
#

last update was Mar 13

warped trail
#

at least we won't get lights in hrV2 in URP until the end of the year, if i understood things correctly😔

dull copper
#

huh?

#

isn't it somewhat functional already?

bright sentinel
#

Yeah that's what I heard too

dull copper
#

which one? 😄

warped trail
#

1 directional light

#

and thats it

dull copper
#

oh, that's not hybrid limitation

#

or you mean there's no support for spot and point lights?

warped trail
#

no ambient light, no point, spot

dull copper
#

ah, that sucks

#

I thought you meant like there's only support for one directional light and not two of them 😄

bright sentinel
#

Yeah that's how I understood it too 😂

dull copper
#

I can't remember about URP but on HDRP you can have multiple but only 1 can cast shadows

#

same on URP (only 1 shadow casting dir light)

warped trail
#

i don't like black triangles

bright sentinel
#

That's kinda racist bro 😦

warped trail
#

😒

eager oracle
#

What did triangles ever do to you?

#

Dont badmouth them, just because they have 3 vertices

warped trail
#

so now i decided to play with Tiny only😑

#

but it kinda sucks, that you have to build your game every time😑

dull copper
#

Tiny is like 10x more experimental than rest of the DOTS

#

they've what, redone the whole thing from scratch how many times now?

warped trail
#

1?🤔

dull copper
#

first the typescript thing

#

then c# and they added DOTS mode later with it's own scene files, now they scratched all that and it's all authoring scripts

#

I bet they find a way to make people start again with zero update path at least one or two more times 😄

bright sentinel
#

Well tbf moving to using the same DOTS runtime is really the way to go. Maybe they just didn't have the same information when they started than they do now, and decided that changing it was better for the long run

dull copper
#

at least on desktop side, you can update your things to match the new api changes with somewhat decent amount of work

bright sentinel
#

So is there anything you'd like to see for Entities 0.9?

#

And just generally?

warped trail
#

thank god that im just some hobbyist😅

dull copper
#

I just want better editor tooling at this point

bright sentinel
#

What specifically?

opaque ledge
#

entity command buffer exists method can be useful as well 😄

bright sentinel
#

Like, for Entities I don't think there's much more that's doable atm compared to the functionality

#

Maybe something like a component lifetime debugger

opaque ledge
#

i also would want a special tag components that wont trigger chunk recalculation so adding/removing them to drive a behaviour would be fast 🤔

bright sentinel
#

Couldn't you use either a chunk component or shared component for that?

opaque ledge
#

i dont think so

bright sentinel
#

But yeah, essentially a kind of event system that doesn't incur structural changes would be really nice

opaque ledge
#

and i never used chunk component 🤔

north bay
#

More visual tools 🙂

#

I wanna see my endless dependency chains

opaque ledge
#

i mean for 4k entities, it takes like 4-5 ms for very minimal state amount(2)

#

i am using custom entity comman system, it runs after decision making and before action themselves

#

anyway, hmm.. what else 🤔

#

definitely an event system, i am waiting on Tertle's new event system right now

bright sentinel
#

Hm yeah, a dependency chain could be a really useful analysis tool

opaque ledge
#

definitely i want render culling to work 😄 spending like 35ms for the things that isnt in camera

dull copper
#

What specifically?
@bright sentinel like, being able to pick objects from scene live and examine the values, or if possible, even edit the componentdata live

#

current entity debugger feels like just isolated debugging tool, not something that would feel actually integrated in the editor

#

dots editor package goes part of the way of making that nicer but it feels like a hack and it doesn't even work on most of my use cases

bright sentinel
#

Ah yeah, so basically a scene view for entities I guess

dull copper
#

I'd just want something that would just... work 😄

#

getting basic debugging tools feels like very basic requirement to me

#

I mean, users have built these things partially in relatively short time

#

surely unity with all their resources could do it just properly

#

I'd also want to author entities directly on the scene and have none of the conversion stuff but can't have everything..

bright sentinel
#

@dull copper Yeah I agree, although I think they're focusing a lot more on the conversion. People got scared that they're moving completely away from MBs, and they're probably also worried that people don't want to learn everything from scratch. Furthermore, just scratching all the tools they have made for GOs is also not really a good move atm.

#

A lot of things speak for a conversion workflow for now until they get their own tools

#

So I think you should get used to authoring everything with GOs still and then just convert it

dull copper
#

it doesn't look like there's alternative to it 😄

#

they've been pretty clear that focus is now on conversion

#

also conversion can bit misleading wording at times but I know Unity prefers to use it

#

I mean it's not always about converting MB things but also about authoring things

bright sentinel
#

Ah yeah, but I actually really like the authoring workflow right now

#

It's actually really nice to have those separated

#

Like, having an FPS authoring component that has the available stats that a designer needs, while converting them into ECS components which has the architectural benefits an ECS architecture provides

#

It's like the perfect mix

dull copper
#

I hate it 😄

bright sentinel
#

How come?

dull copper
#

like, the new tags that are supposed to make the authoring simpler don't work for my use case, I need to rewrite most of the things manually

#

exposing component data directly on MB's has quite limited uses for me

bright sentinel
#

Well that's what I like, that you have control over what you show to the designer

#

Like, showing a bunch of different components to a designer is not as useful as gathering an FPS controller into a single component

#

Then you can also create custom editors for MBs like you did before

#

Or with the new UIElements stuff

dull copper
#

and then you don't have need for the generated authoring components again

#

and you still do the things manually

bright sentinel
#

Well no, but auto generated authoring components aren't the end-all solution to conversion

#

It's a convenience function

dull copper
#

for trivial problems yes

#

most games don't work like that though

bright sentinel
#

Exactly. But it's not much different from writing custom editors

#

It's just a lot easier since you don't HAVE to do it, you can just expose the fields in the MB and then add the components

#

ECS architecture isn't too user-friendly from an authoring standpoint

#

So having this authoring layer is a really nice solution to it

dull copper
#

I'd just rather get direct access to that in the editor, instead of having to play with custom scripts

#

but yeah, that's not happening so may as well accept it

bright sentinel
#

But can't you do that with generated authoring components? That gives you direct access to the data

#

Maybe I don't quite understand exactly what kind of representation you want access to in the editor

dull copper
#

I don't really have any showstoppers on this, I just dislike the whole current approach

#

everything can be worked around

#

I just keep thinking all the time how much more streamlined the whole thing could be

#

I'm the kind of person who gets triggered of all extra work that wouldn't need to be done if things had been designed differently

bright sentinel
#

Are you working alone on your project?

dull copper
#

at least the ECS side code is quite nice now, initially I disliked all the boilerplate too 😄

#

yes, but ECS isn't on my main project, I just keep evaluating it at this point

#

I currently only have few prototypes on DOTS

worldly pulsar
#

I'd also want to author entities directly on the scene
How would a directly authored entity be different from a gameobject with a bunch of of [generateAuthoring] components on it (from a UI standpoint)?

bright sentinel
#

That was kind of my question above 😅

#

Just nicer put I guess 😄

worldly pulsar
#

in a subscene*

#

ignoring the editing at runtime/debugging/visualisation for now, just the authoring part

dull copper
#

basically being able to add components directly to entities that get authored, like on the dots mode they had for small moment for tiny. obviously it's not all that black and white though as most things get bundled with tons of components before the system actually works with them

#

I'm guessing the VS for DOTS is going to do things in more the way I'm after here, but I'd not want to use VS for actual code, just for the setup I guess

bright sentinel
#

But isn't that what subscenes already does for you?

#

Make a GO in a subscene, attach a [GenerateAuthoringComponent] to it and bam, you're done

dull copper
#

in trivial cases, yes

#

on my use cases, subscenes just breaks everything 😄

bright sentinel
#

So what are some non-trivial cases?

dull copper
#

basically today the most pain boils down to DOTS packages just not supporting subscenes properly yet

#

also if you have any kind of hybrid setup, like you need to have today, you will have to build custom hacks to communicate between subscene entities and gameobject scene

bright sentinel
#

basically today the most pain boils down to DOTS packages just not supporting subscenes properly yet
Which ones?

worldly pulsar
#

yeah, the hybrid path is a major pain atm

dull copper
#

all in all, its just so much easier to just not touch dots subscenes today

#

@bright sentinel my main interest is on Unity Physics package

#

the joint authoring scripts available today will break on dots subscenes, I think the conversion scripts may already work though

#

but I hate the whole idea of putting physx joints there just to work around it

bright sentinel
#

Hmm, that's weird, subscenes shouldn't change that much about that kind of conversion 🤔

dull copper
#

of course I can write my own authoring scripts to work around that

#

but it also gets back to the original point how PITA all of this current setup is

bright sentinel
#

But that's more about physics than the authoring workflow tbh

dull copper
#

it's more of physics package not being up for the current workflows, yes

bright sentinel
#

My point is just that your problems doesn't seem to be with the actual authoring workflow, at least not what you're describing here.

dull copper
#

but it's same with everything on DOTS really

bright sentinel
#

Well subscenes are quite recent, other packages still need to catch up

dull copper
#

well, I don't really want to expose the componentdata one by one in the editor either

bright sentinel
#

No, but that's the pain with ECS in general

#

Which is where MBs come in as a good solution

dull copper
#

this is why I just have SO driving these on the authoring script (I only use SO data for building the entities)

bright sentinel
#

Ah, so that's where your pain is

#

Maybe you've just overcomplicated your own authoring workflow then

dull copper
#

I need to assign refs to entities on the authoring script too, I can't do that in the editor like on old MB scripts

#

if I only had isolated single use systems, all this would be trivial

#

but conversion workflow just complicates the initial setup a lot

#

again, none of this is showstopping

#

it's just not a very nice workflow

bright sentinel
#

It sort of sounds like you've made that workflow more complicated yourself

#

Because I'm not having those issues as I'm not using SO's

dull copper
#

SO's are not really the thing complicating this

#

SO's are there to simplify the mess it is now

#

it's just easier to setup things through them

bright sentinel
#

Well I disagree here, having it directly on MBs is pretty useful

dull copper
#

basically the main thing complicating my setup is that I have multiple entities connected to the same systems here

bright sentinel
#

Well then that sounds like your systems needs to be split up 🤔

dull copper
#

I try to minimize these connections but I need to sync data still

#

but like, I have component data in child entities that I just want to author in one place

#

without custom authoring scripts, that's not happening

bright sentinel
#

And why are you so against custom authoring scripts? They take like 5 min to set up, and then you have a much nicer representation for your entity

#

You can even create a snippet for your IDE to set it up

#

Then it only takes 10 seconds

dull copper
#

I just don't like when the same thing could take seconds instead

bright sentinel
#

But how would you have something custom like this be done automatically?

#

If it's custom to your case, the editor can't really generate it for you

dull copper
#

the whole point is that you have to do tons of custom scripts on my use cases

#

and that it's mainly happening because there's no editor support that lets me just setup the thing in editor

#

again, I'm just not happy with the current tooling

#

again, everything I need to do is doable already

worldly pulsar
#

Sounds like some magic in [GenerateAuthoring] that turns IComponentData with an Entity field into a GameObject field in the editor and then use GetPrimaryEntity for the mapping would solve that problem (and would be useful in general)

dull copper
#

I just don't like the workflow

bright sentinel
#

Yeah that's fair, I was just trying to dig into the why

#

Not trying to attack your workflow 😅

dull copper
#

oh I'm sure my workflow is total crap too 😄

bright sentinel
#

Personally I completely disagree with your reasons, but to each his own 🙂