#archived-dots
1 messages ยท Page 174 of 1
But it's not that far off from just installing packages via git url
they keep going from bad to worse
Their solution for listing it though seems headass as fuck
And makes discovery impossible
until yesterday when timboc told me, I had no idea that the full package name is a valid git url you can add
because git url isn't indicative that it means this notation (too) imo
@solid flume also, for completenss sake... calling the high bit a "sign" bit is... technically wrong
scoped registries?
So this isn't too big of a departure for me
if you really want to get to splitting hairs and being technically correct level, yes the highest bit being set to 1 in signed numbers means the number is negative... but its not a sign bit... it's actually needed for calculations for sub/add/etc.
Yeah true
Errr, you can add your own custom UPM packages if you set up your own NPM registries
I've been using it for some of my own shared libraries
@solid flume compared to floats, which have a proper sign bit - it's evne called that
Before that I just either git submoduled it
I don't know floats
@solid flume floats is just base-2 scientific notation, with a sign bit in the front
Or subsequently used git urls in manifest.json
Ah
I forget if it allows higher exponents or not
Does Physics.OverlapSphere or something exist for ECS?
I haven't checked the standard in a while
@solid flume it does 11 bits
So I can check vision radius
@solid flume nope, overlap queries only support AABB testing
I would wager a zero distance collider cast would work though
I'm questioning why I'm even trying to use ECS for abm but it's not like I have anything better to do
It seems to work in my use case
@solid flume vision radius might be easier with CalculateDistsnces
checking radius is easy
No idea what that is
@solid flume provided a collider geometry
It finds the closest point on nearby colliders
so the scoped registries are essentially the qualified names like com.unity.dots.... etc?
I don't see how I would use that. I give it a sphere collider, it finds the closest point on every nearby collider?
@minor sluice for example, my GGPO port has the qualified name of "com.houraiteahouse.backroll"
It's hosted on https://upm.houraiteahouse.net
And my manifest.json says to fetch all packages starting with "com.houraiteahouse" from that registry
@solid flume yep
But how do I find If there exists a plant in my vision radius?
You then filter it down to those that are under a maximum distance
The max vision radius you set
And that's the set of visible objects
Since we are operating in euclidian space, that distance automatically forms a sphere
I'll have to try this and see
But thanks
I can do stuff like use a script to generate a bunch of cubes with the convert to entity component, and then run my game right? That'll work?
Nah, this isn't a game just a simulation I'm doing for fun, so I can (probably) avoid (most of) the fancy stuff
Make sure to update the Translation component so they're not all stacked up on each other
Or just don't and watch physics blow it apart?
If you are using Physics, sure
ah I see, thx,
at the moment, for my own projects at least, I'm more a fan of using git submodules than upm packages (maybe also because I haven't given the later an earnest try yet)
@minor sluice do actually try it, it's a lot less of a headache when working with people unfamiliar with source control
It also makes dependency management a much simpler problem
can imagine that, luckily (for this specific case at least) I work alone on my current projects. My main reason for the submodules was that I could edit the module in any project that uses it and push the changes then. Not sure if or how easy that works with packages
You generally need to republish it
But the intention is to have more than just you working with it remotely
but you as owner of the repository can treat the repo the package comes from as just any other git repo right? so that would mean you could have multiple local repositories of the package for multiple projects on your disk and just republish the package from whatever project you currently work in?
I think that would be an approach I'd like
Not in the same way submodules work
You will need to separately make changes to the repo, publish the package and update your package manifest.
It's not ideal for a single developer
But for a community or a large team, this separation is critical
ah, alright!
don't have much experience with working in large teams or for communities
https://forum.unity.com/threads/dots-sentiment.956936/#post-6238085 someone laying it out
haha wasn't that you who posted that @trail burrow ?
Had a lot of quotes similar to you that's why I assumed ๐ (e.g. https://discordapp.com/channels/489222168727519232/497874303463850004/747139543567958137)
@amber flicker yeah that quote has been circulated in a lot of places now apparently
someone sent a pic of it to me in PM, etc lol
ditch ecs, keep jobs/burst, switch to .net 5, improve GO/MB workflow, etc.
stop trying to re-write the entire engine sigh
Have we today built-in system for sync data between LocalToWorld DOTS component and Transform mono component?
wow, that thread gained quite some traction
well, HPC# allows more than just burst itself, it also allows then to do their safety checks to allow multi-threading in a safe way (the one thing that no game engine solved so far AFAIK)
@rancid geode no HPC# is only for burst compatibilty
HPC# is just crock of shit
it's just that they cant burst compile more than that
HPC# doesn't "allow" anything, it just allows burst to work
by restricting the feature set of the language
personally, I really like ECS-way of doing things (not the half-baked current hybrid workflow, but the way to structure the code ifself), so I prefer to wait until 1.0 to made my judgement about if it was worth their investment or not
to basically C
.NET 5 JIT performs basically as well as burst, and doesn't give up 85% of the language features...
HPC# doesn't "allow" anything, it just allows burst to work
@trail burrow if you dont do things the "Burstable" way, then the safety checks won't work and they can't prevent race conditions
they are actually linked
Given he paraphrases you without attribution I kinda wonder if he's just spewing other peoples gripes without any real experience in using it for himself ๐
it is just that dealing with classes in c# is a mess without having an option to manually control the memory the way we can in C++
How do I store a target of something I want to move to?
@rancid geode HPC# exists for burst, no other reason. You can't burst code that isn't HPC#. The safety check system has nothing to do with HPC#, it could've been built without HPC# subset.
In a component
so they need to rely on a constrained version of the language for that (while still allowing entire C# stuff out of Burst context)
@safe lintel I can assure you he doesn't, i know the guy, he knows what he's talking about
@rancid geode HPC# exists for burst, no other reason. You can't burst code that isn't HPC#. The safety check system has nothing to do with HPC#, it could've been built without HPC# subset.
@trail burrow I don't see how they could guarantee the thread-safety without the HPC#
Like if I want to move to something, I check if my target isn't null and move toward it's transform.position
How does that work out in ECS language?
How do I store a target of something I want to move to?
@solid flume you can expose an Entity field and use GetComponent<Translation>(thatEntity)
@trail burrow thats not vblanco is it?
no
I guess I could just add a bool to see if the target is valid and set that to false instead of nulling
Can I do null checks on it?
@solid flume if (thatEntity != Entity.Null)
I really need to write on that thread... But, I'm tempted to just be lazy and say "DOTS is driving me to drink" ๐
Oh that's nice
I'm still wondering when will they support .NET 5, I know it won't be on release...
if your target is another entity and you have it stored in a component, I think the equivalent of checking if that entity target exist is by using EntityManager.Exists or if you pass a ComponentDataFromEntity group to a job, you also have an ComponentDataFromEntity.Exists method
@rancid geode the safety system can be in place without HPC#, you can still fuck it up despite their 'safety' system even now... all the safety system does is check for read/write conflicts... that system can be in place no matter HPC# or not.
for example, the ComponentDataFromEntity<Translation> group and you check if a the target exists with a translation component with doing the .Exists(targetEntity) method
@trail burrow by the way, Joachim (I believe) replied once about why the don't have ref return on the data access arrays of chunks, and he said that it was because they didn't have how to do their safety checks with a reference value
okey?
entity is a struct, did they include a null check? otherwise you probably have to check for if (entity == default) (for structs),
but it is better if you check if the entity actually exists in your world with entityManager.Exists
if you have reference values (class) you can't guarantee that it won't be modified in another place and create race conditions
oh but also, didn't know about Entity.Null (so please ignore what I said about default)
@rancid geode no sure.. but you can already do that with the "safety system" today in place, you can fuck up the thread safety and have it blow up despite all of their safety checks
it's very easy
so despite HPC#/Safety/Burst, you can still blow your leg off easy
well, yeah, but with the safety system you at least know what and how to fix
So whats the argument - that you COULD do something wrong that wasnt safe if the restriction wasn't there?
No...
multi-threading is easy this way
in any case, HPC# / Burst / Jobs are all opt-in features
then you're not doing complex enough multi-threading
you can still do everything single-threaded with C# and/or multi-threaded with C# Tasks
if multi-threading means: batch processing of arrays of data, sure it stops the absolute noobs from fucking stuff up
that's kind of a moot point tho
you just have now an option to do thread-safe code without much more headache than limit yourself to a subset of the language
multi-threaded with C# Tasks
that kinda defeats the purpose of writing safe multi threaded code tho
problem with using regular C# threads in unity is that the mono threading primitives are shit
and are basically unusable
for high frequency or low timing scenarios
@deft stump which brings back why HPC# and the Safety System are useful for us
Can I find all entities inside a certain radius?
I can't seem to figure out how spherecasts work
if multi-threading means: batch processing of arrays of data, sure it stops the absolute noobs from fucking stuff up
@trail burrow well, yeah, but if you combine that with the ECS structure it becomes way damn powerful
In ECS
which is way I am giving a shot on Unity's ECS and hoping that they will do that right
the current issue with Unity's ECS is not even the API itself, but the hybrid workflow that just doesn't work properly/the way we expected
@rancid geode batch processing of data is usually not needed when dealing with game logic outside of a few game types, actually the architecture they have picked hurts performance when you're implementing fine grained game logic which lots of conditions and checks and combinations of various operations
but it is not production-ready yet, so this can be something that is being worked on (but we don't now because they aren't clear about their roadmap)
it was suppoed to be released in 2020.1
yes, but we are all developers and we know that timeline changes
the stuff you need to build an actual game
meanwhile people that need to build actual games on unity are left by the wayside, working with tech from 2016, because nothing is being done to fix old problems, bugs, etc.
this is a big change, I prefer it to take longer and right, and be released earlier and be useless
@rancid geode so far it's taking longer and wrong
don't see why wrong ๐ค but this could be personal taste
i mean they had 3 years so far, and it's still basically as useless as it was 3 years ago
yes, but we are all developers and we know that timeline changes
@rancid geode true. however, they're a tool maker.
if a tool maker takes so long to make the tools, then it's better to just move on.
Unity better not give up on DOTS ๐
we've got game schedules to keep
i was, for the record, super excited about dots when it was announced
it would be kinda neat if unity focused on a system to better distribute the load of regular threads, based on the end system the app runs on, if that was possible
we wouldn't have half the tools we do have if people gave up half way through making them just because they took to long
@pliant pike yeah sure if it was developed in a vacum that'd work
@deft stump I must disagree on that, they just showcased too early, most tool makers doesn't showcase their new tools until it is almost finished, even if it took 3-5 years to reach that state
The point is:
- a few experienced guys are feeling (at this point) that there are fundamental problems with Unity's specific approach...:)
- so the whole path is wrong (it's not only timing)...
It's not that it was taking to long that I have the issue with, it's that they didn't tell us anything
the issue is that ECS shouldn't be showcased before late 2019 (which is when the API got barely usable)
They just told us to wait till next unite for the next big update to entities or physics being released
we've got game schedules to keep
@deft stump for that reason they advertise that it is not production-ready
Yeah, that was a recent change
I really like that they offer dots for us, even if I only have little experience with it,
think the main issue is transparency, communication and probably documentation too
@rancid geode and that would be FINE if they hadn't left the rest of the engine to die by the wayside lol.
while they working on their ivory tower dots thing
which is still, useless
They didn't throw it in your face as much before, and they gave the impression it was only going to take one to two years for most of it to be ready for games
like james brought up really well, most of the time users go on forums or on here to find out about stuff that is sometimes basic but just not well documented and the ecs sample package isn't that accessible for beginners either
They were showing off full demos (nordus RTS demo) in 2018
While that happens, we can live with 2015-ish renderer and (contested) animation tech for production-ready MB.
yeah they do need to properly document it
@minor sluice it's not even that, it's that it's buggy and incomplete. You can't actually build anything serious with it. I don't need a documentation or manual to do stuff unless it's really complex stuff... yeah sure docs suck, but you cant document shit that doesn't exist yet or is fully broken.
@rancid geode and that would be FINE if they hadn't left the rest of the engine to die by the wayside lol.
@trail burrow not sure why you feel that way, sure they haven't added anything BIG to GO world in the last years (beside some cool acquisitions like Cinemachine, ProBuilder and the new Bolt)
but we did have some cool progress like Addressables and InputSystem
The documentation is the source code
only neo can read the source code
@rancid geode those are all new tools... and they both are in 'preview' stage... im talking about core bugs in the existing physics/animation/rendering/audio/etc. stuff, which goes unfixed for YEARS while they fiddle on dots
we could have more if there wasn't any DOTS to care about? maybe, or maybe the team size would be smaller because there won't be any DOTS stuff
things that actually block progress for real products
There's a lot of standard comment (not XML autodoc) at the header of most files I've looked at in entities
I guess the few people that actually have a dots project in production spent tons of hours on the forums, and rolling a lot of custom systems that users would expect that unity offers itself?
for the documentation part, I think that is generally an issue with the new packages. I really liked that they pointed out that they work on documentation for how to convert shaders from standard to srp pipelines for example but... at the moment it's really pretty bad
@rancid geode oh and ProBuilder/Bolt? let's see, pro builder integration is still shit and its buggy af. Bolt 2.0 that was worked on for ages was scrapped and ditched, and they went back to Bolt 1.0 (unitys decision)
I'll give you cine machine is decent
adressables are still buggy, at least last time we tried to use them
another issue I see is that they market things as out of preview at times when a lot of users still seem to have problems with those packages that would indicate that they are still in alpha or beta state.
i dont know what kinds of companies you work for, but i prefer solid tools that do what says on the tin so we can schedule time and count on them, not have shit change under our feets 3 times per year.
Cinemachine, ProBuilder and the new Bolt)
but we did have some cool progress like Addressables and InputSystem
Being honest, why were these not built in house, the engine feels like it's made of duct tape.
or have to drag 5-6 year old bugs around
I don't use bolt but some people said bolt 2 would have really been great and one even said that could have been a decent competitor solution to unreal's blueprints even
@minor sluice yeah i dont use it ither but they ditched all of it
lol
and if youre just a hobby user fiddling at home with unity personal edition, what you think of this... doesn't really matter, because you can take as long as you want, you have no budget, you can play with shit beause it's fun, etc.
but the people that have companies, staff and money on the line
need dependable shit
not ivory tower dreams
yeah, would prefer more stable features too, so I'm glad that they stated they want to work on stability and workflow improvement,
I still use all the old things, standard renderpipleine, monobehaviours etc. (and had few to no issues with them)
just that I played a few times with jobs/ecs
i dont know what kinds of companies you work for, but i prefer solid tools that do what says on the tin so we can schedule time and count on them, not have shit change under our feets 3 times per year.
totally agree on this.
Like I said before, Unity is a tool maker. We can't have tools that doesn't work out of the box.
they break dev scheduling
@minor sluice same, we use: Old Input, Old Renderer, Go/Mb system, "Old" UI system (not ui elements), etc.
or rather, there are always small issues somewhere, but they never felt like a pain point really
and they are still plauged by the bugs that were during during 5.x release cycle
because LITERALLY everything else they have made since 2016
is USELESS for a real project
because it's unstable, incompatible, incomplete
Or atleast, I just want Unity to be honest with themselves.
Just make a giant public announcement and say "we fucked up, here's the ACTUAL state of things"
and my faith in them might get restored.
yeah i have zero faith anymore
Honestly, with the whole hpc# and .net 5 stuff, I'm actually just heading back to cpp myself @trail burrow
@low tangle i have so much of my company/career tied to unity, i would jump ship if i could
in a fucking split second
the idea and the direction of the new features is really impressive I think,
dots, and also the problems that the new input solution would solve for example,
but I agree with your statement on production ready projects.
for inputs, I'll just use ReWired and let them handle whatever abstraction or interfacing they choose with the unity input
Yep
and yeah ReWired is good
I haven't checked it for a few months, but they should still be on the old input system too
solid asset, been around for ages
ReWired seems like the goto input solution many unity studios choose for their games
yeah for good reason
My prototype core in unity is using the native plugin interface right now, in cpp, and I honestly forgot why I hated it before. My 2yo unity game takes a long ass time to compile, and 20 min with il2cpp, which generates a gig of source
Yeah we just use unity for rendering, rest of game is pure standalone C#
I can't stand il2cpp, really wish direct cpp was a option
I just really dont want to go back to C++ lol
I'm so happy in C# land
espc with .NET 5
I am, but also tired of not being able to directly compile. .net native stuff has been killed off by Microsoft so many times
@rancid geode oh and ProBuilder/Bolt? let's see, pro builder integration is still shit and its buggy af. Bolt 2.0 that was worked on for ages was scrapped and ditched, and they went back to Bolt 1.0 (unitys decision)
@trail burrow Bolt 1 is fully functional as it was, also ProBuilder, it just didn't improved much since the acquisition, but I understand you as I was furious when they acquired Anima2D just to abandon it
@rancid geode I don't use any of those tools. I just know that when unity acquires something = over for it.
Esp when you had just bought it full price recently
And bolt2 was VASTLY better than bolt1 from what i heard from ppl that actually use it
I tried bolt 2 (when was still with ludiq, right before the acquisition) and it was barely functional
What is the reason for abandoning Bolt2? Probably have them work on a DOTS 2.5 version that will never see light of day?
was at least 1-2 years away from being usable
@tiny ore they are 'consolidating' all their visual scripting tools, that is the official reasoning at least
but I think we are going a little offtopic here haha
I don't remember that they had an official visual scripting before
I mean, people use either Bolt or Playmaker
"consolidating" sounds like merging an internal team, probably
they are 'consolidating' all their visual scripting tools, that is the official reasoning at least
(this is actually a little funny, because they don't have a consolidated vs tool yet, but want to consolidated them all together already)
god just reading through the thread and their response just makes me hurl
I read a bit, yeah, my expectations for the "consolidated" version are not high

oh no, but unity recently acquired plasticSCM 
^consolidated
@minor sluice one of my fav products about to get 'reckt by unity
absolutely love plastic
God are they becoming Google
someone told me it was perfectly fine to be used for unity before the acquisition too,
I speculate on some collab 2 rebrand or something too
Ye plastic is awesome, I'm a bit worried ๐ฆ
[BurstCompile]
public struct RaycastJob : IJobParallelFor
{
[ReadOnly] public CollisionWorld world;
[ReadOnly] public NativeArray<RaycastInput> inputs;
public NativeArray<RaycastHit> results;
public unsafe void Execute(int index)
{
RaycastHit hit;
world.CastRay(inputs[index], out hit);
results[index] = hit;
}
}
``` What's the use of unsafe here?
Got this directly from Unity.Physics documentation
Also, can I schedule a job (The above one) inside an entities.foreach?
@solid flume might be a mistake
When you schedule it, results needs to be marked as disable
@low tangle marked as disable?
Yeah the uh, disable parallel for restriction
Basically, I want to spherecast around entities that have a particular value of a specific component and then do something with the result
The job is picking up on the inputs being safe, where only one touches one
Ah, that might be why the unsafe was there
As an alternative to disable parallel for
But it doesn't know that on the read write to the results
No
Unsafe is there because the physics code tends to use pointers often
Pointers to colliders and such
Do they change the semantics of what c# unsafe means?
No
Because you only ened to mark the method as unsafe is there is pointer logic DIRECTLY in that method/class/struct
Also, I realised spherecast will only hit one thing. I want to implement vision radius. Any way I can get entities within a radius?
Anyone seen this funny performance in float4x4.TRS before?
If a method you call uses it, the calling one does not need to be marked as unssafe
It just allows pointers, the person who wrote that likely copied or modified from another job that was using pointers
7.72ms spent in float3x3 constructor looks wrong to me
It's a deep profiler... could be a slow machine (331 calls to the constructor)
@tiny ore Nah, the reason I started profiling in the first place is because I was seeing slowdowns
So the performance is bad independently of the deep profiler
It's also a fat struct to copy
Plus it's running on a Ryzen 2600, so not that slow
Is that in burst code or main thread
Hm, it's only the constructors and matrix multiplys
The weird thing is that all the other operations look fast, just the 3x3 construction is dog slow
It's a 4x4 by the way
I know, but the slow part appears to be a 3x3 ctor?
Yeah
Testing here our own TRS
If you expand the hiearchy a bit what's the rest of the call stack look like
have you checked in the timeline? it's not hiding a wait or smth?
Well
Throw it into a job and burst it, then complete it
Deep Profiler in Editor/mono is shit
Just try a proper burst + il2cpp build
Tossing stuff into a single job is a nice way to test if burst is going to help the code much
Has a lot less restrictions due to only bring one thread
Thanks for the advice!
@outer swift IIRC TRS involves constructing 3 4x4s and multiplies them together
A good portion of the multiplies isn't vectorized due to their memory layout
If you know one or two of the components it might be easier to hand craft the matrix yourself
Duly noted.
Unity intends to list its common stock on the New York Stock Exchange under the ticker symbol โUโ.
wew
kind of a weird time to do it? where a lot of development on it seems in a weird state of flux with a somewhat grumbly userbase?
well.. someone else pointed out... "As the only game engine available on Apple products" ๐คฃ
frytakemymoney.gif
would be kinda hilarious(and tragic) if epic lost their lawsuit against apple and were barred from it completely
it's been in the works for a long time - probably were going to do it just as covid happened.. might have decided it's worse to keep putting it off and now with Unreal maybe it's as good a time as any... 100% speculation ๐
yeah true, just how the timing worked out doesnt seem to be on their side.
yep afaik itโs been planned, pretty sure I saw talk about it a while back
this is a slightly dumb question as I've been using lambdas & IJobChunks almost exclusively. Say I have a e.g. NativeArray<Entity> myEntities and I want to iterate over all of them and set their translations. What's the "best" way to do this? The two methods that spring to mind are either e.g. for() { EntityManager.SetComponentData} etc or for(Entity e, Translation t) { if(myEntities.contains(entity)) then... )} - neither of these feel very optimal? Feels like I'm missing a third way?
do you have a set of entites, or do you have a archtype you can iterate?
set of entities - their archetype isn't unique
for { if HasComponent<T>() -> GetComponent<T>(e) }
HasComponent compares off the archtype of the entity, and is pretty dang fast
duh... yea that makes total sense.. thanks @low tangle - I somehow thought I had to be in a lambda to do that
if you have a set, theres no way to filter it with a query, which sucks because you could just ask the query for a set of the components in a array, or to set all of them with a array of components<T>
yea
If your not within a system base, then you just need to do what its doing for you. If within a job, get a GetComponentDataFromEntity<T>() and use the Exist function on that, or maybe it has a Has function now, forget. otherwise if your main thread, just use EntityManager.HasComponent<T>() and EntityManager.GetComponentData<T>() etc
yea so if I'm in SystemBase and I do for(.. myEntities.Length){ GetComponent, SetComponent} etc, do I need to do anything to make it burstable I wonder
but if I didn't do that, it wouldn't be right?
it wont be bursted yeah, burst can only run on methods, like the ones within lambdas
Any way I can get all entities in X unit radius? Maybe within a job
how many entities
how many subjects will you be looking at
if the set is small, say less than 10k protentional, then just burst a foreach and radius check each.
Oh less than 10k is small I like that
if its more than that, try the boids hashmap bucket approach and quantize each position into a grid point hash, and then brute force a smaller set
You are telling guys to do an O(n^2) loop on 10k entities? Or a single O(n)?
I'd go for the buckets approach if you need to check that from different places
If it's just a single run per update, then should be fine
store the location your checking from and use one point within the job for all protentional, its not as slow as you think
you should always start with the naive / brute force approach. you can and will likely optimize it later if it was ever a problem
I mean, I few.months ago I wrote a sample for a game with 10k zombies and 6 cars
For switch (the demo)
very nice
So in the end, the best solution (that scaled) was more.the inverted idea:
hows the switch hardware feel using ecs/burst?
Instead.of the cars checking for the zombies closeby, I made the main zombie updates to look for the close cars
hows the switch hardware feel using ecs/burst?
Photon Quantum's own ECS
yeah, inversion of logic is usually a good way to structure things with ECS
But the general principles are similar
yeah same thing honestly, just assumed you were referring to it
Ye... I mean, same idea would work perfectly with unity's, that's why I'm saying
And I agree you don't need to add the whole kitchen sync (like a broadphase) for this every time
I needed to update the zombies anyway for their movement, so I scheduled the car proximity checks to happen in subsequent ticks)
oh it for sure does, but I get the feeling crypticax hasn't learned a ton of ecs patterns yet, so I didn't want to give them a complex solution when a simple and easy to understand one will at least get them onto the next phase of their game
I've literally just picked up ECS because I wanted to do agent based modeling and this seemed like a great application
In the end it's 6 X 10k checks (over the scheduling tick rate) anyway, but it felt better from the gameplay with the invertion
its great for that yeah, anything simulation heavy really
In the end I did not add a broadphase (even for the cars, that would be fast to add) because it worked well already
Though there are some unfortunate game types that require strictly sequential processing
yeah and there a real pain to decompose into jobs
I did NOT used our parallel tasks for this case, lol
I wanted to measure the limits within the main thread
I still don't know how to do the iteration since I need all entities with a component of type X to look for the nearest component of type Y and move randomly if it can't find it
@solid flume you can do bucketing
Its a common parallelization technique that puts common components in small buckets based on some function
It's not perfect but it splits up your objects roughly by their base location
You then run the actual distance check only in the buckets
Or the bucket and all nearby buckets
Is that documented as a pattern in unity ECS samples?
Still no idea how to do that. ECS is confusing
I mean a couple of bucketing implementations
Using a bucket size roughly equal to the average vision radius is probably going to be sufficient
@tiny ore unfortunately not
Bucketing would involve some sort of hashmap from coordinate to list?
I only know this because I do big data analysis for my day job
yeah its what the boids demo does, its simple in practice once you understand it
Ye, any voids demo must probably do that
Which is just DOTS but scaled up to millions of data points and thousands of machines
Boids
sucks it hasn't been turned into a proper documentation anywhere
Actually
Is there generic interest in this kind of stuff?
I can probably write up some common techniques I have been using
eventually ecs and dots needs some proper patterns written up to direct people to
Definitely
theres a lot of useful tools/patterns out there
I can say that's one of the things we do more
It's to recognize patterns (including when customers ask questions), document and point
I've done a lot of systems programming
And think very much in terms of share nothing parallelization
https://github.com/hecomi/UnityECSBoidsSimulation Where is the hashing in this I can't find it?
And pure functional programming
Ah thanks
theres a comment above that line I linked as well explaining whats going on
Yep, that does it
thats the exact position hash at that line
yeah. the unifiy wiki has the old recomendation on it
Unity currently recommends only using the new ECS package for experimentation or if you're just starting your project and plan to release towards the end of 2019 or later. Since the package should be quite stable by then.
I've been saying two years, but I knew they said it was only going to take a year
might be able to find the form post as well
I don't get how that hashmap works. Different boids could have the same hash?
not if the entity index + version is used as a key, that's a 'perfect' 8 byte hash
@solid flume yes
the position is being hashed, into a axis aligned grid, of whole (integer) numbers
oh
I'm not entirely sure either but it would put multiple in the same bucket (hash)
if a boid is 'close' to another, its position will hash to the same cell and be in the same bucket
So how do I get entities in a bucket?
Aren't hashmaps basically dictionaries?
which is that line I linked
Probably the misleading name
Ugh ECS ain't easy
Haha anything involving multiple threads isn't easy
But that what also makes it interesting/fun
So every update loop basically I calculate this hashmap? And it's only available to this system, so anything that needs it should run in this system?
yes, but you can do it on change and expose it
English please
Static?
then other systems can grab it from that system
doesn't have to be static, as you can always World.GetExistingSystem<hashmapsystem>().TheHashMap
Ah
but static is fine yeah
This is fine assuming you don't have multiple Worlds with the sam system
hashing every frame is fine if there isn't too many boids, I think that demo handled 50k or so? on some macbook
Yeah I'm way under 50k
Yeah it's not particularly heavy of an operation
So how do I ensure that this will run before any system that needs the hashmap?
ideal is if you can do whatever work you need with the hashmap, within the same system thats going to use it. So if your hashing your npcs to avoid them, then doing a movement operation, you would want to place these within the same system. if that doesn't work for you then it gets a bit more complicated or slow if you want to keep it simple
I have a System that I want to Update manually... from an extension method... It doesn't seem to be possible as I can't e.g. get the default World from a static method so then I can't get the System to run. Is this crazy talk?
World.DefaultGameobject blah blah doesnt work?
yea - Burst error BC1016: The managed function Unity.Entities.World.get_DefaultGameObjectInjectionWorld() is not supported
I guess maybe I should be using IJobFor or something
instead of trying to do this with a system
burst compiling your static method?
I think it's trying - but adding [BurstDiscard] to the extension method it errors about not being able to do that as the method takes ref NativeArray<>
yeah it needs to be a job struct if your going to compile it, otherwise you need to look at the documentation for burst function pointer stuff, I haven't had to use them yet
can't link to a section due to a lack of anchors
What's the entity in query index?
Why is that what we add to each hash
Also, if I don't do .Schedule does the entities.foreach actually happen?
it does not yeah, you have to .Schedule .Run or .ScheduleParalell
I believe if you don't specify a run or schedule, Unity will throw a compilation error in the console stating it must end with a Run or Schedule
have you dug though the ecs samples packages yet? and got the hang of systems?
So I'm trying to use a job struct but I don't know how to set a CDFE without running into the same issues :/
you have to get CDFE's from a system
there a 'object' ||struct|| that you need to get from a entity manager
to get a system or an entity manager I guess it has to be passed in to the extension method?
I think you might be approaching your problem in a way that isn't compatible with burst/jobs
can you explain a bit more what your trying to do
I think I want to be able to say:
public myStruct: IComponentData { int id = 100; }
myStruct.FindEntities(ref resultList);```
Then the FindEntities extension method runs the FindSystem, passing the list to be written to. The system finds all entities with that struct and returns all entities with a matching id for example.
wait so
you want to be able to run a filter, for a id=100 on that struct type?
storing the result into a nativelist?
Essentially - but there's blobassetrefs involved etc
the id is a blobassetref rather than int, which contains a BlobArray<Hash128>
yea I'm cool with that, no worries
So this is how I iterate over a multihashmap? foreach (int ind in buckets.GetValuesForKey(hash))
manually yeah, but theres a job for iterating it
these are also useful jobs for filtering
What's the filter mean? I know the normal parallelfor
been awhile since I used it, let me find a test case for it
Also, can I get a random value from a multihashmap?
Like, a random value from the hashset corresponding to a specific key
oh the Filtering is quite nice - you can either append indices of some collection to a native list
ah yeah, the filter job is a filter you run on the native array
struct FilterMod7Job : IJobParallelForFilter
{
public bool Execute(int index)
{
return index % 7 == 0;
}
}
struct FilterAllJob : IJobParallelForFilter
{
public bool Execute(int index)
{
return true;
}
}
or prune out elements from some collection
yep, used to fill up a list
which you can then run a fordefered on that list, and get a index per job elem as well
So my solution for a random value is generate a random number from 0 to number of values mapped to hash -1, go over it in a foreach and break out at that value
Horrible solution I know
struct GetArrayValuesJobParallel : IJobParallelForDefer
{
[ReadOnly]
public NativeArray<int> array;
public void Execute(int index)
{
}
}
{
var list = new NativeList<int>(Allocator.TempJob);
list.Resize(42, NativeArrayOptions.UninitializedMemory);
var setValuesJob = new GetArrayValuesJobParallel { array = list.AsDeferredJobArray() };
var jobHandle = setValuesJob.Schedule(list, 3);
}
So. Many. Jobs.
allowing you to run a filter on the input to a filter job, then the list your appending to, into a defered job
you're meant to chain jobs
if you want speed that is
Actually working first, speed later is usually how I do things
First make it do something, then see why its slow and fix it
then just do it within a systembase, use entitymanager, use .run on your foreach lambdas
everythings allowed there
.withstructurechanges on the foreach lambda if you need to entitymanager.add remove destroy within
I don't think I'll actually need too many of the big performance things apart from the occasional bursted job, since the number of entities that actually do something will not be too many in the grand scheme of things
Also does ECS have a way of logging values to a file? Can I just use standard c# filestreams? Because that's basically a requirement in what I'm doing
yes, just use a filestream
can't use those within burst, so put .withoutburst if its a foreach
Aight, thanks. Can I use an Entity.Index value to get the actual entity?
Sorry for spamming questions xD
What do you mean with actual entity? for logging purpose?
I have the entity index. How do I get the entity?
I've basically hashed some entities to buckets
So I get a value from a bucket
Which is the index of an entity in that bucket
The usual recommendation is to not store an Entity reference outside IComponentData and/or IBufferElementData
Hmm
there is no actual entity
it's just a index into a lookup data structure
Entity is all there is
Then I can get the Entity struct somehow?
I can have a hashmap to entities?
yes
Well that simplifies things
it sure does
@low tangle btw i tried to use JobsUtility.JobWorkerCount = 0 in build and it just crashes on startup lmao, dunno if that's because i'm doing something weird or unity, log just says invalid address
yet JobWorkerCount = 1 does work in build
so seems like even though they added 0 in 2020 it still doesn't work properly so yer not missing anything
Modifying LocalToWorld.Position moves my entity right?
@solid flume No LocalToWorld.Position is a readonly property

also fun fact my sim loop takes 0,15ms with 1 jobworkerthread, and 0,50ms with default
aaa
@hollow sorrel their job system is kinda meh ๐
it has so much inter-job overhead
its an absolute PITA to get consistent perf out of
also fun fact my sim loop takes 0,15ms with 1 jobworkerthread, and 0,50ms with default
aaa
Sure, let's take the pain out of parallelism and replace with overhead... Sorry,.could not resist
LocalToWorld is to store the transformation matrix for the given entity, if you have a Translation component attached too it will get overriden every frame inside the TransformSystemGroup
so you can either:
- Use the Translation component (recommended approach)
- Modify directly the LocalToWorld (which is a float4x4 and involves some math work)
if doing the second option, ensure to remove the Translation component, or else the LocalToWorld will get overriden again on the following frame
So I just feed translation what I want to move by and it does it?
you feed it with the actual position you want it to have
Oh
So I use the localtoworld to get the position, add whatever I want and assign it to translation.value
Man things are weird with ECS
example:
Entities.ForEach((ref Translation t) => t.Value += math.float3(1, 0, 0)).Schedule();
you will only use LocalToWorld directly if you are doing something very special to it or if you have a parented Entity which you want to get the actual world position (as Translation is always the "local position")
you can see LocalToWorld.Position as transform.position and Translation.Value as transform.localPosition
I just saw the boids demo use it and I was like sure okay I guess this is how this works
Makes sense now though
So I just wrote my first system and if this works Ima be very surprised
Ayyyy it works
Not as intended, but I know why
also fun fact my sim loop takes 0,15ms with 1 jobworkerthread, and 0,50ms with default
i pretty much just use Run() for everything, its generally faster unless you're doing 5K+ operations.
@mint iron does that still support Burst for enabled jobs?
I sort of wish there was an adaptive performance check
yeah you can burst .Run stuff, same limitations regarding no managed things
A collider cast says it can return all intersections for a given shape
Does that mean everything inside it too, or just the stuff the shape surface actually intersects with?
I have not checked the source code of the dots physics package, but I assume they have both sphere-cast and sphere-overlap
the overlap test should definitely consider things "inside"
A cast I'm not sure, would have to check the code (but I have not done so)
I actually need vision radius, so an aabb is not what I'm going for
Although I guess it could work out if I approximate a sphere as a cube
Could it work if I have a trigger on everything that needs a vision radius, and implement on enter and on exit callbacks?
I think we all explained you should use a spatial hash yesterday
Do not try to place this in a complete physics engine (overkill) if the only thing you need is a distance (radius) check
BTW, a distance/radius check is cheaper than the AABB
You just compare the Sqr radius with the Sqr distance
The spatial hash isn't working
I mean theoretically. Anything moving randomly will only end up staying inside it's own hashed area
That implementation is just one example, you can do however you want
And it only detects something inside it's own hashed area
So anything even on the border doesn't work
That's the bread and butter of distance checks in a stateless system:
- broadphase pass: inject objects into the spatial hash data structure (whatever you chose to use)
- queries: test only stuff inserted in cells close enough to the desired origin
And it only detects something inside it's own hashed area
That'รs easy to solve
You need to also get the hashes for anything in the right/left/forward/backward (maybe also up/down) direction from the desired point, using the radius
If you make the hash cells big ENOUGH, you only need to check 2 extra ones
if the cell size is Radius * 2, you only need to check 3 cells (not 2, sorry) besides the one you're in
assuming a 2D hashing... So 4 cells in total
If your radius varies (and you do not have a reasonable maximum), you need to procedurally find all cells/hashes that your position+radius reach...
That's it
Huh
Also, how would interactions work? Like if entity A needs to consume a resource in entity B
Just my 2 cents - Erick is correct... but I'd probably go with the physics approach unless performance is your concern right now - I suspect Unity.Physics is fast enough not to be your bottleneck unless you're doing 1000s of collider casts a frame or something
(but I may be missing context from earlier convos)
Context: I need a vision radius. I see the approach Erick is talking about, and I want to explore different approaches as well and see what works how
Also, yeah performance is not really a concern for me
Its a simulation
So if everything isn't 60fps isn't a big deal
imo using physics (at least for now) means you can quickly experiment with different casts and reduce the code you have to write right now - it's also supposedly very well optimised code (though I haven't used it myself)
but obviously, it's good to try out these different options and learn / see for yourself
depending on how much time and appetite you have for such things ๐
Quick questions: Do collider casts return what's inside it, if it doesn't intersect with the surface. And is there anything for on trigger exit? I can only find stuff that works on trigger enter
Also apparently there's visual scripting for entities? Do my eyes deceive me?
com.unity.visualscripting.entities
I haven't tried it, but yea it exists. I would be mildly surprised if it supported raycasts, collecting results and processing them in a way you want already but if it does, ๐
I agree with Timboc
My perspective should always be taken with a grain of salt (I'm a performance freak)
My expectation (untested) is the collider cast would return what's inside - though easy to test
Go for the physics engine to have a quick result
Ookay, thanks
But @amber flicker this is one of the points that make Tim Sweeney and many other experienced developer look at ECSs with a grain of salt.
We also deliver a ECS-only gameplay engine (Photon Quantum), and I know the struggles of developers to "think" in ECS ways, and to develop gameplay, etc
It enables a lot of cool stuff, but it does have an impact in teams... It all boils down (IMHO) to what is your target audience... ECSs are great, but they are not really easy for the vast majority of devs... We REQUIRE an ECS approach due to performance reasons for multiplayer, but we try to EASE a bit to the regular developer with:
- lots of samples
- docs
- flexibility in the APIs (you can even use a semi OO approach to help you organize ideas).
It's worked well for the past 3 years... But I understand the criticism of the overall approach
Is this in reference to the post on the forums @tiny ore ? Or something I said here to Cryptic?
To the post, but in reference to the questions...
It's not only about the ECS libs being "incomplete". Doing things with ECSs is many times a bit more convoluted
Completely agree
And you only get the real benefits if:
- you have enough complexity to begin with
- you rely on well designed data parallelism
For most cases of "small" single player mobile games (the VAST majority of the Unity market share), ECSs are not really really necessary... And alienates most of the developer community they built.
And this is probably the reason why they will NEED to keep supporting 2 engines (Dots vs MB)
They just can not afford to "deprecate" MBs... Maybe never.
So we only hope they can fully support both engine flavors going forward.
We're all part of the unity community.
We all want it to succeed... And I in particular (I think my colleagues agree with me on this) would love to move to a pure ECS rendering + animation to fit Quantum even tighter (we will jump to it as soon as it's stable and complete).
But I just can't guarantee at all they (Unity) will be able to do both things well... Lets see... We're in this for the long run.
Sounds like we're in agreement basically? I wonder if something I said made you think otherwise.
For additional context, I'm most of the way through making an animation package for Unity (tween library with a Timeline for authoring). It was complex and a lot of work but the authoring workflow in editor is consistent if working with GameObjects or entities. It is all ecs under the hood, meaning decent performance but from a user perspective they can choose the paradigm they want to use the API in. It isn't perfect but the reason I bring it up is I see that as part of the solution to the problem of ecs being sometimes overly complex and not a great fit for many teams, is better tooling and to just keep working on getting features over to ecs land.
Not at all - just don't want to come across as though I'm evangelical haha
So casts do return everything inside
nice then
Also, any way I can have a nativearray of native lists?
I can burst all the collider casts I need to do inside of a job, but every collider cast needs to output a list
@tiny ore 1 sec, posted in here before.. finding a link
How do we realise the following in a ecs -> "Player should work to entity, once collided a timer should start a countdown" ? We already have a "MoveTo", "Position", "Collider" e.g. component... we simply have no clue how we should chain them in order to spawn a timer once collided... any ideas ?
I guess I can have a work around with native multihashmaps instead of nested lists
Create a Timer component... Add it to entity on collision callback
Create a system to run timer
Thanks... will take a look now
Oh, it's for tweening...
You have no interest/opinion on character animation timeline editors?
It's a hot topic given Unity's dead state in MB-land (mecanim and playables are "abandoned"), and no sign of maturity status for everything DOTS
If a native collection is created and disposed inside a job, I should use the temp allocator right?
Yea... well.. I know Unity have their dots timeline.. I don't want to get into rigging and state machines etc.. I trust Unity will do it fairly well in the end
I do not...:)
haha fair
Given what Mecanim was
notice I said.. in the end
and Playables (promising API-wise) is implemented as a Mecanim instance underneath,
In the end, possibly... I hope so
But what I've seen for (studios with enough resources) is a lot of custom tools (mostly around Playables)
If the new tooling has an API similar to Playables (with a good implementation underneath), I bet custom tooling will still be a thing
Hence opportunities for tool developers
Most likely.
On a smaller scale, atm I'm close to releasing a very modest asset (https://www.boxofclicks.com/btagged - half finished web page) that also attempts to bridge the workflow gaps a little. I think there's an opportunity for tool develops here to help pull the quality of the ecs experience up.. but of course, it still relies on Unity making a lot more progress.
For the same entity, does the entityInQueryIndex stay the same across all identical queries?
Not if you have any structural changes in between the jobs running. Generally you shouldn't rely on it.
Gotit. I'll rely on the entity.index then
that's the same thing ๐ - well, not the same thing but the same issue
just rely on entity
I guess the struct/type Entity is the thing... That's the unique identifier
I assume Unity never reuses the entity unique "instance" (with a versioned property)
So my solution is queuing up collider casts in one foreach, doing it in a bursted parallel for job, then going through the results in the next foreach
Does a nativemultihashmap need to be preallocated if I want to write to it in a parallel bursted job?
you don't need to give it a size but you need to allocate it - in your case probably Allocator.TempJob.
So I don't need to use a parallel writer, I can just use a nativedisableparallelfor?
you should use the parallel writer version of it
I'm not sure if you need the nativedisable... if you're only writing to it
I have a feeling you don't
Argh, shit updated Burst to 1.4.0.preview4 and getting like a million warnings Burst warning BC1370: An exception was thrown from a function without the correct [Conditional("ENABLE_UNITY_COLLECTIONS_CHECKS")] guard. which appear to come from within the Entities package itself 0.11.0-preview.7.
Anyone knows starting which entities version (or Unity version 2020 maybe?) those will disappear?
I guess with burst 1.4 you probably want entities 0.14 in Unity 2020.1.0f1 or later?
Everything seems to run (on Android at least) so far...
It didn't complain otherwise
I feel backed into a corner... ๐
Can't upgrade to 2020 due to apparent Hybrid Renderer issues ๐ข
Want to upgrade to 2020 because entities beyond 0.11 is only 2020 and higher ๐ข
<sacrasm> I heard that Dots is secretly fully complete and they'll unleash it with a BANG right before the IPO ๐ </sarcasm>
sooner or later, trying to stick to 0.11 is going to be a headache. What are the apparent render issues you mention?
I simply cant find a nice solution for this scenario : Event occurs ( Button click e.g. ), Player moves to Entity, on collision spawn another entity. Only once... how would you implement this ?
The difficult part is the "once" here... Only execute that action once
one option is to create an event entity that is destroyed/consumed by the spawner?
@amber flicker How do you mean this ? The problem here is... how do we tell the ecs "If that player collides, only spawn stuff once... next time he collides, ignore it"
Hello, anyone know if we can use Kinematica with dots project?
Since there is no animation system
@stone osprey alternatively
Use singletons
And just edit the target instead of spawning a new one
@stone osprey So.. the answer imo depends on the data. Why should it only spawn stuff once? If it's because the player doesn't have a sword yet and the spawner makes a sword, that might mean the spawn system checks if the player already has one for example.
@dusky wind @amber flicker Thanks for your answers. Lets use the following example to describe my problem more detailed. When we press on the "Chop tree" button a event gets spawned... our player listens to that event and should move to a tree. Once he collides with that tree we wanna spawn a "progress entity" which takes care about the chopping part. Thats what i need to realise inside the ecs. With monobehaviours i could simply chain actions/functions/delegates to realise this easily ( onCollision += spawnProgressAndRemoveFromCollisionLaterOn )... But this a ecs, so i have no idea how i could tell the ecs that it should only execute a certain task one single time on collision and next time we collide it ignores that
I guess there are many directions to approach this from. One way would be to add a 'ReadyToChop' tag to the player. The tree system sees a player with that tag has collided and sends another event or manipulates things directly. Or the player could check for trees and do a similar thing. The key is around the player having that tag and when the action is performed, the tag is removed.
A variation on that is to have a ReadyToChop tag that has a .Enabled bool that you set (instead of adding and removing the component).
@amber flicker Thanks a lot ! Now we are talking ๐ That makes sense... never thought its that easy.
ok awesome ๐ - I wouldn't say making all these systems is going to be easy but I'm glad that helps. One thing to keep in mind is if a player is told to 'chop' many times, only one tag is added until he chops and the tag is removed. This is great if it's what you want. If it's not, you can put a counter inside which you increment or you can look into using Buffer elements instead.
For the more general case you could make an array (dynamic buffer) of actions you want the player to perform and remove them as they're performed.
@amber flicker Most of the systems are already implemented ^^ another thing im struggling with is how i fire the collisions... my current approach is that i check all entities each frame and once a collision occurs i fire a "event-entity", that includes the data of entities collided... but instead we could also mark those both entities as "collided" directly ( which would involve a structural change )... What would you go with ?
these decisions (structural changes vs bools vs entities) are so dependent on the scales and systems involved - there's no general answer in terms of speed other than to profile with your use-case. As for style, I don't think it matters too much. Either way you have to deal with what if something collides multiple times in quick succession or what happens if both things collide with each other and both try to tag each other etc.
@amber flicker Alright, thanks ^^ than im gonna go with my approach till i really need to change it... because there so many ways of ecs-architectures im mostly not that sure what is considered clean and what not ๐
I don't think there's really any authority on the subject - still working it out ourselves. Stick with what you have until you find a reason to change sounds like a good strategy ๐
The spherecast needs a sphere collider. As far as I know, I add colliders through PhysicsShape components. How do I get the collider through a entities.foreach?
Do I have to dispose of native collections I create in OnUpdate?
There's something wrong with my code. Every time I press play, unity starts using 4GB RAM and stops responding
Apparently disposing of collections I create in onupdate was doing this
I see the entities/hybrid renderer with addressables bug still isn't fixed, nice ๐
did I just lose a whole ms of cpu time by updating hdrp 
depends, are you on built in render pipeline ?
then should be a breeze
This is what's taking up my CPU time
be careful that you don't have accidently added physics colliders to your cubes
That's probably it
it's waiting 11.4ms for jobs from other systems, not the rendering itself
Nope it wasnt that. I removed all colliders bar one, and it's still showing the same thing
Worse, if anything
then show. the. jobs. running.
there's a jobs tab in the frame debugger
show me the components you have on your cube entities
show me the components you have on your cube entities
How?
in the entity debugger
are you doing this on purpose ?.. https://i.imgur.com/fNZNuIA.png
that's alot of chunks, do you have alot of types of entity in your world or just the renderer ones ?
The green is one type of entity, blue is one, and theres a tiny little sphere
The only difference between the green and the blue is a material and a component
Also what is meant by chunks
There are 10k total cubes, so maybe that's why so many chunks?
is your material set to be instanced?
also, the hybrid renderer does take quite a long time for 10k dynamic cubes - probably around 4-5ms at a guess depending on machine
Think of a chunk as a span of memory defined for an archetype (if you have an archetype of xyz, then memory gets allocated to store xyz)
I don't know about instancing, but this is the material
don't think that shader's supported
It's not shader graph. I noticed removing the light from my scene improved frame time, so I just made all the materials unlit
I dont know if ECS works with 2D or else I would've used that. I have no practical use for 3 dimensions
isn't project tiny for 2d ?
Oh it works alright.
Save for... Animating
Curios. What game or poc are you trying to do?
I'm trying agent based modeling
Think this https://www.youtube.com/watch?v=r_It_X7v-1E
I figured it out
I generate maps in edit mode. Turns out old cubes weren't getting disposed
Its better, but that culling job is still taking like 10ms
it's somehow not doing culling per chunk but per entity, which shouldn't happen
switch to standard shader and enable material instancing to see if that helps
and btw if you're going for what I think it is, you can use vertex colors instead of materials
you could also merge your meshes but thats a bit more advanced to get right
I'm creating the landscape in editor, so I could do it. It's basically just a big mesh with however many quads I need and vertex coloured
@solid flume I'll play devil's advocate here. I have some experience with simulation (and other stuff you with a PhD in CS).
@amber flicker no difference
It looks like you want to simulate something grid based, like finite elements, discrete integrations, etc
Yes
Why the heck are you using entities then?
This makes no sense IMHO...:)
You should just use a native array
It looked like a good way to learn
@tiny ore ??????
I see your point though
You have a Nail, and you are trying to use a screwdriver, honestly
Store state in a struct array, update it in a bursted job?
I don't
OR even better run this in CUDA or similar
Never heard of this
Do you have any idea that pretty much all the fastest super computers actually run processing data on GPUs?
Yes
Well, that's GPGPU (general processing on GPUs)
I should do this through compute shaders?
CUDA is the most prevalent of the programming libraries for this (NVidia specific)
@tiny ore and you're throwing a way too complicated answer and omega overkill at someone who just want to try stuff out
I see that it would be way better for what I want to do, but I want small scale and learn ECS and try stuff out
this is the #archived-dots channel
well, it is not, in an very optimized scenario
Yes, I'm throwing the industry standard...
for learning purposes I don't see why not
And don't want to learn an entirely new tool just for a project I'm doing to stop me from being bored
DOTS is not ECS only
A burst compiled parallel job on top of native arrays of structs is nice
Sorry, but I'm not wrong
I know you aren't. I'm not denying it
yes, but you surely can do that with ECS too if that is what you are trying to learn
I'm not a fanboy of any particular tech... I just pointed to the right options...:)
I know I'm not using the right tool for the job
The problems you are facing are mostly because you are going around and using the wrong tool
I just thought that trying to simulate a couple hundred agents might be a decent use case to learn ECS
I mean, it taking ages to cull is not my fault
You are designing stuff for entities semantics, where entity semantics are not a good way to express this problem
Specially archetype ECS (Unity's memory model)
You are neither benefiting much from data locality (not nearly as close as you'd be with a spatial buffer) neither making your life easier (in terms of expressive power/semantics)
I'm not trying to offend anyone here, or try say anything is wrong. I'm not in a position to do that, but can we get back to the topic?
Sorry, I had to say this...
You can.
Won't comment.
You can always go the wrong way...:)
I understand what I'm doing makes no sense, but I want to do it anyway
kindly fuck off now, you're getting omega annoying
he wants to use dots and ecs, let him be @tiny ore
I mean, there are nicer ways to say that
kindly fuck off now, you're getting omega annoying
Sorry... You can do whatever you want... Including call annoying someone telling you the right way to do stuff...:)
people, lets calm down please and go back to the topic
kindly fuck off now, you're getting omega annoying
there's a proper way to say that
@solid flume is just trying to get some help to learn ECS, lets help him
this is what this server is for
I'm storing data in native collections, and using it in a bursted job to do a bunch of collider casts. If I don't dispose of the collections in on update, memory leak. If I do, nothing happens
@solid flume how is your code?
I honestly just started with a proper DOTS way (name of the channel).
make collections
fill collections in entities.foreach
burstedParallelFor.Schedule.Complete
use bursted results in entities.foreach (different one)
dispose collections
Basically my code^
Burst is turned off, so there's that
this make collection part...
I'm guessing it's a nativeArray of sorts.
and you're filling it with stuff from components right?
wait, why do you have burst turned off 
Because I'm using foreach loops and burst doesn't like that
dispose collections you are passing the Dependency as the parameter?
just [BurstDiscard] it then no ?
What dependency?
In effect, I want to run an entities.foreach, then a bursted job, then an entities.foreach, then dispose in that order
Dependency = MyJob.Schedule(Dependency);
MyNativeStuff.Dispose(Dependency);
yes, the Dependency property
I mean, if you Entitiess.ForEach is Run it doesn't make difference, but if you are using Schedule it does
thus why seeing the actual code would make easier to help
So,```cs
var dep = new JobHandle;
dep = Entities.ForEach(...).Schedule(dep);
dep = burstedJob.Schedule(dep);
dep = Entities.ForEach(...).Schedule(dep);
dispose passing dep as parameter
(return dep/complete dep?)
Why does onupdate require me to return a jobHandle
you are using JobComponentSystem, use SystemBase instead
ComponentSystem and JobComponentSystem shouldn't be used anymore
but yes, your logic is right now
(return dep in your case if you want multithreading, complete if you want to finish everything right away on main thread)
I can't use a GetComponentDataFromEntity inside an entities.foreach?
I want a component on an entity that I got from a component
You can,
var someData = GetComponentDataFromEntity<SomeType>(true); // True for read only data, false if you need to write back
Entities.ForEach((Entity e) => {
var data = someData[e]; // Do w/e you need with data
}).Schedule();
you can even skip the GetComponentDataFroEntity altogether and just use GetComponent , HasComponent or SetComponent inside the ForEach
Oh. That's much better
The GetComponentData thing throws an error when I play
The has component throws an error
literally GetComponent not GetComponentData if you want to replace the functionality of a CDFE
Figured it out. Apparently I can't use those if the Foreach takes the same component as a ref parameter
yes, correct ๐
Honest question: is this from the same entity, or for example from another referenced entity?
In the loop iteration. The limitation of not being possible to Get the component
Okay, now when I did the dependency thing, it's throwing an error that I need to call complete on the job that writes to the native collection before using said native collection, which is what I want to happen anyway but i guess isn't happening
@tiny ore another referenced entity
hmm
trying to understand the reasons why, that's it (has to do with the memory model). Thanks
You're welcome
@tiny ore I think it's not strictly necessary but probably very verbose to define what you're trying to do is safe (if it is). When you do ForEach..(Entity e, ref Thing thing), the thing is in the chunk (as I guess you know). When you do GetComponent<Thing>(..) it's random access. By ensuring you remove the ref Thing from foreach, it means they can easily detect if you try to write to thing in parallel and if it's safe to do so. What would be nice in some future version is to have the expressivity to say something like "I want to write to all the Thing's in the iterated chunk and only ever read using CDFE". I didn't explain that well but I guess you're smart enough to work out what I mean haha
I assumed it is to protect concurrent modification, yes.
I just thought you could retrieve a copy of the original data, and modifications could be done with copy-on-write semantics under the hood...
But maybe I assumed wrong
Then it makes sense to not give access, because the loop may run in parallel, so you can guarantee no concurrent modifications happen to the same instance of the component
yea - plus, if you're sure anyway you can just disable the safety check
got it. ty
kind of obvious, ye, sorry... REF means you do want to write to it (at least the copy from the looped entity)
Say I do want to modify in parallel, but I want to use data (read) from the same component of other entities... What is the existing approach for it?
a) I manually create a copy of these so I can read the original data
b) any proper safe way to do it from the ECS API as it is now?
variation of a) could also mean I do one iteration with read only saving the data I want to modify in a buffer, then do a second parallel loop to apply modifications.
the variation of a - exists to a degree - you can read the data initially - do some modification as a copy, and then apply the changes later through their command buffer
the changes aren't applied in parallel though, it's played back on the main thread
ok, so there's an exposed command buffer (that's one of the common solutions for this)
yea - there are existing ones (e.g. at start and end of frame) that are sync points you can use for this - you can also create your own
or yea, you could write to a queue or a nativearray in parallel then process
one technique I kinda use is to attach a SharedComponentData to a group of entities - then I can easily filter the entities at the chunk level and process them in order - useful if there's a hierarchical relationship with many entities
makes sense.
I might frame this. I've been using HasComponent and was wondering if there were other ones, haha.
I still think everyone should be forced to write an IJobChunk before using the lambdas
They abstract a lot away
I wonder if many people just use IJobChunks instead of the SystemBases so it's more explicit
yea - it's awesome.. but I can only imagine how magical it feels not knowing what is being abstracted
I don't think many people do (IJC instead of SB for explicitness) - it's just a horrible amount of code.
I actually think this would be a lot cleaner and easier to understand as an IJobChunk
fyi your WithNone can be written WithNone<A, B>()
I just find with the level of abstraction all the variables got named virtually the same thing which makes it fairly confusing
Also I'm not really sure exactly what "GetComponentTypeHandle" and "GetEntityTypeHandle" are doing
Well, kind of more how it's doing or why it's required
It's not what you're talking about but does VS's autocomplete/intellisense drive anyone else mad? I have a lot of Translation translation type of things and I swear 90% of the time it thinks I want Translation which is the exact inverse relationship of how often I do haha
GetComponentTypeHandle etc is all to do with HPC limitations I had assumed
HPC?
I wonder if many people just use IJobChunks instead of the SystemBases so it's more explicit
well, I am one of those people haha
(High Performance C# ๐คฎ ๐ฌ ) the subset of C# that Unity support burst etc for - structs n stuff
interesting
Gaaah I'm spending dayzzzz making examples, documentation, videos and tutorials for something that might sell zero copies. Much work, no fun. Bleh.
MVP it. Throw it out there. Document later.
lol
DOTS people are used to no docs, it'll be fine
Besides, most the people that buy it are probably in this channel and will just ask you how to use it, hahaha
I actually hope it has a substantial non-dots audience ๐ค