#archived-dots
1 messages Β· Page 70 of 1
ugh, sorry
i was wondering "why is this so slow??!", accidentally produced 2 million entities π
do I understand it right that this dynamic buffer thing is basically a replacement for making a BufferInt component for example?
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?
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
the new samples are great @full stirrup
they start from very very easy and are well documented
i was looking at some older examples using 'Attach' which is now deprecated i think, how do we do that now?
Parent
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?
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
Position is now Translation
Renamed for consistency sake with splitting a matrix into translation/rotation/scale or anything beneficial to it?
Do I use position or positionproxy?
As recursive said use translation since its going to be the newer version (assuming)
Where is that?
What is a βentity component systemβ?
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)
@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
@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.
@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
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.
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;
}
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
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.
@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.
Translation
That is what I meant, I just miss-typed it here
I mean it's there so... maybe your project's messed up somehow?
Do you do custom Assembly Definitions?
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
Eh first
So you do "using Unity.Transforms;" at the top... then you try to add a Translation to a job... correct?
Yup
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?
the newer packages are all on 2019.1
yeah 2018.3.10. I just restarted Unity and Entities jump from preview 8 to 24
I don't know when Translation was added unfortunately.
But yeah that would be your problem. Old package.
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 ! π
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)
Alright. Bit of a shame no bool yet.
Yeah most people have made their own bool class.
Although it's good if I don't need to now. Hmm.
I am just going to use an int for now π
@untold night How good is Burst at packing multiple bools btw?
I haven't tested it. Out of habit I'd just make a bitfield enum though
Yup
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
it work now with normal c# bools
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.
@fringe sinew with Entities.ForEach
Okay, how do I fetch data from another entity's component to do, for example, AABB?
I think there's a misunderstanding
AABB would have you looping through all entities anyway to check if their AABB box overlaps the current one
Exactly. How do I loop a current box over every other box component?
How do I get other boxes to check against?
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
What if it's chunked? What if I don't want to use jobs for it?
Probably be a bit mental if you wanted to run computed collision detection on a single thread
Can confirm that
Would need to look at the boids example
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
Theres IJobChunk as well
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
Not only does everything go wrong, but completely unrelated things that previously worked suddenly stops working, that kinda 'more than everything'?
@fringe sinew you could get all the ComponentData for a ComponentGroup by doing ToComponentDataArray and compare that with a particular entity in a job
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?
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
Thank you very much
you only need to do GetComponentGroup in OnCreateManager or OnStartRunning
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
is there a way to have fixed size arrays inside a component?
or is the only way now to use these dynamic buffers?
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
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?
take a look at this example https://github.com/Unity-Technologies/DOTS-StreamedInstancingSample/tree/master/Assets
Joachim uses a lot of dynamic buffers in there
thanks
ok, this file shows how he does it https://github.com/Unity-Technologies/DOTS-StreamedInstancingSample/blob/master/Assets/ProceduralScatter.cs
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
another example https://forum.unity.com/threads/example-ijobprocesscomponentdatawithentity-and-ibufferelementdata.584548/#post-3899059
man Im dying for that Connect the dots roadmap to be released
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 π
not sure, was just using that second link last night as Im just starting to do stuff with buffers π
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
yeah that's odd, i saw your post but i have no idea what would cause that
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
could be worse, when i shoot a weapon in a recent build the camera stops working
id take gi perf spikes over that!
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
can I somehow pass in a length to a nativearray (like reserve in C++) and then just add elements?
I only see very few methods here https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html
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
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?
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
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
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?
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?
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)
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
what do you mean by the capacity version?
There should be (was) a version that took a size then an allocator
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
Sec
ah no I found it
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
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
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:
- For each Job calculate how good it is at it (by comparing its own Properties to the Jobs OptimalProperties)
- 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
- 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
Ctrl+Dot (.) or alt+enter(not always?) should give you intellisense suggestions in VS
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?
Ctrl+dot is one of my most used hotkeys on my job, since I'm working with systems I don't fully know/understand
I really like ctrl + click to go to definition of the class
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 + .
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 π
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
yeah I always buy UK keyboards they are nice for programming
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
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
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)
sorry I don't fully understand that. I should have a job that is idle most of the time?
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
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?
what does that have to do with idle CPU time?
or did I missunderstand something there?
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
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
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
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
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?
A Person has a Profession. A Profession refers to a Mission. Something like that?
yes
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.
ah no it is not like that
it is not that jobs need to be done
it is an economy simulation
More of their mission in life. Not so much their single run
they want a job to make money
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?
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
--Only time they change profession is when it is demanded. not when work runs out--
no it is something that happens sometime, but not too often
like maybe at most every 10-20 minutes per human in game
I misunderstood, then. I understood it as a Rimworld/Dwarf Fortress type colony builder
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 π
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
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 π
Run once as opposed to run repeatedly
It SOUNDS neat
And yeah, the art of boiling down your concept to as limited a scope as possible while asking for help is a difficult one
yes they will have their profession until something "big" happens (price change in the stuff they are producing)
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
ok, I'll formulate it again a bit better
yes thank you for trying to understand it, I see that it was prone to missunderstanding
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.
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
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 π
π
Translation & Rotation are depreciated?
the SharedComponentDataProxy is on the outs
@gusty comet no
says they are when I add them to an object - not in console only in the "Add Component" dialogue
@gusty comet the monobehaviour proxy that they supply are deprecated in favour of the new conversion workflow, the actual IComponentData themselves are not
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.)
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.
i think there is only the unite presentation
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.
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.
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
something else
its goap ai
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
im hoping the perf is good enough for some sort of rimworld scale simulation
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???
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
That error is talking about Pure.Stages, Pure.CurrentData looks fine
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?
what is stage
[Serializable]
public struct Stage
{
public float scaleAmount;
public float secondsInStage;
}
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
Oh, got it. Thank you. I also just pulled the docs up so will read up on them
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>();
So this should work right??
[Serializable]
public struct Stages : IComponentData
{
public DynamicBuffer<Stage> Value;
}
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,
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
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!
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.
How stable is 2019.1?
its really hard to tell between all the preview packages im using π¦
@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>>
{ ... }
... }
Right now there's 2 ways to use DynamicBuffer<T> with Jobs:
- Use ArchetypeChunkBufferType<T> with IJobChunk.
- 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.
What class is GetBufferFromEntity<T> in?
Should be in JobComponentSystem.
oh I see. I was trying to access it from inside a IJobProcessComponentData
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.
IJobProcessComponentDataWithEntity<...> is what you want then
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?
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?
@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.
@amber flicker Thanks! I'll try out the Entity parenting : )
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
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?
what problem are you having?
Hybrid is required for that
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
Is it the updated boids example (there is one, right?)
Otherwise it could just be a bug between versions
I basicly copied both SpawnRandomInSphere[...].cs and used it my own project just to discover that warning + no spawning of any entities
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.
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
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
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?
You ... "can"
but Native containers are nonblittable
Examples of arrays would be the DynamicBuffers and you add those to the entity
@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.
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
Thanks @solar ridge
Hey guys, for which usecase this method is ment: chunk.GetComponentObjects
the Object stuff in ecs is usually referring to classic unity components
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?
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?
Sadly i can't answer your questions π but ill add one of my own. Any ideas why i would be getting * solved and it had nothing to do with the error description. :SAssertion 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().
Guessing its checking if the number of jobs is 1
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
did you click the refresh dissassembly button
that was it, thanks π
How do you do rendering with ECS?
I can't find anything on it but obviously it can be done.
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.
Right... but which components are required for rendering...?
im not sure if theyre all required but mine have RenderMesh, RenderBounds, WorldRenderBounds and ChunkWorldRenderBounds
Hmm, I can't find those ones... maybe I don't have the right namespace?
im on the latest, its possible theyre new 2019.1/Entities preview29
Unity.Rendering.RenderMesh
oh.. well.. I actually installed the Hybrid Renderer package and now have that namespace... π
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...
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
@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
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
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 π
You would think, but task manager says GPU is at 7% and CPU is at 80%
you are running pure right?
ah in which case (sorry, lots of guessing here), are you using Burst? Possibly paste your job code here
Here is the script for the system it self https://pastebin.com/ptX66Xsq
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
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
^That's probably more useful than just seeing the usage, though. It will let you see what uses all those resources
Yeah sure
Yikes that's a lot of time spent in RootLocalToWorld
I am assuming that is due to scaling the entities?
are there deep hierarchies?
Nope, this is what I did spawn them https://pastebin.com/Vc0qdceC
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?
Yeah it is settled. That is how it is the entire time (Ran for at least 6 seconds before taking screenshot)
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?
Attached build?
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
Hybrid renderer package is 0.0.1-preview.4
I am on unity 2018.3.11f1
ah.. ok... this is probably why I'm seeing much better numbers
2019.1.b09 & preview.9 for me
Hmm, let me trying opening it up in a project using 2019
May your upgrade path be smooth and your gains plentiful
Slightly less than smooth...
@amber flicker Got it to work! Mostly... now I just need to figure out why the rendering doesn't seem to be working.
Nice! @vale gorge probably because your entities are missing a LocalToWorld component or something
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?
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
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!
No problem - glad to hear it's much improved π Have fun!
Thanks! π
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?
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)
oh....
it is indeed one of those 'I can't believe that's not the first thing I tried' facepalm-moments.. Thanks π
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 π¦
well if they arent doing anything shouldnt be a big deal right?
though it does sorta clog up the debugger
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 
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/
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?
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
I wanted to avoid gameobjects entirely if possible
with the current conversion workflow, gameobjects make it easy to set up entities
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
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)
@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
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.
beginning to wonder if that gdc talk will be paywalled for a year or something
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
i think I saw someone else report this one a short while back on the forums
but I get it too
ok thanks @safe lintel - if it's not just me then I'm sure it'll get fixed soon π
and yea, you're right - last post (today at 1:45pm) - https://forum.unity.com/threads/new-subscene-converttoentity-workflows.638785/page-2
ive seen a mention of it before that too so I wasnt inclined to bug report it
Hi, Does ArchetypeChunk.GetComponentObjects() works correctly? I found that it always throw out of range exception when I used with ArchetypeQuery.Any.
For me it worked. How you are using it?
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.
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?
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
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```
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
can anyone recommend a high performance linear algebra library in c#?
unfortunately the bust compiled unity mathematics only works up to dimension 4 π¦
what are you building that it doesn't cover?
new entities, hybrid, collections and jobs packages on staging
still waiting for new physics package π
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
are there in general math libs that handle that kind of scenario? π
(I have no idea, just curious)
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
a new entities package?
preview 30
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
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
they made a post about the api changes https://forum.unity.com/threads/upcoming-api-changes-in-0-27.656245/unread
wonder if this fixes the debugger monobehavour bug
@dull copper did you see any new features on ECS ? (besides the renaming and other non-feature stuff) ?
Yeah thought it wasn't out yet but it was
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
** Removed obsolete ComponentSystem.ForEach
** Removed obsolete [Inject]
** Removed obsolete ComponentDataArray
** Removed obsolete SharedComponentDataArray
** Removed obsolete BufferArray
** Removed obsolete EntityArray
** Removed obsolete ComponentGroupArray```
Yep, I replaced everything with their alternatives, only BufferArray is waiting for his successor
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
I think that if they don't make a job just like the ToComponentArray I will just make mine, one way or another
Is ECS still doesn't support string and bool?
The newest version supports at least bool, not sure about string, but remember that someone talked about it or workarounds.
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
It was some special struct for it?
Hum not that I know of
NativeString etc?
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
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
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?
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 ?
no, regular non staging
0lento mentioned above they were on the regular registry but maybe they just arent visible then
Which Unity version do you use?
2019.0b9
Aw, I am not a fan of the new naming for IJobProcessComponentData. It was descriptive.
Then I don't think your version is it...
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
https://www.gdcvault.com/play/1026146/
https://www.gdcvault.com/play/1026171/
https://www.gdcvault.com/play/1026147/
Join Martin Gram, the Product Manager for our Data-Oriented Technology Stack (DOTS), and guests as they spotlight the latest DOTS features. They will also unveil some exciting high-level systems coming your way in 2019.
At Unite Los Angeles, the Unity sample project Megacity demonstrated the powerful capabilities of our new Data-Oriented Technology Stack (DOTS) and provided many
Are you developing instant games? Come meet members of the Project Tiny team, who will give you a quick walk through of our new Data-Oriented Technology Stack (DOTS) and its strengths for creating instant games. At the end of this session, you'll...
2019 videos are now up
luckily Unity sessions will be on the free side as Unity is a sponsor
What the most performant alternative for ComponentDataArray?
Alternative of ComponentGroup named EntityQuery brings us ToComponentDataArray(). Is it good way to replace ComponentDataArray?
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
I feel like we are constantly spoiling ourselves by stalking Bintray (I know most of these announced things xD)
whew just updated everything, not as bad as I thought especially renaming the physics stuff
It's your fault @dull copper π¦
yeah i was expecting animation from the bintray stuff with gdc and i was kinda letdown when it didnt show up
@safe lintel linked the rigging talk on #π»βunity-talk
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)
i meant the dots animation, just making my way through the dots roadmap now
I always assumed it would be the same thing as the c# jobified animation thing
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
ah, I haven't watched it yet π
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
did you get the dots animation package to work?
I mostly read the code so haven't really tried that
is there no physics update that supports the api changes in preview-30 yet?
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
3 year plan!
So first is conversion to subscene...
this is with us now but in a rough state
@knotty radish You said that ToComponentDataArray cannot be used inside a job, unlike manual iteration of chunks. Do you mean IJobChunk?
@frosty siren you can pass the resulting nativearray from ToComponentDataArray to a job
What thelebaron just said
@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.
well you can do it when you construct your job, not sure why you would need to do it directly inside the job?
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
Yeah i know, but if i want use for example IJobForEach i need to convert to NativeArray anyway
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
Exactly what i wanted to read, thank u guys
Np
heres a simple IJobForEach where I also use ToComponentDataArray to read stuff that the job doesnt automatically fetch https://pastebin.com/bYZ9LqBw
And a little stupid question. In CreateArchetypeChunkArray() and ToComponentDataArray() methods we have override with Jobhandle parameter. For what?
"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)
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)
Yeah it could work for that
Right now we have no way access dynamic buffers inside jobs except IJobChunk, yeah?
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
Sorry, don't understand second string of your message
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?
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)
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 π
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
nice and vague π’
so, come back in 2022 and have something solid π
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
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 comet thanks for the answer, I think i'll will have to comeup with a workaround untill it's added in entity manager
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 π€
Yeah although the forum might answer, the developers like to discuss dots
I didn't think it would take them 3+ years to be honest
It means probably that in 3 years, they got the whole engine in dots, production ready
I think that sounds right - and so would anyone else if they poked around inside the megacity demo
It sounds like a realistic estimate tbh
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
This is why they put so much focus on hybrid
As we need the old unity still for many things
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
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.
well it is 5 years in total though π
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.
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
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?
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
Hmm
I havent updated just yet so dont have the ability to check unfortunately
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
@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.
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
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
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.
how would it look with broad markup?
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
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
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
@hollow sorrel if you look at https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/UnityPhysicsExamples/Assets/Demos/6. Use Cases/RaycastCar that's what they do there for vehicles
I dunno if other samples do the same
thanks i'll check it out
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
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);
}
}
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
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
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
yay no more renaming
heh
i think i did that like 5 or 6x now
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
like smoothing out movement?
it's rather simple to do if you have visuals transforms and physics transforms treated separately
yeah
i literally just got over this hump earlier today
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
did physx have interpolation?
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
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
well, it's no big issue, I can do that really quickly
still hoping they relent on having it stateless, or having state optional
i want my stacking π¦
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
how do I debug Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak ?
ah, the wonkyness I saw is sourced from the camera movement script
@junior fjord have you the most recent unity version?
I have DeallocateOnJobCompletion which is the right thing to do for TempJob, right?
that message got spammed all the time in past
I think I have the new beta 09
ah
you get the warning if you don't run your own scripts?
could be some error elsewhere
ah very good tip
can I somehow easily disable my systems?
or disable a specific system?
I wouldn't know, maybe someone else here does π
ok I'll just comment the whole file out for now π
ecs physics samples still do the deallocate the same way:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/0df25da86c755fecd83758fc0b334cfff9487bf7/UnityPhysicsExamples/Assets/Demos/6. Use Cases/CharacterController/Scripts/CharacterControllerComponent.cs#L96
so apparently nothing changed regarding that
now that I said that, I must have leak detection turned off so I don't see these π
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
I think I saw those errors occasionally on project startup on other project, which doesn't really use much ECS atm
hmm yes also with everything commented out I get the error
2019.2 at least has also this option
dunno if 2019.1 got it
could help on tracing where it happens
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
no not really π
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
Reproduction Steps: 1. Import attached project. 2. Open Test scene. 3. Build and Run. 4. In Standalone Build Data files, open output...
seems like someone messed up something π
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
@junior fjord sometimes when I comment out a system like that, I reimport the script to make sure it worked.
how do you do that @upper tiger ?
Right click->reimport?
Right-click the script and select reimport
oh yes thats easy, thanks
It's so easy you won't even think of it!
Had the same problem before, cant really recreate it, but now I do it always
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 π
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
Sounds like some compiled code persists despite the original being changed, possibly in memory if restarting the editor fixes it.
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
yes
each entity has a ComponentData called Inventar
I would think thats a fine way to do it
and how do I save the stuff in inventar so that I can have a runtime-differing number of goods?
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
(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)
Inventory: list/array of InventoryEntry
InventoryEntry: key/value pair of reference to the resource and the amount
Anyway to generate random float between 0-1 inside job with unity.mathamatics ?
rng.NextFloat() I think
right so you want each inventory to have a entity references to other entites in the game
Okay I tride something like this but how can I generate random seed
@tawdry tree how do I put lists/arrays into a componentdata? I thought only DynamicBuffers are supported now
I am getting same value random struct
@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)
Is it possible with noise struct to get diff random numbers ?
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
Just send time as the seed
exactly you can time-seed it
Either the ticks of the game, current pc time in ticks etc
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
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
@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)
@junior fjord @solar ridge Thanks:)
ok yes that is what I am using on other places, just wanted to go sure that there is actually no other good way π
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.
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
BUT then you also carry the burden of if you don't use any of the slots of the array you are wasting memory
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
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.
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
[
"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.
I tried Datetime.now.milliseconds as seed but getting burst error that system.timezoneinfo class is ont supported
yeah I will compare the entities directly
So you could generate IDs(/GUIDs) for each resource and use that as the keys
But then of course you would need to lookup the entity. Not sure how/if you can directly store references to entities
convert it to an int somehow
Using the entity ids as is should be fine
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
Just make sure you get the version, too. maybe a struct?
struct EntityId{
int EntityId;
int VersionId;
}
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
I am converting it (uint) and I am getting different numbers with it but it gives above error on startup
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?
I wouldn't know
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
@junior fjord Thanks
Does anyone know of a place where I can see exactly what parts of unity have ECS support?
@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)?
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.
yes but component cannot store strings
Didn't they make a blittable string variant recently?
ah they did? I'll try to find it thanks
hmm blittable strings google does not help me π
Found the message I got it from:
https://forum.unity.com/threads/strings-are-usable-in-component-data-now.644647/
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)
@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
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
Where can i read about
IJobExtensions
IJobParallelForExtansion
IJobParallelForDeferExtansion
IJobParallelForFilter
JobParallelIndexListExtension
JobStructProduce
There is no word about it in documentation(
ECS documentation at the moment seems to be 'read the source code' π¦
=\
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
@mint iron https://github.com/Unity-Technologies/EntityComponentSystemSamples, https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/index.html and actual package sources are best ways to go now, yes
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
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
considering how much things I dig from public ones, I doubt they'd want to give me access to the closed ones π
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)
@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.
Is it efficient now to use EntityManager property in ComponentSystems or it's better to cache?
Yeah, I have them working in a project, you still need to call .Dispose() on them,but unity will throw warnings if you dont
in 2019.1b+ in a job, they don't need to have dispose called on them
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
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.
this is just in the main thread
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
what do you mean run a job?
I mean that it's scheduling and running a job in order to fill your Array of playerInputs
i think a lot comes from https://bintray.com/unity
@gusty comet https://bintray.com/unity/notifications especially is golden, but Unity also has bunch of github repos
@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?
is it normal that quite some of my components are just links to other entities?
@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.
are you supposed to use systems for things with one entity? feels wasteful to be iterating over 1 specific thing
@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
@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)
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
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
@hollow sorrel why can't u just use mono for this?
@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.
@frosty siren isn't the whole point of pure ecs to avoid gameobjects
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
you can fully avoid gameobjects in 2022 according to later DOTS roadmap π
@hollow sorrel totally agree with Hodhandr
whatever works is what we go with before that
yeah but i imagine the tooling isn't gonna change for single entity systems
ecs has existed before unity ecs
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
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?"
it'll be more important once we actually get that DOTS only runtime :p
as you can't have hybrid there
i mean if we ignore unity
how are you supposed to deal with single entity systems
should it just be a POCO instead
oh, ok
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
also isn't there overhead in setting component data on systems from monobehaviours and vice versa
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)
yea i'm just talking from a ecs architecture standpoint not unity ecs specifically
apart from the overhead thing that's unity specific
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)
is it? instinctively would think bridging is slower than just mono because you have that step in between
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
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...
Is there approach to set default element count of dynamic buffer?
Pure ECS editor is already in Tiny package, just need to wait for C# support(Q2)
@frosty siren you can set [InternalBufferCapacity(3)]
when defining the bufferelement
burst 1.0.0p11 on staging
wonder if this one is stable again
p9 and p10 just crashed my 2019.2 editor
sigh
p8 is default for newest entities package I think, so that's a nonissue right now
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.
@urban rivet whats this about GOAP ? is Unity doing GOAP with dots?
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?
oh i guess it must be this, https://github.com/Unity-Technologies/otto will dig into it
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?
@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.
This is an interesting method, but I don't think it'll be suitable for my case.
@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.
well, beyond the things that are already in preview probably
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 (:
@wintry birch how u made units clickable in ECS?
getting the mouse position on click and checking if it's close to the unit position
how much units u have?
"why" what?
why did you ask about units