#What is DOTS mostly replacing?

1 messages · Page 1 of 1 (latest)

gritty jacinth
#

As someone who’s new to Unity and has to traverse a sea of mostly outdated tutorials I’m trying to get a firm understanding of what’s considered the previous approach and the new DOTS approach. Somethings I’ve seen are GameObjects, MonoBehaviours and etc.

Is there a translation that makes DOTS concept from what was the previous concept? I understand that MonoBehaviours are still used when necessary but I don’t understand the “when necessary part”.

rose kettle
#

"When necessary" means when there are holes in the design that needs to be bridged. For example, you will need a monobehavior authoring script to convert your prefab/gameobject into an entity

#

This will probably be addressed in Unity 7+ but for now you'd still be using mono for converting and systems for practically everything else

gritty jacinth
rose kettle
#

And as for the monos being the old versions of ISystem (or SystemBase), kinda. Systems do have similar lifecycle to monobehaviors

gritty jacinth
#

What is the difference between Prefab, Baking, Authoring?
Sorry if these are ambigious questions, but I am just trying to understand the relationship between these and what they are used for.
I am familiar with ECS, but Unity seems to have other stuff as baggage, and those parts I don't understand.
I am new to Unity, but not multithreaded ECS or game dev in general.

rose kettle
#

Yeah, Unity's implementation of ECS is kinda unique in a way. Basically, an authoring script is a mono script that creates an entity and sets it's values. Prefab is basically a template of an object that describes what kind of components and what values of those components it may have, authoring script is a mono script that implements a bake method, which contains the logic for creating the entity and copying values into it (this is called baking process)

gritty jacinth
#

So prefab is the old style components, and you want to translate those components from a prefab to the new IComponentData and you do that by loading it during a "bake" and manually take each component the prefab has and make your own components?

rose kettle
#

The reason for this kind of workflow is because prefabs are normally used in regular, OOP\Entity-Component Unity, and there isn't really a way to make an entity out of it directly in the editor yet

rose kettle
#

Not the built in, like mesh filters and such, those are automatically converted

#

But for anything custom, you'd do

public override void Bake(CustomComponentAuthoring authoring)
    {
        var entity = GetEntity(TransformUsageFlags.Dynamic);
        AddComponent(entity, new CustomComponent
        {
            SomeValue = authoring.SomeSerializedValue
        });
    }
gritty jacinth
#

Do I get it from the authoring or from the prefab? Your example used authoring.SomeSerializedValue

rose kettle
#

The values?

gritty jacinth
#

Nah the components that are part of the "old ways" inside the prefabs.

#

Maybe I misunderstood, but I was under the impression Prefabs had their own components. that were the "old way".
So when I enter the Bake method I could access those components out of the Prefab to make my own
SomeValue = authoring.ThePrefab.SomeSerializedValue?

rose kettle
rose kettle
#

But that's kinda pointless

#

Unity's components get baked anyway and your authoring script should contain everything you need to make an entity

gritty jacinth
#

Oh ok, I guess I gotta figure out what's automatic and what's manual then

rose kettle
#

Gl. Newer version docs (1.3) actually do make a good job explaining most stuff

gritty jacinth
#

Link?

gritty jacinth
#

This might sound strange, but do the Bakin convert a Prefab into a GameObject before breaking it into into whatever DOTS need (entity and a bunch of components)?
Documentation isn't clear on this.
I know what a Prefab is, it's like a blueprint for how to build the GameObject and all its components, and a GameObject is a runtime instance of the Prefab.
I am assuming Prefabs are still a thing because the concept of a blueprint isn't going to go away, is it straight up baked into a DOTS, or is it made into a GameObject first?

#

Actually it does mention this

When prefab instances are present in the subscene hierarchy, baking treats them as normal GameObjects because they don't have the Prefab or LinkedEntityGroup components.

So I guess the GameObjects are stored straight up and not converted?

gritty jacinth
#

@rose kettle Sorry to bother you, but how can you tell if assets on the store are compatible with DOTS?
And if they aren't, is it possible for you to write the glue code or how does it work?

rose kettle
#

Doubt anyone uses that one though

#

And I guess once you get the asset you can modify the code however you like, including authoring everything and making it into entities

gritty jacinth
#

It's alright, I decided to go back to Rust.
So far I haven't find a single resource on how to start with 2d and DOTS.
The documentations and resources... leaves a lot to be desired.
Going through 20 ads on youtube for a person who claims to do ECS only to just use monobehaviours for everything was also painful.
heh, sorry, very frustrated.

rose kettle
#

API changed a bunch since first release of unity's dots, 90% of tutorials and resources are outdated (or incorrect to begin with), docs don't cover nearly enough

#

Most people around who actually made a product with it stuck around long enough to just learn all the ins and outs of it themselves

#

But it's a huge time investment

gritty jacinth
#

I don't mind the inestment, it's the lack of resources from the team managing that bothers me. Not even proper 2d examples with DOTS, even if it's not fully supported, show me the glue code.

rose kettle
#

Now that I think about it, I haven't seen any good 2D dots samples either

#

There's galaxy sure but it's 3d

#

Last time I checked 2D was barely supported at all

#

Probably changed since 1.0

dark harbor
# gritty jacinth I don't mind the inestment, it's the lack of resources from the team managing th...

there is no 2d specific stuff for entities. you can achieve 2d with a quad and ignoring one axis. there are physics constraints to do this as well. theres not even an official native 3d animation package for entities, so really these things are on you to figure out. you should assume every asset is incompatible or does not really feature entities compatible code unless it specifically mentions it, and tbh there are very few given the vast quantity of assets in the store. if you're new to unity, you might be better off sticking with gameobjects and the sprite system

gritty jacinth
#

I am more familiar with ECS, than GameObject, so I rather use that.
I am not asking for specific 2d stuff, I am asking what the current M.O is to make 2d stuff like tilemaps and pathfinding work with the new DOTS stuff

#

There is zero resources on this.

rose kettle
#

As I said, the time investment is massive

#

Plenty of people in the community who only ever make tools and hardly any projects because of how much is lacking

#

Especially for 2D

dark harbor
#

the current mo is to invent it yourself

#

or use the existing stuff with entities as managed components, but probably simpler to just use gameobjects as such heavy reliance with interop would be more confusing than simply using one or the other

gritty jacinth
#

So I added a Sprite to my scene, how do I associate it with a entity and access it in a system?
Same with the Camera and the Tilemap?
Like where do I read on how to do that?

dark harbor
#

so you can use HYBRID_ENTITIES_CAMERA_CONVERSION to convert a camera automatically if its placed in a subscene

#

in your scripting define symbols in the player settings

#

afaik for tilemap thats up to you and I dont think its supported under the companion system

#

the simplest way to do things would be add a script to your tilemap that on start: creates an entity, adds the tilemap component as a managed component and maybe another component to identify it(not really sure how tilemaps work if you only have one ever or multiple in a scene), and then use a system to control it using those two components to identify it

gritty jacinth
#

You mean the baking process?

dark harbor
#

the only guideline that is kind of accepted as a universal rule from community experience is basically use systems to control your gameobjects, dont do the other way around(gameobjects controlling entities)

gritty jacinth
#

I should bake the tilemap and its various children?

dark harbor
#

I dont have any experience with tilemaps or sprites tbh, so I really dont know what the best workflow for them is. but when I was using mecanim, I had my gameobjects as prefabs to be instantiated by entities, so their lifecycle could be controlled in systems and jobs. Whether you choose to bake the tilemap or do a runtime connection like my previous suggestion, do what feels best because there arent any hard rules to it(other than ideally you control all logic from your entities systems)

#

just the hassle of making glue to work inbetween entities and gameobjects might not be worth it for a first endeavour if you're new to unity because it seems to trip up even experienced unity users and unity is working on a huge project of making entities back gameobjects to (presumably) ease the interop between the two

gritty jacinth
#

Well I wanna learn so I am gonna go with that approach, draw my tilemap and then figure out the baking process of turning the tilemap, and individual tiles into entities.

keen grotto
foggy bison
#

This is called hybrid workflow where you use a GameObject to host the presentation functionality.

foggy bison
rose kettle
foggy bison
#

I don't have enough knowledge on unity ecs and bevy to tell which one is better in general.

rose kettle
#

I only used Bevy briefly and it kinda suffers from the same "very early and a lot of useful things aren't supported yet" thing

#

Notoriously complicated to get a UI working

foggy bison
#

What I mean is it's better choice for them. Given that they are familiar with Rust, maybe familiar with Bevy also (we joined the Bevy Discord so I can see it as a mutual server), and if they only publish on Desktop platform.

rose kettle
#

Yeah I misunderstood

#

But it's true though, if they know bevy already would be kind of a waste of time to learn all the unity-exclusive unity stuff

#

Cause it's a lot of learning

#

Also, I didn't know they officially said they won't support 2D in ECS

#

So insanely lame

foggy bison
rose kettle
#

In retrospect not surprising, they struggled to get ECS working at all

gritty jacinth
gritty jacinth
# foggy bison In my opinion, if you already know how to use Bevy, and won't publish your game ...

I am intertaining the idea of going back to bevy, but as @rose kettle it is missing a whole lot, and the stuff it isn't missing is very unstable. Bevy suffers from the issues other Rust projects do, they move forward trying to remake to most complex things when simple things are missing. Even as we speak they are dealing with Reflection and Making an Editor, when they should be focused on making simple things actually work instead of being broken.

gritty jacinth
#

I mean the whole thing is, you place shit on the editor.
You write some bake code to get it inside an entity, with some of the shit on the scene as part of various components.

Unity has a baking tutorial, but it's incomplete, they really should have like:
Here's a Tilemap, and how to bake it
Here's a Sprite, and how to bake it

dark harbor
#

Baking is just populating your runtime data, to any components you might need. a transform would mean copying position, rotation, scale and any hierarchy related info. If its an animation it means going through and copying the curve data to a format that can be read easily in jobs. A terrain baker might copy the heightmap data into a a buffer or a blob and also create a collider using that data.

If you need specific data from those sprites and tilemaps, well you get to decide exactly how to format that data for your own uses.

gritty jacinth
#

Yeah but I am confused over what I access. Say I used the editor and I added a TileMap. That comes with a grid and a TileMap and I want to bake that into ECS, how would that look?

keen grotto
#

Maybe you could add the Tilemap/Grid to an IComponentData class. Then add that component to an entity. Not sure what purpose this would serve.

#

Get the singleton from a system and perhaps you can call functions from the Tilemap.

#

If this actually works it means you can’t burst compile the main thread.

dark harbor
# gritty jacinth Yeah but I am confused over what I access. Say I used the editor and I added a T...

very simple and quickly put together so dont take this as optimized but more what you can expect to need to do to bake your own data

https://github.com/thelebaron/tilemap_entities_test_example/blob/main/Assets/MapTileAuthoring.cs
https://github.com/thelebaron/tilemap_entities_test_example/blob/main/Assets/TileBakingSystem.cs

GitHub

Contribute to thelebaron/tilemap_entities_test_example development by creating an account on GitHub.

GitHub

Contribute to thelebaron/tilemap_entities_test_example development by creating an account on GitHub.

rugged veldt
#

nobody is actively working on 2d dots anything right this second to my knowledge, but i just suspect something in that department may end up happening under new management at some point

foggy bison
rugged veldt