#archived-dots

1 messages ยท Page 1 of 1 (latest)

rustic rain
#

How to disable creation of default World?

frosty siren
errant hawk
#

I created a new project with unity 2022.2b1 and almost all the entites packages have some sort of exception being thrown

#

I created a new project in 2022.2a17 and didnt have this issue at all

#

what changed?

rustic rain
#

@rotund token do you happen to know this error might be related to?
This is me trying to load external assembly with IJobEntityBatch system

#
    public partial class ModSystem : SystemBase
    {
        private EntityQuery _query;


        protected override void OnCreate()
        {
            _query = GetEntityQuery(ComponentType.ReadOnly<RotatingCube>(), ComponentType.ReadWrite<Rotation>());
        }

        protected override void OnUpdate()
        {
            Dependency = new RotateJob
            {
                rotHandle = GetComponentTypeHandle<Rotation>(),
                rcHandle = GetComponentTypeHandle<RotatingCube>(),
                delta = Time.DeltaTime
            }.ScheduleParallel(_query, Dependency);
        }

        private struct RotateJob : IJobEntityBatch
        {
            public ComponentTypeHandle<Rotation> rotHandle;
            [ReadOnly] public ComponentTypeHandle<RotatingCube> rcHandle;
            public float delta;

            public void Execute(ArchetypeChunk batchInChunk, int batchIndex)
            {
                var rotations = batchInChunk.GetNativeArray(rotHandle);
                var rcs = batchInChunk.GetNativeArray(rcHandle);
                for (int i = 0; i < rotations.Length; i++)
                {
                    var rc = rcs[i];
                    var rot = rotations[i];
                    rot.Value = math.mul(rot.Value, quaternion.RotateX(rc.speed * delta));
                    rotations[i] = rot;
                }
            }
        }
    }
rustic rain
#

I guess it's related to burst not being loaded

#

welp, judging by official burst docs

#

I literally have no other way

#

but enforce modders to use Editor to build mods

#

kek

viral sonnet
#

what were you plans then when it wasn't the editor?

rustic rain
#

aaaand JIT compilation, kek

rotund token
#

did you tell burst to load the new dll

#

(sounds like you might have realised this)

rustic rain
#

currently I am having trouble to even build mod dll

#

importing Assembly-CSharp

#

causes errors

#

not sure if that's the case though

#

Soooo, Burst manual has this script for building mod

    public static void BuildGame()
    {
        string modName = "TestMod";

        string projectFolder = Path.Combine(Application.dataPath, "..");
        string buildFolder = Path.Combine(projectFolder, "PluginTemp");

        // Get filename.
        string path = EditorUtility.SaveFolderPanel("Choose Final Mod Location", "", "");

        FileUtil.DeleteFileOrDirectory(buildFolder);
        Directory.CreateDirectory(buildFolder);

        // Build player.
        var report = BuildPipeline.BuildPlayer(new[] { "Assets/Scenes/SampleScene.unity" }, Path.Combine(buildFolder, $"{modName}.exe"), BuildTarget.StandaloneWindows64, BuildOptions.Development);

        if (report.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
        {
            // Copy Managed library
            var managedDest = Path.Combine(path, $"{modName}_Managed.dll");
            var managedSrc = Path.Combine(buildFolder, $"{modName}_Data/Managed/{modName}_Managed.dll");
            FileUtil.DeleteFileOrDirectory(managedDest);
            if (!File.Exists(managedDest))  // Managed side not unloaded
                FileUtil.CopyFileOrDirectory(managedSrc, managedDest);
            else
                Debug.LogWarning($"Couldn't update manged dll, {managedDest} is it currently in use?");

            // Copy Burst library
            var burstedDest = Path.Combine(path, $"{modName}_win_x86_64.dll");
            var burstedSrc = Path.Combine(buildFolder, $"{modName}_Data/Plugins/x86_64/lib_burst_generated.dll");
            FileUtil.DeleteFileOrDirectory(burstedDest);
            if (!File.Exists(burstedDest))
                FileUtil.CopyFileOrDirectory(burstedSrc, burstedDest);
            else
                Debug.LogWarning($"Couldn't update bursted dll, {burstedDest} is it currently in use?");
        }
    }
#

but I'm confused

#

_Managed.dll

#

where is it even supposed to be

rustic rain
#

huh

#

It works

#

For some reason Manual has some very weird path errors xD

#

but mod works

#

loaded assembly

#

which even loaded all systems normally

#

one system*

#

so, now I need to test Harmony patching

#

of bursted code

rustic rain
#

welp

#

sadly doesn't work

rustic rain
#

hold oooon

#

looks like it works

#

kek

rotund token
#

Well this is a roller-coaster

rustic rain
#

hehehe

#

and patch indeed works

#

also what is most fun - I can test it as modder right from editor

rotund token
#

Confirmed its executing as burst?

rustic rain
#

hmmm

#

I do have tick "Burst compilation"

#

not sure how to actually check

rotund token
#

Just hook up a profiler

rustic rain
#

whether it's bursted

rotund token
#

Or add a conditional pass with burst discard that debugs something different in burst or mono

rustic rain
#

oh well, looks like burst gets discarded

rotund token
#

Did you pass the dll to the burst method that it requires

rustic rain
#
    [HarmonyPatch("RotateCubeSystem_LambdaJob_0_Job", "OriginalLambdaBody")]
    public static class PatchRotatingSystem
    {
        public static void Postfix(float ___delta, ref Rotation rot, in RotatingCube rc)
        {
            rot.Value = math.mul(rot.Value, quaternion.RotateZ(-rc.speed * ___delta));
        }
    }
rustic rain
#

but

#

oh wait

#

maybe I should apply [BurstCompile] to patch

#

nah, didn't help

rotund token
#

I'm not sure why that would patch the burst job instead of the mono

#

i'm not super familiar with harmony but from what i understand it patches .net methods at runtime

#

but you need to precompile burst

rustic rain
#
    [HarmonyPatch("RotateCubeSystem_LambdaJob_0_Job", "OriginalLambdaBody")]
    [BurstCompile]
    public static class PatchRotatingSystem
    {
        [BurstCompile]
        public static void Postfix(float ___delta, ref Rotation rot, in RotatingCube rc)
        {
            rot.Value = math.mul(rot.Value, quaternion.RotateZ(-rc.speed * ___delta));
        }
    }

I tried this

#

I assume it compiles that method for jobs, right?

rotund token
#

you can't pass structs into function pointers in burst

#

hmm

#

harmony does not support patching native methods

#

so i just don't see how this would ever work?

rustic rain
#

fully recompile job?

#

is it possible in runtime?

rotund token
#

no

rustic rain
#

aren't generic jobs work like this?

rotund token
#

you have to register all generic jobs in advanced

#

this is the whole restriction behind generics and burst

rustic rain
#

ah

#

hmmm

rotund token
#

not sure how much that helps you though

rustic rain
#

I guess

#

Unity just needs to add support for recompilation

rotund token
#

i always imagined modding with entities/burst to simply be writing your own new burst jobs, using write groups to override existing behaviour and loading them with BurstRuntime.LoadAdditionalLibrary(burstedAssembly)

rustic rain
#

certainly it's an option, but mostly ppl just want to modify some existing behaviour

#

so that everyone else who relies on this behaviour

#

can keep on relying on it

rotund token
#

i don't see why overriding existing behaviour with write groups would be any different for other users

rustic rain
#

ECS kind of makes it better though

#

since it's all just data

#

so it makes no different what modified it

rustic rain
#

there's Just no tag on job, since I'd never even think someone would want to override it

#

but here we go

rotund token
#

that seems to be up to the developer, i.e. you, to decide ๐Ÿ˜„

rustic rain
#

well yeah, but in normal mono Harmony brutforced it

#

so you could patch literally anything

rotund token
#

This city deserves a better class of modder

#

anyway this is all just a vision from me, i don't think of it as modding more collaborative development

rustic rain
rotund token
#

I'm a man of the people

#

If that's what the people want, that's what the people get

rustic rain
#

that's why Unity needs to make runtime recompilation possible

#

maybe just make some static method to manually call it

rotund token
#

i can't see burst being used outside the editor anytime soon

#

or ever

#

big difference between aot and jit code

rustic rain
#

oooooh

#

hold on

#

I have to check one thing first

#

nnnah

#

that didn't work

rotund token
#

recompile your game with il2cpp and then use harmony

#

does that work?

rustic rain
#

I'd need a little bit of research before I can test

#

and that would be delayed till tomorrow

rotund token
#

it was kind of a rhetorical question

#

as far as i'm aware you need something like BepInEx

balmy thistle
#

Does Harmony work with il2cpp? It sounds like it needs access to the IL

rotund token
#

it doesn't as far as i'm aware, it's an IL patcher

balmy thistle
#

Yeah I'd be surprised

devout prairie
#

so i'm just thinking out loud here..

#

is there much of a difference between say passing in ComponentDataFromEntity<LocalToWorld>, as an example

#

compared to first firing a job that iterates the LTW's and fills an array with the values, and passing that in

harsh quiver
#

For simple wildcard queries all the ECS has to do is "find all tables with (Effect, *)" which is an O(1) operation, and then it can just iterate the list

rustic rain
#

Does it mean you need to know relationship during compile time

#

Or are queries can be generalized somehow?

harsh quiver
#

When a component (or relationship) is first added to an entity, an index is created for it that stores all tables for that component

rustic rain
#

But how so you query through relationship?

#

Do you just create a loop of

#

Uugh

#

For example

#

Likes With Entity as value argument?

harsh quiver
#

I can then add that component id (which is actually a relationship pair) to an entity

rustic rain
#

Basically uugh

#

Relationship<T0,T1>

harsh quiver
#

Yep that's right ๐Ÿ™‚ The ECS storage doesn't really need to know about relationships, it just works with ids. You could emulate that part with generics (or templates in C++)

rustic rain
#

I can definitely see the benefits of using it

#

Wonder though whether this can already be implemented

#

In unity ECS

harsh quiver
#

Things get a bit, but not much, more complex with queries. I want to be able to query for (Likes, *), even though I never add (Likes, *) to an entity. Another thing outside of the storage that is a bit harder is cleanup: if you delete a parent entity, you want to delete all entities with a (ChildOf, parent) relationship

rustic rain
#

I remember seeing smth about generic component

#

Gotta read about it

#

But you said it's tag

#

Meanwhile Parent is actually value

#

Unless it's some hardcoded singleton

harsh quiver
#

Right, so, both ids that are encoded in a pair are actually entity ids

#

Components, relationships, parents, normal entities, all have entity ids

#

Entity ids are always runtime, which is why I can add (ChildOf, parent) to an entity

rustic rain
#

Well this one sounds like a trouble already

#

Although

#

Maybe it can look like

harsh quiver
#

It lets you do lots of cool stuff. Like, what if you could add a Serializable tag to your component, so you could query all entities with serializable components

rustic rain
#

Relationship<Likes, Entity> after all

#

Meaning it would be not just pair

#

But a tag + struct

#

So total size of such component is 8 bytes

#

I even feel like if generic components is a thing it actually might work, kek

harsh quiver
rustic rain
#

Oh well

#

Seems like this one is fully supported

harsh quiver
#

Relationships can also contain data:

e.set<Position, Begin>({0, 0});
e.set<Position, End>({10, 20});
rustic rain
#

But

#

It kind of inlines it all to basic struct

#

So in the end

#

You can't add multiple of( likes, entity) pair

harsh quiver
rustic rain
#

I mean in Unity ECS

harsh quiver
#

Ahh right. Yeah before relationships I had the same problem

rustic rain
#

Well, currently

#

This all can be solved through dynamic buffer component

#

Just call it

#

Likes

harsh quiver
rustic rain
#

As a wrapper of entity

harsh quiver
#

Say I want to find all entities with (Eats, Apples). I'd have to iterate all entities with (Eats, *)

rustic rain
#

I honestly just don't see how indexing of actual entity would work in unity

#

Since from what I understand

#

Types are resolved only once

#

Not dynamically

#

And if you actually remember type as id

#

So entity is removed

#

And now type id is corrupt

harsh quiver
rustic rain
#

Or...

#

Since unity ecs using pair of ints

#

Index and Version

#

Maybe this will just keep creating new ids

#

But I don't see how quering it would be fast

#

Since you'd need to get new query every time

#

As each new component id creates new archetype

#

Smth for Unity to crack I guess

harsh quiver
#

Hah yes ๐Ÿ˜‹ You're exactly listing the problems one by one that need to be solved

#

They can be solved though

rustic rain
#

Tbh

harsh quiver
rustic rain
#

There is already similar filtering

#

With shared components

#

You can filter by value

#

But shared components are always considered managed

#

And they create way too many double archetypes for their implementation

harsh quiver
#

in my implementation shared components are implemented through relationships, they kind of sit at the same (archetype) level

rustic rain
#

But that makes filtering way slower

#

It'll have to check per entity

#

Meanwhile current implementation checks by chunk

harsh quiver
harsh quiver
#

they're similar to components, like:

entity Likes = world.entity();
entity Bob = world.entity();
entity Alice = world.entity();

Bob.set<Position>({10, 20}); // bob is in archetype [Position]
Bob.add(Likes, Alice);       // bob is in archetype [Position, (Likes, Alice)]
rustic rain
#

Yeah, I get that part

#

Value is transformed into type id

#

Exactly how shared components work

#

And actually

#

They say they work on unmanaged version of shared component

#

So maybe it would it

rustic rain
#

All right, my fun with Harmony patching continues

#

turns out last time I checked I forgot to import bursted library

#

kek

#

into mod project

rustic rain
#

Welp

#

turns out

#

you still can't patch bursted methods

#

you end up with only unbursted part being patched

#

so... it works when you disable burst

#

but not when it's on

#

that is a very sad constraint

viral sonnet
#

@harsh quiver How are the relationships modeled in memory then? This all sounds nice to me but I'm also expecting a lot of iterations on fragmented memory with lots of random access.

harsh quiver
#

So in theory relationships are just as fast/slow as working with regular components.

#

The caveat is that relationship pairs can contain regular entities, of which there can be a lot. An application that's a heavy user of relationships will see increased archetype fragmentation

#

There are a couple of ways to deal with that, some framework side some application side:

  • make your archetype creation fast and overhead low (some flecs apps run with 50-500k archetypes)
  • use features that reduce fragmentation, like component enabling/disabling (bitset based, I believe dots has a similar feature)
  • use non-fragmenting relationships (a special kind of relationship that does not fragment but is slower to iterate)
#

A big storage upgrade I've been working on separates tables from archetypes, where a table only stores components, archetypes store the id lists for components & tags, and multiple archetypes can index into the same table.

#

You still get archetype fragmentation, but tables (where it matters most, since they store the data) don't get fragmented by tags

#

That way you can have your cake and eat it too: pure component queries can iterate big unfragmented chunks of memory, while query for tags/relationship pairs eat a slight indexing overhead

#

(sorry for the wall of text, it's a simple question with a complex answer :p)

viral sonnet
#

don't be sorry, i appreciate it ๐Ÿ™‚

#

the most basic problem I have in ECS is a target relationship. entity can have another entity as target. both entities have a position, get the distance of these targets. highly random memory access job to calculate that data.

#

worst of all, no simd

rustic rain
#

all will be lined up good for cache

harsh quiver
#

Right, so this is a common use case: have a Transform system (or similar) use a Position component from the entity itself as well as from its parent. Here the fragmenting relationship behavior is actually desirable, since all children for a parent pare packed in the same table. This means you can reuse the same parent's Position component for the entire table, which means you can do SIMD again

#

It's not perfect, you can have a degenerate case with lots of parents and tiny child tables

#

But even if you only have a handful of entities in a table, it'll perform slightly better than 100% random access

#

Something else you can leverage here is that because you're likely iterating cached query results (I'm assuming dots does this), you can sort cached tables breadth-first based on the scene graph, which ensures parent Position components are processed before children. The sorting of tables is almost free

viral sonnet
#

hm, i fail to see the similarity between parent/child. a target can change and the target position can change. otherwise it would be possible to cache or duplicate the data for better access patterns

viral sonnet
harsh quiver
viral sonnet
#

yeah entities doesn't have that ๐Ÿ˜„ afaik it doesn't even have caching in that sense

harsh quiver
#

Say you have a table with ids [Position, (ChildOf, some_parent)]. If you want to transform all entities in that table, you only need to fetch the parent's Position once

#

Oh really? That'd surprise me

#

Cached queries make a lot of sense for an archetype based ECS, even more so if you don't have relationships which means the list of archetypes is very stable

viral sonnet
#

some time ago i tested effect entities and to my surprise having lots of entities slowed down the whole system. tertle then told me entities has to evaluate every archetype and chunk for the queries. so pretty sure, no caching, otherwise this wouldn't happen i think

#

so just creating like 10mil entities in 1 archetype slowed down every system. even though no system worked on the 10 mil entities

harsh quiver
#

that's weird, trying to think of anything that could cause that

viral sonnet
#

yep, i was pretty perplexed too. didn't think this would happen

harsh quiver
#

even if queries aren't cached, a system query doesn't have to look at individual entities, it just needs to match archetypes

viral sonnet
#

maybe it's memory fragmentation. like relevant chunk A/B/C, lots of D chunks that don't do anything and then relevant chunks E/F/G

#

afaik it also checks chunks (for whatever reason)

harsh quiver
#

maybe the job system gets flooded with a job per chunk

#

idk, don't know dots that well

#

in any case, that doesn't happen in my code, so the relationship stuff doesn't suffer from it :p

#

in a small set of use cases relationships can improve cache efficiency as it lets you build instancing-like behavior on the CPU

#

e.g. loading a single shared component inherited from a prefab puts a lot less pressure on the CPU cache than having to load a private copy for each iterated entity

#

I heavily rely on that in this project https://flecs.dev/city where most of the component data is shared across prefabs

#

(not as impressive as the unity megacity demo :p but you gotta start somewhere as a solo dev)

rustic rain
#

hmmm

#

what I figured

#

in case you need some entity-entity relationship with random access

viral sonnet
#

pretty cool stuff. what code language is most of this city demo? flecs itself is c++ and i see all this browser stuff ๐Ÿ™‚

rustic rain
#

ah, nvm

viral sonnet
#

btw. can i access this dashboard for the city demo?

harsh quiver
harsh quiver
#

at some point I'll figure out how to run both in the same browser tab, but not there yet

viral sonnet
#

how do you fragment your tables? same as entities with 16k chunks?

harsh quiver
#

It wouldn't scale for me, I need to be able to support hundreds of thousands of tables. If each table is at least the size of one chunk, that'd blow up in memory very quickly

viral sonnet
#

oh so how do you handle adding/removing to those tables?

harsh quiver
#

Each component vector is a separate array. When I move an entity out of a table, I iterate each vector, and move the last element into the entity's old spot

#

Table insertion is a simple append to each vector

viral sonnet
#

so having a million entities would involve a memcpy when the vector capacity exceeds?

harsh quiver
#

Yep, that's the tradeoff

#

I've been working on a pluggable storage prototype where you could do something custom for extreme cases like these (even use chunks if you wanted to)

#

but that's still a few months out

#

it could make sense to use chunked storages for large tables, and regular storages for small ones

viral sonnet
#

i see, yeah when its modular enough i dont see much downsides. for low entity amounts its even preferred

#

the lack of modularity sucks in entities.

harsh quiver
#

having a single table with 1m entities is rare though :p I'm already happy if I see a table with a few thousand entities

harsh quiver
viral sonnet
#

haha, tertle and me do that all the time. he's now up to 100mil test cases

harsh quiver
#

oh yeah, it's not hard to create a table with 1 million entities, but I haven't seen it yet in actual applications heh

viral sonnet
#

(not that these are realistic in game scenarios) we just have fun with it

harsh quiver
#

as soon as I start writing ECS code I stop caring about fragmentation and I'm adding/removing components left and right ๐Ÿ™ƒ

viral sonnet
#

with your approach adding/removing comps doesn't change archetypes right? afaik they are decoupled in flecs

harsh quiver
#

in the new table vs. archetype design adding/removing comps would change archetype, but not table

#

I'm still working on it though, so by default adding/removing does change tables

viral sonnet
#

because one of the big issues in entities is removing a comp needs a memcpy of all entity data in that archetype

#

which is a big performance problem

harsh quiver
#

Hm really? it's not like I haven't seen this be an issue, but it doesn't come up a lot. It can become a problem for big components, or components that are complex to move

#

Though yeah if you're generating add/remove's for 1m entities each frame that would definitely bring everything down to a crawl

viral sonnet
#

wouldn't even need that much. adding something like an event comp on 250k is already a huge spike

harsh quiver
#

Part of the new storage design I'm working on is to allow for storages that can be indexed by "table index" (the row of the entity in the table) and entity id. The latter would make it possible to have a single storage per world per type, which you wouldn't have to move when an entity changes archetype

harsh quiver
#

that's the only way I could make that work performantly in flecs I think

viral sonnet
#

it does. remove is quite fast obviously. adding can also have the, too much data in a single frame problem

#

allocating so much data is just a general problem

harsh quiver
#

in the best case you add a component to all entities in a table (or matching a query), and the target tables are empty

#

in that case you can just move the comp arrays (or chunks in the case of dots)

#

something I've also been toying with is the idea to keep track of destination archetype while enqueueing commands

#

that way if you have 10 commands enqueued for the same entity, you'd first move it to the right archetype, then apply the commands

#

vs. having to do 10 archetype moves

viral sonnet
#

sounds like a good way to handle it

harsh quiver
#

lots of ideas, very little time :p

devout prairie
#

has FLECS been tried with unity, sounds really interesting

harsh quiver
#

there's a C# binding in development, though I don't think it's quite ready yet

#

somebody also just posted a project today that reads in a Unity scene file and converts it to a flecs scene prefabs and all, which was .. surprising

devout prairie
#

haha nice

#

do you have a render engine for it?

#

i'm guessing a no for that ๐Ÿ˜›

harsh quiver
#

Surprisingly yes #729773810953355355 message but don't quote me on how usable it is, I think it's still very early days. I believe it is using the Forge

devout prairie
#

interesting to hear a different approach to ecs though.. i remember reading the DOD book that unity shared way back, some guy discussing in detail the benefits of DOD and ECS, and how it can be thought of in terms of a database access kindof mechanic.. was really eye opening actually and laid out the case for DOD/ECS really well

devout prairie
#

dm me an invite if it is ๐Ÿ™‚

harsh quiver
#

I did build a toy renderer which is used by this https://flecs.dev/city and a few other demo projects, but my render coding skills are nothing short of unimpressive :p I'm hoping someone more qualified will some day pick up the renderer and turn it into something decent heh

#

DM'd

harsh quiver
#

I spent three weeks trying to get the ssao to work and it's still glitchy as hell

devout prairie
#

that was the first thing i noticed, it has AO!

#

and bloom

harsh quiver
#

bloom is not that hard, just blur & combine

#

the ssao is let's say "finely tuned" for this scene :p don't try it for anything else

devout prairie
#

how about physics? that natural progression i guess is a full pipeline with maybe a c++ api or something right

#

even just bolting together some existing solutions i guess, if they're fast and modular etc

harsh quiver
#

Yeah, I've made some attempts at that but they're kind of at the same level of the renderer heh. I'm trying to develop a bunch of modules (these ones https://github.com/SanderMertens/flecs#flecs-hub) that when combined can be used as an engine

#

That's still waay far off though, I'm happy if it'll ever be sufficient for a gamejam

#

The physics module has some basic features, like it can populate an octree from ECS data

#

No rigidbody physics or anything close to it

devout prairie
#

really cool stuff ๐Ÿ™‚

harsh quiver
#

it's okay, I'm having fun with it ^^ more than anything I'm trying things out that I'd like to see in a game engine but not sure if they're possible

#

like single-line imports of ECS modules. It should be possible to make a 3D app headless by un-importing the renderer module

#

lot of interesting problems around how you order systems imported from different modules (I've seen some dots features like system groups for this, pretty cool)

#

another moonshot idea I'm trying out is if I can build a renderer that uses ECS queries to batch entities for different render pipelines

#

like, the render pass for solid objects matches entities with Rgb, the render pass for transparent objects matches entities with Rgba

devout prairie
#

ahh interesting

#

i was just looking at the Forge, i hadn't seen that before, so it's using Flecs as it's built in ECS implementation

harsh quiver
#

yup yup ^^ not sure how many people actually use it though :p the Forge is more of a toolkit where you use what you want

#

still cool they took the effort to integrate it

devout prairie
#

yeah definitely, it's great to see independent toolsets being developed that in fact are competitive with top level products

#

Blender probably being the greatest of all examples of that in many ways

harsh quiver
#

blender is awesome (though I'm Dutch so definitely biased)

devout prairie
#

hehe, ton roosondal is like the prophet i think

harsh quiver
#

haha he is :p

#

Those new geometry nodes look awesome.. I wish I could do something like that in ECS. Like a node-based approach to generating an ECS scene graph

devout prairie
#

regards dod/ecs, i genuinely think it's going to be a game changer over the next ten years, largely due to how much more efficient it is, compared to how wasteful the 'traditional' oop approach so often is, in terms of energy/resource utilization etc.. we're moving into a world of carbon credits and energy i think is going to be increasingly precious.. if you have a platform that users can use that is reliable and can produce applications that cater to that level of efficiency etc, i think you'll be ready for the new world

rustic rain
#

ten years?

#

it's already a game changer

devout prairie
#

ok two weeks

rustic rain
#

utilizing all cores

#

who else does it, kek

devout prairie
#

absolutely, it is

#

but i believe it's basically going to be a requirement, pretty soon

#

the old world of oop will soon be gone ๐Ÿ˜›

#

i think maybe a world with the best of both.. the benefits of an oop layer over an ecs foundation

harsh quiver
#

Just not having to deal with fixed type hierarches that put in stone what an object can and can't have is liberating

devout prairie
#

yeahp, and ridiculous layers of inheritance etc

#

just data and transforms

harsh quiver
#

usability is still a bit of a problem though

#

ECS libraries need to get their * together when it comes to behavior that only matches single entities

#

I'm also hearing from a lot of folks that not having native language support for it can be a barrier

rustic rain
devout prairie
#

ah right yeh

harsh quiver
# devout prairie how do you mean?

Like what if you have a system that only matches a specific boss in your game. It's totally possible with todays libraries, but gosh I have to write a system with an interface that's clearly optimized for iterating multiple entities, need to make sure I'm matching all the right components, probably need to introduce a tag specific to that boss so I don't accidentally match the wrong thing

#

Vs. here's a class with an update() method, go

#

There's sometimes this sense that if you use inheritance or have a system that's coupled to an entity the ECS code isn't pure enough

#

which leads to people pretending that a MeleeUnit isn't a subclass of Unit (it is) or that the DragonAttackBehavior system isn't tightly coupled with the dragon boss at level 2 (it is)

devout prairie
#

right yeh that makes sense

harsh quiver
#

(also, I only know a handful of ECS libraries, so maybe dots has better solutions for this that I'm not aware of)

viral sonnet
#

it's time for cpu creators to utilize the logic of ecs on a hardware level ๐Ÿ˜„

devout prairie
#

i have to say i have a liiiitle bit of trepidation when i think about what unity is doing and look back to the end times of flash..

#

i think unity are still kindof keeping one foot in the old world and one foot in the new, which was kinda what killed flash really

viral sonnet
#

deprecation of the npapi killed flash

devout prairie
#

actionscript started leveraging more low level access, there were even tools to write super fast native c code and leverage it etc

#

but ultimately, the html5 revolution just left it behind

rustic rain
#

Do you guys know whether it's possible to build separate Burst library for each built assembly in project?

devout prairie
#

interesting that just the battery life consideration was a big factor, and that was then.. even more important now

rustic rain
#

basically so that Player's burst lib and actual project's burst lib are separate

rotund token
#

I'm not sure if you can split it per assembly, though the editor actually splits every job into its own dll

#

But you can load more than 1 burst dll at runtime

rustic rain
#

it's only required for mod project

rustic rain
#

but it resulted in tons of exceptions

#

lemme boot it and show

#
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
        public static void Load()
        {
            var path = Path.Combine(Application.dataPath, "Reference/UnityECSModTestBurst.dll");
            Debug.Log(path);
            if (File.Exists(path))
            {
                BurstRuntime.LoadAdditionalLibrary(path);
                Debug.Log("Loaded reference burst");
            }
            else
            {
                Debug.LogError("Didn't load reference burst, file doesn't exist");
            }
        }

here how I load it

#

and here what I get ๐Ÿ‘ด

#

xD

#

here first errors

#

what I assume: original project's build compiled it all into 1 library

#

and now it is having trouble Editor's player burst libraries

errant hawk
#

which unity editor version works with entities 0.51-preview32? I can't seem to add the entities package anymore without errors

errant hawk
solar spire
#

What version are you using then?

errant hawk
#

as that seems to be the majority of conflics

#

at this time, using 2022.2.a17

#

I tried the beta, but it was worse

solar spire
#

You have to either be on a 2020.3 or 2021.3 version

#

(above the mentioned ones)

errant hawk
#

I also tried 2021.3, 2022.1.8, and 2022.2b1 with similar issues regarding packages. Neither seems to allow for the correct package anymore

rustic rain
#

I use this

#

but it has some weird bug with android builder

errant hawk
# rustic rain 2021.3.4+ works

I cant import without the console screaming at me saying there's 50+ ambiguous references... importing the correct package has not even allowed me to change the version number because entities requires a newer package than the one described on their docs

#

I also have tried 2021.3.6f1 with the same results

#

last week I created a project and imported everything entities related without issue in 2022.2.a17.... but now I cant

rustic rain
#

so

#

can you just try create new project?

errant hawk
#

this is a new project

#

brand new

rustic rain
#

and how exactly

errant hawk
#

first thing added is entites

rustic rain
#

are you installing DOTS packages

errant hawk
#

com.unity.entites

rustic rain
#

through package manager or manifest?

errant hawk
#

package manager

rustic rain
#

try manifest

#
    "com.unity.burst": "1.7.3",
    "com.unity.rendering.hybrid" : "0.51.0-preview.32",
#

you can add these 2 lines

#

and you'll get all dependencies resolved

#

for you

#

this will give you all required ECS + Jobs + Burst packages

#

without Physics though

errant hawk
#

what version of collections and mathematics are you using?

rustic rain
#

idk

#

they are resolved for me

#

and I haven't had any need in other version

errant hawk
rustic rain
errant hawk
#

Some of the version numbers are not even correct because the package manager shows a different version

rustic rain
#

you probably have some of them wrong

#

remove all dots related packages

#

but those 2 sent

errant hawk
#

im just going to create a new project and send that manifest

rustic rain
#

sir

#

just create new project

#

and add to manifest those 2 lines I sent you

#

this will give you all you need for Dots

#

when you create project

#

pick URP/HDRP template

solar spire
#

I imagine the problem is using that version of Collections

errant hawk
#

I tried manually setting the version afterwards using the package manager with no success

#

@rustic rain here's the manifest I got when creating a new project in 2021.3.6f1 (the one you use)

rustic rain
#

don't even touch package manager

errant hawk
#

ok that worked

#

how

#

something must be messed up with the package manager

#

it's weird, because all the packages relating to burst/mathematics/collections/entities is the same version on the other projects that have issues

rustic rain
#

package manager doesn't work with them

errant hawk
#

well that's wack

rustic rain
#

it is

#

no idea why they made it the way it is

#

older version worked fine with preview packages

rustic rain
#

hmm

#

Is there a way to figure out whether burst is working in build?

errant hawk
#

Debug.Log works inside Burstified jobs

rustic rain
#

ah yes, Burst Discard

#

welp

#

looks like JIT burst

#

doesn't work

#

That is sad

errant hawk
#

AOT is what burst uses in builds, and JIT in editor afaik

rustic rain
#

yeah, but if you import dll of build into editor

#

JIT won't work either

#

and that is a problem for modding

#

I am trying to solve

errant hawk
#

huh yeah that is an issue

#

Try the Synchronous Compilation setting under the Jobs tab. No idea if that will change anything for builds tho

#

Also, instead of using compiled mods, you could try hot-loading source code instead

rustic rain
#

oof

#

I wouldn't want to make game open source this way

#

besides

#

sharing source code this way would be even more pain

errant hawk
#

you would not need to opensource you game. Just an API wrapper that interfaces with the mods and your game

rustic rain
#

ahem, hot loading source code is not supported at all

#

for burst

#

kek

#

besides

#

that's not the problem

#

final game that loads mod does work with burst (I think)

#

the problem is related to smth else

#

it's mod project

#

once you loaded assembly of game build

#

nothing of burst works in editor for mod project

#

meaning big scaled projects will be impossible to run in editor

#

for modders

rustic rain
#

yeah, that's what I used in the first place

#

allthough it has errors, kek

errant hawk
#

what kind of errors?

rustic rain
#

naming pattern is wrong

#

there is no _Managed suffix

#

on built dll

errant hawk
#

the names assigned when using the PluginManager script are arbitrary

rustic rain
#

assembly names aren't

errant hawk
rustic rain
#

yeah, and for some reason they thought that it would have _Managed suffix

errant hawk
rustic rain
#

nothing wrong with that

#

it's editor part

#

not build

errant hawk
#

Then change how the editor script reads names to the compiled .dlls

rustic rain
#

sir, I did it long time ago
Once again, it's Modder's experience that is my concern

#

because as modder you can't get bursted game assembly

#

thus if you try to test some mechanic that relies on existing one which potentially is heavy

#

you'll end up testing in 0.1fps conditions

#

Just checked

#

mod assembly loaded by game works fine

#

burst loads correctly

rustic rain
#

here's crash stacktrace

rustic rain
#

also nvm, burst does not load correctly

#

hmmm

#

how would you structure prefab database?

#

the way so you can easily query over them by string, change them however you want and etc

#

also very important - the way so you can collect them

viral sonnet
#

a hashmap? ๐Ÿ™‚

rustic rain
#

well yeah, that's obvious

#

but I'm confused over how to manage it

#

I need to keep link to prefab in instantiated entities

#

so they can be later saved and restored by that prefab reference

#

I'm considering shared component

#

so memory overhead is 0

rotund token
#

i use weak references

#

similar system that the dots shooter used to manage it's prefabs

rustic rain
rotund token
rustic rain
#

I can't and probably should not rely on IDs

#

what I would like to use is string (fixed)

#

because that's the best way to keep unique reference between game, modders and etc

#

at least I think so

rotund token
#

not sure how having you users choose strings, "monster", is going to be more unique than guids

rustic rain
#

in code

rotund token
#

so? make them call your method to get an id

rustic rain
#

and pass what in for it?

rotund token
#

nothing

rustic rain
#

how would I know then what prefab to give to them

#

my point is:
modder creates some prefabs that get instantiated into world as prefabs and then saved in database

Then in some trigger event or smth he wants that prefab to be instantiated and do smth with it
what would be a way to get that reference?

rotund token
#

from the guid he was given

rustic rain
#

and what does he pass as argument to get that guid

#

prefab is instantiated outside of his control

rotund token
#

var id = GetUniqueID();
DataBase.RegisterPrefab(id, myprefab);

user does what the fuck they like

rustic rain
#

it's just written into world

#

that's the point

#

there is no prefab for user

#

he is not the one writing to database

rotund token
#

so the prefabs already exist?

rustic rain
#

yes

rotund token
#

then i dont see the problem at all

#

i thought the problem was you wanted modders to be able to add prefabs

rustic rain
#

but how would you get a reference to that prefab?

#

if it's written behind IDs

rotund token
#

var prefab = DataBase.GetPrefab(id);

rustic rain
#

there is no way to know beforehand

#

what id is it

rotund token
#

whatever id they want

#

if u use 33 in minecraft i'll get a piston

rustic rain
#

they don't know id

rotund token
rustic rain
#

that's why I want to have string/prefab

rotund token
#

how is string any more useful than an ID

#

they dont know the string ^_^'

#

string is just an id

rustic rain
#

because I still don't see how user would get an ID of prefab

#

because as for string

#

user will manually write it

rotund token
#

your string is ID

rustic rain
#

yes

rotund token
#

they can manually write an int the same way they can manually write a string

#

do they not have numbers on their keyboards

rustic rain
#

but there are supposed to be many modders

#

so the odds they pick same numbers

#

welp, kind of high

rotund token
#

dude just literally said the prefab already exists

#

so you've set these ids up

rustic rain
#

well, the best I see is just keep another hash

#

for string/id

#

but that's just extra step

rotund token
rotund token
#

these are contradictory

rustic rain
#

Modder is supposed to be able to create prefabs, even without assembly

rotund token
rustic rain
#

so game loads those prefabs and uses them automatically (or not)

rotund token
rustic rain
#

but modder does not have any reference to that prefab

rotund token
#

i just went through this with you
i was providing a solution to have users create prefabs

#

then you said, users are not creating prefabs

#

they already exist

rustic rain
#

Modder creates prefabs and serializes them so then game loads them

#

but he is not meant to have control over loading process

rotund token
#

thats all you need

#

i don't get it

#

you just need a way for a user to register a unique id to a prefab

rustic rain
#

string

rotund token
#

a string is an id

#

i dont care if your id is a string, int, long, texture, or biometrics

#

id does not mean int

rustic rain
#

I kind of assumed it is, kek

rotund token
#

my ids are 4 longs

#

in guid format

rustic rain
#

hmm

#

when game object prefab is getting converted

#

I guess prefab is not taken in account in any way?

#

conversion systems probably just process it without any regards for prefab

viral sonnet
#

๐Ÿ˜„

#

that weakreference script is a blast from the past. tertle, can you remind me why they were setting it up like that?

rustic rain
#

During conversion is it possible to get reference to actual target world?

#

I have extension fields in it I would like to fill

#

During conversion

#

I don't really want to create additional system with query

#

Welp, seems like I do need it

#

Sadge

rotund token
#

Back when you get to register all your ghosts (I'm not sure this is the case anymore)

rustic rain
#

Are entity references in fields resolved during conversion?

#

Basically if I create Entity in conversion system

#

that will have component that references other entity

#

after it's copied into actual world

#

are references remapped?

rotund token
#

if so yes things should remap

rustic rain
#

I need to create copy of entity, add prefab tag to it
And save it to other entity as field in comp

#

all will be created in conversion system

rotund token
#

is this runtime conversion?

rustic rain
#

subscene too

#

both

#

I'm also still can't figure out how to resolve it all correctly

#

I want to have GO prefabs with special authoring component, which will be responsible for solving copies

#

so if let's say you spawn 10 GOs with same authoring component's value

#

only 1 copy of them all will be written as prefab in World

#

and this also for subscenes

#

so once world is started and running, all existing entities that are spawned from prefab will have it's link

#

so that I can restore them later during save/load

#

based of these prefabs

rustic rain
#

Is updating in [UpdateInGroup(typeof(InitializationSystemGroup))] ok?

#

Does it update same way as in editor?

rotund token
#

yeah

rustic rain
#

so in short it's just a system that updates before simulation?

rotund token
#

yes

rustic rain
#

btw, can it be bursted?

#

These attributes are somehwat confusing

#

since some of them say BurstCompatible

#

other say structuralmethod

rotund token
#

should be fine in burst

rustic rain
#

bruh

#

InvalidOperationException: SolvePrefabsJob.query.__impl uses unsafe Pointers which is not allowed. Unsafe Pointers can lead to crashes and no safety against race conditions can be provided.

#

why EntityQuery methods have BurstCompatible attributes

#

if safety checks won't even let you use them in jobs

#

hmmm.
Wonder if I should rely on Transform parenting system

#

or just work with world coordinates

#

even if they are wonky and huge

rotund token
#

burst compatible

#

does not mean job/thread safe

#

these were all made burst compatible for ISystem

rustic rain
#

oh

#

maybe I'll just do ISystem then

#

yay, it works

rustic rain
#

hmmm

#

Do I need to specify every method for BurstCompile or?

#

For some reason simply tagging struct as BurstCompile doesn't work

#

in ISystem

rustic rain
#

oh man I start to really enjoy fully unmanaged ECS world

#

no need for any references between systems

#

just do EntityManager extension

#

and do event entity

rotund token
#

tagging OnUpdate actually makes that method compile bursted
while tagging the ISystem struct just gives burst a hint where it needs to look to compile a method

#

it's too costly for burst to simply try inspect every method in a project to see if it needs compiling

rustic rain
#

I see

#

will other methods like OnCreate or OnDestroy be bursted though?

rotund token
#

no

#

well if you put it on those methods then it probably would

#

i've never actually tried though tbh

#

i usually have managed code or unburstable code in OnCreate

#

like GetEntityQuery is not burstable

rustic rain
#

yeah, it's ok

dense crypt
#

I heard it's supposedly possible to debug jobs with breakpoints nowadays, do I need to do some special setup to make them work? Because just putting a breakpoint doesn't seem to trigger it. I'm using Rider.

#

To add to above,, disabling Burst Compilation makes it work properly, but I was under the impression that "Native Debug Mode Compilation" would do something similar for me

rustic rain
#

tertle said VS has one

#

I haven't tried it yet

dense crypt
rustic rain
#

oh god, treating shared components as managed feels awful

#

so many workarounds

#

I feel terrible

nova river
#

Hey guys, just getting started with Unity & DOTS. Tried following the new ECS project video (https://www.youtube.com/watch?v=m_ZDL2X9jvM&t=1s ) to get started and I can't get a baisc 3d object to convert and render in my game window in play mode. Using Unity 2021.3.6f1 and Hybrid Renderer 0.51.0-preview.32
Based on the DOTS hierearchy, the object is being converted correctly, but I don't think its rendering.
Anyone have any ideas?

๐Ÿ’ฌ Join our Discord community: https://tmg.dev/Discord ๐Ÿ’ฌ

๐Ÿ’ป My Game Development Setup: https://tmg.dev/GameDevPC ๐Ÿ’ป
๐Ÿ“ธ My Camera Gear: https://tmg.dev/CameraGear ๐Ÿ“ธ
๐ŸŽฎ Let me know what other topics you want to learn about ๐ŸŽฎ

โŒš Time stamps for key topics โŒš

  • 0:00 - Entities 0.50
  • 0:47 - A Word of Caution on ECS
  • 1:29 - Upgrade Prerequisites
  • 2:28 ...
โ–ถ Play video
rustic rain
#

ahem

#

is calling World from SystemBase is a sync point?

viral sonnet
#

What are you calling from it? I'm not aware of any sync points.

rustic rain
viral sonnet
#

what data do you get from it?

#

EntityManager?

rustic rain
#

nah, just extension field

#

I won't be able to check anything though, because I already moved everything to callback events that assign data instead

viral sonnet
#

huh, well, I dunno. Just calling World is not a sync point. It just returns you the unmanaged world object

#

in general, only certain methods have sync points from EntityManager and some forms of schedule like with change filter. most are quite obvious though

#

and when not obvious, running the game will give you errors when you rely on schedules

rustic rain
#

It returns Managed world

#

tbh

#

I'm not sure what actually causes errors at this point

#

so I'll just leave it behind until I face it again, kek

viral sonnet
#

the managed world is mostly a wrapper afaik

rustic rain
#

yeah, but you can extend it

#

I already overabused the power of it

viral sonnet
#

hehe

rustic rain
#

xD

pliant pike
#

Has anyone else come across this error Assets\Scripts\FlowFieldGridStuff\CalculateCellCost.cs(10,5): error SGICE002: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.IO.IOException: Cannot create 'Unity Projects\LOR Tower Defence Test Scene\Temp\GeneratedCode\Assembly-CSharp' because a file or directory with the same name already exists.

#

it appears my project is completely broke now it won't compile anything and I don't know what to do ๐Ÿ˜•

calm edge
#

I'd close unity and nuke the temp folder

pliant pike
#

ok I think its fixed now thanks

rustic rain
#

Is casting to IEnumerable<T> burst compatible?

#

I kind of don't want to write utility method for literally all native containers out there

haughty rampart
#

try it out

void ravine
pliant pike
rotund token
#

You don't need to close unity to fix this error

#

Just load up the temp / code generated folder

#

Delete the files in that

#

Reimport a script to trigger a recompile

#

For some reason the code gen is creating files instead of folders sometimes blocking the folders being created

pliant pike
#

ok, that's good to know

drowsy pagoda
#

Is there a safe way to write to an ISystemStateComponent collected from CDFE which was plugged into an IJobEntityBatchWithIndex.ScheduleParallel()?

rotund token
#

can more than 1 thread write to the same one?

#

or does your logic prevent it

drowsy pagoda
#

I get error that that CDFE<StateComponent> is not declared as ReadOnly, container does not support parallel writing.

#

Is that something I can "make" it support? Or I have to schedule single?

rotund token
#

if you have 2 separate threads writing to the same entity

#

it's just not safe

#

so that's why it's prevented by default

drowsy pagoda
#

If I want to get around it, I'd need to use NativeDisableForParallelRestriction type deal?

rotund token
#

yes

#

you're telling unity that you promise you aren't doing something unsafe

#

but it's up to you to ensure that

drowsy pagoda
#

And say another thread writes to it at the same time, will it silently overwrite, or will it throw exceptions?

rotund token
#

there will be no safety for you

#

the result will be undefined

#

in theory you could end up with half the value from 1 write and half from the other write

#

unity will not tell you this is broken

#

you have to be certain this situation can't happen

#

i.e. you should never do this unless you only map 1:1

#

if you are just writing randomly then this is not safe

drowsy pagoda
#

I see, yeah best not to mess with that then.

rotund token
#

if you had like single fields to modify, you could do things with interlocked etc to write safely in parallel

#

but you need to be comfortable with what you're doing otherwise turning off safety is a really easy way to cause yourself rare random bugs that are extremely hard to track down

drowsy pagoda
#

interlocked etc, meaning lock (myField) { // execute write here } type deal?

rotund token
#

interlocked as in

#

Interlocked.Exchange|Add|etc

drowsy pagoda
#

I think this is new for me. Can you give me more info?

rotund token
#

microsoft do a better than i ever would

drowsy pagoda
#

Woah, narly!

#

So here is the part in the job that I need to write back. How would I perform this Interlocked technique on this?

var treeState = unitStateComponents[directive.TargetTree];
treeState.health = math.max(0, treeState.health - toolPower);
unitStateComponents[directive.TargetTree] = treeState;
rotund token
#

will never work

#

not with the max

#

you'd have to remove the max

#

and have another job later apply it

#

in the time you read
Read: treeState.health
Execute: math.max(0, treeState.health - toolPower);
Write from another thread: treeState.health
Write this thread: treeState.health

drowsy pagoda
#

I see

rotund token
#

firstly you need a custom extension for ComponentDataFromEntity that will return the value by ref/pointer

#

then call Interlocked.Add(ptr, -toolpower)

#

and it would safely sum all threads

#

then you'd need a second job to go over all healths and do a max(0) on them

drowsy pagoda
#

I think I'll just chain jobs, Schedule Parallel all the calculations, and Schedule Single (dependency on parallel completion) to apply changes in calculations.

pliant pike
#

I don't suppose anyone knows how I use a CollisionFilter so that a raycast or an overlapsphere only hits on specific groups

#

I've got the raycast sort of working correctly by getting the filter from environment entity's

#

but the overlapsphere I need it to exclude the environment but I'm not sure how I set it up to do that

rotund token
#

if the environment in its own layer?

pliant pike
#

yeah

#

does physics entity's actually use the layers?

#

I thought it only used the belongs to and Collides with Collisionfilter thing

rotund token
#

they are the layers

pliant pike
#

so its something in the way I have it setup

#

I have the environment that collides with both enemies and environments

#

and I have enemies that only collide with the environment

#

so if I get the collisionfilter from the enemies then that means that cast should only collide with the environment? ๐Ÿ˜•

#

so I probably need to either create a new object that only collides with enemies or manually create a collisionfilter but the filter is kind of confusing because it uses uint

#

I wish I could get the names of what the values are because they don't seem to correspond to what they should

pliant pike
#

I think I did it leahYAY

#

I created an entiy and it had to belong to the environment and only collide with enemy's

dense crypt
#

Isn't the Burst Inspector supposed to show pieces of your original code in comments? Currently I have a simple Entities.ForEach and the Burst Inspector ASM is >10k lines, so I'm not really sure where my ForEach is or how I can locate it

#

I find all sorts of code gen stuff for grabbing components from chunks but I can't find the actual code that I wrote

rotund token
#

reading through very fast ๐Ÿ˜„

#

usually in middle 3rd

rustic rain
#

hmm

#

I assume there's no ReadOnly version of array or lists in native collections?

#

btw, is accessing field as ref is that simple?
ref var galaxy = ref World.galaxy;

rotund token
rustic rain
#

oh

rustic rain
#

oh god

#

I could have made things so much easier

viral sonnet
#

ref is pretty cool. best feature in modern c#

rustic rain
#

bruh

#

GetEntityQuery is protected of SystemBase

frigid crypt
#

I have a question, is there any tutorial or something that showcases how Joints work with DOTS and Unity Physics?

robust scaffold
#

Ugh. Back and forth, back and forth for days and weeks now. I think I might roll my own 2d physics engine as well. That way I no longer have to touch GOs at all

rustic rain
#

just set up constaints

#

and should be good

robust scaffold
#

It's pretty noticable in that DOTS UI video with the 2d sample game. The enemies bunched together would vibrate in position against each other due to the lack of stable collisions.

#

And plus performance. Why model 3d physics mesh when 2d is what is needed

viral sonnet
#

performance difference is not that big between 3d and 2d physics. depends on shape I guess. usually a bunch of standard shapes is enough to model something

robust scaffold
#

Just circles and squares. A bunch of them but just those 2

#

Maybe polygons but I can make them out of a bunch of squares. Tilemap colliders

rustic rain
#

well, tbh

viral sonnet
#

then it doesn't matter really. but what's your issue, the sliding or more?

rustic rain
#

3d should be fine perfomance wise

#

if you only use cubes, spheres

#

and etc

robust scaffold
#

just the sliding. I know Havoc has contact welding which will probably solve the issue but Im also dipping my toes into multiplayer. This is just a proof of concept project where I'm just touching upon various areas of game dev for a surface level understanding

robust scaffold
#

Ya know, I wonder what's going on in Unity DOTS team. They've gone back to radio silence on many of the forum posts. Except for netcode though. They were still active even before 0.50.

#

Or they could just be on summer vacation. The europeans have those strange things.

rustic rain
#

It is hot in europe during summer, kek

rocky dove
#

Inside an Entities.ForEach(), is it bad to then call a static function and pass the components as arguments?

rustic rain
#

it will be inlined

#

in burst at least

#

I personally do it for like 80% of all logic, xD

rocky dove
#

Thanks dude

tribal helm
#

Hi everyone, I currently have an issue with entity generation. When I try to generate it with a script (the script get mesh and materials to generate an entity with this), it just doesn't render at all (I'm running the script on an empty GameObject).

I'm running on 2021.3.6f1 with experimental packages:

  • entities
  • hybrid renderer
  • unity physics

All packages are version 0.51.0-preview32.
Any advice would be greatly appreciated

#

Here my script```cs
public class WorldManager : MonoBehaviour
{
[SerializeField] private Mesh unitMesh;
[SerializeField] private Material unitMaterial;

void Start()
{
    float3 position = Random.insideUnitSphere * new float3(100f, 100f, 100f);
    quaternion rotation = quaternion.Euler(0f, 0f, 0f);
    float3 scale = Vector3.one;

    EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
    EntityArchetype archetype = entityManager.CreateArchetype(
        typeof(Translation),
        typeof(Rotation),
        typeof(RenderMesh),
        typeof(RenderBounds),
        typeof(LocalToWorld)
        );

    unitMesh.bounds.ToAABB();
    Entity myEntity = entityManager.CreateEntity(archetype);

    entityManager.AddComponentData(myEntity, new Translation
    {
        Value = new float3(2f, 0f, 4f)
    });

    entityManager.AddSharedComponentData(myEntity, new RenderMesh
    {
        mesh = unitMesh,
        material = unitMaterial
    });
}```
rustic rain
#

try using utility method

#

RenderMeshUtility I think it's called

#

it will add all required components itself

fleet quartz
#

Relatively new to Unity here. Is DOTS available and ready for production?

#

I heard it got canceled or something but maybe that is bad info

coarse turtle
#

Entities is still in preproduction - but 1.0 release is coming to a later release in 2022.2 beta. Burst & Job System that ships with the editor are ready for production

fleet quartz
#

All the Unity news lately has been confusing to me

tribal helm
rustic rain
#

check in hierarchy window

#

system relationship

#

is it affected by HybridRenderer?

tribal helm
rustic rain
#

window-Dots-hierarchy

tribal helm
#

oh

#

thx for this info

misty wedge
#

Anyone else have issues with unity using a lot of RAM? Each time assemblies are reloaded it seems to use more

viral sonnet
rustic rain
#

Brrruuuuh
Feels so bad having no 2d transform

#

Now I'm between 2 fires:

  1. Make 2d transform and renderer
  2. Make it all on 3d through constraints with very little chance to easily refactor it
rotund token
#

Is there actually a reason you're sticking with entities? It doesn't really seem to meet the needs of your project atm @rustic rain

rustic rain
#

Why wouldn't I?

#

I need a large simulation

rotund token
#

What is it giving you? From what I understand you're mostly hybrid and using 2d

rustic rain
#

With scaling capabilities

rotund token
#

You can still write a large simulation with burst and jobs without entities

rustic rain
#

No hybrid

rotund token
#

Oh you scraped all that?

rustic rain
#

Those are different projects

#

The other one is finished actually

rotund token
#

So confusing ๐Ÿ˜ฉ

rustic rain
#

There's runner game with cannon and there's space tycoon

#

Cannon is done

#

Tycoon is in progress

tribal helm
drowsy pagoda
#

Is there a built in way to detect when entity came/left into/from camera view? If not, can someone give me some pointers on how to go about this?

rotund token
#

it's a shame there is currently no easy way to hook into HR culling as far as i'm aware to get this info

#

but you can just do your own frustrum culling if you need

drowsy pagoda
#

Shit. I was afraid someone was gonna say that. Ok, how would one do their own frustrum culling. What formulas/API do I need for this?

rotund token
#

FrustumPlanes in Unity.Rendering has methods for you

#

pretty straight forward

#

FrustumPlanes.FromCamera(Camera camera, NativeArray<float4> planes)
then just call
IntersectResult FrustumPlanes.Intersect(NativeArray<float4> cullingPlanes, AABB a)
to do a check

drowsy pagoda
#

Awesome thanks.

drowsy pagoda
rustic rain
#

hmmm

#

I am doing a UI-World connection in which I want to create UI data after certain action

#

but what if Entity gets destroyed, on which this UI is based

#

is there some kind of way to have callback?

#

or simply checking whether Entity is legit on every update is the way?

rotund token
#

you can create your own 'callback'

#

but apart from that yeah you need to check

#

i have a standard destroy/cleanup pipeline

#

that every entity goes through

#

and things can check if an entity is going to be destroyed and do cleanup on it

#

but even this can become a complicated mess at times

rustic rain
#

well yeah, that would require creating quite a lot of systems for callbacks

#

I guess it would be easier to just check every frame whether it's valid

#

while bursted it's pretty inexpensive

#

glad I learnt how to use ISystem

#

kek

rustic rain
#

hmmm

#

I just figured an interesting approach to handling UI and fields

#

can make some Component with float field and also attach VisualElement to it (text for example)

#

and then if that float field is written - other system will rewrite it as string to text object, while filtering change version

#

UI systems will be responsible for creating such queries

#

I guess they can be separated with shared component of value of certain screen reference hash

#

so by filtering you can find any singleton entity

molten flame
#

I have a need to generate a bunch of dynamic physics objects but with random scales.
These objects need to be spawned at runtime from a prefab because they are networked ghosts.
Because Unity bakes in the scale at authoring time for dynamic physics objects I need to create these prefabs at authoring time, so there could be quite a few.
It'd be nice If I could automate this process to create a bunch of baked prefabs to leverage the authoring systems.
Has anyone done this before, i.e. baking prefabs from an authoring script during conversion? especially in a NetCode context.

rustic rain
rotund token
rustic rain
#

and then during instantiation

#

you set the value

rotund token
#

that won't update the collider

rustic rain
#

composite scale?

rotund token
#

sure that works?

rustic rain
#

I think? xD

#

gotta test

rotund token
#

(see I thought it did but I can't see how it can since I see no references in code except in physics smoothing)

#

(the CreateRigidBodies job does not have a reference to any scale)

rustic rain
#

well, composite scale does exist for some reason, kek

#

and it's automatically added to entities with colliders

#

so I'd guess the easiest would be - just test it

rotund token
#

and yeah its only used as part of smoothing, so yeah not sure

molten flame
#

If I could do it at runtime that'd be a lot easier but I'm pretty sure the scale is baked into the physics geometry during conversion

#

TBH its probably easier to manually create a few variations with different scales and randomly choose from those.

#

I'm not big brain enough to go toe to toe with the DOTS gods like you guys XD

rustic rain
#

I highly doubt Unity added whole damn another scale component just to adjust drawing

#

It's a pain working with two already

#

Let alone 3

rotund token
#

as long as client/server both add the physics components the same way should be fine?

rustic rain
#

I assume components version filtering only works for chunks?

#

Meaning if one entity has changed whole chunk will pass?

#

Not a good thing in my case since it will probably recreate whole UI

rotund token
#

you just use change filtering as a broadphase

#

you nearly always have to check individually entities yourself after this

molten flame
rustic rain
#

and how can I filter individual entity?

#

I'm really interested in trying to make this UI elements + Entities integration

#

for every named VisualElement there will be created entity with attached object

#

and by adding special components you can manipulate how values will be applied to those objects

dreamy glade
#

I've generated a bunch of voxel chunk entities from scratch but none of them have proper lighting/shading/shadows. Anyone know why this could be? They each have their correct components and component data when compared to test-gameobjects that I've then turned to entities that DO have proper lighting. Any ideas? Thanks.

rustic rain
#

mostly Text I guess

robust scaffold
#

ugh, unity's gonna make me implement my own sprite renderer arent they

rustic rain
robust scaffold
#

im gonna give hybrid renderer a poke but last time I checked, it had enormous overhead

#

like 3-4 ms per frame rendering nothing.

rustic rain
#

what I think of it is

#

all you need is make a object dictionary

#

every time you convert object

#

with sprite renderer

#

you check whether sprite already belongs to some material

#

if it is

#

you just assign that material

robust scaffold
#

I literally render flat unlit textures. I roll my own lighting system. I just need a texture lookup

rustic rain
#

and then render instanced

#

ugh, sir

#

you can just use sprite material

#

lit/unlit

robust scaffold
#

I'm also rolling my own physics system in order to decouple the need for a game object entirely. However, I still need a sprite renderer.

rustic rain
#

just gotta figure what MTB properties belong to that shader

robust scaffold
#

Probably a custom SRP for that

#

hook it up manually

rustic rain
#

so in short it'll be:
grab all entities that belong to same atlas (material), grab their MTB (sprite UV) and then just pass that array to Instanced draw call

#

using quad as mesh

#

no need for custom SRP

#

just for that

#

in fact

#

Unity already rolled their implementation of it

#

you can look up sources on github

robust scaffold
#

Oh yea, hybrid has a sprite renderer implementation. Guess i can just copy and kinda customize

rustic rain
#

no

#

it's different

#

it's for project Tiny afaik

coarse turtle
#

yea unity tiny uses bgfx as its backend for rendering

robust scaffold
#

Oh F tiny

#

Back when unity was optimistic in their dots development, before it got sucked into development hell.

rustic rain
#

well, as long as they release entities to 1.0

#

someone will come up with 2D

#

sprite rendering seems quite easy ngl