#archived-dots

1 messages Β· Page 243 of 1

spiral flint
remote crater
#

This will sound dumb, but can I use an EntityCommandBufferSystem in a monobehavior? Seems cromulent except won't let me end it.

rustic rain
#

I assume monos get to run somewhere separated from systems

viral sonnet
#

yeah, use EM directly

#

easier for batch commands

#

has anyone looked into creating stats for achievements in Entities? Seems somewhat painful

spiral flint
#

Does DOTs questions include questions about Jobs?

viral sonnet
#

sure

rustic rain
#

this is basically the only channel about anything related to ecs kek

#

I guess I'll live here for a while

spiral flint
#

Okay, I'm having trouble Dipose()ing of my native arrays. I call Dispose() at the end of Awake (the only time I schedule the job) and I still get a error about a collection not being disposed

#

I've eyeballed my code like 10 times and can't figure it out

rustic rain
#

send us code?

hot basin
spiral flint
#

Here's the job:

struct PerCubeDataJob: IJobParallelFor
{
    [ReadOnly]public NativeArray<float> _density;
    [ReadOnly]public float _surface;
    [ReadOnly]public int _resolution;
    public NativeArray<Vector3> _vertices;
    public NativeArray<int> _triangles;

    public void Execute(int index){
        int vec2int = index % (_resolution * _resolution);

        int x = Mathf.FloorToInt(vec2int % _resolution);
        int y = (vec2int - x) / _resolution;
        int z = (index - (x + y)) / (_resolution * _resolution);

        float[] cube = new float[8];
        for(int i = 0; i < 8; i++){
            Vector3Int corner = new Vector3Int(x, y, z) + MarchingTables.CornerTable[i];
            cube[i] = _density[x + (y * _resolution) + (z * _resolution * _resolution)];
        }
        MarchCube(new Vector3(x, y, z), cube);
        float point_density = _density[index];
    }
    void MarchCube(Vector3 position, float[] cube){
        int config = GetCubeConfig(cube);

        if (config == 0 || config == 255)
            return;

        int edge_index = 0;
        for (int i = 0; i < 5; i++)
        {
            for (int p = 0; p < 3; p++)
            {
                int indice = MarchingTables.TriangleTable[config, edge_index];

                if (indice == -1){
                    return;
                }

                Vector3 vert1 = position + MarchingTables.EdgeTable[indice, 0];
                Vector3 vert2 = position + MarchingTables.EdgeTable[indice, 1];

                Vector3 vert_pos = (vert1 + vert2) / 2;

                int index = (i * 3) + p;
                _vertices[index] = vert_pos;
                _triangles[index] = index - 1;
                edge_index++;
            }
        }
    }
    int GetCubeConfig(float[] cube)
    {
        int config = 0;
        for (int i = 0; i < 8; i++)
        {
            if (cube[i] > _surface)
                config |= 1 << i;
        }
        return config;
    }
}
rustic rain
#

thus no need for buffer

hot basin
viral sonnet
spiral flint
#

And here's Awake(): ```
void Awake()
{
filter = GetComponent<MeshFilter>();
scale = 1 / Mathf.RoundToInt(Mathf.Pow(2, tree_depth));

    //density1d = new float[8 * 8 * 8];

    NativeArray<float> density_array = new NativeArray<float>( GenerateDensity(8), Allocator.TempJob);
    NativeArray<Vector3> vertices = new NativeList<Vector3>(8 * 8 * 8, Allocator.TempJob);
    NativeArray<int> triangles = new NativeList<int>(8 * 8 * 8, Allocator.TempJob);
    PerCubeDataJob cubeDataJob = new PerCubeDataJob
    {
        _resolution = 8,
        _surface = surface,
        _density = density_array,
        _vertices = vertices,
        _triangles = triangles
    };

    JobHandle testHandler = cubeDataJob.Schedule(8 * 8 * 8, 8);
    testHandler.Complete();

    Mesh mesh = new Mesh();

    mesh.SetVertices(vertices);
    mesh.SetTriangles(triangles.ToArray(), 0);

    filter.mesh.Clear();
    filter.mesh = mesh;

    
    density_array.Dispose();
    vertices.Dispose();
    triangles.Dispose();
}
hot basin
#

MBs run before system if I remember correctly

spiral flint
hot basin
#

density_array.Dispose(testHandler); here

#

you are using job handle but never .Complete() it afterwards

spiral flint
#

Yeah I do

#

testHandler.Complete()

hot basin
#

afterwards

viral sonnet
#

density_array.Dispose(testHandler); returns a jobhandle but you don't use it

#

replace with density_array.Dispose(); and it will work

#

no need to let it run in a job I think

spiral flint
#

Well, I did that, and nothing changed

viral sonnet
#

if you made the code change just recently the error msg could be thrown from your previous leak

spiral flint
#

It's pointing to triangles and vertices

#

Could it have something to do with the arrays not being big enough or something?

#

Why wouldn't Dispose() work?

viral sonnet
#

no, you'd get an out of bounds exception if that is the case

#

is it hitting the dispose lines? does it run multiple times?

spiral flint
#

I'll change it to Start() and see

#

It's not throwing up anything about the dispose lines, and it's only running once

viral sonnet
#

insert some debug.logs to confirm πŸ™‚

#

I can't see anything wrong with the code so the error must be somewhere else I think. Never had any issues with Dispose unless I forget it πŸ™‚

spiral flint
#

How would I use debug logs to check?

#

I know to use them, but what would I print in this case?

viral sonnet
#

insert a Debug.Log("Disposing ...") to see if the line is hit and one after. it's really just for confirmation that nothing is going wrong up until that point

spiral flint
#

Well, I just put debugs in Execute() and in Start() and the code runs all the way through

#

Is this an actual Unity bug?

#

I don't understand

viral sonnet
#

I don't think so. Would have seen more reports by now. Which Unity version are you using?

spiral flint
#

Hold on...

#

Bad initializers

#

wrong type

viral sonnet
#

oh lol, just saw it too πŸ˜„

#

omg

spiral flint
#

That bug message is too vague!

#

I guess I should have looked closer but still lol

viral sonnet
#

hehe, sometimes the most obvious mistakes are the hardest to spot

#

I didn't even know initializing a list to an array can even compile

spiral flint
#

Now I just have to make my code work

remote crater
#

I know work around, but seeing what is possible. Ty

viral sonnet
#
... do work
commandBuffer.Playback(EntityManager);
commandBuffer.Dispose(); ```
spiral flint
#

Since I can't modify lists with multithreading, how can I add the same values in a manner that doesn't use lists? The current way doesn't work.

#

Since I also can't get a _vertices.Count value, since it's size is predefined

graceful mason
#

you could use dynamicbuffer but im not sure its a good way or not

spiral flint
#

that's how you get spagett

graceful mason
#

ive used it before in a run parallell, each mesh was its own entity with its own buffers and ran in parallell but no idea if it was performing well or not πŸ˜„

spiral flint
remote crater
#

How do you pass a null for a EntityCommandBuffer.ParallelWriter parameter to a method?

#

Aka how do you set: EntityCommandBuffer.ParallelWriter = null ?

graceful mason
#

im not sure if theres some faster thing you can just use in a job that doesnt need to save it as component at all

zenith wyvern
spiral flint
zenith wyvern
spiral flint
zenith wyvern
#

Copy your native arrays into lists?

spiral flint
zenith wyvern
#

Apparently SetVertices takes NativeArrays directly now too

spiral flint
#

My issue is with the structures used to generate data. I just need to figure out how to keep the data clean while moving from single thread to multithread

zenith wyvern
#

Not sure what the issue is

spiral flint
zenith wyvern
#

I really have no idea what you're doing then. Any time I make a mesh I fill the vertices and triangles at the same time. I'm not sure how it makes sense to do it otherwise

spiral flint
zenith wyvern
#

It doesn't matter if it's multithreaded or single threaded. Verts and tris have a 1-1 relationship. Or a 1-3 relationship I guess. You shouldn't be filling one without filling the other at the same time

spiral flint
#

Yeah, just saying that doesn't magically make me understand how to do it

#

My code is all above, feel free to take a look

zenith wyvern
#

Yeah I'm not going to try to piece together whatever that is doing. But the way you're describing your problem doesn't really make sense to me. The indices for a given triangle should always be the same given that they're derived from the index of the vertex/quad. It shouldn't matter if it's multithreaded or not, it should still be giving you the same indices in order

#

My advice would be to try to tackle something simpler to start with and work your way up to whatever that is

coarse turtle
spiral flint
#

I've got this far, I'm too close to give up

worn valley
#

That is a huge pain in the ass but I've done it

#

You need to pre allocate the arrays you've decided to fill with data

#

And then write them in parallel, disabling the native parallelism safetys

#

@spiral flint

coarse turtle
#

if you know how many triangles/quads to generate before, you know the minimum # of vertices & indices you need

worn valley
#

If the sizes of the meshes you are building is unknown at the time, just run the code twice. First round get the count, finish those jobs, allocate and then write to the jobs in the second round. It'll take two frames but it means you don't have to estimate how large your arrays will be

#

Not perfect for performance but better because memory bandwidth is the bottoeneck in ECS and DOTS

coarse turtle
#

for 50,000 vertices and counting ahead of time in my imgui framework - it took around 0.04ms - which isn't bad when you iterate twice

devout prairie
worn valley
#

Yeah great point. But you do need to complete the count job before the write job. I tried to think of a way to do it in one pass but I am not enough of a master of pointers to figure that out.

devout prairie
#

Yeah for sure i don't know the specifics of the situation tbh, but i did spend quite a bit of time figuring out how to use the existing ecb systems / sync points to get multiple-stage workloads to complete within the frame.. so just saying it is possible, and quite nice actually when you kinda learn how it's all structured

spiral flint
#

Know of any examples I could look at? It's not easy for me to imagine how it would work

worn valley
#

Unfortunately I have no examples on hand. I kind of stumbled into this with a lot of frustration.

#

I don't entirely understand the problem either. Are you generating a mesh at runtime and want to multi thread it?

spiral flint
devout prairie
spiral flint
#

I swear, GitHub is like a giant code textbook

#

I just get intimidated with large repos because there's too many parts for my smol brain

devout prairie
#

Yeah i mean it might be possible to find parts that are relevant.. or even scroll through the discussion he was having on here as i think some of it was similar, trying to init arrays of unknown size and also some issues with doing it in parallel.. worth a quick read maybe 🀷

spiral flint
#

Looks like a different issue. I think I can just solve this with math. With the information given, namely vertex index.

#

I feel like my solution is staring me in the face

#

I also have the edge index and the iterations of the array

spiral flint
#

I can get the "index" of the triangle int tri_index = (int)math.floor( value_index /3);

worn valley
#

Tell us the final problem.

#

I think you are trying to find a solution without telling us what you need to do

#

A mesh is just a list of points

#

And the the triangles are indexes to each point

#

(Just making sure we are on the same page)

spiral flint
#

So in the single-threaded code, in this loop, he adds the index of the vertex to the list of triangles.

    void MarchCube (Vector3 position, float[] cube) {

        // Get the configuration index of this cube.
        int configIndex = GetCubeConfiguration(cube);

        // If the configuration of this cube is 0 or 255 (completely inside the terrain or completely outside of it) we don't need to do anything.
        if (configIndex == 0 || configIndex == 255)
            return;

        // Loop through the triangles. There are never more than 5 triangles to a cube and only three vertices to a triangle.
        int edgeIndex = 0;
        for(int i = 0; i < 5; i++) {
            for(int p = 0; p < 3; p++) {

                // Get the current indice. We increment triangleIndex through each loop.
                int indice = TriangleTable[configIndex, edgeIndex];

                // If the current edgeIndex is -1, there are no more indices and we can exit the function.
                if (indice == -1)
                    return;

                // Get the vertices for the start and end of this edge.
                Vector3 vert1 = position + EdgeTable[indice, 0];
                Vector3 vert2 = position + EdgeTable[indice, 1];

                // Get the midpoint of this edge.
                Vector3 vertPosition = (vert1 + vert2) / 2f;

                // Add to our vertices and triangles list and incremement the edgeIndex.
                vertices.Add(vertPosition);
                triangles.Add(vertices.Count - 1);
                edgeIndex++;

            }
        }
    }

My problem is that I can't modify a list in parallel, so I need to do it a little different. I'll post my current code ...

worn valley
#

Okay what you need to do is first count the size of list you need

#

So run the code once's figuring out the final array list length

spiral flint
#

In my code, I can still reference the index of the vertex, but I need to know what triangle to assign.

void MarchCube(Vector3 position, float[] cube, int value_index)
    {
        int config = GetCubeConfig(cube);

        if (config == 0 || config == 255)
            return;

        int edge_index = 0;
        for (int i = 0; i < 5; i++)
        {
            for (int p = 0; p < 3; p++)
            {
                int indice = MarchingTables.TriangleTable[config, edge_index];

                if (indice == -1)
                {
                    return;
                }

                Vector3 vert1 = position + MarchingTables.EdgeTable[indice, 0];
                Vector3 vert2 = position + MarchingTables.EdgeTable[indice, 1];

                Vector3 vert_pos = (vert1 + vert2) / 2;

                int index = (i * 3) + p;

                int tri_index = (int)math.floor( value_index /3); // index of the current triangle being added to _triangles
                _vertices[value_index] = vert_pos;
                _triangles[(3 * tri_index) + p] = value_index - 1;


                //_triangles[value_index] = index - 1;
                edge_index++;
            }
        }

    }
worn valley
#

Then read that info from your job

#

Then do the same stuff again but this time writing it

#

A list is an array with a wrapper in it

#

So when you add something to a list, you are changing the underlying array and increasing the count of the list

#

So a list may appear to have 5 items in it, but the underlying array has 64 items in it, 59 of the which are junk data

#

So you need to find the size of your array to fill first

spiral flint
worn valley
#

I gotta go do something so I can't explain it right now. But look up how C# lists work and that will help you crack it.

#

You are close, you just gotta figure out how to add things to an array as if it were a list

#

oh you are so close

#

Edge_index is the point right?

#

So just use that to reference the triangle

#

the index of the triangle you are using is the index of the vert you have just written

#

and now I really gotta go, good luck!

viral sonnet
#

How are you guys handling conditional write backs in an IJobChunk? Like, always getting a write handle sometimes makes no sense when nothing is written back. Getting a write handle alone bumps up the chunk version. My naive solution is to handle it with bools that determine if something is written back and if it's true, only then a write handle will be acquired. It "works" but it's so suboptimal.

rotund token
hot basin
#

Is there any advantage to use IJobChunk?

#

never used it as well as IJobEntityBatch, seems very specific

rotund token
#

well you shouldn't use IJobChunk as it's deprecated in favor of IJobEntityBatch

#

as for if you should use them, up to you

#

I actually write most of my backend code in IJobEntityBatch (or other jobs)

amber flicker
#

The main advantage (compared to lambdas) is you can more easily do chunk level optimisations. Eg if(HasComponent(blah)) once per chunk rather than per entity

hot basin
amber flicker
rustic rain
#

sooo, this is my player prefab.
How do I get camera entitiy from it during runtime?

karmic basin
#

You can tag it

rustic rain
#

Doesn't camera already has a tag?

karmic basin
#

Oh yeah then query a relevant tag

#

Or reference it, depends where you are

rustic rain
#

I'm guessing

#

this is camera?

#

ugh, working with children is weird

misty wedge
#

Are there any well tested and used solutions for event systems yet?

haughty rampart
rustic rain
#

For best performance and up-to-date results, it is recommended that static bodies do not have a Parent.
Hmm

#

How do you set up world like that then?
What is the way to destroy all dummy parents upon conversion?

#

For example if you have smth like Environment{ FirstRoom {wall wall... door} ... LastRoom {} }

misty wedge
haughty rampart
misty wedge
#

Then how will the damage system know when to apply damage

#

Read from a component?

haughty rampart
#

yes

rustic rain
#

by processing all entities with component

misty wedge
#

But would I keep a component with a "currentFrameDamageValue", or add a component to the entity, or create an entity?

haughty rampart
#

if applying damage is done frequently you'd not want to add a component whenever you need it but have an already available component on your entity. you would not create an entity. and the first one 'currentFrameDamageValue' i don't understand

misty wedge
#

Basically have a component with an e.g. integer that stores the damage that should be applied that frame, and is then set to 0

#

Which is never removed or added

haughty rampart
#

yes

misty wedge
#

Alright. I think I like the "creating event entities" approach more, but there seem to be performance issues with it

#

Does the scheduling system ever become a bottleneck if these systems always run, or is it not an issue?

haughty rampart
rustic rain
#

I'm just a newbie, so take it with a grain of salt, but I think of it this way:
upon casting ability (system that reads input), let's say fireball, you create entity by your fireball prefab. Then whatever movement system you have will move that fireball in world space. And other system will check for collisions of this fireball. Once collision happened you destroy entity, add component to collider. And then the other system applies damage to that collider enitity.

misty wedge
#

its also the way NetCode handles RPCs

misty wedge
#

Adding components is very slow

haughty rampart
#

there is no structural change in that example

misty wedge
#

How so? He is adding a component

haughty rampart
#

well....sure adding the component is not good. you'd just have the component already. then there's no structural change

misty wedge
#

Well yeah, but his example mentions "add component to collider"...

rustic rain
#

is adding component that bad tho?

#

From what I'v read structural changes are basis of ECS

misty wedge
#

It will copy the entire memory block of all components on the entity iirc

rustic rain
#

you won't avoid it

#

yeah

#

but it's like

#

one event

misty wedge
#

Yes, but if you have thousands then it can become an issue

rustic rain
#

that doesn't happen more than 1 times per second probably

haughty rampart
rustic rain
#

oh well

misty wedge
#

Dealing damage won't happen more than once per second?

rustic rain
#

hm

misty wedge
#

What if you have thousands of actors, shooting tens of thousands of bullets?

rustic rain
#

I guess you do need a tricky way to process it then

haughty rampart
#

even if it's once per frame it's still okish

misty wedge
#

@haughty rampart do you know if systems will process disabled components once that's a thing?

rustic rain
#

if there are thousands of actors, then it would happen way more than once per frame

misty wedge
#

Or will the iterating code just skip those

misty wedge
#

I see

#

Is there some info on that? I also read about entirely unmanaged systems using an interface called ISystem, but I have no idea where people are getting this info

rustic rain
#

Maybe just have component

#

damagable

#

and write to it upon impact

#

and write it back to 0 once damage is done

misty wedge
rustic rain
#

bad thing is that system will iterate through it for nothing

#

but I guess that's not as bad as structural changes

haughty rampart
misty wedge
#

Interesting that disabling components is so complicated

haughty rampart
misty wedge
#

Yeah but that can still cause it to run almost every frame if the archetype is small

haughty rampart
misty wedge
#

I see

haughty rampart
#

cause there are many different ways in how this could be implemented

misty wedge
#

Is there an ETA on 0.50?

haughty rampart
haughty rampart
misty wedge
#

But it would probably always be faster

#

Unless you have a massive amount of entities

haughty rampart
haughty rampart
spiral flint
#

Do you think that DOTS will make Unity's current object oriented systems obsolete? It seems like there's already a lot of advantages to using DOTS instead

rustic rain
#

prob not

#

OOP is used everywhere

#

while DOD used only in games

haughty rampart
rustic rain
#

mostly

deft stump
haughty rampart
spiral flint
#

So maybe. I think it's likely that OOP will stick around for people to ignore DOTS like I have for the last 2 years until it's in the way.

#

I was a total main-threader until last week lol

haughty rampart
deft stump
#

I can't wait to use DOTS 1.0 in my RPG game with just 1-3 entities moving around

haughty rampart
#

that's a perfectly fine use case

rustic rain
#

when you start with dots you quite literally need to "forget all you know about oop programming"

deft stump
#

I know Joachim said "that not everything should in fact be solved with ECS."
but F that. I want it in my RPG XD

remote crater
#

Quick question: Is Physics.IgnoreCollision contained in Dots/ECS or do I need to roll my own homebrew version.

worn valley
#

OOP has been used since the 80s. And most programmers learned how to program during the OOP days. It's also easier to understand because it's how our brain works. So OOP is probably going to be with us forever. But DOD is way better for the computer so it's gonna be used when speed is an issue.

remote crater
#

Oh yeah OOP is great, but DOTS is greater

worn valley
#

I also found once I got my brain into the ECS mindset things became simpler and better to pull apart.

remote crater
#

Its like when you have to start coding microcontrollers, different rules for different paradigms

#

Or like driving a boat vs driving a rocket ship.

worn valley
#

I am pretty sure you fly a rocket ship πŸ˜‰

remote crater
#

boats can be comfortable and familiar with all your amenities there.

#

I command a fleet of them πŸ˜‰

deft stump
remote crater
#

But rocket ships go zoooom

#

if you're writing monobehavior, you're not writing dots right

worn valley
deft stump
haughty rampart
viral sonnet
#

is there a workaround so subscene gameobject can have gizmos?

coarse turtle
safe lintel
#

can also use aline(though its a paid asset)

haughty rampart
worn valley
#

ah okay, yeah depends. I find I can write monobehaviours faster for prototyping but after a while it becomes a convoluted mess

worn valley
#

Any old thing.

remote crater
#

But somehow lasers shoot my main guy, and still apparently bounce off me

hollow jolt
#

.

is there a way to make the GameObjectConversionSystem execute after mono awake / start ?

#

in that system I'm trying to add data form a mono that is being populated on the MonoBehavior : Awake() method

haughty rampart
hollow jolt
#

2 game objects , one is converted , the other is not

#

i want to fetch data from the none-converted gameobject that defines that data on Awake/Start

#

and only then allow the gameobject which is flagged for conversion to start the process

rustic rain
hollow jolt
remote crater
#

How do I make an object look (aka rotate forward towards) another position?

#

In unity it was:

#

UnityEngine.Vector3 newDir = UnityEngine.Vector3.RotateTowards(pos2, pos, 1, 0.0f);

#

rotation.Value = UnityEngine.Quaternion.LookRotation(newDir);

#

pos2 = my position

#

pos = aimed at position

#

That does not seem to work in DOTS ECS

#

I just spent 2 hours wondering why my laser "lead target" to hit moving target code was failing

#

I reduced it down to... Literally I can't get an entity rotating properly to look at a point.

#

It always looks off to the side like a derp

worn valley
#

@remote crater I THINK that buried somewhere in this github repo is the code for look towards

#

I had to write my own math functions to replace some of the ones missing from Unity.Mathimatics. I ended up calling it mathf (instead of Mathf. If you find where those functions are, let me know. Its frustrating that Unity wouldn't completely reproduce the functions we've used for many years. I think it has something to do with SIMD functionality.

deft stump
tulip robin
#

Hello everyone, I am facing a dilemma, I have created my own hashtable of component etc...
for 65536 int
NativeArray take 11237 ticks ~= 1.1ms
OwnHashtable take 3456 ticks ~= 0.3 ms

Anyway, I wanted to know if burst compiler and ijob was so powerful that from scratch we can't do faster?

namely it is for the management of chunks.

I would like to be as optimized as possible!

also is it possible to execute a compute shader in a job ?
is there a more optimized way ?

viral sonnet
#

what are the timings? adding?

#

and does the code run bursted? nativecontainers are slow in normal C#

tulip robin
#

ok ok I was testing with ecs, when all of a sudden I had a problem with the meshes not having the colors anymore, possible to set mesh.colors on ecs ?

#

URP btw

tulip robin
#

@viral sonnet my question is it's better after build then "object []" ?

rustic rain
#

hmm

#

any tip how to make responsive character controller with dots physics body?

rustic rain
#

I'm guessing there is no "character controller" for dots as of now

#

and I haven't worked with rigid body characters yet

north bay
#

There is one in the physics samples and one on the asset store called rival

rustic rain
#

and now that I work with dots physics I feel lost

haughty rampart
rustic rain
#

Well, I used Unity's character controller

#

with it's built in colliders feature

#

Move(Vector3) thingy

#

actually I think I figured it out, velocity seems pretty responsive when you directly assign to input movement vector

hot basin
#

there is always asset store πŸ˜„

rustic rain
#

well, I'm trying to learn how to do it, not just use it

rustic rain
#

Anyone here worked with Dots physics collision trigger event system?

#

TriggerEventConversionSystem

#

from sample

#

I read through it's code several times but I just lack some clarification about it

#

The most I could (which might be absolutely wrong) understand:
It creates entity with some kind of list of StatefulTriggerEvent struct which looks like this (screenshot)

#

And then you just query with your systems through entities with data component

#

Is any of it correct?

#

here sample itself

karmic basin
#

yeah basically after solving contact pairs for triggers it stores them in a buffer with a state of ENTER/STAY/EXIT

#

did you browse the sample scenes too, or only the code ?

#

they show a lot of use cases

#

but triggers/collisions is still a verbose hell

#

it's just a simple "force field" trigger zone which applies velocity, but there's an even simpler sample with color change

#

IIRC there are also dedicated collision jobs, which are even worse on boilerplate

rustic rain
#

meaning you can't thread it with native jobs interfaces

#

I also having trouble to understand what exact collision does it get from physics

#

only collisions that are defined by layers?

#

eg: entity X belong to layer 1 and collides with layer 2,3.
So will that buffer store collision of entity X with entity that belongs only to layer 4?

karmic basin
#

There are dedicated physics jobs to access the collisions and trigger events

#

if you implement this interface ^

rustic rain
#

what about the second question?

karmic basin
#

sorry it's a very incomplete answer but you can find example in the samples

rustic rain
#

I mean that part

#

eg: entity X belong to layer 1 and collides with layer 2,3.
So will that buffer store collision of entity X with entity that belongs only to layer 4?

karmic basin
#

for layers ? I don't remember πŸ€”

#

So will that buffer store collision of entity X with entity that belongs only to layer 4?
-> wait, what ?
It looks for collisions in the same physicsWorld, I just can't remember if there's a collision layers matrix like in PhysX Unity
But you're wondering if the buffer is the list of events for entities that DID NOT collide ? Sounds weird to me, not sure I understand πŸ˜›

#

Oh I get it now, you're asking if the CollisionFilter is absolute ?

rustic rain
#

literally all entities with physics body?

#

or only those that go along with collision filter

karmic basin
#

I don't remember seeing the filter used to solve collisions/triggers. It would make sense but I'm only sure for ray/shape casts.
Can be quickly tested in a new scene though

#

Sorry I don't want to tell you a mistake

rustic rain
#

welp, looks like collision filter indeed applies

karmic basin
#

If it's not used, you would have to check layers yourself in the job

#

Oh well great then πŸ™‚

rustic rain
#

Anyone knows any example of using UI with dots?

#

UI toolkit in particular

safe lintel
#

access it on the mainthread like any other managed type in dots

rustic rain
#

so you mean

#

I need GameObjects for this

#

that are responsible to UI and then just send data from dots systems?

safe lintel
#

yeah theres no dots native ui

rotund token
#

(except to store the UI Document script)

#

i have a UISystemBase for my UI and I'd recommend you build something similar

#

for example my (currently very simple) menu UI system looks like this

    {
        /// <inheritdoc/>
        public override uint StateKey => Keys<UIStates>.NameToKey("menu");

        /// <inheritdoc/>
        public override ComponentType StateInstanceComponent { get; } = typeof(UIMenu);

        /// <inheritdoc/>
        protected override void OnLoad(VisualElement panel)
        {
            var playButton = panel.Q<Button>("play");
            playButton.clicked += this.PlayButtonOnClicked;
        }

        private void PlayButtonOnClicked()
        {
            var uiState = this.GetSingleton<ClientState>();
            uiState.Value = new BitArray256 { [Keys<ClientStates>.NameToKey("go-in-game")] = true };
            this.SetSingleton(uiState);
        }

        private struct UIMenu : IComponentData
        {
        }
    }```
(This combines like half a dozen concepts in my project so probably doesn't make a lot of sense what's going on)
hot basin
#

uiState.Value = new BitArray256 { [Keys<ClientStates>.NameToKey("go-in-game")] = true }; neat

rustic rain
#

I do get the part when you can just call UI (menu for eg)

#

by clicking button

#

which is processed by system

#

but part of opening window itself

#

seems like relies on game object

rotund token
#

UI Toolkit doesn't use gameobjects except for the root UI Document script

rotund token
hot basin
#

it's just a singleton?

rotund token
#

i guess in a way?

#

under the hood it's really just a Dictionary<Type, Dictionary<string, uint>>

#

it's only something i recently added so haven't completely fleshed it out yet

#

i've been doing a lot of experimental work on the concept of application/game level states

#

and trying to find a really nice flow for an entity based project

#

(pretty happy with how it's turned out now)

hot basin
#

I was wondering about something similar but for data and assets

#

as a mean to connect DOTS pure data and artist/designer GO with easiness of authoring

rotund token
#

yeah that's pretty much the majority of work i do at the moment

#

developing in a way to empower artists/designers

#

i.e. no point* in developing this high performance AI, skill system, game manager etc library if your designers can't use it
(*only relevant to professionals, hobbyist should develop the fastest way they can if they want any hope of releasing their game)

safe lintel
#

just started using your eventsystem(v2) and it works wonderfully so thanks @rotund token though I have a question, is there a particular reason 1.5.1 of burst is used? getting some annoying warnings on build and im fairly certain they didnt occur in the previous version I was using

rotund token
#

it's just min dependency

#

you can use any version after that you like

#

you should definitely update it to at least 1.5.7 or 1.6.3

#

unless you want to downgrade. i can't remember why it was 1.5.1 min, i believe it was related to V1 and I haven't tested V2 in 1.4.X

#

so feel free to test it, it might work fine

safe lintel
#

yeah seems like dspgraph doesnt play well with 1.6.3, wasnt really relying on it but annoying

rotund token
#

anyway let me know if you find any issues with V2

#

i've been using it in my own libraries but not at work

#

and haven't found any issues, but i don't consider it tested enough to mark as production ready

safe lintel
#

will do!

rotund token
#

(also it kills a few features found in v1 which i'm hesitant to nuke for existing users as i have no intention of adding them)

#

will probably push V2 to master when 0.5 is out

#

as V2 supports ISystem

safe lintel
#

I did notice the mention of at least no mixing of fixedrate but I dont think thats a requirement for me

rotund token
#

can't remember what i wrote, but writing from fixed update should be fine if you're readers are in the regular update

#

but not vice versa

safe lintel
#

@rotund token one thing I wasnt sure of - I havent yet gotten around to this part but

var myEventWriter = eventProducer.CreateWriter();
Entities.ForEach(({
  myEventWriter.Write(new MyEvent);}
.Run();
eventProducer.AddJobHandle(Dependency);
Entities.ForEach(({
  myEventWriter.Write(new MyEvent);}
.Run();
eventProducer.AddJobHandle(Dependency);

do I need both AddJobHandles or just the second (or should I be making a new writer in this instance)?

gilded palm
#

hi, how can I ignore a specific collider when Raycast (ECS).
My situation: I have lots of same object moving around, I use raycast to detect if they will hit other, but everytime, they hit themselves

frosty siren
#

Hi guys, i hope the beginning of the year turned out to be successful for you. 🌠
I have a problem with which i break my head for a whole day!
Imagine i have N sprites with different sets of shader properties. Properties stored as IComponentData, so to render N sprites i gather theirs position data for sorting -> then sort them -> then gather properties data and reorder this data according to position order -> and finally writes data in correct order to ComputeBuffer -> and finally render all this N sprites.
The problem appears when i want to replicate unity's sorting groups, when your sprites can be nested. I want to remain approach with linear accessing to properties data, that's because i don't want to have DynamicBuffer with entity links on parent sprites, instead i want to have some struct ParentSprite : IComponentData { public Entity link ;} (enities which has no parent will link themselves or Entity.null).
So with ParentID component i have arbitrary sequence of N entities which might have parents and i need to account it while sorting. After sorting all sprites which has parent should goes after parent and be sorted only with other children.
The naive solution for me is to firstly sort whole N elements by parent -> then find groups -> then sort groups depending on root parent sorting data -> then restore whole array with childrens using copy/paste of groups. But this solution look very inefficient, because even without sorting groups sorting process is the biggest consumer of time, and with this solution i get extra sorting in worst case with the same N elements.

What you think about it? Can you advise some smart algorithms, or point me on that whole this approach is bad?

vivid robin
#

What do people recommend doing in lieu of the hybrid renderer in order to render dots entities in deferred renderers? Allocate game-objects for each one and hope for the best?

vivid robin
frosty siren
vivid robin
#

If your sort key was:

let p = f(Parent) in
  case f(Child) of
    c if c == p -> p * 3
    c if c < p -> (p * 3) - 1
    c -> (p * 3) + 1

then it'd make sure that parents with lower children sort lower than parents with higher children but equal parent value

#

it assumes that each entity has exactly one child; you can make the c == p case also consider "if c is null" as an option, or slot that wherever is appropriate

frosty siren
#

i need to parent can have any count of children

#

and also i can't understand code example 😬

vivid robin
#

"any number of children" is hard to even represent in dots, from what I'm seeing, due to the lack of reference types or pointers

frosty siren
#

that is why i'm asking advice πŸ™‚

vivid robin
#

I suspect it might need database-style thinking- a collection of entities which contain an ID, a collection of entities for the child types, and a collection of (parentId, childId) tuples saying which ones are related.

But that seems way more complicated than just writing this sort of thing in Rust...
So I'm pretty sure Unity would've tried to come up with something better, somewhere

molten flame
#

Has anyone had luck rendering something that cant be rendered with hybrid renderer by using AddHybridComponent?
Everything seems to work, companion link is set up, companion game object exists but no bueno on the rendering.

molten flame
# vivid robin https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.Lin...

I mean, there are ways to do it https://www.youtube.com/watch?v=L7M_vbo1N2g
But really you might as well just go pure Rust if you wanna endure that pain

I added Rust support for the Unity game engine.
Is it really possible? YES it is!
I managed to make a game 100% coded in Rust, but using Unity as editor and runtime.
This has to be one of my craziest projects yet!

I utilized a library called Bevy game framework/engine, to handle the gameplay programming. Utilizing Bevy systems I was able to hid...

β–Ά Play video
frosty siren
safe lintel
#

@gilded palm you need to use an ICollector, the physics samples have examples of it but heres one simple one I use

   [BurstCompile]
    public struct IgnoreSpecificEntityCollector : ICollector<RaycastHit>
    {
        private readonly Entity ignoreEntity;

        public bool       EarlyOutOnFirstHit => false;
        public float      MaxFraction        { get; private set; }
        public int        NumHits            { get; private set; }
        public RaycastHit Hit                { get; private set; }

        public IgnoreSpecificEntityCollector(Entity ignoreEntity, float maxFraction)
        {
            this.ignoreEntity = ignoreEntity;
            Hit = default(RaycastHit);
            MaxFraction = maxFraction;
            NumHits = 0;
        }

        public bool AddHit(RaycastHit hit)
        {
            if (hit.Entity.Equals(ignoreEntity))
                return false;
            
            MaxFraction = hit.Fraction;
            Hit = hit;
            NumHits = 1;
            return true;
        }
    }
#
var collector = new IgnoreSpecificEntityCollector(instigator.Value, 1.0f);
var hit       = CollisionWorld.CastRay(rayInput, ref collector);
var hitBody   = CollisionWorld.Bodies[collector.Hit.RigidBodyIndex];
var hitentity = hitBody.Entity;
var rayHit    = collector.Hit;
gilded palm
safe lintel
#

@molten flame they will be making companion gameobjects(and I think AddHybridComponent) internal in 0.50 so I wouldnt rely on it. can you not just keep some relationship in a class IComponentData via AddComponentObject?

worn valley
vivid robin
#

Do you have a link to something that describes it / how to use it?

safe lintel
#

LinkedEntityGroup will instantiate and destroy all entities inside the buffer

vivid robin
molten flame
vivid robin
#

WTB hybrid rendering for 2022 πŸ˜›

rotund token
safe lintel
#

np, thanks

rotund token
#

technically with the code you're doing on mainthread you don't even need AddJobHandle

#

it's just a requirement of the libraries internal safety system though

half jay
#

How to properly write Unit Test to system using EntityCommandBufferSystem? I have problem that code which should be done by EntityCommandBufferSystem has no effect. Doing it like this

var system = World.GetOrCreateSystem<CreateBlockViewSystem>();
var syncSystem = World.GetOrCreateSystem<CreateBlockViewSyncSystem>();

m_Manager.CompleteAllJobs();

system.Update();
syncSystem.Update();
rustic rain
#

Is there a way to get singleton from monobehaviour (UI)?

#

I'm trying to think of a way to get input from UI into ECS

rustic rain
#

Assets\UI\MainMenu\MainMenuUISystem.cs(17,78): error CS0246: The type or namespace name 'UIDocument' could not be found (are you missing a using directive or an assembly reference?)
What

rotund token
rustic rain
rotund token
#

runtime ui elements does not work well in 2020

#

i would advice against ui toolkit unless you are willing to risk 2021 (what i'm doing)

rustic rain
#

brrrrruuuh

#

how am I supposed to learn current gen tech

#

if it doesn't work

rotund token
#

yes

rustic rain
#

I had trouble even installing it, how did you do it?

rotund token
#

i have no issue with dots in 2021

#

what's the problem?

#

(be warned, there is a good chance 0.5 breaks it though they have confirmed support for it but maybe not straight away so you may have to delay an upgrade if you use it)

rustic rain
half jay
rustic rain
#

Is there any way to delay when my system runs?

#

delay I mean

#

gets created in the first place

#

I want to initialize only after UI game object is created

rotund token
#

that should work from memory, let me check my tests
Why is your
m_Manager.CompleteAllJobs();
before
system.Update();
if you're only testing output of the ECBS it shouldn't matter, just a random observation

rotund token
rustic rain
#

I mean, I do find stuff in google

#

but it's mostly from 2019

#

and most guides from this year use deprecated stuff

rotund token
#

There's 2 parts, implementation of ICustomBootstrap let's you define what systems go into world

#

Defining UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP let's you control when the worlds are initialized

#

Unity's implementation is just htis

    {
        [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
        static void Initialize()
        {
            DefaultWorldInitialization.Initialize("Default World", false);
            GameObjectSceneUtility.AddGameObjectSceneReferences();
        }
    }```
#

so before the first scene loads, it creates your default world

#

so if you implement this yourself, you can wait till whenever you want (e.g. after you create gameobjects)

rustic rain
half jay
rotund token
#

yeah but you completed all jobs before the system ran

#

so you're not completing anything?

#

unless there's more code that isn't shown

rotund token
rustic rain
#

so, to implement my own bootstrap I use ICustomBootstrap interface or [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] attribute?

rotund token
#

ICustomBootstrap is used to control what systems go in each world

#

i.e. say you have server/client worlds you don't want the same systems to exist in both

#

so you can implement ICustomBootstrap on a class and unity will call this during world setup

#

this isn't your problem, you're problem is just timing

#

so you just need to define UNITY_DISABLE_AUTOMATIC_SYSTEM_BOOTSTRAP

#

and then call

            GameObjectSceneUtility.AddGameObjectSceneReferences();```
#

at some point in the app when you're ready for your entity worlds to be created

#

you don't need RuntimeInitializeOnLoadMethod

#

you could put it in Start in a monobehaviour or whatever you want

#

whatever framework works for you

rustic rain
#

ah, I see

#

I kind of see the way I can load my main menu scene

#

with this

#

and then load game world from it

#

so, world is entity related thing, right?

#

I'm guessing game objects exist in scene

#

not in world

devout prairie
#

Something i've never messed with in dots/hybrid-renderer is materials - i want to spawn a bunch of entities from prefab entities, but i'd like some to use a different material..

rustic rain
#

when you instantiate your prefab you can simply set component data to smth else

devout prairie
#

So my first thought would be i could either manually change the material of the entity or generate prefab entities variations and spawn those directly

rustic rain
#

well, if you only want to change material, just use AuthoringComponent in your prefab

#

and in Convert method

#

assign different components of materials

#

assuming you're using SharedData comps

#

it's just that simple

devout prairie
#

well my prefabs are inside a subscene so authoring component would of course run during conversion of the subscene, and i guess i could apply a shared component to the prefab with a list of mats, is that kinda what you mean?

#

and then when i instantiate the prefab, grab one of the mats and apply it to the entity

#

ie literally set the Material of the RenderMesh component after instantiate

#

just wondering if it is that simple, or if there's any chance it could break optimization of archetypes or material instancing or something, is this the best approach

rustic rain
#

oh wait, it's prefab

#

in that case just set random comp data

#

upon instantiation of your entities

#

just like you set data of your entitiy positon for example

devout prairie
#

yeahh

karmic basin
rustic rain
#

I keep getting these errors

rustic rain
#

GameObjectConversionSystem
Any idea what assembly is it?

#

I decided to split my project into assemblies

#

and I can't figure out what reference this system belongs to

#

Looks like Hybrid it seems

karmic basin
#

I'd say entities

karmic basin
#

Add another field with the camera one

rustic rain
#

Translation

#

what about this one

#

I know for sure

#

it's from physics

#

but what exact assembly

#

a lot of stuff actually missing

#

that is base dots

karmic basin
#

using Unity.Transforms;

rustic rain
#

finally it loaded without errors

#

whew

rustic rain
#

I still get all my entities and etc

#

I guess it didn't work?

pliant pike
#

has anyone else had any problems they've had where componentdatas not updating in the inspector

plain hatch
#

Hey, I've got a question about the EntityCommandBuffer:
Is it possible to create entities via an ecb inside one job, and use references to these entities in a job scheduled after that?

graceful mason
#

I tried it, afaik an entity is just an int type of data really (not an actual int but similar), so yes you can store a reference to an entity and use it. However, until the ecb is played, its just an int, and has no components πŸ™‚

misty wedge
#

Whats the consensus on Schedule vs ScheduleParallel? Use the latter wherever possible?

#

(assuming many entities)

#

(or lots of work to be done)

left oak
#

Well, not every job is safe to perform in parallel. Also, if your job does a lot of calculation over many frames, it might be better to just schedule it so that it doesn't hog all the worker threads.

worn valley
misty wedge
remote crater
#

Is it possible to have an "Ignore collision" component with data of entities it ignores collision with? If not, maybe in the future.

haughty rampart
misty wedge
#

The reason I ask is because it kind of ties into my question above (Schedule vs ScheduleParallel). I was planning on rewriting a few systems to use what you mentioned (not adding / removing components but using e.g. a boolean to signal change), but this means that the system will iterate over many more entities each frame. Would ScheduleParallel (almost) always be there correct way to go for something like this?

haughty rampart
#

In my opinion yes. I'm rarely using .schedule

tranquil jay
#

Hello, I have a 2d racing game which I am converting to 3d (bound to X/Z) and I wanted to convert it to **DOTS **as well.

I attempted to use **TinyRacing **as a base (I only have Start->Finish) but I can't figure out how to keep my prefabs in a Conversion World, so I don't have the originals existing in my actual World.

I could not figure out how to isolate the original prefabs, as **TinyRacing **is setup with everything pre-instantiated in the subscene.

Combine this with DOTS 1.0 coming "soon", I decided to disable the ECS/DOTS libraries for the time being and do 2d-3d work but I still want to reach out for help on the world conversion thing.

Thank you kindly!

coarse turtle
#

maybe I'm confused, why do you need the prefab in a conversion world?

tranquil jay
coarse turtle
#

as long as you don't query the entities with the prefab component you don't have to touch the original ones

tranquil jay
#

Pretty much like a Prefab in Project folders

#

They would still render

coarse turtle
#

instantiate a copy of the prefab entity and modify away

tranquil jay
#

and colliders

coarse turtle
#

I'm pretty sure Tiny has been shleved so I'm only speaking from experience with plain old entities package

#

EntityQueries typically ignore entities that are prefabs/disabled, unless you provide the option to query for them

#

so if it's rendering and interacting with your systems, then it might not be a prefab entity or your systems are querying for prefabs

tranquil jay
#

Do you have a simple project (like the tiny ones) with this setup? It's hard to wrap my brain around it

coarse turtle
#

the entity component system samples are pinned on this discord channel

tranquil jay
#

I tried to find one but somebody had the good idea to name it DOTS and google is uncooperative at finding me results

coarse turtle
safe lintel
#

dots 1.0 isnt coming soon, 0.50 might(but im still skeptical)

#

you can also look at the pinned messages here for docs and sample links

rustic rain
#

bruuuuh

#

I spent hours figuring out why my default worlds keep spawning

tranquil jay
#

Oh so the "conversion world" is something MYSELF have to create and provide to the GameObject -> Entity

rustic rain
#

and it just appears you need to implement interface for custom initialization

#

besides constraints

safe lintel
#

@tranquil jay no it happens automatically unless you are doing some sort of custom world initialization in which case I have no idea what happens with the conversion world

safe lintel
#

digging for what specifically?

rustic rain
#

it seems that default world gen is done by just this

#
            DefaultWorldInitialization.Initialize("Default World", false);
            GameObjectSceneUtility.AddGameObjectSceneReferences();
#

I hope at least

rustic rain
#

have you seen this tutorial?

#

it actually a really helpful one

#

I'v been digging it for a week now

#

Barely had any questions after most things I done

tranquil jay
#

I only started Dots since last Monday, it's a bit overwhelming and there's lots of dead stuff to sift through

rustic rain
#

ECS in general is completely new way of thinking

tranquil jay
tranquil jay
rustic rain
#

yeah, you can just go through beginning if you'd like

#

it goes through things that are used like 90% times (I think)

tranquil jay
#

will finish eating then go through it, it has potential, thanks @rustic rain

#

I am assuming there's an asteroid prefab to be instantiated, but the original asteroid is not present in the world, neither render or collision. It's exactly what I need, if so

rustic rain
#

yeah

rustic rain
#
public class NewSystem : ICustomBootstrap
{
    public bool Initialize(string defaultWorldName)
    {
        DefaultWorldInitialization.Initialize("Default World", false);
        GameObjectSceneUtility.AddGameObjectSceneReferences();
        return true;
    }
}

Am I doing smth wrong? I get funny exception here

rotund token
#

you are definitely doing something wrong here

rotund token
#

so you're basically looping over and over

rustic rain
#

oh well

#

ooooh

#

I get it now

#

this method is for custom DefaultWorldInitialization

#

ok

rotund token
#
        {
            RegisterUnloadOrPlayModeChangeShutdown();

            if (!editorWorld)
            {
                var bootStrap = CreateBootStrap();
                if (bootStrap != null && bootStrap.Initialize(defaultWorldName))```
rustic rain
#

GameObjectSceneUtility.AddGameObjectSceneReferences();

#

any idea what this is btw?

rotund token
#

it's for subscene stuff

rustic rain
#

like, what exactly?

#

or at least

#

approximately

rotund token
#
        // This can be used in custom Entity Bootstrap code to ensure currently loaded Game Object Scenes are added as references to the GameObjectSceneSystem
        // for cases where these scenes were loaded without the GameObjectSceneSystem (eg in the Editor and pressing Play).
        public static void AddGameObjectSceneReferences()```
rustic rain
#

how did you find it

rotund token
#

basically adds all scenes in the build config to the subscene list

rotund token
#

and i can see the entities source

rustic rain
#

IDE is Unity or?

rotund token
#

ide = rider for me

rustic rain
#

ah

#

fancy stuff

rotund token
#

(visual studios for most, but that's the issue. visual studios doesn't do this by default)

#

unity documents their packages very well and the best resource for learning is to just read it

rustic rain
#

yeah, I actually tried to dig into code

#

but my VS was only able to get inside of default world class

#

this static I ask about was white and wasn't expandable

rotund token
#

main reason i ditched VS

#

resharper adds support to VS and there might be a way to tell VS to actually show the source now natively i just don't know it as it's been too long

rustic rain
#

there probably is

#

just gotta find it

rotund token
#

i'm not confident there is

rustic rain
#

VS is capable of decompilation natively

#

doubt it won't be able to dig into source files

rotund token
#

well there is 1 way to do it

#

but it's via unity

#

and it causes problems

#

and that is to generate project files for all packages

rustic rain
#

oof, disgusting

#

I'd rather just use search in files lol

tranquil jay
#

me: Rider enjoyer

#

@rustic rain if you are a student, you can probably get a student Rider licence

rustic rain
#

nnnah

#

I am no official student sadkek

rotund token
#

yeah unfortunately pricing is not hobbyist friendly though i do appreciate all the groups they give it away for free to

#

but that's what employers are for

coarse turtle
rustic rain
#

yeah, I used ILspy as well

#

but mostly for decompilation

#

not looking through sources

coarse turtle
#

yea

tranquil jay
#

@rustic rain that project is incredible

tranquil jay
#

@rustic rain It answered my question, quite strange though, there is a MeshRenderer and MeshFilter that LOOKS LIKE to me like it's automatically converted internally

coarse turtle
tranquil jay
#

@coarse turtle it is indeed in this project (and was not in my testing proj) This is hella good news

#

thanks

hot basin
#

some more info dropped in

coarse turtle
#

cant wait to see the breaking changes πŸ‘€

#

going to be a fun day of refactoring πŸ™‚

deft stump
#

and then they forgot to drop the migration guide from 0.17 -> 0.5 XD

safe lintel
#

@rustic rain if you download the EAP you can evaluate them for free, they usually have a good number of them so i think that you could probably use rider for free for the majority of time although there would be interruptions

viral sonnet
#

still no accurate date except Q1 2022 -.-

#

alpha versions of 1.0

#

now that's funny πŸ˜„

robust scaffold
#

And none of my requests were answered. So sad.

viral sonnet
#

Top notch communication. We waited so long, with the frequency we are answering things 0.50 will be released by then. I'm half joking. The guys probably had a well deserved vacation.

#

I wonder what the breaking changes will be. Hopefully none too breaking πŸ˜„

robust scaffold
#

Archetype API may be changing. Hopefully with greater access though to the underlying unsafe pointers

rotund token
#

what IJobChunk 😬

#

i suspect the removal of IJobChunk will be one of the changes

#

(obviously with the replacements IJobEntityBatch/IJobEntityBatchWithIndex)

robust scaffold
rotund token
#

you mean for ISystem[base]?

robust scaffold
#

Yea. Only IJobChunk works with bursted OnUpdate

rotund token
#

pretty sure they just hadn't implemented by 0.17

#

as far as i hear all jobs should (hopefully) schedule fine in ISystem now

robust scaffold
#

Its strange basic IJob didnt schedule under burst strangely. I didnt really dig into it myself but I could possibly fix it. Maybe

#

But given 0.50 is releasing in a month or two, ehhh

safe lintel
rustic rain
rustic rain
rustic rain
#

Do you guys know how worlds are initilized?
If you load another scene. What happens to existing worlds?

#

do they stay or new world is generated and old is discarded?

rustic rain
#

Is there basically some kind of example how to do loads from one level to another in dots?

rustic rain
#

ok, with some decompilation digging, it is Cleaning up all worlds before loading next scene

#

that makes things way easier

#

sooo

#

if I want only certain systems to work

#

do I just remove them after game initialized?

#

or is there some way to prevent systems to be loaded in the first place

#

for example:
I want main menu scene only to contain some visual and UI systems.

While some game scene not to contain main menu related scenes

#

assuming list is not small

#

What is the way to achieve smth like this?

north bay
#

But IJob requires to to define a new job type because it's in the main unity core assembly

rotund token
#

changing scenes never really made much sense to me in an entities project. both my project at work and my personal projects only have 1 scene

#

(that's not to say you can't have many subscenes)

rustic rain
#

luckily by default worlds do get removed upon scene change

#

I just want to be able to swap between scenes nice and easy

#

without some useless system overhea

rotund token
#

if you like this workflow

#

highly recommend looking into latios framework

#

at least for ideas/inspiration

tulip robin
#

Hey guys
just why my mesh is transparent ? :/

frosty siren
tulip robin
#

yeah

#

work with this

#

but ugly and too heavy

#

i think the problem is URP

haughty rampart
tulip robin
#

but how fix it don't know

#

ahah mind

haughty rampart
# tulip robin

btw. you should not build up rendered entities with code. it is recommended to convert a gameobject and reassign changed components to that because unity adds many more components when converting a rendered gameobject to entity

tulip robin
#

yeah i see, will try to see the differencies

#

"you should not build up rendered entities with code" i know that is why i want to find solution

#

x)

haughty rampart
#

i just told you

safe lintel
#

hybrid renderer docs has the runtime api usage

#

@tulip robin

#

you are basically missing some components I think maybe chunk bounds and some other one, if you just convert a gameobject primitive you can see for yourself in the debugger, but id recommend just using the hybrid renderer api as any future changes to the components will then be taken care of by them instead of you

tulip robin
#

@safe lintel so i need to create my render system ?

#

yeah that's !

#

i m going to try to add WorldRenderBounds And ChunkWorldRenderBounds

#

ok ok the problem is vertex shader of material i think

#

so it doesn't work

#

No body ? :/

stone spoke
#

what's your problem?

tulip robin
#

Mesh are transparent with dots

#

and i think it's my material because he is shader

stone spoke
#

he UvTrain material?

#

what is it?

tulip robin
#

my i made it

#

Toon Shader Graph

stone spoke
#

what about the default material?

tulip robin
#

Same

stone spoke
#

what about your normals?

#

Maybe try to enable backface thingy

stone spoke
tulip robin
#

not run

#

it's only when i run

stone spoke
#

try changing the Render Face to both

tulip robin
#

oooh

#

you think triangles are reverse ?

stone spoke
#

yeah maybe

#

I'd try it just to see

graceful mason
#

is dots at all helpful for say a RPG with conversations unique per charecter??

#

I cant imagine it is trying to think what code you could write for it πŸ˜„

coarse turtle
graceful mason
#

i only know dots all my learning has been with dots, all my games are entirely created in scripts πŸ˜„ now wanna try a point and click adventure style but I think I will learn mono for that

coarse turtle
#

the text can pretty much live at a pointer since strings are just char pointers

tulip robin
#

@stone spoke not that

#

Seriously DOTS can manage URP ?

#

Or just make it from scratch ?

rustic rain
#

Dialogues shouldn't be limited to struct comps

#

pretty sure

#

dialogues should be kept as managed data

#

after all , it's not really per update process

tulip robin
#

DOTS for dialogues ?

rustic rain
#

feels like using Hz frequencies for notes lul

haughty rampart
#

dots for dialogues can be good as well. depends on how

rustic rain
#

that's the question

#

how

#

I can only imagine it using managed data

tulip robin
#

NANI guys

rustic rain
#

lemme check

#

which one

tulip robin
#

if you find cool but i stay on my position why use dots for dialogue

spiral flint
#

he was talking to someone else, mr. impatient

tulip robin
#

ooh fack

rustic rain
#

not entirely sure

#

but I think these are comps

#

system assigns itself

tulip robin
#

will try thanks

rustic rain
#

when you convert simple cube

#

without collider

tulip robin
#

😒

#

already did that

rustic rain
#

no rotation?

tulip robin
#

you think is that ?

#

nooo

#

cannot

rustic rain
#

maybe

#

Idk

tulip robin
#

ll try

#

😒

#

nop

rustic rain
#

did you try different material?

tulip robin
#

yeah

#

but same issue

rustic rain
#

so

#

the issue is that tree is transparent?

tulip robin
#

yes tree == test btw

rustic rain
#

so, does it work when you convert from game obj?

tulip robin
#

nop

#

nothing work at all x)

#

URP ?

#

yeah it's urp

#

I FOUND IT

#

thanks all for your replies !

graceful mason
#

did you set your project to linear colour space?

tulip robin
#

nop

robust scaffold
tulip robin
#

New question how manage clipping mesh of entities because when my camera is too closest that's disappear

rustic rain
#

dots has native unity physics

#

collisions are default in it for all physics bodies

north bay
stone spoke
rustic rain
#

ok, one thing I realised

#

there is no point doing UI with UI toolkit with dots rn

#

absolutely no compatibility in mind

rotund token
#

it works great (in 2021.2)

#

completely broken in 2020.3 though

rustic rain
#

I switched into 2021 too but

#

that's not what I mean

#

I just mean, that it's way too easier and better just do Monos

#

to control UI

#

rather than figuring out systems

rotund token
#

how so?

rustic rain
#

and then trying to figure out how to enable/disable them

#

for different screens

rotund token
#

like you are removing the need for monobehaviours and doing the exact same thing just better

rustic rain
#

I don't see any good solution for controlling UI through systems rn

#

you either need a lot of systems

#

or god system

rotund token
#

i have 1 system per 'panel'

#

panel being like, main menu, inventory, minimap, etc

rustic rain
#

yeah, and how do you avoid overhead of unnecessary systems?

rotund token
#

why do you consider them unncessary

#

do you use 1 monobehaviour for all your UI panels?

#

or do you not have a Monobehaviour for inventory, a monobehaviour for menu etc

rustic rain
#

no

#

What I mean is that when you are in game

#

your main menu

#

is just not here

#

meanwhile system will check for it's query every time unless you override it somehow

rotund token
#

i add up every single non-running UI system

#

and it adds to 0.00ms

#

on the profiler

#

like literally unprofilable

#

why is this an issue?

#

my entire UISystemGroup comes in at 0.01ms

rustic rain
#

where do you put it? near end of frame?

rotund token
#

in presentationsystemgroup

rustic rain
#

uuugh, I don't quite remember where is it

#

ah

#

found it

#

hmm

#

could you share any example of your UI system?

rotund token
#

pretty sure i posted it here the other day but

#
    {
        /// <inheritdoc/>
        public override uint StateKey => Keys<UIStates>.NameToKey("menu");

        /// <inheritdoc/>
        public override ComponentType StateInstanceComponent { get; } = typeof(UIMenu);

        /// <inheritdoc/>
        protected override void OnLoad(VisualElement panel)
        {
            var playButton = panel.Q<Button>("play");
            playButton.clicked += this.PlayButtonOnClicked;
        }

        private void PlayButtonOnClicked()
        {
            var uiState = this.GetSingleton<ClientState>();
            uiState.Value = new BitArray256 { [Keys<ClientStates>.NameToKey("go-in-game")] = true };
            this.SetSingleton(uiState);
        }

        private struct UIMenu : IComponentData
        {
        }
    }```
remote crater
#

Can you make a "DoNotCollideWith" list?

#

Apart from mask filters?

rustic rain
#

Layer filters?

remote crater
#

yah

#

Not too important, I know GameObject Land Unity has it

#

I think it might not be entities land

#

I can deny a trigger event with my own stuff, but denying the physics is trickier

rustic rain
#

Dots had extremely versatile layer filters in physics module

#

Two 32 size arrayd

#

To choose to what layer your entity belongs

#

And with what collides

remote crater
#

Sometimes you want to collide with one layer but not a specific guy.

#

Its okay, I'll make do, ain't that big.

#

I was just inquiring.

rotund token
#

thats one of the huge advantage of dots physics

#

You have the BelongsTo, CollidesWith

#

but also
GroupIndex

#

GroupIndex int An override for the bit mask checks. If the value in both objects is equal and positive, the objects always collide. If the value in both objects is equal and negative, the objects never collide.

#

you can force certain colliders to always collide or never collide

#

regardless of the layers

viral sonnet
#

is this for MB or UIElements?

rotund token
#

ui elements

#

it handles adding/removing from ui document, loading the asset, etc

viral sonnet
#

ah cool, I'm still on UnityUI. I'm thinking about making a jump to UIElements, thing is, I've even written a mobile app in UnityUI and I never had any issues really. Previously worked with NGUI and that had it's problems with scaling. What do you think are some huge pros of UIElements over UnityUI?

#

or, what do you like more about the approach?

rotund token
#

much more performant for starters

#

(if you've ever tried to run ugui on consoles or even a lot of it on mobile you'll know how bad layouts are)

viral sonnet
#

it's certainly draining too much battery for what it's doing, true

rotund token
#

apart from that, it's just a much better framework to use imo

#

(obviously it's a bit rough atm)

#

(but just conceptually)

viral sonnet
#

I need to look into it at some point how fast I can do a switch. It took quite a while to bring the whole app to UnityUI from NGUI and now I'd need a rewrite to UIElements. lol πŸ˜„

rotund token
#

yeah it'd be pretty painful to rewrite

#

i'm mostly using it because i decided to use it from the start

viral sonnet
#

what's the official state of UIElements for runtime? You say it works for 2021+?

robust scaffold
viral sonnet
#

ah i see, totally not up-to-date πŸ˜„

#

are you using any UI designers?

#

UIToolkit seems like a generic layout, right?

coarse turtle
#

pretty much

#

it uses yoga flexbox to do the layout

viral sonnet
#

thanks

remote crater
#

Thanks guys, only about 5 hrs left on the ECS/DOTS then 10-30 hours finishin networking for my MMORPG engine to be tested via MOBA: https://www.youtube.com/watch?v=nAkNxFiGzKA

I Didn't Start the Baron & Other Music Video Disasters I Made! https://www.youtube.com/playlist?list=PLOQ-J23AJUfTlLHkmqqFQIS8_ewaSaCqx

StarfighterGeneral.com Bloopers, Bugs and Outtakes: https://www.youtube.com/playlist?list=PLOQ-J23AJUfSCeuHkKQtL1Al70iAWnbSO

Been #1 in the world at every online ladder video game I played even the highest sk...

β–Ά Play video
tulip robin
#

nani

#

@viral sonnet rick is the best

viral sonnet
#

Funniest shit I've ever seen!

tulip robin
#

ahah

viral sonnet
#

looks pretty good already, having no SDF texts is a breaking point though

tulip robin
#

guys i have question for "fun", compute shader in ECS not possible ?

coarse turtle
tulip robin
#

Yeah

#

i tried

#

FindKernel in main thread

#

for me in my head "possible wrong",
ECS/DOTS Optimization CPU Multi-thread Parallelism etc...
Compute shader GPU calcul usage..

#

i know we can Instantiate(ComputeShader)

#

so why we cannot use it in jobs 😒

coarse turtle
#

When the compute shader executes, you're likely waiting for the compute shader to finish if you're trying to read the data back from the GPU

tulip robin
#

And i don't really want to do it on CPU with multi-thread it's useless in my case

#

@coarse turtle +1 yes exact

coarse turtle
#

so unity's bindings probably don't have a good way to have a job thread wait on the GPU

tulip robin
#

so why not wait it on thread etc

#

you have solution to give me ?

coarse turtle
#

No

tulip robin
#

F.A.C.K

#

real ?

#

I can to use the CPU or the GPU but not both?

#

whoaaa, no no i think we have solution

coarse turtle
#

Are you dispatching the work via a command buffer?

tulip robin
#

yeah you are thinking for DispatchIndirect ?

#

i can try it in coroutines "DIRTY time"

coarse turtle
#

thinking more GraphicsFence instead πŸ€”

#

of dispatch

#

it's been a while since I used those commands, so my memory is a bit fuzzy

tulip robin
#

ok ok not bad not bad

#

EntityCommandBuffers we are close but thanks you give me a way !
ExecuteCommandBufferAsync.

coarse turtle
#

ah, i meant more CommandBuffer from the UnityRendering API. You can create a graphics fence and poll whether or not the operation has been "passed" in the GPU

tulip robin
#

OH will learn about this thanks *10 billion

rustic rain
tulip robin
#

@rustic rain i was searching so i was out what i found at this time πŸ˜‰

#

but thanks ❀️

frosty siren
#

How would you write sorting groups for sprites in custom sprite rendering system if sprites are entities and theirs shader properties are components? I am out of ideas of how to do it without dramatic sort timings. Please help, any advices πŸ₯²

rustic rain
#

Any tip on how to implement "settings"?
Persistent data basically

#

Should I hussle with entities or?

rotund token
#

i personally bind all my settings to an entity but i'm not that opinionated on the best way to do, just how i do it

#

But this is my entire settings authoring setup.

    {
        [SerializeField]
        private Settings[] settings;

        void IDeclareReferencedPrefabs.DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
        {
            if (this.settings == null)
            {
                return;
            }

            foreach (var setting in this.settings)
            {
                if (setting == null)
                {
                    Debug.LogWarning("Setting is null");
                    continue;
                }

                setting.DeclareReferencedPrefabs(referencedPrefabs);
            }
        }

        /// <inheritdoc/>
        void IConvertGameObjectToEntity.Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
        {
            if (this.settings == null)
            {
                return;
            }

            foreach (var setting in this.settings)
            {
                if (setting == null)
                {
                    Debug.LogWarning("Setting is null");
                    continue;
                }

                conversionSystem.DeclareAssetDependency(this.gameObject, setting);

                setting.Convert(entity, dstManager, conversionSystem);
            }
        }
    }```

```    public abstract class Settings : ScriptableObject, ISettings
    {
        public virtual void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
        {
        }

        public abstract void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem);
    }```
#

basically just a collection of scriptable objects that self convert themselves to their various representation

#

but i have a few tools on top like a single searchable UI window that auto populates itself from these ISettings

#

making them entities has some advantage though - some of my settings are marked as Ghosts in netcode so I can send them from server to client if the server wants to make changes or player want to load mods etc

last swan
#

I need the amount of entities, CalculateEntityCount(), but I need a query for that. I have a Entities.WithAll<RandomComponents>().ForEach() and need the amount right before the ForEach - how can I achieve this?

#

I made it now like this, I hope this is right?

var entityCount = GetEntityQuery(ComponentType.ReadOnly<ReplayIdentifier>()).CalculateEntityCount();

 Entities.ForEach
  (
    (
     Entity entity,
     in ReplayIdentifier replayIdentifier
    ) =>
    {
    }
  )
rotund token
last swan
#

thank you πŸ™‚

hot basin
last swan
#

at work this is the style guide, we need to split it up like this for better readability - don't ask me why it is like this, it was decided before my time:)

hot basin
#

yeah I was wondering if that's a company issue because it's look so ridiculous that no sane human wouldn't subject himself to this πŸ˜„

#

Do you consider it a help in readability?

#

I'm asking because of course all style guides are just learned and are subjective

last swan
#

I mean, I am already used to it and know exactly where I have to look at what, so yes it is a help since everyone at work uses this style guide (obv thats what they are used for). this would be a bigger example:

Entities
.WithoutBurst() 
.WithAll<ABC>()
.WithAll<BCD>()
.WithNone<XYZ>()
.ForEach
(
    (
        Entity entity,
        in Stuff stuff,
        ref OtherStuff otherStuff,
        ref NoStuff noStuff
    ) =>
    {
    // stuff
    // very much code
    }
)
.Run();
#

But it is ||a pain in the ass|| (tedious) to format it like that xD

hot basin
last swan
#

Probably yes, never done this before πŸ€·β€β™€οΈ

frosty siren
# rustic rain sorting for what?

sorting sprites to render in proper order. Most commonly sprites with greater y and x coordinates renders first. But there is also sorting groups in unity, when sprites can be nested, so they goes with it's parent and only sorts with other children.

rustic rain
frosty siren
rustic rain
#

you have your own renderer?

frosty siren
#

yes

rustic rain
#

you might want to just add property for render order

#

instead of sorting

#

some comp that defines what render layer this entity belongs to

frosty siren
#

this is not what i'm talking about. I'm about case when N of your sprites has same order value and needed to be sorted by it's positions, like N characters, you want to sort your characters depending on it's positions on screen every frame

coarse turtle
#

how many entities are you sorting?

frosty siren
#

since we are in dots i want to sort as many as possible, but talking realistically without "sorting groups" problem i'm able to render ~60k sprites with 60fps, but after i've implemented sorting groups with simple SelectionSort O(n^2) then performance is terrible. obviously.

#

also for my needs it is about few thousands of sprites, not more

coarse turtle
#

im thinking spatial queries and determining which entity is in view of the camera would help limit the sort space