#archived-dots

1 messages Β· Page 81 of 1

hollow sorrel
#

also good read

cunning perch
#

i like his blog images. totally random, but nice

mint iron
#

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.

safe lintel
#

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?

safe gate
#

Thanks guys! I will be sticking to the enum as I won't have much more than 50 entities that uses them

winter depot
#

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.

vagrant surge
#

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

winter depot
#

So is the best aim to add a MyFaction component, then multiple EnemyFaction components?

#

instead of one EnemyFaction with multiple values inside

vagrant surge
#

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

coarse turtle
#

Well you could have an interface of type <T> that the component can implement

#
// If you really need this
struct Faction : IComponentData, IFaction<Red> { } 
winter depot
#

I didn't realize we could even implement more than just IComponentData

coarse turtle
#

Yep, they're just interfaces, so you can implement multiple interfaces

winter depot
#

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.

vagrant surge
#

yeah that would work like a charm

tawdry tree
#

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.

winter depot
#

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

coarse turtle
#

DynamicBuffers are like stretchy arrays

winter depot
#

The can grow but not shrink ya?

coarse turtle
#

You can "shrink" them by doing a Clear()

#

I do believe there is a RemoveAt() function call

#

You have RemoveAt(...) and RemoveRange(...)

untold night
#

You have to call TrimExcess() to shrink the capacity.

wooden pivot
#

@coarse turtle RemoveAt doesn't shrink

#

It just copies all data above removed index one index lower

coarse turtle
#

Ah that makes sense, I haven't used a dynamic buffer for resizing often

wooden pivot
#

At least that's how it works for Lists, should be the same though

winter depot
#

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?

wooden pivot
#

Heap allocations and GC are extremely costly in unity

winter depot
#

So instead of re-assigning we should try to always to remove, shrink, then relocate the indexes essentially?

tawdry tree
#

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 component TemporaryFaction or 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.
winter depot
#

@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

tawdry tree
#

Is it temporary or permanent?

winter depot
#

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

tawdry tree
#

So DOTA style friendly unit killing?

winter depot
#

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

tawdry tree
#

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.

winter depot
#

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

tawdry tree
#

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.

winter depot
#

I guess I could just reference it all in a parentEntity field

#

^

tawdry tree
#

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.

winter depot
#

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;

tawdry tree
#

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?'

winter depot
#

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

tawdry tree
#

In this case, 'where' does the first and second of those code blocks happen?

#

Where in the flow, and which systems?

winter depot
#

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.

tawdry tree
#

Also, it's wayyy past midnight for me and I'm pretty tired, so I should really go to bed. Like, yesterday πŸ˜›

winter depot
#
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.

tawdry tree
#

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?

winter depot
#

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

tawdry tree
#
//Some example
public static void Main(params string[] args){
  Console.WriteLine("Hello, world!");
}
/*Written as:
'''csharp
(code stuff)
'''
if the single-quotes were backticks*/
winter depot
#

I see

tawdry tree
#

πŸ‘

winter depot
#

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.

tawdry tree
#

If I understand correctly, FindTarget here takes in those inputs and basically picks a target for a unit?

winter depot
#

It actually builds an group of targets in that quadrant. Another job is actually looking through this data and finding the real target

tawdry tree
#

Right, so that one basically narrows the search range to make things a bit more sane to work with?

winter depot
#

Yes

tawdry tree
#

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?

winter depot
#

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.

tawdry tree
#

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!

winter depot
#

Thank you again, for that advise and the previous advice @tawdry tree

minor sapphire
#

has anyone got 2019.3a10 working with packages?

gusty comet
#

Hi, anyone got anything against using unity Mecanim in ecs context, apart from having to configure states non-programatically?

pliant pike
#

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();
    }    
}```
tawdry tree
#

Is it because it's automatically disposed after the job? Which part of your code gets the error?

pliant pike
#

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

amber flicker
#

@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?

pliant pike
#

I even cast it to a nativearray and I get the same error

tawdry tree
#

Doesn't it have a callstack?

pliant pike
#

yeah I know my variable naming scheme is terrible

amber flicker
#

to see more info, make sure you've enabled Jobs->Leak detection-> Full stack traces

#

wait I think you simply never create the list?

tawdry tree
#

Wait yeah, you don't instantiate the list in that code

pliant pike
#

yeah your right

tawdry tree
#

That's a bit of a facepalm moment...
Been there, done that.

pliant pike
#

thanks

amber flicker
#

πŸ‘

safe lintel
dull copper
#

staging only has 0.1.0-preview

coarse turtle
#

looks nice @safe lintel

safe lintel
#

thanks, doing joint stuff without being able to visualize the joints in edit mode is painful

amber flicker
#

@minor sapphire also interested - any chance you got things up and running?

winter depot
#

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

minor sapphire
#

No Timboc I didn't. I think we need an entities/hybrid update.

#

@amber flicker

amber flicker
#

πŸ‘ 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

winter depot
#

Nvm I can just do myComponent.value++; I had no idea that would work

safe lintel
#

@minor sapphire , @amber flicker is this to do with the hdpipeline and hybridrenderer?

minor sapphire
#

@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.

dull copper
#

@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

minor sapphire
#

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.

dull copper
#

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

low tangle
#

would love that

#

maybe one day

dull copper
#

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

lament orbit
#

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!

safe lintel
#

yeah on the child add Parent and ParentToLocal

lament orbit
#

that's a huge relief to hear πŸ˜ƒ

safe lintel
#

system will then auto add all the children entities as a child buffer on the parent entity

lament orbit
#

mmhmmm ok - thank you for the tip @safe lintel

fast tartan
#

Does anyone have any idea how to disable light on an object in script light.enabled seems depreciated in 2019 unity

safe lintel
#

also the Entities package documentation has tons of info on the transform system and how it works

#

@lament orbit

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:

safe gate
#

@lament orbit take a look at the pinned message

lament orbit
#

ooo nice list of links, thanks!

shut cosmos
#

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?

safe lintel
#

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

shut cosmos
#

how would I do that? EntityManager is a class, so I suppose I can't query the components from inside the job

safe lintel
#

cache entitymanager from start or awake and pass in data to your jobs on creation of the job

shut cosmos
#

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?

safe lintel
#

what type of query? theres stuff thats exclusive to componentsystems and jobcomponentsystems that you would miss with a mb

shut cosmos
#

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

safe lintel
#

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

shut cosmos
#

from what I've seen I can't feed additional data to the ComponentSystem, unlike the simple ParallelFor job

safe lintel
#

not sure by what you mean from that, my only use cases for favoring a monobehaviour for logic is stuff like event callbacks

shut cosmos
#
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

coarse turtle
#

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 πŸ€”

safe lintel
#

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

coarse turtle
#

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

safe lintel
#

not saying it cant be done but my knowledge is just lacking πŸ˜ƒ

coarse turtle
#

lol same, I'm sure there's a way to do it with memset

stiff skiff
#

Wish I could fork it, there are so many places where I need api changes

dull copper
#

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

#

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

tawdry tree
#

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 πŸ˜›

dull copper
#

well, proper DOTS code would jobify this and run it on all hw threads

tawdry tree
#

for-for-for-while
yeesh

dull copper
#

if you get like 2x faster results with Burst vs with Mono, you do something very wrong

tawdry tree
#

That's some nesting. If nothing else, breaking it up should make it a lot more readable and maintainable.

low tangle
#

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

stiff skiff
#

Should stay single core to stay a valid comparison, but using the Mathematics package would be a good move

low tangle
#

totally

#

saying it should be 1 + mult core of some sort

#

to be able to pickup the slicing per core

stiff skiff
#

I'd love to see a benchmark on the overhead of using Jobs on small data sets

dull copper
#

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

stiff skiff
#

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

hollow sorrel
#

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

amber flicker
#

@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

stiff skiff
#

ComponentObjects are part of the Archetype

hollow sorrel
#

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

stiff skiff
#

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)

dull copper
#

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

amber flicker
#

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.

stiff skiff
#

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

amber flicker
#

Could well be an oversight with the API - worth making a forum post perhaps?

stiff skiff
#

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

amber flicker
#

I suspect the forum is more carefully read than it may appear sometimes πŸ˜…

elder wharf
#

@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>())
    {
        // ...
    }
}
stiff skiff
#

True, basically a reimplementation of Has for this might do

#

@elder wharf Thanks, might try this πŸ˜‰

elder wharf
#

πŸ‘

stiff skiff
#

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.

amber flicker
#

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

stiff skiff
#

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

mint iron
#

@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?

stiff skiff
#

@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

safe gate
#

When should I use IJobForEach and IJobParallelFor?

safe lintel
#

i guess situations when your data isnt necessarily tied to an entity archetype at that time

safe gate
#

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?

safe lintel
#

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

safe gate
#

But this way ins't more performatic?

#

Just know that I know 0 about jobs

untold night
#

Single Job is better. If you use IJobParalellFor you can use the concurrent accessor for ECB

safe lintel
#

also you return the job handle so

var handle = job.Schedule(this, inputDepencencies);
return handle;
untold night
#

There's also a batch API if you have 100K+ levels of spawning to do

safe gate
#

But what if I want to instantiate 50k instances?

safe lintel
#

you taken a look at the samples repo on github?

safe gate
#

Yup, I know what to return when it is a single job

safe lintel
#

oh you mean for your array?

safe gate
#

I just didn't know what to return if I wanted multiples

untold night
#

If it's 10K spawns or more, you probably want to use EntityManager's Batch Creation functions

safe gate
#

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

untold night
#

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

safe gate
#

Every single position has an entity

#

Having a array<array>> is bad?

untold night
#

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.

safe gate
#

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

untold night
#

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.

safe gate
#

How do I make the system run only one time?

#

And thanks for the info. I will take a look into it

untold night
#

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

dull copper
safe lintel
#

theres like almost zero editor experience for dots, seems premature for feedback πŸ˜„

magic frigate
#

Is this more about Tiny? The only real non-tiny ecs editor thingy is the entity debugger, right?

opaque aurora
#

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

tawdry tree
#

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
#

yea empty project and add ECS gives me a error on the

#

Burstcompiler

amber flicker
#

@opaque aurora those errors are specifically related to a10 - use a8

opaque aurora
#

ahh

#

goddamn it ok, thanks alot

amber flicker
#

no problem! tis annoying! good luck πŸ˜ƒ

stiff skiff
#

They might have moved UnityEngine.Experimental.Rendering out of Experimental?

dull copper
#

for HDRP on recent 2019.3 / 7.x, yes

opaque aurora
dull copper
#

HDRP is about to release along with 2019.3 so it needs to get out of experimental

#

@opaque aurora why not a10?

opaque aurora
#

had these errors

#

on a10

dull copper
#

oh you are rolling back

opaque aurora
#

ye

dull copper
#

yeah, I'm aware of those

#

I manually fixed the packages

opaque aurora
#

i haven't been using unity for a while so i have no idea how to edit the packages myself

dull copper
#

but yeah, probably easier to just roll back at this point unless you really want to use the bleeding edge HDRP

opaque aurora
#

πŸ˜„ yes i need my cubes to look gorgeous

stiff skiff
#

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

coarse turtle
#

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 πŸ€”

safe lintel
#

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

dull copper
#

probably hybrid

low tangle
#

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

dull copper
#

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.

vagrant surge
#

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?

coarse turtle
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

coarse turtle
#

Lol, touche

dull copper
#

you'd have to do webinars with them

low tangle
#

how come? @dull copper

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.

low tangle
#

because of the video interview part right?

dull copper
#

ah web interview, well, I dunno if it's different from webinar

#

webinar is for masses right? πŸ˜„

low tangle
#

in the survey they mentioned skybe/something else

#

yeah

dull copper
#

yeah, something like that

low tangle
#

one to many

#

instead of few to few

dull copper
#

I don't even have a mic here

#

not to talk about webcam πŸ˜„

low tangle
#

yeah if they want webcam nope

dull copper
#

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

low tangle
#

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

dull copper
#

huh

#

you'd do great there

low tangle
#

my scope is limited on it though

dull copper
#

you've actually used the thing extensively, that's just the kind of people they want

low tangle
#

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

dull copper
#

I hate that too

low tangle
#

they are doing everything fast, except moving the editor to dots

dull copper
#

I'd want both GO's and entities in the same session

low tangle
#

exactly what we have now

dull copper
#

they can be separated but not some "you get one but not other"

low tangle
#

yep

#

because thats exactly how it works right now

dull copper
#

they could easily do DOTS view on the hierarchy even now

low tangle
#

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

dull copper
#

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

low tangle
#

I did say yes but

#

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

dull copper
#

2019.3?

low tangle
#

2019.1.10f1

dull copper
#

ah, it's not related to the new feat then

low tangle
#

boggles the mind since this is the 'stable' version

dull copper
#

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.

low tangle
#

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?

dull copper
#

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

low tangle
#

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

dull copper
#

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

safe lintel
#

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

low tangle
analog horizon
#

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();
low tangle
#

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

minor sapphire
#

this doesn't look like an ECS question

cursive void
#

oh mb

#

new to this

minor sapphire
#

all good πŸ˜ƒ put it in General Code πŸ˜ƒ

cursive void
#

wait

#

so what is this then

#

?

analog horizon
#

Fair enough @low tangle!

shut cosmos
#

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?

pliant pike
#

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

low tangle
#

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

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

low tangle
#

how are you finding the first set?

#

query?

pliant pike
#

I use the IjobforeachwithEntity_EBC method

low tangle
#

so a query, is it conditional or just all of that query go into a certain buffer on a certain entity?

pliant pike
#

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

low tangle
#

you likely just need to chain two jobs, build a array in the first job, then use said array in second job to add

pliant pike
#

ok thanks I'll try that

mint iron
#

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 😦

pliant pike
#

yeah or just trial and error I guess,

faint scarab
#

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?

gusty comet
#

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*

low tangle
#

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

gusty comet
#

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.

low tangle
#

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

gusty comet
#

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.

manic elbow
#

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) ?

safe lintel
#

one way is to use ComponentDataFromEntity

manic elbow
#

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.

minor sapphire
#

@Burve#5008 unity physics has colliders.

manic elbow
#

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

lament orbit
#

me learning DOTS

pliant pike
#

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

manic elbow
#

I am pretty sure my evil approach will work, texting that now

pliant pike
#

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

manic elbow
#

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

lament orbit
#

Attach component.. seems to have gone away? trying to setup a parent / child transform relationship.. anyone point me in the right direction plz?

safe lintel
#

give it a parent component and a localtoparent

lament orbit
#

ok i've got that, child seems to vanish .. hrm .. thx

safe lintel
#

what does it show in the entity debugger?

lament orbit
#

show entity 0 (parent) has a child (entity 1) , and entity 1 shows it has a parent 0

#

trying to make an invisible parent, and a child with a renderer

safe lintel
#

are you setting the parent component to a specific entity?

lament orbit
#

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

safe lintel
#

was just about to test but if its working its working πŸ˜ƒ

golden heron
#

Sup guys i have some questions about ecs shared components, but already explained on the forums hehe

pliant pike
#

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

mint gust
#

Hello great people, I have a question. How can I put particle system or trail renderer in an entity?

#

Help, help, help

#

πŸ˜„

tawdry tree
#

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.

mint gust
#

Hybrid gameObject Entity?

tawdry tree
#

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.

mint gust
#

How can you put ECS componenet on gameobject

#

sorry about all this questions :3

tawdry tree
#

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.

mint gust
#

Alright, Thank you πŸ˜„

dull copper
#

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

mint gust
#

Alright I'll try that

mint gust
#

Thank you

safe lintel
#

i keep checking the package manager for that fabled entities update

coarse turtle
#

Same here

hollow sorrel
#

might be a while

#

unity Time.timeScale = 0.1f

pliant pike
#

I spent the whole weekend trying to solve that jobsystem above and I get home now and solved it in 5 minutes leahA

safe lintel
#

took me way more than a weekend to grasp ecs and jobs πŸ˜„

pliant pike
#

well I'm not saying I've grasped ecs in general no where near just solved that particular code problem above

safe lintel
#

well when things finally click its nice πŸ˜ƒ

pliant pike
#

yeah and annoying after so much time, I just had to basically create sync points and call jobhandle.complete on certain bits of code

pliant pike
#

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)

half cedar
#

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?

pliant pike
#

is there a localtoworld component as well?

half cedar
#

No Is that a new requirement?

pliant pike
#

yeah

half cedar
#

Thanks

coarse turtle
#

Transform is added via conversion API, so LocalToWorld, Translation, Rotation, and Non/UniformScale is added when the gameObject is converted

vale stream
#

is this also the channel to ask questions about the job system?

safe lintel
#

yeah

vale stream
#

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.

safe lintel
#

what does the code look like?

vale stream
#

it's an JobComponentSystem with a IJobForEachWithEntity job
Im not exactly sure which parts of the code would be helpful to show

safe lintel
#

you had it working at one point?

vale stream
#

no, this last image is from the video tutorial

safe lintel
#

cant really diagnose anything from a profiler screenshot tbh

boreal glade
#

Post the scheduling code?

vale stream
#

Don't JobComponentSystems sort of schedule themselves?

vale stream
#

my mistake, this is in the OnUpdate for the JobComponentSystem
JobHandle jobHandle = findTargetJob.Schedule(this,inputDeps);

boreal glade
#

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.

minor sapphire
#

You type .schedule somewhere usually @vale stream

#

Hopefully it's not .schedulesingle for example.

vale stream
#

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!

low tangle
#

only one chunk :)

#

take a look at the entity debugger and see how many entities per chunk (for that archtype)

vale stream
#

this part of the UI? I'm new to ECS, jobs and DOTS in general and I haven't heard the term chunks before

boreal glade
vale stream
#

Ty πŸ‘

full stirrup
#

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

boreal glade
dull copper
#

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)

amber flicker
#

interesting rename of Concurrent to ParallelWriter for queues - was hoping for the burst compatible ECB's but not yet I guess?

dull copper
#
## [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

vagrant surge
#

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

amber flicker
#

PSA - latest packages only run on < 2019.3 or >= 2019.3.a10 - also.. time to change all OnCreateManagers over to OnCreate

dull copper
#

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

amber flicker
#

😦

#

Hybrid renderer? That seems to be working ok for me? I think

vestal hatch
#

@dull copper where do you see those release notes at?

dull copper
#

@vestal hatch when you install the packages, you can browse the packages at projects Library/PackageCache, each package usually has CHANGELOG.md

low tangle
#

ooh thats where you found it

#

that makes a lot of sense

#

I checked the documentation page for them but that changelog lags apparently

dull copper
#

well, there's also link on the package manager to same file

#

"view changelog"

#

for me it opens the changelog from local file

low tangle
#

oh wow I never clicked that link

#

assumed it jumped to the website changelog

dull copper
#

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

low tangle
#

hm

#

I'm not getting any warning on those

dull copper
#

after 22nd of October, this thing ceases to work

low tangle
#

so remove Manager from all the systems

dull copper
#

well, I have old mouse picker on this project from old physics samples

low tangle
#

surprised they didn't just run the unity update on them

dull copper
#

they probably updated it already on DOTS samples

low tangle
#

OnCreateManager should be renamed as well I assume?

amber flicker
#

yup

low tangle
#

that unity dots testing interview is in a few hours sweatingman

vestal hatch
#

unity dots testing interview?

dull copper
#

gl

low tangle
#

50 OnCreateManagers replaced with OnCreate

dull copper
#

@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

low tangle
#

theres more? to it I guess

vestal hatch
#

oh interesting

low tangle
#

nda already

dull copper
#

could be

#

I hope you get access to their internal DOTS repo

#

to make that worthwhile πŸ˜„

low tangle
#

that would be really intresting

#

pretty painless update to 2019.2 + dots update

#

always feels nice when it goes off without a hitch

dull copper
#

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
low tangle
#

yeah I skimmed the source on a handful, didnt look like any important changes

#

I want jobified ecbs sleep

dull copper
#

I didn't even know boids had any documentation :p

low tangle
#

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

#

remember watching this when it came out

#

@dull copper

#

this explains the boids demo very very well

dull copper
#

well, I remember one thing from that talk

#

it's that Acton is scary AF πŸ˜„

#

that poor guy asking something on Q&A

thick carbon
#

I liked his talk on DOD at the CPP conference way more, this one was kinda vague

coarse turtle
#

Lol he is a bit intimidating

#

Felt that way when I spoke to him at Unite LA

low tangle
#

@thick carbon ooh you could share that one?

coarse turtle
#

Whoops

low tangle
#

hah

coarse turtle
#

So thats the CPPCon talk lol

low tangle
#

thank you :)

thick carbon
#

there are some slides to a code review he's done that's really popular as well

coarse turtle
#

Yeah, I think he reviewed Ogre 3D

boreal glade
#

Are there any performance implications in adding and removing components in a single frame?

#

Marker components for example

coarse turtle
low tangle
#

thanks for more stuffs

#

I really want to get this converted into a pdf for my kindle to read sometime

#

lots of wonderful stuff in it

boreal glade
low tangle
#

yeah but thats the 'kindle' format

#

it isn't open

boreal glade
#

here you go

low tangle
#

well shit

#

thats fucking awesome

coarse turtle
lapis kettle
#

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?

coarse turtle
#

ah the dod book, that's where I first learned about bloom filters are a plausble data structure in my game πŸ˜…

low tangle
#

haven't heard about those

#

@lapis kettle its getting closeish to ready

boreal glade
#

@coarse turtle Thanks! I'll check that out

low tangle
#

my whole game core is built on it, but is heavily hybrid objects for physics and rendering (but driven from ecs)

lapis kettle
#

I don't know much, but if I am correct, didn't the new update introduce physics for pure ecs?

coarse turtle
#

Yes, physics 0.2.0 is recently released

#

Which is the DOD workflow

lapis kettle
#

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 πŸ˜„

coarse turtle
#

it was revealed in 2016 from what I recall

low tangle
#

yeah but didn't get super useful till almost exactly a year ago

#

jobs was out then though

coarse turtle
#

Yea

lapis kettle
#

are there any good example projects out there?

low tangle
#

not that I know of

coarse turtle
#

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

lapis kettle
#

thanks, I'll check it out

boreal glade
#

@coarse turtle That resource was exactly what I needed. Thanks so much!

safe lintel
#

@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

coarse turtle
#

Ah I gotta play around with the converted lights

low tangle
#

yeah baking lighting is still in progress

coarse turtle
#

Ah looks like the new packages dropped

safe lintel
#

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

mint iron
#

someone needs to do a diff and give us all the juicy details.

coarse turtle
#

o so NativeQueue.ToConcurrent() is deprecated

#

We have AsParallelWriter instead

amber flicker
#

@safe lintel yea so 2019.1 & 2019.2 are ok but if you're on 2019.3, make sure you're on the latest

manic elbow
#

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) ?

safe lintel
#

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)

manic elbow
#

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 πŸ˜„

low tangle
#

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

low tangle
#

@dull copper interview thing over, I like what they got going. I hope my feedback helps them out

pliant pike
#

is there a framerate limit put on the 2019.3, it seems like my frame rate has dropped in it

safe lintel
#

what things did they want feedback about specifically(if you are willing)?

low tangle
#

nda thingy

safe lintel
#

ah ok

minor sapphire
#

Ooo new package? Can someone paste changelog or something, currently at work.

low tangle
#

click this

minor sapphire
#

Thanks June

safe lintel
#

hmm i guess this isnt the update that allows for fully burstable entitycommandbuffers 😦

safe lintel
minor sapphire
#

@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

safe lintel
#

it was better in build but still slowed down, i didnt profile it though but probably similar

dull copper
#

wait, each particle emits it's own light?

#

that's going to be slow

#

like, that's expected

minor sapphire
#

surely that's not enough lights to cause that much slow down ....

dull copper
#

hundred moving pointlights?

vestal hatch
#

if you're using forward rendering all those lights are going to increase draw calls significantly

mystic mountain
#

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?

mint iron
#

i'm getting lots of crashes and regressions on latest release 😦

pliant pike
#

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?

amber flicker
#

just for ForEach lambdas I think right?

pliant pike
#

yeah I guess that but you need something like an EntityManager to add them

safe lintel
#

postupdatecommands is just for mainthread ComponentSystems so I assume EntityManager just replaces it there

#

for jobs its still EntityCommandBuffers

pliant pike
#

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

safe lintel
#

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);

pliant pike
#

that's great, thanks

lapis kettle
#

is pure ECS an option at this point or is hybrid a better approach right now?

pliant pike
#

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

lapis kettle
#

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

pliant pike
#

there's not really any downside to learning it, I'm liking it a lot more than oop

lapis kettle
#

alright, I'm going to start playing with it I guess

#

thanks

safe lintel
#

oh i get it regarding my lights, im just creating new gameobject lights that are pooled, its not quite native ecs

tawdry tree
#

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.

low tangle
#

Pretty much

vagrant surge
#

they could improve the hybrid mode

#

but they dont want to

low tangle
#

Nah

vagrant surge
#

Entitas style linking gameobjects to entities

#

and that way people can start doing ecs systems in their unity games right now

pliant pike
#

it'll take even longer for the majority of developers to move over to using ECs as well

tawdry tree
#

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.

low tangle
#

They want to ditch game objects

pliant pike
#

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?

tawdry tree
#

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 ...'
}
vagrant surge
#

@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

pliant pike
#

hmm I haven burst it yet though

tawdry tree
#

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.

pliant pike
#

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

tawdry tree
#

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.

pliant pike
#

yeah its weird

safe lintel
#

anyone used the livelink? is it supposed to be in editor stuff or something? because it doesnt appear to do anything for me

coarse turtle
#

Ah what's live link? Ive been curious about it but I've been pretty busy this week to find info abt it

low tangle
#

@pliant pike your first version was correct, you just needed to use the concurrent interface from the ECB

safe lintel
#

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

pliant pike
#

awesome that works, thanks @low tangle

fringe sinew
#

For a general rule, will IJobChunk be always faster than IJobForEach?

pliant pike
#

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

safe lintel
#

you can use burst with creation and destruction of entities but not yet with add/remove components

dull copper
#

I don't remember this many images there

safe lintel
#

nice, thats definitely new

dull copper
#
  • 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)

tawdry tree
#

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.

pliant pike
#

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

coarse turtle
#

Yea, filtering on types was good for the time being, but the pagination looks quite nice

dull copper
#

ah, the link is broken

stiff skiff
#

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

minor sapphire
#

@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.

dull copper
#

ah, nice

minor sapphire
#

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?

coarse turtle
#

Library might be the folder to delete @minor sapphire

#

Or maybe just Library/PackageCache at the bare minimum

dull copper
#

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```
toxic walrus
#

still waiting for deterministic fp support^^

dull copper
#

I think it was postponed to next winter again

#

:/

low tangle
minor sapphire
#

unfortunately I can't get my actual project working with all the latest stuff 😐

#

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

dull copper
#

urp has different pp now

mint iron
#

yeah, i was using shader graph shaders and replacing materials for the property block settings but after the update they're all broken.

dull copper
#

@minor sapphire

mint iron
#

also add component with bulk overload doesn't do anything special, it just wraps a for loop. 😦

minor sapphire
#

@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...

dull copper
#

@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

minor sapphire
#

ohhhhh jeez ok I better go look this up

#

why is the Post Processing package still a dependency of the LWRP then... 😐

dull copper
#

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

minor sapphire
#

I'm really confused, LWRP does depend on universal

#

and also PP

dull copper
#

ok, lets try again

minor sapphire
#

universal is just a 'core' that HDRP and LWRP will reference? or is universal a replacement for LWRP or something??

dull copper
#

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

minor sapphire
#

should I be referencing both of these packages or only one??

dull copper
#

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

minor sapphire
#

right I see

#

How did I miss the memo lol

dull copper
#

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

minor sapphire
#

right, ok I'm gonna remove LWRP and see what happens lol

dull copper
#

(especially since LWRP came out of preview just on 2019.1)

minor sapphire
#

ok I found this

minor sapphire
#

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

dull copper
#
[2:15 PM] 0lento: no more pp volumes or pp layers```
#

well, yeah πŸ˜„

minor sapphire
#

ok ok, well to be fair, when you said that I was completely lost and it went over my head πŸ˜›

mint iron
#

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.

pliant pike
#

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

minor sapphire
#

@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

pliant pike
#

right I figured it would just put them all in the list

minor sapphire
#

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

pliant pike
#
struct CountUnemployedJob : IJobForEach<EventEntityinfo, GeneralCityInfo, Unemployed>```
#

thats 3 separate entity's that I tried to get to work

mint iron
#

that will bring in all entities that have all 3 components by default

minor sapphire
#

no it's going to look for entities that match all three

#

why not schedule one job for each of them?

pliant pike
#

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

minor sapphire
#

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

pliant pike
#

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

amber flicker
#

@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

pliant pike
#

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

amber flicker
#

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

pliant pike
#

yeah I guess there's no way for it to figure there all in different chunks

amber flicker
#

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

pliant pike
#

yeah I see what you mean

mint iron
#

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

pliant pike
#

I'll try it different ways and see whats better

mint iron
#

another option is to pre-filter the whole system with RequireForUpdate and have multiple systems.

stiff skiff
#

@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?)

pliant pike
#

its a single entity, I've heard singletons are bad so try and stay away from them

stiff skiff
#

On a side note, why store this info on an entity?

pliant pike
#

why not? where else would I store it

stiff skiff
#

In a field on a system

pliant pike
#

oh well I do want to use that data on other things

stiff skiff
#

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

pliant pike
#

I guess not, if I just have a system then I know the data is always up to date

tawdry tree
#

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)

pliant pike
#

yeah I think I understand

#

I do want to store the data later on though in a simple text file or something

stiff skiff
#

@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

mint iron
#

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.

stiff skiff
#

A good reason to store it on an entity, if that is the requirement

tawdry tree
#

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.

mint iron
#

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.

stiff skiff
#

Configuration for what?

mint iron
#

level data, game behaviors that need to be tweakable etc

coarse turtle
#

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

stiff skiff
#

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

tawdry tree
pliant pike
#

@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

tawdry tree
#

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?

pliant pike
#

maybe using delegates?

stiff skiff
#

@pliant pike its a buildin method for 0.1.0

mint iron
#

it was CalculateLength() before

stiff skiff
#

^

pliant pike
#

thanks yeah I've found it now

stiff skiff
#

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)

pliant pike
#

EntityQuery in off itself is a job isnt it

stiff skiff
#

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

pliant pike
#

yeah I mean when I do things like tocomponentdataarray or copyfromcomponentdata...

stiff skiff
#

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

pliant pike
#

I had to do it manually when I used them

stiff skiff
#

Just checked, they both use a job internally

pliant pike
#

or I had to make sure the dependancies were passed between them and the job

stiff skiff
#

they have 2 versions. 1 calls complete internally, the other returns the job

pliant pike
#

I couldn't get the first version to work correctly without the handle

safe lintel
#

@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

pliant pike
#

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

mint iron
#

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)
});
safe lintel
#

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

pliant pike
#

cool, if you use GetEntityCount it just shows them all in a list on the EntityDebugger on the jobsystem

vagrant surge
#

@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

stiff skiff
#

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

vagrant surge
#

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

stiff skiff
#

Its fine if the "speed" isnt just a number but a category

stiff skiff
#

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

pliant pike
#

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

stiff skiff
#

That sounds like a different issue

pliant pike
#

yeah I think its because its a run time issue

stiff skiff
#

I hope you mean 0.250ms?

pliant pike
#

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

tawdry tree
#

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.

stiff skiff
#

Maybe I'll try making some alterations to the package to see if it works tomorrow

pliant pike
#

ok I've figured out how to get idle time down to 0.02ms between CopyfromComponentDataArray and the job

stiff skiff
#

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

pliant pike
#

you have to call complete on the CFCDA for it to work, but you dont have to do it before the job

pliant pike
#

is a jobcomponentsystem supposed to run on the main thread?

untold night
#

The OnUpdate part is, the Job prep Scheduling has to take place on the main thread for safety.

The Jobs themselves do not

pliant pike
#

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?

stiff skiff
#

What does AssignEmployeesJob do?

pliant pike
#

it adds entities into dynamic buffers

stiff skiff
#

Really wondering what that looks like. 13 ms is a LOT of time

pliant pike
#

yeah its even longer without burst, I can post the code if you want

stiff skiff
#

You run at about 1 fps?

pliant pike
#

I dont think that influences the framerate, if its running on a separate thread it shouldn't should it?

stiff skiff
#

I mean, your screenshot is showing you're clearly running at 632ms per frame

#

so 1.5 fps

#

Also that job is not running on a seperate thread