#archived-dots
1 messages · Page 104 of 1
my questions are going to be a bit basic because I'm returning to ECS after a long time of not using it
what is DOT?
but! so I should be able to put a material and a mesh in a sharedcomponentdata and inject that into a job, right?
did they deprecate [Inject]?
ah, it seems they did. how do I inject into jobs and job systems now?
Hm. this ISharedComponentData has no boxing conversation into componentdata. i have no idea how to do that
@last lintel you should look through the official samples (see pinned post). The API has changed a lot since [Inject] was a thing.
thanks! this documentation is much better than it was in 2018
though it seems like I can't run Graphics.DrawMeshInstanced in job's Execute because drawmeshinstanced definitely takes a Mesh and not a RenderMesh, and won't even let me pass it RenderMesh.mesh
I really suck at this
you can't call Unity API from jobs
I thought you could if you added WithoutBurst() ?
WithoutBurst() lets you use managed types (so e.g. new MyClass()), but most Unity APIs are not thread safe and can't be used in jobs
so if I want to draw lots of quads from a job, is there a good way to do that at the moment?
what if you Run() the job on the main thread
prepare the data in jobs, call DrawMeshInstanced from the main thread
right
ah yeah that sounds like the way to do it
(depending on the use case it may be better to manually batch the quads into a single Mesh btw)
Guys now that you are here, does anyone has some insight with my issue in the Physics channel?
I would definately try batching map tiles into a single mesh
I'm not too familiar with it, but how would I separate materials?
You don't, you use texture atlasses and draw with the same material
what i'm saying is, if I'm turning a thousand quads into one big quad, how do I draw the materials inside it? (again, pretty new at this)
You are not turning them into one big quad, you are turning them into a single Mesh containing all the quads. Then use uv coordinates into a texture atlas so each quad has the correct texture
If the map tiles don't change really often this is pretty much guaranteed to be faster than drawing each tile separately
all rendered with the same material/shader correct?
yup
can you even have a mesh rendered with multiple materials
yes, although i vaguely remember unity's inspector warned me against it one time haha
'multiple materials on the same mesh are bad for performance' or some such
I think I vaguely remember something like that too
Not really (Unity has the concept of submeshes, but that's basically just multiple meshes packed into the same Mesh object (this is a bit bigger topic and mostly irrelevant to what we are talking about))
well you can put a material and its normal map onto the same mesh
gotcha
so how do I go about batching meshes?
there are tutorials online 😛
great 😛
if I'm making a 2d game where I have a player entity that needs a collision shape, body and sprite, should those all be components on the player entity? or entities of their own that reference the main player entity to update their transforms?
do you have a reason to make them separate?
mainly scaling the sprite independently of the collision box
or rotating it
if I make them separate entities though it becomes difficult to query them doesn't it
hmm
I guess essentially I'm unsure how the traditional GO transform hierarchy is supposed to translate to entities
I did notice that if you select "convert and destroy" it creates an entity for each child GO, but "convert and inject gameobject" only creates one entity for the parent GO
Ok, so coming back to game dev after a fews years I'm now getting acquainted with DOD approaches. I was indie so I only used OOP and it was fine. Also having ML experience it's not something very alien to me. But then it begs the question: can games be made to run on TPUs? 🤔
I've noticed I think just the first time I call DefaultWorldInitialization.DefaultLazyEditModeInitialize() after editor launch I get a >45s wait and noticed the audio thread appears to be taking all the time? Any insights @digital scarab? 😅 (audio thread could be a red herring - perhaps actually an initial compile of some sort). Interestingly I don't see this if I make a code change before launching the editor (so it does a compile on launch) so this is likely just noticeable due to my longer compile times.
So trying to work with the new DOTS Sample project from Unity and looking at the youtube videos of the sample, I noticed in the video's they talk about the [GenerateAuthoringComponent] they put on the ComponentData. However in the project they have seperate code files for Authoring. Does anyone have any experience with this and can explain why they choose to do it that way?
writing your own authoring lets you do a bunch of things the generated one doesn't do, like process data at conversion time, reference prefabs etc
Thanks @worldly pulsar that confirms some of my assumptions!
Anyway we can synchronize changes made in Editor on a Authoring IComponentData with converted and injected Entity? GameObjectEntity workflow is deprecated and I don't want to write a system to synchronize the changes back.
how do you set an entity's name via code
@glass tiger EntityManager.SetName?
thanks
I was checking on the entity object itself but I guess the entity manager is responsible for maintaining the name mapping
any planes to add support for a multi tag file ? something like this ( Tags.cs ) :
using Unity.Entities;
[GenerateAuthoringComponent] class Tag_Player : IComponentData { }
[GenerateAuthoringComponent] class Tag_Rocket : IComponentData { }
[GenerateAuthoringComponent] class Tag_Field : IComponentData { }
[GenerateAuthoringComponent] class Tag_PickUp : IComponentData { }
[GenerateAuthoringComponent] class Tag_Locked : IComponentData { }
It gets a bit too much when there are heaps of single lined files over time.
.
recon i can make something like a custom menu item that would re-generate those files from a scriptable object, but hope there is something quicker tho
You can have something like enum value in MB with IConvertGameObjectToEntity and store all this Tags in single file
@hollow jolt they are working on it, some editor limitation apparently
@worldly pulsar
?
that was easier then expected
is there any reason to extend ComponentSystem now that the AlwaysSynchronizeSystem attribute exists for JobComponentSystem
basically no - JCS should cover all your needs and there's been mention that ComponentSystem may be depreciated at some point in the future
makes sense
@last lintel did you make any headway? i've done a bunch of mapping to meshes myself. it's fairly easy in a basic sense, which is more or less overkill anyways, but can be improved upon a bunch
they are planning on removing it because the internals of JCS changed, it uses the faster paths (burst) for structure changes. that and they want people to use the simpler lambdas
its kinda like v4 of systems
the what now? are we meant to always use jobs? or just JCS is just going to be the default and pass through the inputdeps
you can do main thread non job work in JCS now
simply .WithoutBurst() and .Run() instead of schedule
.WithStructureChanges() if you want to create/edit entities though the EntityManager
You can still use burst on the main thread for the record
yeah, but most main thread work is likely monobehaviours and what not, cant burst that
The only features missing from JCS that CS has I can think of are Entities.WithAll<X>().ToEntityQuery() (no direct equivalent in JCS), and using generic types in the WithAll and friends (so
class IncrementMyComponentSystemFor<T> : ComponentSystem {
JobHandle OnUpdate(JobHandle deps) {
Entities.WithAll<T>.ForEach((ref MyComponent m) => m.Value++);
}
}
will work in the old CS, but the JCS equivalent won't compile
both cases are rather unusual
You can use WithStoreEntityQueryInField if you want the query generated by the foreach
tbh generics like that are really anti dots
I've seen quite a few people on the fourms doing that, and its just never made sense why you would ever need to do that
entities scares me. haven't tried using it yet 😛 seems kinda complicated.
it isn't
interfacing to the rest of the unity world is complicated
the whole point of entities is to be dead simple data processing
Yeah it's not too complicated, the hard part is just getting used to the API
@zenith wyvern I guess you can do Entities.WithAll<X>().WithStoreEntityQueryInField(ref _query).ForEach((Entity e) => {}).Run(); in OnCreate, but... yuck... (both ForEach and Run are mandatory)
Which with the new ForEach is dead simple
most unity devs seem to not be used to fluent api (aka functional programing chaining of function returns)
Well the query is created at compile time so you can use it before the actual Foreach for whatever you were trying to determine, so there shouldn't be any need ot run an empty foreach
It's a bit magicky but it works
pretty sure you can still just pass in a query for one part, but you have to not have overlaps with the rest of your foreach
Oh this isn't to pass in the query, but to capture the implicit query generated by the Foreach's withall/withnone expression
So you can use the query beforehand to determine if the foreach should be run in the first place
what
Yeah it's a bit weird but it works great
@zenith wyvern there is a way to do this without the .ForEach(...).Run() part?
oh I think I know what your talking about
you should really just clean up your query conditions into your oncreate
instead of extracting one with a code generated body
@worldly pulsar The WithStoreEntityQueryInField will ensure that, at compile time, your query contains the implicit query generated by your ForEach
So whatever you needed the query for, you can use it before the foreach ever runs
just create the matching query in your create and CalculateEntityCount() on that
not the one for the foreach
Exactly
so question. if say, i want to do the entities thing, requiring 2 components, and optionally having a third... would it be .WithAll<T1, T2>().WithAny<T3>() ?
yes, but you have to decide which ones data you have to look at
if you wanted to look at T1, T2 you would put those as ref's in the foreach lambda (the second to last part)
because those are implicitly as part of the query
I guess you would need a CDFE to check if the optional one exists in that case?
@low tangle I know, I just miss the old Entities.WithAll<X, Y>().WithNone<Z>().ToEntityQuery(); Typing ComponentType.ReadOnly gets tiresome 😛
yeah, its weird for me since I've got 180 systems that all are explicit querys in the on create for readability
then the foreach's are just using the query in them
all of them just With(query)
so I can't bulk move all classes over easy, I have to reconstruct the querys in foreach syntax
oh, yeah, the .With(query) is another feature missing from JCS
latest version of unity absolutely destroyed the game lol
did someone had the same problem ?
really hoping they add it, might need to ask on the fourms @worldly pulsar
just been so busy getting this game update out to even think about doing that
im talking about 2019.2.18f1
"absolutely destroyed" is not a very specific problem
sorry hum i meant the physics broke
That's still not very specific
its a minecraft clone im doing as a learning project and walking on cubes now bump my character
btw @low tangle why would you say having generic systems/generic methods in a system is anti-dots?
well that's not the only problem but the rest is very difficult to describe
it's broken in a very weird way :(
Is this a dots problem? It sounds like you might want to ask in #💻┃code-beginner or #⚛️┃physics
well the game is 100% ECS so i thought it could be useful to go here
What version of entities and dots are you using? I'm not sure the latest versions work on 2019.2 do they?
this is all my opinion, but so far dots has been all about concrete handling of everything, direct stream processing, so it makes no sense to 'handle all the cases' (generics) when I should just be handling the cases my game will actually be handling. so far its been way more sane to deal with / reason about what the game is doing. @worldly pulsar
well it worked perfectly with 2019.2.4f1 :x
we were using the 0.2.0 but my friend tells me its also broken in 0.2.4
I dont have a single generic system or generic classes really. I've got a single 'magic' thing I'm working on, which is my network serialization, but thats using explict code gen'd bodies, like unity's networking high level api. also for refrence, thats like 1/20 of all systems in my game.
I'm pretty sure since 0.4 of entities they require 2019.3. That doesn't mean it won't work, but that there's no support for older versions
ok so i'll try 2019.3 thanks
Generics is nice just to save typing
It does usually make your code way harder to read though
That's very fair, but depending on what you're doing and if you're the only one who's touching it, it can be a huge benefit
I can see why they wouldn't go out of their way to support it though
I've been work on this codebase for a year and a half now. I dont need this shit harder to read
Wow, that must have been annoying to keep that up to date with the changing ECS apis
it has been yeah
Is this the terrain thing you mentioned before?
I've used it since the first preview, which was very worth it
oh no, that was just for fun
thats a little project for parsing and loading all of oblivion from their data formats
loads esm's and esp's directly
where do i use WithStructureChanges()?
if you use EntityManager.CreateEntity .AddComponent .RemoveComponent
Any time you're creating or destroying an entity or component
Sorry to interrupt, but I need a bit of a sanity check: if I have a shared piece of data (lets call it a big bitmap, or something) that I need to share between many entities, but I need to use the VALUE in a job, I shouldn't use ISharedComponentData, but perhaps a BlobAssetReference stored in a ChunkComponentData? The naming conventions are weird...
Probably if you're resizing a dynamic buffer too, not sure about that
BlobAsset is exactly what you want @left oak
yeah but i don't see WSC in the intellisense. i'm using entities 0.5.0p17
is there a newer one or something?
Thanks, @low tangle
let me double check for you
I've found intellisense is a bit iffy with the Foreach. Usually it fixes itself if you create the barebones structure of the Foreach first
What I found is the semicolon after .Run(); tends to fix the Intellisense
I'm using visual studio 2019 16.1.6 with almost no issues on it
I've gotten a few crashes on a c# plugin but its usually a enormous file that does it
I'm on 15.9.18 and it definitely fails to fill out Entities functions until I actually complete the foreach first like Rett said
oops i forgot to change it to a JCS
maybe they've updated it a bit then
visual studio thankfully is getting slimmer with updates so there less painful
I think 2020 isn't too far out now
dang lookin good
ok, so i run it, but thats a void, wheres the jobhandle to return?
Show the code
.Run() executes on main thread so doesn't return a job handle
^
ah. well thats what i want anyways
to schedule a job use .Schedule()
i see that now
i'm just trying to convert a componentsystem to a jcs to try out this fancy stuff 😛
if you don't have any dependencies to return (and have [AlwaysSynchronize] on your system) you can just return default;
From the docs
AlwaysSynchronizeSystem can be applied to a JobComponentSystem to force it to synchronize on all of its dependencies before every update. This attribute should only be applied when a synchronization point is necessary every frame.
All I know is it can cause dependency errors if you're trying to use dependent objects on the main thread
If you don't use it
sorry i need to read the docs, but making sure i'm looking at version i'm currently using is always a pain
always make sure to click that blue "view latest version" button at the top
i didn't know that existed! thanks
np
Does this imply that a JCS doesn't synchronize with its dependencies unless instructed to?
it synchronizes automagically according to the dependencies the job uses doesn't it
well the sync comes from the order handles are chained right? so in a JCS with no handle made (not using a job) there's noting to tie it o
It's only if you need it to synchronize on the main thread specifically. Otherwise you would be passing in inputdeps to the .Schedule
if your job reads one piece of data and writes to another, it's aware of those dependencies and uses them to manage synchronization
oh, so this attribute should be paired with some main thread code you're running?
as I understand it AlwaysSynchronizeSystem is an attribute you always want to use for JCSes that are meant to run on the main thread
Basically if you use a component in a main thread job called with .Run, and that component is used in a threaded job anywhere, then you will get a dependency error unless you have [AlwaysSynchronizeSystem]
yeah
It's very weird and not intuitive, hopefully they will come up with something better
once you know the rule of thumb it's not too bad
but yeah it's weird when you're learning
a single entity should not/cannot ever have multiple of the same type of component, correct?
As far as I know yeah
I was making a component for the player's inputs for a particular frame, and then the player entity would keep track of a list of them to have a record of what the inputs were
I guess in this case the right way to do it is a single component that has an array that holds all the input frames
and those input frames are just structs, not IComponentData structs
Yes, in most cases when you would want that you can use multiple entities or a dynamicbuffer or a fixedarray
hmm haven't looked into either of those yet, I'll check now
NativeQueue could be good if order of inputs is important
but that'd be stored in a system i guess
if you only have one player, then it'd be fine
I'm still unsure of the different types of components beyond the simple general purpose ones
If you want the data to be read anywhere outside the system you're better off avoiding nativecontainers, else you end up in dependency hell
yeah I'd like to keep it generic to support multiple players
oh yeah, ive got a summer home there, @zenith wyvern
I'm not tracking inputs, per se, but the effects of inputs in the world as Transactions, which need to be able to play both forward and backward, for undo/redo functionality. That has been a headache.
As I understand it the physics systems has simliar problems to solve, you can always look to it for inspiration
That's a good insight. I'll have to dive into that package a bit.
Although, I tried to do the same to understand how RenderMeshSystemV2 actually gets the RenderMesh values to work on, which I deeply regret: like staring into an old god's eyes.
Yeah I couldn't make heads or tails of that either. For people smarter than me I guess
theres a video of mike talking on how it works
could probally dig it up if you want to understand it a bit better
mike's voice is so reassuring, he always lulls me into a false sense of understanding what he's talking about
@low tangle I would be interested in that if you don't mind
trying to track it down but I cant remember which megacity video has it
How we used ECS to display a large environment in the Unite LA MegaCity streaming demo.
Slides: https://www.slideshare.net/unity3d/lod-and-culling-systems-that-scale-unite-la
Speaker: Mike Acton (Unity Technologies)
Is that it?
Mike Acton is a rockstar for programming
the only gotcha on this is that subscenes morphed slightly since this
to make them more general instead of just for megacity
but this is roughly/almost exactly how rendering is done in v2
Gotcha, thanks for the information! Although I feel like this may be obsolete once we get the promised renderer updates in a few motnhs
if only they could morph V2 to make it more general instead of just for megacity -_-
I'd still like to know how it works
it wont exactly be out dated
the updates will be somewhat similar to this (this is dead simple and good)
skip to 16:10
Huh, it's weird to hear him talk about how simple it all is considering how truly hard to read that code is
exactly
the data is simple and simple to understand, but the code is much harder
but its like the quality triangle
fast, readable, cheap to write
Pick 2
yup
Makes sense, I appreciate you letting me know this exists too, thanks. Should be helpful
one nice thing about dots though, when you do it right you can optimize later on when you actually need it. so I've personally been choosing readable and cheap for all of my systems / logic. and only very few are heavily optimized (namely the ones that scale up to a million ish entities in need)
Yeah I remember when I was doing the instanced sprite renderer thing I ended up using generics to save some typing, it ran great but the code ended up being a nightmare to decipher. I think I may take your approach moving forward, hahah
this was also a great video to watch
https://www.youtube.com/watch?v=9MuC3Kp6OBU
This in-depth talk covers entity serialization to and from disk, how we built seamless play mode streaming and efficient editor workflow, and what a separate ECS world can do for you.
Slides: https://www.slideshare.net/unity3d/ecs-streaming-and-serialization-unite-la
Speake...
I'll add to to the queue, thank you
np
the way I reason about it is, do I really need x?
if its no or maybe, I delete it end of story
I've got everything in a repo so if I ever want it back I get it
I'm a firm believer in deleting every bit of code that isn't needed. and generics is kinda like generating a infinite amount of code variations
but there are totally cases where it works really well, like serialization
well that was indeed quite easy.. and simplified a LOT. thanks everyone!
At times I've found myself wondering if I shouldn't just write my own code generation to solve certain problems. As bad as generics can be I wonder if that wouldn't be much worse
code gen is just another form of meta programming, and a pretty powerful one
most of dots uses code gen in some form, and the networking library's high level parts are all code gen
it seems really natural for some reason, really fitting to solving some problems
I mean if you think about it in the lisp way, code is data too, which should be manipulated if it helps solve your problem
It always feels weird to me in C#. There's not really many built-in language features to make it easier that I've seen
reflection?
code gen happens in the editor not at runtime, so might as well use its power there
That's true. I guess if I'm already creating a readability problem, might as well go all in trying to make it as easy on myself as possible
the code generated doesn't have to be unreadable
I was more worried about the generation code itself
Hello, i was trying to play with Dynamic buffer and i encountered an issue, so here are my scrips: this is my main monobehaviour script to spawn entities,
{
var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
var archetype = entityManager.CreateArchetype(
typeof(LocalToWorld),
typeof(Translation),
typeof(MarketData)
);
NativeArray<int> array = new NativeArray<int>(10, Allocator.Temp);
for (int i = 0; i < array.Length; i++)
{
var entity = entityManager.CreateEntity(archetype);
var buffer = entityManager.GetBuffer<MarketData>(entity);
buffer.Add(new MarketData { basePrice = 1, currentPrice = 2, demand = 3, supply = 4, targetPrice = 5});
}
array.Dispose();
}
my marketdatastruct:
public struct MarketData : IBufferElementData
{
public int supply;
public int demand;
public float basePrice;
public float currentPrice;
public float targetPrice;
}
And my jobsystem:
{
public struct MarketUpdateJobStruct : IJobForEach_B<MarketData>
{
public float deltaTime;
public void Execute(DynamicBuffer<MarketData> marketDatas)
{
for (int i = 0; i < marketDatas.Length; i++)
{
var marketData = marketDatas[i];
var data = marketData.currentPrice + deltaTime;
marketData.currentPrice = data;
}
}
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var job = new MarketUpdateJobStruct()
{
deltaTime = Time.DeltaTime
};
return job.Schedule(this, inputDeps);
}
}
The thing is my current price is not increasing, when i Debug.Log those values it looks like its increasing but not in reality.
I wonder if eventually Unity won't give us access to whatever they use for code gen
Some utilities to make it easier at least
you can actually do that if you wanted
you should take a look at the "Type" class
its pretty easy to get data from unknown things
@opaque ledge You need to assign back your data to the buffer after you change it
@opaque ledge I dont see any reason to have that temp array of 10 you have there
yep, its not a ref struct like most component data
marketDatas[i] = marketData;
You're creating a copy of the data inside the buffer
you need this at the end to assign the value back into that index
Then changing the copy, but not assigning it back
oh wait, i need to create a new marketdata struct and assign that to that index ?
no
you just need this line at the end\
marketDatas[i] = marketData;
var marketData = marketDatas[i];
@opaque ledge Remember that you're working with structs. It's a value type
this line is asking for a copy of the marketdata at that index, you now have a local version
oooh it works now 😄
yeah, sorry my experience with structs is pretty low, i know that it takes a value but since when normally we deal with ref struct i thought when i access the element in index that would be ref as well
but thanks, i understood now
👍🏻
it gets easier to reason about it after you get used to your new tools
The temptation to fill-in the current gaps in DOTS is tremendous: I started implementing sngdan's double-buffered drawmeshinstancedindirect rendering system, then realized I was putting myself on a whole development track parallel to unity's own development of rendering, so I trashed it, and am patiently waiting for unity to fill in the gaps themselves.
awhile back I went and played around in a custom c project to reason about some ecs ideas outside of unitys api
highly suggest this if you want something close to how to unity's works
https://github.com/SanderMertens/flecs
yeah waiting on them to finish up the gaps is so painful. I really wish they could just drop the whole hybrid stuff and go all out on finishing the rest of the systems
I was going to ask, there are many cases with 'tag' components, but i also heard that if you add a tag to an entity or remove, it causes to chunks to be recalculated, is adding or removing components(or adding entities or removing entities) expensive operations ?
Feels like tag components can be very useful and abused, i thought i would ask
they are slightly expensive but you should not even think about performance when you start out
no, abuse them
yay 😈
They have gotten a lot faster now that you can use ECB in a bursted job
I highly suggest reading the existence based processing chapter of the DOD book
check out 5argon's benchmarks on tagging
and def read the whole DOD book
that chaper alone will help you understand how good getting your arch types right can be
and it argues against shying away from them just because of the mem copy
hell mem copys are about as fast as you can get anyways
dont make your code less readable just because "performance"
yeah, I just reread DOD for like the third time, and I've upturned my whole concept of what "should" be an entity
oh btw the reason i created that native array is because thats what code monkey does and it gives me some practice creating native containers 😄
DOD book?
what is the DOD book ?
starting to think about lots of loosely tied thin entities? @left oak
what beautiful styling
one thing that really started working fire was thinking about m vrs n amount of lookups in a system. but theres a flawlessly performant way of dealing with it
let me find a example
yeah the whole tables == unordered sets thing is hard to grock
I have that book, I'm finding it hard to figure out how I can take what it's trying to teach and apply it to Unity's ECS
but very powerful
I blame that on my own slow learning process though
if you have a query, that needs to look up your body based on a id alone (the best way) then hell, why not just add a non required query to your system, hash them at the start (which can be a job) then use said lookup inside of the system
the actual pattern in the code is so simple and clean that you can practically copy paste it to the start of each system
for me, the difficulty is removing entity -> entity references, and trying to make do with linear access
your system then just checks if the id is present in the hashmap and your good to go with a ref to the actual entity
thus avoiding the mess of adding direct entity refs
I no longer have fat components, so producing something is multiple entities
if you need data, find it
yeah, i'd describe my learning ecs has been going from fat systems/entities/components to thin systems/entities/components
if you need data every single frame and it needs to be faster, then you actually sort and make it easier to fastly get it
exactly
oop is hard to break
and dod is hard to get at first
I've read the dod book about three times now, and it finally all clicked. now I'm thinking about general purpose patterns to use
entity existence as actions is another great one to get
instead of a entity that does x, then y, then z, why not instead 3 separate small entities that each trigger x,y,z to happen
this allows for each one to be consumed to cause the action to happen, which is existence based processing
no entity mutations or tags for stages are needed
I think from the names alone you can figure out what this causes to happen
and thats a simple entity emission from another processed event
So, to burst compile a struct(or a job struct rather), i wont be able to put any managed stuff to that struct right ? so i cannot use UnityEngine API ?
correct
so many of my old entities are just entries in a dynamic buffer on a single entity
Yes, unless you use unsafe code you can't use managed types inside burst or jobs
so i don't have to do entity -> entity random lookups
so.. why is the performance is so huge ? i just did a test, i made 2000 entities with 500 of those market data struct, and it was taking like 50-60 ms, and with burst it started to take 0.04-0.05 ms
how come this huge performance come exactly ?
it feels like this burst compiling made data orianted programming popular then ?
You're making a lot of sacrifices to be able to use it and in return you get great performance
I find looking things up and querying is really powerful for decoupling entites
so I'm trying to go as thin as I can for everything now. instead of fat monsters that are used in 10s of systems
Data oriented design was around long before OOP
yeah i know that, but what about burst compiling ?
its a combo of a bunch of lines of thought
It used to be the normal way to do things, then OOP was made to try and make code easier to understand
i mean if it wasnt burst compiling, unity wouldnt work on ECS no ?
And in return that made the code harder for machines to run efficiently
yeah
So now we've gone in a nice big circle and we're back to DoD
stream processing is my holy grail: how can I run a transform across an unordered set (table) without external references
at least for gaming yeah
If you believe the marketing then burst is supposed to make C# run faster than similiarly written C++ code
I'm not too sure about that but it seems pretty good so far
why I fired up my test project, guess whats stupidly good at stream processing? GPUs
if its done right to minimize the latency you could all the heavy processing on a gpu, maybe even the entire game.
But what about the sorry souls running integrated graphics
yeah, that's how i got pulled into Graphics.DrawMeshInstancedIndirect
still works on cpu then
cpus are still good at stream processing, it would just be slower
Aren't there still lots of phones that don't even support compute buffers though?
older apis yeah
but most phones you would even want to run on support compute
if they dont then I already dont target them
thats like opengl4 / es2
Not too worried about grandma being unable to run your game on her flip phone huh
Grandma deserves to experience the virtual world too
yeah, I went back to Hybrid for the grandma's sake, lol
stock renderer, with dummy gameobjects for rendering here
the ecs on a gpu game is gonna be cuda and a side project anyways
I'd never lock things down that hard for a main game
anybody know if the new input package plays well with ECS
seems like the input actions are event-based? not sure how querying them works
I remember seeing a thread about there being some incompatability, I'm assuming they've fixed it by now
0.5 just came out
maybe I'm meant to poll the input actions in the system
hmm
or maybe somebody's made a thread about it
Oh I don't think it's integrated with ECS at all
ah
You still have to read all your input on the main thread then translate it into ECS data
Maybe keep an eye on project tiny to see how they're integrating input
gotcha so I still need to make my own input component structures
they've made very little headway towards supporting touch input, I believe
"All I can offer at this point is a rough list of the things we consider important/bigger ticket items after 1.0.
DOTS support
Broader device support
"Routed" input for actions (i.e. input triggering action X prevent action Y from triggering)
Gesture support
Extended haptics
Images and models for controls and devices"
from the forums
considering they're not yet at 1.0, I wouldn't hold your breath
crazy how long input has taken
Has anyone played around with BlobString ? i couldnt make it work
yeah, ive been following it for a while, but it never seems quite ready
@opaque ledge have you checked out the BlobificationTests.cs file in your packages?
that's the only example ive looked at
thanks, i will check it out now
Hmm, there is no any example of how to allocate/create one
there is only one method with "ValidateBlobString" which validates a blob string and nothing else
static unsafe BlobAssetReference<MyData> ConstructBlobData()
{
var builder = new BlobBuilder(Allocator.Temp);
ref var root = ref builder.ConstructRoot<MyData>();
var floatArray = builder.Allocate(ref root.floatArray, 3);
ref Vector3 oneVector3 = ref builder.Allocate(ref root.oneVector3);
var nestedArrays = builder.Allocate(ref root.nestedArray, 2);
var nestedArray0 = builder.Allocate(ref nestedArrays[0], 1);
var nestedArray1 = builder.Allocate(ref nestedArrays[1], 2);
builder.AllocateString(ref root.str, "Blah");
builder.AllocateString(ref root.emptyStr, "");
nestedArray0[0] = 0;
nestedArray1[0] = 1;
nestedArray1[1] = 2;
floatArray[0] = 0;
floatArray[1] = 1;
floatArray[2] = 2;
root.embeddedFloat = 4;
oneVector3 = new Vector3(3, 3, 3);
var blobAsset = builder.CreateBlobAssetReference<MyData>(Allocator.Persistent);
builder.Dispose();
return blobAsset;
}
oooh okay thanks, sorry 😄
np, ecs is a pain in the butt
i pressed "find all references" on str and empty string, which couldnt find any
blobs are great but the api is a real pain in the ass at first
i guess i have to create a root first for some reason
yeah, it's all a mystery: like a literal "mystery": an obscure dark ritual practiced by a cult
so i guess i gotta learn this blobstring for.. string stuff which i certainly use it everywhere
❔
❔
that or NativeString
blobs are a mystery...
oh there is a nativestring ?
yep
lol nice emote
New in 0.5 I think
but in order to a string like struct to be live in a component it has to be a struct that contains a blobstring right ?
right ? 😄
no
you can only manipulate the string / construct it on main thread, but the nativestring is just a big fixed chunk of bytes
but you cant put a native collection into a IComponent right ?
i cant seem to find it on scripting api of 0.5
do you have it ?
i will never know 😱
FixedString is the new replacement for NativeString in 0.5. Look in packages/collections/tests/fixedstringtests
It's very new and there's no official docs for it so you have to do some digging
yeah sounds like it, i am unfortunately too noob for that kind of stuff
i wonder if there will be a tag component to reduce the performance hit on tag component add/remove somehow
but i guess as June said its almost neglible
tagging is good for preventing whole systems from running, so that's how I evaluate the cost.
they moved namespaces from Unity.Entites to Unity.Collections
in 0.4 entites update
@opaque ledge @zenith wyvern
Yeah I think FixedString is meant to replace NativeString if you just want a simple way to store strings in a component
They also added FixedList to store a simple resizable list inside a component
native string isn't deprecated though
Dunno, I remember seeing a Unity dev say it yesterday
There's a pretty comprehensive set of tests for FixedString and I don't see any for NativeString
* Added FixedString types, guaranteed binary-layout identical to NativeString types, which they are intended to replace.
From the changelog
hmm quick question - if you do CmdBuffer.Instantiate(...) how are ComponentObjects handled in the instantiation? I'd assume the entity would be linked to the same ComponentObject 🤔
ah cool - just found out they're linked to the same ones 🙂
@winter veldt I did, though I had to leave DOTS for the time being. What I ended up doing:
- Finding a tutorial for mesh stitching with SkinnedMeshRenderer
- realising that all I really wanted was a custom mesh of 32x32 quads
- spent a fair while finding out how to create a custom asset from the procedural quad
- made a material with two textures and figured out how to set the individual quads to one of those two
now i'm stuck on a more tricky UV problem because I've got this random texture from another game (as practise/test) which is 1024x64 and I thought it would be simple to set the UVs to something within that ... but not so. everything I do looks abysmal
if I can figure this out (and a few more bumps in the road, no doubt) I might end up switching to DOTS at some point to set UVs. I can only imagine that the process of copy the UV array -> edit the UV array -> send it back to the mesh -> would be faster in DOTS/ECS
@last lintel setting / remapping UVs sounds like a job better suited for a shader / shadergraph?
quite probably, I'm just very uneducated about shaders 😄
I ended up hacking it together
it's enough that I can work on other stuff without going insane for now
oh boy
trying to learn how Unity.Physics works from looking at the Physics examples just felt like biting off way, way more than I can chew
all I want to do is implement collision separation for my 2D player's kinematic body
so what does that leave Dynamic buffer ? If a component can have a resizable list, then there wouldnt be a reason to create dynamic buffer unless its for specific purpose
@digital scarab How does the actual usage of FixedList/FixedString look like? I couldn't find any in docs
Interesting, so FixedList is an option over DynamicBuffers as long as you don't need the container to be resized?
Basically it's like a list, but the Capcity field is fixed, based on the number of bytes in the container / your element size
Nice! There's a data structure I had to turn into an Entity so that I could add an array to it, but with this it sounds like I don't need them to be entities anymore.
So FixedList32 has 30 bytes of capacity (with 2 bytes reserved for length of element, this is the case for all of the FixedList* variants)
so if it's ints or int-sized, that's 30 / 4 = 7.5, round down for safety, 7 elements of capacity, with 2 bytes unused
with FixedList64, that's 62 / 4 = 15.5, or 15 elements of cacpacity, with 2 bytes unused
there do seem to be concrete versions for byte, int, and float too, so you don't need the generic versions for those
Makes sense. In my case I'm storing float4 values, so 16 bytes each I think?
yeah. ranges are 32, 64, 128, 512, and 4096
yes, seems to be that way along with the FixedString* NativeString* replacements
and a bunch of Unsafe goodies
and some bit array things
oh they are actually like that
and a ring buffer
Hahah
i get you cant resize them
but it would be nice to be able to actually pick the size when you define them
but it can be stack-allocated and stored in IComponentData without any issue
i.e. i need a component list to hold 12 integers
Right, which is awesome.
or w/e
and that absolutely is possible to do, i dont like it having pre-defined sizes?
that is both inflexible, and wastes space
unfortuantely:
- This isn't C++, we cannot do that thing with templates that take arguments
- This is also for alignment purposes. There's no padding in any of these and I think they're specced to common cache page size multiples
@untold night uhm, it sure is doable
fixed Byte _Test_Backing_[128];
public FixedArray<FP> Test {
get {
return new FixedArray<FP>(Unsafe.Ptr(ref _Test_Backing_), 8, 16);
}
}
but you can't make a generic type parameter an int that you can use to set the size:
struct MyArray<T, int U = 32>
{
fixed T m_Backing[U];
// ... accessors and such
}
Sorry if I wasn't clear enough
this is a thing you can do in C++
no sure, 100%, but you can setup collections like the one above in C#, it is a bit more work but it at least gives some flexibility
so you can have std::array<int, 12>, or what have you
yes, i know how C++ works 😄
sorry. I'm fading out
You probably want UnsafeList<T>
It's like NativeList<T>, but with all the safety bits removed
No, that's not what I'm asking for :p
I'm just asking that it'd be nice to have some flexibility, for the inline fixed stuff
yeah, but I think that's a C# issue, and they picked the sizes that fit the most use-cases
i don't think you can do fixed buffers with a parameter for size
no, but you can do what i did above
externally defined from the stuct itself i mean
which achieves the same result-ish, but with a bit more work
public struct Foo {
fixed Byte _Test_Backing_[128];
public FixedArray<Bar> Test {
get {
return new FixedArray<Bar>(Unsafe.Ptr(ref _Test_Backing_), 8, 16);
}
}
}
ok I get it now,
16 elements of 8 bytes (Bar) each array
looking at the backing stores it looks like they've not even used fixed.
they litterally defined byte seqence structs of various sizes, with explicit field offsets and used them throughout the Fixed* types as backing stores.
this is almost assuredly for packing guarantees
they can't have a packing guarantee
since they dont know what comes before/after in the struct the lists are in
[StructLayout(LayoutKind.Explicit, Size = 16)]
internal struct FixedBytes16
{
[FieldOffset(0)]
internal byte byte0000;
[FieldOffset(1)]
internal byte byte0001;
[FieldOffset(2)]
internal byte byte0002;
[FieldOffset(3)]
internal byte byte0003;
[FieldOffset(4)]
internal byte byte0004;
[FieldOffset(5)]
internal byte byte0005;
[FieldOffset(6)]
internal byte byte0006;
[FieldOffset(7)]
internal byte byte0007;
[FieldOffset(8)]
internal byte byte0008;
[FieldOffset(9)]
internal byte byte0009;
[FieldOffset(10)]
internal byte byte0010;
[FieldOffset(11)]
internal byte byte0011;
[FieldOffset(12)]
internal byte byte0012;
[FieldOffset(13)]
internal byte byte0013;
[FieldOffset(14)]
internal byte byte0014;
[FieldOffset(15)]
internal byte byte0015;
}
🤷♂️
yeah not quite sure why they did that
packing in terms of the buffer/Fixed* itself
yeah but the packing for a fixed byte _bytes[16]
is identical
to the above
[StructLayout(LayoutKind.Explicit, Size = 16)]
internal struct FixedBytes16 {
[FieldOffset(0)]
internal fixed byte bytes[16];
}
is identical to the above
in memory layout at least
Does anyone have any resources that go over the basics of blobs? I've seen them mentioned a few times now but can't figure out what they are/when to use them 😄
{
public BlobArray<float> floatArray;
public BlobPtr<float> nullPtr;
public BlobPtr<Vector3> oneVector3;
public float embeddedFloat;
public BlobArray<BlobArray<int>> nestedArray;
public BlobString str;
public BlobString emptyStr;
}
static unsafe BlobAssetReference<MyData> ConstructBlobData()
{
var builder = new BlobBuilder(Allocator.Temp);
ref var root = ref builder.ConstructRoot<MyData>();
var floatArray = builder.Allocate(ref root.floatArray, 3);
ref Vector3 oneVector3 = ref builder.Allocate(ref root.oneVector3);
var nestedArrays = builder.Allocate(ref root.nestedArray, 2);
var nestedArray0 = builder.Allocate(ref nestedArrays[0], 1);
var nestedArray1 = builder.Allocate(ref nestedArrays[1], 2);
builder.AllocateString(ref root.str, "Blah");
builder.AllocateString(ref root.emptyStr, "");
nestedArray0[0] = 0;
nestedArray1[0] = 1;
nestedArray1[1] = 2;
floatArray[0] = 0;
floatArray[1] = 1;
floatArray[2] = 2;
root.embeddedFloat = 4;
oneVector3 = new Vector3(3, 3, 3);
var blobAsset = builder.CreateBlobAssetReference<MyData>(Allocator.Persistent);
builder.Dispose();
return blobAsset;
}```
this code is from Unity.Entities.Tests/BlobificationTests
i never used blob asset as well but maybe this can help you
@verbal pewter
@trail burrow I'm not sure I see how your Foo is different from FixedList128<T> (other than the fact FixedLists have 2 bytes used for Length). Both cases have a fixed size backing buffer you can't change at definition time.
@worldly pulsar you can change the values on the FixedArray<> in any way you want?
public struct Foo {
// 16 elements
fixed Byte _Test_Backing_[128];
public FixedArray<Bar> Test => return new FixedArray<Bar>(Unsafe.Ptr(ref _Test_Backing_), 8, 16);
// 24 elements
fixed Byte _Test2_Backing_[196];
public FixedArray<Bar> Test2 => return new FixedArray<Bar>(Unsafe.Ptr(ref _Test2_Backing_), 8, 24);
}
the FixedList128<T> etc are locked, you cant do a FixedList96<T> or a FixedList150<T>, etc.
yes my way is more 'work'
Oh, you mean define a backing field + wrapper accessor, ok.
I thought you proposed Foo as a library type 😛
no
I guess the major annoyance would be replicating the .Add() interface
@opaque ledge Someone can correct me if I'm wrong, but I don't think there's a built-in way to do that. Out of curiosity, can I ask what the use case is?
Well, i am doing a space game, and every faction sends a trade ship from one of their station to some other station(if AI decides to that is) in my non-ecs project i was sending out an event every 5 seconds so each cooperation would send a trade ship on that every event.
I was wondering if i should have a float timer field on my struct and increase it by delta time everytime its run and when that timer reaches 5 that means event is off, after processing that i would reset the timer.
Yep, that's what I would do.
what happens if job takes more than 1 frame tho 🤔
My take on it is that any time-dependent things like incrementing the delta time should be done in the main thread rather than a job. I'm no expert on DOTS though, so someone else might have a better perspective on it.
You can create custom system group which can update in fixed time steps but you need to edit source files to make this functionality available to you
ah, i rather wait then 😄
Also, just thinking out loud, but it feels kind of dirty to have an elapsedTime value on every faction entity, where in reality you'd really just want one value shared by all those entities. I'm not sure what the best practice is for accomplishing that is with DOTS, though.
i was kinda hoping new Time.DeltaTime would give delta time unique to jobs, but i think its a long shot 😄
at least look at ComponentSystemGroup.cs mayby it will help you 🤔
Burst error BC1045: Struct System.ValueTuple2` with auto layout is not supported
😦
i was trying to return a tuple from a job struct to be used in that job struct but i guess its not burst compilable
@opaque ledge Btw, thanks for the link to the BlobBuilder docs!
👍
I think I understand their use, but wanted to write out a possible use case to see if I've misunderstood. In my procedural city gen program I have Networks (ie, "Roads") that are made up of Nodes and Connections. Nodes and Connections need to store references to each other. Right now I'm doing this by storing either a float2 or float4 value as the "key." When I need to access the value I do a lookup in a buffer, matching the key values.
From the sound of it, I can instead create Nodes and Connections as blobs and store the BlobAssetReference in the Nodes and Connections instead of key values. That would allow me to access the Node/Connection data directly without doing any lookups. For anyone familiar with blobs, does this sound about right?
Also, @untold night or anyone familiar with the new FixedList, how do you go about calculating the FixedList size you'll need for Unity types such as BlobAssetReference?
@untold night "but it can be stack-allocated and stored in IComponentData without any issue" no point of doing that because it will crash Unity if you will try to access the allocated buffer next frame or within next system execution since the stack memory will be cleared.
how can i reach entitycommandbuffer from jobcomponentsystem ? seems like in componentsystem you can use "PostUpdateCommands" but not sure on job version
@opaque ledge The Enity Command Buffer doc says this: "For jobs, you must request EntityCommandBuffer from a entity command buffer system on the main thread, and pass them to jobs. When the EntityCommandBufferSystem updates, the command buffers will play back on the main thread in the order they were created. This extra step is required so that memory management can be centralized and determinism of the generated entities and components can be guaranteed."
https://docs.unity3d.com/Packages/com.unity.entities@0.1/manual/entity_command_buffer.html
I have spawnable entities in my project, these come from e.g. selecting a specific ship, and is managed with SOs referencing a GOs. I don't want to fill up all scenes I might use with conversion for all prefabs entities. Currently my approach has been in spawnsystems to fetch these singleton SOs that hold GOs to convert them, and then use them. But I'm not sure if there is any downside to this? And what BlobAssetStore means in the context of using GameObjectConversionSettings. My second thought would be of using a subscene I load from Resources which contains authoringComponents referencing the SOs that will convert the prefab entities. Anyone stomped into the similar issue with any cool solution? 😛
@verbal pewter for the new JCB you can do with structural changes to the lambda if it's a main thread run. If it's instead one that you need a ecb, but you are still finishing it that frame you can simply alloc one there and playback it at the end of the system then dispose
If it's a job based one you will need to grab a reference to a entity command buffer system in on create, then call the method that's roughly get command buffer, and a second one add job handle for producer so that system has your job handle to call complete on when it runs
@mystic mountain I have prefabs with unique IDs and a Monobehaviour which holds a list and converts them to entity prefabs in OnEnable with ConversionUtility. My spawner system registers them in a NativeHashMap<int, Entity>. When a spawn request arrives my spawn system looks up the prefab entity for the given ID and spawns it with EntityManager.Instantiate.
@gusty comet I'd ask on #💻┃code-beginner. This channel is for DOTS related questions.
ok
@gusty comet Seems to be a internet connection issue
At least package manager is working on my side right now
its a firewall issue not internet connection issue
Isn't it the same sometimes?
@low tangle Thanks for the heads up. I just realized I was looking at the 0.1 version of the docs. Here's the 0.5 version @opaque ledge: https://docs.unity3d.com/Packages/com.unity.entities@0.5/manual/entity_command_buffer.html
yeah i did it 😄
i made an event system using tag components, and i remove the event tag component after i am done with it
i am kinda happy 😄
Alright nice 🙂
@dull copper I think he's agreeing with you though?
@safe lintel Unfortunately this is an areas where hobbyists get hit the hardest, because they naturally gravitate towards high level flows and lack the experience to see those are where the most churn is likely to happen. was direct try to get under my skin
this is what that person does on every reply for any of my comments
they are always dismissive
Combined with Unity not keeping tutorials up to date it's not a great place for hobbyists to be right now. is quite wrong too
because all official DOTS docs and samples are kept up-to-date
only things that are outdated from Unity are old video tutorials but that's quite impossible to keep them updated even due to the whole concept
i guess i just dont see it as a dig on you? 🤷♂️
i get the sentiment, samples is up to date, but there are a number of old tutorials out there that dont get updated. theres also a dots landing page with a bunch of old outdated videos, but no mention is made that its outdated. the samples repo itself is not really publicised outside the forums?
i didn't update DOTS for a long time and now time has come. So how we should initialize world in 2020? cause i see no autocreation anymore. I saw some posts on forum abour it, but can't now find them
add to the fact that documentation is in a weird state now with the old manual and api has zero links or notes of the package stuff in another thats almost sequestered away, it doesnt give beginners much in the way of a good starting point
I guess, it's just really easy to see the comments in different light with the past discussions taken into account 🙂
imo they need to clone will goldstone or someone like him just for dots, a singular voice to get a lot of the repeated feedback sorted
yes i am definitely missing any past history so just from that short interaction is my take 🙂
I don't really see the difference between hobbyists and professionals like that
I've seen really crazy low level stuff done by hobbyists
i agree there totally
anyway, thanks for your thoughts, gave things more perspective 🙂
np, i enjoy the meta discussions
@frosty siren are you talking about default world initialization or manually created ones?
i mean that i updated entities and now default world not creates on start. so now i need to know how to initialize it. Am i need now to manually call DefaultWorldInitialization.Initialize(string, bool) ?
or i have some kind of issue?
Is there a legit way to either select an entity in the Entity Debugger of just directly getting the inspector view of an entity you get when you select and entity in the Entity Debugger? I would like to get this from another editor tool.
@dull copper that is a really frustrating thread to read
I've literally got a released game build on dots minus rendering nothing else
Yet, no dots totally isn't ready
Default world should be initialized when game starts i think
what do you see in your entity debugger when you play ?
@frosty siren Unless I'm misunderstanding what you're asking, you now get the default world using: World.DefaultGameObjectInjectionWorld.
@low tangle it is, I'd really suggest not to read it 😄
I've unsubscribed from it like 10 times but someone always keeps replying to me there
I should just ignore those
Anyone who could explain to me the difference of Child of entity and being in the LinkedEntityGroup?
Has anyone had issues updating the Entities package? Can't upgrade to either 0.4.0 or 0.5.0, getting the following error: Cannot perform upm operation: EBUSY: resource busy or locked, open 'C:\Users\Edvard\Documents\CityGen\Library\PackageCache\.tmp17812YrbLUf4pFhah\copy\Unity.Entities.Tests\EntityQueryBuilderTests.cs' [NotFound] UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
@mystic mountain I believe if an entity is a child and it's in a linked group and you destroy the "parent" entity it will destroy all the children in it's linked group, I'm not 100% on that though
@trail burrow Hmmmm, it's strange cause I can upgrade any other package just fine.
@verbal pewter Close unity and delete your library and temp folders
@zenith wyvern Alright, will give it a shot. Thanks.
Oh that's from the actual package cache, weird.
I'm upgrading to the latest version of 2019.3 to see if that makes a difference.
Entities 0.5 has 2019.3.0f1 set as minimum on the package
so I'd guess they don't support older betas
@scarlet basinnto Yeah, I was using that version.
@opaque ledge it's empty
@zenith wyvern Hm ok. I'm looking at difference of how conversion handles a gameobject that has physics shape and child tree of colliders vs the same without physics shape. It seems that when you have physics shape it keeps the hierarchy as children and parents, but without it only kept first child, then the remaining GO's that were below in hierarchy are only in LinkedEntityGroup but not parented/children of something.
So it only retains the parent/child gameobject hierarchy if you're using the physics shape? That seems weird, not sure why they would do it that way, I'm sure there's some reason
And go figure there's not even a mention of LinkedEntityGroup in the docs
@frosty siren imo, update entity related packages and your unity
@zenith wyvern Maybe it's more specific for physics conversion, also note that it combines the children into 3 composites.
(below non physics shape)
Yeah, I'm using the GameObjectConversionUtility.ConvertGameObjectHierarchy
If you were comparing a conversion with a prefab vs one without a prefab that could explain it
@zenith wyvern Same thing but without the LinkedIndexGroup showing
In case anyone runs into the same issue with the Entities package, updating my version of Unity seemed to fix it.
So I guess it's only for destroying, and that if there is no physics shape, it regards all entities with a physics body as it's own entity since it "should be" static
Actually not the same thing..
TBH I'm not familiar enough with the conversion system to provide any useful information, all I can suggest is to look at the source for the hybrid conversion system
Or make a thread about it
how can i do nested entityquery in jobcomponent system
error says when i try, it returns a reference type and that is only allowed in Run() and WithoutBurst()
foreach loop in a foreach loop? @opaque ledge
if so, you cant in the new ones yet, there still working on them
I'm curious, what is the current state of ECS? Is it properly supported in editor? Is the API ready? Are all features supported fully?
{
var jobHandler = Entities.WithAll<Kanwis>().ForEach((Entity baseE, DynamicBuffer<LocalMarketComparissionBuffer> baseCompare, DynamicBuffer<MarketData> baseMarketDatas, in Translation baseT) => {
var baseEntity = baseE;
var baseTranslation = baseT;
var baseMarketData = baseMarketDatas;
var comparision = baseCompare;
//Entities.WithAll<Kanwis>().ForEach((Entity entity, DynamicBuffer<MarketData> marketDatas, in Translation translation) =>
//{
// var targetEntity = entity;
// var targetMarketDatas = marketDatas;
// var targetTranslation = translation;
//});
}).Schedule(inputDependencies);
// Now that the job is set up, schedule it to be run.
return jobHandler;
}```
@viral kindle meh-level support
you can build stuff with it
but it's not complete/finished
can probably build a game if you know how to do shit yourself, etc.
if i remove the comment on nested it gives the error
core api has had minimal changes and its pretty solid (jobs, jobforeach, jobhashmap, chunks, components)
high level api was stuck in dev hell for figuring out how to do proper hybrid
its still pretty shit and I just avoid it mostly
thankfully everything in dots is optional
I assume that whole scene disapears as soon as you press Play because ECS
including DOTS itself, thankfully 😄
not exactly no, if you do the full hybrid conversion yeah
everything just goes into the entity debugger basically
can view any entity in the scene there. 2019.3 and the newer entitiys now have a live link on the gameobjects to show the conversion
trying to debug while job system has stalls, etc. is basically impossible
So if you use ECS, you no longer have actual Editor
no you do?
@viral kindle editor when not in play mode
you can convert GOs to entities
etc.
but when you start playing you dont have the 'editor' in that regard no
you can also just not use the conversion api
But what's the point of ECS then?
its meant for people to convert slowly, but thats a joke because not all of unity converts
that it's faster, that's about it
@viral kindle This should give you an idea of how it works now https://docs.unity3d.com/Packages/com.unity.entities@0.5/manual/gp_overview.html
I mean what's the point of ECS if you do not convert objects
"you can also just not use the conversion api"
you can do it by hand, set everything up, etc.
without the GO/MBs
which is valid ofc, if thats ur thing
or your game is proc gen heavy, etc.
you just write the entities logic without having to deal with conversion
MB -> ESC is done offline?
yes and no
they are done at editor time
both offline and runtime
TBH the conversion workflow is such a janky solution
it feels like a solution to a workflow problem that doesnt exist
but most people are not willing to convert anyways
i also wish they would just put their efforts into making it native, and just saying there is no conversion process 😕
which i suppose, is exactly what it is
"both offline and runtime"
What?
I mean what's the point of ECS if you do not convert objects
@viral kindle
There's some use cases where dragging and dropping things in the editor just doesn't make sense
Like procedural generation
basically there is a option for either @viral kindle
To be sure, by "offline" I mean "not in finished product but before release"
they mean in the editor at some point before creating a build
which is offline / before build is baked
im just tired of things being broken and buggy
that tps shooter lol
and not being able to rely on the engine that I use to work properly
@vagrant surge lol, you mean the 'netcode sample' ?
'dots netcode sample'
the dots shooter
or w/e it is called
I guess I will wait for final version still then
Even the latest one kinda feels like it's held together with duct tape
it's such a joke lol
has the unity animation system in it
its very rough and clearly using stuff just exposed for it
not even close to a preview api
Which might not be a problem but at Unite they kinda presented it as this fully fleshed out example that works great
and has a few thousand lines copy pasted from the fps sample lol
And it's definitely not that
I was expecting animation to be much further along
Wait, it still does not have proper animation?
it does
Thanks for clearing this up guys
lol
Depends on your definition of "proper" I guess, hahah
it just has a uber complex matrix submission process for the skinned mesh renderers
@zenith wyvern This is my WHOLE issue with DOTS. What they are trying to do is cool, the performance is nice, etc... but they keep presenting it at unites like "THIS IS DONE AND AMAZING" and it so clearly ISN'T. DOTS as a whole is still alpha level code quality.
you probally mean the do everything garabage animation system regular unity has
I'm talking about skinned meshes in dots
"everything garabage animation system regular unity has"
I mean, this system works
@trail burrow I agree with you for the most part, but they are a business so I guess they have to do what they have to do on the marketing front
Just a huge bummer when we end up seeing what they give us as a result
@zenith wyvern Oh sure, it's just... they've been presenting it like it's done for two years lol, but it's still at best an alpha.
takes about 3x longer than their first release
they never quite say what is done
only reason they get away with it
they have their own version of dll-hell
upm-hell
😄
i wanted to build this new tech im fiddling on as a hobby inside DOTS
do it?
no, i chose .net core 3.1 instead
because it's just... like, i can't get it to reliably do what i want
thats cool too
the scheduling issues with the job system
and unity not being super stable for long running processes
huh
dots being well... buggy
I've had my dots game running for 3 days straight without issue
@low tangle that's great with anecdotal evidence 😄
"I've had my dots game running for 3 days straight without issue"
How and why?
Oh, makes sense
its just the full version of the game with no rendering
now that its fully dots, (voice chat was the last to convert) it now has stable memory usage
sits at a +- delta of 3mb with a few people on
which is amazing compared to when it was all monobehaviours and would rise and fall about 200mb
i've had too many random crashes and shit happening with unity in general and dots/burst specifically
to feel like i can rely on it
Nice to know there's at least a few people who seem to have fully fleshed out games running in dots, even in it's current state
I've noticed 2019.3 the crashes went wayyy up with domain reload off in the editor play settings
yeah but I've been working on this since dots came out and its been a up and down ride
glad I never jumped onto the high level shit
it all rubbed me the wrong way, and the current is only marginally better
I guess you're talking about the conversion system specifically?
Very fair
I can't use them since lots of my game is loaded from asset bundles
theres no future api for me either from unity
so it sucks knowing I'll just have to replace most of asset bundles with a custom format eventually
that is if unity ever gets feature parity with other systems
im finally gonna get to jump ship to UE later this year
I'm probably reading too much into it but it kinda feels like subscenes were just a thing they came up with to make Megacity work and then they ended up running with it
as its looking now
@zenith wyvern that's their whole dev process lol
for literally everything
good luck with that, I tried to switch several times to UE in the past
"oh this is cool i suppose we use this now"
Maybe so
hate that engine arch with a passion
@low tangle luckily i don't build games, i build middleware 😄
thats good then, you will be able to sell your plugins for way higher then
The workflow is just designed for larger teams
As someone who's always learning as they go UE just doesn't feel practical for me, I feel like you really need to know what you're doing to be able to tolerate the compile times
@zenith wyvern default way is blueprints, and then convert to C++ when you need perf
Yeah, and part of design is coffe break every time you change anything
If you use C++ from the getgo for everything in UE u gonna have a bad time
blueprints is the default way you should build things
and move to C++ when u need perf, build completely fresh functionality, etc.
Yeah, that also felt like such a foreign workflow to make everything revolve around blueprints
If you're used to Unity/C#, UE feels foreign af yes
I'm sure it's great when you get used to it but it's hard to beat the simplicity of the unity inspector and the play button
I mean literally the ONLY reason I'm staying with Unity is because C#. C# is such a good language/platform
My first approach to UE went like:
Me: "I want EMPTY SCENE"
UE: "Player? Can do! And I will also add a gun for free! Great deal!"
iteration times are fast
@viral kindle You're mostly just showing your ignorance with these complaints lol
i.e. didn't read past the first page of the manual
I don't know, I think saying it's a FPS focused engine (or seems that way to someone coming to it as a beginner) is a fair criticism
I can't stand not making games in a data oriented way anymore. everything being uobjects and object hierarchies just doesn't suit games anymore
DOD kool-aid 😄
we should be moving to linear memory and linear processing of things, not more objects calling super.update() tick()
I think if someone enjoys making games using DOD and finds it preferable to OOP it's not really fair to say they're drinking koolaid. Just because OOP works great for you, not going to for everyone
And it's not like DOD is new
@zenith wyvern OOP and DOD are not opposite/competing technologies
Yes, but OOP is a huge pain in the ass for myself and lots of people, compared to making games with DOD
ECS and OOP are 'competing' technologies, DOD can be used with either of them
alright well you want to argue so I'll just head back to work
im leaving for the day so 🙂
@trail burrow // I'm not saying it's UE's fault. But I will just have hard time fitting myself to that workflow.
I'm sure it's fine for poeple who work in this enviroment
And especially if your game fits what UE was made for
I'm with you, I find it much harder to use than Unity, and the insane download sizes and compile times don't make it any easier
I need to finally give UE at least a week of tutorial/manual learning
Who knows, maybe it will be better in long run
Same with Godot
Starting to feel like Unity is falling so far behind in departments where UE has been really fleshed out by this point though, like networking.
Networking at this point in Unity you know... does not exist
Yup. They've tried and retried so much I'm wondering if they'll ever get there
Unity is far from Unreal on many fronts now, sadly
tbh off the shelf solutions is exactly what I'm trying to avoid
its why I disliked the hacked together network priority of unreals bog standard old networking
that hasn't had any major changes since unreal 2
its just been incremental changes
I'm not too familiar with it but I've heard people swear by it
and any major game that has major networking requirements (mmos etc) just gut it right away
I guess it's a pretty low bar though considering the competition
the only large amount of networking that is done on it was fortnite and pubg
which both required hacks to make it work
And had a lot of help from Epic I'm sure
network priority also eats cpu performance since its non linear accessing all the objects to do a distance check and then store memory there
before cache thrashing and going to the next
Another place where dod can help out I suppose
there was as test of a guy who literally added a ecs framework to unreal, and it ran about 10x faster than doing the same in unreal objects
for a simple space fighter game with ships flying at you
but unreal isn't setup for batch submission of matrices and what not like unity so its unable to get some real performance out of it
I thought I heard unreal is working on their own ECS now is that right?
not exactly last I heard, they just made yet another subsystem for particles that is very ecs like
Ahh
pretty sure it was vblanco who did that ue ecs implementation
I've got the thread bookmarked somewhere
if I ever went back to unreal thats what I'd work on
Thought I'd share this video for anyone still in the process of learning all the different features in DOTS. Was super helpful for me. https://www.youtube.com/watch?v=q1_b--k3fQ8
Covers some of the more advanced features of Unity's ECS: Object Components, Chunk Components, Shared Components, SystemState Components, and Blob Assets.
unreal isn't fps focused engine at all, but if you look at their netcode and specifically client prediction code, it only exists for their character controller, in fact all that code is embedded on single 10k+ line c++ file
that one magic files contains like 5 different subsystems that should have been separeted years before UE4 was even a thing
I guess this is one of the things in that engine that worked on some old UE so they decided to keep it going
@vagrant surge would probably know the best here what Epic is cooking in regards of DOD
it's root of all evil, yes
the rest of the networking is very undesirable as well
super slow and perf heavy too
yeah
epic games isnt really adding an ECS, as far as i know
what i do know is that they are improving unreal for bigger worlds and better data management in general
for example subsystems, which are managed-singletons, or stuff like ISPC which is equivalent-ish to Burst, used for the new physics engine and some animation nodes
on the actor (gameplay) level, they are adding push-networking, which is setting stuff as dirty manually, to skip the "iterate all and check who changed" sstep in networking
and they are also adding class-data, which is to have some data that is shared beetween all object from a blueprint
like, say you are making a RTS, and have a bunch of unit data. Your Unit actor can be thin, and most of its paremeters are on this shared data thing
they are using it to thin a bunch of stuff
in general they are working towards making ue4 not-garbage for open world and large scale games
@verbal pewter that was a really useful video! Thank you.
thats good
dirty bits are a waste of performance though (if you read the dod book it actually talks about dirty bits)
@honest dirge Np!
@low tangle its more like dirty lists + dirty bit
objects have multiple replicated properties
yeah I know
when you dirty an object property, it adds that object to a list of dirtied objects, and sets the "dirty" bit for the property that got dirtied
the whole thing of using dirty flags vs. computing the delta and finding changes every farme, etc.
is... not a clean cut decision
both approaches have their uses, and it depends on what you're replicating
i'd say that in general, the dirty bit systems (i.e. eventual consistency) is the more generic setup that works for more kind of games
than the straight delta/change detection setup, where you scan for changes manually
it's... like there isn't a clear winner, but dirty bit system has more uses IMHO.
but if you have the type of game, where delta compressed snapshots is the best solution, then having it all in linear memory is great ofc
because it's a lot of fkn data to scan 😄
if you know ue4 architecture at all, you'll know how bloody slow they are there to iterate anything
even basic operations have huge overhead
I could see dirty bits working fine on codebase like that
Hmmmm, so I was hoping to create a FixedList of BlobAssetReferences but it seems like that's not possible? The type 'Unity.Entities.BlobAssetReference<RockMine.CityGen.Networks.ConnectionEdgeData>' cannot be used as type parameter 'T' in the generic type or method 'FixedList64<T>'. There is no boxing conversion from 'Unity.Entities.BlobAssetReference<RockMine.CityGen.Networks.ConnectionEdgeData>' to 'System.IComparable<Unity.Entities.BlobAssetReference<RockMine.CityGen.Networks.ConnectionEdgeData>>'. [Assembly-CSharp]
it's not as clear cut as dirty bits being better or worse than delta snapshots
it depends massively on the use case
for example, a dirty bit/eventual consistency setup will use less bandwidth than a straight delta snapshot system
and it will use less CPU, even in the case of linear memory DOD type stuff
@verbal pewter - I'd use BlobArray for arrays in Blobs, as they're meant to be read-only. If you meant a FixedList of BlobAssetReference, I believe they're a just pointer (8 bytes on a 64-bit machine).
Yes, the latter. To be honest I'm not sure if it's something I'm doing that's throwing that error or what.
@autumn sleet - Sorry, I was tired. You can allocate it on the stack since it's not on the heap, and you can store a Fixed* on a component, as since it's size is known it doesn't need the safety system and is safe to store there.
oh wait, I guess the type needs to implement IComparable to go in a fixed list
and BlobAssetReference only implement IEquatable
Yeah, curious why BlobAssetReference doesn't.
well, what does comparing two blobs mean? They have no semantic ordering on their own, which is the reasoning I can see for not implementing IComparable<T>
@opaque ledge i completely forgot to update unity, thx, this fixed all issues
Ah, ya, fair enough. Too bad 😦
👍
Oh man... can't use float4 either 😮
The use case for FixedList suddenly shrunk considerably.
do you guys thing, in current state of ECS, its possible to make a decent sized game ?
i already went %50 on my game, and i was wondering if its worth to convert into ECS, but i am having hard time tbh
Sounds like @low tangle has managed to.
I would focus on converting the parts that are performance bottlenecks.
As they say, premature optimization is the root of all evil 🙂
if you are 50% through, are you really prepared to throw 100% of your code away to get going with this half done system? 🙂
there has to be good reason to swap IMO
well, technically my game could use lots of performance gain from ECS
but not really 'essential'
perf gains totally depend on your game too
yeah, i have lots of calculation going on so
id probably recommend you dont switch tbh
i mean i want to learn ECS, but someone has to make a comperehansive guide for OOP to Data Design 😄
Have you ever looped over an array? Now do this for all of your code ;D
also prepare to be lacking sound, animation and pathfinding as there are no native ecs versions of them that are really friendly to use. you will need to stick with the old way for many things, and you might find its just not worth the hassle given you are both learning a new way to code, and dealing with incomplete, nonexistent/and or buggy features
Hmm i think I might be on @safe lintel on this, like I enjoy using it - but in hindsight (comparing to using MonoBehaviour Unity or a custom engine) - right now I'm in a position where I'm like "okay this is kind of like building a custom engine") - a lot of things I've been making are actually from scratch (UI, basic physics) which also got me thinking the other day, why didn't my friend I just continue our own custom engine for the game 👀
if you want to learn it feel free 🙂 id just caution you for throwing out your existing project in an effort to convert it all to dots
if anything, at least start doing some smaller scale prototypes with your game mechanics first
@coarse turtle i kinda regret jumping on this train this early too 😬 there are pros and cons but its a bumpy ride thats for sure
see how it feels like
I personally love observing new tech coming along but DOTS in general has gone some many stages now and is still going through that it's been probably bumpiest ride in whole Unity history
also personally hate the whole conversion workflow
I really wanted to see full dots editor
it just adds the pain on fully adopting the new setup IMO
personally conversion is the least of my own issues, its like the strange intersection of srps & dots has issues, issues with job scheduling that i for the love of god cant track down, and lastly incomplete features forcing you to do a strange patchwork between built in and native interaction
Hmm to that point with seeing how it felt - that actually convinced my friend as a workflow since it was "feasible" to setup with some monobehaviours for certain things that we could migrate it later - but at this point we were like "yea we'll embrace these changes - it's quite a nice learning experience - even though a lot of things are built from scratch" 😅
But yea my fault for not vetting the whole thing more thoroughly early on- overall I'm okay with the current conversion process since we have a lot of custom conversion scripts for the things we need for our game
yeah i love DOTS, like i like the designing, Component data, Buffer elements, systems, i mean there are so neat, plus the performance boost, but i have hard time to put my toughts/plans into code, i can do it on OOP but not on DDO
We spreadsheeted a lot of things early on (since we had existing code from our own engine) and just focused on the "minimal" amount of data required to do x thing
and we built from there, so it was a lot of here's our high level design, now what do we really need and how many of these entities are there going to be
@opaque ledge i do really enjoy the ecs system nature, feels way better than using monobehaviours or trying to force monobehaviours into a similar manager > component workflow
i'd focus on the thinking "What is the data you need to do x things" and kind of think of it like a "database" for a lack of a better phrase (you'll need these data/attributes from some_space (like a table) with this query to get the data), the dod book @low tangle mentioned can give you insight too @opaque ledge
You can always transition performance sensitive code to use bursted jobs to start with, should be much easier than trying to convert an entire game to ECS
If performance is your only concern @opaque ledge
Should also give you a good idea of how the whole ECS framework works under the hood without having to dive in the deep end
for starter reads, I found the blog that introduced me to it: http://gamesfromwithin.com/data-oriented-design - he's got a few other related blogs
Picture this: Toward the end of the development cycle, your game crawls, but you don’t see any obvious hotspots in the profiler. The culprit? Random memory access patterns and constant cache misses.
so i wanted to ask to DOT experts, so i am making a space game, where lets say there are 30 stations, there are 5 factions owning 6 station each, each station has a market with their own supply and demand and market item's price is changing according to that supply and demand (and base price) so i want each cooperation to create a trade ship, and carry items from stations to stations respecting buy low sell high, so how would you program a system to do that.
I first places faction tag to those stations so each cooperation can get their own stations, but i just couldnt do double query to compare market to market and choose the most lucrative route to send trade ship to.
So i am like, if i cant even solve this i really cant make a game using ECS 😄
You should really take a step back and learn the basics before you try to immediately transition a complicated system to ECS. Go over the manual and the samples carefully. https://docs.unity3d.com/Packages/com.unity.entities@latest https://github.com/Unity-Technologies/EntityComponentSystemSamples