#archived-dots
1 messages Β· Page 81 of 1
i like his blog images. totally random, but nice
there are some notes at the top of the EntityComponentStore which are quite interesting: Rework internal storage so that structural changes are blittable (and burst job). Soon add/remove might be fast enough to not be an issue. I also saw a post on the forums by Joachim saying We have landed necessary changes for entitycommandbuffers to be burstable in 19.3.. So yeah, i am pretty excited about the prospect.
with blob data being immutable does this also mean from potential editor changes in the future ie when we eventually have tools to modify ecs data in play mode?
Thanks guys! I will be sticking to the enum as I won't have much more than 50 entities that uses them
I am trying to work out factions for my targeting system, and I am struggling because my initial thought was to use a single Faction component, and then inside of that have the entities faction, along with a list of enemy factions (probably use int). Now obviously I can't use list or array, so I am reading about dynamic buffers.. does this work in this situation used in IcomponentData? Or do I need to go with a bit type system like layermasks? I know I will need list type functionality at some point as I am converting, like my <StatusEffects> for example I will also run into this same problem. Any input would be very much appreciated, thank you.
i wrote a C++ version of unity ECS
mostly to test performance qualities
add/remove components is a fairly expensive operation, but not as expensive as you would think
its basically just doing 2N memcopy, where N is the number of components of your entitiy
one thing that IS important, is that you could batch it so it moves a bunch of entities at a time from 1 block to another block. That could be a faster scenario than doing it individually
i wonder if thats what they are doing
but btw, on the add/remove, i had a culling system that worked by adding/removing "Culled" components
and doing that tens of thousands of times a frame was no issue
even hundred thousand
So is the best aim to add a MyFaction component, then multiple EnemyFaction components?
instead of one EnemyFaction with multiple values inside
for factions you likely want separated components
you could use templates
not sure if C# does it well, but i did it once in C++ with sutff like
Faction<Faction_RED>
as component
Well you could have an interface of type <T> that the component can implement
// If you really need this
struct Faction : IComponentData, IFaction<Red> { }
I didn't realize we could even implement more than just IComponentData
Yep, they're just interfaces, so you can implement multiple interfaces
Good to know, I think I will try that path. Thank you guys very much. I only started learning programming 6 months ago, and after spending all that time focusing on OOP I am now realizing I want to get ahead of the curve with ECS.
yeah that would work like a charm
It seems wrong to me for an individual unit entity to refer to enemy factions, which is what it sounds like you're thinking of.
With data-oriented design such as ECS, I think it would be more 'correct' to store faction info, including diplomacy (friendly/neutral/hostile) in one central location, but I'm not sure what the best way would be.
Could be an entity with a FactionInfoComponent ("the" faction entity), I guess, or maybe just some static (pure) helper functions if you were confident you could do that without incurring a boatload of technical depth.
At any rate, a faction would (in my mind) look something like this:
- Faction ID
- Array/list of key-value pairs of faction IDs and diplomacy status (HashMap/dictionary type structure? Would also allow for non-mutual statuses)
That or just masks for each faction pair.
Point is, you're supposed to avoid duplicating data, and unless an individual unit can freely change which factions it likes and hates, that data belongs elsewhere, or you get duplication.
Well it can, in a sense because there is mind control capability in the game, and an ability to make enemy units taunt to have its own unit attack. And I felt as though at that placement the faction ID would need to switch, to then be targeted by the new correct faction. Which is really as you said just changing the ID. I agree with maybe holding it all in another location altogether.
The array/list thing was my original question. Eventually I feel as though I will need to use a group of data while working with components. I started to read on dynamic buffer but took a break due to frustration
DynamicBuffers are like stretchy arrays
The can grow but not shrink ya?
You can "shrink" them by doing a Clear()
I do believe there is a RemoveAt() function call
You have RemoveAt(...) and RemoveRange(...)
You have to call TrimExcess() to shrink the capacity.
@coarse turtle RemoveAt doesn't shrink
It just copies all data above removed index one index lower
Ah that makes sense, I haven't used a dynamic buffer for resizing often
At least that's how it works for Lists, should be the same though
So your indexes get re-arranged anyway, you would need to rebuild the references at that point right? Which then why not just replace the entire thing? Is it garbage reasons?
Heap allocations and GC are extremely costly in unity
So instead of re-assigning we should try to always to remove, shrink, then relocate the indexes essentially?
Now that I've thought a bit more about it, I think the ECS way to do it, or something close to that anyway, is to:
- Each unit hold one bit of faction info: The ID or a reference to which one it belongs to.
- In the system where you need to know about diplomatic statuses, you first run a job that iterates all entities FactionInfo and use that to compile either a 'diplomacy matrix' or some other data structure which holds the relevant info (who wants to attack who)
- Said data is then sent into/used by the other job(s).
If you want mind control or another temporary alignment switch (enraged - attacks everything?) you could add a componentTemporaryFactionor something like that. You'd need to have two separate jobs or loops, though, one which does only affects HAS Faction AND NOT Temporaryfaction, and another which requires both.
Permanent faction switches a la WOLOLO can just switch the faction ID/reference, though.
@tawdry tree I think I understand that for the most part, but I guess another thought is that I am not just using this system for a unit to find a target, but also a projectile to find if its hit a target. Which in some cases, if directly told, a unit will target its own faction (think of denying in dota, not a mind control example)... In this case now I have a isFriendlyFire bool that needs to be flagged, seperate from this matrix?
Or should I split the jobs up entirely?
I am thinking even if I split it, I would still want to use the same quadrant system I am working with, but maybe even a sub quadrant system because projectile hitboxes are much smaller
Is it temporary or permanent?
I am not sure I get what you mean. Like say a reward is involved in a unit dying to the faction that kills it. So instead of letting a enemy faction land the last hit, you yourself take a unit of your faction and intentionally target it. This projectile has my faction, but with a system in place searching through my quadrant I shouldn't see my own unit as a target. So I would need a flag on this projectile that is friendly. The entity projectile is destroyed once it hits the target regardless
I guess I am asking if you think I would include all of this information in the faction matrix you proposed, or if an entirely different system would check just for isFriendlyTarget bool type flag
So DOTA style friendly unit killing?
Yes
So lets say I have a faction system referring to static class feeding what it should target, that's all working correct. I am trying to plan out should I also use this same quadrant targeting system for all projectiles, as I do finding targets, or should I create a separate job that essentially does the same thing on a much smaller quadrant system for just projectiles. This system would also be checking for the isFriendlyTarget bool
That would be temporary for the unit, but not for the projectile. Doesn't make much sense for a projectile to change allegiance mid-flight, and the only reason for it to have any reference to a faction at all would be because friendly-fire mechanics
So essentially, if you tell your unit to attack a friendly unit, it will spawn projectiles which belong a 'No faction' faction, aka hostile to everything, possibly including it's own faction.
I think it would be the same faction as the parent
Thinking about analytical data such as kill count for parent entities or damage recaps you would need to know this at some point
Again, doesn't make sense for a projectile to have a faction aside from friendly-fire stuff, so if it is supposed to do friendly fire, then it might as well be set as none.
If it's for data reasons, then I'd add a SourceFaction component or field.
Probably a separate component, to separate concerns
As for the unit, I'd probably make a special order (however you code those) that explicitly overrides the normal faction check on looking for targets, so it'd be more in the field of you AI systems.
Which would again, shoot projectiles with the FactionComponent set to 'hostile to all', and, as per usual add the SourceFactionComponent referring to the unit's faction.
As an added bonus, you get units which don't give a shit about friendly fire for free - just give them a flag or something which causes all projectiles to switch to that faction. Alternatively, the enemy could mess with your IFF or something to make projectile switch to their team.
Okay. I have been having trouble separating AddComponent logic vs a value or field in a component. Like the targeting quadrant system is saying [RequireComponentTag(typeof(Target)] [ExcludeComponent(typeof(HasTarget))] vs down the line saying with the information I already have if (quadrantData.quadrantEntity.thisFaction == faction.myFaction && !offensive.isFriendlyFire) continue;
Try to think about it from a data perspective - does this data belong in this component?
That's a good start, but as with all patterns and rules of thumb, the second thing to ask is 'and would that be the best way to do things in my case?'
Right
I am thinking that data should have never gotten that far down the line
It should have been caught before that search was happening
In this case, 'where' does the first and second of those code blocks happen?
Where in the flow, and which systems?
First code block in this example is happening in FindTargetQuadrantSystem which is a IJobForEachWithEntity using burst. The second is in that job each quadrant FindTarget() method for the hasmapkey building.
Also, it's wayyy past midnight for me and I'm pretty tired, so I should really go to bed. Like, yesterday π
private void FindTarget(int hashMapKey, float3 searcherPosition, QuadrantEntity quadrantEntity, ref Entity closestTargetEntity, ref float closestTargetDistance, ref Offensive offensive, ref Faction faction)
{
QuadrantData quadrantData;
NativeMultiHashMapIterator<int> nativeMultiHashMapIterator;
if (quadrantMultiHashMap.TryGetFirstValue(hashMapKey, out quadrantData, out nativeMultiHashMapIterator))
{
do
{
if (quadrantEntity.typeEnum != quadrantData.quadrantEntity.typeEnum)
{
if (quadrantData.quadrantEntity.thisFaction == faction.myFaction && !offensive.isFriendlyFire) continue;```
That pasted ugly, sorry.
You can add cs or csharp after the backticks to get C# code highlighting. The word must be on the same line, and must immediately be followed by a linebreak, no spaces or tabs
Also, I find it better to replace tabs with two spaces when sharing code on Discord, for readability
What's a quadrant in this case?
A quadrant is a hashmap. Just splits the map up into squares so instead of searching through 1000 units, I search through the ones in my square or neighboring squares.
Well more like 10,000 units but same concept
//Some example
public static void Main(params string[] args){
Console.WriteLine("Hello, world!");
}
/*Written as:
'''csharp
(code stuff)
'''
if the single-quotes were backticks*/
I see
π
Anyway, if you have to run I understand, you have done more than enough already. I feel more confident with each conversation I have been having. I normally stay away from forum posting or discord for questions, but this has been very productive.
If I understand correctly, FindTarget here takes in those inputs and basically picks a target for a unit?
It actually builds an group of targets in that quadrant. Another job is actually looking through this data and finding the real target
Right, so that one basically narrows the search range to make things a bit more sane to work with?
Yes
Then it sounds to me like it's this job, the first(?) one that should filter on friend or foe if relevant
That, or a new, intermediate one, whose sole purpose would be to just do that filtering
But I feel like that would be more trouble than it's worth
Meaning FindTarget here would need to know which quadrant the unit is in, and it's faction, of course. Said faction could be the actual faction (usually would be) or from a TemporaryFactionComponent if the unit has a confusion or mind contorl type debuff. (in addition to the other data it would need accessible)
But it shouldn't even get to that point if it has a specifc order, because said order would already have given it a target
Uhm, does that leave any of your questions unanswered?
I think it answers a good amount. I will need to test things out and see where to cut things as I progress through so I am only looking for exactly whatβs needed at the right places.
Well, it sounds like you at least have an idea of where to go or what to do to find answers π
A tip when working with systems and jobs and asking for help or input is to explain what each system, job, and even parts of jobs (if they do multiple things) in a short manner, since other people don't have your code -and understanding of it- What systems do, and how data changes throughout the flow can greatly affect what is and isn't a good idea.
For example, my understanding of your (relevant) code is as follows:
You have one or more systems with two jobs. Their purpose is to give units their targets.
The first job does initial, coarse filtering on units _potential_ targets.
The second takes this subset and finds out which exact target to choose.
Of course, this is just what I gleaned from talking to you, and it's not always easy to explain what does what and why and how, but if it's really hard, that in itself might be a sign of code smell, that you've done something in a way that is perhaps not the best one.
Good luck!
Thank you again, for that advise and the previous advice @tawdry tree
has anyone got 2019.3a10 working with packages?
Hi, anyone got anything against using unity Mecanim in ecs context, apart from having to configure states non-programatically?
I don't suppose anyone knows why I'm getting an error warning "The NativeArray has been deallocated, it is not allowed to access it", with this code
((public NativeArray<Entity> temppeoplearray;// = new NativeArray<Entity>(numbofPeople, Allocator.Temp);
public NativeList<Entity> temptemppeoplelist;
[RequireComponentTag(typeof(Business))]
private struct AssignEmployeesJob : IJobForEach_B<EmployeeEntitysArray>
{
//public NativeArray<Entity> temppeoplearrayinjob;
public NativeList<Entity> temppeoplelistinjob;
public void Execute(DynamicBuffer<EmployeeEntitysArray> currentbuffer)
{
for (int i = 0; i < currentbuffer.Length; i ++)
{
currentbuffer.Add(temppeoplelistinjob[i]);
}
}
}
protected override void OnUpdate()
{
Entities.WithAllReadOnly<Person>().ForEach((Entity currentent) =>
{
temptemppeoplelist.Add(currentent);
});
//temppeoplearray = new NativeArray<Entity>(temptemppeoplelist.Length, Allocator.Temp);
//temppeoplearray = temptemppeoplelist.AsArray();
temppeoplearray = new NativeArray<Entity>(10, Allocator.TempJob);
AssignEmployeesJob currentAssignEmployeesjob = new AssignEmployeesJob
{
//temppeoplearrayinjob = temppeoplearray,
temppeoplelistinjob = temptemppeoplelist
};
JobHandle currentjobhandle = currentAssignEmployeesjob.Schedule(this);
currentjobhandle.Complete();
temptemppeoplelist.Dispose();
temppeoplearray.Dispose();
}
}```
Is it because it's automatically disposed after the job? Which part of your code gets the error?
I cant really tell to be honest the error isnt clear on that
Its something to do with the nativelist, I can pass nativearray fine but nativelist I get that error
@pliant pike can't help but think you're making life hard for yourself with those names but at any rate, I can't see where temptemppeoplelist is initialised?
I even cast it to a nativearray and I get the same error
Doesn't it have a callstack?
yeah I know my variable naming scheme is terrible
to see more info, make sure you've enabled Jobs->Leak detection-> Full stack traces
wait I think you simply never create the list?
Wait yeah, you don't instantiate the list in that code
yeah your right
That's a bit of a facepalm moment...
Been there, done that.
thanks
π
ahh finally got the joints looking passable for my dots ragdoll setup https://gfycat.com/vibrantlimpingfrog
oh wow... this must be first package I've found that exists on regular registry but not on staging https://bintray.com/unity/unity/com.unity.physics/0.2.0-preview
staging only has 0.1.0-preview
looks nice @safe lintel
thanks, doing joint stuff without being able to visualize the joints in edit mode is painful
@minor sapphire also interested - any chance you got things up and running?
Is there a way around having to call SetComponent every time you make a change to it?
I am assuming that you can to certain things like Translation, but any custom IComponentData no
π yea, think you're right - seems RenderPipeline has changed to something else
@winter depot it's very common to set them using ComponentSystem's or JobComponentSystems - you request the IComponentData's you're interested in and then do e.g. myComponent = new MyComponent(){ Value = updatedVal; }
because it's all structs, the new is fine
Nvm I can just do myComponent.value++; I had no idea that would work
@minor sapphire , @amber flicker is this to do with the hdpipeline and hybridrenderer?
@safe lintel its seems the new render pipeline core is required in the new Alpha, but the latest entities and hybrid don't like the new render pipeline core.
@minor sapphire RP core has always been a requirement
but you should never install it yourself unless you work with github or custom packages
same goes with SG
these are automatically installed via package dependencies
@minor sapphire or you mean the hybrid not working without SRP?
anyway, I've fixed the latest entities and hybrid to work with HDRP from github master
there were bunch of small changes due to HDRP leaving experimental + some other minor things
I dunno for sure, but when I upgraded from 2019.2b6 to 2019.3a10 I had to upgrade rp packages. I saw the update buttons on core rp and lwrp so updates to 7.0
Entities and hybrid did not like that though lol
Too damn hard to figure out what goes with what
Was really keen to retest performance now that the main thread utilisation bug has been fixed.
if DOTS packages were on github, I could just share the fixes via forks
it feels like Unity doesn't want that to happen tho (put DOTS packs to github)
I mean, on a public repo
I've nagged enough of that already
I tried to get staff response on the forums, it got plenty of views and comments but all staffers just ignored it
I even tagged Joachim to it π
they must have a some stance/agreement they don't comment this topic publicly
Hi all, this is my first post here π I've spent about 10 hours building with DOTS... I have a high level question:
Is it possible to create parent-child relationships with entities?
ex: An object or entity parent contains several child entities. When the parent rotates, the children move relative to the parent.
Thanks!
yeah on the child add Parent and ParentToLocal
that's a huge relief to hear π
system will then auto add all the children entities as a child buffer on the parent entity
mmhmmm ok - thank you for the tip @safe lintel
Does anyone have any idea how to disable light on an object in script light.enabled seems depreciated in 2019 unity
also the Entities package documentation has tons of info on the transform system and how it works
@lament orbit
@safe lintel cool - using the key words you provided i was able to dig up the docs on Transforms which seems to contain the info here:
@lament orbit take a look at the pinned message
ooo nice list of links, thanks!
I want to manually schedule a job from some MonoBehaviour Update function and pass some variables (non static) to it, but I also want to process entity component data with that job. What would be the best way to do that?
i guess just get the entity manager with entitymanager = World.Active.EntityManager; and query the componentdata with it for your job, not sure if theres anything special to just doing it
how would I do that? EntityManager is a class, so I suppose I can't query the components from inside the job
cache entitymanager from start or awake and pass in data to your jobs on creation of the job
I mean, how do I query the components? I think that's all I need
and should I query every frame or can I 'store' them when caching the manager?
what type of query? theres stuff thats exclusive to componentsystems and jobcomponentsystems that you would miss with a mb
at the start of the monobehaviour, I create an array of entities and add a single component to them
I'd like to access an array of said components so I could change their values from inside a IJobParallelFor
I need to feed some more data to this job
any reason you dont want to use a componentsystem? i dont know how dependencies for jobs/systems work if you schedule them from monobehaviours and want to access componentdata that other systems may also want to access
from what I've seen I can't feed additional data to the ComponentSystem, unlike the simple ParallelFor job
not sure by what you mean from that, my only use cases for favoring a monobehaviour for logic is stuff like event callbacks
public struct NotesJob : IJobParallelFor {
[ReadOnly] public Matrix4x4 parent;
[ReadOnly] public float time;
[ReadOnly] public float beat;
public void Execute(int i){
// (...)
}
}
monobehaviour:
private void Update() {
var job = new NotesJob(){
parent = transform.localToWorldMatrix,
time = currentTime,
beat = currentBeat,
};
}
none of the variables being passed to the job are static, and I don't think I can do that with ComponentSystems
if there's a way to do that then I'd definitely switch over tho
If you want to process entity component data, I'm assuming you want to set data of an entity within a job?
You can use an EntityCommandBuffer in your job if you'd like to set the entity data
Entities also supports childing entities, though, I've barely used it so I can't speak much about it π€
yeah if you know what components an entity has already, you can just use ecbs or the entity manager, but ComponentDataFromEntity is very handy if you are not sure if an entity has a component but afaik its only useable from job/componentsystems
actually im just not sure at all about entity + job usage in non componentsystems situations the more i think about it
same, the only way I can think of it is using a ecb to do the work π€ but that's only like a few cases
not saying it cant be done but my knowledge is just lacking π
lol same, I'm sure there's a way to do it with memset
Wish I could fork it, there are so many places where I need api changes
I dunno if this is supposed to be some joke or something https://forum.unity.com/threads/benchmarking-burst-against-gcc-machine-code-fibonacci-mandelbrot-nbody-and-others.715133
I truly don't get the point of the whole thing
it's like he's trying to get bad results from burst by using it wrong
raytracer had stuff like this:
I mean, if you don't want to get gains from Burst, sure, redo all math and hope for the best but it totally beats the purpose of doing any perf comparisons...
his mandelbrot had regular for loops etc
Dunno about the exact code, but from what I can see those are hardly bad results against GCC machine code with all optimizations. Some are very close, none have a bigger than 1-to-3 difference.
3rd comment already has optimization suggestions, though
So yeah π
well, proper DOTS code would jobify this and run it on all hw threads
for-for-for-while
yeesh
if you get like 2x faster results with Burst vs with Mono, you do something very wrong
That's some nesting. If nothing else, breaking it up should make it a lot more readable and maintainable.
intresting
it doesn't seem malicious but it really isn't using burst well
I bet it would run a lot faster if it used all of the math namespace everywhere
should also run it on 4/8 cores
just to see how nicely it slices up that work
Should stay single core to stay a valid comparison, but using the Mathematics package would be a good move
totally
saying it should be 1 + mult core of some sort
to be able to pickup the slicing per core
I'd love to see a benchmark on the overhead of using Jobs on small data sets
not using all cores is not really fair either
DOTS is built for that stuff
it makes no sense comparing it otherwise
benchmarks should give people indication of what kind of perf they are getting with alternative x
this isn't doing that
Btw, just to sanity check. Is there any way to check if an ArchetypeChunk contains a given Component?
And with that I mean a Component like Transform or Rigidbody
NOT the IComponentData type of components
i dunno about using all cores is a better indication
it's not like the work itself is faster, it's just spread over multiple workers
i think total ticks with one core is easier for comparison
@stiff skiff I don't think a ComponentObject is part of the Archetype (though I could be wrong) - more that it is associated with an entity... so you need to use e.g. EntityManager.HasComponent<blah>(entity) is my understanding
ComponentObjects are part of the Archetype
regarding games, if you're using all cores that doesn't necessarily mean you're saving ticks, those other cores can't be used for other things while they're doing that one job
There is the ComponentSystemBase.GetArchetypeChunkComponentType<T>() combined with the ArchetypeChunk.Has<T>(ArchetypeChunkComponentType<T> type)
However, for some odd reason the Has restricts T to struct, IComponentData
While GetArchetypeChunkComponentType does not
There is an ArchetypeChunk.GetComponentObjects<T>(ArchetypeChunkComponentType<T> componentType, EntityManager manager) Which will allow me to actually get the ComponentObjects for that chunk
However using this function on a chunk that does not contain the type, will give garbage data (not even a crash or warning, just garbage)
the issue with doing comparisons that don't fully utilize system x is that people who casually stumble to these comparisons actually think that's all you get from that system
it's like beating the whole purpose of these new systems that let you write performant code easier
what I meant by not part of the archetype is that 'a true'? archetype describes the layout in memory - obviously managed components can't be part of that and although some of the syntax is the same, I think all the mb's sit in a big list in managed memory and when you add a component object to an entity it's essentially adding an int to index into that.. maybe? I remember reading something about this once but struggling to find anything about it now. This means a chunk isn't broken by having many different Rigidbodys associated but also that it doesn't know on the chunk level that it has that 'type'? Obviously they could make an API that iterates GetComponentObjects for you but my guess is they don't to be explicit about it not having the same cost as IComponentData has calls? Please step in if anyone knows more or has relevant doc links - just sharing my understanding which could be flawed.
You are correct
The storage for the Reference to the actual component is in a large object[]
Which is indexed using offsets stored on the Archetype
However the archetype still does know about the type
as it's a ComponentType still in the list
It's just that the data is stored in the managed array, instead of the chunks
The problem I'm having, is that the currently API implementation, doesn't let me check if the ArchetypeChunk (Not to be confused with the Chunk actually containing component data) contains a ComponentObject type
Even through its perfectly capable of doing so
Could well be an oversight with the API - worth making a forum post perhaps?
And I've not been able to find a way around this
Would be nice to have a Github for these issues, since the Forum isn't always read
I suspect the forum is more carefully read than it may appear sometimes π
@stiff skiff
you could get the archetype from the chunk and iterate throught the posseded component types to see if there is your component object type
ArchetypeChunk chunk;
var comps = chunk.Archetype.GetComponentTypes();
for (var i = 0; i != comps.Length; i++)
{
if (comps[i] == ComponentType.ReadWrite<Transform>())
{
// ...
}
}
True, basically a reimplementation of Has for this might do
@elder wharf Thanks, might try this π
π
While I'm at it. Does anyone here use CreateArchetypeChunkArray on a query with with a SharedComponentData filter?
I've noticed that doing the filtering by hand, over setting the filter on the query, is a good bit faster. And I was wondering if anyone else had tried this.
I was actually just about to... good to know
file a bug if you can easily repro?
Also... I'm looking for something like myEntityQuery.HasMatch() - I can use CalculateLength() but that's overkill and there's IsEmptyIgnoreFilter but sometimes this is true even when the length is zero
It might just be due to my rather small entity count do note
When you don't use the filter, it does a single job to gather the chunks
But when you DO use the filter: it does a job, waits for completion, do some main thread code to count chunks, do a job to combined filtered results`
I'm guessing that the overhead of doing a job, might negate its usefulness due to my small entity count. Which is made worse with the filtering requiring 2 jobs. However that is just a guess
@amber flicker best bet is probably to take a look at ComponentChunkIterator.cs >> CalculateLength() and copy/paste it and return as soon any match is found.
Anyone know of a way to get their modifications compiled as Unity internal so that they can exist beside the default packages but still have internal access?
@mint iron I don't think thats possible without altering Unity's package
I've been using Reflection where I've needed something like this
When should I use IJobForEach and IJobParallelFor?
i guess situations when your data isnt necessarily tied to an entity archetype at that time
Another thing, I want to spawn a grid. Should a create a single job that iterates over the grid or multiple jobs for each grid unit?
I'm not sure how to link all them
protected override JobHandle OnUpdate(JobHandle inputDependencies)
{
EntityCommandBuffer.Concurrent entityCommandBuffer = _entityCommandBufferSystem.CreateCommandBuffer().ToConcurrent();
for (int i = 0; i < CellData.RowCount; i++)
{
for (int j = 0; j < CellData.LineCount; j++)
{
var job = new InstantiateJob
{
X = i,
Y = j,
EntityCommandBuffer = entityCommandBuffer
}.Schedule(this, inputDependencies);
}
}
return ???;
}
What should I return?
could you do your loop inside the job itself?
not saying you cant do this but i think there may be overhead in scheduling so many jobs
Single Job is better. If you use IJobParalellFor you can use the concurrent accessor for ECB
also you return the job handle so
var handle = job.Schedule(this, inputDepencencies);
return handle;
There's also a batch API if you have 100K+ levels of spawning to do
But what if I want to instantiate 50k instances?
you taken a look at the samples repo on github?
Yup, I know what to return when it is a single job
oh you mean for your array?
I just didn't know what to return if I wanted multiples
If it's 10K spawns or more, you probably want to use EntityManager's Batch Creation functions
Yeah, I have to learn collections as well lol
I want to have a grid of entities
Right now I will spawn less than 1k just for testing
But I want to eventually reach ludicrous ammounts
Yeah I'd look at NativeArray and the like.
There's no specific multidimensional array but you can either do NativeArray with math to access it like a grid, or you can use NativeMultiHashMap if you have a sparser grid with denser points
It just plain wont work with Jobs/Burst.
Under the hood, the NativeContainers are all NativeArrays<T> at the engine level. Everything else is a C# wrapper to access the memory in different ways, such as a Hash table or List.
NativeContainers don't have support for NativeArray<NativeArray<T>> since the programmer is responsible for memory management, you'd run into problems with tracking down leaks with the manual memory management. So it's not allowed.
The recommended approach is to use math to navigate an array with grid coordinates.
Ok
Another simple question. How do I pass the array from the InstantiateSystem to the UpdateSystem? Through an entity with a GridArray component?
Still trying to get my mind into ECS
You probably want to have an Entity that represents the grid itself and look into using Dynamic Buffers
While it's possible to pass NativeContainers between Systems, it's tricky to get correct and can introduce issues with the safety system/thread ordering.
Most of us started using DynamicBuffers for problems like this once they were implemented
The recommended approach is use NativeContainers for System-specific acceleration structures (flatten data to NativeArray for blitzing operations if able, filter data with NativeList, Queue events with NativeQueue for another stage to process, NativeHashMap and NativeMultiHashMap for key-value operations) and Use DynamicBuffers or certain types of Component Data as markers to pass data between systems.
The best part of this (which is called Existance-Based Processing) is that if the data doesn't exist, the system doesn't run at all.
You can actually have systems that restrict running to only when certain components exist on Entities, if no Entities have that component, the system won't run at all.
Even systems that don't have the requirement will do less work if they have empty queries.
Here's the package docs for Dynamic Buffers: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/dynamic_buffers.html
How do I make the system run only one time?
And thanks for the info. I will take a look into it
there's a flag that Enabled that you can turn off after the first run
another recommended alternative is create an entity that marks a generation request, and delete it after running Generation
theres like almost zero editor experience for dots, seems premature for feedback π
Is this more about Tiny? The only real non-tiny ecs editor thingy is the entity debugger, right?
halp I must be retarded, I keep trying on different projects to enable ECS & Jobs however I keep getting errors with empty projects
I have tried 700 version combinations with all different packages
:L
I'm running unity 2019.3.0a10
Empty project->add ECS?
If you get the error at that point, try restarting Unity. I've had a few weird errors that needed restarts.
@opaque aurora those errors are specifically related to a10 - use a8
no problem! tis annoying! good luck π
They might have moved UnityEngine.Experimental.Rendering out of Experimental?
for HDRP on recent 2019.3 / 7.x, yes
here we go again lmao
HDRP is about to release along with 2019.3 so it needs to get out of experimental
@opaque aurora why not a10?
oh you are rolling back
ye
i haven't been using unity for a while so i have no idea how to edit the packages myself
but yeah, probably easier to just roll back at this point unless you really want to use the bleeding edge HDRP
π yes i need my cubes to look gorgeous
EntityQueryBuilder, if this is missing my particular combination of types, I cant get it to regenerate can i π¦
It has the F_EBCCC but no combination of F_BDDC
You can do
F_EB for the time being and just grab the component via EntityManager
Maybe there's a way to create your own delegate that the fluent api can accept via extension functions π€
anyone know if when joachim mentioned light conversion in the next update he meant a native dots light component? i havent tried anything with lights so not sure if they werent getting injected etc
probably hybrid
part of the entity renderer
I'm sure its getting a good jump in functionality
I'm excited for the new ecs version
been a long time since the last one so it should be a big change again
there weren't any major changes during hackweek
they leaked the DOTS master and unity physics master on some repo
unity physics 0.2 was mostly what they had there by then
this was probably most notable thing: Allow structural changes to entities (add/remove components, add/destroy entities, etc.) while inside of `ForEach` lambda functions. This negates the need for using `PostUpdateCommands` inside of ForEach.
i implemented that feature in my ECS
its NOT a easy feature to add in an archetype ECS
mine barely woks
but its a huge deal
@dull copper you already did the whole survey thing?
nice job with the comprehensive links π @dull copper
@coarse turtle it was lazy copy paste from the post I did here π
@vagrant surge nah, I don't want to get involved with Unity's planning that much
Lol, touche
you'd have to do webinars with them
how come? @dull copper
We are scheduling 1-hour web conference interviews between July 30th and August 1st. If you are interested in being part of this study, please fill out this brief survey.
because of the video interview part right?
ah web interview, well, I dunno if it's different from webinar
webinar is for masses right? π
yeah, something like that
yeah if they want webcam nope
I don't have against that in particular, it just feels like a thing that will take bit longer time than one would hope
plus there are more experienced users that really should take part of that thing :p
by that I mean, more experienced in DOTS specifically
yeah thats what I was thinking
I dont feel that qualified to talk about it even though I've been using it every day the past year
my scope is limited on it though
you've actually used the thing extensively, that's just the kind of people they want
I've solved some hard to do in ecs things but it seems like they want general tiny devs
the people just poking the editor to try dots stuff
I dont really like the tiny approach or at least the stigma around how they are turning that into dots mode
I hate that too
they are doing everything fast, except moving the editor to dots
I'd want both GO's and entities in the same session
exactly what we have now
they can be separated but not some "you get one but not other"
they could easily do DOTS view on the hierarchy even now
but instead they want to do a funky hybrid editor (which always works well)
yep
I would love that
the entity debugger is a godsend
if we didnt have that we would be fucked
but can we get more than that please?
just anything
I suggested toggle that people could use to swap sides if the editor for both modes at once would be too much for them
but I really meant like thing you can just toggle any moment
to see dots side or gameobjects
so, you should definitely participate and convince Unity they should do that ;D
I did say yes but

the domain reload dumping all types for a short time really pisses me off
will just freeze the game in a error state every build of the game, I'm not sure if its related to dots or not. but it stated recently after I updated all my packages and unity version
2019.3?
2019.1.10f1
ah, it's not related to the new feat then
boggles the mind since this is the 'stable' version
2019.3 got this now: Editor: Domain reload and / or scene reload could be disabled when entering play mode to allow faster iteration times in the editor.
yeah wanted to try that actually
but I can't move this game too much yet
trying to prep for early access so I'm trying to minify all the bugs
think I'm going to port to 2019.2 + hdrp this week though
HDRP vr support is finally 75% there (the few effects not supported are not deal breakers anymore)
any idea on how the dots renderer works with hdrp?
you mean the hybrid? megacity is using it with HDRP
I have that setup on my project but I barely render things on ECS side
same, I just dont want to be locked out of porting to it in the future
I did forget that megacity was hdrp
thats my bad
I was thinking of trying to do some destruction with the dots physics, for that it would make sense to just render it all on hybrid renderer but will see how that goes in practice
that being able to disable domain reload thing is a godsend considering theres no hotreloading with dots
really does improve time to enter play mode, at least with a smaller project
@dull copper
How should one handle scene switching when using hybrid ECS?
Oh nvm! Works like a charm (so far :P)
NativeArray<Entity> e = World.Active.EntityManager.GetAllEntities(Allocator.TempJob);
World.Active.EntityManager.DestroyEntity(e);
SceneManager.LoadScene("Level", LoadSceneMode.Single);
e.Dispose();
you can dispose the entities before switching scenes if you like
I prefer the scenes not killing my entities as my core networking is in them
this doesn't look like an ECS question
all good π put it in General Code π
Fair enough @low tangle!
this is probably a really stupid question, but do I really need to remove a key before trying to change its value (i.e TryAdd again) on a NativeHashMap?
or is there an easier way to change values?
I have a kind of basic how do people figure out how to even use some of this stuff?
I'm trying to figure out how to use EntityQuery.CopyFromComponentDataArray and there's just a vague description in the docs with no example
so I barely have a clue for how to format it exactly and where I can use it
its the older way of grabbing data to iterate over, if you are using it you usually have exhausted
other ways or need to setup a job in one way
what exactly do you need it for @pliant pike
I need to get two separate sets of entities into a jobcomponentsystem
I'm trying to adding some entities into another group of entities dynamicbuffers
I use the IjobforeachwithEntity_EBC method
so a query, is it conditional or just all of that query go into a certain buffer on a certain entity?
then I'm trying to get the other set using the entity query system
its conditional I'm going to do a check if first before adding
you likely just need to chain two jobs, build a array in the first job, then use said array in second job to add
ok thanks I'll try that
how do people figure out how to even use some of this stuff?
It often comes down to reading the source code in the package or finding an example on the forums/github π¦
yeah or just trial and error I guess,
Do anyone know how can translate entiry from default world to new world?
I Know i should use entitymanager.MoveEntitiesFrom
But i done understand what is NativeArray<EntityRemapUtility.EntityRemapInfo> entityRemapping and how can i use it?
Out of curiosity. is it possible to convert speed trees to ECS? And if so - would that even be worth the effort is able?
if able*
yeah it would, but also not
unity took the single model approach for LOD with mega city and it wasn't a massive jump
they had to move to HLOD at the chunk level
which isn't exactly what speed tree is meant for
Ah okay, I suppose that makes sense. I was just trying to think of ways I can make my real-time dynamic culling system even more efficient. So far 500,000+ speed trees loaded and still in the 50's on FPS lol.
@gusty comet https://shaderbits.com/blog/octahedral-impostors/
It is finally time to release the first version of the Impostor Baker tool! This is currently uploaded to github since I could not get access to the ue4 community server:
https://github.com/ictusbrucks/ImpostorBaker
Notes:
Currently for UE4.19 only. I have a 4.18 version th...
theres a couple of implementations in unity as well. I'm planning on including this with my games sdk and internally for skinned meshes at a distance
Interesting ready, despite not being able to use this in my game as it's all procedurally generated in real time. But it does definitely give me some ideas on things I can try. Thanks mate.
I really hope this is a simple question - having link to Entity (got it from Entities.ForEach) how can I access components on that entity that I know is there and I just want to edit some values in it (I can't use Entities.ForEach to get access to them in my case) ?
one way is to use ComponentDataFromEntity
hmm, either I am doing it wrong, or I can't modify values it returns
do use it in hybrid ECS, but I did not expect this complication
basically I am trying to sort out collision system, from what I understand I can't use colliders, at least with Hybrid ECS (I might be wrong), so good old check distance between objects is fine. Only problem is, that Entities.ForEach inside another Entities.ForEach kills all point of ECS (and I am trying to check collision between few thousands of bullets and around hundred of enemies). So far approach to first run enemies Entities.ForEach to save result in local list and then use that local list in bullets Entities.ForEach works fine, except now I don't have access to enemies health and all I can do is just destroy them (Entities reference worked fine, while all my component references are read only, so I can check if enemy have health, but I can't make it smaller).
While I can change my logic around all enemies just having 1 health, this approach looks not that practical and there must be a better solution for this.
@Burve#5008 unity physics has colliders.
in any case my question is - how can I edit component data of the Entity, that is not current in Entities.ForEach ?
in hybrid ECS
I can always go evil way - first cache data I want to edit in local variable, then run Entities.ForEach on data that might edit cached data and then run Entities.ForEach or cached data and compare what I got cached with what Entities.ForEach returned and do corrections what is needed, but that is evil
burve I barely no what I'm doing but perhaps the EntityQuery system and use ToComponentDataArray
its a copy so you have to copy it back using CopyfromComponentDataArray
I havent figured out how to get that part to work yet though so if you figure it out let me know
I am pretty sure my evil approach will work, texting that now
yeah I'm thinking of doing it the manual way, I did it before in a componentsystem just iterate and add a bunch of components to a nativelist then convert to nativearray and then use that
silly me, I guess 30C inside is getting to me (it is way too hot :() - I was saving data in first iteration wrongly, now when I save it in to a temp class, I can edit it fine and all works like a magic π
so what I did was - in OnUpdate() I first iterated my first list (enemies) using Entities.ForEach and saved all data from that in to my custom list that have a temp class. Then I iterated my second Entities.ForEach (bullets) and in each bullet test I used my previously saved list as enemy references, where I edited enemies health and all now works fine
all this talk was helpful, thx π
hmm, there is some strange issues, I think edited health is not saving back to original entities, but that are minor details now π
and evil plan finished it
Attach component.. seems to have gone away? trying to setup a parent / child transform relationship.. anyone point me in the right direction plz?
give it a parent component and a localtoparent
ok i've got that, child seems to vanish .. hrm .. thx
what does it show in the entity debugger?
show entity 0 (parent) has a child (entity 1) , and entity 1 shows it has a parent 0
i might be noobing this up...
trying to make an invisible parent, and a child with a renderer
are you setting the parent component to a specific entity?
i don't think so. the parent should be top level. I'm setting the child to have a parent of the parent entity - at least this is my intention π
got it
i think there may have been a system in the 'Unity Samples' that may have been complicating things
thanks @safe lintel for looking
was just about to test but if its working its working π
Sup guys i have some questions about ecs shared components, but already explained on the forums hehe
I dont suppose anyone has a any idea for how I should register the inputdeps correctly in this job
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var peepcomps = peoplequery.ToComponentDataArray<PersonEntityInfo>(Allocator.TempJob, out JobHandle peephandle);
var peoples = peoplequery.ToEntityArray(Allocator.TempJob, out JobHandle peoplhandle);
JobHandle.CombineDependencies(peephandle, peoplhandle).Complete();
AssignEmployeesJob jobber = new AssignEmployeesJob()
{
personworkplaceref = peepcomps,
dudes = peoples
};
peoplequery.CopyFromComponentDataArray(peepcomps);
peepcomps.Dispose();
peoples.Dispose();
numofcycles++;
if (numofcycles == 1)
{
this.Enabled = false;
}
return jobber.ScheduleSingle(this, inputDeps);
}
}```
I'm getting an error where a nativearray has been deallocated All containers must be valid when scheduling a job
its the personworkplaceref that I'm getting that error with and its caused by the dispose methods
Hello great people, I have a question. How can I put particle system or trail renderer in an entity?
Help, help, help
π
You don't have ECS versions of those, so you'll need to either implement it yourself (ouch!) or make a system which moves them to the the relevant entity. Alternatively, you could use a hybrid gameobject entity.
Hybrid gameObject Entity?
I'm not sure what the way do do it right now is, but essentially, you put ECS components on a gameobject, Unity does some magic, and the gameobject becomes a wrapper of sorts for an entity.
Here's an old forum thread: https://forum.unity.com/threads/keeping-entity-and-gameobject-in-sync.524237/
Here's documentation for the GameObjectEntity class: https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.GameObjectEntity.html
At least previously you would make a monohebaviour which was a wrapper for an ECS component do to something but I've never done that and can't recall if that was to make a gameobject entity or something else.
Hopefully someone else will see this and can give you a better/more complete answer.
Alright, Thank you π
@mint gust DOTS physics samples just set ref to entity ID and poll it then on each update:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsExamples/Assets/Common/Scripts/EntityTracker.cs
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsExamples/Assets/Common/Scripts/EntitySender.cs
this isn't very robust solution, I got hard crash on IL2CPP with this when the entity didn't exist yet and it ran that thing
there are ways to fix that but it's bit hacky anyway
Alright I'll try that
Thank you
i keep checking the package manager for that fabled entities update
Same here
I spent the whole weekend trying to solve that jobsystem above and I get home now and solved it in 5 minutes 
took me way more than a weekend to grasp ecs and jobs π
well I'm not saying I've grasped ecs in general no where near just solved that particular code problem above
well when things finally click its nice π
yeah and annoying after so much time, I just had to basically create sync points and call jobhandle.complete on certain bits of code
i really like ECS though, the great thing about it is I need to build more entities of different types, and that jobcomponentsystem will just work with them, without me needing to do anything(as long as they have the right components)
I start to mess around with ecs in 2019.1 and the entities dont seem to be rendering and all the correct components are attached eg RenderMesh, Translation, Rotation & Scale. I've used ecs previously in 2018.3, do I need to enable the hybrid render in a settings menu in 2019.1?
is there a localtoworld component as well?
No Is that a new requirement?
yeah
Thanks
Transform is added via conversion API, so LocalToWorld, Translation, Rotation, and Non/UniformScale is added when the gameObject is converted
is this also the channel to ask questions about the job system?
yeah
Thanks. I've been following a tutorial and for some reason the job doesn't seem to be running on multiple workers and I'm not sure why or where to start looking to solve this. The tutorial shows a profiler with this function being worked on in all worker threads.
what does the code look like?
it's an JobComponentSystem with a IJobForEachWithEntity job
Im not exactly sure which parts of the code would be helpful to show
this is what it should be looking like, though
you had it working at one point?
no, this last image is from the video tutorial
cant really diagnose anything from a profiler screenshot tbh
Post the scheduling code?
Don't JobComponentSystems sort of schedule themselves?
my mistake, this is in the OnUpdate for the JobComponentSystem
JobHandle jobHandle = findTargetJob.Schedule(this,inputDeps);
You're correct in that unity handles scheduling by itself, so it's sorta difficult to mess it up, that's why I was asking.
But yea, that's not really conclusive. With just that i'm unsure.
You type .schedule somewhere usually @vale stream
Hopefully it's not .schedulesingle for example.
I found the reason why it was only using one thread. I simply didnt have enough entities spawned it seems.
if I only spawn 100 entities, it only uses 1 worker thread, but if I spawn 1000, it uses all 6
But because I was only seeing 1 thread and expected to see more, I was worried that I had written some code wrong π
ty for all the input, though!
only one chunk :)
take a look at the entity debugger and see how many entities per chunk (for that archtype)
this part of the UI? I'm new to ECS, jobs and DOTS in general and I haven't heard the term chunks before
@vale stream Yes that's correct. https://rams3s.github.io/blog/2019-01-09-ecs-deep-dive/#chunks This is some helpful reading
Ty π
Is there a latest take on ecs for documentation? not touched for a few months and was basically watching tutorials and converting normal mono stuff
@full stirrup https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/index.html like so?
new packages on regular registry
they bumped everything to 0.1.0-preview now
kinda bummed that they don't put these on staging anymore, as you can't easily use some things from staging and others from regular registry
well in case anyone here wondered... 0.1.0-previews are not 2019.3 ready for HDRP (concerns people who use Hybrid with HDRP and 2019.3)
so if you need that, manual package modifications are still needed due to HDRP namespace change (it's leaving experimental)
interesting rename of Concurrent to ParallelWriter for queues - was hoping for the burst compatible ECB's but not yet I guess?
## [Hybrid Renderer 0.1.0-preview] - 2019-07-30
### New Features
* New `GameObjectConversionSettings` class that we are using to help manage the various and growing settings that can tune a GameObject conversion.
* New ability to convert and export Assets, which is initially needed for Tiny.
* Assets are discovered via `DeclareReferencedAsset` in the `GameObjectConversionDeclareObjectsGroup` phase and can then be converted by a System during normal conversion phases.
* Assets can be marked for export and assigned a guid via `GameObjectConversionSystem.GetGuidForAssetExport`. During the System `GameObjectExportGroup` phase, the converted assets can be exported via `TryCreateAssetExportWriter`.
* `GetPrimaryEntity`, `HasPrimaryEntity`, and the new `TryGetPrimaryEntity` all now work on `UnityEngine.Object` instead of `GameObject` so that they can also query against Unity Assets.
### Upgrade guide
* Various GameObject conversion-related methods now receive a `GameObjectConversionSettings` object rather than a set of misc config params.
* `GameObjectConversionSettings` has implicit constructors for common parameters such as `World`, so much existing code will likely just work.
* Otherwise construct a `GameObjectConversionSettings`, configure it with the parameters you used previously, and send it in.
* `GameObjectConversionSystem`: `AddLinkedEntityGroup` is now `DeclareLinkedEntityGroup` (should auto-upgrade).
* The System group `GameObjectConversionDeclarePrefabsGroup` is now `GameObjectConversionDeclareObjectsGroup`. This cannot auto-upgrade but a global find&replace will fix it.
* `GameObjectConversionUtility.ConversionFlags.None` is gone, use 0 instead.```
## [Entities 0.1.0-preview] - 2019-07-30
### New Features
* Added the `#UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP_RUNTIME_WORLD` and `#UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP_EDITOR_WORLD` defines which respectively can be used to disable runtime and editor default world generation. Defining `#UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP` will still disable all default world generation.
* Allow structural changes to entities (add/remove components, add/destroy entities, etc.) while inside of `ForEach` lambda functions. This negates the need for using `PostUpdateCommands` inside of ForEach.
* `EntityCommandBuffer` has some additional methods for adding components based on `ComponentType`, or for adding empty components of a certain type (`<T>`)
* EntityManagerDiffer & EntityManagerPatcher provides highly optimized diffing & patching functionality. It is used in the editor for providing scene conversion live link.
* Added support for `EntityManager.MoveEntitiesFrom` with managed arrays (Object Components).
* EntityManager.SetArchetype lets you change an entity to a specific archetype. Removing & adding the necessary components with default values. System state components are not allowed to be removed with this method, it throws an exception to avoid accidental system state removal. (Used in incremental live link conversion it made conversion from 100ms -> 40ms for 1000 changed game objects)
* Entity Debugger's system list now has a string filter field. This makes it easier to find a system by name when you have a lot of systems.
* Added IComponentData type `Asset` that will be used by Tiny to convert Editor assets to runtime assets
* Filled in some `<T>` holes in the overloads we provide in `EntityManager`
* New `Entities.WithIncludeAll()` that will include in matching all components that are normally ignored by default (currently `Prefab` and `Disabled`)
* EntityManager.CopyAndReplaceEntitiesFrom has been added it can be used to store & restore a backup of the world for the purposes of general purpose simulation rollback.
* EntityManager.AddComponentData<T>(EntityQuery entityQuery, NativeArray<T> componentArray) has been added. This can be used to efficiently add components to an entityQuery and set the component data on each entity.
### Upgrade guide
* WorldDiff has been removed. It has been replaced by EntityManagerDiff & EntityManagerPatch.
* Renamed `EntityGroupManager` to `EntityQueryManager`.```
### Changes
* EntityArchetype.GetComponentTypes no longer includes Entity in the list of components (it is implied). Behaviour now matches the EntityMangager.GetComponentTypes method. This matches the behavior of the corresponding `EntityManager` function.
* `EntityCommandBuffer.AddComponent(Entity, ComponentType)` no longer fails if the target entity already has the specified component.
### Fixes
* Entity Inspector now shows DynamicBuffer elements in pages of five at a time
* Resources folder renamed to Styles so as not to add editor assets to built player
* `EntityQueryBuilder.ShallowEquals` (used from `Entities.ForEach`) no longer boxes and allocs GC
* Improved error message for unnecessary/invalid `UpdateBefore` and `UpdateAfter`
* Fixed leak in BlobBuilder.CreateBlobAssetReference
* ComponentSystems are now properly preserved when running the UnityLinker. Note this requires 19.3a10 to work correctly. If your project is not yet using 19.3 you can workaround the issue using the link.xml file. https://docs.unity3d.com/Manual//IL2CPP-BytecodeStripping.html
* Types that trigger an exception in the TypeManager won't prevent other types from initializing properly.```
/ spam
Allow structural changes to entities (add/remove components, add/destroy entities, etc.) while inside of `ForEach` lambda functions. This negates the need for using `PostUpdateCommands` inside of ForEach. commenting again, but this is very big, and quite hard to implement
PSA - latest packages only run on < 2019.3 or >= 2019.3.a10 - also.. time to change all OnCreateManagers over to OnCreate
well, it's funny that Entities package would want a10
but hybrid breaks on a10
I just manually fixed the hybrid again
but it's like 40 lines you need to change
@dull copper where do you see those release notes at?
@vestal hatch when you install the packages, you can browse the packages at projects Library/PackageCache, each package usually has CHANGELOG.md
ooh thats where you found it
that makes a lot of sense
I checked the documentation page for them but that changelog lags apparently
well, there's also link on the package manager to same file
"view changelog"
for me it opens the changelog from local file
I'm getting this warning now π OnDestroyManager in Unity.Physics.Extensions.MousePickSystem is obsolete and shall be renamed to OnDestroy. This message will be (RemovedAfter 2019-10-22) and OnDestroyManager will no longer be called
I mean, that's oddly specific
after 22nd of October, this thing ceases to work
so remove Manager from all the systems
well, I have old mouse picker on this project from old physics samples
surprised they didn't just run the unity update on them
they probably updated it already on DOTS samples
OnCreateManager should be renamed as well I assume?
yup
that unity dots testing interview is in a few hours 
unity dots testing interview?
gl
50 OnCreateManagers replaced with OnCreate
@vestal hatch Unity asked for DOTS users to give them feedback, they had like survey on the site and then they contacted select (?) people from those to do like 1h web interviews on the topic
theres more? to it I guess
oh interesting
nda already
could be
I hope you get access to their internal DOTS repo
to make that worthwhile π
that would be really intresting
pretty painless update to 2019.2 + dots update
always feels nice when it goes off without a hitch
no big changes for DOTS samples:
# Samples Version 30
To view the changelog for a package, go to **Package Manager** and click on **View changelog** or open the respective `CHANGELOG.md` file inside the package folder.
## Changes
* Improved documentation for the Boids Sample
* Updated API to correspond to the latest package APIs
yeah I skimmed the source on a handful, didnt look like any important changes
I want jobified ecbs 
I didn't even know boids had any documentation :p
I mean it had that one video on it
the one with the brick background
guy explained how it worked and the whys really well
trying to find it, found this gem
Joachim and Martin hold an open chat about Unity's new systems and the changes ahead. This talk also showcases some of the latest additions to the Entity Com...
remember watching this when it came out
found it
https://youtu.be/p65Yt20pw0g
March 23, 1:00pm (San Francisco) - Mike Acton demonstrates best practices for component design to achieve a high degree of parallelism, minimum synchronizati...
@dull copper
this explains the boids demo very very well
well, I remember one thing from that talk
it's that Acton is scary AF π
that poor guy asking something on Q&A
I liked his talk on DOD at the CPP conference way more, this one was kinda vague
@thick carbon ooh you could share that one?
Whoops
hah
http://www.cppcon.org -- Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2014 -- The t...
So thats the CPPCon talk lol
thank you :)
there are some slides to a code review he's done that's really popular as well
Yeah, I think he reviewed Ogre 3D
Are there any performance implications in adding and removing components in a single frame?
Marker components for example
https://www.youtube.com/watch?v=yy8jQgmhbAU there's also one from Stoyan Nikolov
http://CppCon.org β Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2018 β For decades...
thanks for more stuffs
I really want to get this converted into a pdf for my kindle to read sometime
Data-Oriented Design
lots of wonderful stuff in it
@low tangle I mean.... https://www.amazon.com/dp/1916478700
@boreal glade I think this is what you might be looking for, im not sure if Marker components are tag components like what 5argon spoke abt: https://gametorrahod.com/tag-component/
hey guys, I'm kinda new and looking at ECS, how ready is it at the time for messing around with for semi-serious projects?
ah the dod book, that's where I first learned about bloom filters are a plausble data structure in my game π
@coarse turtle Thanks! I'll check that out
my whole game core is built on it, but is heavily hybrid objects for physics and rendering (but driven from ecs)
I don't know much, but if I am correct, didn't the new update introduce physics for pure ecs?
I messed with something very simple in ECS quite some time ago, a year or two I think
not sure how long ECS has been around for in unity π
it was revealed in 2016 from what I recall
yeah but didn't get super useful till almost exactly a year ago
jobs was out then though
Yea
are there any good example projects out there?
not that I know of
A lot of them are dated
Some still use dependency injection which is long gone, Id say the best example so far is probably the entitycomponentsystemsamples on github
thanks, I'll check it out
@coarse turtle That resource was exactly what I needed. Thanks so much!
@amber flicker i dont appear to be having problems with the latest stuff on 2019.1
unless some of the packages are not showing in this, but so far upgraded to 0.1.0 without a hitch
converted light is nice
aw no light probe group conversion, figured it wouldnt but was hoping for a surprise
Ah I gotta play around with the converted lights
yeah baking lighting is still in progress
Ah looks like the new packages dropped
grateful for the update but im kinda surprised they didnt mention the new system has support for light conversion/new light system
wondering what other hidden new features are there
someone needs to do a diff and give us all the juicy details.
o so NativeQueue.ToConcurrent() is deprecated
We have AsParallelWriter instead
Pretty cool they give a removal date in the warning
@safe lintel yea so 2019.1 & 2019.2 are ok but if you're on 2019.3, make sure you're on the latest
is there a way to get Euler angles back from quaternion (from Unity Mathematics) or there is some way I missed how can I edit Entity Rotation after it is created (and , hopefully, not doing that directly with quaternion values) ?
afaik not with any of the official functions
you can use the rotationXYZ (or any ZYX YXZ etc) components to override the roation component as described in the transform system(which is how I went about it)
right now I used my component to set how much to rotate on every frame, and I saved in it my current rotation in degrees, so I just force new quaternion when I do update, but having ability to read value back would be nice
I tried formula that convert it from quaternion to euler, but that destroyed all performance π¦
so far ECS is fun, but feels like reinventing the wheel at every step π
its the good kind of reinventing though
where by remaking it, you are making it into a super simple easy to grasp problem
where your solution is just, look at the data, do something to it
@dull copper interview thing over, I like what they got going. I hope my feedback helps them out
is there a framerate limit put on the 2019.3, it seems like my frame rate has dropped in it
what things did they want feedback about specifically(if you are willing)?
nda thingy
ah ok
Ooo new package? Can someone paste changelog or something, currently at work.
Thanks June
hmm i guess this isnt the update that allows for fully burstable entitycommandbuffers π¦
hmm am i expecting too much with this amount of light instantiation? https://gfycat.com/officialillfatedkatydid
@safe lintel look how much garbage!
do you get similar performance in a build?
I wonder if it's related to profiling in any way?
I would say your expectations of it being 'better than that' are pretty reasonable lol
it was better in build but still slowed down, i didnt profile it though but probably similar
wait, each particle emits it's own light?
that's going to be slow
like, that's expected
surely that's not enough lights to cause that much slow down ....
hundred moving pointlights?
if you're using forward rendering all those lights are going to increase draw calls significantly
If I'm using the ConvertUtility to create a entitiyPrefab, is that prefab bound to the world, or can it be used to create entities in all worlds?
i'm getting lots of crashes and regressions on latest release π¦
it says in the latest docs you can add/remove components in a job now without postupdate commands, I'm guessing its still using the entitycommandbuffer system?
I dont suppose anyone has seen an example for how you do that?
just for ForEach lambdas I think right?
yeah I guess that but you need something like an EntityManager to add them
postupdatecommands is just for mainthread ComponentSystems so I assume EntityManager just replaces it there
for jobs its still EntityCommandBuffers
yeah the commandbuffer does have a straight addcomponent method
so I guess I've just got to figure out how to pass the commandbuffer into the job
get the barrier system
EndFrameSystem = World.Active.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
then pass that into the job on creation of it
var job = new MyJob{ EntityCommandBuffer = EndFrameSystem.CreateCommandBuffer() } var handle = job.Schedule(this, inputdeps);
also have to add a handle to the barrier system
EndFrameSystem.AddJobHandleForProducer(handle);
that's great, thanks
is pure ECS an option at this point or is hybrid a better approach right now?
pure ecs is an option, but its kind of difficult and missing lots of things, I doubt you could make a full game with it currently, but its fine to mess around with
I'm switching to Unity and I really like the data oriented approach, but not sure how to start with it or if it's even a good idea
there's not really any downside to learning it, I'm liking it a lot more than oop
oh i get it regarding my lights, im just creating new gameobject lights that are pooled, its not quite native ecs
To add to this, it seems to me like Unity wants to make the DOTS stack (Burst, jobs, ECS, maybe something I forgot?) the 'default mode' to make games.
Just... not in a long while (at least 2 years) since the features aren't there yet.
Pretty much
Nah
Entitas style linking gameobjects to entities
and that way people can start doing ecs systems in their unity games right now
it'll take even longer for the majority of developers to move over to using ECs as well
No reason not to learn it, though; it's a great addition to your toolbox. As for concrete examples, jobs can (and arguably should, in many cases) be used without the other DOTS parts to get parallelism pretty easily, and are out of preview status, and the ECS way to do things can be super useful for certain games, genres, mechanics, ECS. And normally useful to in many more cases.
They want to ditch game objects
it seems like the new add component system is working well if I'm doing it correctly
struct AssignUnemployedCompJob : IJobForEachWithEntity<PersonEntityInfo>
{
public EntityCommandBuffer commandsBuffer;
public void Execute(Entity currentent, int index, [ReadOnly] ref PersonEntityInfo currentcomp)
{
if(currentcomp.WorkPlaceEntityRef == Entity.Null)
{
commandsBuffer.AddComponent<Unemployed>(currentent);
}
}
}```
it doesn't work multithreaded though
although it took only 3.22 miliseconds to iterate through 6000 entity's and add the component to 1000
I get the error " AssignUnemployedCompJob.Data.commandsBuffer is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type."
so I guess you can't use the commandbuffer to write in multithreaded code?
Have you tried declaring it ReadOnly? The attribute should only actually apply to the buffer itself, not it's fields and methods.
Ie:
[ReadOnly]public EntityCommandBuffer readOnlyEcb;
public EntityCommandBuffer ecb;
public void SomeMethod(){
//Acceptable:
ecb.DoThing();
ecb.variable = "foo";
ecb = GetNewECB();
readOnlyEcb.DoThing();
readOnlyEcb.variable = "foo";
//Not acceptable:
readOnlyEcb = GetNewECB(); //Should give an error like 'can't write to readonly ...'
}
@pliant pike thats oddly slow
3 ms for 1000 entity updates is very very very slow
should be 0.3 and that would even be slow
hmm I haven burst it yet though
So that's singlethreaded 6k entities with 1k updates? What kind of computer do you run? You can't really say that anything is fast or slow, for all we know you could be running on a laptop from '05 or a gaming superrig.
I'm on a 2700x
so do I need to pass two buffers to the job @tawdry tree because I get the error "The native container has been declared as [ReadOnly] in the job, but you are writing to it." when declaring the buffer readonly
So it makes the internals readonly too, huh. I just know that usually readonly just means that specific field/variable, but I suppose the attribute tells the ECS system (the underlying ones, not your system) that all writing to it and its internals is forbidden.
yeah its weird
anyone used the livelink? is it supposed to be in editor stuff or something? because it doesnt appear to do anything for me
Ah what's live link? Ive been curious about it but I've been pretty busy this week to find info abt it
@pliant pike your first version was correct, you just needed to use the concurrent interface from the ECB
not sure but it defaults to disabled
setting it doesnt appear to do anything for me so not sure if you need to use it from somewhere else or if its just not actually enabled yet
awesome that works, thanks @low tangle
For a general rule, will IJobChunk be always faster than IJobForEach?
So I tried Burst and a job went from over 725ms down to 15ms is that good?
I dont think Burst works with ECBs currently I just get a typeface error when trying
you can use burst with creation and destruction of entities but not yet with add/remove components
did they refresh their docs? https://docs.unity3d.com/Packages/com.unity.entities@0.1
I don't remember this many images there
nice, thats definitely new
- I think the organization is different
@minor sapphire I forgot to follow the job forum thread, did they already release a fix?
(I have a horrible memory)
Probably updated docs when they updated to the (latest) 0.1.0-preview version, which was yesterday
I haven't had that many systems at the same time, since I've been doing fairly basic testing and getting used to stuff, not making a more complex game, but Entity Debugger's system list now has a string filter field. This makes it easier to find a system by name when you have a lot of systems. already seems quite useful.
I hope they are going to have tabs for the entity list like they do the dynamicbuffers, I'm going to need it or some better ways to organise and view all the enity's
Yea, filtering on types was good for the time being, but the pagination looks quite nice
Any users of the EntityQuery.CreateArchetypeChunkArray(NativeArray, JobHandle) API here?
Specifically, using this with a query that has a filter
I was wondering if you also have some performance issues with this
@dull copper Alpha 10 introduced the main thread utilisation fix. I haven't actually gotten through all other errors to retest it yet though lol.
Oh actually I made a test project for it with code in the forum. I'll try that project when I get home in like 10 hours heh.
ah, nice
After upgrading packages, what is the best way to ensure 'upgrade bugs' don't happen... I want a clean reimport of the packages. What folder should I delete?
Library might be the folder to delete @minor sapphire
Or maybe just Library/PackageCache at the bare minimum
now the burst package loads
it's 2019.3 verified package now
## [Burst 1.1.2] - 2019-07-26
- Fix an issue where non-readonly static variable would not fail in burst while they are not supported
- Fix issue with char comparison against an integer. Add partial support for C# char type
- Improve codegen for struct layout with simple explicit layout
- Fix NullReferenceException when using a static variable with a generic declaring type
- Fix issue with `stackalloc` not clearing the allocated stack memory as it is done in .NET CLR```
still waiting for deterministic fp support^^

Main thread utilisation looking good in a10
unfortunately I can't get my actual project working with all the latest stuff π
when I start unity:
Then stupid assertion errors when I add component with bulk overload where at least one archetype already matches
argh so frustrated
then there's the whole 'bloom stopped working' when I updated lol
urp has different pp now
yeah, i was using shader graph shaders and replacing materials for the property block settings but after the update they're all broken.
@minor sapphire
also add component with bulk overload doesn't do anything special, it just wraps a for loop. π¦
@dull copper different pp?
@mint iron makes me wonder why I don't see forum posts about it then, hard to figure out what's different about my project...
@minor sapphire URP comes with it's own dedicated PP now, similar thing as with HDRP
postprocessing package does nothing on it when using 2019.3 afaik
(PR's indicated they replaced the PP fully)
basically you add regular volume to the scene where you can add these effects
no more pp volumes or pp layers
ohhhhh jeez ok I better go look this up
why is the Post Processing package still a dependency of the LWRP then... π
probably because upgrade path
does urp itself still have it?
ah, it does not
so the PP dependency is probably there so people don't get errors when they open their old project
once the LWRP ref is actually swapped to universal, PP dependency is lost
ok, lets try again
universal is just a 'core' that HDRP and LWRP will reference? or is universal a replacement for LWRP or something??
there's no LWRP anymore on 2019.3, it's just empty shell that moves people to use URP
and URP is just renamed LWRP
so the reason LWRP exists on 2019.3 is just so people can upgrade their old projects gracefully
should I be referencing both of these packages or only one??
you should just ref to universal package if you've gotten rid of the old PP stuff already
pretty sure LWRP will be fully removed soon
there hasn't been any public posts about this
I just know these as follow SRP repo PR's closely and have talked briefly about URP with Unity staff
I expect some blog post once 2019.3 gets to betas and URP matures a bit
it's probably quite broken after such big changes for a while
so makes no sense on promoting it yet
right, ok I'm gonna remove LWRP and see what happens lol
(especially since LWRP came out of preview just on 2019.1)
ok I found this
got most of it working
in terms of rendering anyway lol
now just have to figure out the PP
I suppose I'll look for some HDRP PP videos or something if it's similar
argh they called the script just 'volume' I was looking for at least the word 'post' lol
ok ok, well to be fair, when you said that I was completely lost and it went over my head π
just a shot in the dark but does anyone have a starting point for how to add explosive force to unity physics entities? thought id ask before i go randomly stabbing around in the physics example project.
I have kind of a basic(stupid?) question can you only have one Entity type and its components in an Ijobforeach<> job search?
I've tried putting 3 completely separate entity's which dont share any components into an Ijobforeach job but I cant get it to work
@pliant pike IJobForEach is working on a query typically right? That query can pick up different archetypes as long as all the archetypes match the query.
I'm not sure about how to manually pull in 3 separate entities
right I figured it would just put them all in the list
not something I've had to think about, but you could iterate over them in an IJobParallelFor if you have them in an entity array or something
struct CountUnemployedJob : IJobForEach<EventEntityinfo, GeneralCityInfo, Unemployed>```
thats 3 separate entity's that I tried to get to work
that will bring in all entities that have all 3 components by default
no it's going to look for entities that match all three
why not schedule one job for each of them?
the event and unemployed are both just tags and the event only exists after a spacebar press
they only really require one job, i'm trying to get an sort of entity event system to work
I haven't actually had a case for generics yet, but I wonder if they work here?
sorry not generics
I meant to say interfaces
it starts only when the evententityinfo is created and should stop when its destroyed
and counts the unemployed and writes that to generalcityinfo
that's what I'm trying to do anyway
@pliant pike I think youβre looking for ComponentDataFromEntity - pretty sure some of the docs have examples - these represent components that can be looked up by entity - each job only iterates over one chunk (archetype) at a time
ok thanks @amber flicker
its curious it doesn't give an error, or just carry on with the first chunk/ when putting to many in though
because it thinks you're trying to find entities that match all 3
CDFE might not be what you're after - it might just be a series of jobs, commandbuffers, nativequeues/hashmaps etc... bit hard to tell - sounds like you might benefit from looking around at a few more examples - in particular I think the forums have some event -related systems
yeah I guess there's no way for it to figure there all in different chunks
well.. it's partially that it wouldn't want to. All the entities of a certain archetype are all laid out next to each other in memory (essentially) - this is part of what makes jobs really fast - as you do a for loop over all the entities, they're all ready for you in the cpu
however sometimes you *need to go and fetch another bit of memory
that's basically what CDFE's are for
yeah I see what you mean
yeah i think timbocs right, you'd loop through entities with the component they all share IJobForEach<SomeCommonComponent> (or use an EntityQuery to do the prefilter) then check ComponentDataFromEntity.Exists() to see if each one in the loop has the additional data you need.
or do it in multiple jobs one for each combination of components
there's a IJobChunk version of the same idea, where you can check if the chunk has a component
I'll try it different ways and see whats better
another option is to pre-filter the whole system with RequireForUpdate and have multiple systems.
@pliant pike I think you might be putting to much into a single job
The spacebar check should just be a normal Input test in your system, which calls GetEntityCount on a query that matches on Unemployed
Then the result can be written into the singleton GeneralCityInfo component (I assume its a singleton?)
its a single entity, I've heard singletons are bad so try and stay away from them
On a side note, why store this info on an entity?
why not? where else would I store it
In a field on a system
oh well I do want to use that data on other things
You can always just run a GetExistingSystem<>.UnemployedCount
I see no reason to make an singleton style entity for storing data, outside of having the data serialize nicely with your world for saving and loading
I've found it very easy to use the ECS and its API in ways that aren't really performant
I guess not, if I just have a system then I know the data is always up to date
I believe the point is to not save said data on the system (which I don't think should have any data (on the class) if you go purist ECS philosophy)
yeah I think I understand
I do want to store the data later on though in a simple text file or something
@tawdry tree Agreed, but if performance isn't an issue, and there is no direct need to have something in ECS, beyond it being "the ECS way". Then why bother
i find it useful to be able to see the current values easily in the Entity Debugger, but it helps that im converting named prefabs mostly so its easy to find the singleton entities. If you had to look for Entity563 its not helpful.
A good reason to store it on an entity, if that is the requirement
But honestly I think the better way to store system-wide data, is to do it as variables. At least so far the data I've stored is cached archetypes and queries from startup, and I've mostly stored it statically.
i'm going back and forth on how best to handle configuration data π¦ I thought about building out scriptable objects, but i'd have to manually convert all the data into the entities equivalent and that is a pain. π¦ Just using addressable prefabs right now.
Configuration for what?
level data, game behaviors that need to be tweakable etc
You can try to store scriptables in blobs, but that still means you have to make an entity to hold the blob data, but i still find the authoring in Scriptables nice desprite the caveat
For sparse configuration (movement speed that differs per type of entity) we've been using ISharedComponentData, which are filled based on SO's
Though our usage of the ECS is a eccentric haha
https://forum.unity.com/threads/dynamic-entity-archetypes-using-scriptable-objects.547043/#post-3610572 This seems related
@stiff skiff I presume GetEntityCount isn't a built in method, so I'm not sure how I would build a job that takes in generic components
Instead of a job taking generic components you would end up making a helper function that takes a generic component and builds a query and job from that, wouldn't you?
maybe using delegates?
@pliant pike its a buildin method for 0.1.0
it was CalculateLength() before
^
thanks yeah I've found it now
Also, make sure you only use Jobs for logic that either: 1. you need the results of later. 2. runs over a large amount of data
The overhead of starting and waiting for a job to complete can quickly be more costly then doing some quick iterations on the main thread
(Looking at you EntityQuery.SetFilter...why do you be like this)
EntityQuery in off itself is a job isnt it
EntityQuery is just an accessor to kicking off some data collection or iteration
For example using CreateArchetypeChunkArray
which internally does a job, or 2 if you have a filter
yeah I mean when I do things like tocomponentdataarray or copyfromcomponentdata...
Yes, though I dont remember of the top of my head if those use jobs internally
And if they do, they would call job.Complete() internally
I had to do it manually when I used them
Just checked, they both use a job internally
or I had to make sure the dependancies were passed between them and the job
they have 2 versions. 1 calls complete internally, the other returns the job
I couldn't get the first version to work correctly without the handle
@mint iron there is the ApplyLinearImpulse from ComponentExtensions class
why did they go with GetEntityCount instead of just Count or Length?
didnt care for calculatelength either
well I was trying to find that when I looked in the web docs
I probably would have found it if it was called GetEntityCount
thnx @safe lintel ! i tried ApplyLinearImpulse but it wasn't having the dramatic effect i wanted for an explosion. It almost seems like the more power i added to it, the less impact it made, so something is going on there i don't understand.
For now it seems to be working great to set the PhysicsVelocity, which is pretty much the same as setting the initial velocity on the PhysicsBody monobehavior.
EntityManager.SetComponentData(child, new PhysicsVelocity
{
Angular = UnityEngine.Random.insideUnitSphere * UnityEngine.Random.Range(10f,40f),
Linear = UnityEngine.Random.insideUnitSphere * UnityEngine.Random.Range(10f,25f)
});
well it does factor in the mass when it applies a force, but other than that eh not sure why it would have the inverse effect you wanted
cool, if you use GetEntityCount it just shows them all in a list on the EntityDebugger on the jobsystem
@stiff skiff its recomended to not use SharedComponentData unless you really know what you are doing and need it on an algorithm level
it does not decrease memory usage, in fact it increases it
Shared components should never be used unless you have an algorithm that does chunk-wide logic with them. They are used to forcefully split entities into different blocks, and increase fragmentation a lot
Yes I know
We use a shared component to ensure the entities that have different logic to drive them, are split into different chunks on purpose
So when we iterate over the chunks there is no need to do a branch for the different logic on an entity level
But on chunk level instead
ah, ok then
thought you were commenting of just having different speed per chunk as shared comp, which is such a terrible thing to do
Its fine if the "speed" isnt just a number but a category
Question for the Job system people. What is the overhead of chaining jobs like?
I've been staring at the ComponentChunkIterator.CreateArchetypeChunkArray and am really wondering why the Filtered branch isn't doing the chunk counting a job
While the counting takes no time at all, it does force the main thread to wait on the parallel chunk gathering job, which feels wastefull
I dont know, it seems ok I think I have 5 jobs chained together into one Onupdate method I dont see much difference between using complete and adding the dependancy to the next job
then again maybe its not, I have about 250ms between some of the jobs
that seems like a lot
That sounds like a different issue
yeah I think its because its a run time issue
I hope you mean 0.250ms?
nope it is 250ms, I think its because the entitys dont exist between the jobs
the rest of the jobs its about 5ms max between them
I need to make sure the whole thing runs after I've created all the entity's
Chaining should be better than running .Complete() as that would create a synchronization point where a chain runs start-to-end. Not sure how big of an impact, but if you have jobs that should run sequentially, chaining is best practice.
Maybe I'll try making some alterations to the package to see if it works tomorrow
ok I've figured out how to get idle time down to 0.02ms between CopyfromComponentDataArray and the job
Currently it does an IJobParallelFor to gather all chunks with filtering, but then has a sync point and counts the resulting chunks per matching archetype on the main thread
before allocating a NativeArray of the right size, and using another IJobParallelFor to copy over the filtered chunks into the result array
But that means the entire first job and counting logic, stalls the main thread, which I want to try and avoid
you have to call complete on the CFCDA for it to work, but you dont have to do it before the job
is a jobcomponentsystem supposed to run on the main thread?
The OnUpdate part is, the Job prep Scheduling has to take place on the main thread for safety.
The Jobs themselves do not
one of mine seems to I couldn't find it in the list of workers that's because its in the main thread
I guess it does it if the main thread isn't doing much else?
What does AssignEmployeesJob do?
it adds entities into dynamic buffers
Really wondering what that looks like. 13 ms is a LOT of time
yeah its even longer without burst, I can post the code if you want
You run at about 1 fps?
I dont think that influences the framerate, if its running on a separate thread it shouldn't should it?