#archived-dots
1 messages ยท Page 167 of 1
i just want their animation to get going, every damn idea i have involves some form of animation and being chained to monobehaviours for characters means my game is always hampered despite 90% of it being pure dots
I'm actually interested in DOTS audio but no one seems to care about it so I dunno if it's gonna happen soon. No one ever talks about it hahah
@dusky wind What I've decided on animation is to use the existing GO structure, and write comms tooling to get the GO world and the ECS world in sync
About 90% of the rest of my game is done already, just need the rendering parts to fall into place.
problem is that I need deterministic animation
i dont think its correct to call that DOTS audio because its PRETTY LOW level stuff, like you can adjust frequency of the sound, who does that ๐
and I'm not all that sure the existing animation system is running with FloatMode.Strict
And also i want project tiny to have better documentation. Like. What the fuck is that?
we need high level audio for DOTS imo
ah new people for the dots animation support group ๐
Is it even functional on 2020.x?
@opaque ledge yeah, it was weird. They were showing DSP in the example and you're like ... woah. There is not a lot of people that have the math background to do real time audio DSP.
Would be very niche haha
Last time I tried, I crashed going into play mode.
I'm interested in their "textures emitting sound" and new ideas on how to place audio throughout games, because I could do that professionally as a specialist
i think someone asked in forums about the progress on DSP and they answer like "eeeh not for a long while" ๐
Lel is it time to buy your services @tardy spoke once dsp comes out?
it is if you have a deep understanding of it. they are using it internally for their new project, but the samples havent been updated in like 7 months so for us who dont have a direct line of communication to their animation devs, gotta be a a smarty pants to understand it
yeah it sounds cool @tardy spoke but i am not really interested in that at all, i just want to play an audio time to time ๐
haha, nah wrong idea, I don't do DSP coding, I just meant i'm an audio engineer and I could be like a sound design specialist if I came across a studio using DOTS
yeah dspgraph anther one with no updates closing in a year or so
but there's nothing really to learn/use yet inside DOTS for audio so you're just doing it the normal way still
@safe lintel all I gleamed was that the animations are baked into a BlobAsset and write to a unmanaged buffer of float3x4s
Audio DSP coding is amazing and I commend people that can do it. Looked into it before. That shit is hard - the mathematics side of it, I mean.
which requires a specific shader to render
Would be nice to be able to switch for mobile
I think the idea was that it's the simplest way of doing it at scale for a buttload of skinned meshes
which... isn't wrong per se, but it definitely doesn't port well for certain platforms
Yah. I think I'm going to bow out of skinned meshes by style in my project
my only focus is desktop so im not familiar to how that affects other platforms
Been digging around the API for a way to read out of that buffer
All I need is a local to world matrix for specific bones
@opaque ledge yeah what I want it for is like in the megacity demo, how they do interesting things like change the audio tracks when they fly higher to reduce certain instruments and create wind noise. I'd love to do some interesting things like that in my game.
Actually some interesting advice is the importance of the quality of audio in media. You can have bad visuals and pro sound and people will still register it as professional (IE Blair witch project type movies, etc). If you have bad sound no matter how good the visual, people always associate it with indie / non-pro.
๐
Agreed, sound is often so under-rated by game devs
Good advice. ThNks for that alex
Yeah, even things like just balancing the sounds and having some sounds WAAAAY too loud compared to other sounds, even if the sounds are high quality themselves, there's a lot of dimensions to what determines the "quality" of sound.
I was thinking of making some tutorials on YouTube of audio for indie game developers.
I view audio and music this way: It frames the emotional tone. If you are not using it correctly in that way, you are missing the opportunity
Graphics excites the mind. Audio excites the soul
Thinking about it As a fighting game player, even if the gameplay sucks as long as the bg is bangable, i'd still enjoy it
Practical things such as "how to balance dialogue levels" and stuff and just basic concepts of things that can accidentally easily ruin experiences
and i'd like to demonstrate it with dots Audio or a powerful next-gen system but... what I need (higher level and useful in a practical sense) doesn't exist haha.
I guess I can figure out how Unity does it regularly for demonstrations, no big deal.
megacity claimed it uses tens of thousands of audio emitters
I'm honestly looking forward to cracking open that demo someday, when I get into proc level gen
That'll be cool. It'll likely all be wildly outdated though.
Update megacity?
That'd be cool.
Or, ANY of the good DOTs examples Unity made and just forgot about
I can't believe it isn't worth one Unity dev's time to update those examples taht they spent MONTHS creating
We'll just be adding comments, we dont want to break stuff we know nothing about lel
I bet it's under a permissible license
deciphering megacity's audiosystem would be a great project ๐
Yeah. And seeing how well it actually runs on a phone... lol
it's honestly baffling how devs need to RE an example
just to figure out how the guts work
Especially when the objective of the company is to get people to use the technology
speaking of which, is there a good way to consistently hash an entire world?
SerializeUtilty methods include entire chunks with uninitialized memory and are fucknormous
or rather, hash specific component types throughout the world
So.... That's a nasty bug
I had a GameObject with components and authoring comonents in a subscene. The editor crashed, because one of the MB components had an error, and all of those components got wiped out, including Mesh Renderer and ParticleSystem and all the authoring. Just an empty object
I shouldn't need to add the default world to the player loop if I'm adding systems to it right?
not sure when or where I got the code example but it ends by calling ScriptBehaviourUpdateOrder.UpdatePLayerLoop
which is deprecated
and I'm guessing the replacement of addworldtoplayerloop doesn't need to be called for the default world
Hi Is this the right place for Tiny questions?
@gusty comet don't see why not, but in the forums you might get more help (there isn't much tiny talk around here)
@violet cosmos there seems to be an issue while parsing JSON that Unity likes to know the structure of the object before parsing it - which in my case is fairly difficult as the quests will be of varying length and have repeating steps, etc.
I'm thinking a custom solution of just creating a Dictionary<TKey, List<TValue>> is likely going to be better, and just have an algo on the scriptable object take the text from the textAsset line by line and "construct" that object.
@tardy spoke I don't see why quests couldn't have a structure, and using the built-in types like List
yeah but if I have like 5 lines that are "go to" how do I predefine that? Say another quest has 1 or 10 of that
Quest
List<QuestStep> Steps
When you parse JSON it wants you to write the structure of the whole object out before hand
You can use complex types in json
Yup, how is that bad? Structure your quest objects
Hmm, I must be misunderstanding something
Start with the objects first, THEN json
So say the JSON is like this
{GoTo: X500, Y500,
GoTo: X200, Y300,
GoTo: X100, Y400,
}
How do I predefine a structure for that if it could be any length
Hmm, I'm not sure we're probably thinking different things here
[GoTo {X500, Y500}, GoTo {X200, Y300}] etc
Then, make sure they're all marked serializable. Then populate them with some data. THEN convert that to JSON, and you'll see what it ends up like
Structure your objects the way you'd want to use them
But it has to be a logistical order
{
Dialogue: "You need to go to there",
GoTo: X500, Y500,
GetItem: Something,
GoTo: X200, Y300,
GoTo: X100, Y400,
}
So how do you pull the order back out after you've parsed it if the structure is predetermined, and if it's another object to keep track of the order or something, isn't it going to be easier just to write the custom reader that creates the sequential dictionary object?
class Quest
public string Dialogue;
public List<Vector2> Waypoints;
public int GetItem;
Then just spit that out into JSON, trust me it figures it out
I'm deserializing from JSON
When you injest the json, you'll be using something like Quest q = JsonConvert.DeserializeObject<Quest>(jsonString);
Oh, you're saying if you just define the types it will actually keep the order in the object?
It magically figures out all of the stuff, because JSON is named and structured
oh shit
Yes, List and Array is implicit ordering
If you've added them in the right order, they're be deserialized in the correct order
Right, just the expected types. For some reason in some of the examples it looked like people were actually like redoing the "format" they expected it to come in as, but that makes total sense.
That's what I'm saying: Start with your object types and hierarchy first, then just let JSON do it's thing
Yeah sorry, just a misunderstanding on my part, I get what you're saying ๐
I thought the converter was "dumber" than it is
it is, it converts exactly what you tell it to...
Yeah for some reason looking at the examples I thought it threw the hierarchy out and I was like "... well that's dumb"
though I've noticed it does a shit job on floats
output a float to json (4.0, 3.1, 4.5 etc.), deserialize the json you just serialized and get back 3.9992394, 3.100000209234, 4.4996988856 etc. very irritating
should work if you can round to a decimal place but wtf...
You can if you want, just change the precision
Also, the more likely culprit is Unity and it drifting floats if your data is coming in and out
hate floating point inprecision
Unity often drifts, even in the editor when I typed something in
since the json serialize/deserialize is built into Unit, the culprit is "Unity"
If it's to/from your own storage, you can use whatever one you want
I noticed that a lot of the new DOTs related packages now have dependencies to Newtonsoft JSON. But, IIRC for runtime, the dumb/simple Unity version is faster
Why does everything I need to do, in the way I need to it, involve some kind of bizarre workaround?
Apparently scriptableObjects Awake function doesn't work if the SO wasn't created with a script that initializes it?? So if you use it as a menu item that method doesn't work, hahaha.
The workaround is a monoBehaviour must reference it for it to fire if it wasn't instantiated via code. Lol. ๐คฆโโ๏ธ
I guess this is just part of my game forever then, hahaha.
try the OnEnable() message callback
I just realized something, and correct me if I'm wrong...
I can't have multiple IComponentData of the same type on a single Entity
yes, you're right
That's.... annoying
See, this is some of my issues when people (on the forums) are like "Oh, you don't have to worry about stuff" and then I don't and here we are
You have a few options: DynamicBuffer<T> or IComponentData with an UnsafeList<T> or T* ptr.
Yah, that's what I need to do, and make a whole other separate boilerplate system just to handle "stacking"
It's OK, just annoying, and I'm definitely going to keep up with my habit of marking components with tag interfaces. In this case, IStackedComponentData
@coarse turtle it doesn't matter, no methods will fire with no reference except onDelete unless created by code.
More detail here https://forum.unity.com/threads/scriptableobject-behaviour-discussion-how-scriptable-objects-work.541212/
Anyone has tried the store version of entitas here?
Well - I'm not sure what your set up is, but I had assumed you'd have a Scriptable object asset and you just need OnEnable to initialize some storage ๐ค
@coarse turtle when creating them as menu items those methods won't work unless referenced by a monobehaviour. It's insane.
If instantiating via code, no problem.
well OnEnable() would be called on asset creation
I need them to run on play
the dumb referencing thing works
so... that's fine for now I guess haha
ah yea - if it's a runtime thing, you'll want to refer them in a MonoBehaviour. Scriptable Objects are really just POCO that are serialized to an asset
@violet cosmos so, one of the issues with using JSON for the quest instructions is you're not allowed to use duplicate key names, so you can't actually even have 2 goTo commands if you're just trying to have it parse sequentially and run through it like a set of instructions.
Additionally the JSON deserializer I'm using doesn't seem able to handle that nested array structure for the goTo's anyway, though you could easily get around that by formatting it different. Could become more problematic for other situations, though.
@tardy spoke SOs are good for serialized data independent of scenes, prefabs and hierarchy that you read at runtime - they can do more but that's where they excel - if you're aiming for a runtime set or similar, they're also cool but you need to dev good tooling
Quest { string Name; List<Vector3> GoTo;}
Then QuestCollection { List<Quest> Quests; }
QuestCollection q = Deserialize<QuestCollection>() and don't worry about Quest, it's implicit. You just pass in the top level class
I keep saying to go from the objects first, please heed my advice
Oh, so breaking it down so each "step" that wouldn't contain multiple of the same directive is it's own "quest"?
I don't know, I'm just making up names
If it's class Quest / class QuestStep it's irrelevant to my point: Make your class hierarchy first
like, actual classes in C#. Then instantiate them using "new", seed data by hand in C#, and play with that data. Ignore JSON exists until you have that done, and you're using it and the class layout is good
... then, you can use Serialize(someQuest) and see the JSON it spits out. And you might learn a bit about how JSON reflects the instantiated classes. You don't work with JSON directly if you can help it, you always work with the objects in memory
Yeah, I'm just working with a non-programmer has to be able to create the quests - the more complex solution is better obviously with good tooling, though
The non programmer needs to make up those numbers?
Like, how do they get the world coordinates?
Haha, it's not a PERFECT solution
Move a vector3 in the world, grab the coords
it's not clean or good
lol
Then, you need to think about it like a programmer to help them. How many minutes do you think it would take to wire up a stupid UI that lets the non programmer type in some text and drop some dots on a map?
You can do that in JavaScript even, it doesn't matter if the structure, data types, and property names are the same as the C# classes, and spit out JSON all day
We'll find out how many days it takes me to program that, hahah
Keep it easy, but especially working with non-developers, quick to bang out tools are your friend
Look, you can hack that so easily.
Make a big dynamic table with 1000 rows, 1000 cells that's drawn on top of the world map. When someone clicks a point, it gets that row/column and bam
Think like this: Make things hacked and work
Yeah that's cool. Or just a box gizmo they can draw on the world map that returns the vector2's of the corners.
Keep it simple to start. You have no idea what you need right now until you have playable quests
Another way to do it is to have them just run around inside your game in a special mode and press P to Poop Out Way Point
You don't store that in JSON, you store that in the object, and when they're done... Then, JSON
It doesn't matter, what matters is you can make it easily and they can work with it in some fashion that is less prone to errors. it doesn't have to be pretty, it just needs to work. If you keep using it, you will iterate on it and improve it, or you may realize it needs to be scrapped altogether because you changed the plan
There are two sides to development:
1> You have a clear vision and documentation and it's going to work. Then you can take your time and make it correct and appease your ego of quality code only a few people on the planet will ever see.
2> You know you need something that does something, and you need it now. You hack it together as fast and ugly as you can. It works, and everyone is happy
The trick is knowing which one you're working on at any given moment, even within the same project, and often even within the same feature/system/component
Hmm, I could approach it the other way and build the tooling that spits out the JSON
hahaha
๐คฆโโ๏ธ
I'm not quite sure about your fascination with working with JSON directly man...
I mean like build the system properly that serializes the results into JSON haha
instead of writing the JSON
Not just literally building tools that work directly on JSON haha
hahaha, good. Thank you. We were about to not be friends anymore ๐
This is going to take me weeks to build. ๐ค Love seeing that finish line move further and further away, hahahaha.
But I guess if I'm going to show it to anyone on the wiki it's better it's done well, haha.
I wouldn't do that in ECS, fwiw
Just make a Singleton that manages and deals with quests
Ye doesn't have to be directly through ecs, you can still store the quests in Blobs
If you didn't understand OOP well you might consider it, haha. ๐คทโโ๏ธ
Yeah, could store the quests as Blobs
If you are talking about quests, i only glimpsed over
Why? There's no reason. The only thing I can see valid in his current design is to store the waypoints in an entity that draws the waypoints
So you can reference them from your player/whatever without needing a weak reference
Singleton, again. You can just reference it from anywhere
I actually am on the line if the simple bespoke textAsset parser is actually the "best" solution to this, haha. Yeah more time to make the quests in texts, but you avoid building all the tooling, etc, not hard to teach and potentially keeps the other systems simpler. Depending on quality of parser you build, might be the easiest to troubleshoot issues, etc. You know the issue has to be within only the one system.
That may be idiotic, but I'm always wary of over-engineering on projects
imo (fwiw): If you have a bunch of immutable data (Quest dialogue, goals etc) then: Quest SO to represent data -> Gets converted to blobasset data at some point and serialized into Subscene. No JSON, no text parsing.
Unless you need to be compatible with some other third party / external to Unity tool
If you're investing in dots you want those sweet sweet serialized blobs for instant loading etc
I feel that loading a singular textAsset or deserializing a JSON object when you're within 3 meters of an NPC isn't necessarily the end of the world, even on Oculus Quest, haha.
Definitely not. Especially if you use the async routines
People do that with frick'n movie files. You can do that with 1kb of text
I dunno if I can justify optimizing the textAsset loader or deserializer vs the 10,000 enemy zombies which need AI and nav.
up to you of course but from pov it looks like the most straight-forward and best performing option ยฏ_(ใ)_/ยฏ
... the most straight forward option is my text parser. I know it's the most straight forward because I know what I don't know and that's what I made. ๐
yup.. nothing wrong with going with what you know
It's probably not the best or even a good solution, and I almost want to try it just to find out what the exact weaknesses of the approach are or how quickly it turns into a huge rabbit hole.
But a more proper solution of building tooling to generate the quests and store them w/out touching the quest code also has many learning opportunities, haha.
parsing text is fine.. but you end up wanting to refer to in-game stuff in my experience. That's where SOs come into their own. You can e.g. set the location to 'Player Home' which itself can be an SO etc.
In the spirit of ECS I should probably take a disastrous hybrid approach that just makes everything harder. ๐ค
Just sharing how I would approach it, not how you should
Yeah I need to get more familiar and watch more about SO's
I don't have a great understanding of all the crazy stuff they can do and how they fit in with ECS.
I always heard parsing text usually turns into a disaster situation because you basically end up writing your own mini programming language depending how complex the functionality gets, but that kinda sounds fun.
As an example, this is just a SciptableObject with a custom editor window. You can build on really simple to make things as pretty and feature-rich as you like.
The trick with my project is I'm in control of the specs, so the systems can be built quite a bit differently. If I'm like "oh if I had to do this I would have to rewrite the whole system" unless I REAAAALLY want that feautre, I just ... don't do it, haha. Which makes a parser less risky.
unless im out of touch, so's dont really fit in at all with ecs currently?
Yeah, not technically. I think they get some love acting as a glue though in hybrid approach stuff.
My only caution (which you are very welcome to ignore) is that you may find you get on a slippery slope with custom text parsing (that will become harder and harder to maintain over time). Inventing all sorts of ways to refer to in-game stuff.
SO's work fine with ECS? You do need to at some point convert the data to entities or blobs but that works well?
i meant more like theres no builtin conversion that takes place, nor are they treated like blobs or anything. it is what you make of it ๐
Yeah, the slippery slopeness is noted, that would be my concern as well. I'll see if referring to in-game stuff becomes an issue, I could see that happening, haha.
Are you just converting SO's to blobs for the performance benefit with ECS? No other reason?
@safe lintel Hmm I guess? It might just be that my workflow suits it well but I'm not sure what any kind of automated thing would look like.
In my case my animations are serialized as SOs. A component is attached to a GameObject with a reference to an animation then either constructs that tween on Awake or on Conversion if in a subscene. If on conversion, it creates entities and populates them with initialization data for the tween. This gets serialized in the subscene so you no longer even need to 'create' a tween at runtime - you just play or pause. I do use blobs for some other stuff.
Working on a separate asset with the very simple job of Tagging gameobjects. It adds a hash associated with a GameObject. If you have Entities installed and convert the GameObject it will (on conversion) create a BlobAssetReference for that entity with any tags/hashes associated with it. Then you can easily e.g. find a child of an entity with a certain tag.
Could you program a full project in Unity with just SO's instead of monobehaviours? I guess you could?
I won't argue everything should be in ECS, unless you're in Project Tiny ๐
I'm not saying it's a GOOD idea, but just for my understanding of them ... you could?
actually, no update loop
so I guess you'd be screwed there.
Oh yah, definitely could. They're just structured data holders, with the ability to do some logic
lol they blow my mind. They're just like... little not quite lambda functions floating around.
that's like saying "could you make a project with only data and no systems"
No, you wouldn't be screwed. You just need to have some way to load them. You can also load them from disk
The other weird thing about them is they seem to be persistent with their data?
But, not a whole project. Just the main parts of the data. I was assuming in your analogy ECS was the systems
That's actually good (in a way) they're persistent. Editor changes stay
Interesting
I think it would actually encourage better architecture that they are because you have to better understand you systems and initializations and whatnot
One way of thinking about it is that ScriptableObjects are to BlobAssets what GameObjects are to Entities.
Although they are far more capable, the author representation of immutable data is really where they're strength lies imo.
I've never tried but can you execute a function on a blobAsset of code?
if you were to blobAsset-ize some callable code?
Not sure - you could possibly add a method (similar to an ICD) but also similar to ICD, I suspect that's usually a bad pattern.
Yeah, can't think of why you would, but would be an interesting thing to try, haha.
Have you looked at the Collider code in DOTS Physics?
They do smth like that.
All their colliders store a header with the type of the collider and some other stuff i cant remember.
Based upon the type they cast the collider ptr and execute the method on the specific collider type
Could you program a full project in Unity with just SO's instead of monobehaviours? I guess you could?
@tardy spoke SO's doesn't have any hook into the Update loop, so no, you would still require at least one MonoBehaviour to hook your events on
well.. you could program an entire game events based rather than Update loop but anyway... let's stop ๐
@rancid geode totally. But theoretically with all SO's and then one monobehaviour you could, haha. ๐
Lol yeah, make a turn based game. Boom done.
Checkers
well, yeah, you could, but it doesn't mean you should hehe
Well, none of us SHOULD be using ECS either. It's hard and makes us grumpy. Yet here we are. ๐คทโโ๏ธ
you can make a unity project without any monobehaviours
just a regular C# class with [InitializeOnLoadMethod] where you inject into the update loop
Making SO checkers would be soooo much easier than my current project. ๐ค
Haha. That's kinda cool. I'd like to look into some course on the structure of Unity at some point to understand that kinda stuff.
I also didn't realize that Unity was a C++ engine with a C# layer until 10 seconds ago. I thought it was all C#
Uff, I hate all these instantiation examples.... So much spreading around of code. Hybrid ECS is a mess
anything in particular?
Building dynamically pieced together structures of prefabs and defining them in definition prefabs or SO's
I'd like to do it in all systems, but it has to be spread across MonoBehaviours as well, it seems
Hard to comment on really but I do find having to have a subscene for prefabs a little clumsy right now - I hope they do something to improve that.
Haven't even gotten into subscene, caching serialized converted entities and loading them at runtime. That's going to be a whole other chore, I feel, once I have hundreds of prefabs and only need a few dozen
Yea you'll need some of that to get rid of monobehaviours I guess. Wish there was a little more transparency about the ideas they're thinking of / moving forward with or if it's about as good as it's going to be.
No, they said they're definitely working on it, but I don't think they have even figured it out
Right now, I'm working on what would be a generalized workflow, and noting my pain points and making tools
Need sources: Why does project tiny require c++ build environmental
https://docs.unity3d.com/Packages/com.unity.entities@0.0/api/Unity.Entities.LinkedEntityGroup.html
LinkedEntityGroup.... If that has to be on the parent... Is the parent's Value null, and the children have it too but their Value is the parent?
... and it's buffer data, for some reason?
@wheat stump because it uses burst compiler which has that as requirement for windows builds
unless you mean how do you find out in which case you can check requirements here https://docs.google.com/document/d/1A8hen2hLFY5FLkC5gd3JP2Z-IpHfnAX-CpYLK3aOdwA/edit#heading=h.od6pqxv78b97
@wheat stump
For now in Tiny there is no direct access to Java native methods from C#. So it is required to use intermediate C++ level to do this.
https://docs.google.com/document/d/1A8hen2hLFY5FLkC5gd3JP2Z-IpHfnAX-CpYLK3aOdwA/edit#
Thanks @tardy spoke and @hollow sorrel
@amber flicker So, I have a prefab that has a particle system. On the GameObject for the particles, in IConvertGameObjectToEntity, I'm using AddHybridComponent to add both the particles and renderer.
But, when I instantiate, while it finds the prefab by prefab reference, it doesn't do anything with the particlesystem. No rendering, no components on the child entity
Entity trailEffectsInst = dstManager.Instantiate(trailEffectsPre);
dstManager.AddComponentData(trailEffectsInst, new Parent { Value = entity });
dstManager.AddComponentData(trailEffectsInst, new LocalToParent());```
That code snippet is in the parent, that's trying to auto-init particles
Ah this might be that you also need to add the particlesystemrenderer? I think I remember seeing someone else with that problem anyway
I did
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
conversionSystem.AddHybridComponent(GetComponent<ParticleSystem>());
conversionSystem.AddHybridComponent(GetComponent<ParticleSystemRenderer>());
}
}```
That's on the Prefab, at the root level with the particles
Ah sorry didnโt see you said that ๐
I'm going to try to automate that later... But first things first
If I move that top level game object to SubScene...
DuplicateEntityGuidException: Found 1 EntityGuid components that are shared by more than one Entity
guid = 22232:00:00000000, count = 1, obj = TrailEffects (UnityEngine.GameObject)
Sorry on my phone and headed to sleep soon. Are you following an example? I think there are a couple around for particlesystems. The duplicate error is likely due to creating an entity without using the โcreateAdditionalEntityโ method of the conversion system
Thanks, I'll follow up on that
This is so annoying
Am I missing how EntityManager.Instantiate(someOther) works? Doesn't it make a new copy, with all the same values and components?
yes
Welp, it's not. Not sure why
I made an entity from the prefab, it's 2:1. I can see it, with the particles and child and child mesh. But, it's converted as a part of DeclareReferencedPrefabs.
I instantiate it later, as a part of another GameOjbect's conversion, and set Parent and LocalToParent, and I see a new entity with the same name but pretty much nothing on it.
If I drag the entity into the SampleSubScene, I see it converts more of the particle system... But, still when I instantiate from it, the clone is empty
could it be that you're cloning before the prefab entity adds its components? or maybe that the prefab entity has no components at the time of cloning for some other reason
The prefab has this script, along with ConvertToEntity and a particle system at the top level. It has a child of just a sphere to draw
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
conversionSystem.AddHybridComponent(GetComponent<ParticleSystem>());
conversionSystem.AddHybridComponent(GetComponent<ParticleSystemRenderer>());
dstManager.AddComponentData(entity, new PrefabToEntity { PrefabReference = entity });
}
}```
It's instantiated later, when another GameObject's IConvertGameObjectToEntity is called....
``` void IConvertGameObjectToEntity.Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
//dstManager.AddComponent<LinkedEntityGroup>(entity);
if (TrailEffectPrefab != null)
{
Entity trailEffectsPre = conversionSystem.GetPrimaryEntity(TrailEffectPrefab);
Entity trailEffectsInst = dstManager.Instantiate(trailEffectsPre);
dstManager.AddComponentData(trailEffectsInst, new Parent { Value = entity });
dstManager.AddComponentData(trailEffectsInst, new LocalToParent());
dstManager.AddComponentData(entity, new AbilityGeneral { TrailEffectPrefab = trailEffectsInst } );
}
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.Add(TrailEffectPrefab);
}
What annoys me the most is that the prefab sitting there in the world, whether it's converted with drag-n-drop to scene, or as a part of DeclareReferencedPrefabs. But, it's just instantiating some hallow shell with the same name
Real quick question
Dots is just a different programming paradigm right?
(this has no relation to any current questions, I'm just asking because I don't know much about it atm)
@wild verge DOTS is a collection of tech. Jobs is kind of what you're used to, but organized multithreadeding. ECS is what you're thinking of, that's radically different
its basically unity's new engine
i vaguely remember something about DeclareReferencedPrefabs only working with actual prefabs, not prefab instances
What annoys me the most is that the prefab sitting there in the world sounds like you're using it differently
dunno if that's causing your actual issue but might be a lead
@wild verge within dots, the entity component system(entities package) follows the data orientated design(dod) philosophy, which is different from the object orientated approach most of unity currently uses, and unity are using dod as like their design philosophy going forward
Is there a way to roll back packages in Unity?
version control ๐
but it's only ecs that's using the design philosophy right now right?
so jobs, burst and entities make up the dots core, and they are building everything else upon these. not everything can be forced into that pattern but most everything will certainly have it in mind
@hollow sorrel Yah, that's kind of the point. I'm trying to pre-cache prefabs before using them,
entity prefabs?
I'm making GameObjects as prefabs to author them, and trying to manage that workflow so I can move more stuff into ECS
But, my big issue right now is EntityManager.Instantiate is being a jerk
i think the best idea is to put your prefab references or instances in a subscene, then it can be processed at editor time and loaded already in its transformed final form.
@mint iron For me, it's better to manage loading. I'm going to have tons of prefabs and I'm going to pre-load just what are needed into subscene
But, that's not my problem. The prefab is migrating into World just fine. It's that when I call Instantiate that clone is doing... nothing to copy the Entity's components or depth
I'm super annoyed that I have to do something to try and roll back to 0.13
Because I see no reason why Instantiate should just be flat out broken
i tried a runtime loading system like that and i probably dont possess the needed grey matter to figure it out because it turned into a complicated buggy nightmare ๐ฆ My biggest issue there came from the fact that they changed the loading system on me, and it no longer guaranteed that child prefabs would be processed before their parent when nested, so id load them in and the assets they needed hadn't been processed yet.
Hybrid is a nightmare right now
But, I can't get around it, I need hybrid in some fashion or another
Unless someone knows a really nice, fully featured, robust ECS authoring tool that has it's own concept of Prefabs, works with non-ECS things like particles and skeletons, and lets me interop with GameObjects easily....
what i meant was are you referencing your actual prefab, or are you referencing the instantiated prefab in your scene
conversionSystem.GetPrimaryEntity(manager.TrailEffectPrefab);
Which returns the correct index
I can set a breakpoint right before instantiate.... OK, it's 3:1. Cool, found it correctly using conversionSystem.GetPrimaryEntity(manager.TrailEffectPrefab); I go double check that it's the full featured conversion of the prefab. Yup, that's 3:1
Instantiate.... empty wasteland of an entity, no children, no components
check if that entity it found actually has the component(s) you want right before it instantiates
also you didn't really answer wether you're referencing your prefab, as in the gameobject in your assets folder, or a prefab instance, as in a reference to something in your scene
So, testing... It does appear like Unity is somehow not doing this in the correct order
Here's the workflow:
- On the PrefabManager I drag some Prefabs from the project. It's MB script execution order is -100
- PrefabManager has IDeclareReferencedPrefabs and adds all prefabs to the referencedPrefabs list
- The GameObject, which to test isn't in SubScene, has IConvertGameObjectToEntity and and whatever it needs. It also has a reference to the Prefab by GameObject
- The GameObject then attempts to instantiate an instance of the prefab, by looking it up and then adding it as a child
I think, I need to somehow migrate this into a system that runs after the whole thing has had a chance to cycle once over prefabs. The conversion pipeline is not handling dependencies smartly here
The Catch22 about that is I can't easily pass in GameObject references to the original prefab, and the others don't have references to the Entity version of the prefab, so I can't set those references
SO and BlobAsset to the rescue?
i don't think it has to do with cycling/ordering
declarereferences always runs before conversion
your script execution order doesn't matter for this either
I think it's the systems order, I should say. The full conversion hasn't run yet. I bet if I delay a frame...
so you have a prefab that contains a list of prefabs?
wait, yes. I do
and do the child prefabs also require conversion?
The GameObject instance isn't a prefab, but it references a prefab. That reference is reverse resolved with conversionSystem.GetPrimaryEntity(manager.TrailEffectPrefab);
If I delay a frame... When I use GetPrimaryEntity on the same GameObject reference that was the converted pre-cached Prefab, it then returns null. So.... I somehow need to resolve those to Entity references in the manager
.... and, voilla!
Manager does the convert, needs to immediately get the reference because that gets lost in the ether somewhere later, but... Once that's referenced then I can instantiate fully and correctly. Progress
lawl, sounds like the same issue i had! but i didnt consider delaying a frame.
So, GetPrimaryEntity is trash. Don't trust it
Only works in that one frame, which is definitely an issue considering that CompanionLink does exist on the converted Entity
Cool, I can build on this pile of hot mess to do what I need for both abilities and proc level gen
[RequireComponent(typeof(ConvertToEntity))]
public class PrefabMananger : MonoBehaviour, IDeclareReferencedPrefabs, IConvertGameObjectToEntity
{
[SerializeField] public GameObject TrailEffectPrefab;
public Entity TrailEffectPrefabEntity;
void Start()
{
GetComponent<ConvertToEntity>().ConversionMode = ConvertToEntity.Mode.ConvertAndInjectGameObject;
}
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
TrailEffectPrefabEntity = conversionSystem.GetPrimaryEntity(TrailEffectPrefab);
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.Add(TrailEffectPrefab);
}
}```
You can see kind of what's going on here, and how it could be easily extended to build up some sort of managed and structured list before Convert/DeclareReferencedPrefabs
Then, it just works to reference a prefab later by GO, kind of....
Need to do some better structuring down the pipeline, I think
And inject a Singleton into ECS so I can do the same work on both sides.... Managed/Systems
Oh... You are having the same issue that I had, I thought is was a bug at the time but then I understood the whole point of it https://issuetracker.unity3d.com/issues/incorrect-entity-gets-returned-when-using-gameobjectconversionsystem-dot-getprimaryentity-function-for-converted-prefabs-in-subscene
How to reproduce: 1. Open the attached project's Scene labeled "Test" 2. Enter the Play Mode 3. In the Hierarchy, enable the "Prefab...
So, now this brings up a question.... IConvertGameObjectToEntity and IDeclareReferencedPrefabs work at runtime too, correct?
You shouldn't store the an Entity reference outside the ECS world
@rancid geode Sure. So how do I reference entities to send data back to them in a Hybrid system?
Lets say I have some code in regular MB an some in ECS, they need to interop. What's the pattern?
You can store it in an IComponentData, then retrieve it back later
I can store an IComponentData, that may or may not be dereferenced. What's the different between storing that and an Entity?
Also, you have to understand my use case. I'm streaming Prefabs from disk into a SubScene at runtime. This is for proc level gen and dynamic abilities
Not sure if following you, but basically the Entity returned at conversion time is the one from the conversion world, you want the Entity in the destination world
If you store it in an IComponentData/IBufferElementData, the Entity is updated correctly after conversion, if not then you will have an invalid Entity reference
That's part of it, I think. But the structure I pasted above for PrefabManager works and retrieves the correct ID
public struct SpawnerBufferElement : IBufferElementData
{
public Entity Prefab;
}
[DisallowMultipleComponent]
[RequiresEntityConversion]
[ConverterVersion("coimbra", 2)]
public sealed class SpawnerAuthoring : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
{
public GameObject[] Prefabs = Array.Empty<GameObject>();
public void Convert(Entity entity, EntityManager destinationManager, GameObjectConversionSystem conversionSystem)
{
GameObjectConversionUtility.ConvertGameObjectsToEntitiesField(conversionSystem, Prefabs, out Entity[] prefabs);
DynamicBuffer<SpawnerBufferElement> spawnerBuffer = destinationManager.AddBuffer<SpawnerBufferElement>(entity);
foreach (Entity prefab in prefabs)
{
if (prefab != Entity.Null)
{
spawnerBuffer.Add(new SpawnerBufferElement
{
Prefab = prefab,
});
}
}
}
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
foreach (GameObject prefab in Prefabs)
{
if (prefab != null)
{
referencedPrefabs.Add(prefab);
}
}
}
}
This is a working example of mine
Cool, but I see why you have that problem... You're calling Convert twice on the prefabs Once in DeclareReferenced and once in Convert
ConvertGameObjectsToEntitiesField just calls GetPrimaryEntity inside
GameObjectConversionUtility.ConvertGameObjectsToEntitiesField(... , Prefabs
DeclareReferencedPrefabs(... prefabs)
Ah, so it doesn't actually... convert, like it's name implies?
GetPrimaryEntity converts if it is not converted yet AFAIK
I think I'm going to go with a Key/Value system for my needs, but I appreciate knowing I'm on the correct track
And this works at runtime too?
It would be nice if we could do some of this with Systems though, wouldn't it? If we could cram a list of prefabs into a buffer and call them to be converted
Correction: GetPrimaryEntity doesn't convert if no entity is found, it throwns an error ๐
so this method is Literally "Convert GameObject[] to Entity[] " lol
but yeah ,the issue you are having is about you saving a reference to the Entity in conversion Time
@rancid geode What do you think about doing this process on the systems side? Is there a way to force a GameObject into a World?
the issue I linked is the one I reported with a similar use case as yours
Like.... World.AddEntity(GameObject prefab). Wouldn't that be lovely
World.ConversionCommandBuffer ๐
@rancid geode What do you think about doing this process on the systems side? Is there a way to force a GameObject into a World?
@violet cosmos never thought about doing that on the systems side, I tend to avoid accesing GameObjects in Systems (besides ComponentObjects/HybridComponents stored in Entities)
Or, lets say... Even MB reference side. Is there a way to straight up do the convert/inject rather than relying on the interfaces?
(then it could be jobified)
yeah but then you're basically writing your own conversion system ๐
besides the GameObjectConversionSystems (which aren't jobfied), AFAIK no
Boo. That would be nice, wouldn't it? Make a job with a bunch of GameObject references that you can manage loading in what and when you need, rather than having to do something dumb like make a dynamic game object at runtime that implements IDeclareReferencedPrefabs, just to use that and destroy it ๐
Also, would you please clarify for me that IDeclareReferencedPrefabs and IConvertGameObjectToEntity do work at runtime?
a GameObjectConversionUtility.ConvertGameObjectHierarchy(List<GameObject) would be enough for me haha
Also, would you please clarify for me that IDeclareReferencedPrefabs and IConvertGameObjectToEntity do work at runtime?
@violet cosmos they do, you just shouldn't rely on the returned Entity directly, always store it on ICD or IBED and then retrieve it back later
you can just instantiate any object with ConvertToObject script on it and it will be converted, this is how you can do it with addressables, primary addressable comes in, instantiate it into scene which kicks off the conversion.
Oh yah, definitely. Thank you for clarifying. If it didn't, i would have had another mess on my hands
you can just instantiate any object with ConvertToObject script on it and it will be converted, this is how you can do it with addressables, primary addressable comes in, instantiate it into scene which kicks off the conversion.
@mint iron yeah, this is how I have been doing, but it is kind of hacky haha
and topher told us in this discord that its not going to be supported ๐
What? That's stupid, it is, just a chore
yeah, but the only reason I have been doing that is because we don't have dots addressables yet, once we have it I won't need to do conversion at runtime anymore (I hope, at least)
who knows that was about 8 months ago now so maybe things change
DOTS Addressables sounds lovely too. I'd take that
it was mentioned a couple of times already, together with an Addressables 2.0
hopefully it comes sooner than later
you could use prefab subscenes, i think the whole subscene can be passed in addressables? basically use it as a group container.
oh yeah? never thought about it
I did, that's not ideal though
seems a cool workaround, but we lose the nice window with everything on the same place
You load in more than you need, and have to clean up
Anything for injecting prefabs is better than this unproven idea:
- Make a new GameObject
- Disable it
- Attach your ConvertManager Script which implements the conversion interfaces
- Populate your prefabs to ConvertManager
- Enable object
- Wait.
- Destroy GameObject ๐
I guess another way might be to do that on a subscene.... and then merge the scenes, but that's also just dumb
When we really could just use some real tools
I am almost sure that you can just do something like:
new GameObject(typeof(ConvertToEntity)).AddComponent<ConvertManager>().AddBunchOfPrefabs(myList);
and let it go (I would never write a long line like that, but still simple)
we all know about your long line fetish, its okay ๐
@rancid geode That PrefabManager I wrote is going to be the point of ingress and cleanup of prefabs for the game
Even if I have to hack my way through it with that stupid GameObject/ConvertManager step by step, chunking in prefabs over x frames to make it "async", I'll do it
bleh do i really have to mangle my player loop to get physics in fixed update still
WTF Amazon? On the right I'm not logged in
amazon wants your money
it's the light theme tax
If I log in on that other browser, the prices triples
I have an Amazon MX account too. If I go there not logged in, it's available on kindle for around $11. If I go there on the logged in side, it's not even available on Kindle
๐คทโโ๏ธ
Wrote the author, something seems whacky, and I'm sure they'd like to know
You know, I see the power of it, but ECS is a nightmare of tools right now for what I need
Something basic is a struggle. Re: Converting and Instantiating a prefab correctly. That should be bread and butter stuff!
maybe we should make our own tools haha.
add it to our projects in the organization.
make it open source.
make money from it
I'm working on my own tools. Open source? We'll see as it solidifies and where it lands as Unity maybe steers the hybrid workflow
I've come up with some hacky stuff I don't think the wider world should be aware of
Is this a prefab with a unityengine component as a hybrid companion?
?
oh my god FixedRateUtils.EnableFixedRateWithCatchUp is a thing, you can just slap it on a group and get fixed timestep
so it's a hacky way to do fixedupdate?
basically. they kept saying the feature was pending while they finalized the api
but...it's there, and it took way too much searching to find people talking about it
@manic aurora Would you post a simplified example on the wiki in recipes when you get a chance?
Ah, yeah, that is better than parsing text, hahah
@tardy spoke What/how are you passing into the first parameter of the foreach?
that's a class ICD I believe
Unity just accepts it? I thought foreach had a very strict blueprint.
hardcoded parameters (entity, index) > ref > in
could be a custom delegate?
Why is burst/jobs package not showing up in 2020.1 package manager
you have to add manually now i think
@solid flume https://github.com/DOTS-Discord/Unity-DOTS-Discord/wiki/Installing-DOTS-Package-in-Unity-2020.1
Latest versions work fine for me, mfragger
hrmmm
Unrelated -- the per-instance material stuff I was trying to do yesterday has to go on-hold until Unity brings "DOTS Instancing" in Shader Graph materials to URP. The stuff I was reading on doing per-entity instance materials was for HDRP. And since I'm targeting the Switch, and Switch has no plans of ever supporting HDRP, I can't do per-instance materials in DOTS right now ๐ฆ
I'll rollback and wait for burst and jobs to update.
there isn't much update on entities package that I want anyway other than a new way to make archetypes
You could manually select newest versions if you were installing DOTS via dependencies -- I think the Hybrid Renderer doesn't install the newest previews by default yet
Mike Acton put a ton of replies about DOTS on yesterdays AMA: https://www.reddit.com/r/Unity3D/comments/i9meq1/unity_rd_team_2021_roadmap_ama/
It's clear the roadmap and expectations for DOTS have been confusing quite a few of our users. We intend to clarify the road to DOTS in a future blog post for everyone.
confusing is bit of an understatement and not even users fault, Unity just struggles to communicate upon this topic
in fact anything related to DOTS future functionality seems heavily kept secret on their part
we learn about most changes through changelogs once the changes hit, only occasionally know about some bigger incoming feats but that's even worse now that they've put DOTS out of the spotlight
preach. i'm happy to see them acknowledge it, but it's still obnoxious. for a while i've just kind of assumed they've been making up the roadmap as they go based on what needs done in the short term to support other integrated systems
````Providing the best possible .NET runtime performance is definitely an important focus area for us and we have done some initial experiments with CoreCLR, parts of which are detailed in this Porting the Unity Engine to .NET CoreCLR blog post. We do not have any concrete plans to announce at this time, as we are still in the process of assessing the benefits of migrating to CoreCLR for typical Unity workloads.```
soooooooooooooooooooo... Unity isn't planning .Net 5 until 2022 then
wwwweeeeelp
oh unity why do you make me want to jump ship
http://actors.pixeye.games/ what do you guys think of this?
I dunno what to say... unity is eating up 2.7GB of ram
is this the price of performance by default?
@solid flume nice high level stuff. On a quick code check, it seems very similar to how entitas works
so its relatively slow for an ECS
correct me if I'm wrong, but the fact that untiy ecs uses structs for components was for the fact that it'll be on the stack right?
nope
its because structs in C# can be plain-old-data and be memcopied around safely
- they can bypass the GC
hrmmmm...
structs can live purely on the stack which is a fast memory,
and for data oriented architecture, consider speed of access: if you had an array of reference objects, they are just references to a different address, those addresses are often not close to each other,
with an array of structs it is possible to (pre)load all or a lot of the necessary data into the cpu cache, which makes access insanely fast, compared to having to access values in the ram,
and depending on how many such read operations you have, this can matter a lot
there are probably other reasons like vblanco said too
Also how does entitas compare to other ECS solutions including unity ecs
I was thinking of trying ECS with a naive surface nets algorithm
So each chunk is its own entity
entitas is great architecture wise, they also have codegen features,
but they use reference types and interfaces afaik,
so speed and performance wise, unity ecs should be miles ahead
But it's still faster in comparison to the traditional unity workflow?
Why would someone go for an ECS workflow if not for performance benefits?
because there are big architectural benefits too
if you separate everything neatly with systems and components
Tbf I'm kinda not the biggest fan of the scalability of traditional unity, I just haven't had any project where it would matter
I tend to end up relying on inheritance heirarchies and scriptable objects a lot
Also is unity ECS worth learning considering how rapidly it's changing
structs can live purely on the stack which is a fast memory,
and for data oriented architecture, consider speed of access: if you had an array of reference objects, they are just references to a different address, those addresses are often not close to each other,
with an array of structs it is possible to (pre)load all or a lot of the necessary data into the cpu cache, which makes access insanely fast, compared to having to access values in the ram,
and depending on how many such read operations you have, this can matter a lot
@minor sluice so unity ecs benefits greatly because its struct components live on the stack? Whereas entitas uses references types. Is that right so far?
Afaik, not quite.
me not being a cs student is biting me in the ass
Yes you can pass structs (value types) to functions or whatever, which is fast, yes.
BUT
if you have a struct in a class reference, afaik, they live in the same memory that where the heap stores the class instance? although not so sure,
I think it isn't as simple as to say all structs just live on the stack
Most of the benefits come from them living "close to each other" in memory.
but they are "usually" stack allocated
Yes you can pass structs (value types) to functions or whatever, which is fast, yes
this is only true if the struct isn't big,
if you copy a large number of bigger structs (which can just mean calling a method where you don't pass structs as ref) that can take white a significant performance overhead
Most of the benefits come from them living "close to each other" in memory.
hrmmm. Then how does unity achieve that?
You don't store keep things around on the stack. The stack gets filled and popped with "local variables" at whatever piece of code the program is currently executing.
"Entities" or better to say (I think) their archetypes are stored in chunks.
The chunks have a predetermined size of like 16kB or something.
So all entities of the same archetype will be in the same chiunk.
And whenever you're "Entities.ForEach"-ing, you're effectively iterating over all the "entries" on a bunch of different chunks that match whatever query you were looking for.
What ECS system would you recommend for someone who hasn't messed with ECS before ever, both in terms of support/ease of learning as well as general structure of the system?
I'd watch videos
I think the general approach is similar, I only really tried unity ecs so far so I don't have a good comparison
but yeah, maybe watching some talks or articles on data oriented design and ecs might help
There seem to be a lot of options, with many coming before unity ECS and unity ECS being sort of ever changing
Given that chunks are just big of memory, it's extremely cache efficient (given the close memory locality).
@spark glade so unity crams them in this 16KB chunk and also making sure they're components are aligned (since they all have the same components anyway)
(Compare that to a C# Array, where the Array is effectively just . a list of pointers to random memory addresses)
@deft stump exactly
Which is also why it's "expensive" to add/remove components
bc entities have to be copied around to another chunk that matches their new archetype
And i guess the fact that they have this 1 chunk = 1 archetype rule is to divide the chunk into the number of components.
So like the first section is all component a, and the second section is all component b
Yeah there is some smart memory alignment tricks they're doing
And given that the components "line up nicely" in memory, the compiler can do some magic and vectorize some of your code.
This is one of the videos that goes into most of the stuff we just talked about:
Why is ECS fast? In this Unite LA session, Intel showcases examples of the C# Job System + ECS (Entity Component System), and explains how to take advantage of this new Unity feature to optimize your CPU usage.
Speaker:
Issam Khalil (Intel)
I recommend watching the whole thing.
Dang, I can't find the other one that explains all the reasons why ECS is fast so much better than I ever could at 3am ๐ข
What's the difference between .Schedule and .ScheduleParallel?
Long story short, all those things together (+ some more, like heavy reliance on jobs, the burst compiler, ...) CAN make your game, IF there is a use case.
@solid flume from the docs:
Executing the lambda function
To execute a ForEach construction, you have three options:
ScheduleParallel() -- schedules the work to be done in parallel using the C# Job system. Each parallel job instance processes at least one chunk of entities at a time. In other words, if all the selected entities are in the same chunk, then only one job instance is spawned.
Schedule() -- schedules the work to be done in a single job (no matter how many entities are selected).
Run() -- evaluates the entity query and invokes the lambda function for each selected entity immediately on the main thread. Calling Run() completes the system Dependency JobHandle before running, blocking the main thread, if necessary, while it waits for those jobs to finish.
What's the difference between .Schedule and .ScheduleParallel?
@solid flume
Sched executes the job on one thread.
Schedparallel, if your query touches different chunks, will sched the thread per chunk
Fun fact is that under certain conditions (very low entity count), Run() can be faster than ScheduleParalell, because there is some overhead with the job system.
Oh
Why is passing an int to .schedule on an ijobfor throwing an error
JobHandle job = new PointValuesJob()
{
Offset = _currentIndex,
Points = _pointValues,
Size = chunkSize
}.Schedule(_pointValues.Length);```
Because iirc that param is supposed to be a JobHandle.
Apparently it wants a dependency
If I specify a dependency next it stops being angry
But I don't want a dependency
I want this job to do it's own stuff and finish
Unsure about plain Jobs (without ECS context), but, can't you just pass nothing or default ?
Thoinks
Is it a bad idea to just pass a new JobHandle as a parameter without keeping track of it? Will it dispose of itself after the job ends?
I believe that you have to call .Complete() on the job to properly dispose itself
there's a bool for the jobhandle called IsCompleted? not sure. But if it's scheduled, it will check if the job is completed.
once it is, you have to explicitly call Complete() coz it doesn't call that by itself.
Okay, thanks
@spark glade question, are these 16KB chunks not close to one another?
@solid flume even entitas ECS is still a perf win
ive tested it myself
entitas ECS is about 100 times slower than unity ECS, tho the exact number epends on what are you doing
plus huge architectural benefits
which is why people really use it
I feel like learning some form of ECS is a benefit to any project I make, but I'm kinda reluctant to learn unity ECS as my first just because it's in development, and probably not as well documented
ive made a project using it, and quite liked it
tho that project was a perfect use case
being a music game (think beat saber)
@deft stump I'm not sure. I assume they're not linear, but allocated wherever the OS determines it's a good spot. 16kB (or what ever the exact size is) is reasonably to get 99% of the cache locality benefits that it's good enough and chunks don't need to be linear. But I'm completely guessing here.
so basically every note is 1 entitiy, and their logic is done by components/systems
@spark glade there is something important that unity ECS doesnt do
that i tested on my own implementation of a unity-like ECS
idea being
instead of doing
for(chunk in chunks){
systemA(chunk);
}
for(chunk in chunks){
systemB(chunk);
}
doing
for(chunk in chunks){
systemA(chunk);
systemB(chunk);
}
absolutely huge speed gains in the case that systems AB are related systems and read/write related components, as the chunk stays loaded in the L1 cache through multiple systems
tho you can do that sort of stuff "manually" if you need it
@deft stump https://github.com/DOTS-Discord/Unity-DOTS-Discord/wiki/ECS:-Run-vs.-Schedule-vs.-ScheduleParallel - URL says it all
@violet cosmos he was asking plain jobs not ecs jobs.
Same thing, I need to reformat it so it covers both contexts though
Well, mostly. Thinking on it... maybe there should be a separate version for Jobs and ECS
Is there any way I can cancel and immediately stop a job?
call complete
I'll have to wait for it to finish then
entitas ECS is about 100 times slower than unity ECS, tho the exact number epends on what are you doing
it really does depend what you're doing, if you're properly processing large amounts of stuff in burst then Unity ECS is going to win hands down (and almost all of that is due to burst not anything inherently good about the ECS impl). But if you're doing a lot UI, interaction, lots of different things that each do very little then Entities is faster because it doesn't have the same overheads - the code gen basically hardcodes most of the data access.
@spark glade I asked a friend. and yup, you're right. the OS does decide where to put the chunk in mem.
to achieve what I asked on making the chunks side-by-side my friend said that you can just make 1 giant malloc and subdivide it by 16kb. but that's inflexible.
I wonder if there's a pattern to stop a Job that goes something like...
int jobDef = JobManagerSingle.RegisterNewJob();
Job {
if (JobManagerSingle.JobCancel(jobDef)
return;
//work
}.Schedule();
That doesn't sound like a good idea.... Because then you have partial results in a dependency. But, it might be OK if it's one job you've scheduled and it hasn't run yet
your method in ForEach is wrapped by the code that iterates the chunks, so they could easily put an early-out option in there somewhere to break the loop. Seems useful, and if it were an option they could compile it out for normal loops where its not needed/used.
o0o0o, this just came up on my github feed https://github.com/badamczewski/DataOrientedDesign/tree/master/DoDSamples/Samples
There's a book called Data Oriented Design, by Richard Fabian that I think I'm going to read through
is it this? https://www.dataorienteddesign.com/dodbook/
Data-Oriented Design
i really like this video too i think its required listening on some of the underpinnings: https://youtu.be/WDIkqP4JbkE?t=80
code::dive conference 2014 - Nokia Wrocลaw
http://codedive.pl/
Ah, yes. I was going to get the Kindle version, but it seems like it's not a correct conversion... Seems odd, for a developer, not to be able to convert correctly and instead use a physical book conversion service
Is the array returned by EntityManager.Instantiate batch method ordered the same way a .ForEach job would iterate the entities over?
Assuming unique foreach conditions that only get the newly instantiated entities.
I hate not being able to debug log from inside jobs
You can log if you don't use burst or parallel.
Nope
Nothing
Oh wait
Its running on the worker
Ugh
I can't write to a native list in an ijobfor?
Taking this class psudocode.... How do I find the instance of MySystem and call DoWork()?
I'm looking at kind of a neat pattern online, and it does make sense to call into the system directly
class MySystem : SystemBase
public void DoWork()
Try World.GetOrCreateSystem
That's it, thank you ๐
Is there any thread safe containers like List/Dictionary provided by Unity, or should I use the C# versions?
"Note: All safety checks on NativeContainer types (such as out of bounds checks, deallocation checks, and race condition checks) are only available in the Unity Editor and Play Mode." - it's this warning that has me feeling squeamish
hooo boy. you gotta love that memleaks
@tardy spoke What/how are you passing into the first parameter of the foreach?
@dark cypress Yeah that's a class ICD, I think they're called managed ICD's in the manual.
They're to help bridge between ECS and traditional GO's and stuff.
So that one is holding a ref to a scriptable object called "Quest" (it used to be a textAsset, that's why it's called QuestGiverTextSteps, but that name will be changed).
Look in the manual hiding under "Managed IComponentData".
https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/component_data.html
A lot of people don't know about that ๐คทโโ๏ธ
ty
@solid flume you might as well just get started with Unity ECS I would think? You're already familiar with Unity and stuff so you have a good foundation to understand what's up. Might as well get started now so you're confident at it when it's ready for production stuff in a year or so?
Huh. Fair point
I'm not of the opinion that ECS is the answer for everything. Jobs work fine too, if you know where to cut them in
No, but it's good to learn in general
Agreed, but if you have an existing project there needs to be a reason
That's my angle, if I was doing something for pay I wouldn't touch this shit.
when it's ready for production stuff in a year or so?
i like your optimism ๐
Haha, define "ready", right?
I was honestly given a contract work to make some ecs stuff for them.
Had to explain ALOOOOOT of stuff "that this won't work! It doesn't work that!"
which prompted me to make that dispelling page in the wiki
and then I was booted out
XD
Dev and programming always has weird buzzwords and stuff and DOD and ECS may be one of them soon.
At our mortgage financing company they tasked me with researching machine learning that I already knew didn't apply at all to our product.
They're like "do we need machine learning developers!?" and I'm like "... we have zero problems in that domain. Zero. Problems."
Lol, ML is old as the hills, it's just more powerful since processors are more powerful. I remember researching it first example of ML learning to play checkers was like 1960-something.
ECS is neat but there's a lot of leverage and power in using standardized/understood processes. You make your hiring way more difficult the more specialized you go.
it's best to have a team that is willing to traverse into uncharted waters
Absoloutely. It's a balance for sure.
Is something wrong with my IDE or does Random.Range not work in SystemBase? ๐
in my previous job, we were eating ourselves out lel! can't even grow. had to leave (also prompted my hate for oop).
It wouldn't work in the entites.forEach loop ?
@pliant pike show code
'cause it's a reference
need to use the math library random
I'm just using it in a for loop even straight in the Onupdate it doesn't autocomplete
@deft stump my favourite thing of all time is literally working on small teams or by myself. I can't stand large teams anymore, haha. Inefficiency destroys my soul.
math.Random ?
I'm just not sure if its Visual studio going crap again or what
I'll try it on mine @pliant pike
Random Needs using UnityEngine
Or Unity.Mathematics
Depending on which one you want.
I've got Unity.Mathematics
That one you need to create an instance of, before you can use it.
UnityEngine.Random, not System.Random
I can't find Random in Mathematics
It's in there.
Hmm, weird, I can't either
This works if you need BOTH unityEngine and unity.Mathematics
One seems to break the other because of the overlap in method name
yeah ok thanks all, I'll stick with one or the other
lol that would've confused the hell out of me also
I should put a tutorial up for managed ICD's on the wiki because so many people don't know about that and it really does make creating projects with ECS a LOOOOOOT easier.
yeah I'll have to stick with the UnityEngine one I cant seem to get the maths one to work
= new math.Random ?
I think it needs an initialization because for the forEach loop it would need to be a value type instead of reference
that and it really does make creating projects with ECS a LOOOOOOT easier.
what makes them a lot easier though?
nope doesn't work @tardy spoke
public Random rundom; When I try and do that it says theres a conflict between mathematics.random and Unity.random
you can say it explicitly.
mathemathics.Random rundom = new mathemathics.Random();
@deft stump well what really makes it easier is knowing mentally that if you need to you can easily reach out of the ECS system and use Unity normally, so it's unlikely you'll ever meet an insurmountable problem when building an ECS project that actually derails the whole thing.
that's what I tried but that isnt a proper namespace I dont think
did you try... unity.mathemathics.Random?
@deft stump well what really makes it easier is knowing mentally that if you need to you can easily reach out of the ECS system and use Unity normally, so it's unlikely you'll ever meet an insurmountable problem when building an ECS project that actually derails the whole thing.
@tardy spoke hrmmm... but i'm still expected to write in ecs.
and most probably, it's also not a way to bridge physics between ecs physics and mono physics.
hello, saturday
yep that works, noice, thanks
why does it have to be so complicated
namespaces love being explicit
I get stuck on little problems like that for hours. I always think it's the logic and big stuff that'll take time, but for example I spent 2 hours yesterday figuring out the OnAwake function of a Scriptable object doesn't call unless it's referenced by a monobehaviour somewhere in the project, unless instantiated by code (I was using create asset menu items).
plus ambiguity, and C# hates ambiguity. you gotta tell it what it you need
I think logic in general hates ambiguity. Not sure there's a programming language out there that handles overlapping methods in namespaces well, haha.
yeah same alex that's what I spend most of the time figuring out
Yeah the worst is when the answer actually IS something dumb like that
I don't mind when I'm dumb, but it's worse when the answer is dumb.
I have so many dumb answered questions here 
Haha, pretty sure I hold the record.
Was that just a test experiment or did you release it on some stores?
Ah. I think that's what most programmers call a "regular project".
Once you stop working on it, sometimes it becomes a "test project". ๐
i keep it in my github coz I need the referrence
Is there any good easy way to give an SO asset a "permanent" GUID on creation?
I'll explain more in a wiki page, but the base idea that I came to was make the bullet pattern mapped into a table where each cell points to a list of predefined behaviour.
and each row is supposed to be a 1 pattern.
or do they contain any secret existing GUID upon creation
@tardy spoke I think I did something like that
So I added an assembly definition... and added Unity.Entities as a reference to that. Now I'm getting errors like "The type or namespace name 'IConvertGameObjectToEntity' could not be found "
Is there some restriction using Unity.Entities in an assembly?
@pliant pike yeah, it'd be cool to have it generated and displayed as a read only field. Handy.
But how do I stop it from "re-initializing", hmmm
because it needs to be persistent... like... forever persistent.
I dont know if its completely unique but I used addressables
Everything even basic about ECS just doesn't work ๐
@violet cosmos been meaning to ask. how should I write the page for this example game? should I TL;DR it and summarize the current code base.
OR should I go step by step and retrace my thought process and put it all in there?
.
@deft stump Don't know. Depends on what you're trying to achieve. I'd say, just write what you feel is necessary on a separate page
int tempintval = sauceitem.GetInstanceID();
sauceitem.UniqueID = tempintval;``` I just did that @tardy spoke loaded the scriptbale into sauceitem, then it gives a 4 digit unique integer
@pliant pike good tutorial I found on it, I think it's grabbing the GUID's from an internal system so I believe they'll be stable.
https://coderwall.com/p/jd8ouq/generate-a-unique-id-in-unity-using-a-property-drawer
hooo entities 14 came out yesterday, same for hybrid renderer 0.8
ehh, almost empty updates --'
yeah thats pretty similar to what I'm using
don't you love undocumented updates in editor https://i.imgur.com/3Bu9xmU.png
time to get back to 2020.1.1 then
does anyone know off the top of their head what the threadIndex argument name needs to be for ForEach?
entityInQueryIndex?
ahhh its nativeThreadIndex
@violet cosmos its probably entities.hybrid, thats not dots' fault ๐
Figured out my asmdef issue... Apparently it's not doing the dependency chain correctly...
Yah, that happened to me recently too
what did you do?
In this case it wasn't annoying, because it was just testing flow of GameObject conversion with prefabs and could easily rebuild my one or two test objects
But if I had real stuff in there, I would have been pissed. Likely would have had to roll back the scene files from source control
Try to copy the scene back in with Unity closed?
Wooo, advancements. Now I have a ScriptableObject that defines sets of AssetReference objects to prefabs. It uses Addressables to load the SO, then each prefab. Each prefab is then injected into the world
This happens in helper methods a system, so I can easily schedule structural changes too without having to step too much outside ECS
I think I can even release the GameObject references if I keep the Entity reference
ok nvm it's those 2 new entities & hr version that somehow straight up don't work with addressables 1.8.4
nice
@solid flume wrote a logger that works in jobs/burst etc this morning https://gist.github.com/jeffvella/dee1a82bd5edfcdc9d3067d8c038f95c
ok nvm it's those 2 new entities & hr version that somehow straight up don't work with addressables 1.8.4
@zinc plinth I had a lot of problems with 1.8.4, but removing it and using 1.13.1 in Unity 2020.1 helped
Like, it straight up wouldn't compile
except I wouldn't have addressables in my packages if I wasn't using it?..
Oh, no. Sorry if you were using my screenshot as a reference for setting up Assembly Definitions
??
I think I'm confused. Was trying to help you out with Addressables not working
Welp, it did work for a minute... Now I get "ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext"
When using GameObjectConversionUtility.ConvertGameObjectHierarchy
you want a way to make blobassets?
Now I'm getting new lovely errors. Somehow Addressables just purged and mucked up the script reference to my SO?
OK, I think Unity is doing the correct thing and really sitting down and fixing stuff
@deft stump In this case, the BlobAsset error is in the process of converting a prefab GameObject to an Entity
... hmmm.. is something like this possible? ๐ค
Hm, it's not converting the Collider correctly because somehow the built in hybrid converter's GameObjectConversion system doesn't have a BlobAssetStore initialized yet
Ah, it's angry
Hmm, guess not?
I don't really actually need to do that, just thought it'd be cool.
Yah, I ran into that
The thing is, in the systems world, the types are gone. You have to reflect back to the reference world and that's just not good
If I end up just using "Target" Component it'll likely always be Target and that can just be hardcoded. Less flexible, but it'll do probably for my system.
Yeah, it's weird "crossing the barrier" sometimes.
Can I even target a specific entity by GUID or anything? Those are generated dynamically, haha.
I feel there is something smarter than giving some entities Name components and targeting that way with a string. There's gotta be a more robust solution than that.
You know, I'm just thinking to myself to install Unity 2018 LTS so I can't even be tempted by anything new
Everything is broken
Just another victim of ECS. Sad to see.
So far I haven't had much of an issue with ECS, because I suck so much I only use the basic functionality which seems pretty stable so far. ๐คทโโ๏ธ
SystemBase is GOOD TO GO GUYS!
Ah! The trick is to not even know what addressables are. That has served me well.
Watching vids on them now, haha.
Lel inb4 i want to render sprite animations in ecs
And VS integration is broken. I have to rebuild my project files to get "Attach to Unity" at least once a day
OK, I figured out what's wrong... In my GameObjectConversionSettings object, I need to specify a BlobAssetStore when constructing it, otherwise it's null
Now, I need to find the conversion world, get the BlobAssetStore from the GameObjectConversionSystem there, and then... maybe?
Or, does conversion world only exist in editor time?
goddamnm why do they assume TempJob allocator can only live for 4 frames
they use it internally all over the place meaning if you update your world manually e.g. at 60fps but your game runs at 240fps then you'll get warnings all over the place
it's 2020 games aren't 60fps anymore unity cmonbro
You can tell Unity to cap frame rate per device I believe?
by default comps run unlimited, but I think it can be capped.
Mobile I think caps at 90 or something to save battery
Yeah, but I mean, if it's between that and a bunch of errors or problems... haha
I'd rather play a game at 150 FPS than not play it at all, hahaha
@mint iron That's awesome i wanted to build a logger with which i can specify what world should log, that looks like a solid base for that.
yes you can cap framerate but i mean if your rendering is capped at 240fps to support 240hz monitors, but your logic is capped at 60fps, you'll get warnings
there's even 360hz monitors now
There are 300hz displays that exist, in laptops no less
Ah, interesting, Yeah it seems strange to me to do a "frame" cap vs some kind of cap based on a specific rate, like how DeltaTime works.
maybe underneath is it timebased not frame based
frame caps are only useful on certain platforms
it is frame based and it's really awkward
lul
there's a thread with 50k views here https://forum.unity.com/threads/jobs-lags-jobtempalloc-has-allocations-that-are-more-than-4-frames-old.513124/
but no official acknowledgement i think
Holy hell, really... How do I find which World I should be injecting Prefabs so I they'll eventually show up in the default World? There's four named "loading world" and a 5th that's also tagged "synchronous"
the fix is basically "just cap your game at 60fps lole"
What should I use to schedule a job for every element of an array in parallel?
i could be wrong but i vaguely remember hearing conversion world gets created then destroyed in one frame when conversion needs to happen
Or even better if I can say how many batches to schedule.
it's not something you should touch from the outside but you can add your own conversion systems inside
@hollow sorrel The issue here is that I need to reference a BlobAssetStore. Maybe just make a new one?
haven't used it but BlobAssetStore seems to be a per subscene thing so not sure if that's useful to use
you might wanna cache your blobassets in your regular World and use that
I haven't loaded these yet, I was hoping to tie into an existing conversion world, but it might make sense to make my own
Considering I'm also going to need not just streaming in, but also cleanup that runs smoothly
this is weird
my subscenes are not showing up in scene view
but game view is totally fine
checked
Click "load scene"?
lol
maybe they got unloaded
and are auto loading on runtime
OR... and hear me out... maybe, DOTS is glitchy af and it's just not working. ๐
Lel
Im gonna deal with this tomorrow
Sometimes you eat the bear - and sometimes the bear eats you.
Ahh, I see what's up with Addressables.
If there's a script error when I exit Unity, and come back in they're corrupt in the Editor view. I have to fix all script errors (even if it's in a totally different thing, like my ECS system), and then it shows up
Maybe it won't permanently eat my SO's after all
Geeeze
OK, now I see why they don't want you to use GameObjectConversionUtility at runtime and are likely to deprecate it....
It locks up the editor for seconds
Shit.
This is what it looks like on the Profiler
That is just to convert a particle system with a sphere as a child. Nothing complex
GameObjectConversionUtility.ConvertScene()... 2445.80ms
That's with the whole thing definitely using worker threads
So, next up is to test additive load sub scenes. If that's not going to work, I'm going to have to bow out of ECS
Let me know the subscene performance
and any sweet optimizations you figure out, haha
I just... don't even know if I want to go down that route though
A core tenant of my game design was a bunch of abilities for enemies with mix and match behaviors and graphics, along with procedural generation of levels and even some character bodies
Having to organize that into some sane subscene structure where there's not a lot of unnecessary data loaded might be impossible
The only way I can really think is to have some sort of declarative list of components, and create the entity template on the fly, and have my own custom version of a bi-directional link. But, that's kind of defeating the purpose of ECS, even for Hybrid
@north bay glad you like it, i just fixed a bug on the gist, the update in initialization group attribute was on the wrong list. But yeah, its just a quick rough version, might be worth it to double buffer if you wanted to be able to write from the editor threads as well. The clear is fine here only because system jobs are forced to complete each frame so its not going to overlap for jobs running after the initialization group.
You can use the exact same technique to pass any info back to the main thread like for handle/gizmo drawing etc, its essentially what they do already for unity's debug stream thing for physics collider drawing.
While I am importing project tiny through git url I am getting this error: Library\PackageCache\com.unity.dots.runtime@0.28.0-preview.40\Unity.Entities.Runtime.Build\TinyExportDriver.cs(44,30): error CS0508: 'TinyExportDriver.GetGuidForAssetExport(Object)': return type must be 'Hash128' to match overridden member 'GameObjectConversionSettings.GetGuidForAssetExport(Object)'
com.unity.tiny.all
com.unity.entities
Should I import anything else
Please help me
So, I made a SubScene, and the only thing in it is a prefab with IConvertToEntity.... Same result when I load that additively
@violet cosmos did you solve the erroer?
Oh, well not exactly. Removing the Convert to Entity tag.... It then dropped to 51ms
@wheat stump hahaha, at this point.... which one?
Lol Okay
so yah, even with subscene that have pre-converted entities, it's still avg 55ms to load a very basic hybrid component
That's far far faster than 2800ms, but....
To load an instantiate the prefab, without any ECS stuff is the same, about 55ms
I really need to work this out somehow
Never thought I would write a non-cryptographic Merkel tree for a game
Anyone have tips on how to further optimize this? I already disabled most of the safety restrictions on this to enable unconventional C# job concurrency models.
nniice
I might rewrite that since the hash is dependent on entity ID too
Which may not be consistent from game to game
i'm also making an attempt at that but mine is very early stages, haven't even got to hashing yet but your example will prob help ๐
are you seperating simulation from rendering?
Data wise? No
But since ECS can't do animation, skinned meshes, or cloth physics yet
It is kept separate since it's a GameObject that's rendering
I'm a bit concerned with the way I am doing hashes though
Merkel trees increase in probability of hash collisions the more children they have
i don't know about hashing algorithms but from a quick glance, a target for optimization could be your hashing jobs
ComponentDataFromEntity = random access, there's a couple lookups being done to get from Entity id to Component
it'd be faster if you could iterate and hash in one go, but might be difficult since you have optional components
dunno what the best way would be but you could try an entityquery-per-component approach, that way you'd still have one iteration per component but at least you wouldn't have constant random access
might be worth benchmarking i think
The alternative is to use entity queries
but constructing them is bound to the main thread
and when constructing 8+ queries, it takes longer to do it than the cost incurred by random access
you'd only need to construct them once during oncreate
no, they can be run in jobs
not sure what you mean by that
Right now, every component fires off a IJobParallelFor to spread the computation wide.
For hashing for a specific component/entity combination.
i dunno about ijobparallelfor but if you're doing the entityquery way you'd typically just use IJobChunk, which you can schedule parallel
or use the new way for less boilerplate
and use Entities.ForEach for each component, and .ScheduleParallel() that
basically same thing but your job gets codegen'd
Problem with the new way is that it breaks hard if you aren't using it in OnUpdate
and it doesn't play well when you run it in a generic method
aren't you doing this in OnUpdate
See HashComponents<T> in the file above
The job is actually launched from a generic method
sorry it's private and only being called from onupdate in that file so i assumed it's not being used elsewhere
but yea if you're using it elsewhere that's true
in which case you could still use the IJobChunk way
IJobChunk runs the query in the worker thread, yes?
yeah
does it then spread the computation?
i.e. if there are a high number of chunks, does it distribute the workload?
if you use ScheduleParallel yeah
Hmm, I'll try this and see if I can get this working
it runs per chunk so it can be completely parallel, one chunk is only ever touched by one job at the same time
don't forget to benchmark, i'm curious to see the difference (if you don't want to post result that's fine too, but you should benchmark for your own sake)
I was already sub-0.5 ms for a world with ~600 entities and 6 types
on a 4 core w/ hyperthreading CPU
oo not bad
in debug mode
how much does your simulation tick take?
1ms right now in release mode
Most of which is Unity Physics' Build/Step Physics World
i've never seen anyone else here making a deterministic game so if i'm asking too much just ignore me
ahh yea
i'm also getting 1ms just from Unity Physics, without even adding other systems yet
They really need to figure a better way than to run most of that on the main thread.
yeah the base cost really sucks
you could add 100 physics objects and the result would prob still be around the same 1ms, but it's still 1ms even for nothing
i'm worried that by the time i get to add my own systems sim tick will take too long
how many frames rollback do games usually support, like 8?
8 * 2ms = 16ms so no more time for rendering
I've got a ring buffer of 128
the world size I have is ~212kb?
it's about 27MB of memory, some textures are bigger
Is there a way to get the Entity index from IJobChunk?
yeah
what package version are you using? they changed the names after 0.13 so don't wanna give you wrong info
I'm on 2019.4, so 0.11
aight then i think it's still ArchetypeChunkEntityType
which you pass into your job with EntityManager.GetArchetypeChunkEntityType();
Wait I'm confused, I am trying to get the Entity.Index of the components in the chunk
Is it just firstEntityIndex + i?
sorry indentation keeps fucking me
should figure out how to properly copypaste from visual studio one day
quick example
instead of entitytype you can do the same but for ComponentType<>
ohyeah i forgot the part where you schedule
Dependency = poopJob.ScheduleParallel(entityQuery, Dependency); <- you pass in the entityquery it looks for in this part, not the job itself
Time to toss this in with some unsafe pointers....
@hollow sorrel it actually takes longer
though that might also be because I'm using a NativeMultiHashMap now
either way it's within acceptable performance for me
about 2x longer
whaat
I'm pretty sure it's the atomic write checks NativeMultiHashMap uses
I'll be pushing it up in a second
you could add 100 physics objects and the result would prob still be around the same 1ms, but it's still 1ms even for nothing
yeah the mere overhead of the physics systems existing and being active is weird. you can duplicate the world out from underneath it, simulate it hundreds of times concurrently, and it'll STILL finish in half a millisecond....but one physics world, one object? 0.5ms.
Honestly if it means that scaling up the physics world doesn't have a significant impact, I'll accept the overhead. 
I'm 99% sure the performance regression was moving from NativeArray -> NativeMultiHashMap
since the latter uses atomics to ensure that the state is maintained if written from multiple threads when using ParallelWriter
and the former has zero protection when using from multiple threads
this does mean I'm using less memory as a result
Downloading MegaCity.... Going to need to drink tonight, I think ๐
I'm watching this, and I think some of my problems might be solved in MegaCity https://www.youtube.com/watch?v=9MuC3Kp6OBU
@dusky wind sry late reply, didn't get a good look until now
yea the hashmap might be the reason
however you're also doing GetEntityQuery 6 times every frame, which is kinda slow but it also allocates GC
if you cache these in OnCreate it might still be slower overall but should be better than now at least
Right now... I'm thinking about having PrefabWorld, which has all of the original instances, with ID's and a way to manage them. Something that's persistent with very few actual systems. Then stream into there. Then, when I need something, make a copy and move it into the destination world
But, when I define a system, I can restrict it to only operate on one named world, right?
@hollow sorrel I was under the impression that those are supposed to be cached queries already
also if you could substitute that hashmap for a nativearray it'd prob help a lot
i think you could use [NativeSetThreadIndex] private int threadIndex; in your job and set the result in a nativearray[threadIndex] to guarantee that index will only be written by 1 job at a time
But then I need a native array of entitycount * component count
Which is what I had before
It needs to be sorted too, which doesn't scale linearly or allow for easily spreading over multiple threads
oh i see what you're doing with that sry misread
that's fair
also lemme get back to you on that getentityquery, not sure now
woo, there we go.... "[DisableAutoCreation]", then I can bootstrap my own systems
