#archived-dots

1 messages ยท Page 167 of 1

opaque ledge
#

haha no

safe lintel
#

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

tardy spoke
#

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

violet cosmos
#

@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

dusky wind
#

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

opaque ledge
#

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 ๐Ÿ˜„

dusky wind
#

and I'm not all that sure the existing animation system is running with FloatMode.Strict

deft stump
#

And also i want project tiny to have better documentation. Like. What the fuck is that?

opaque ledge
#

we need high level audio for DOTS imo

safe lintel
#

ah new people for the dots animation support group ๐Ÿ˜…

dusky wind
#

Is it even functional on 2020.x?

tardy spoke
#

@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

dusky wind
#

Last time I tried, I crashed going into play mode.

tardy spoke
#

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

opaque ledge
#

i think someone asked in forums about the progress on DSP and they answer like "eeeh not for a long while" ๐Ÿ˜„

deft stump
#

Lel is it time to buy your services @tardy spoke once dsp comes out?

safe lintel
#

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

opaque ledge
#

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 ๐Ÿ˜„

tardy spoke
#

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

safe lintel
#

yeah dspgraph anther one with no updates closing in a year or so

tardy spoke
#

but there's nothing really to learn/use yet inside DOTS for audio so you're just doing it the normal way still

dusky wind
#

@safe lintel all I gleamed was that the animations are baked into a BlobAsset and write to a unmanaged buffer of float3x4s

tardy spoke
#

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.

dusky wind
#

which requires a specific shader to render

violet cosmos
#

They're using GPU animation? That's annoying for mobile

#

Or anyone GPU bound

tardy spoke
#

Would be nice to be able to switch for mobile

dusky wind
#

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

violet cosmos
#

Yah. I think I'm going to bow out of skinned meshes by style in my project

safe lintel
#

my only focus is desktop so im not familiar to how that affects other platforms

dusky wind
#

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

tardy spoke
#

@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.

opaque ledge
#

๐Ÿ‘

violet cosmos
#

Agreed, sound is often so under-rated by game devs

deft stump
#

Good advice. ThNks for that alex

tardy spoke
#

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.

violet cosmos
#

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

deft stump
#

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

tardy spoke
#

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.

violet cosmos
#

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

tardy spoke
#

That'll be cool. It'll likely all be wildly outdated though.

deft stump
#

Maybe we should do it as joint community project

#

Then make it a wiki page

violet cosmos
#

Update megacity?

tardy spoke
#

That'd be cool.

violet cosmos
#

Or, ANY of the good DOTs examples Unity made and just forgot about

tardy spoke
#

I can't believe it isn't worth one Unity dev's time to update those examples taht they spent MONTHS creating

deft stump
#

We'll just be adding comments, we dont want to break stuff we know nothing about lel

violet cosmos
#

I bet it's under a permissible license

tardy spoke
#

A monobehaviour with no GO / transform.

safe lintel
#

deciphering megacity's audiosystem would be a great project ๐Ÿ‘

tardy spoke
#

Yeah. And seeing how well it actually runs on a phone... lol

dusky wind
#

it's honestly baffling how devs need to RE an example

#

just to figure out how the guts work

tardy spoke
#

Especially when the objective of the company is to get people to use the technology

dusky wind
#

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

violet cosmos
#

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

low oasis
#

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

gusty comet
#

Hi Is this the right place for Tiny questions?

rancid geode
#

@gusty comet don't see why not, but in the forums you might get more help (there isn't much tiny talk around here)

tardy spoke
#

@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.

violet cosmos
#

@tardy spoke I don't see why quests couldn't have a structure, and using the built-in types like List

tardy spoke
#

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

violet cosmos
#

Quest
List<QuestStep> Steps

tardy spoke
#

When you parse JSON it wants you to write the structure of the whole object out before hand

violet cosmos
#

You can use complex types in json

#

Yup, how is that bad? Structure your quest objects

tardy spoke
#

Hmm, I must be misunderstanding something

violet cosmos
#

Start with the objects first, THEN json

tardy spoke
#

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

violet cosmos
#

That's just a List<Vector2>

#

Structure your objects first

tardy spoke
#

Hmm, I'm not sure we're probably thinking different things here

low oasis
#

[GoTo {X500, Y500}, GoTo {X200, Y300}] etc

violet cosmos
#

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

tardy spoke
#

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?

violet cosmos
#
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

tardy spoke
#

I'm deserializing from JSON

violet cosmos
#

When you injest the json, you'll be using something like Quest q = JsonConvert.DeserializeObject<Quest>(jsonString);

tardy spoke
#

Oh, you're saying if you just define the types it will actually keep the order in the object?

violet cosmos
#

It magically figures out all of the stuff, because JSON is named and structured

tardy spoke
#

oh shit

violet cosmos
#

Yes, List and Array is implicit ordering

#

If you've added them in the right order, they're be deserialized in the correct order

tardy spoke
#

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.

violet cosmos
#

That's what I'm saying: Start with your object types and hierarchy first, then just let JSON do it's thing

tardy spoke
#

Yeah sorry, just a misunderstanding on my part, I get what you're saying ๐Ÿ‘

#

I thought the converter was "dumber" than it is

low oasis
#

it is, it converts exactly what you tell it to...

tardy spoke
#

Yeah for some reason looking at the examples I thought it threw the hierarchy out and I was like "... well that's dumb"

low oasis
#

though I've noticed it does a shit job on floats

tardy spoke
#

Luckily, turns out I'm just dumb. ๐Ÿคทโ€โ™‚๏ธ

#

@low oasis in what way?

low oasis
#

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...

violet cosmos
#

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

low oasis
#

hate floating point inprecision

violet cosmos
#

Unity often drifts, even in the editor when I typed something in

low oasis
#

since the json serialize/deserialize is built into Unit, the culprit is "Unity"

violet cosmos
#

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

tardy spoke
#

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.

coarse turtle
#

try the OnEnable() message callback

violet cosmos
#

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

coarse turtle
#

yes, you're right

violet cosmos
#

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

coarse turtle
#

You have a few options: DynamicBuffer<T> or IComponentData with an UnsafeList<T> or T* ptr.

violet cosmos
#

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

tardy spoke
#

@coarse turtle it doesn't matter, no methods will fire with no reference except onDelete unless created by code.

vestal sorrel
#

Anyone has tried the store version of entitas here?

coarse turtle
#

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 ๐Ÿค”

tardy spoke
#

@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.

coarse turtle
tardy spoke
#

I need them to run on play

#

the dumb referencing thing works

#

so... that's fine for now I guess haha

coarse turtle
#

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

tardy spoke
#

@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.

violet cosmos
#

.seebelow

#

You're also structuring it wrong....

amber flicker
#

@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

violet cosmos
#

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

tardy spoke
#

Oh, so breaking it down so each "step" that wouldn't contain multiple of the same directive is it's own "quest"?

violet cosmos
#

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

tardy spoke
#

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

violet cosmos
#

The non programmer needs to make up those numbers?

#

Like, how do they get the world coordinates?

tardy spoke
#

Haha, it's not a PERFECT solution

#

Move a vector3 in the world, grab the coords

#

it's not clean or good

#

lol

violet cosmos
#

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

tardy spoke
#

We'll find out how many days it takes me to program that, hahah

violet cosmos
#

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

tardy spoke
#

Yeah that's cool. Or just a box gizmo they can draw on the world map that returns the vector2's of the corners.

violet cosmos
#

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

tardy spoke
#

Hmm, I could approach it the other way and build the tooling that spits out the JSON

violet cosmos
#

hahaha

#

๐Ÿคฆโ€โ™‚๏ธ

#

I'm not quite sure about your fascination with working with JSON directly man...

tardy spoke
#

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

violet cosmos
#

hahaha, good. Thank you. We were about to not be friends anymore ๐Ÿ˜‰

tardy spoke
#

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.

violet cosmos
#

I wouldn't do that in ECS, fwiw

#

Just make a Singleton that manages and deals with quests

north bay
#

Ye doesn't have to be directly through ecs, you can still store the quests in Blobs

tardy spoke
#

If you didn't understand OOP well you might consider it, haha. ๐Ÿคทโ€โ™‚๏ธ

#

Yeah, could store the quests as Blobs

north bay
#

If you are talking about quests, i only glimpsed over

violet cosmos
#

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

north bay
#

So you can reference them from your player/whatever without needing a weak reference

violet cosmos
#

Singleton, again. You can just reference it from anywhere

tardy spoke
#

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

amber flicker
#

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

tardy spoke
#

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.

violet cosmos
#

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

tardy spoke
#

I dunno if I can justify optimizing the textAsset loader or deserializer vs the 10,000 enemy zombies which need AI and nav.

amber flicker
#

up to you of course but from pov it looks like the most straight-forward and best performing option ยฏ_(ใƒ„)_/ยฏ

tardy spoke
#

... 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. ๐Ÿ™‚

amber flicker
#

yup.. nothing wrong with going with what you know

tardy spoke
#

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.

amber flicker
#

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.

tardy spoke
#

In the spirit of ECS I should probably take a disastrous hybrid approach that just makes everything harder. ๐Ÿค”

amber flicker
#

Just sharing how I would approach it, not how you should

tardy spoke
#

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.

amber flicker
#

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.

tardy spoke
#

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.

safe lintel
#

unless im out of touch, so's dont really fit in at all with ecs currently?

tardy spoke
#

Yeah, not technically. I think they get some love acting as a glue though in hybrid approach stuff.

amber flicker
#

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?

safe lintel
#

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 ๐Ÿ™‚

tardy spoke
#

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?

amber flicker
#

@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.

tardy spoke
#

Could you program a full project in Unity with just SO's instead of monobehaviours? I guess you could?

violet cosmos
#

I won't argue everything should be in ECS, unless you're in Project Tiny ๐Ÿ˜‰

tardy spoke
#

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.

violet cosmos
#

Oh yah, definitely could. They're just structured data holders, with the ability to do some logic

tardy spoke
#

lol they blow my mind. They're just like... little not quite lambda functions floating around.

hollow sorrel
#

that's like saying "could you make a project with only data and no systems"

violet cosmos
#

No, you wouldn't be screwed. You just need to have some way to load them. You can also load them from disk

tardy spoke
#

The other weird thing about them is they seem to be persistent with their data?

violet cosmos
#

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

tardy spoke
#

Interesting

#

I think it would actually encourage better architecture that they are because you have to better understand you systems and initializations and whatnot

amber flicker
#

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.

tardy spoke
#

I've never tried but can you execute a function on a blobAsset of code?

#

if you were to blobAsset-ize some callable code?

amber flicker
#

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.

tardy spoke
#

Yeah, can't think of why you would, but would be an interesting thing to try, haha.

north bay
#

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

rancid geode
#

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

amber flicker
#

well.. you could program an entire game events based rather than Update loop but anyway... let's stop ๐Ÿ˜„

tardy spoke
#

@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

rancid geode
#

well, yeah, you could, but it doesn't mean you should hehe

tardy spoke
#

Well, none of us SHOULD be using ECS either. It's hard and makes us grumpy. Yet here we are. ๐Ÿคทโ€โ™‚๏ธ

hollow sorrel
#

you can make a unity project without any monobehaviours

#

just a regular C# class with [InitializeOnLoadMethod] where you inject into the update loop

tardy spoke
#

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#

violet cosmos
#

Uff, I hate all these instantiation examples.... So much spreading around of code. Hybrid ECS is a mess

amber flicker
#

anything in particular?

violet cosmos
#

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

amber flicker
#

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.

violet cosmos
#

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

amber flicker
#

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.

violet cosmos
#

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

wheat stump
#

Need sources: Why does project tiny require c++ build environmental

violet cosmos
#

... and it's buffer data, for some reason?

hollow sorrel
tardy spoke
wheat stump
#

Thanks @tardy spoke and @hollow sorrel

violet cosmos
#

@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

amber flicker
#

Ah this might be that you also need to add the particlesystemrenderer? I think I remember seeing someone else with that problem anyway

violet cosmos
#

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
amber flicker
#

Ah sorry didnโ€™t see you said that ๐Ÿ‘

violet cosmos
#

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)

amber flicker
#

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

violet cosmos
#

Thanks, I'll follow up on that

violet cosmos
#

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?

hollow sorrel
#

yes

violet cosmos
#

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.

hollow sorrel
#

pretty much nothing?

#

what does it have on it?

violet cosmos
#

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

hollow sorrel
#

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

violet cosmos
#

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

wild verge
#

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)

violet cosmos
#

@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

safe lintel
#

its basically unity's new engine

wild verge
#

Ah, makes sense

#

Thanks :D

hollow sorrel
#

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

safe lintel
#

@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

violet cosmos
#

Is there a way to roll back packages in Unity?

safe lintel
#

version control ๐Ÿ˜‰

wild verge
#

but it's only ecs that's using the design philosophy right now right?

safe lintel
#

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

wild verge
#

Alright

#

Thanks for the info

violet cosmos
#

@hollow sorrel Yah, that's kind of the point. I'm trying to pre-cache prefabs before using them,

mint iron
#

entity prefabs?

violet cosmos
#

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

mint iron
#

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.

violet cosmos
#

@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

mint iron
#

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.

violet cosmos
#

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....

hollow sorrel
#

what i meant was are you referencing your actual prefab, or are you referencing the instantiated prefab in your scene

violet cosmos
#

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

hollow sorrel
#

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

violet cosmos
#

So, testing... It does appear like Unity is somehow not doing this in the correct order

#

Here's the workflow:

  1. On the PrefabManager I drag some Prefabs from the project. It's MB script execution order is -100
  2. PrefabManager has IDeclareReferencedPrefabs and adds all prefabs to the referencedPrefabs list
  3. 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
  4. 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?

hollow sorrel
#

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

violet cosmos
#

I think it's the systems order, I should say. The full conversion hasn't run yet. I bet if I delay a frame...

mint iron
#

so you have a prefab that contains a list of prefabs?

violet cosmos
#

wait, yes. I do

mint iron
#

and do the child prefabs also require conversion?

violet cosmos
#

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

mint iron
#

lawl, sounds like the same issue i had! but i didnt consider delaying a frame.

violet cosmos
#

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

rancid geode
#

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

violet cosmos
#

So, now this brings up a question.... IConvertGameObjectToEntity and IDeclareReferencedPrefabs work at runtime too, correct?

rancid geode
#

You shouldn't store the an Entity reference outside the ECS world

violet cosmos
#

@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?

rancid geode
#

You can store it in an IComponentData, then retrieve it back later

violet cosmos
#

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

rancid geode
#

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

violet cosmos
#

That's part of it, I think. But the structure I pasted above for PrefabManager works and retrieves the correct ID

rancid geode
#
    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

violet cosmos
#

Cool, but I see why you have that problem... You're calling Convert twice on the prefabs Once in DeclareReferenced and once in Convert

rancid geode
#

ConvertGameObjectsToEntitiesField just calls GetPrimaryEntity inside

violet cosmos
#

GameObjectConversionUtility.ConvertGameObjectsToEntitiesField(... , Prefabs
DeclareReferencedPrefabs(... prefabs)

#

Ah, so it doesn't actually... convert, like it's name implies?

rancid geode
#

GetPrimaryEntity converts if it is not converted yet AFAIK

violet cosmos
#

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

rancid geode
#

Correction: GetPrimaryEntity doesn't convert if no entity is found, it throwns an error ๐Ÿ‘€

#

so this method is Literally "Convert GameObject[] to Entity[] " lol

violet cosmos
#

hahaha

#

Nice... "Under Construction"

rancid geode
#

but yeah ,the issue you are having is about you saving a reference to the Entity in conversion Time

violet cosmos
#

@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?

rancid geode
#

the issue I linked is the one I reported with a similar use case as yours

violet cosmos
#

Like.... World.AddEntity(GameObject prefab). Wouldn't that be lovely

#

World.ConversionCommandBuffer ๐Ÿ˜

rancid geode
#

@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)

violet cosmos
#

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)

mint iron
#

yeah but then you're basically writing your own conversion system ๐Ÿ˜„

rancid geode
#

besides the GameObjectConversionSystems (which aren't jobfied), AFAIK no

violet cosmos
#

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?

rancid geode
#

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

mint iron
#

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.

violet cosmos
#

Oh yah, definitely. Thank you for clarifying. If it didn't, i would have had another mess on my hands

rancid geode
#

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

mint iron
#

and topher told us in this discord that its not going to be supported ๐Ÿ˜›

violet cosmos
#

What? That's stupid, it is, just a chore

rancid geode
#

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)

mint iron
#

who knows that was about 8 months ago now so maybe things change

violet cosmos
#

DOTS Addressables sounds lovely too. I'd take that

rancid geode
#

it was mentioned a couple of times already, together with an Addressables 2.0

#

hopefully it comes sooner than later

mint iron
#

you could use prefab subscenes, i think the whole subscene can be passed in addressables? basically use it as a group container.

rancid geode
#

oh yeah? never thought about it

violet cosmos
#

I did, that's not ideal though

rancid geode
#

seems a cool workaround, but we lose the nice window with everything on the same place

violet cosmos
#

You load in more than you need, and have to clean up

rancid geode
#

yeah, fair

#

will keep using the ICGOTE hacky way for now

violet cosmos
#

Anything for injecting prefabs is better than this unproven idea:

  1. Make a new GameObject
  2. Disable it
  3. Attach your ConvertManager Script which implements the conversion interfaces
  4. Populate your prefabs to ConvertManager
  5. Enable object
  6. Wait.
  7. 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

rancid geode
#

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)

mint iron
#

we all know about your long line fetish, its okay ๐Ÿ˜„

violet cosmos
#

@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

manic aurora
#

bleh do i really have to mangle my player loop to get physics in fixed update still

violet cosmos
deft stump
#

amazon wants your money

hollow sorrel
#

it's the light theme tax

violet cosmos
#

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

deft stump
#

coding in ecs and dod, I can never go back to oop! XD

#

I forgot my monob basics lel

violet cosmos
#

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!

deft stump
#

maybe we should make our own tools haha.
add it to our projects in the organization.
make it open source.
make money from it

violet cosmos
#

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

safe lintel
#

Is this a prefab with a unityengine component as a hybrid companion?

violet cosmos
#

?

manic aurora
#

oh my god FixedRateUtils.EnableFixedRateWithCatchUp is a thing, you can just slap it on a group and get fixed timestep

deft stump
#

so it's a hacky way to do fixedupdate?

manic aurora
#

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

violet cosmos
#

@manic aurora Would you post a simplified example on the wiki in recipes when you get a chance?

tardy spoke
dark cypress
#

@tardy spoke What/how are you passing into the first parameter of the foreach?

deft stump
#

that's a class ICD I believe

dark cypress
#

Unity just accepts it? I thought foreach had a very strict blueprint.

#

hardcoded parameters (entity, index) > ref > in

safe lintel
#

could be a custom delegate?

solid flume
#

Why is burst/jobs package not showing up in 2020.1 package manager

opaque ledge
#

you have to add manually now i think

solid flume
#

How?

#

Okay apparently show preview packages is in project settings now

opaque ledge
solid flume
#

I got it now

#

Just have to enable preview packages

#

It's dumb that they moved it

deft stump
#

hrmmm

#

new entities package is giving errors

#

burst incompatability?

slow vault
#

Latest versions work fine for me, mfragger

deft stump
#

hrmmm

slow vault
#

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 ๐Ÿ˜ฆ

deft stump
#

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

slow vault
#

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

dark cypress
#

Yeah, you have to edit the manifest to get HDRP to work.

#

With hybrid V2.

dull copper
#

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

manic aurora
#

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

deft stump
#

````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

solid flume
deft stump
#

I dunno what to say... unity is eating up 2.7GB of ram

#

is this the price of performance by default?

vagrant surge
#

@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

deft stump
#

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?

vagrant surge
#

nope

#

its because structs in C# can be plain-old-data and be memcopied around safely

#
  • they can bypass the GC
deft stump
#

hrmmmm...

solid flume
#

Is it enough of a performance benefit to learn over unity ECS?

#

@vagrant surge

minor sluice
#

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

solid flume
#

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

minor sluice
#

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

solid flume
#

But it's still faster in comparison to the traditional unity workflow?

minor sluice
#

no idea

#

I have seen some talks around it, haven't actually used it tbh

solid flume
#

Why would someone go for an ECS workflow if not for performance benefits?

minor sluice
#

because there are big architectural benefits too

#

if you separate everything neatly with systems and components

solid flume
#

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

deft stump
#

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?

spark glade
#

Afaik, not quite.

deft stump
#

me not being a cs student is biting me in the ass

spark glade
#

Yes you can pass structs (value types) to functions or whatever, which is fast, yes.

#

BUT

minor sluice
#

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

spark glade
#

Most of the benefits come from them living "close to each other" in memory.

minor sluice
#

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

deft stump
#

Most of the benefits come from them living "close to each other" in memory.
hrmmm. Then how does unity achieve that?

spark glade
#

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.

solid flume
#

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?

spark glade
#

I'd watch videos

minor sluice
#

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

solid flume
#

There seem to be a lot of options, with many coming before unity ECS and unity ECS being sort of ever changing

spark glade
#

Given that chunks are just big of memory, it's extremely cache efficient (given the close memory locality).

deft stump
#

@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)

spark glade
#

(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

deft stump
#

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

spark glade
#

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:

#

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 ๐Ÿ˜ข

solid flume
#

What's the difference between .Schedule and .ScheduleParallel?

spark glade
#

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.
deft stump
#

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

solid flume
#

What chunks

#

I'm not using ecs

#

Just plain jobs

spark glade
#

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.

deft stump
#

Oh

solid flume
#

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);```
spark glade
#

Because iirc that param is supposed to be a JobHandle.

solid flume
#

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

spark glade
#

Unsure about plain Jobs (without ECS context), but, can't you just pass nothing or default ?

solid flume
#

Can't pass nothing

#

Ah docs says it needs a dependency so just give it a new job

deft stump
#

@solid flume this vid might help you out. I forgot my plain jobs

solid flume
#

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?

deft stump
#

I believe that you have to call .Complete() on the job to properly dispose itself

solid flume
#

Ugh

#

I guess I might as well just have a JobHandle just for this

deft stump
#

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.

solid flume
#

Okay, thanks

deft stump
#

@spark glade question, are these 16KB chunks not close to one another?

vagrant surge
#

@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

solid flume
#

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

vagrant surge
#

just try Entitas

#

its been used in quite a few real games

solid flume
#

Okay

#

Thanks for the input

vagrant surge
#

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)

spark glade
#

@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.

vagrant surge
#

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

violet cosmos
deft stump
#

@violet cosmos he was asking plain jobs not ecs jobs.

violet cosmos
#

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

solid flume
#

Is there any way I can cancel and immediately stop a job?

deft stump
#

call complete

solid flume
#

I'll have to wait for it to finish then

mint iron
#

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.

deft stump
#

@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.

violet cosmos
#

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

mint iron
#

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.

deft stump
#

noiece

#

github really is the facebook for developers

violet cosmos
#

There's a book called Data Oriented Design, by Richard Fabian that I think I'm going to read through

deft stump
mint iron
violet cosmos
#

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

dark cypress
#

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.

solid flume
#

I hate not being able to debug log from inside jobs

dark cypress
#

You can log if you don't use burst or parallel.

solid flume
#

I'm using ijobfor without burst

#

My debug logs aren't showing up

dark cypress
#

IIRC logs only show up if it runs on the main thread.

#

Check in the profiler.

solid flume
#

Nope

#

Nothing

#

Oh wait

#

Its running on the worker

#

Ugh

#

I can't write to a native list in an ijobfor?

violet cosmos
#

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()
dark cypress
#

Try World.GetOrCreateSystem

violet cosmos
#

That's it, thank you ๐Ÿ˜„

#

Is there any thread safe containers like List/Dictionary provided by Unity, or should I use the C# versions?

dark cypress
#

There are a bunch of native collections.

#

In the Unity.Collections namespace.

violet cosmos
#

"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

deft stump
#

hooo boy. you gotta love that memleaks

tardy spoke
#

@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 ๐Ÿคทโ€โ™‚๏ธ

dark cypress
#

ty

tardy spoke
#

@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?

solid flume
#

Huh. Fair point

violet cosmos
#

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

tardy spoke
#

No, but it's good to learn in general

violet cosmos
#

Agreed, but if you have an existing project there needs to be a reason

tardy spoke
#

That's my angle, if I was doing something for pay I wouldn't touch this shit.

mint iron
#

when it's ready for production stuff in a year or so?
i like your optimism ๐Ÿ˜‹

tardy spoke
#

Haha, define "ready", right?

deft stump
#

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

tardy spoke
#

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.

deft stump
#

it's best to have a team that is willing to traverse into uncharted waters

tardy spoke
#

Absoloutely. It's a balance for sure.

pliant pike
#

Is something wrong with my IDE or does Random.Range not work in SystemBase? ๐Ÿ˜•

deft stump
#

in my previous job, we were eating ourselves out lel! can't even grow. had to leave (also prompted my hate for oop).

tardy spoke
#

It wouldn't work in the entites.forEach loop ?

deft stump
#

@pliant pike show code

tardy spoke
#

'cause it's a reference

mint iron
#

need to use the math library random

pliant pike
#

I'm just using it in a for loop even straight in the Onupdate it doesn't autocomplete

tardy spoke
#

@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 ?

pliant pike
#

I'm just not sure if its Visual studio going crap again or what

tardy spoke
#

I'll try it on mine @pliant pike

dark cypress
#

Random Needs using UnityEngine

#

Or Unity.Mathematics

#

Depending on which one you want.

pliant pike
#

I've got Unity.Mathematics

dark cypress
#

That one you need to create an instance of, before you can use it.

tardy spoke
rancid geode
#

UnityEngine.Random, not System.Random

pliant pike
#

I can't find Random in Mathematics

dark cypress
#

It's in there.

tardy spoke
#

Hmm, weird, I can't either

dark cypress
#

From mathematics.

tardy spoke
#

One seems to break the other because of the overlap in method name

pliant pike
#

yeah ok thanks all, I'll stick with one or the other

tardy spoke
#

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.

pliant pike
#

yeah I'll have to stick with the UnityEngine one I cant seem to get the maths one to work

tardy spoke
#

= 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

deft stump
#

that and it really does make creating projects with ECS a LOOOOOOT easier.
what makes them a lot easier though?

pliant pike
#

nope doesn't work @tardy spoke

tardy spoke
#

Weird shit

#

I wonder if I use random anywhere... I'll check

deft stump
#

what do you mean it doesn't work?

#

compiler complaining?

pliant pike
#

public Random rundom; When I try and do that it says theres a conflict between mathematics.random and Unity.random

deft stump
#

you can say it explicitly.
mathemathics.Random rundom = new mathemathics.Random();

tardy spoke
#

@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.

pliant pike
#

that's what I tried but that isnt a proper namespace I dont think

deft stump
#

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.

tight blade
#

hello, saturday

pliant pike
#

yep that works, noice, thanks

tardy spoke
#

Yaaaay

#

Randomness

pliant pike
#

why does it have to be so complicatedleahU

deft stump
#

namespaces love being explicit

tardy spoke
#

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).

deft stump
#

plus ambiguity, and C# hates ambiguity. you gotta tell it what it you need

tardy spoke
#

I think logic in general hates ambiguity. Not sure there's a programming language out there that handles overlapping methods in namespaces well, haha.

pliant pike
#

yeah same alex that's what I spend most of the time figuring out

tardy spoke
#

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.

pliant pike
#

I have so many dumb answered questions here leahS

tardy spoke
#

Haha, pretty sure I hold the record.

deft stump
#

trying to push the bullethell game, to the wiki

#

lel

tardy spoke
#

Was that just a test experiment or did you release it on some stores?

deft stump
#

an abandoned project

#

but the base idea and implementations are solid enough

tardy spoke
#

Ah. I think that's what most programmers call a "regular project".

#

Once you stop working on it, sometimes it becomes a "test project". ๐Ÿ™‚

deft stump
#

i keep it in my github coz I need the referrence

tardy spoke
#

Is there any good easy way to give an SO asset a "permanent" GUID on creation?

deft stump
#

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.

tardy spoke
#

or do they contain any secret existing GUID upon creation

pliant pike
#

@tardy spoke I think I did something like that

violet cosmos
#

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?

tardy spoke
#

@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.

pliant pike
#

I dont know if its completely unique but I used addressables

violet cosmos
#

Everything even basic about ECS just doesn't work ๐Ÿ˜›

deft stump
#

@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?

violet cosmos
#

.

#

@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

pliant pike
#
            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
tardy spoke
zinc plinth
#

hooo entities 14 came out yesterday, same for hybrid renderer 0.8

#

ehh, almost empty updates --'

pliant pike
#

yeah thats pretty similar to what I'm using

zinc plinth
#

time to get back to 2020.1.1 then

mint iron
#

does anyone know off the top of their head what the threadIndex argument name needs to be for ForEach?

dark cypress
#

entityInQueryIndex?

mint iron
#

ahhh its nativeThreadIndex

safe lintel
#

@violet cosmos its probably entities.hybrid, thats not dots' fault ๐Ÿ™‚

violet cosmos
#

Figured out my asmdef issue... Apparently it's not doing the dependency chain correctly...

deft stump
#

so

#

the new entities package

#

killed my subscene

violet cosmos
#

Yah, that happened to me recently too

deft stump
#

what did you do?

violet cosmos
#

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

deft stump
#

I have realstuff

#

tsk

#

the price of bleeding edge

violet cosmos
#

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

zinc plinth
#

ok nvm it's those 2 new entities & hr version that somehow straight up don't work with addressables 1.8.4

#

nice

mint iron
violet cosmos
#

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

zinc plinth
#

except I wouldn't have addressables in my packages if I wasn't using it?..

violet cosmos
#

Oh, no. Sorry if you were using my screenshot as a reference for setting up Assembly Definitions

zinc plinth
#

??

violet cosmos
#

I think I'm confused. Was trying to help you out with Addressables not working

deft stump
#

lele

#

so just 1 restart

#

fixed it

violet cosmos
#

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

deft stump
#

you want a way to make blobassets?

violet cosmos
#

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

tardy spoke
violet cosmos
#

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

tardy spoke
#

I don't really actually need to do that, just thought it'd be cool.

violet cosmos
#

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

tardy spoke
#

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.

violet cosmos
#

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

tardy spoke
#

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!

violet cosmos
#

No, Addressables is broken. It's 1.13!

#

It's eating my ScriptableObjects

tardy spoke
#

Ah! The trick is to not even know what addressables are. That has served me well.

#

Watching vids on them now, haha.

deft stump
#

Lel inb4 i want to render sprite animations in ecs

violet cosmos
#

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?

hollow sorrel
#

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

tardy spoke
#

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

deft stump
#

not everyone likes to have their game capped.

#

I honestly dont

tardy spoke
#

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

north bay
#

@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.

hollow sorrel
#

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

violet cosmos
#

There are 300hz displays that exist, in laptops no less

tardy spoke
#

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.

deft stump
#

maybe underneath is it timebased not frame based

violet cosmos
#

frame caps are only useful on certain platforms

hollow sorrel
#

it is frame based and it's really awkward

deft stump
#

lul

hollow sorrel
violet cosmos
#

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"

hollow sorrel
#

the fix is basically "just cap your game at 60fps lole"

violet cosmos
dark cypress
#

What should I use to schedule a job for every element of an array in parallel?

hollow sorrel
#

i could be wrong but i vaguely remember hearing conversion world gets created then destroyed in one frame when conversion needs to happen

dark cypress
#

Or even better if I can say how many batches to schedule.

hollow sorrel
#

it's not something you should touch from the outside but you can add your own conversion systems inside

violet cosmos
#

@hollow sorrel The issue here is that I need to reference a BlobAssetStore. Maybe just make a new one?

hollow sorrel
#

not sure

#

what're you using it for

#

out of curiosity

violet cosmos
#

Streaming in prefabs

#

At runtime, pretty much as needed

hollow sorrel
#

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

violet cosmos
#

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

deft stump
#

this is weird

#

my subscenes are not showing up in scene view

#

but game view is totally fine

tardy spoke
#

autoload is checked or unchecked?

#

also

deft stump
#

checked

tardy spoke
#

also scenes reimport button

deft stump
#

it shows up in game view

#

but not in scene view

tardy spoke
#

Click "load scene"?

#

lol

#

and are auto loading on runtime

#

OR... and hear me out... maybe, DOTS is glitchy af and it's just not working. ๐Ÿ˜‰

deft stump
#

Lel

tardy spoke
#

Did you move their assets by accident?

#

actually that probably wouldn't do it

deft stump
#

Im gonna deal with this tomorrow

tardy spoke
#

Sometimes you eat the bear - and sometimes the bear eats you.

violet cosmos
#

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.

#

That is just to convert a particle system with a sphere as a child. Nothing complex

violet cosmos
#

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

tardy spoke
#

Let me know the subscene performance

#

and any sweet optimizations you figure out, haha

violet cosmos
#

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

hollow sorrel
#

give in to the boilerplate

#

join the dark oriented side

#

i mean data

mint iron
#

@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.

wheat stump
#

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

violet cosmos
#

So, I made a SubScene, and the only thing in it is a prefab with IConvertToEntity.... Same result when I load that additively

wheat stump
#

@violet cosmos did you solve the erroer?

violet cosmos
#

Oh, well not exactly. Removing the Convert to Entity tag.... It then dropped to 51ms

#

@wheat stump hahaha, at this point.... which one?

wheat stump
#

Lol Okay

violet cosmos
#

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....

violet cosmos
#

To load an instantiate the prefab, without any ECS stuff is the same, about 55ms

#

I really need to work this out somehow

dusky wind
#

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.

hollow sorrel
#

ooo

#

are you also making a deterministic game?

dusky wind
#

Yes

#

The main reason I want ECS/DOTS is rollback compatible determinism

hollow sorrel
#

nniice

dusky wind
#

I might rewrite that since the hash is dependent on entity ID too

#

Which may not be consistent from game to game

hollow sorrel
#

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?

dusky wind
#

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

hollow sorrel
#

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

dusky wind
#

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

hollow sorrel
#

you'd only need to construct them once during oncreate

dusky wind
#

Are queries not bound to the main thread?

#

or can they be run in jobs?

hollow sorrel
#

no, they can be run in jobs

dusky wind
#

Oh hmm

#

Can you schedule as IJobParallelFor from a job?

hollow sorrel
#

not sure what you mean by that

dusky wind
#

Right now, every component fires off a IJobParallelFor to spread the computation wide.

#

For hashing for a specific component/entity combination.

hollow sorrel
#

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

dusky wind
#

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

hollow sorrel
#

aren't you doing this in OnUpdate

dusky wind
#

See HashComponents<T> in the file above

#

The job is actually launched from a generic method

hollow sorrel
#

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

dusky wind
#

IJobChunk runs the query in the worker thread, yes?

hollow sorrel
#

yeah

dusky wind
#

does it then spread the computation?

#

i.e. if there are a high number of chunks, does it distribute the workload?

hollow sorrel
#

if you use ScheduleParallel yeah

dusky wind
#

Hmm, I'll try this and see if I can get this working

hollow sorrel
#

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)

dusky wind
#

I was already sub-0.5 ms for a world with ~600 entities and 6 types

#

on a 4 core w/ hyperthreading CPU

hollow sorrel
#

oo not bad

dusky wind
#

in debug mode

hollow sorrel
#

how much does your simulation tick take?

dusky wind
#

1ms right now in release mode

#

Most of which is Unity Physics' Build/Step Physics World

hollow sorrel
#

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

dusky wind
#

They really need to figure a better way than to run most of that on the main thread.

hollow sorrel
#

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

dusky wind
#

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?

hollow sorrel
#

yeah

#

what package version are you using? they changed the names after 0.13 so don't wanna give you wrong info

dusky wind
#

I'm on 2019.4, so 0.11

hollow sorrel
#

aight then i think it's still ArchetypeChunkEntityType

#

which you pass into your job with EntityManager.GetArchetypeChunkEntityType();

dusky wind
#

Wait I'm confused, I am trying to get the Entity.Index of the components in the chunk

#

Is it just firstEntityIndex + i?

hollow sorrel
#

sorry indentation keeps fucking me
should figure out how to properly copypaste from visual studio one day

#

quick example

dusky wind
#

Ohhhh

#

I see

#

thanks!

hollow sorrel
#

instead of entitytype you can do the same but for ComponentType<>

dusky wind
#

This is... unintuitive

#

to say the least

hollow sorrel
#

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

dusky wind
#

Time to toss this in with some unsafe pointers....

dusky wind
#

@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

hollow sorrel
#

huh that's weird

#

how much longer?

dusky wind
#

about 2x longer

hollow sorrel
#

whaat

dusky wind
#

I'm pretty sure it's the atomic write checks NativeMultiHashMap uses

hollow sorrel
#

can i see the new code?

#

out of curiosity

dusky wind
#

I'll be pushing it up in a second

manic aurora
#

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.

dusky wind
#

Honestly if it means that scaling up the physics world doesn't have a significant impact, I'll accept the overhead. OMEGALUL

#

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

violet cosmos
#

Downloading MegaCity.... Going to need to drink tonight, I think ๐Ÿ˜„

hollow sorrel
#

@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

violet cosmos
#

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?

dusky wind
#

@hollow sorrel I was under the impression that those are supposed to be cached queries already

hollow sorrel
#

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

dusky wind
#

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

hollow sorrel
#

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

violet cosmos
#

woo, there we go.... "[DisableAutoCreation]", then I can bootstrap my own systems

hollow sorrel
#

@dusky wind hah, docs do say it is cached but apparently it's still allocating because you pass in a componenttype[] which is managed

#

learned something new today

#

but yea execution time it's prob not so bad then