#archived-dots
1 messages Β· Page 178 of 1
@stone osprey I understand you also. Archetype / Struct Inheritance is certainly much less risky and brittle than Function / Method / Code inheritance. Just something to be careful about when using it and why. Not trying to be a purist here.
So I don't the others were fully wrong.
You have to be careful when designing these...
At the same point, Unity's ECS is archetype, which kind of discourages add/remove (it's a bit expensive) in runtime (compared to say sparse set, in which these ops are super cheap)
Sorry to not have just pointed to "library or example X"
Just wanted to chime in the topic... In summary IMHO: useful, but if not used carefully it does "smell" a bit like OO
Thats understandable π thanks a lot
@stone osprey @tiny ore @zinc plinth I value this kind of discourse as well so thanks all for your replies. It was a bit of a provocation π.
Hi all.. Should I be using 2019.3 or the latest version for learning dots?
prolly go for 2020.1 to learn dots and also get the latest packages. as they stopped updating the packages on 2019.3.
Cool, will try again to get the DOTS sample working with it tomorrow
@lost umbra I'd recommend 2020.1 for DOTS as well... though worth noting if you did want to use 2019.3 for something, just use 2019.4 LTS in that case.
Another quick question... should we use properties in components ? Or just raw public variables ?
As you should fully use and abuse adding and removing components in runtime based in code... Not fully pre-defined archetypes that never change. - just to say @tiny ore, fully pre-defined archetypes where ICD's get enabled/disabled may be a really good way of working in the future so I'm not totally onboard with this sentence
I am currently trying to figure out how/if to port my event system to DOTS. I feel like there are many 'systems' that heavily profit from having some form of events such as quests and achievements. How do you handle this? Also did a more in depth forum post btw.: https://forum.unity.com/threads/do-i-need-an-event-message-system-or-do-i-have-the-wrong-mindset.969627/
though Erick did say that its expensive to add/remove components.
Interesting @amber flicker it does seem like a good trade-of between memory and cpu indeed
But to me it looks like a "valid" work around for one of the archetype model shortcomings.
it's all hypothetical until Unity release (what was supposed to be out a while ago) but it really should strike a good balance between the cost of changing archetype and the pain of bool checks everywhere
the structural changes are not only relatively expensive but sync points too
Properties or variables in components ?^^
I assume you are familiar with the sparse set model.
The "ifs everywhere" would be required to filter out disabled components... I mean:
- what is the API-wise difference between an entity archetype with Transform+Collider from one with Transform+Collider+(disabled)Body?
Properties or variables in components ?^^
@stone osprey As components should not have behaviours it woulndt make sense to have properties as properties define a behaviour that happens when setting/getting
The sparse set model solvers this well enough, specially if used with mask-based checks (but I'm getting into ECS model discussions, which is off topic a bit)
so the whole point would be that myICD.Enabled = false means a Query<MyICD> doesn't return any results - meaning you can take advantage of the queries in a similar way to changing archetype - it's just that behind the scenes it's basically checking bools.
So you still would not have real existential querying?
I'd say getter properties would not be so bad... Sometimes data-conversion setters are also fine (but that's just my personal opinion)
So you still would not have real existential querying?
No
Maybe we did not understand each other
Thanks ! So theres no guideline like : Always use raw attributes/variables instead of properties ?
What I mean is:
- if on the archetype model you can disable components and that will be (correctly) reflected in queries, a single query would have to be checked which archetypes MAY include it, combined with the "ifs" (could be mask based)
then it would loose the (hypothetical) advantage archetypes have compared to sparse sets
Maybe I did fully understand the changes required... But that's what it sounded to me
But maybe not, as I do not always query for specific archteypes. Nevermind
There's already an efficient filter for which archetypes match... That just needs to be DYNAMIC (as the enabled status might change the matching ones)
I was only talking about fixed archetypes + enabled being a good way to work with Unity's ECS. In general, I agree it's one of the shortcomings of their model v sparse sets - but it's not something I'm that knowledgeable about
I recall this blog post covers some details and discussion of Sparse Set ECS vs Archetype ECS that Unity uses. It may not be new info to many of you but it will be to some: https://leatherbee.org/index.php/2019/09/12/ecs-1-inheritance-vs-composition-and-ecs-background/#Sparse_Set_ECS
Thanks, just what i needed π
Anybody using some kind of event/messaging system with ecs?
@pulsar jay whenever this comes up people refer to Tertle's event system. Though I don't know if many people are using it in practice. Have you checked it out?
@inland root the post is a bit vague and empty
This is their con about Archtype: "The drawbacks are that Archetype ECS is more difficult to code and use."
That's NOT the only drawback...
@amber flicker doesnt ring a bell. So I guess I dont know it yet
@tiny ore Yeah that's why I made that disclaimer ha. You may not learn much from it just wanted to throw it out there
It does summarize well the main structures of both models though
@amber flicker thx will have a look at it
From a very general pov, the main issue with events is multi-threading - jobs/ecs - ordering/timing becomes something to manage in addition to / in conjunction with the ordering of jobs & systems
@amber flicker yeah that was the main pain point I was trying to figure out. The description of Tertle's events system looks to goog to be true so far π
do subscenes "bake" in the data from the gameobjects that exist?
seems like the vertex info I want to bake from the UI isn't correct on runtime since I can see the scale be downsized considerably compared to editing time π€
are there any good resources on NativeStream? the event system repo just mentions that you should know how to use them but there is not much in the docs
We cant use native hashmap inside components ?
What else can we use to store key/value pairs ?
UnsafeHashMap
Ah that works, ty ! π
Is there somewhere a cheat sheet for all those data structures ? It gets overwhelming pretty fast :ΓΌ
uh not that i know of online, I just mainly look at ILSpy and the Unity.Collections package for reference
just an fyi, with unsafe data structures in components, you need to dispose the memory yourself manually
Alright, thanks π
stupid question but is it better to just create a bunch of entity's using EntityManager not in a job or anything?
because that's what my profiler seems to indicate
EntityMananger should be avoid in job since it will force that job to on main thread
Use EntityCommandBuffer inside jobs for Schedule and ScheduleParallel use
*avoided
but there's not much difference between creating 1000 entity's and setting a single variable in a job with an ecb
than there is with setting a load of variables in entitymanager on the main thread
I think the difference is 10ms with the entity manager vs 7ms with a bursted ecb
Because it is not a heavy task to do. Setting a 1000 entities doesn't take much processing time so the difference will be negligible .
if you have lots of systems running.
then you should use ecb. since when that EM system runs all systems that uses sched before it will be forced to complete.
The thing is EntityManager will create a sync point, while the ECB does not. Might be important if you are running lots of jobs at the same time
its not going to be run lots of times just at the start
but it would save me time not having to turn it all into a job
You can just start with EM, if you get performance issues later, you can still move it to ECB & jobs.
Chances are, you will never have to switch, unless these systems are creating 10.000's of entities every frame or so.
yeah, I guess jobs aren't always optimal or necessary
If the task is simple enough and doesn't require too many entities per frame, doing it jobless might be cheaper (since a job has a very small setup overhead).
However with DOTS it think chances are higher of running into algorithm bottlenecks, then bottlenecks over job or no job usage (for simple functions). Keep in mind SyncPoints of course.
speaking of sync points.
Does moving a managed GameObject in ecs causes sync points? I have UI that's following the player.
What do you mean by moving?
updating the transform.position
Just to say, if it's specifically instantiating entities - as much as possible, do all instantiations at once and use EntityManager is good (obviously unless you do it in the middle of frame and it's responsible for causing a hard sync you wouldn't have otherwise had).
batch EM instantiate is much faster than anything else afaik
Speaking of which, I wish there was an EntityManager.Instantiate(NativeArray<>, NativeArray<> * n) overload
yeah I'm surprised at that, at least I did test it I guess
I don't find it that surprising... The only reason ECB is ever faster is you can burst add & execute but they haven't bothered for EM yet (except instantiation and possibly some other things). Otherwise ecb would always be slower - creating a big list of tasks and then executing later, disposing list etc. (sync points aside - assuming use of EM at sensible times)
Is it possible to use concurrent .NET types with dots such as ConcurrentDictionary? This would make it much easier to port my own event system to dots
I don't think so @pulsar jay but I could be wrong
I guess just pushing an event into a concurrent dictionary and then reading it in another system should be pretty simple and straight forward π€·ββοΈ
@pulsar jay Don't think so. ConcurrentDictionary lives in Managed C# space.
And it even allows objects in contrast to native containers
well.. if you want to use them with burst, definitely not I guess
I see. So it would prevent burst but should work with multithreading?
You should look into a NativeStream for what you want to do with Burst
the job system? I'd guess not - but you can do multi-threading manually. I'd just switch them over to NativemultiHashMap or NativeStream ^ though. When I say just... obviously not super simple.
Yeah I had a look at tertle's event system. It used NativeStreams and later swtiched to a custom container. I thought I could get away with sth simpler which would better integrate with my 'legacy' events
As the current system uses classes inheriting from an Events base class this obviously wont work with all the Native containers as they only allow structs
I'm not sure what the point of making it DOTS would be if it's in Unity and already works?
If it's managed you're likely not going to get any perf benefits
I haven't watched it but here's another resource if you want another perspective - https://unitycodemonkey.com/video.php?v=fkJ-7pqnRGo
There are a lot of systems that would benefit from dots in the next project. It cannot be pure dots though as there is too much stuff missing still (especially for VR). So I would need some way to properly propagate events between the two
I did watch the codemonkey video and it has some nice and simple approaches but its more of a starting point
E.g. it couples event queues tightly to specific systems
I didn't check it out but just in case it hasn't come up yet, instantiating an "event entity" is fairly common I'd say.
yeah I was also thinking about that
is there any way to ensure that an entity lives exactly one frame? because I would like to make sure each system has a chance to see it and then clear it up
sure.... a really nice way in fact
you just give an entity a tag like EventTag then have a system that runs at the end of the frame that destroys all entities matching a query for the tag. The EntityManager batch query methods are your friends. For the case where your event might be created in the middle of a frame but used at the start of the next, you can have that cleanup run just before your event system creates the new entities.
So I guess I would have to make it run right before the ECB
Yes
yeah that might work. As I should be going the way of composition instead of inheritance I think I should have an Event component and then additional e.g. EnemyKilledEvent components on each of thos entities
ooooh if anyone else comes across this, the reason my Blob ICDs weren't being instantiated was because I actually changed the ICD to ISystemStateComponentData... doh. Annoying. Does anyone know if it's necessary to dispose of blobs manually or if they're reference counted & destroying an entity will do so?
from the top of my head, doesn't the EntityComponentSystemSamples have a blob asset example? You can probably look there to see if they dispose it manually π€
hmm ok.. don't think I've seen those samples π
Looks v barebones, hard to say - they don't destroy any entities. Guess it warrants a forum post.
ah dang, that sucks - I'd be interested to know too if we have to do it manually
If we don't have to do it manually I'm slightly surprised as it must mean there's reference counting going on somewhere. I suppose I could try and go through source...
The blob asset is created in unmanaged memory. Call <see cref="Dispose"/> to free the asset memory when it is no longer needed.
I might look harder at BlobAssetStore - it has GetBlobAssetRefCounter for example
Oh except maybe you can only increment that if you're using a Unity Object π€
I hope this isnt yet another week without some sort of dots public communication silence π
I think they won't release any news until Unity IPO on September 17th
thought the little dots blip was kinda funny, considering they went through a lot to hide it from users lately
sort of doubt, its like a drip feed at this point, i just want a bit more big picture information
hopefully unity doesn't bail on dots. Or i'd be really pisssed XD
What does For those of you who prefer to wait until the software is out of beta, we expect the full release of Unity 2020.2 to ship later this year with a TECH release level of stability mean?
https://blogs.unity3d.com/2020/09/14/unity-2020-2-beta-is-now-available-and-we-welcome-your-feedback/ - blog update for reference - a few interesting things I wasn't aware of- as expected, nothing really on dots
it means it is expected to be as reliable (stability-wise) as 2020.1 release, if you are expecting more stability then wait for 2020.3 LTS
https://media.discordapp.net/attachments/623671788840288277/755139339624775720/unknown.png
Im getting huge performance drops when creating over 100k entities, is there anyway that I can optimize this?
Well you are adding 350 batches to each frame for the Renderer to handle
The RenderMeshSystemV2 does not like that. You'd need to optimize your meshes.
right but the mesh im using is just 2 quads
Same materials and UV offsets?
Well generally speaking if the meshes use different materials they cannot be combined into batches which increase the amount of batch calls. Even if it is just a simple quad.
ye but all the meshes use the same material
I have entities for world chunks, and sometimes I need to rebuild the mesh for world chunks but it could take more than a frame.. is there a way to work with entities over mulitple frames? Can I somehow query to get a few entities and schedule a job?
@ebon scaffold Then I am out of advice π
damn
schedule a job in the system and query the handle every frame till its done. in said job you work with native arrays then produce the final entity edits when all of said native data is done. @calm edge
Looking for suggestions / documentation on how to link a camera to an entity so that I can move it with the entity. Appreciate any resources / help
Looking for suggestions / documentation on how to link a camera to an entity so that I can move it with the entity. Appreciate any resources / help
@drowsy igloo https://github.com/DOTS-Discord/Unity-DOTS-Discord/wiki/Adding-Hybrid-Components
you can view the info in the community dots wiki - but hybrid components sounds like something that might help you with the camera
@coarse turtle Thanks, that helps a ton! I also found that the DOTS physics samples also have a player controller entity that I'm looking into right now.
Hi all. How today we should create own worlds in dots? We are creating new world, it shows up in entity debugger, systems being created, but there is no update for this world.
@frosty siren if you're using the default root groups (init, simulation and presentation system groups) you can just do ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world); and it'll tick every frame and systems show up in entity debugger
if you are manually ticking your world, entitydebugger doesn't support this unfortunately
Anyone know the most up to date sample code of using DrawMeshInstancedIndirect() with SPR/URP and DOTS?
@hollow sorrel thank you. We try to tick world manually through World.Update() but system doesn't update. but calls OnCreate() method.
I messed with it a bit recently - the workflow is pretty similar to a non DOTS workflow with URP
- Set up draw args (probably need to cache the compute buffer and indirect args)
- Set up compute buffer for transform data + bind to material
- Gather chunks and collect the LTW matrices to set transform data
- Queue the draw mesh instanced indirect call
@finite breach
@frosty siren did you attach your system under init/sim/presentation systemgroup?
not yet. will try it a bit later)
asking because world.update only updates those groups
we can't use 2 dimensional nativearrays can we?
I need to store two values like a minimum and maximum value together
Yeah, probably flatten it out or you store T** a pointer to pointer
so you can treat it like an array of arrays of sorts
a nativarray in a nativarray you mean?
yeah
or maybe I could just store two values in one value π€
yea that works too
use a float then have the minimum value be the value before the decimel and the maximum after the decimel
@pliant pike you may just want to use float2? You can of course pack your data tighter if you need to but I'm not sure if you need that level of optimization and there's a certain amount of false economy there too.
of course, that makes sense, I know about float3 I forgot about float2
, Thanks @amber flicker
there's also e.g. int2 if you want smaller data
so many data types my brain can't remember them all
@tight blade thats sexy AF
thank you! and those are all physicsbodies with physics shapes, so its physics enabled, not just visual!
I really became convinced yesterday that I was never going to get it working. spent the day rethinking features
and then this morning I doodled something in my notebook and tried it out
You need to post that to oddly satisfying @tight blade
So I have a prefab that reference prefabs in authoring components, during the conversion I use declare prefabs thingy but when the entity is instantiated, the children prefabs are prefabs and not actual entities
What do I have to do to have these entities not flagged as prefabs once the prefab is instantiated
I don't think this makes any sense but we'll see
i think if you want to do runtime conversion you have to call like GetPrimaryEntity on the embedded prefabs or something like that. I dont have any examples on hand but maybe this helps: https://gametorrahod.com/game-object-conversion-and-subscene/
if your problem is that once you've instanitated entities, they have a prefab component then you could just remove it.
I do this, the actionPrefab entity has all the components converted and the Prefab component
The anctionEntity entity has NO components except a transform
{
public List<GameObject> actions;
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
Dictionary<int, Entity> actionEntities = new Dictionary<int, Entity>();
foreach (GameObject action in actions)
{
Entity actionPrefab = conversionSystem.GetPrimaryEntity(action);
Entity actionEntity = dstManager.Instantiate(actionPrefab);
}
//ADD entity in buffer
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.AddRange(actions);
}
}```
uhmmm, i think if you're creating entities you have to do it in a specific way
its like .CreateAdditionalEntity() or summin
yeah CreateAdditionalEntity(Object/Component) will let you create another entity in the conversion system
So reading the article you've linked, it appears it's impossible to reference a prefab, and instantiate it in the same Convert method because at this point in the conversion the prefab entity doesn't have all the other components
Which makes sense anyway
Anyone know why DOTS, Entities, and other packages are not listed in the preview packages for Unity 2020.1 or .2?
because unity
A bit discouraging for learning DOTS and makes me think it's probably not worth starting projects on DOTS now unless they're purely experimental projects. Thoughts?
unless you're a madlad, like most guys that are here almost every day, there's nothing stopping you from making your game in DOTS.
madlads unite
All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1).
{
Entity action = ecb.Instantiate(learn.actionPrefab);
var buffer = GetBuffer<GrimoireBD>(learn.character);
buffer.Add(new GrimoireBD()
{
action = action,
id = GetComponent<ID>(action).value
});
ecb.DestroyEntity(ent);
}).Schedule();```
Any idea as to why I'm getting this? This isn't the first time I create entities with ECB lol
Ha it's because I can't call GetComponent in the same frame as the instantiation
You can't call it on your new entity since the buffer hasn't played back yet. You can call it on your prefab though, it should have the same ID right
A bit discouraging for learning DOTS and makes me think it's probably not worth starting projects on DOTS now unless they're purely experimental projects. Thoughts?
@drowsy igloo This has always been the case, that is: DOTS has not and is not ready for production projects. Like all experimentals / alphas /betas / previews, only use it / learn it if you want to be involved in the development of future Unity features and provide feedback, suggestions, bug reports, etc. The benefit for you is by the time DOTS is production ready, you (or your team) will be in a small pool of in-demand experts right out of the gate, and perhaps even shaped or guided DOTS development significantly. while others will be just starting to learn DOTS. That's the risk / reward. It's not for everyone. π€
DOTS evolves a lot, you learn something today, you need to relearn it in few months
in addition, overall DOTS framework (meaning all related packages) development has been quite slow paced, so if you need engine features, you have to build some wonky hybrid anyway
it's definitely not production ready and will not be in years at this pace but there are some parts of it that are already pretty robust
just... whole game in DOTS today... that's a nope unless you are willing to roll a ton of your own systems
I personally thought things would be quite good shape by now, but it's really far from that
like, when I started testing DOTS early on, everyone expected it to be more mature faster
it's been years now and Unity now even hid the packages from users - which should tell you enough how production ready it is
@dull copper I think some at Unity had that same optimism? Not necessarily the developers though more likely the product managers and execs until reality sunk in how monumental of a project this is for a such a large long standing engine with so many use cases in various industries, and with other features in heavy development
@drowsy igloo The main thing that Unity has changed recently here is just setting clearer expectations around this and not rushing things into preview or beta and having it one click away in the package manager, which ultimately disappoints most people by giving them the wrong idea about its current state of usability and causes a bunch of noise in support and discussion channels.
The "clear expectations" is also PR talk, so we can't possibly know what they are planning/doing internally.
So everything is just speculation... I am carefully optimistic to be clear.
@tiny ore yeah i mean I hope so.. better to underpromise and overdeliver, as the saying goes
But as you said, it's better to take things as they are, study, evaluate, etc...
Daily scouring the forums to find even the tiniest bits of info: https://forum.unity.com/threads/feedback-request-ijobentity.888121/#post-6315795
so you can't put dynamic-sized arrays in an IComponentData?
@inland root to me it did appear that the overall dev pace suddenly stalled or they hit bigger issues that took them more time to solve. I was hyped about the dots editor (where you had entities in place of gameobjects) etc but these all got put on hold for the time being. There's been a ton of things that I've expected to be there by now, like crossplatform deterministic Burst compilation but Unity keeps postponing it all the time
original plan of the latter was so that the feat would have been out for ~2 years by now
I've pretty much abandoned DOTS myself besides few select things from it, it's not safe for my use cases and it's not evolving in ways and direction in short term I'd want to see it go
I also really dislike the whole conversion setup
@dull copper ah yeah that makes sense, thanks for that info
I do support Unity on their recent action of hiding DOTS packages from users tho
Just learned some cool generic-foo
Generic arguments in a generic constructor can't be inferred, but you can create a static generic method that can be inferred. For example...
public struct MyGeneric<A, B, C>
{
public MyGeneric(B b, C c) {}
}
// Making this a generic static class since ``A`` can't be
// inferred from the type arguments anyway
public static class MyGeneric<A>
{
public MyGeneric<A, B, C> New<B, C>(B b, C c)
{
return new MyGeneric<A, B, C>(b, c);
}
}
// instantiating the generic with static method (``B`` and ``C`` are implied):
var x = MyGeneric<A>.New(b, c);
// instantiating normally...
var x = new MyGeneric<A, B, C>(b, c);
This gets significantly nicer the more complicated your generics become.
but I'd still rather have them have some "experimental" package setting somewhere for use cases like this
@dull copper and yeah I understand why the entity and hybrid conversion workflows exist but they are so jankey i'd rather they just skip them altogether and work on fully DOTS enabled editor features first.
it's actually the opposite, they are not working on direct dots editor anymore, it's on hold. instead they focus on making the conversion / hybrid work well first
rather than getting all slowed up with backwards compatibility tech debt integration
ahh well at least they are working on one thing at a time
i'll take that lol
they do have "DOTS editor" package to make the usage easier though but it's been rough
last iteration of it that I tried, actually lists all entities in gameobject like hierarchy and you can select items from it for examination, that alone is a big deal
I just wish you could also edit and add stuff there π
ah yeah having inspection / visibility in editor is a good first step anyway
it would be like third/fourth iteration currently π
ah yeah fair lol
first versions of that package worked very differently and then there was full dots editor (only for tiny) and then there's entity debugger which was more like debugging tool for initial development but kinda stuck there as there were nothing else
so you can't put dynamic-sized arrays in an IComponentData?
@visual mist
You can store unsafe containers in an icomponentdata but you're responsible for creating and destroying them. Or just use a dynamic buffer
hmmm I don't know anything about them but if they're using it for editor it doesn't mean we'll be able to use 5 right?
@zenith wyvern thanks, so it's not a bad idea to put some DynamicBuffer<Entity> fields in an IComponentData?
yeah i don't think it would be available for runtime already so soon
but to use them wouldn't that mean they use it in editor? seems soon for that too
not sure how they are going to handle it
You don't put it in the component, you attach the dynamic buffer to an entity. The dynamic buffer itself is a component on an entity. And no, it's not necessarily a bad idea to have a DynamicBuffer<Entity>, depending on what you're doing. You just have to be careful of referencing dead entities
sounds exciting news tho
it's like the first time in months that anyone's said they're working on something π - it's dumb but somehow that's reassuring
This is such a hilarious and fun community. We're like early prospectors before the full gold rush has started. All telling legends to each other about the gold in the hills, cursing the day we picked our picks and pans, and selectively sharing info to help coordinate a search
@hollow sorrel can u please tell more detailed about proper world creation at runtime. I tried do ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(world); but there is no AddWorldToCurrentPlayerLoop in ScriptBehaviourUpdateOrder. And how to attach created system under simulation group in new world?
@frosty siren oh sounds like you're using an older entities version
try ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world, PlayerLoop.GetCurrentPlayerLoop());
as for attaching systems, just world.getexistingsystem<simulationgroup>() (assuming you already added it) and then .AddSystemToUpdateList with your system
@hollow sorrel can you explain the significance of the c# generators? I saw that post earlier but dont really know what he meant or why thats a big deal π€·ββοΈ
@hollow sorrel thank you. Finally get it worked)
@safe lintel C# source generators lets you run code after compile kinda like analyzers and also add your own code in there after compile step (but not modify existing)
i think the 3 things joachim mentioned pretty much sums up why it's a big deal, faster compile, easier codegen (for unity) and better debugging
seems to be an evolution of existing codegen and should let us debug entities.foreach (unless that's already possible? haven't tried tbh)
also it should be able to replace reflection in most cases, since you can just analyze the assembly during compile and have no runtime cost
but it's only supposed to be out in .NET 5 with C#9, considering we're still on .net 4.6 that's like 4 years behind so i don't know how they're gonna support source generators
ah thanks @hollow sorrel
@hollow sorrel they can also be using their own compiler/code-gen (like we do for quantum) that generates plain C# code...
What the post means is that they are re-writing that part of the ECS engine (it's their 4th iteration - they've written already with: 1) dynamic injection, 2) manual job interfaces, 3) IL-weaving, and now 4) C# code-gen)
Indeed it can be .Net 5's one... But no guarantees just from that post IMHO.
They have NOT used C# code gen at all before AFAIK.
They did dynamic injection and IL-weaving, which are different than generating plain C# code.
This is AFAIK... I might be missing something, of course.
not sure how to spot the difference between actual codegen and IL-weaving
is there any clear giveaways
Easier debugging?
As it's easier to trace back the original code... That's one thing, I think.
Also any tools made available to C# in general will work (and your generated code will make use of them).
like flagging code for inlining, etc... But this is good if they fully go for 5, from my limited PoV.
mmm
well you can read the codegen'd lambda jobs C# in the dots inspector but i'm not sure if that's still IL weaved or actual codegen
but anyway C# source generator is a specific name for a specific tech, if they were just resulting to codegen they'd just say that
regular codegen wouldn't have the benefits of faster compile and better debugging
ye, the last sentence makes sense.
Maybe they are referring to the specific tech indeed
stupid question but I dont suppose anyone knows why this does not work
BaseMoneyAvailable[0].x = 0;```
its saying cannot modify because value is not a variable
so what is x π
@pliant pike BaseMoneyAvailable[0] = new float2()
or var val = BaseMoneyAvailable[0]; val.x = 0; BaseMoneyAvailable[0] = val;
ok thanks Timboc, I dont understand why you have to do it that way
native array index accessor returns the dereferenced pointer internally, which would return a copy of the value
I think I understand some of those words, thanks π
Im back with another design question : Spawning of entities... lets say we have the following structure : Chunk spawns Spawner based on weight, spawner spawns resources based on weight... the weight should be highly customizable. How do we realize this inside an ecs ?
The dirty part here is storing the "What should i spawn" method callbacks... we dont simply wanna spawn a empty archetype, we also wanna fill it with default values ( thats what the method reference is for )
I have 2-approaches:
- ) can't you have the spawner entity already in memory? I assume that the spawner holds references to your resources as entities, (which is already in mem).
then have a system, query for spawner entity, does ifs and elses on weights, goes through the list of referenced entities and ecb-spawns it.
OR.
2.) skip the spwaner entity entirely. have all relative resources prefabs to-be spawned in memory. since they're prefabs, you can add in your default ICDs and just set them during ecb.
have a system, query for all resources to-be spawned, check ifs and elses on weights, then spawn only the ones you want as you go down the list of resources to be ecb-spawned.
I lean on the 2nd approach though, since... you dont need to re-list the list.
@deft stump Thanks for your answer ! Thats an interessting approach, so instead of spawning... we create those types "once" and use them to determine what to spawn. And the chunk simply references to the already existing entities, which acts as "templates". I never thought of that, but it would work ( Im not quite sure how to "clone" those existing entities )... my mind still thinks that one entity should be used to spawn another one...
you can just ecb.Instantiate the existing entities. and it'll clone them.
Oh thats insane, didnt knew that ^^
I wonder how other games realize this... such mechanics are a bit "difficult"
are callbacks inside a ecs really a performance killer ? Lets say we have a spawn-system that iterates over spawn requests and each spawn request contains a method reference to the method used for spawning an entity... that method gets called. Would that really be a huge performance killer ?
I'd be more worried about the maintenance cost than the performance cost. Function pointers make your code a mess, most of the time there are better alternatives
Why do you need function pointers?
Of course, in unity i would use that instantiate for cloning existing entities... but im more talking about my server side code ( no unity )... there i have no easy way to clone prefab entities, so i need some way to fill them with default values
artemis odb ( java ) ^
@stone osprey i'm guessing that you need to fill it with default values on instantiate huh. since you need to call db
@fluid kiln Well that could get used... currently using the "Protoype-Pattern" for instantiating entities.... @deft stump Yep, thats what i thought i need callbacks for... .spawn += createDefaultResource;
@stone osprey I am using a similar system, I am constructing "template" Entities loaded from an XML + reflection with default values. I then use ecb.Instantiate() to clone those entities when needed.
If I'm purely processing a native array, and dont require any reference to entities, what's my most performant option? IJobParallelFor?
Obviously that's a super vague question, but maybe theres a hierarchical answer of some sort. "The fastest would be IJobParallelForBatch if you could blah blah, otherwise blag blah"
you know, come to think of it, I dont understand this description of IJobParallelFor at all
https://docs.unity3d.com/ScriptReference/Unity.Jobs.IJobParallelFor.html
why in the world would they want to execute, e.g. position[6]=position[6]+velocity[6] * deltaTime 64 times??
its not
its batch size
so 64 operations in a batch
its how the scheduler breaks up the work
not the amount of work being done
lol. Im an idiot. I think this is because I was imagining this job occurring with my own inner forloop, and I was planning to pass in my own batch size, and then just have each batch run through i->i+batch_size
now I see that the point is I dont have to do that.
lol. thank you.
everyone forget I asked this question now.
np π
@inland root @dull copper @deft stump and any others I may have missed, thanks for the input on their change to DOTS packages displaying. I've been somewhat (but not super closely) looking into DOTS for the past year and a half or so and I love the fundamental idea. I just recently started experimenting with it and, although there's a relatively steep learning curve, I've been finding it makes more logical sense to me too. Guess I got too hopeful that they were further along than they are. I think I saw in their reddit AMA that they'll be posting more about the future of DOTS in a blog post. Any idea when that will be?
AMA that they'll be posting more about the future of DOTS in a blog post. Any idea when that will be?
That's what we're asking XD
the AMA just said they'll write the blog some time this year
and it being such loose timeframe, it might not even happen this year (just trying to set the expectations right)
when you convert a gameobject to an entity, if there are multiple gameobjects of the same prefab, do they end up automatically sharing the same mesh in ecs ?
what's the use case for Worlds? there's not much info on it but im interested in checking it out if it provides another performance boost
https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/world.html
@craggy orbit some use cases:
- a server could run one match per world, having each world being completely seperated from eachother, so you could run multiple matches in 1 game instance which would be better than 1 game instance per match
- loading/procgen in a seperate world then merging it back with the main world when done
- seperating simulation from rendering to make deterministic simulation easier
as for performance, the main thing is that seperate worlds don't have to wait on eachother's sync points
ah gotcha. that last one would be useful for me. thank you very much!
Alright one more then I'll stop self congratulatory posting
But man I am really putting linear memory access to work and it feels so good.
How does the profiler look for that? If you're willing to be so vulnerable π€£
That looks really good!
are there any general considerations for making method/function calls from inside a ForEach lambda?
like, should you try to keep all the code/logic inside the lambda? or is it ok to call other methods in the system?
or should other methods be static? or lambdas themselves?
I think static methods are great for factoring out heavily reused code - you just need to pass everything they need into them so you lose a bit of niceness with the Get/Set/Has component methods and have to pass in CDFEs etc. Don't think I'd use any non-static methods?
ok, so don't make regular system class method calls, right? I was just trying to neatly organize some functionality like you would expect in a MB
@amber flicker if you're willing to help me out with profiling, I'd absolutely be willing! lol
Im terrible with profiling.
it's not for code reuse at all
@tight blade just take a screengrab of the timeline view of your profiler - that will say a lot π
hmm @swift heron perhaps an example would help? I don't think I can think of a good use-case for that but I could be wrong.
@tight blade cool but can you do one with a frame selected - that lower half should have some data
sure... it's actually the most simple use case you can think of. just off the top of my head, anything like this...
Entities.ForEach((Entity entity) => {
var data = FetchSomething();
var result = DoSomethingWithData(data);
TheseAreAllMethodsLocalToTheSystem(result);
});
oh wow, that is really useful
@tight blade nice - you can expand the 'Job' dropdown if you want but initially that looks good - lots of thread utilisation
need to open that up and zoom in a bit to see your jobs - clearly some physics going on
yeah those workers seem pretty well balanced
@swift heron the point of the lambda's is to have the data you want immediately there (linear memory access) and you're sorta bypassing the safety system if you work like that too
except for worker 8. that lazy pos
@amber flicker thanks that's exactly what i was afraid of
although, you're not reading into my made up method names, right?
π
i'm just checking that it's ok to call any method outside of the lambda or not
well... I haven't tried doing that (other than static methods) so I couldn't say for sure that the code gen would always work. To my eyes, doing that looks very confusing - I don't really understand the point still - but it might work. Obviously if those methods reference managed code you won't be able to use burst or threads and you'll have to be careful not to do any structural changes in the methods too.
@tight blade I have a suspicion that's not as fast as it could be but on the whole, great stuff - all using burst and workers π
Well, theres something that demo wasnt showing that may affect that analysis
do you see those little tiny bars in the far left and right?
and north and south
those are the actual extents of the simulation node range. the part in the center is a 100x100 grid. the part outside is a 1000 by 1000 grid. all the nodes are participating in the simulation, but I just restricted spawning entities to the 100x100 grid
if you're simulating 1mil nodes that looks pretty great to me then π
since things kind of fall apart above 75^2 entities even without my simulation
fall apart? π - do you mean rendering cost of all those dynamic cubes?
I actually have no idea haha, I just know that if I spawn like 75^2 or more entities, the player cant maintain above 60fps.
are you assigning a material to the cubes that has gpu instancing enabled?
theyre just default primitives
yea - try that (new material)
probably rendering then, you think?
the timeline view will show you what it is - my bet is rendering, yes
the actual visuals will be totally different. I'm going to pass the simulation computed array to a shader and have it just set vertices of a plane to those positions
or at least, naively, thats my plan
this is probably the point you could expect someone to point out this might all be better done in a compute shader π
I mean hell, and I think you may have intuited this by now, I'm like scrappy but lack a lot of knowledge. so... uh, if thats a thing that could help me out I'd definitely be into it
Do I have to write compute shaders in hlsl or what have you? because my head breaks every time I look at that stuff
the advantage of doing this on cpu is ease of use for e.g. buoyancy for objects or something but likely gpu would be much more optimal. There are also ways to read back from the gpu - especially if a frame delay is fine. (Obviously) compute shaders is a whole thing - likely not too hard now that you've worked out the parallel aspects of the simulation though.
wait, so compute shaders are gpu then? the name was leading me to believe it might be cpu
gpu, yea π
so if I want to run this on a phone, still need the ole cpu
well if the phone supports compute shaders - should be able to run it π
old phones.. most modern phones are fairly capable
only other reason to use cpu is if you were heavily gpu bound and had plenty spare cpu
it's definitely confusing. i have a pretty unique use case. all of my position data is loaded from an external source that represents real world position data of satellites. there is no input from the user. these systems will run on fixed timesteps and will do nothing but back-load data so it is available in real time to the system that is actually moving my entities. all that being said, i don't like monolithic code and was just trying to encapsulate bits of functionality for readability's sake.
just a little testing: i have one problematic method call that unity is currently barking at for operating on a reference type. changing the method logic to a lambda function does not resolve the issue. the error goes away if i make the function static or if i use a local function inside OnUpdate. looks like i'll just make sure i use static functions. thanks a lot for the advice @amber flicker
Ok - I don't know how helpful I've actually been but wish you best of luck! You may also wish to look into 'SharedStatics' if you have data being loaded via some monobehaviour that you want available in your lambdas.
and uh... no one has built a 3rd party tool for making compute shaders with a shadergraph like interface. have they?
it's very helpful, and i'm actually loading all my data inside of systems, not MBs. i can share my class in a gist or something so it's a little easier to see what i'm doing/talking about
and yeah, thanks a lot for the knowledge you're dropping on me, guys! @amber flicker you've already set me ahead significantly!
it's a total mess, lots of test/debug code as i just try to figure out the right way to organize this code
100% possible for me to just inline all the logic inside the lambda
when you convert a gameobject to an entity, if there are multiple gameobjects of the same prefab, do they end up automatically sharing the same mesh in ecs ?
@buoyant ivy what happens when you try? If the gameobjects have the same mesh, I believe they will both have the same IsharededComponentData value so be in the same chunk.
how can i check that ?
i think the component in question is the RenderMesh or something right? i think that extends that isharedcomponentdata. but how can i check that its the same reference on all the entities ?
@swift heron from a quick look, this is similar to a convo we had the other day (https://discordapp.com/channels/489222168727519232/497874303463850004/754700895920324619) - it looks like you have some async call within the lambda - I'm surprised this compiles at all and I'd try and avoid it.
@buoyant ivy have you read this? https://gametorrahod.com/game-object-conversion-and-subscene/
@buoyant ivy easiest way is if you use the entity debugger, the gameobjects/entities should appear to be in one chunk (unless they have different components)
ya i really have no idea how else to handle it. all of the data must come from these external sources. i will load about 170 entities that represent satellites. each of those has about 10MB of data that needs to be fetched once an hour
systems require data to run. They will run when that data exists. So simply create the entities with reference to that data once the data is loaded.
i have 3 systems responsible for handling this, 1 to instantiate new satellites, 1 to keep the next hours worth of data loaded, and 1 to move the next data point values into the current position component
one system runs once per minute, one runs once per hour, and the other once per day
i just want them to be "in the background" all the time
I wouldn't be afraid to leave the systems running every frame and just create & destroy entities when new data comes in
the system that needs the data to exist to move and render the satellites only knows that it has the current position and the destination position at any given time
i read about chunks but how do i see what a chunk is in the debugger
but i can't fetch 1.7GB every frame π
@swift heron you don't need to fetch 1.7gb every frame..
ok i see it thanks
very crudely I'm thinking.. data.OnReceived => DefaultWorld.EntityManager.CreateSatellite(data) - that method creates a satellite entity maybe with a BlobAssetReference filled with the data.
so when my "app" starts, there are no satellite entities. a system runs immediately and then again once a day to see if we have launched any new satellites. at this point i'm just grabbing all of the "Operational" satellites and creating empty entities for them
another system will loop through each satellite entity once per hour.
and pull the future positions: https://ephemerides.planet-labs.com/0e0f_oem.txt
it will capture the next hour's worth of positions, each 1 minute apart, and store them in a dynamic buffer attached to the entity
the 3rd system will run once per minute and pull 1 element from the buffer and load it into the data compoment
and the movement system then interpolates each frame between those 2 points
i hope i explained that well enough to make sense
sure - does my approach above not make sense in that context?
can be a dynamic buffer instead of a blob (10mb dynamic buffer's quite big though)
so i'm just not clear on what data is or it's OnReceive callback π the http portion of this was also definitely a concern... because the http requests happen relatively infrequently, i don't want to block. i thought if i just scheduled the calls AND they were async, the systems and jobs could continue to run and the data would just be available when it's available
basically this: https://gist.github.com/joshfix/061cf191b62866d1a3791bad02215989
at this point, there are no satellite entities -- this is the entry point for creating them
once this runs, it should let the system responsible for making that 10MB call to fetch the position data on each satellite, as the entity query will start to match
This is becoming a bit specific/involved - I should probably get back to what I was doing haha - a few very quick thoughts:
- No need to kick off async in SystemBase - I might personally use a coroutine but not that important
- My code above was very psuedo code - the point being that after async getting the data, creating entities with blob/buffer to data means that your other systems don't need to know anything - just that an entity with a reference to data now exists.
- Modifying the buffer every minute (like I think you're doing now) is fine. So probably would destroying and creating a new entity every minute. If modifying, instead of creating a satellite entity on data load, I'd create e.g. a 'NewSatelliteData' entity with an id (common to the existing satellite entity) and have a system update the Satellite entities
float3 newTargetPositionfor example.
ha ya this is all above and beyond and very much appreciated!
i think your pseudo code is a match for what i'm doing now
cool
i think i'm close on #3 too -- except when i create the satellite entity, i'm just attaching a "NewSatelliteTag" component to it, which will be removed once it gets its data
and i'll keep diggin on #1
I think that's a bit of an important difference. Rather than it 'fetching' data - creating an entity once the data exists. Said slightly differently, once the data is loaded, create an ecs representation of it. Then systems can just require that data be present.
aww man now you're confusing me again! π so i need to "fetch" the data so that i can create the entities
ah yes
ok, that is exactly what i'm designing and implmenting! whew...
thanks again! i am walking away from this convo with very useful knowledge
ace - best of luck and caveat, all just my opinion - some may disagree with what I've said
I was just looking at the Unity DOTS Sample (FPS) again and now I am wondering why did they use a Monobehaviour Singleton as an "entry point" instead of a system?
DOTS Sample is a badly named prototype. Not at all representative of how you're meant to make dots games
Even unity devs say more or less as much
yeah, the DOTS Samples are all horrible. they only serve as a starting point to google forum posts about how bad they are so that you can get a decent answer
Could anyone explain to me why the "live conversion" workflow from GameObjects to Entities is the only option? What if I want to do a Pure DOTS approach without GameObjects? This whole GameObject <-> Entity conversion thing gives me the feeling DOTS is not finished yet.
Could anyone explain to me why the "live conversion" workflow from GameObjects to Entities is the only option? What if I want to do a Pure DOTS approach without GameObjects? This whole GameObject <-> Entity conversion thing gives me the feeling DOTS is not finished yet.
@south birch Well thats the problem. It is not finished yet
As far as Unity is concerned "Pure dots" just means no gameobjects at runtime. We're meant to use gameobjects/prefabs at edit time
I was just wondering if it would make sense to have some kind of initialization and gameloop management system. So I took a look at the sample and found that they just use a Singleton π
gives me the feeling DOTS is not finished yet.
that's perhaps the kindest outlook on DOTS we see around here
Alright, noted. Let's hope their elimination on GameObjects is on the end of the todo list..
Alright, noted. Let's hope their elimination on GameObjects is on the end of the todo list..
@south birch I am not even sure if thats still planned at all
They used to sell project tiny as a solution which is completely build on entities
DOTS is like self driving cars. getting rid of human driven cars might eventually happen, but no one is considering that the active plan
@tight blade Okey that made me laugh
But now they are mainly focusing on the point that edit time data should be completely separate from runtime data
Even project tiny still uses gameobjects at edit time
Even project tiny still uses gameobjects at edit time
@zenith wyvern Oh does it?
Then I am misinformed π
Time to make an optimized MMORPG in project Tiny!! lets gooo
You set up your scene with gameobjects and then convert everything to entities via subscenes or when you hit play. This is how Unity intends it to work
yeah, @south birch , you get to use the sweet networking package that totally exists and is a real thing
Was it like that all the time? I thought they were pushing the all ecs way with tiny at the beginning
Tiny is special in that it literally cannot use gameobjects at runtime, but you still use them in the editor. In normal unity you can use both and it's fine.
@tight blade They just released 0.4.0, it's almost done and since it's DOTS you can obviously use it in Project Tiny, right? right?
good to know
they did have a 1:1 dots editor a long time ago
but they ditched it, because after the most basic of stuff, doing it that way is kind of awful
they did have a 1:1 dots editor a long time ago
@safe lintel thats what I thought. so my info is just out of date
@safe lintel That's really interesting, could you give an example?
components dont have default values for one
I still dont understand why authoring entities would be so bad (except for the transition from legacy tools) as they are basically just "objects" without a hierarchy
Because they would be giving up the countless years of work they have put into gameobjects and prefabs
Better to leverage that work at edit time and use super efficient entities for runtime
yeah thats what I meant by: I see the need for the transition period
Of course right now the process is super arcane and awkward and buggy. But in a perfect world it will be seamless and smooth...eventually
if you look at how animation is converted and the resulting entity, theres like so much crap going on you need some sort of conversion to handle it. people complain about boilerplate in code, but you will be entering in so many fiddly details in the inspector, its the stuff of nightmares
Hopefully. Maybe
@zenith wyvern That sounds logical I guess.. I mean the nested prefabs took them years. If you ditch that now you could say it was all for nothing.. But that would be a bad attitude imo
like does anyone want to be manually adding all those components just to make a plane renderable?
that doesnt even cover own game logic @south birch
I wouldnt need the HybridChunkInfo and RenderBounds now would I? At least from a normal workflow perspective. It's just extra info provided, not a mandatory component to add.
But I could be wrong.. π
might be added automatically, ill get another example π
Cheers
I guess the example is good enough. I can see your point
So what are you guy using as an entrypoint? If I remember correctly there is a hook where you can setup all the systems yourself. I like the way unity sets up the default systems (physics etc.) itself though. So a system to initialize my custom gameplay systems might be intersting
heres a weapon from my own project https://imgur.com/a/7dzRYPq (not sure how to remove the embed)
Well damn
since dots encourages flattened hierarchies, i also have entities(where they would be class objects) that arent part of the hierarchy but necessary for it to work so more clutter to the editor hierarchy
Alright, this does bring your point across, lots of 4x4 matrix, lot's of Vector4, It's almost as if you want that to be converted to more convenient data types and shown on the editor, oh wait.
that doesnt even cover own game logic @south birch
@safe lintel
game logic in dots is a myth!
a character is worse, https://imgur.com/a/VKa9g6t its a fairly old example of what the dots conversion results in, but so many ugly buffers and really obscure data, also zero actual gameplay components there so for a AAA type project, id imagine just a horrifying amount of crap to exist there.
this also ignores that - all dynamic physics entities at runtime are unparented so for characters or complex setups they wont be neatly tucked away inside a transform hierarchy, you will have like 30 odd rigidbody entities just hanging out in addition to those two root character entities(that get converted from a single character gameobject).
in my own project a door was 4 separate(non hierachical) entities π€ͺ
ive come to the conclusion that while i think conversion is totally necessary, still not sure if explicitly relying on converting from unity's old stuff is the way to go. a new dots authoring type mightve made more sense? anyway theres a lot of room for unexpected setups. they have so much ground to cover before its seamless.
there are only cubes -_-
Thanks for making your point @safe lintel I'm convinced.. I guess it's a main disadvantage of data oriented development.
someone will probably just write their own conversion system that is better and make bank on the marketplace π
the sheer quantity of amazing assets and how fast they get new features and stuff makes me wonder why official things in unity take so long
there are some advantages to not being forced to support older client versions.
true but many of the top assets do seem to support older versions. im still annoyed monobehaviours still have .rigidbody .collider .camera etc when they have been made obsolete for years, but then other stuff unity just zaps out of existence without warning
true
it drives me crazy too, like back in the mid 2000s i was working with json.Net who had completely figured out interface and dictionary serialization, and it took unity like 15 years and we still have terrible serialization support, their new JsonUtility is not really any better. No interface serialized field support in the editor. Someone like odin comes along and just knocks it out of the park. I feel like a company of Unitys size should be able to get these sort of things handled.
I made an asset for tagging (unique guid's per gameobject/entity) and decided to override .tag in my assets tag monobehaviour - my asset replaces it's functionality so I did it to avoid confusion.. but it was a hard call - does anyone use Component.tag?
Apologies if this question is unwelcome but would anyone value a nice UI for creating/renaming/categorising ICD tags?
why would it be un-welcome? π
also the opposite of that is how they buy things and then they just languish - like textmeshpro exists as its own thing that doesnt feel integrated, probuilder hasnt really had any improvements since being bought, its experimental stuff is still marked experimental since prior to being purchased. the next slow motion fiasco may or may not be bolt.
the mecanim default human avatar/bug eyed dude triggers me so hard, it looks sooooo unprofessional and yet it remains
also @amber flicker didnt even know it existed outside of gameobject tags
haha @tiny ore I guess because it's commercial/market-research question? ||current asset: https://twitter.com/timboc_/status/1302981776051261440 , http://u3d.as/1ZsW- wondering whether to add support for ICD tag generation as it would be easy||
#BTagged 1.1 now up!
β‘οΈEasily reference GameObjects anywhere
β‘οΈAvoid messy hierarchical references
β‘οΈEvent callbacks for anything tagged
β‘οΈAll project uses at a glance
β‘οΈSupports editor functionality
β‘οΈMB/DOTS examples + all source included
Get it hereβ¨https://t.co/JVfw3XqPo...
@safe lintel I think Component.tag just accesses GameObject.tag? Which is just dumb? Or maybe I'm wrong π
That looks fancy
You should definitely add IComponentData generation than that thing is a must have
Roger that, thank you. Will have a think of a clean way to integrate it into the UI.
just trying to validate another hunch... is
Entities
.WithAll<UpdateMovementComponentTag>()
.ForEach((Entity entity, ref EtlHeaderData headerData) =>
more performant or in any way superior to
Entities
.ForEach((Entity entity, ref EtlHeaderData headerData, in UpdateMovementComponentTag tag) =>
i don't need the tag, just need to query for entities with it
I would like to know for sure but my assumption is 1) is better. In fact, I donβt know if with the debugger on it allows you to do 2)?
Are callbacks (Lambda, method, delegate ) used in systems or components really bad for the performance ?
I often use method references for injecting unique gameplay elements... like executing different and dynamic actions on the death of an entity
@amber flicker that was my assumption as well. #2 does work fine, i suppose since the tag is nothing more than an IComponentData with no values, but i suppose i'll stick with #1
@stone osprey not speaking from experience, but i've read many times that callbacks are very bad for performance
theres a point where you have to make tradeoffs to actually be able to implement logic with less effort on the developer part
in my c based ecs game I just stuff function pointers into components from a suggestion that was posted here
gives you the ability to swap out functionality super easy
@low tangle Yes, thats what im also doing rn, either real method references or lambdas ^^ for example to react to events, like collisions... sometimes i have the feeling that realizing certain advanced mechanics with a pure ecs approach is nearly impossible.
'pure ecs' doesn't mean you cant use function pointers and void data. if reactionary systems were much easier to write, like in say EnTT or FLECS you wouldn't need so many callback based things
theres some real missing functionality in UECS that is holding it back a lot
on a personal non-unity project, im storing OOP-ish "brain" objects in a component
I've been thinking about it lately after switching to UE4, and I think the thing I was really missing from ecs was the fact there isn't any low level engine inlets to allow you to finish ecs for your project. so things like animation which are just now becoming a thing, were (I'm probably wrong) impossible to submit the matrices for skinning avatar bones etc, until that low level api was added for their animation package. if unity had exposed a lot of the low level submit structures for ecs, then I would've been able to finish up the systems as needed, and if those changed over time it would've been fine, as long as there was some way. as it stands everything had to come back though the old cpp object components to properly register into the unity rendering pipeline, aka gameobjects and components
closed source is a bitch
100%
@vagrant surge Phew... im not the only one ^^ heres how i inject logic mostly ( java, serverside )
you maybe be able to edit that in ue4, but doesnt make its easy
No acess with unity pro ? Atleast i thought that you gain acess to the source code with pro*
a lot of ue4 stuff goes directly against ecs stuff, and injecting/hooking stuff will be very painful
the code above is for this prototype im making
nice will check it out
ill eventually put it on unreal or unity (making multiplat on raw cpp + sdl is a huge pain)
made that in 2 days, its pure ECS
yeah I'm not worried about ecs as much, as I simply have to finish the game at this point
entt + SDL lib
thats what I've been working on as well lol
entt + sdl + taskflow + xxhash
taskflow for all non ecs jobs in the engine
but thats just a side project when not working
i found SDL render api works incredibly well with ecs patterns
excelent
the thing is that SDL is stateless
yep
you just call RenderCopy to render a sprite
no need to create a sprite object or similar
another fun thing is that the game i posted runs at around 0.5-1 ms for the entire game loop
so yeah basically unlimited amount of sprites no prob
goal is to eventually make it run game logic at 120 fps no matter what
so that the entire thing can be 100% consistent
throw a fixed timestep in then
yes, fixed timestemp at 120, decoupled from rendering
just wanted to dev something very simple that i can develop to a good point in a week or two
yeah those little projects are critical to keeping the mind happy
regular work cant experiment, waste time on new things that might not work
want to see if i can convince nintendo to give me switch devkits using that game
and actually release it once finished, maybe
devkits are pretty expensive
ill just hire freelancers to do art, sounds, and fx once i have at least 50% of the content locked down
oh thats no prob
im preparing a porting studio
you can just sign up to the dev portal with your business info
and im already on talks to port other games to switch
so just gotta get them devkit
yeeee not so easy
switches and 3ds both you can buy direct now
took one day, yeah
one day?
i contacted nintendo through their dev portal last friday, didnt receive anything yet
i did contact xbox
and already signed ndas
playstation i already have it
should be pretty easy then
lets see. I have a significant budget for the business, so buying devkits for everything doesnt even make a dent
will port unity and unreal games mostly, tho ill ready some non-engine tech demos
more than money, i kinda see it in a fairly different way
in my country, spain, i constantly see very nice games that sell literally nothing on PC or mobile
i believe offering porting/publishing contracts to those can make a lot of profit
Any idea why netcode creates 3 GhostCollections even tho I only have 1 in my hierarchy during conversion?
Any idea why netcode creates 3 GhostCollections even tho I only have 1 in my hierarchy during conversion?
It creates a bunch of useless prefabs and bloats my entity list ;_;
@low tangle btw did you see the size of the .zip
take that, unity tiny
XD
i wonder what would the size be if i tried to do an emscripten build
given that emscripten implements SDL, which is the biggest hit to the size
i think it could end at sub 0.5 mb
i need to make http requests for 165 of my entities once per hour. when the system starts making these requests, unity falls to its knees. each request is ~10MB of data and i need to parse the response and finally append about 60 elements to a dynamic buffer for each entity. outside of a foreach lambda, i can make all the requests async and it takes about a minute to finish.
but inside the foreach, instant death
these processes are not time sensitive -- it's just a background process that ensures data is ready when it's needed. can anybody offer advice on the proper way to handle these longer running background tasks?
dont write inside for each imo, run it on main thread
Addressables also gives issuses if you do something with it inside ForEach
i mean you dont have to do EVERYTHING inside systems or ForEach
if it has to be done inside a system, you should create the array of async tasks, and check them over and over
honestly you should just stuff them into a monobehaviour though
then stuff them into the entities once done
You could do it in a non-entities job?
And make sure that it can run cross-frame
async stuff doesn't belong in jobs
It's a pity there's no job-async integration tbh
both of them are sheduled things that have dependencies
ya so, this is my first forray into ECS. i had all of this working with MB already, then in standalone ECS, then with client/server using DOTSNET
so trying to force this into systems is strictly for my learning π
async in Unity works weird tho
if you use Task.WhenAll it will hang forever for example
i also read to not user coroutines inside the lambda
so i'm not entirely certain how to ensure all of these requests are ran in the background using systems
if it's just not reasonable, then i'll abandon the effort
the array of async tasks sounds interesting... i'm assuming that would be in a dynamic buffer? since i don't want to be storing state in the system?
you can store state within systems
and should
there is some runtime only data that isn't gameworld related
that is non game requests, io, http, assets etc
native memory for plugins, those kinds of data should be stored within the system or globally
so does this throw a monkey wrench in things... previously, i had a static list of "things" (ids of satellites) that i manually built and iterated over outside of any entity query. i just finished a system to dynamically check this list of operational satellites once per day and instantiate any new ones that may have launched. now the system i'm working on is the one responsible for fetching the future position data for each of the 165 satellites. it obviously only runs after the first system has created the entities.
hmm.... ya well i suppose it just won't really work for this use case
it would work?
nothing in there screams that it cant
System1: Has it been a day? Spawn a update req, Start the req (send the actual http requests off), update local timer so we're done for this day
System2: is there a update req? check if its done? if done, update all sat positions, remove req
store the actual async objects that represent the request somewhere and your done
that is pretty much the solution i'm trying to work towards
but, i'm doing everything with entities
can be done within one system as well, just with a state bool for switching
that is with entities or not
same logic
right
i've had that exact thing working without entities... still in systems, but without entities until late
logic - what your doing, then the data to support that
now, i'm trying to immediately start with entities. but making those http requests in the 2nd system completely locks up the editor
creating the async tasks?
create a monobehaviour so you can make the task creation async as well then, attach it to the update req using a hybrid component
then you can make the task creation slower and not choke up one frame
any idea how i could buffer the change of one simply variable ? CommandBufferSystem only allows the replacement of whole components... i basically need to modify one simple attribute of one component ( Working with prefabs here, dont wanna override the whole component )
pull the value of the component modify the value then place back
if not, you have to pull that value out into a isolated component, if you really cant read then modifiy it
I can acess the component when its not created yet ?
you can just sign up to the dev portal with your business info
@low tangle
yeah no its super weird. The switch dev kits are like getting membership into some secret society
for sure
I checked after saying that
I'm trying to work though so I didnt update my post here mb
its such a funny experience. it reminds me of old MUD games where other players try to prevent newbs from finding and joining the thieves guild.
thanks a lot @low tangle -- one final question... i've had the async solution working in a system without an entity query. is doing this specifically in a MB an important aspect? or would it work just as well in a system?
would be fine within a system, just have to manually poll the async tasks
instead of just awaiting them within a mb
ok interesting. this was my previous solution: https://gist.github.com/joshfix/792cfdb46175c69ef8ab7258f96db8c4
and it seemed to work, but i don't know if i just got lucky and i'm doing some things seriously wrong...
well the same async system unity has for mb might work within systems, but I wasn't aware of that
async is a mono runtime component not really class based
thanks a bunch @low tangle! your help is really appreciated. i'm going to move all this data loading work into MBs and see how we do π
I have a NativeArray of colors that have all the information I need to generate an image. My NativeArray<Color> can update at 200fps no problem, but when I use SetPixels and Apply it can take 30 seconds or more if it's a large image. Is there a more direct path? I tried Texture2D.SetPixelData and it didn't seem much faster.
I should note that I've tried methods of not updating mipmaps and that only helped a little.
After a bit more searching I've found Graphics.Blit and Graphics.CopyTexture as possible options, but I'm wondering if this actually bypasses the need for the slow .Apply()
those only operate on textures that are on the gpu
which is what apply is doing, copying your pixel data to the gpu
one of the set pixels that requires a proper stride is the faster copy method
Since the NativeArray is really fast, and GPUs are really fast, my hope is that I can make it display really fast π
So maybe my question is, what's the fastest way to copy pixels to the GPU? Which may not be dots related at all.
it's probably either the Apply, or a ComputeBuffer
ComputeBuffer sounds promising.
@tiny solar yeah ComputeBuffer or GraphicsBuffer. You will still pay a penalty in latency for the memory copy from CPU mem to GPU mem however unless you are targeting a platform with a shared memory architecture.
I'm done with work in 30 minutes and I will try.
I don't feel like I'm the first person to want to do this though - maybe if I understood what was happening in Apply() then there would be a way to format my data better. Right now it's in NativeArray<Color> but it could be anything
@tiny solar
public void SetData(NativeArray<T> data, int nativeBufferStartIndex, int computeBufferStartIndex, int count);
https://docs.unity3d.com/ScriptReference/ComputeBuffer.SetData.html
oh snap
I tried ComputeBuffers like 5 years ago, so I'll have to relearn it but shouldn't be too bad
@tiny solar you could even do additional SIMD optimized processing on that data in a GPU compute kernel (written in HLSL) before actually rendering it if you wanted at that point. a lot of possibilities to balance your CPU and GPU performance budgets that way.
probably someday the Burst compiler will just target the GPU as well, i think there was some kind of hackweek proof of concept? but don't hold your breath on that yet :)
Right now I'm at such a disconnect between my data being calculated and displaying an image that I feel like any step like this is going to be a dramatic improvement
200fps on the array, and >60 seconds getting an image
I'm about to start, my guess is that I should try and copy the array to a ComputeBuffer and then output it to a RenderTexture via ComputeShader.SetTexture, but I might be missing a Texture step
I'm about to start, my guess is that I should try and copy the array to a ComputeBuffer and then output it to a RenderTexture via ComputeShader.SetTexture, but I might be missing a Texture step
@tiny solar that would work, but you can skip the texture if you don't need it and have the material shader read the ComputeBuffer directly via Material.SetBuffer https://docs.unity3d.com/ScriptReference/Material.SetBuffer.html
Yes I want to skip the texture, thank you
this getting more into #archived-shaders territory though and less #archived-dots so maybe check in there once you get to that stage
it's all kind of converging sooner or later i guess π. shader programs, whether for graphics or general purpose compute are strictly "data oriented" by design, as dictated by GPU architecture / intrinsics
I've been learning all sorts of stuff on my DOTS journey
Very appreciated, I'm going to try this
It works, and it's beautiful, thank you @inland root
It's literally over 10,000 times faster
I'm finding a need for an easy burst-compatible delegate past FunctionPointers. Would y'all be interested in something like that?
You'd declare a ValueDelegate in your jobs that is constructed from delegates.
public struct MyJob : IJob
{
public ValueFunc<int> Func;
public void Execute()
{
Func.Invoke();
}
}
// calling the job
var job = new MyJob { Func = (ValueFunc<int>)(() => 0) };
job.Run();
It would have the same limitations as Entities.ForEach, and I'm not sure how to get around forcing a cast when defining the lambda
@inland root I've been watching this thing generate ever since I got it to run in realtime. I dedicate this one to you:
if I have some conceptual hierarchical data, say a Deck that contains come Cards, should I have some DeckData : IComponentData that contains:
- a
DynamicBuffer<CardData>? - a
DynamicBuffer<Entity>where the entities will supposedly have someCardData? - neither of these and I'm thinking about this wrong?
Or just have lots of Card entities with an ICD of WhereInDeckData and store an int value.
but what relates the Card entity to which Deck it is part of?
Unity finally updated https://github.com/Unity-Technologies/EntityComponentSystemSamples
ECS samples updated for Entities 0.13 and they also just updated physics samples one minute ago
previous update to the ECS samples was from Feb
hmmm, wonder why they updated the ECS samples to such old version
but what relates the Card entity to which Deck it is part of?
@visual mist I mean, you can have another int in the icd called deckID or something.
or slap another ICD on the card.
ok, so in this case more of a "reference" rather than nesting components within one another
Physics now updates in the FixedStepSimulationSystemGroup
Physics bodies can now be smoothed if the Physics step and Rendering steps are out of sync. New options have been added to PhysicsBodyAuthoring to support this functionality, similar to the interpolation option on classic Rigidbody components.
about time
nice
have the DOTS team just come back from a few months r&r? π€
also re upcoming .enabled states: Hi, did I miss the new feature or were you a bit optimistic in the ETA ? Joachim_Ante: I was yes. π
Im back with another design question ^^ At the start of my game i spawn or load in chunks... if a chunk contains no spawner, it should create a spawnerRecipe and if that recipe is allowed to resolve the spawner, the recipe spawns in the spawner. Im using the command buffer system, so this whole process is "asynchron"... that means when my chunk system checks if its allowed to create spawner recipes, it does not know if the command buffer already has recipes enlisted... this causes each spawner to create 2-3 times the amount of spawners... is there a way to determine what is buffered in a ecbs ? Or do i need to rework my chunk/spawner structure ?
Chunk -> If chunk contains no spawners -> create spawner recipe -> if recipe is allowed to resolve -> recipe creates the actuall spawner -> spawner gets inserted into chunk
Can we somehow access singleton entity not from system and not using entity queries? I mean with such a clean way like GetSingleton/SetSingleton.
so 2020.2 just broke subscenes
aargh it was a bad idea to update to 2020.2
so here's what subscene is supposed to look like
here what the panels looks like when I apply subscene
kawabangga baby
have you cleared the cache?
I think DOTS->Clear entities cache or something - longshot but just wondered if it might help
i'll try
I haven't tried subscenes with hybrid renderer
but it seems to work for me on some custom stuff π€
Whats a pure ecs approach of a "Spawner" ? Lets say our spawner should choose N locations, have a set of entities to choose from ( for spawning ) and each of these entities have one or multiple conditions when they are allowed to spawn... any help here ? Cant find any usefull and flexible structure for this :/
One example is minecraft... i know that each entity is weighted and have conditions... like monsters are only allowed to spawn in at night, other ones only in the sea
@amber flicker yup that works
sweet
from the top of my head, maybe if you had n collections of entities to choose from, each collection can refer to some kind of rule (I"m not sure how these rules be set up - enum/bit flags?). You can check if the rule is applicable and then spawn the set of entities per region? @stone osprey
@coarse turtle That would work ^^ But we would need to check that rule for every spawn point the spawner choosed... nevertheless, how do we keep those rules flexible ? I think its no good idea to hard code them all in one method/system...
For example to allow modders / other developers to easily change rules or add new ones...
oh hmm π€ that's a bit tough
you could try to generate unique ids/hashes per rule sets depending on whatever info is piped
I have something similar in my card system, define the card's category and the concatenated categories generate a hash that i would generate/bake in editor time and read in runtime
well that makes sense, thanks π And how do we add new rules ? Or new code that processes those rules ? the only way i could imagine is using method references... like "Oh the set uses that rule ? Lets check our dictionary what method processes that rule..."
yeah i have something like that - just stored it into a hashmap to check if i can execute the card
Thanks ^^ so theres no way to solve this flexible rule system without using callbacks ? Looks like pure ecs is really, really tight in case of useages :p
for my case, I didn't really care if it was pure unity ecs - it was just going to make it harder to build + I needed to iterate and test out viability of certain cards (i think once Unity supports c# 9's unsafe function pointers it might just be easier to do it in ecs)
C#9 might come when C#10 is around the corner XD
Alright thanks ! Probably i just need to realize that pure ecs is very limited
fwiw, most of the other parts of the gameplay works well with an ecs architecture (physics/physics events, platforming, game states/rounds)
Thats true ^^ its only the dynamic stuff that does not work that well with ecs architectures
I would create an AllowedSpawnType component, that has an Entity field pointing to a entity prefab, and use per-monster-type systems to add/remove them from spawn location entities
Then when the spawn system goes to spawn something, it looks at the AllowedSpawnType(s) on the spawnpoint, and sees if there's a match to what it's been instructed to spawn
@toxic mural Thanks, thats also a good idea ^^
spawning mechanics are pretty hard to design... i think im gonna try the following now : Spawner generates X locations -> Spawner validates entities that could get spawned on there -> Spawner applies weight to them and creates the entities itself
I think im gonna split this into three parts... Location -> Validation -> Weighting / A component for each those tasks... just have no idea how to combine them, because there 9 different combinations of those... spawners having only location and weighting, spawners only having location and validation, spawners only having location :p e.g. any idea how we can process those without writing 9 different systems ?
Or is there even a way ?
I haven't really been following but have you got down to the fundamental data you require. It seems for the system that instantiates you need a type (entity prefab) and a location (float3?). For the spawn system you need a list of possible prefabs (DynamicBuffer of entities?) and a probability for each (float?). Does that miss anything?
@amber flicker Thats it ^^ do you mean its too much to divide those into three different components for the spawning process?
I think... this is super straight-forward.. I'm not really understanding the issue so I can only say that I'd approach this backwards - what is the minimum data required, then how can that data come into existence in ecs land.
Alright, i just dont wanna make the mistake to hardcode any stuff that should be flexible ^^ thats why i thought it may be good to split this behaviour into multiple components
In psuedo code, to me one version looks like this:
SpawnPoint : ICD { float SpawnInterval; float3 SpawnLocation; DynamicBuffer<Entity> Prefabs; DynamicBuffer<float> Probabilities } then (optionally e.g.) NormalizeSpawnProbabilities { copy Probabilities, normalize, write back, remove NeedsNormalizingTag}
then SpawnSystem { ForEach(spawnPoint) => if(timeSinceLastSpawn - Time > SpawnInterval) choose entity, EntityManager.Instantiate() }
If you want to add in more functionality later (like spawning multiple in the same frame or whatever), you can just add that as you need.
I feel like I'm missing the issue π§
reading back I see the question is more with regard to rules like 'at night'. Your spawn system can check for the presence of tags e.g. if(HasComponent<SpawnOnlyAtNight>(spawnPoint)) .. spawn if night time
~~hmm I have a question unrelated to the current topic, How do you initalize an UnsafeList? Seems like most constructors always explicitly define that Ptr is null π€
I could always just assign a pointer, but seems odd that UnsafeList initializes likes so~~
ah nvm, I can't read the debugger π
@amber flicker Thanks π I just searched for a way to prevent myself from hardcoding the spawn mechanic... Found a solution, theres another component ( Spawn ) that stores a entity id and spawn point queue... and that component processes them, polls one entity, one location and instantiates that entity at that location... this way we can let other systems or components run before that spawn system to modify either the locations or the entitys to spawn ( algorithm to choose location, condition and weightning )

New physics update
But its still making me sad π¦
int numChunks;
using (NativeArray<ArchetypeChunk> chunks = StaticEntityGroup.CreateArchetypeChunkArray(Allocator.TempJob))
{
numChunks = chunks.Length;
}```
Why is this a thing xD
i really hate how for some packages it no longer says that a new package is available
is there a reason that Physics 0.5.0 preview 1 isn't available for installation? everything is grayed out when i click on that version
im on 2020.2b2 so the Unity version shouldn't be a problem
i suppose i could just manually update
not sure why, maybe close the package manager window and open it again or restart the editor, i just updated without too many hitches(flushed all dots data to fix my first runtime errors)
ah i probably should've just restarted the editor. maybe they pushed the release while it was still open or something. oh well. it's loading after a manual update
I have to say, Joachim is a fucking beast... he's answering dots forum questions on the day of the IPO of the company he founded.... π π π π
This guy is eyeing the tres-commas-club and still got time for us β€οΈ
when you put it like that π
yeah that is pretty cool
I hope that he makes a boatload of money and doesn't care π
(basically I want him to keep doing what he's doing!)
very cool!
i've gotten to the point where im successfully creating multiple worlds, but i can't figure out how to remove default systems (physics, rendering) in the main world to move them to the special worlds. if i try to destroy physics systems in the main world, i get a bunch of errors every frame, and soon after the editor freezes and i have to force quit. any ideas, or do i just have to disable them in the main world and add them to the new world?
@craggy orbit what errors are you getting and how are you destroying them?
ill have to check the logs for the specific errors, since i can't scroll up in the console to check after the editor freezes, but im using World.DefaultGameObjectInjectionWorld.DestroySystem(BuildPhysicsWorld) (same as with Step, Export, and EndFrame) to destroy the systems
Are you also destroying the debug draw systems?
no, are those added by default?
i'm guessing you're missing a couple physics systems that are dependent on those so they throw errors
if i pause before playing, the editor doesn't crash, at least.
"InvalidOperationException: object is not initialized or has already been destroyed"
in the system update loop. so yeah i must've missed a system π
ill go have another look at all of the systems
I'm using DOTS and VSCode, and while VSCode shows compiler errors, it never shows more DOTS-specific errors (stuff like doing unsafe accesses within a ForEach). Is it normal? Is it better with Visual Studio?
i've never seen DOTS specific errors outside of Unity either
cool, just wanted to make sure I wasn't missing out on some plugin goodness
oh wow i missed a ton of systems when removing. i was only looking under the Unity.Physics.Systems namespace
dunno if you found em already but here's a list for 0.4.1
DisplayBroadphaseAabbsSystem
DisplayColliderAabbsSystem
DisplayBodyColliders
DisplayCollisionEventsSystem
DisplayContactsSystem
DisplayJointsSystem
DisplayMassPropertiesSystem
DisplayTriggerEventsSystem
BuildPhysicsWorld
EndFramePhysicsSystem
ExportPhysicsWorld
StepPhysicsWorld
got em from the docs, but thanks!
still getting the same vague error as before :/ here's the full error
https://pastebin.com/RcAuXsb2
unfortunately if i try to edit the script from where the error is thrown (error line 7) the script reverts back after reentering Unity, so i can't add additional detail like what system im at in the update loop
oh never mind this time it stayed
FixedStepSimulationSystemGroup is the "not initialized or been destroyed"
if i don't destroy that system, instead it debugs all of the physics systems that i destroy
might need to take them out of that group's update list too
not sure if destroy does that automatically
guess not
how odd. ill look into that, thanks!
I spent like... 2 full days making an Archetype Authoring-like component... for my ease of use...
and then it hit me...
prefabs exist, prefab variants exist
:notlikethis:
It's package update day wish me luck π¨
which packages were updated?
i think he meant he is going to update packages to current ones
only 'big' one is physics i think
hi everyone, I'm a little confused, I want to run a ForEach on some selected entities, but I'd also like to know how many entities were actually ran, so that I can keep track of some count elsewhere. I thought I could do an EntityQuery and use its CalculateEntityCount, but now I'm unsure how to turn that query into something I can ForEach over
I see online people doing Entities.With(query), but for me this gives 'ForEachLambdaJobDescription' does not contain a definition for 'With' and no accessible extension method 'With' accepting a first argument of type 'ForEachLambdaJobDescription' could be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]
Passing a query to ForEach is planned but not in yet I think. You can use https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/ecs_entities_foreach.html#accessing-the-entityquery-object
thanks, this compiles at least, now to solve my thousand runtime errors to see if it actually worked! π
Is it usefull to use the ecs architecture for "producer/consumer" patterns ? Like... "SpawnPointsSystem" produces locations by an algorithm and inserts them into "SpawnPoint" component, "SpawnSystem" is a consumer and takes the locations to spawn entities in ? The only problem with such a pattern this needs to run sequential after another.
The advantage here is that its pretty easy to customize and to extend... we simply need to make sure that the consumer gets what he deserves :ΓΌ
incredibly common @stone osprey
i use it constnatly
most often, its used with a singleton entity that has a queue/array of some kind
@vagrant surge Thanks ! Thats great to hear π The only huge withdraw here is that theres tons of boilerplate code...
Those "...To..." systems are only used for copy data into the next step
thats overkill
this is how i spawn objects in my non-unity bullet hell game
so essentially, its literally just a function that creates the entity, sets default parameters, and "clones" it from a different world where the prototype entity is
this is done "directly"
alternatively
i do
have a spawn system
that iterates BulletSpawner and creates the stuff
Is this entt ? Used that framework some time ago for a opengl university project ^^
but both of them just call the build_bullet function which creates the bullet "instantly"
yes
its miles ahead of dots in usability, yuo can spawn entities inside iterations and things like that
and you dont have to setup a system
you can just from anywhere perform a query (registry.view<stuff>)
because it has no concept of a system, my loop just looks like this
each "system" is just a pure function i call from the main game loop
thats right ^^ so you mean my 9 systems for the producer/consumer ecs style is too much ?
way too much
specially on unity ecs where systems have significant overhead
you do not need that
for spawning, you have generally 2 types of spawning
Actually its not unity either π this is part of my serverside code ( artemis odb )...
one is where game AI/logic spawns it
and other is when you actually have a spawner entity that spawns in a loop
i recomend you keep those as a different thing, and basically allow "instant" spawn from anywhere
or close to it
in here i just have a BossAI object (virtual update) that ticks AI logic and spawns some specific bullet patterns on its own
tho it also creates spawners for the "allways spamming" logic
I pretty much tried to implement a "spawner" for mobs... to keep it flexible i thought its a good idea to split it up into 4 pieces : Location generation, Conditions, Weight and the actuall spawn process
highly overkill
Thats why i ended up with that many systems
a important typo in ECS, is that you shouldnt over-componentize stuff
until it makes sense to do so
creating 5 components and 8 systems for "one logic" is not that good of an idea
in your case, you will generally allways pack those components together, and the systems run on the same entities
so just make it monolythic
once you need the different combinations for different types of spawners
only then you divide stuff
Hmmm... that makes sense... tbh, spawning is bretty hard for me to implement. I wanna have it as flexible as possible, different algorithm, with weights, without weights... with conditions or without them... but probably this is really too much
Otherwhise i dont wanna shoot me into my foot later on... i had projects where i hardcoded stuff that were pretty hard to change later on. Mostly OOP projects, but well
dont go overkill until you need it
one of the interesting parts of ecs is that replacing code entirely is easy
so embrace that
Thats right... So splitting up code only makes sense when we really need the flexibility
you can start with 1 spawn system on a relatively fat component, and split it later
after all you can even automate the splitting by having a system that copies the fat component and splits it, while you develop the split version
Thats also a good idea but im not sure if that works in c# or java that well ^^
Alright thanks... one last question... is it still considered as a producer/consumer style when we design our components like the following : Input, Attributes, Output -> LocationGenerator{ input: someLocation, attribute1: width, attribute2 : height }, LocationSystem : Taking the input and attributes to generate locations and put them as a output into LocationGenerator ?
thats fine
Is there a way of making a subscene automatically update whenever there's a git update to a source file?
i guess you could write an editor tool that connects to github and compares the files, downloads new data if required, or you mean at runtime?
just use that version attribute on your authoring components
[ConverterVersion("poop", 1)] i think it was
and then increment the 1 when you make a change
@hollow sorrel Thanks, that's the one I know about. Would just be very convenient if I could bump ConverterVersion whenever there's a change to specific files.
I'm very willing to write an editor tool for this, but unfortunately tags are evaluated on compilation, I think
oh you mean like when non-authoring components change?
Yeah. My intended workflow is like this
I have about 500 fbx files that I currently load via Resources.LoadAsync.
Process them a bit, and then make into parts that slot together
Ideally, I'd be able to have a ConverterVersion that bumped whenever I made a change to those files
ah yea
So I could put all of those in a subscene
i don't think there's a builtin way to do that right now and tbh even the converterversion way is pretty bad at the problem it intends to solve imo
Thanks
does it matter if I use EntityCommandBuffer with ref or not in methods?
I never saw it used with ref but it does seem to work without it
i think you only have to use it if you're making structural changes
that is adding/removing components? you should be able to update values on referenced components without an ecb
am i doing this wrong? i should metion that i'm using DOTSNET. i have a prefab on the server that gets instantiated about 165 times and each entity gets synced to each client, but i'm not certain if having the model on the prefab is bad in ECS? is it pushing around lots of extra data? is there a better way to do this?
hello all
i have a quick question
i'm playing around with the netcube example for netcode
i'm maily trying to turn it into something with first person-esque controls
But i can't get relative movement to work :( Can any of you tell me what i might be doing wrong?
thank you all in advance :)
shameful bump
does anybody have any experience with this?
Well you are applying the rotation to the Rotation component but then using your LocalToWorld to adjust your input vector which wont be updated by Rotation until the TransformSystemGroup updates. You are also multiplying your input vector by LocalToWorld.Forward which is another vector, I'm not 100% sure but I think this does component wise multiplication (ie. (a.x * b.x, a.y * b.y, a.z * b.z)). I think what you want is something more like
trans.Value += math.mul(rot.Value, inputVec) * deltaTime * 10f;
ah, thanks :)
will try that now :)
thank you so much @fair flame it works perfectly :D
you wouldn't happen to know how i might determine if a client owns a ghost instance?
@fair flame (sorry for pinging >_<)
I've been using GhostOwnerComponent
var localPlayerId = GetSingleton<NetworkIdComponent>().Value;
Entities.ForEach(Entity e, in GhostOwnerComponent owner)=>
{
if(owner.NetworkId == localPlayerId)
{
// e is owned by this client
}
}
GhostOwnerComponent should already be setup if you are using client prediction
thank you so much!!! you're a lifesaver :D
you're welcome
just checking, there's no way to add a camera to an entity is there?
you have to do the janky thing where you move the main camera to the entity constantly right?
convert camera into entity? then follow the entity around?
i believe you can do that with Hybrid.
But honestly, I'd just use cinemachine for it.
You can use EntityManager.AddComponentObject(entity, camera); or store a Camera reference in an IComponentData class.
If you add HYBRID_ENTITIES_CAMERA_CONVERSION to your scripting define symbols then you'll get a GameObjectConversionSystem that converts cameras with AddHybridComponent(). You won't be able to use burst with cameras though because they are a reference type.
I'm not sure but I think the AddHybridComponent method might manage its own transform but otherwise you'll have to update the cameras transform yourself but that's pretty easy with the CopyTransformToGameObject component and then adding the transform via AddComponentObject
When new ECS package update will be available ?
thats.. thats the question of the century
that's what we're asking XD
how would I go about changing a material's color?
just googled. so I attach an ICD onto the thing I want its color changed
lemme try
can't [GenerateDataAuthoring] on an ISharedComponentData?
you can
but then when I try to add the script to a game object, it tells me it cannot find the BlahAuthoring class
[GenerateAuthoringComponent]
oh yes that's what I meant
it does not seem to work with my ISharedComponentData
anything obviously wrong with this? http://paste.awesom.eu/cn3z
I try putting large objects with Box Colliders right in front of the camera, but the ray never hits :\
the object's distance is about 50, less than 200 most certainly
hmm used Debug.DrawLine and the ray is definitely where I think it is and touching that object
I haven't touched unity.physics at all yet but I wonder if this is because your code needs to execute at a very particular point with dots physics - I think after export physics world or something? Is there a raycast example you're following?
I've been putting things together from:
https://docs.unity3d.com/Packages/com.unity.physics@0.4/manual/collision_queries.html
and
https://gist.github.com/jeffvella/fa5b7e4eaf3fa4b42e0b77ad26ed3535
ah the latter indeed has some annotations, let me try that
the only other guess I have is some filtering mis-match
still does not register, but I'm sure this was at least something good to have
yeah let me try adding back that filter param
Ignoring invalid [UpdateAfter] attribute on UI.DragAndDropSystem targeting Unity.Physics.Systems.BuildPhysicsWorld. This attribute can only order systems that are members of the same ComponentSystemGroup instance. ah, I may need to figure this out
ah yeah I need to do that final job handle awaiting it seems, will work something...
how do I figure out what ComponentSystemGroup the BuildPhysicsWorld system is part of?
find it in the entity debugger and see what group its in, or look at the source code, attribute at the top of the system.
well I'm a dumdum, turns out I had to use a Physics Shape and not a Box Collider! π
oh damn, sorry I wasn't around to help with that. Yeah colliders screw everything up. If the colliders are even attached to your entity at all, they screw up all collision filters, even if you have a physics shape attached also
hey all
does anyone know the meaning of this error I'm getting, trying to use a NativeArray of a struct inside a job
InvalidOperationException: HumanPoseWrapper used in NativeArray<HumanPoseWrapper> must be unmanaged (contain no managed types) and cannot itself be a native container type.
here's the code
the allocation is: _poses = new NativeArray<HumanPoseWrapper>(poseFrames.frames.ToArray(), Allocator.Persistent);
frames is a list of HumanPoseWrapper inside a scriptableobject type
it means something is not unmanaged inside HumanPostWrapper
perhaps the float array
yeah
how would i work around that?
you could make it fixed, or use an UnsafeList, raw allocation, etc
huh nativearrays can go inside nativearrays?
they're not serializable tho, right?
think i could just fix the size, i think it should have a fixed amount anyways
the data comes from mecanim, so i guess ill have to trust it wont change
or i guess i can make another intermediate data structure that can go straight in the job
probably depends on how efficient you need it to be, how much you care about wasted space etc. like if there's the possibility of there being 20 muscles, but 99% of the time there's only 3 muscles, and you allow space inline for the max amount your iterations are going to be slower having to skip accross all the wasted space.
i can probably trust it'll stay at 95 muscles, hasn't changed in any of the rigs i've tried yet
hmm to fix size buffer i need to make it unsafe
do it and never look back π
do i need to enable unsafe in unity project settings?
yeah
this data structure is mostly for serialization tho, so i think id better think about another way to represent it in a job
i was just hoping i could cut out the middleman π
dump the data straight in
unity API has HumanPose which isnt marked serializable thats why i do this
if you're doing any processing on it in burst you should also switch to float3/quaternion instead as they're optimized
yup, right now im prototyping, will switch to unity.mathematics after i make sure this is feasible
im open to any suggestions, how would i perhaps structure that data to go neatly in a job?
not very experienced with all the jobs stuff yet
hmmm, what kind of serialization are you talking about, and whats the job do