#archived-dots

1 messages Β· Page 70 of 1

untold night
#

interesting, but @chrome pawn was the one with the issue

mint iron
#

ugh, sorry

untold night
#

no problem

#

things move fast in a chat channel

mint iron
#

i was wondering "why is this so slow??!", accidentally produced 2 million entities πŸ˜„

junior fjord
#

do I understand it right that this dynamic buffer thing is basically a replacement for making a BufferInt component for example?

junior fjord
#

do I understand it right that the ordering which unity automatically infers due to read/write is just the ordering at the lowest level?

#

the higher order ordering is done by the systemgroup stuff?

full stirrup
#

there a more decent follow through guide for latest ecs?
Ill be looking at the updated examples soon, but just wondering if there was something a little more solid now that pure has more of a leg to stand on

junior fjord
#

the new samples are great @full stirrup

#

they start from very very easy and are well documented

mint iron
#

i was looking at some older examples using 'Attach' which is now deprecated i think, how do we do that now?

safe lintel
#

Parent

vale gorge
#

How do you edit the things like position, rotation, and scale. Any example or tutorials I have been able to find are using TransformMatrix, which does not seem to exist now?

full stirrup
#

Someone had an issue on the forum where the Position component had been deprecated

#

Originally you would filter your system to look for <Position, Rotation, Scale, (probably a tag so you dont get everything)> and you do your stuff on those entities

untold night
#

Position is now Translation

full stirrup
#

Renamed for consistency sake with splitting a matrix into translation/rotation/scale or anything beneficial to it?

vale gorge
#

Do I use position or positionproxy?

full stirrup
#

As recursive said use translation since its going to be the newer version (assuming)

vale gorge
#

Where is that?

thick plover
#

What is a β€œentity component system”?

mint iron
#

if you don't see it, try updating entities to the latest version (and use a newer version of Unity, 2018 has a lower version cap on entities packages for example)

solar spire
#

@thick plover googling the exact sentence you wrote here produces the exact answers people will give you. If you have further questions feel free to post them here though

analog tangle
#

@vale gorge In Unity.Transforms

#

The namespace, that is. So "using Unity.Transforms;"

#

Kinda a weird namespace name to be honest. I'd expect it to be a set of helper utilities to convert.

vale gorge
#

@analog tangle thanks, though I don't seem to see it :/
I am on 2018.3.10f1. And entities 0.0.12. So, I'm not sure

analog tangle
#

It's in the Unity.Entities package. If you have that installed you should be able to use Unity.Transforms.

#

If you made your own Assembly Definitions files for compilation speed, that could mess with it.

vale gorge
#

I have Unity.Transforms

#

Not sure what in it I am supposed to use

#

I am getting this error with this code.... I can't figure out why... I tried changing the int to a float but that didn't seem to work... What am I missing??

 [Serializable]
    public struct CurrentData : IComponentData
    {
        public bool isFullyGrown;
        public int stageIndex;
        public float secondsSpentInStage;
    }
untold night
#

It's the bool, what versions of entities and burst do you have?

I think the newer ones may have support for bools in IComponentData or they're close to getting it in. bools are now allowed in Native Containers, at least

analog tangle
#

Ah really? They map them to something blittable?

#

@vale gorge You're asking how to edit position, rotation, and scale. What you do is create a job that takes in the components you need AND an entity's translation component... modifying that will move its position. You could also grab its Rotation component and its Scale component.

#

Or rather... grab the component from the translation components that is tagged by the entity that you want to move... as well as whatever other components from the entity that you need to know where to move it to of course.

vale gorge
#

@untold night I have Entities 0.0.12-preview.8 and Burst 1.0.0-preview.8

Really? No bools?

#

@analog tangle for me there is not Unity.Transforms.Translate.

analog tangle
#

Translation

vale gorge
#

That is what I meant, I just miss-typed it here

analog tangle
#

I mean it's there so... maybe your project's messed up somehow?

#

Do you do custom Assembly Definitions?

vale gorge
#

Hmm.. no. It is a brand no project...

#

I will try making a new new project to see if I have it there I guess

analog tangle
#

Eh first

#

So you do "using Unity.Transforms;" at the top... then you try to add a Translation to a job... correct?

vale gorge
analog tangle
#

Oh wait a minute

#

You're way far back

#

I'm on 0.0.12 Preview 29

vale gorge
#

What??

#

How....?

analog tangle
#

I just checked on 2018.3. The latest there is 0.0.12-preview.24

#

I'm on 2019.1

#

Are you on 2018.3 at the earliest?

untold night
#

the newer packages are all on 2019.1

vale gorge
#

yeah 2018.3.10. I just restarted Unity and Entities jump from preview 8 to 24

analog tangle
#

I don't know when Translation was added unfortunately.

#

But yeah that would be your problem. Old package.

vale gorge
#

That is so strange.... i just opened Unity this morning

#

Well.. it is still not seeing it. I think I will just try messing around with it more tomorrow and see if I can figure out why it is being weird.
Thanks for your help @analog tangle and @untold night ! πŸ˜„

analog tangle
#

Yeah you probably still need to use the Position component @vale gorge

#

Just know that it'll eventually be renamed.

#

(has been renamed in later versions)

vale gorge
#

Alright. Bit of a shame no bool yet.

analog tangle
#

Yeah most people have made their own bool class.

#

Although it's good if I don't need to now. Hmm.

vale gorge
#

I am just going to use an int for now πŸ˜›

analog tangle
#

@untold night How good is Burst at packing multiple bools btw?

untold night
#

I haven't tested it. Out of habit I'd just make a bitfield enum though

analog tangle
#

Yup

dull copper
#

does bool require some custom type?

#

I think they recently allowed bools but it doesn't mean it's standard c# bool type

#

also, 0.0.12-preview.29 is latest Entities package now

elder wharf
#

it work now with normal c# bools

fringe sinew
#

God, it is exceptionally confusing!
Do I properly understand that Getcomponentgroup() is invalid when a new entity is created for that group?

#

If so - how in the world are we expected to iterate on data from components tied to another entity? Inject is already deprecated.

toxic walrus
#

@fringe sinew with Entities.ForEach

fringe sinew
#

Okay, how do I fetch data from another entity's component to do, for example, AABB?

#

I think there's a misunderstanding

full stirrup
#

AABB would have you looping through all entities anyway to check if their AABB box overlaps the current one

fringe sinew
#

Exactly. How do I loop a current box over every other box component?

#

How do I get other boxes to check against?

full stirrup
#

IJobParallelFor would get you checking easily since it is a loop, you just do another loop inside checking i against j

#

You would need to provide the colliders and entities

fringe sinew
#

What if it's chunked? What if I don't want to use jobs for it?

full stirrup
#

Probably be a bit mental if you wanted to run computed collision detection on a single thread

fringe sinew
#

Can confirm that

full stirrup
#

Would need to look at the boids example

fringe sinew
#

But really though, IJobParallelFor is a nice thing, but it breaks if chunks are needed. I really want to know how to deal with it then

full stirrup
#

Theres IJobChunk as well

fringe sinew
#

Hmm...

#

But wait, doesn't it send each chunk individually?

#

Wouldn't my checks be limited only for that chunk?

#

I want to iterate over all of it

#

It always cracks me up when people show how many spaceships they can move from one position to the other, but the moment when it is required to implement shooting and damaging - more than everything can go super wrong

tawdry tree
#

Not only does everything go wrong, but completely unrelated things that previously worked suddenly stops working, that kinda 'more than everything'?

safe lintel
#

@fringe sinew you could get all the ComponentData for a ComponentGroup by doing ToComponentDataArray and compare that with a particular entity in a job

fringe sinew
#

But then again, for that afaik you need to call GetComponentGroup, which leads to the original question: will it be invalidated if an entity/component is added to the world's group?

safe lintel
#

i guess im not sure what you mean by "will it be invalidated if an entity/component is added to the world's group?"

#

oh just read up, no

fringe sinew
#

Thank you very much

safe lintel
#

you only need to do GetComponentGroup in OnCreateManager or OnStartRunning

fringe sinew
#

And no matter how many components are added or how many chunks are used, I will always correctly get all the enetities to operate on them

#

Superb

junior fjord
#

is there a way to have fixed size arrays inside a component?

#

or is the only way now to use these dynamic buffers?

mint iron
#

you could try to make a collection using fixed array and put that in your struct, being blittable it 'should' be sized properly by the system but i havent tried it with ECS.

#

i also saw somethign in one of the reason examples using the new blob collections

#

ill try to find it real quick

junior fjord
#

the new docs say that dynamic buffers supersede fixed arrays and should be used instead

#

maybe their overhead is just that small that it is fine?

#

hmm ok but I must be missunderstanding something

#

how could I request only entities that have a specific buffer?

mint iron
#

Joachim uses a lot of dynamic buffers in there

junior fjord
#

thanks

#

he basically adds a Tag-Component for filtering

#

and elseways just loads in the buffer before the job starts

#

ah no later he just uses it like a component

safe lintel
#

man Im dying for that Connect the dots roadmap to be released

junior fjord
#

thank you too

#

does EntityManager.GetBufferFromEntity basically copy the full buffer array?

#

or is that an object that I can use for indexing?

#

that second link was very helpful by the way

#

the first one too but the second one is more stripped down πŸ˜„

safe lintel
#

not sure, was just using that second link last night as Im just starting to do stuff with buffers πŸ˜ƒ

urban rivet
#

all I want is non enlighten realtime gi or for enlighten to actually not keep spiking 50ms non stop just because the sky farted once

lime dome
#

yeah that's odd, i saw your post but i have no idea what would cause that

urban rivet
#

it's the procedural sky

#

for some reason, rather than actually using async readback (a native gpu feature of unity) it stalls the entire pipeline, rudely grabs the sky and then on cpu writes it to lightmaps

#

in short its pissed me off

#

with its amateur hour nonsense

#

I try to be polite because its professional but sometimes ugh

safe lintel
#

could be worse, when i shoot a weapon in a recent build the camera stops working

#

id take gi perf spikes over that!

urban rivet
#

it's basically just a horrific lack of interest in keeping enlighten up to date with unity's rendering

#

so I dumped it, I don't see why I should suffer, I'll just work around it.

#

ECS is a really good thing actually

#

I could do a bunch of jobified (not ecs sorry) casts and manually place soft diffuse hdrp lights for bounce...

#

(best move this to srp or such) sorry :D

lime dome
#

well they are currently redoing the sky

#

so maybe they will fix that in the process

junior fjord
#

can I somehow pass in a length to a nativearray (like reserve in C++) and then just add elements?

tawdry tree
#

So initialize with a given size, but not initialize the elements?
A workaround could be to initialize it with empty/dummy elements, which you later replace

junior fjord
#

how would I initlize it like that?

#

create an empty normal c# array and pass it to the constructor?

#

that is the only way right?

tawdry tree
#

I don't actually know how NativeArrays work.
The first question was to check if i understood what you meant, and the workaround is what it is

junior fjord
#

ok thank you very much

#

I went with
var dummy = new float[professions.Length]; //default contains only 0s
var bestUsePerTimeRation = new NativeArray<float>(dummy, Allocator.TempJob);

#

not sure that is good but yeah

tawdry tree
#

As often is the case with anything performance - it depends. In this case i'd say it probably doesn't matter. Approximately how big is the array, and how often do you allocate it?

junior fjord
#

no it does not matter in this case, the array is small and the system should not run too often

#

do you have any tips on what to do in case it would matter?

tawdry tree
#

That's when I'd find out if there is a 'best practice' way to do that πŸ˜›
Like, are you supposed to just make and reallocate? Or is there some hidden way to initialize without the dummy array? -shrugs-
First rule of optimization: Don't. Second rule of optimization: If you need to optimize, profile first. That's what one of my CS professors said (he was/is the leader for the game programming focus area, so this was both in general but also for games)

solar ridge
#

Allocating a temp nativearray per update is fine.

#

If you are doing default values, use the capacity version instead as no value can be null

#

So it will default them anyway

#

Persistent is ideal for data that needs to live cross frame and I'd say less ideal to merely keep an array alive to remap. That will be handled for you

junior fjord
#

what do you mean by the capacity version?

solar ridge
#

There should be (was) a version that took a size then an allocator

junior fjord
#

ah yes I saw that online but my Visual Studio does not show me that when I Ctrl + Click on NativeArray

#

that is what I was searching for

solar ridge
#

Sec

junior fjord
#

ah no I found it

solar ridge
#

new NativeArray<int>(12, Allocator.TempJob)

#

was valid

junior fjord
#

I misread the documentation page, I can click on the constructor and then there are different constructors, not just one

#

thank you, this is what I needed

solar ridge
#

Ctrl space in rider is handy. I believe VS has it as well

#

where it will auto complete and have a drop down of all the choices

junior fjord
#

I have another more best-practicy question. I have the following setup. I have Humans that need a Job.
Humans have Properties
Jobs have OptimalProperties and Goods
For a Human to search a Job it needs to:

  1. For each Job calculate how good it is at it (by comparing its own Properties to the Jobs OptimalProperties)
  2. For each Good that the Job can produce check the price of the Good and how long it would take to make the good for this Human
  3. Take some Maximum to see what is best

At the moment I do this all in one JobComponentSystem. In OnUpdate I copy all the Jobs and the goods that they can produce etc to the Job system, the Job system then requires Humans without the Job compoinent. In the Execute method it then loops through all professions to find the optimal one for this human

tawdry tree
#

Ctrl+Dot (.) or alt+enter(not always?) should give you intellisense suggestions in VS

junior fjord
#

is this a good approach or can I optimize something? The only problem I have is that from my feel it is all very mingled as I loop through professions, then the goods that each profession can produce and later I loop through all entities

#

instead of maybe some simpler setup with more systems?

tawdry tree
#

Ctrl+dot is one of my most used hotkeys on my job, since I'm working with systems I don't fully know/understand

junior fjord
#

I really like ctrl + click to go to definition of the class

solar ridge
#

I never understood VS desire to make a lot of hot keys that are more frequently used require both hands to utilize: example being ctrl + .

junior fjord
#

Unfortunately it is always only from metadata not the full commented source code, I would love that

#

yeah the hotkeys in vs are really not nice. It is the first time that ctrl + / does not mean comment πŸ˜„

tawdry tree
#

Slash itself is requires a modifier (it's shift+7) on scandinavian keyboards, or to switch to an english setup, but that's just confusing

junior fjord
#

yeah I always buy UK keyboards they are nice for programming

tawdry tree
#

And of course, you can just rebind hotkeys.

#

Most of the time you're likely coding with both hands anyway, so having to use both doesn't really matter

junior fjord
#

they have ;, /, [, ] all without modifier and {} with only the shift modifier

#

I wrote a simple setup of one of my systems above (you have to scroll up about 10 messages), if any one of you could read it and say if it sounds okish or very bad that would me of very great help for me

tawdry tree
#

Back to the topic, what you do now doesn't sound like a particularly bad idea to me, but there should be an 'idle' job they will grab if none other are found, so they don't use the CPU every single frame

#

I believe in these kinda games it's fairly standard for the idle state to be a job (or whatever the game uses to keep track of what's being done) that does nothing for a lil while (I'd suggest starting with 200ms, but you could modify that)

junior fjord
#

sorry I don't fully understand that. I should have a job that is idle most of the time?

solar ridge
#

First off: I'd recommend renaming jobs to tasks to prevent confusion from the job system

#

or missions or something

#

Your goal for many things ironically is to idle a lot more than you work in terms of CPU. so if you can group everything in an idle mission or remove the mission tag from the people that would be an interesting way of assigning new missions to those who need one

#

Atm I believe (I could be wrong) but changing the archetype while allows for interesting design choices, is not the best for things that are to update frequently. So having a component for the mission type and having an idle state could be interesting.

#

I believe there was a rather decent forum post comparing performance on adding/removing a tag vs changing the value of a tag

junior fjord
#

Yes ok lets call it Profession instead of Job
I still don't fully understand the idle thing. You mean I should just have a "idle" state in my Profession? E.g. HumanProfession{bool isIdle; Entity Profession;} where the Entity Profession is without any information in case the human is idle?

solar ridge
#

Right

#

You cant have null

junior fjord
#

what does that have to do with idle CPU time?

#

or did I missunderstand something there?

solar ridge
#

If you are checking to see what they excel at, and they are idle, it can omit most of those can't you?

#

And idle would be profession

#

Or None

tawdry tree
#

Yeah, when I said job in this case I meant jobs/tasks/missions as in what your people do, and changing the name there would be a good idea specifically to avoid confusion

junior fjord
#

but I would only need to check what they excel at if they are currently searching for a new Profession?

#

I think I am missunderstanding something

#

yes I am calling it Profession from now on

tawdry tree
#

My point was that There should be an Idle Profession, to stop the 'i need a new Profession/Task code from running on them too often

junior fjord
#

it is something like "cook" or "goldsmith"

#

but if I have an idle profession I have to run the system pretty often to check if anyone is idle right? If I just would remove the Profession component then ok I would have two copies but the system would only run when someone actually has no Job

#

is it clear that one is better than the other here or are you just saying I should try both?

tawdry tree
#

A Person has a Profession. A Profession refers to a Mission. Something like that?

junior fjord
#

yes

tawdry tree
#

To clarify what I mean: Say that Person A just finished their Mission. They are now Idle.
The System runs, but find no jobs that needs to be done.

junior fjord
#

ah no it is not like that

#

it is not that jobs need to be done

#

it is an economy simulation

solar ridge
#

More of their mission in life. Not so much their single run

junior fjord
#

they want a job to make money

tawdry tree
#

In this case, they should get a new Profession, 'Idle', to stop the system from searching for a new job again

#

Oh, so it's a one-time thing?

junior fjord
#

so they will always search a job as soon as they have none or maybe something changed that makes them think a new job could be better

solar ridge
#

--Only time they change profession is when it is demanded. not when work runs out--

junior fjord
#

no it is something that happens sometime, but not too often

#

like maybe at most every 10-20 minutes per human in game

tawdry tree
#

I misunderstood, then. I understood it as a Rimworld/Dwarf Fortress type colony builder

junior fjord
#

I would obviously love the game to scale to a looot of humans but yeah

#

no it is more a a real world economy with jobs where they want to make money on their own

#

allthough these are great games πŸ˜„

tawdry tree
#

I meant one-time not as in literally only needed once, but it runs and is done unless something makes them lose their profession or something

solar ridge
#

Problem I think you will have is you will need to reduce the scope of the question to get decent feedback. As this sounds like a lot of concepts of other games and we want to perceive it as such. but it sounds simple to you as you are acquainted with it πŸ˜›

tawdry tree
#

Run once as opposed to run repeatedly

solar ridge
#

It SOUNDS neat

tawdry tree
#

And yeah, the art of boiling down your concept to as limited a scope as possible while asking for help is a difficult one

junior fjord
#

yes they will have their profession until something "big" happens (price change in the stuff they are producing)

solar ridge
#

Personally, when asking questions I usually try to take my concept abstract it out and convert it to a different scenario and see if the question still makes sense

junior fjord
#

ok, I'll formulate it again a bit better

solar ridge
#

πŸ˜ƒ

#

Good luck!

junior fjord
#

yes thank you for trying to understand it, I see that it was prone to missunderstanding

tawdry tree
#

In this case, something like:
I have entities which needs to search through a set of 'Option's.
They have certain 'Properties'.
They will compare their 'Properties' with those of the 'Option's, and select the best one.
I do this in one JobComponentSystem. The archetype I use for the system is all entities of that kind without an 'Option'.

#

...I spent more time than necessary thinking that up, but in general you want to abstract away the details when asking for guidance. It might be better to use 'Human's instead of entities for my example here to denote that it is a specific Thing, but oh well.

junior fjord
#

Humans in the Economy have Professions (Like Goldsmith etc.). Each Profession can Produce a few (say 2-3) Goods (Items, e.g.jewerlery and coins for the Goldsmith). The Humans have Properties (Strength, Intelligence, ...) and the Professions have OptimalProperties (Strength, Intelligence). With a Human and a Profession I can calculate how good the Human is at this job and therefore he will be faster at producing the items in that Profession. The Humans keep the Profession for long (as long as not maybe a rapid price change in their good occurs and they search something new).

When searching a new Profession they will: Check all Profession and see how good they are at that Job and how fast they can produce the items of the Profession. Then they check the item prices of that Profession to see which one is of the best yield. Now they have for each Job a "yield" they'd get and will choose the best one

My idea until now is to have a Profession component and when the Profession component is missing a system runs that finds them a new profession

#

yes your text still abstracts it more nicely than mine πŸ˜„

#

I tried to get rid of the missunderstanding by more thorough explanation

#

I even thought about making the ProfessionComponent Shared s.t. each archetype has only Humans with the same Profession, since each profession will need access to the same data (the prices for the same goods etc) and therefor I would not need to change context that often

#

I am afk for 10 mins

tawdry tree
#

There is a balance to be had between abstractedness and details. At which point are details just distracting from the problem at hand, and when are things perhaps over-abstracted, making it harder to understand what actually goes on?
I like to think I'm decent at finding that balance in general, but also know that I have a tendency to get pretty longwinded in explanations.
Self demonstrating πŸ˜›

junior fjord
#

πŸ˜„

gusty comet
#

Translation & Rotation are depreciated?

safe lintel
#

the SharedComponentDataProxy is on the outs

toxic walrus
#

@gusty comet no

gusty comet
#

says they are when I add them to an object - not in console only in the "Add Component" dialogue

safe lintel
#

@gusty comet the monobehaviour proxy that they supply are deprecated in favour of the new conversion workflow, the actual IComponentData themselves are not

analog tangle
#

I managed to work around it, but is there a way to use, ex, lights in the ConvertToEntity workflow? As in have them adjustable in a job?

#

(I have to ship soon so I wrote to the system and wrote from there to a static class and read from there in LateUpdate() of a monobehaviour... works for a "needs to be done today" thing but obviously bad for literally anything else.)

knotty crow
#

Does anyone know if there is a comprehensive documentation anywhere specifically about the code and architectural decisions behind Nordeus / Unite 17 demo that is on Github, besides the presentations? It's a fascinating demo, but i'd love to know more of the overall design decisions. The code has Systems updating after eachother about 12 deep (UdateAfter() attribute). And too bad this wasn't a full game, it's really well done.

toxic walrus
#

i think there is only the unite presentation

crystal zephyr
#

Does anyone know how to deal wit a scenario where I want to have my game data and logic already in ECS but needs to communicate changes and triggers things to non ecs gameobjects. I need that for animated characters playing an other animation or physics collisions with a terrain.

gusty comet
#

Hi guys πŸ˜ƒ I'm a bit lost with EntityCommandBuffer right now. Do I have to create a barrier? The transform system use them directly but when I tried, the SetComponent made me crash. And on a Job like a ParrallelFor, do I have to send a command buffer at the struct creation, or is it automatically filled? The documentation about barrier did disappear so I'm wondering what's happening. Btw I'm blocked in 2018.3 for now.

safe lintel
#

i think its best to cache the barrier system at the creation of the manager and then yeah you have to pass it into the job creation

#

so ```csharp
protected override void OnCreateManager()
{
m_BarrierSystem = World.Active.GetOrCreateManager<EndSimulationEntityCommandBufferSystem>();
}

var job = new MyJob
{
CommandBuffer = m_BarrierSystem.CreateCommandBuffer() /* or "m_BarrierSystem.CreateCommandBuffer().ToConcurrent" for parrallelfor */
}

#

heh how do I do c# syntax highlighting here?

#

also not sure what state ecs is with 2018 now, i think its recommended to be on 2019 for the latest entities package

dull copper
#

they finally updated that to latest ECS

#

so no more errors

urban rivet
#

looks fun but is it ML based or something else?

dull copper
#

something else

safe lintel
#

its goap ai

urban rivet
#

I see yeah, don't need it really

#

might be good for many games

#

pretty nice for not worrying about coupling

#

whats the perf of the unity one like, anyone know?

#

allocations etc

#

does this work well with non-ecs? I imagine it would

#

I might give it a whirl just to see

safe lintel
#

im hoping the perf is good enough for some sort of rimworld scale simulation

vale gorge
#

Okay... so I created a brand new Unity project on 2018.3.11f1.
This script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using System;
using Unity.Mathematics;

namespace Pure
{
    [Serializable]
    public struct CurrentData : IComponentData
    {
        public int isFullyGrown;
        public int stageIndex;
        public float secondsSpentInStage;
    }
}

Is giving this error.

#

Entities 0.0.12-preview.24 btw

#

Does it not support ints???

full stirrup
#

No, ints are blittable regardless of unity

#

Not sure if serializable is doing anything different though

#

Seems they removed ComponentDataWrapper or im just looking in the wrong place

untold night
#

That error is talking about Pure.Stages, Pure.CurrentData looks fine

vale gorge
#

Oh, stupid. Sorry, I was having an error with that script. I just didn't look close enough.
This is stages.

namespace Pure
{
    [Serializable]
    public struct Stages : IComponentData
    {
        public NativeArray<Stage> Value;
    }
}
#

oh btw @full stirrup int is actually a bittable type πŸ˜ƒ

#

Am I using NativeArray wrong @untold night?

full stirrup
#

what is stage

vale gorge
#
[Serializable]
    public struct Stage
    {
        public float scaleAmount;
        public float secondsInStage;
    }
untold night
#

Yes. Native containers are not allowed in IComponentData or ISharedComponentData.

If you're using the later version of the ECS package for 2018.3, you should have access to DynamicBuffer<T> and IBufferElementData, which would solve your problem better

#

IBufferElementData allows you to define a special buffer type.

DynamicBuffer<T> gives you access to that buffered type, and functions exactly like NativeList<T>, DynamicBuffer<T> can be viewed as an array if it's read only in a job or system

vale gorge
#

Oh, got it. Thank you. I also just pulled the docs up so will read up on them

untold night
#

bear in mind, some of the API changed between the last 2018.3 version and the current 2019.1b versions of the ECS packages

namely, ToNativeArray<T> got renamed to AsNativeArray<T> on DynamicBuffer<T>. This is a clarificaition, the original function doesn't actually copy anything, it creates a shadow NativeArray<T> so you can treat the buffer as a NativeArray<T> for static functions that expect NativeArrays<T>

#

another handy trick is the DynamicBuffer<T>.Reinterpret<U>, where sizeof(T) == sizeof(U).

This allows you to make buffer types that wrap other components/structs can be reinterpreted as the actual underlying types with no overhead.

Some Examples:

DynamicBuffer<WaypointPosition> waypoints = ...;
DynamicBuffer<float3> positions = waypoints.Reinterpret<float3>();

A bit more relevant to your example

DynamicBuffer<StageElement> stageElements = ...;
var stageArray = stageElements.ReInterpret<Stage>.ToNativeArray<Stage>();
vale gorge
#

So this should work right??

[Serializable]
    public struct Stages : IComponentData
    {
        public DynamicBuffer<Stage> Value;
    }
untold night
#

no, this should:

[Serializable]
public struct StageElement : IBufferElementData
{
     public Stage Value;
}

There's a DynamicBuffer proxy in the newer ECS packages, not sure when it was introduced,

vale gorge
#

Oh, I see

#

I was thinking there were two different things

#

my mistake

untold night
#

With the exmample I just posted, you can access a dynamicbuffer thru various means (EntityManager, Chunk access, BufferFromEntity<T>) and get a DynamicBuffer<StageElements> you can then manipulate or read from

one thing to note, is if you know the average max size, you can use the [InternalBufferCapacity(NUMELEMENTS)] attribute to set the default buffer size.

how this works is there's a pre-allocated amount of space in the buffer, if it overflows, it switches to a dynamic allocation, which is automatically handled by the EntityManager.

#

if it goes back below NUMELEMENTS, it switches back to the internal buffer

#

otherwise I think it defaults to 8 elements or so

vale gorge
#

Got it. Thank you so much for your help and for taking the time to explain it to me. I will just try reading over what you said and the docs say and see if I can't get it to work (Which thanks to you shouldn't be too hard). Thanks again!

untold night
#

I'd honestly recommend updating to the latest 2019.1 beta if at all feasible.

RC should be out this month and there's a lot of improvements to both the API and Editor workflow that rely on 2019.1 changes.

vale gorge
#

How stable is 2019.1?

safe lintel
#

its really hard to tell between all the preview packages im using 😦

vale gorge
#

@untold night sorry to ask again.
But how do I use it with a JobComponentSystem?
This is the wrong way. I guess I just don't quite understand how DynamicBuffers fit in with all this.
If there is an example project that uses the dynamicbuffer I am happy to learn from that. I just haven't been able to find much on them.

public class GrowSystem : JobComponentSystem
    {               
        struct GrowJob : IJobProcessComponentData<..., DynamicBuffer<Stages>>
        { ... }
... }
safe lintel
untold night
#

Right now there's 2 ways to use DynamicBuffer<T> with Jobs:

  1. Use ArchetypeChunkBufferType<T> with IJobChunk.
  2. Use BufferFromEntity<T>, this can be used with IJobProcessComponentData<T>, and you can use the [RequiresComponentTag(typeof(T))] attribute. You can call GetBufferFromEntity<T> in a JobComponentSystem, then pass the BufferFromEntity<T> lookup structure into 1-more jobs. Read-only access is trivially parallizable, but write access will require you to utilize [DisableNativeParallelForRestriction], only if you can guarantee each buffer will only be written to by one thread at a time.

In both of these cases, T is NOT DynamicBuffer<T>, but just the type of your IBufferElementData component.

vale gorge
#

What class is GetBufferFromEntity<T> in?

untold night
#

Should be in JobComponentSystem.

vale gorge
#

oh I see. I was trying to access it from inside a IJobProcessComponentData

vale gorge
#

Okay I feel like I almost get it now. What I don't quite get is that public BufferFromEntity<Stages> stages; to use stages you need to use an index of an entity. I am not sure how to get that though.

untold night
#

IJobProcessComponentDataWithEntity<...> is what you want then

crystal zephyr
#

Does anybody know how I can add a hybrid component to an GameObjectEntity during runtime?

#

I can add a component on the gameobject but it will not be reflected to the entity world.

#

How I can create the IComponentData which is internally used for the gameobject components?

#

Say I have an animator on a GameObject and I make it a GameObjectEntity. Somehow unity creates an animator component which I can see in the archetype.

#

But how I can do that for my stuff?

mystic mountain
#

So I'm starting with some hybrid stuff with the ECS. I'm trying to figure out the best way to manage a pickup system, kind of like you pick up boxes in your hands. So far my thoughts has been to have one component for the entities that can pick up things, containing Entity of the picked up object, the boxes have only a empty component to mark them as pickupable. Using the old system I would just make the picked up object as a child to the entities hands basically, now trying to move into the ECS stuff, I'm not sure if the current child system(?) can fix this, and if this works with a hybrid approach? Or if I should make a system to set the picked ups object position at the end of frame. Anyone got any suggestions?

amber flicker
#

@mystic mountain I think what you describe makes sense. I'd say you may want to separate it out into a few systems. One that does the picking up (probably you want the component on a box to have a bool like 'held'). A similar one for dropping/putting down. As for the movement, either you could get those systems to parent the corresponding box entity to a hand entity or you could use a separate system to update it's position etc.

mystic mountain
#

@amber flicker Thanks! I'll try out the Entity parenting : )

amber flicker
#

Good luck - if it helps you google, it used to be called 'Attach' - the procedure is the same, only the name has changed to 'Parent' I think

crystal zephyr
#

Hey guys, any idea how to do collision detection with the old physics? Still have an monobeviour and on collision maybe passing something to ECS?

safe lintel
#

what problem are you having?

urban rivet
#

Hybrid is required for that

ember ruin
#

Hey, trying to build a test game from the boid demo, starting a demo play gives me following error:

Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak

Board and SO entries i found from a google search suggest this is an engine bug that was fixed in a 2018 version, I'm currently on a 2019 version that should have that fixed

tawdry tree
#

Is it the updated boids example (there is one, right?)
Otherwise it could just be a bug between versions

ember ruin
#

I basicly copied both SpawnRandomInSphere[...].cs and used it my own project just to discover that warning + no spawning of any entities

tawdry tree
#

What the error means is that something tagged as temporary lives too long, should be fairly easy to find that thing and deallocate it.
Or it could, as you suggested, be an actual bug.

ember ruin
#

Well i could reproduce it in the demo project, when i switched the boid prefab for a simple cube prefab it gave me the same error

ember ruin
#

Well... strange things happening, when I set the prefab back to the boidFish it still gives me the warning xD

#

Ok.. restarting the editor vanishes the message until you swap the prefab again, i can work with that i guess

rough moon
#

Hi, I'm having an error thrown saying:
ArgumentException: PathwayMovementData contains a field of Unity.Collections.LowLevel.Unsafe.DisposeSentinel, which is neither primitive nor blittable.

This is my component:

public struct PathwayMovementData : IComponentData
{
    public int currentWaypointIndex;
    public NativeArray<float3> directions;
    public NativeArray<float3> destinations;
}

So that means I can't have arrays in component data?

solar ridge
#

You ... "can"

#

but Native containers are nonblittable

#

Examples of arrays would be the DynamicBuffers and you add those to the entity

rough moon
#

@solar ridge I don't understand the "blittable" part. Can you please elaborate on this, as I can't understand the Microsoft docs about this either.

solar ridge
#

Errr... so "that have an identical presentation in memory for both managed and unmanaged code". In terms of say an array the managed vs unmanaged are vastly different.

Reference types for instance are non-bittable. It gets to a rather high level of understanding that realistically is a bit much if you are coming from a standpoint of never seeing the word "blittable" before. At that point it is likely better to just understand that things that are non-blittable (I'll explain in a moment) can NOT exist in IComponentData nor Job fields.

Now. To determine if something is Blittable or not, there is a Utility in Unity that assists with this. "UnsafeUtility.IsBlittable<T>()" This can assist in determining if a field type is usable or not.

In terms of arrays. If you look at NativeString64 and on you can see that they do infact use an array but it is of a fixed size

#

Best one liner I have found: "A blittable type is a data type that does not require special attention from the interop marshaler because by default it has a common representation in managed and unmanaged memory."

#

Blittable types are data types in the Microsoft .NET framework that have an identical presentation in memory for both managed and unmanaged code. Understanding the difference between blittable and non-blittable types can aid in using COM Interop or P/Invoke, two techniques fo...

#

In your case: There is something called a DynamicBuffer to solve the problem you are at right now. As for how to use them, I haven't looked into them yet

rough moon
#

Thanks @solar ridge

crystal zephyr
#

Hey guys, for which usecase this method is ment: chunk.GetComponentObjects

lilac ermine
#

the Object stuff in ecs is usually referring to classic unity components

mystic mountain
#

I'm back again. So I tried a bit with the ECS parenting, but I didn't get too far, I try to add Parent and LocalToParent but they seem to get removed? Anyone know what I might be doing wrong or might share a link to a hybrid approach of parenting? But looking at my problem at large. I'm using hybrid approach, I want to pick up objects, and in turn parent these objects. These objects can be controlled by old physics. So what I can see here is that I need GameObject positions => entity positions, and if using the new parenting - entity position => gameObject position, so I will need to swap around which way positions are managed, which in turn requires some connection from Entity to gameObject. So I think the best option in my case will be to have some reference table from entity => gameObject and use old parenting and deactivate physics, until I migrate physics to the new physics system where I can move the parenting along. Any thoughts?

crystal zephyr
#

I'm also back again and can still not help Jaws but have also a question. I have the situation that I have an Entity which has a trigger component and a system which react if a triggerCollisionComponent was added to react on that. But in this system I would need the list of triggerTargets (the object which I want to effect now). How I can connect that? Can I have two groups in a job and then loop through the first one while using the second group as as a lookup list?

#

Like I have two different list of archetypes and they should not interact with each other.

#

With The GameObjectEntity I could link the GameObjectEntity component and access the Entity inside. But how I link a convert to entity?

mint iron
#

Sadly i can't answer your questions πŸ˜ƒ but ill add one of my own. Any ideas why i would be getting Assertion failed on expression: 'jobData->range.numJobs == 1' from injected method JobsUtility:ScheduleParallelFor_Injected(JobScheduleParameters&, Int32, Int32, JobHandle&) gotta love no source code... i only have one IJobChunk job running with Run(). * solved and it had nothing to do with the error description. :S

full stirrup
#

Guessing its checking if the number of jobs is 1

rugged wagon
#

I haven't used the burst inspector before, but I'm assuming something isn't working as intended? I can't see any of the generated code when I select jobs. I just wanna make sure I'm not doing something wrong before submitting a bug report

mint iron
#

did you click the refresh dissassembly button

rugged wagon
#

that was it, thanks πŸ‘

vale gorge
#

How do you do rendering with ECS?

#

I can't find anything on it but obviously it can be done.

mint iron
#

either slap a ConvertToEntity script on a monobehavior and let the system auto convert the components, or manually build the entity adding the components yourself.

vale gorge
#

Right... but which components are required for rendering...?

mint iron
#

im not sure if theyre all required but mine have RenderMesh, RenderBounds, WorldRenderBounds and ChunkWorldRenderBounds

vale gorge
#

Hmm, I can't find those ones... maybe I don't have the right namespace?

mint iron
#

im on the latest, its possible theyre new 2019.1/Entities preview29

#

Unity.Rendering.RenderMesh

vale gorge
#

oh.. well.. I actually installed the Hybrid Renderer package and now have that namespace... πŸ˜›

vale gorge
#

Well... I feel like I am doing something wrong.
Using pure ECS, job system, and burst. I can get about 10k entities at around 30 fps...

tawdry tree
#

How many systems, what do they do, how often, what hardware do you have, etc
Check the profiler and see what takes time, and your task manager to see if you actually use multiple cores

amber flicker
#

@vale gorge also by default there are various safety checks that are quite intensive so always worth profiling against a build... with my 980ti & i5 I can animate >100k cubes around comfortably @60fps.. .oh also be sure to have your material set to enable instancing

vale gorge
#

For hardware I have:
CPU: AMD Ryzen 5 1500X Quad-Core Processor
GPU: Radeon RX 580 series. 8 GB dedicated memory.
(Let me know if you want other numbers, I have never really been a hardware guy, and am just starting to slowly learn it)

I have a single job system, the job runs on onUpdate.
it increases and decreases 3 different numbers, and scales the entity over time.
Rendering seems to be what is slowing it down for the most part. Turning on instancing in the material got about another 12 fps.
If I turn off the rendering components in the entity debugger window. the fps caps at about 80fps until I turn VSync off

amber flicker
#

it sounds like you're gpu bound - could be worth trying a mobile or unlit shader, disabling any light shadows etc if you just want to see more things moving around πŸ˜ƒ

vale gorge
#

You would think, but task manager says GPU is at 7% and CPU is at 80%

full stirrup
#

you are running pure right?

vale gorge
#

Unity specifically is using 5.5% and 60% respectively

#

I think so

amber flicker
#

ah in which case (sorry, lots of guessing here), are you using Burst? Possibly paste your job code here

vale gorge
tawdry tree
#

In Windows you can right click the task manager CPU area and change it to see all cores separately. Specifically, it will show logical processors, which includes virtual cores, but the effect is that it's a lot easier to see if something is efficiently using multithreading

amber flicker
#

hmmm I guess accessing the buffers will cause the memory layout to be non-linear but I'd be surprised if that was having such a large impact - any chance of a profiler->Timeline screen cap? may help illuminate where the time is spent

tawdry tree
#

^That's probably more useful than just seeing the usage, though. It will let you see what uses all those resources

vale gorge
amber flicker
#

Yikes that's a lot of time spent in RootLocalToWorld

vale gorge
#

I am assuming that is due to scaling the entities?

amber flicker
#

are there deep hierarchies?

vale gorge
amber flicker
#

Hmm two quick questions: 1) Is e.g. the timeline above from after it has settled? (e.g. 2seconds) and 2) Is it from an attached build?

vale gorge
#

Yeah it is settled. That is how it is the entire time (Ran for at least 6 seconds before taking screenshot)

amber flicker
#

For comparison - on my I5, 40k scaled cubes spend about 1ms total in TRSToLocalToWorld (in editor) - are you up to date with the hybrid render package etc?

vale gorge
#

Attached build?

amber flicker
#

if you do a build with 'Autoconnect to profiler' it will give you a lot more accurate numbers - though it's obvious even in-editor we're seeing quite different things

vale gorge
#

Hybrid renderer package is 0.0.1-preview.4
I am on unity 2018.3.11f1

amber flicker
#

ah.. ok... this is probably why I'm seeing much better numbers

#

2019.1.b09 & preview.9 for me

vale gorge
#

Hmm, let me trying opening it up in a project using 2019

amber flicker
#

May your upgrade path be smooth and your gains plentiful

vale gorge
vale gorge
#

@amber flicker Got it to work! Mostly... now I just need to figure out why the rendering doesn't seem to be working.

amber flicker
#

Nice! @vale gorge probably because your entities are missing a LocalToWorld component or something

vale gorge
#

Yep that is exactly what it was! So with VSync on I get about 75-80 fps. But with it off I get 200 ish... Do most people turn it off.. or am I missing something or what?

amber flicker
#

Cool, that sounds like a big improvement - vsync is there to reduce tearing etc - up to you whether you leave it on - if it's on, your cpu will be doing less work per frame and saving energy but it can be convenient when dev'ing to leave it off but I guess most people would advise having a ms timer on screen rather than relying on fps

vale gorge
#

Ah, that makes sense. Yeah the improvement is insane. I was googling a bit and it looks like the problem I was having may have been caused by a bug? But it doesn't really matter. It is working now!

#

Thank you so so much for your help. I really appreciate it!

amber flicker
#

No problem - glad to hear it's much improved πŸ˜ƒ Have fun!

vale gorge
#

Thanks! πŸ˜„

vale gorge
#

I'm not sure if it is a problem with how I am thinking or I simple don't know how to do it. But how would I get data from a single entity and a collection at the same time?

For example. I have a bunch of crops that are entities. I want to water them. But I need to check if there is water in my watering can. how can I both check if there is water in my watering can entity and if there is add water to my crops?

tawdry tree
#

Sounds a bit like what someone else asked earlier before coming to the realization that they just needed two separate jobs, where you'd use output of one in the other
(which I feel is one of those 'I can't believe that's not the first thing I tried' facepalm-moment)

vale gorge
#

oh....

#

it is indeed one of those 'I can't believe that's not the first thing I tried' facepalm-moments.. Thanks πŸ˜›

mint iron
#

hmmm, just realized why i have 3x as many entities as i intended, it seems that ConvertToEntity makes a RenderMesh on a new Entity for every SubMesh and does a whole parenty child thing 😦

safe lintel
#

well if they arent doing anything shouldnt be a big deal right?

#

though it does sorta clog up the debugger

solar ridge
#

Entities are fine. Comparison. Game objects doing nothing I am limited pretty heavily in the 10s of thousands. Where as Entities... I have spawned a few million with each having a long and a NativeString64... still going strong soarynDerp

steady quartz
#

Hi all,
I got Error [AssertionException: Assertion failure] while running on Android Device, I built for target ARMv7
anyone got this error before ?
you can see more log and description in forum topic
https://forum.unity.com/threads/error-assertionexception-assertion-failure-while-running-on-android-device.655138/

gusty saffron
#

Has anyone combined scriptable objects and ECS? I'm looking for help on how to build archetypes from scriptable objects. I need to somehow couple the component object with the actual ComponentDataProxy that I have. Any ideas?

mint iron
#

an idea might be to link your SO into a GameObject, and then use ConvertToEntity on it, and in the implementation set a component on the Entity populated with data from the SO.

#

im not sure if they auto convert yet

gusty saffron
#

I wanted to avoid gameobjects entirely if possible

toxic walrus
#

with the current conversion workflow, gameobjects make it easy to set up entities

untold night
#

There's also BlobAssets, which don't have a ton of documentation yet, but the ECS physics package uses them extensively for colliders and joints

mint iron
#

Do component systems update() get run sequentially be default (without grouping) or are they potentially running on different threads at the same time (excluding jobs for a second, just doing work in update method)

dull copper
#

@gusty saffron I think Unity is cooking up something for that already

#

so if you are not in a hurry, could just wait

#

I'd really want to see that DOTS roadmap talk from gdc

#

these session recordings are still not in the gdc vault

#

hmmm, Joachim wrote this month ago: ```the conversion happens at a scene level and you can pull in any data you like. For example you could read the scriptable object data and turn it into ComponentData or DynamicBuffer on an entity.

Next release will also have blob assets which is made for sharable immutable resource data. In that case, you could convert a ScriptableObject into a BlobAsset and then share it from multiple instances in the same scene.

BlobAssets are made for zero cost deserialization for large amounts of data. AnimationClip, CollisionMesh, CurveData is a good example of what we think belongs into a BlobAsset. ```

#

we already got those blob assets

#

I dunno if there was any official plan on making SO's convert to blobs

knotty radish
#

Blobassets are still a bit too unstable not like they crash or doesn't work but because there is custom implementation of them in each new package that Unity is making (like DOTS animation or Dots Physics)

#

In theory they are the perfect way to access const data for components

#

I want them for a lot of things like Colliders (already existing in physics but I'm waiting for the official update), AnimationCurves, SO (more like const struct of data), etc.

safe lintel
#

beginning to wonder if that gdc talk will be paywalled for a year or something

amber flicker
#

If I have any component with a public var attached to a gameobject and then use ConvertToEntity (set to ConvertAndInject) on that gameobject, as soon as I try and view the entity in the debugger I get a continuous: NullReferenceException: Object reference not set to an instance of an object Unity.Collections.LowLevel.Unsafe.UnsafeUtility.CopyPtrToStructure[T] (System.Void* ptr, T& output) (at C:/buildslave/unity/build/Runtime/Export/Unsafe/UnsafeUtilityPatched.cs:15) - such a nuisance - anyone else encountered it?

#

It's related to adding the component as an object to the entity and trying to show it in the inspector I'm pretty sure.. but knowing that doesn't help much

safe lintel
#

i think I saw someone else report this one a short while back on the forums

#

but I get it too

amber flicker
#

ok thanks @safe lintel - if it's not just me then I'm sure it'll get fixed soon πŸ˜„

safe lintel
#

ive seen a mention of it before that too so I wasnt inclined to bug report it

tawny kayak
#

Hi, Does ArchetypeChunk.GetComponentObjects() works correctly? I found that it always throw out of range exception when I used with ArchetypeQuery.Any.

crystal zephyr
#

For me it worked. How you are using it?

tawny kayak
#

Create two monobehaviour type components (MyTypeA,MyTypeB) and iterate chunk via component group with Any=MyTypeA, MyTypeB. Then access MyTypeA via ArchetypeChunkComponentObjects[index]. It throws out of range exception even its Length > 0.

#

EntityArchetypeQuery.All works without any problem. Only Any query makes issue.

#

It seems that ArchetypeChunkComponentObjects.Length > 0 even if the chunk does not have specified type.

mystic mountain
#

Ok so I'm back again with some long conceptual thinking. Going from the end usage point of view; I want a player that can pick up items, drop items, interact with objects - sometimes with items such that they are consumed. Now; how to do this in ECS, I basically have a interaction hierarcy of [interact with object(raycasts) > drop > pickup(raycasts)], where if first can't be done, it moves to second. Looking at the first "interact with object", the outcome can be various different things and should be expandable. So I think there has to be one trigger system that activate a system based on what interacted with, with a reference to the player entity. Next step is "drop", to see if I can drop I need some data component that keeps track if I'm holding anything. In the "pickup" I also need to keep track of what I'm holding. But the two last interactions also need to know if it interacted in the previous step(s), so I figure I need some type of bool along the systems to flag if it should be run or not, and then I also of course have specify that the systems should run in that order. Is this the right kind of thinking, or is there a simpler way to solve this?

amber flicker
#

hmm it depends a lot on specifics but reading the above, my main thought is that 'a bool.. to flag if a system should run'.. is essentially what components (tags) are for. So one system would be responsible for adding a 'pick-uppable' tag to all objects that can be picked up for example

#

then your raycast system would require that tag and only run when there are things that can be potentially picked up

mystic mountain
#

Hmm yeah, but it is within one frame, but I guess I can use a tag component for that?
Basically:

       System to check if we raycast hit with interactable objects (trigger other system with tag and reference entity to player)
              Interacteble object system running
       else (here we need some boolean tag)
             System to check if we are holding something to drop
                   ...
              else (need boolean tag again)
                     System to check if we raycasthit with pickup object```
amber flicker
#

It's hard to tell you exactly what your full architecture will look like without quite a bit of thought. That said, this is an example of how I'd be thinking:
Press interact -> Add [FindInteract] component to Player.
FindInteractableSystem doesn't run because it is set to exclude [HoldingInteractable] which the Player also already has.

#

You could also do things like an early out in your raycast system that checks 'Player.InteractPressed()' but it quickly runs into questions of whether you should be raycasting everything when interact is pressed, what optimisations you can do, whether you want a collider system etc

junior fjord
#

can anyone recommend a high performance linear algebra library in c#?

#

unfortunately the bust compiled unity mathematics only works up to dimension 4 😦

dull copper
#

what are you building that it doesn't cover?

#

new entities, hybrid, collections and jobs packages on staging

#

still waiting for new physics package πŸ˜ƒ

junior fjord
#

economic simulation @dull copper

#

I basically want to have z = Tx, where z is some characteristics that the agents want to fulfil (health, safety, food), x are the goods that they have and T is a technology matrix thing

dull copper
#

are there in general math libs that handle that kind of scenario? πŸ˜ƒ

#

(I have no idea, just curious)

junior fjord
#

yes sure

#

in python everyone uses numpy for everything numerical for example

#

in C++ you have plenty but there is not so much of one stand out I think

#

but I mean you basically have numerical libraries normally, that have a lot of optimization and matrix/vector methods already implemented in a very efficient way

dull copper
#

new packages now on regular registry

#

should show up in PM

junior fjord
#

a new entities package?

toxic walrus
#

preview 30

dull copper
#

AI planner is yet again outdated with new entities package

#

I can only imagine this getting more painful the more ECS dependent packages we get

#

as you need to satisfy the need for ECS version for all packages

#

and if some package gets left behind, people have to either manually upgrade it or stick only to older versions which have compatible packages for same Entities package

#

altho I expect that at some point the ECS API stabilizes enough so that each new version will not not change the API anymore

#

hmmm, apparently ComponentGroup is now EntityQuery

#

IJobProcessComponentData is IJobForEach

#

IJobProcessComponentDataWithEntity is IJobForEachWithEntity

#

I guess it's more consistent

#

easier to understand for new user

#

I kinda liked IJobProcessComponentData though as it literally told what it did

#

also EntityArchetypeQuery => EntityQueryDesc

#

OnCreateManager = > OnCreate

#

they did a full pass on the naming conventions I see

dull copper
#

Hybrid Renderer update is pure API update, there's zero new functionality beyond one new test file (Unity.Rendering.Hybrid.Tests/EndToEndStreamingTests.cs), actual content is 100% same besides the API naming changes

safe lintel
#

wonder if this fixes the debugger monobehavour bug

knotty radish
#

@dull copper did you see any new features on ECS ? (besides the renaming and other non-feature stuff) ?

dull copper
knotty radish
#

Yeah thought it wasn't out yet but it was

dull copper
knotty radish
#

I can't update to that version, they removed BufferArray which I was using 😦

#

The only way to get bufferaccessor is through chunks but there will be some cases you don't want to use chunks

dull copper
#
** Removed obsolete ComponentSystem.ForEach
** Removed obsolete [Inject]
** Removed obsolete ComponentDataArray
** Removed obsolete SharedComponentDataArray
** Removed obsolete BufferArray
** Removed obsolete EntityArray
** Removed obsolete ComponentGroupArray```
knotty radish
#

Yep, I replaced everything with their alternatives, only BufferArray is waiting for his successor

dull copper
#

BufferArray is deprecated. Use ArchetypeChunk.GetBufferAccessor() instead.

#

seems so yeah

#

if you really have to have it, you could probably just put the BufferArray changes back but it's kinda pain

knotty radish
#

I think that if they don't make a job just like the ToComponentArray I will just make mine, one way or another

worn stag
#

Is ECS still doesn't support string and bool?

tawdry tree
#

The newest version supports at least bool, not sure about string, but remember that someone talked about it or workarounds.

knotty radish
#

It does support strings but you need latest 19.1 and latest ECS

#

Bool wasn't a huge issue since you can just use a byte but strings are life saving

dull copper
#

It was some special struct for it?

knotty radish
#

Hum not that I know of

dull copper
#

NativeString etc?

knotty radish
#

Oh thought you meant instead of IComponentData

#

Yeah sure NativeString64 for example

#

I want 2 short term easy to add things for ECS at the moment: a lot more BlobAssets and that API extension for my Buffers

dull copper
#

I just want updated Unity Physics now as it broke with this new Entities package πŸ˜„

#

probably like few minutes to fix it manually but then Unity ships the updated package when it's done

safe lintel
#

hmm latest packages arent showing up on my package manager, any way to force it to see the stuff besides editing the manifest by hand?

knotty radish
#

If it's not published then it's not available yet

#

Should be in a few hours I guess

#

You do have staging in your manifest, right ?

safe lintel
#

no, regular non staging

#

0lento mentioned above they were on the regular registry but maybe they just arent visible then

tawdry tree
#

Which Unity version do you use?

safe lintel
#

2019.0b9

vale gorge
#

Aw, I am not a fan of the new naming for IJobProcessComponentData. It was descriptive.

tawdry tree
#

Then I don't think your version is it...

safe lintel
#

oops 2019.1.0b9

#

ah weird i had to close and open the pm to get it to show even though I closed and reopened the project already

dull copper
#
knotty radish
#

:000

#

I will go and ask for our access to GDC vault to be renewed now

dull copper
#

2019 videos are now up

#

luckily Unity sessions will be on the free side as Unity is a sponsor

frosty siren
#

What the most performant alternative for ComponentDataArray?
Alternative of ComponentGroup named EntityQuery brings us ToComponentDataArray(). Is it good way to replace ComponentDataArray?

knotty radish
#

Well technically, if you are in a use case where chunks are a possibility then use them

#

It will be better thant ToComponentDataArray since that is making a copy (bit slow and can't do it inside a job)

#

If you can't then just use them, just know that accessing BufferArray the same way isn't possible at the moment

dull copper
knotty radish
#

I feel like we are constantly spoiling ourselves by stalking Bintray (I know most of these announced things xD)

safe lintel
#

whew just updated everything, not as bad as I thought especially renaming the physics stuff

knotty radish
#

It's your fault @dull copper 😦

safe lintel
#

yeah i was expecting animation from the bintray stuff with gdc and i was kinda letdown when it didnt show up

dull copper
#

I don't think there was gdc session for animation

#

(could have been on the unity booth but those will appear separately to Unity Youtube)

safe lintel
#

i meant the dots animation, just making my way through the dots roadmap now

dull copper
#

I always assumed it would be the same thing as the c# jobified animation thing

safe lintel
#

well i assume there will be overlap but that rigging talk at a glance is reliant on the old monobehaviour/hybrid workflow and I was looking specifically for a pure ecs animation workflow

#

ok he mentions preview system hopefully end of the year for animation

dull copper
#

ah, I haven't watched it yet πŸ˜ƒ

safe lintel
#

at 19:00 or so

#

(in follow the dots)

knotty radish
#

Are you sure about that ?

#

Dots anim seems to handle skinned mesh

#

Which means that it should also handle rigging

#

Adding a conversion system for more complex rigging should not be very far

safe lintel
#

did you get the dots animation package to work?

knotty radish
#

I mostly read the code so haven't really tried that

manic aurora
#

is there no physics update that supports the api changes in preview-30 yet?

safe lintel
#

is my understanding correct here: if I have a Parent -> 1st Child -> 2nd Child (of 1st Child) and modify the LocalToWorld of the 1st Child, my 2nd Child doesnt take that into account when calculating its position?

#

@manic aurora yeah but its not too much renaming to update manually

urban rivet
#

3 year plan!

#

So first is conversion to subscene...

#

this is with us now but in a rough state

frosty siren
#

@knotty radish You said that ToComponentDataArray cannot be used inside a job, unlike manual iteration of chunks. Do you mean IJobChunk?

safe lintel
#

@frosty siren you can pass the resulting nativearray from ToComponentDataArray to a job

knotty radish
#

What thelebaron just said

frosty siren
#

@safe lintel yeah i know, but dzamani says "bit slow and can't do it inside a job" which means that we can't call ToComponentDataArray() inside the job of course. But getting ChunkArray which need for chunk iteration also impossible inside the job, so i want to specify.

safe lintel
#

well you can do it when you construct your job, not sure why you would need to do it directly inside the job?

knotty radish
#

What I meant was that literally can't call ToComponentDataArray in a basic IJob for IJobChunk you have access to ArchetypeChunkComponentType which gives you the arrays you need through chunk.GetNativeArray(RotationType) for example

frosty siren
#

Yeah i know, but if i want use for example IJobForEach i need to convert to NativeArray anyway

knotty radish
#

I was in a use case where chunks are bringing more overhead than performance so I needed to use ToComponentDataArray on main thread before using a job

frosty siren
#

Exactly what i wanted to read, thank u guys

knotty radish
#

Np

safe lintel
frosty siren
#

And a little stupid question. In CreateArchetypeChunkArray() and ToComponentDataArray() methods we have override with Jobhandle parameter. For what?

knotty radish
#

"This version of the function blocks until the Job used to fill the array is complete."

#

The version where you don't give the JobHandle will be executed and fill the array immediately

#

You could run them all together if you give them a jobhandle

#

(usually we want our arrays right now so haven't found a use case for that)

frosty siren
#

maybe if we have some sequence of jobs we can start preparing NativeArray at start for late jobs (but usually this jobs will work with same data)

knotty radish
#

Yeah it could work for that

frosty siren
#

Right now we have no way access dynamic buffers inside jobs except IJobChunk, yeah?

knotty radish
#

Either use chunks like you can find in the sample or use the IJobForEach

#

What I mean is you can't fill BufferAccessor, you have access to DynamicBuffer in a job

frosty siren
#

Sorry, don't understand second string of your message

frosty siren
#

It's simple sample of using IJobForeEach. My question is where can we get access to dynamic buffers?

#

I see that the only way is chunk iteration and combine with an IJobChunk, am i right?

knotty radish
#

At the moment to have DynamicBuffer in a jobs chunks are the way to go

#

Aria explains things better than I do

#

IJobForEach with access to dynamic buffer is coming soon

#

Or you can forget about jobs and use it with a ComponentSystem

#

(Not sure if it's obvious or not but I'm talking about latest ECS package, before that there was other ways but they are removed or deprecated now)

frosty siren
#

Or you can forget about jobs and use it with a ComponentSystem
It's a very bad idea with my project
(Not sure if it's obvious or not but I'm talking about latest ECS package, before that there was other ways but they are removed or deprecated now)
Yes, i'm understand πŸ˜„

gusty saffron
#

Is it possible to somehow get entity component data by a type?

// This is a ComponentDataProxy
Type proxyComponent = attribute.ProxyTarget;
// This is a IComponentData
Type dataComponent = attribute.DataTarget;

EntityManager.AddComponent(entity, proxyComponent);

// how to?
var data = EntityManager.GetComponentData<dataComponent>(entity);

// would like:
var data = EntityManager.GetComponentData(entity, dataComponent);

I'm only finding the EntityManager.GetComponentData<T>(entity); Could you somehow convert a Type to T ?
The point is that i want to add, get and remove components that I only know at runtime

dull copper
safe lintel
#

nice and vague 😒

dull copper
#

so, come back in 2022 and have something solid πŸ˜„

urban rivet
#

it's definately exp ieaseinout

#

someone used a cheeky spline for that and made stuff up (tm)

#

you're all fired

#

actually that graph hints at completion in 2023

#

its a 3 and half year plan :P

gusty comet
#

2022 wtf, I wanna get off this train.

#

@gusty saffron you can't convert a Type instance to a T type parameter. One is runtime, the other is compile time. You can only turn a type parameter to a type instance with typeof(T) but not the inverse. Maybe you could use reflection to call the necessary method but not sure if ECS TypeManager will catch that.

gusty saffron
#

@gusty comet thanks for the answer, I think i'll will have to comeup with a workaround untill it's added in entity manager

gusty comet
#

But then if you don't know the type until runtime, how would you avoid boxing?

#

Actually, does ECS devirtualize the IComponentData structs? Or is it proper only on the native side and we get shitty virtual calls inside component systems πŸ€”

#

I need to test if compiler ignores struct's virtual declaration if none of the members are actually virtual I guess πŸ€”

urban rivet
#

Yeah although the forum might answer, the developers like to discuss dots

gusty comet
#

I didn't think it would take them 3+ years to be honest

dull copper
#

It means probably that in 3 years, they got the whole engine in dots, production ready

urban rivet
#

I think that sounds right - and so would anyone else if they poked around inside the megacity demo

dull copper
#

It sounds like a realistic estimate tbh

urban rivet
#

we're talking full replacement for mono in 3 years? sounds reasonable tbh

#

i'd worry if they quoted less

#

we can use the bits as they come piecemeal

dull copper
#

This is why they put so much focus on hybrid

#

As we need the old unity still for many things

gusty comet
#

It feels like dots just only got traction from that tbh, they've been working on it for a year and a half already

#

I guess thats right considering addressable assets and input system isn't built for dots, not to mention visual scripting went back to the drawing board

untold night
#

honestly I'm shocked it's not 5, but all of the gains outweigh the need to wait that long:

  • Perf increases for features in DOTS, just by being IN DOTS. "Performance by Default"
  • Speed up engine feature development by moving it into C# and packages.
  • More features replaced = more users using it which justifies allocated more resources for conversion.
gusty comet
#

well it is 5 years in total though πŸ˜„

mint iron
#

well they're basically re-writing everything in unity, that's pretty bold, many companies would just sit back and tack on features which is the easy path.

tawdry tree
#

Honestly, my main takeaway from that graph is that late 2020 you should be able to do the majority of stuff in DOTS, meaning most fairly simple games can do pure ECS or ECS+some Mono, as opposed to the current Mono+Core ECS+Self-made logic ECS

junior fjord
#

unity says it cannot find CreateEntityQuery

#

I am updating 0.29 -> 0.30 and thought that is how I ought to replace GetComponentGroup

#

the field cannot be found in current context

#

what am I doing wrong?

solar ridge
junior fjord
#

exactly what I am following for the update, so I replaced GetComponentGroup with CreateEntityQuery

#

@solar ridge I am following that guide but unity says Cannot find field CreateEntityQuery in current context after me replacing GetComponentGroup with CreateEntityQuery

solar ridge
#

Hmm
I havent updated just yet so dont have the ability to check unfortunately

junior fjord
#

ok thanks nevertheless

#

if I set a component to readonly when creating the entity, will that then be basically constant data?

#

ah it is GetEntityQuery, I overread that

urban rivet
#

@tawdry tree games are shipped with dots already. 2019.3 goal means we will at least be able to generate a pure-dots runtime but I think I can see why it would easily need more. All the classical component workflows of unity need redoing....

but this does not mean some people need editor tooling, a lot of people just take the parts of dots they need - like for an RTS, you can take full advantage right this moment and ship.

dull copper
#

reply from Unity staff:

We will be releasing a new version of the Unity.Physics package next week when all features are completed (which will of course be compatible with Entities preview.30).```
#

so, updated Physics package next week

#

sounds like there are some changes to the physics feats itself too

urban rivet
#

limited 3 stacks? ;)

#

has been pushing hard for limited stacking

dull copper
urban rivet
#

I don't dislike the UI

#

But I'm not sure that level of control is even slightly wise

#

Why is it still sorta-component based ?

#

it'd be better to use broad markup

#

basically defining something elsewhere like "all these objects fitting these criteria are static"

#

like how ecs works with filtering

#

why divert from the dots thinking ? filtering is a natural part of ecs, so why wouldn't we define filtering for conversion ?

#

handling every single thing one by one per "object" is surely what we escape from doing, it's more work, it's a design debt, because you can't broadly change behaviour without touching every single one.

#

and you want to set more things more of the time less uniquely, than things uniquely, less of the time

amber flicker
#

That certainly looks... challenging. Think I need to see that in a larger context to get my head round how that's what you'd want.

safe lintel
#

how would it look with broad markup?

urban rivet
#

well you'd probably want to identify things as static or not, via a tag, and that tag easily can be used to deliver a whole bunch of options, rather than micromanaging the whole bunch of options itself

#

I mean I think we've all been there where we abuse prefabs right now or want to group select a lot of stuff and then try to change their settings in one go

#

this is fine but when projects get larger you incur a debt of forgotten settings and so on

#

we're only human

#

I guess I'm thinking more these days about having all my control local

safe lintel
#

i think just by going component tags could be just as messy, i kinda dislike looking at some of my entities in the debugger already

hollow sorrel
#

is it possible to use ecs physics with gameobjects? e.g. have a physics shape on a gameobject and have it update the gameobject transform from the entity or something

dull copper
#

I dunno if other samples do the same

hollow sorrel
#

thanks i'll check it out

gusty comet
#

Is there a way to process elements in a dynamicbuffer similar to IJobProcessComponentData?

#

Got an entity with a IBufferElementData implementation attached to it and can't find a nice way

#

Closest seems to be doing something like IJobProcessComponentDataWithEntity, manually get/walk over the buffer

#

But that doesn't look right/is probably slow

untold night
#

That is the simpliest performant way right now. If you want absolute performance, look at IJobChunk, ArchetypeChunkBufferType<T> and BufferAccessor<T>

#

Here's a working example:

[BurstCompile]
        private struct AgeBuffersJob : IJobChunk
        {
            public ArchetypeChunkBufferType<ButtonEvent> ButtonEventType;
            public ArchetypeChunkBufferType<MoveEvent> NumpadEventType;

            public int MaxBufferAge;

            public void Execute(
                ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                int chunkCount = chunk.Count;
                
                BufferAccessor<ButtonEvent> buttonAccessor =
                    chunk.GetBufferAccessor(ButtonEventType);
                BufferAccessor<MoveEvent> numpadAccessor =
                    chunk.GetBufferAccessor(NumpadEventType);

                for (int i = 0; i < chunkCount; i++)
                {
                    AgeBuffer(buttonAccessor[i]);
                    AgeBuffer(numpadAccessor[i]);
                }
            }

            private void AgeBuffer<T>(DynamicBuffer<T> buffer)
                where T : struct, IBufferElementData, IInputAgeEvent<T>
            {
                int bufferLength = buffer.Length;
                for (int i = 0; i < bufferLength; i++)
                    buffer[i] = buffer[i].IncrementAge();

                var range = new int2();
                
                for (int i = bufferLength - 1; i >= 0; i--)
                {
                    if (buffer[i].GetAge() >= MaxBufferAge)
                    {
                        range.x = i;
                        range.y++;
                    }
                    else
                        break;
                }

                if (range.y > 0) 
                    buffer.RemoveRange(range.x, range.y);
            }
        }
dull copper
#

heh, release notes have this error: IJobProcessComponentData renamed to IJobForeach

#

should read IJobProcessComponentData renamed to IJobForEach

#

spend stupidly too many minutes chasing down why it didn't work before I realized it had capital E

#

that teaches me to copy paste

#

anyway, got Unity.Physics and the physics samples updated to new Entities syntax

#

no surprises here, just straight forward renaming and fixing the entitymanagers

#

but.. it does crash the editor now on the vehicle sample after short while πŸ˜„

#

ah, I think it's Burst .10 crashing it

#

same with .9

#

.8 is stable

safe lintel
#

when unity crashes and has to be reloaded, annoyingly it always reverts back those physics changes

#

just thought to make a backup folder of the package

dull copper
#

ah, that'll happen even without crashing for the next start

#

never make changes in PackageCache

#

instead move the package from cache into your Packages folder

#

and make it writable

#

that way the api updater can do it's work + you get to keep your modifications

safe lintel
#

yay no more renaming

dull copper
#

heh

safe lintel
#

i think i did that like 5 or 6x now

dull copper
#

I've worked a lot on customized package a lot so I know most of the workarounds

#

basically if you throw a package in packages folder, you don't even have to take it away from manifest, it'll override the manifest value for that same package

#

and at the same time, since every local package inside that folder gets always included, you don't have to have those packages in the manifest at all if you don't want to

#

as another topic

#

wonder if Unity plans to implement some interpolaton setup for this physics package

#

I mean, I can do that manually myself, just wonder if they have it planned

safe lintel
#

like smoothing out movement?

dull copper
#

it's rather simple to do if you have visuals transforms and physics transforms treated separately

#

yeah

safe lintel
#

i literally just got over this hump earlier today

dull copper
#

altho right now the whole Unity Physics movement is wonky due to it running things way too fast

#

it's a bug from the simulation group change

safe lintel
#

did physx have interpolation?

dull copper
#

I put a hacky fix for that but it's still wonky

#

physx itself doesn't have interpolation itself afaik, but every game engine that does fixed timesteps for physics does have some interpolation on it's own, including Unity

safe lintel
#

the way the new hierarchy works kinda boggles my mind but I think ive got the hang of it

#

im guessing unity's built in wont and leave it up to the user, it just sounds so bare bones from all the talk

#

or leave it to havok

dull copper
#

well, it's no big issue, I can do that really quickly

safe lintel
#

still hoping they relent on having it stateless, or having state optional

#

i want my stacking 😦

dull copper
#

there's this weird stuttering on the new physics samples vehicles, it's like something isn't updating the transform in right order to the simulation (like it randomly gets older physics step result)

#

they have this script on LateUpdate that updates the rigidbody position from ECS world and sets the transfor to gameobject scene's gameobject with the relevant components

#

I tried to put the update script to the regular update to guarantee it's done before ECS runs next time (ideally it would be after it but this way it would just bring one frame lag) but it still stuttered

#

I'll try messing with the lateupdate and script execution order still

#

I'm sure this is sorted out on the next weeks release, just curious what causes this

#

it's really obvious it's broken if you drop the physics update rate to 10 - 20 Hz, it's just not obvious if you step it on same update as rest of the ECS like by default

#

I have also interpolation code for this but it's useless if the source data keeps jumping around

junior fjord
#

how do I debug Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak ?

dull copper
#

ah, the wonkyness I saw is sourced from the camera movement script

#

@junior fjord have you the most recent unity version?

junior fjord
#

I have DeallocateOnJobCompletion which is the right thing to do for TempJob, right?

dull copper
#

that message got spammed all the time in past

junior fjord
#

I think I have the new beta 09

dull copper
#

ah

junior fjord
#

yes 2019.1.b09

#

that is the most recent one right?

dull copper
#

you get the warning if you don't run your own scripts?

#

could be some error elsewhere

junior fjord
#

ah very good tip

#

can I somehow easily disable my systems?

#

or disable a specific system?

dull copper
#

I wouldn't know, maybe someone else here does πŸ˜„

junior fjord
#

ok I'll just comment the whole file out for now πŸ˜„

junior fjord
#

I mean I am not sure if that is my problem

#

I am now commenting out all of my systems to see if the error persists

dull copper
#

I think I saw those errors occasionally on project startup on other project, which doesn't really use much ECS atm

junior fjord
#

hmm yes also with everything commented out I get the error

dull copper
#

dunno if 2019.1 got it

#

could help on tracing where it happens

junior fjord
#

yes it has it

#

thanks man!

#

hmm but still the same output:
Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
and
To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp. This will output the callstacks of the leaked allocations

dull copper
#

lol

#

that's not helping

junior fjord
#

no not really πŸ˜„

dull copper
#

heh, the "solutions" people find there

#

I mean, disabling feat x on the scene is just having a side effect that some internal job has time to execute in time etc

#

I think people used to get that error even when they did persistent allocations too

#

seems like someone messed up something πŸ˜„

junior fjord
#

I restarted unity and now I do not hav the errors anymore

#

somehow even though I commented the systems out they where still running

#

now they are not running - no errors. So at least I know the problem is on my side

#

and now I activate the systems one by one

#

thanks for the good tip πŸ˜ƒ

#

haha ok now after activating all systems again everything just works - no errors anymore πŸ˜„

#

seems that all I needed was a unity restart for some reason

upper tiger
#

@junior fjord sometimes when I comment out a system like that, I reimport the script to make sure it worked.

junior fjord
#

how do you do that @upper tiger ?

tawdry tree
#

Right click->reimport?

upper tiger
#

Right-click the script and select reimport

junior fjord
#

oh yes thats easy, thanks

tawdry tree
#

It's so easy you won't even think of it!

upper tiger
#

Had the same problem before, cant really recreate it, but now I do it always

junior fjord
#

but somehow in my case I didn't even have to change anything, when I restarted unity and commented everything back in it just worked without the leak message

#

@tawdry tree πŸ˜„

upper tiger
#

Sometimes you can create a leak, and despite changing the code to "correct code" the problem still persists in the editor somehow until you restart

#

Again, not sure what causes it but I've had that issue when debugging leaks

tawdry tree
#

Sounds like some compiled code persists despite the original being changed, possibly in memory if restarting the editor fixes it.

junior fjord
#

ok thanks for the hints

#

if I have a lot of different entities which all have an inventar (how much gold, wood, chairs, houses, .... they posess), what would you recommend to save that?

#

so number of entities is big and number of different items will probably be 50-300

#

but should be data driven so I cannot just make a component Inventar with
AmoutGold:
AmountWood:
etc

upper tiger
#

wouldnt it just be data?

#

like ints

junior fjord
#

yes

upper tiger
#

each entity has a ComponentData called Inventar

#

I would think thats a fine way to do it

junior fjord
#

and how do I save the stuff in inventar so that I can have a runtime-differing number of goods?

upper tiger
#

you do an entityquery based on Inventar component, then you update the values in a foreach loop or something to what you want based on conditionaal logic

junior fjord
#

(the goods are entities themselves too, so basically I need a map human-> good for each human entity and each good entitiy and weights on these connections that represent the amount)

tawdry tree
#

Inventory: list/array of InventoryEntry
InventoryEntry: key/value pair of reference to the resource and the amount

neat magnet
#

Anyway to generate random float between 0-1 inside job with unity.mathamatics ?

junior fjord
#

rng.NextFloat() I think

upper tiger
#

right so you want each inventory to have a entity references to other entites in the game

junior fjord
#

where rng needs to be a Random thing

#

@neat magnet

neat magnet
#

Okay I tride something like this but how can I generate random seed

junior fjord
#

@tawdry tree how do I put lists/arrays into a componentdata? I thought only DynamicBuffers are supported now

neat magnet
#

I am getting same value random struct

junior fjord
#

@neat magnet
rng = new Random(1);
rng.NextFloat();

#

yes this way you always get the same random number

#

since you always throw in the same seed

#

rng = new Random(1);
makes an rng object which can give you a sequence of numbers that seem random (it is always the same sequence if you don't change the seed 1)

neat magnet
#

Is it possible with noise struct to get diff random numbers ?

junior fjord
#

rng = new Random(1);
rng.NextFloat();
rng.NextFloat();
rng.NextFloat();
gives you 3 different random numbers
rng = new Random(1);
rng.NextFloat();
rng = new Random(1);
rng.NextFloat();
rng = new Random(1);
rng.NextFloat();
gives you three times the same

rng = new Random(1);
rng.NextFloat();
rng = new Random(2);
rng.NextFloat();
rng = new Random(3);
rng.NextFloat();

gives you three different random numbers

solar ridge
#

Just send time as the seed

junior fjord
#

exactly you can time-seed it

solar ridge
#

Either the ticks of the game, current pc time in ticks etc

junior fjord
#

but actually just reuse the rng

#

that is what you'd normally do if you want many random numbers

#

and if you want the sequence of random number to differ each time you start the game, do what @solar ridge said and seed it with the start time or something random

solar ridge
#

And you could also make a random struct. and use that to make seeds for other random structs

#

That way you dont poll time each time

junior fjord
#

@tawdry tree @upper tiger how would I put a list or variable sized array inside a component data (which I need for your proposals as I understand it)

neat magnet
#

@junior fjord @solar ridge Thanks:)

solar ridge
#

Err

#

Wouldnt that be a Dynamic buffer on an entity?

junior fjord
#

ok yes that is what I am using on other places, just wanted to go sure that there is actually no other good way πŸ˜„

tawdry tree
#

Yeah, I haven't used ECS much, but the precise data type doesn't matter, just that you can allocate it at arbitrary size, and that you can either change the size or realloc later.
Hence why I said list/array.

solar ridge
#

In component data, it has to be fixed

#

if using an array

upper tiger
#

not sure if it will help, I havent done much with collections in ecs yet. But you could potentiall set it to be fixed size if you wish to enforce maximum inventory sizes

#

that way you dont need to dynamically allocate

solar ridge
#

BUT then you also carry the burden of if you don't use any of the slots of the array you are wasting memory

junior fjord
#

DynamicBUffers do a mix of preallocation and dynamically resizing as I understand it

#

they preallocate some fixed stuff and if you go over it dynamically allocates the other space you need

tawdry tree
#

As long as you don't resize too often it shouldn't be a problem, and in this case I doubt you'd actually add or remove elements more than at most every second per entity. Change the values? Sure, but fully add or remove? nah.

junior fjord
#

unfortunate that I can't put hasmaps into the componentdatas

#

I will often need to lookup how much of good x does entity y have

tawdry tree
#
[
  "resourceName1": 2,
  "resourceName2": 1,
  [...]
]

In this case you'd increment or decrement the number, but adding new resources would probably be rare, and you don't need to remove it when it reaches 0, instead you can have a rarely run job to do cleanup (remove all resources with 0 amount).

#

Unless the list becomes very big, I don't think it costs that much to just iterate through and do a lookup, but you probably want to compare on something that is not a string.

neat magnet
#

I tried Datetime.now.milliseconds as seed but getting burst error that system.timezoneinfo class is ont supported

junior fjord
#

yeah I will compare the entities directly

tawdry tree
#

So you could generate IDs(/GUIDs) for each resource and use that as the keys

junior fjord
#

I mean I already have IDs (entity ids of the goods)

#

@neat magnet

tawdry tree
#

But then of course you would need to lookup the entity. Not sure how/if you can directly store references to entities

junior fjord
#

convert it to an int somehow

tawdry tree
#

Using the entity ids as is should be fine

junior fjord
#

but the right way to do it is to do
rng = Random(1);
rng.nextFloat();
rng.nextFloat();

etc, i.e. reuse the same rng object

tawdry tree
#

Just make sure you get the version, too. maybe a struct?

struct EntityId{
  int EntityId;
  int VersionId;
}
junior fjord
#

and for development purposes you even often prefer to pull the same random numbers. Then when you go to production you can put some other "random" seed (like time) instead of 1 there, so that the randomness unfolds differently each game @neat magnet

neat magnet
#

I am converting it (uint) and I am getting different numbers with it but it gives above error on startup

junior fjord
#

seeding a new object every time you need a new random number is a bad approach

#

@tawdry tree isn't the Entity struct basically exactly what you have there?

tawdry tree
#

I wouldn't know

junior fjord
#

I thought that Entity probably implements ==

#

I think it is exactly that πŸ˜ƒ

#

@neat magnet I seed my Random object in the main thread and then pass it to the jobs instead of doing it in the job

#

that should remove that error

#

@tawdry tree @solar ridge @upper tiger thanks for the help

neat magnet
#

@junior fjord Thanks

upper tiger
#

Does anyone know of a place where I can see exactly what parts of unity have ECS support?

junior fjord
#

@upper tiger I do not know.. does anything besides the basic rendering and some physics stuff have it yet?

#

what is the best practice way if I want to store entity names (strings)?

tawdry tree
#

Uhm, a component called EntityName?

#

Unless of course you want that name to be attached to something more meaningful, in which case you put it in a component with whatever that meaningful stuff is.

junior fjord
#

yes but component cannot store strings

tawdry tree
#

Didn't they make a blittable string variant recently?

junior fjord
#

ah they did? I'll try to find it thanks

#

hmm blittable strings google does not help me πŸ˜„

tawdry tree
solar ridge
#

Yes NativeString is blittable

#

keep in mind you need to use the variant that best matches the size

#

ie NativeString64 is for 64 byte strings (so names would be ok)

dull copper
#

@junior fjord yeah, I get that error randomly sometimes when I start the editor, it's not consistent

#

when I start the editor again, the errors are gone... so I've pretty much ignored them now πŸ˜„

#

I mean, on the other project where I get those

#

I wish they sort that out as I'd love to get only relevant warnings on the console

junior fjord
#

ok thanks again

#

yeah in future I'll try to restart first

junior fjord
#

but is it actually clever to have a component for the names?

#

they will make the entities considerably bigger and the chunks can hold less then

#

and I basically will never really need to loop over them, most of the time I will just need access entity -> name when the user is displaying something

frosty siren
#

Where can i read about
IJobExtensions
IJobParallelForExtansion
IJobParallelForDeferExtansion
IJobParallelForFilter
JobParallelIndexListExtension
JobStructProduce
There is no word about it in documentation(

mint iron
#

ECS documentation at the moment seems to be 'read the source code' 😦

frosty siren
#

=\

urban rivet
#

Such is what it means to be an early adoptor

#

i remember getting leap motion prototypes in 2014

#

that was tricky and interesting

#

part of intel's dev thing

#

but painful if you are in production :D

dull copper
#

I got local git repo for entities and hybrid packages so I can quickly browse the diffs between the versions

#

tried to ask Unity for permission to upload these to github as their companion license doesn't really forbid me from doing it but it's been a radio silence so far

#

the diffs per package are really handy

#

just wish Unity would do it by default

urban rivet
#

Some parts of Unity are private repos though, I am on some of them, you need to ask for access because the code might not be legal outside of the company

#

they need the companion license

#

if you are a regular contributor imho it makes sense for them to include you, i just think by default they assume you're OK with how it is

#

if you need legal stuff tho i doubt unity will budge much

dull copper
#

considering how much things I dig from public ones, I doubt they'd want to give me access to the closed ones πŸ˜„

frosty siren
#

Could you advise me pls, i need to know which ComponentData was changed, for this i use manual chunk iteration and versions comparison. But this approach gives only information about what chunk was changed. So to know which element was changed i define additional ComponentData with bool field inside and find what entity in chunk has true. Is there any solution that is not so ugly? (except compute all elements in chunk of course)

tawdry tree
#

@junior fjord A bit late, but in general (not just ECS) I'd advice you to separate larger unchanging data away from the stuff you operate to (ie. gameObjects or entities).
To elaborate, for something like a Minecraft game I would have a storage of all blocks with their associated stats and names and whatnot, and a block out in the world would only be an ID, a reference to the Data for whatever block is there, and the state, if relevant. That necessitates going to your 'database' when you need to access that data, of course, but it means you have a single authorative source of information, stored once.
It should be loaded to memory because you really don't want to read from disk every time you need to check what the name of the block the player is looking at (or w/e). In the Mono paradigm I'd use ScriptableObjects for this. Still might, and just have a load-time system find and read them all to what would essentially be an in-memory read-only database.

frosty siren
#

Is it efficient now to use EntityManager property in ComponentSystems or it's better to cache?

safe lintel
#

are Temp allocators working yet?

#

oh thought Allocator.Temp was auto disposed

vapid glen
#

Yeah, I have them working in a project, you still need to call .Dispose() on them,but unity will throw warnings if you dont

untold night
#

in 2019.1b+ in a job, they don't need to have dispose called on them

safe lintel
#

strange, if I do ```csharp
var playerInputs = m_Player.ToComponentDataArray<PlayerInput>(Allocator.Temp);
var input = playerInputs[0];
playerInputs.Dispose();

#

it spits out errors about it not being a tempjob

untold night
#

ToComponentData, etc I think have to be temp Job and using deallocateOnJobCompletion

If you're doing a manually allocated NativeArray, Allocator.Temp should work fine.

safe lintel
#

this is just in the main thread

knotty radish
#

ToComponentDataArray run a Job

#

So it has to be a TempJob

#

It's also making a copy so it may not be the best way to achieve what you want

safe lintel
#

what do you mean run a job?

knotty radish
#

I mean that it's scheduling and running a job in order to fill your Array of playerInputs

safe lintel
#

oh

#

huh never knew that

#

so chunk iteration is the fastest way to do this?

knotty radish
#

ChunkIteration or ForEach

#

Depends on your use case

safe lintel
dull copper
junior fjord
#

@tawdry tree thanks for your elaborate answer. so you say the ecs should only contain stuff I'd need pretty often in the game and "extra/big" data which I only need sometimes should be better stored in some kind of database?

junior fjord
#

is it normal that quite some of my components are just links to other entities?

amber flicker
#

@junior fjord I'd say that's quite normal, yes. One thing that can be a pain though is trying to keep the memory layout linear - i.e. if iterating through a chunk and you go and fetch data from another entity (say via CDFE), my understanding is that will break the cache coherency but that's just a small note - I use it a lot.

hollow sorrel
#

are you supposed to use systems for things with one entity? feels wasteful to be iterating over 1 specific thing

junior fjord
#

@amber flicker yeah it will make cache problems obviously but somehow often I see no other way

#

but at least if it is always the same data that you get then it will be in the cache anyways

knotty radish
#

@hollow sorrel well you can make a system that will handle multiple one entity jobs and run them all concurrently. Would not change the fact that you would have one job per entity but at least it will be only one system. But if your task can be burst compiled then it's worth even for one entity (in theory)

hollow sorrel
#

ahh true

#

to make it more concrete was thinking of stuff like player controller

#

or like updating time of day

#

also feels messy to have a buncha one off systems in entity debugger especially when there's no search

knotty radish
#

By default there is little to no overhead when you use a System, there is one when Scheduling a Job and when you fetch your data so having a system that doesn't do much is "ok" and it also keep your base code harmonious by having everything in a system

#

But you could totally handle that in some other way, it's up to you

frosty siren
#

@hollow sorrel why can't u just use mono for this?

tawdry tree
#

@junior fjord Something like that, yeah. The idea is to avoid duplicate data. SharedComponent has that job in ECS and could hold data itself, refer to an entity, or maybe even refer to a ScriptableObject, if you could make that work smoothly. In the Minecraft example, you could have a BlockType sharedComponent with immutable data, for example.

hollow sorrel
#

@frosty siren isn't the whole point of pure ecs to avoid gameobjects

tawdry tree
#

The tooling isn't quite there for pure ECS for all purposes just yet, and if it's significantly easier to use hybrid, then that's a consideration to take

dull copper
#

you can fully avoid gameobjects in 2022 according to later DOTS roadmap πŸ˜„

frosty siren
#

@hollow sorrel totally agree with Hodhandr

dull copper
#

whatever works is what we go with before that

hollow sorrel
#

yeah but i imagine the tooling isn't gonna change for single entity systems

#

ecs has existed before unity ecs

dull copper
#

making pure ECS would be so much more appealing if we actually got proper editor for it

#

was hoping for some ETA for full ECS scene editor at GDC but they were pretty quiet about it

#

DOTS only standalone runtime was targeted to 2019.3 so I'd guess they plan editor to somewhat same timeframe

frosty siren
#

I don't understand the problem. ECS approach decrease update overhead and makes data accessing more efficient, jobs gives u multithreading. But if u need just 1 object with original logic u can use just mono with accessing to another data through entity manager. It will be the same i think.
So my question is "why is it so important to make really pure ECS?"

dull copper
#

it'll be more important once we actually get that DOTS only runtime :p

#

as you can't have hybrid there

hollow sorrel
#

i mean if we ignore unity
how are you supposed to deal with single entity systems
should it just be a POCO instead

frosty siren
#

oh, ok

dull copper
#

but it'll be optional for long time for sure

#

but for example, if you need tiny runtime, you need to stick to DOTS / pure ECS in the future

hollow sorrel
#

also isn't there overhead in setting component data on systems from monobehaviours and vice versa

dull copper
#

but we are now talking about things that exist year from this moment (2019.3 can be out in half year but first version will always be iffy)

hollow sorrel
#

yea i'm just talking from a ecs architecture standpoint not unity ecs specifically

#

apart from the overhead thing that's unity specific

urban rivet
#

Well I do suspect that come 2022 we will likely have everything dots by default with the monobehaviour approach being gently sidelined but not depreciated. The reason this is inevitable is because all tech going forward is dots first and mono second: see physics, audio, visual scripting, AI (GOAP) and so on. whole of unity is going dots.

I expect nothing to be ready by 2019.3 except for the ability to make a pure dots standalone build, so I guess at or after that point the idea of a Tiny changes from Tiny-ecs to just a unified editor (we apparently get a new editor UI in 2019.3 as well)

#

I guess even if one bridges mono with dots, perf should still be roughly the same.

#

(same as regular mono)

hollow sorrel
#

is it? instinctively would think bridging is slower than just mono because you have that step in between

urban rivet
#

That's right but

#

dots is so much faster I'm expecting it to basically break even going by current hybrid

#

maybe still be faster overall

#

I mean you don't really need to talk to every entity

#

just the results or high level

#

hybrid just performs like regular monobehaviour C#

#

However if I wanted to calculate a thousand agents doing kinky stuff I would so that in ECS land, and that can run alongside fine

tawdry tree
#

I mean, if you wanna code a giant orgy in Unity, you do you. In fact, heavy simulationist games are one amusing bug away from that at any point in time, so...

frosty siren
#

Is there approach to set default element count of dynamic buffer?

worn stag
#

Pure ECS editor is already in Tiny package, just need to wait for C# support(Q2)

junior fjord
#

@frosty siren you can set [InternalBufferCapacity(3)]
when defining the bufferelement

dull copper
#

burst 1.0.0p11 on staging

#

wonder if this one is stable again

#

p9 and p10 just crashed my 2019.2 editor

urban rivet
#

sigh

dull copper
#

p8 is default for newest entities package I think, so that's a nonissue right now

fringe sinew
#

I yet again don't think I get something

#

Let's say that I have 3 systems: AABB checking system, damage receive system and a damage casting system.

fathom trout
#

@urban rivet whats this about GOAP ? is Unity doing GOAP with dots?

fringe sinew
#

How would I, in this example, have AABB check which entities are intersected, store that data and then have the casting system write to receive systems based on the component data?

#

I get that some kind of a long-term nativearray is necessary, so it would exist for the entire lifespan of the component.

#

But what to store there?

fathom trout
fringe sinew
#

Entity IDs or something? Is that even a thing?

#

Well, I mean, it technically is a thing, since entities are basically IDs

#

But how do I get it then?

amber flicker
#

@fringe sinew I'm not sure if this is helpful... you can certainly create arrays, or hashmaps with entites as keys.. but before that, possibly in your situation AABB System adds a component (e.g. IsIntersecting) to intersecting entities, removes for ones that aren't. Then cast system would require that component and all would work. That said though, if you're dealing with thousands of entities that are changing every frame, you may prefer to do something like an Intersecting component with a bool set to true or false that the casting system early-outs depending on the value.

fringe sinew
#

This is an interesting method, but I don't think it'll be suitable for my case.

urban rivet
#

@fathom trout GOAP is released and available (check experimental forums) and is dots based yeah

#

most unity things got pushed back a bit because everything has to be a first class dots citizen going forward

#

I will guess the decision came from joe or someone who knows really, all the parameters

#

there's no new stuff for mono land I don't think, no new unity features being built for it.

dull copper
#

well, beyond the things that are already in preview probably

wintry birch
#

hi, i'm trying to make a highlight system for selected units / objects, so whenever the user clicks on an unit, a green circle is added around it, so what i tried is creating a Highlight component, a HighlightProxy and attach it to the highlight prefab. I added that prefab as a child to the unit prefab, so i think i need a way to check if the parent of my Highlight component is selected (Selection component with a bool) to enable/disable the highlight somehow
so my question is, how can i get a parent component from a child?
i'm using a JobComponentSystem with a IJobForEach<Highlight> job right now, by the way
I started with ECS yesterday, so sorry if this is a trivial question πŸ˜… i couldnt find much documentation about that, i hope i used the right terms (:

frosty siren
#

@wintry birch how u made units clickable in ECS?

wintry birch
#

getting the mouse position on click and checking if it's close to the unit position

frosty siren
#

how much units u have?

wintry birch
#

i'm playing around with 3 or so lol

#

why? is that bad for performance?

frosty siren
#

"why" what?

wintry birch
#

why did you ask about units