#archived-dots

1 messages Β· Page 201 of 1

pulsar jay
#

yeah I thought about that. but I basically want all the functionality without the rendering (meshes etc.) as the effect should chain through mutliple targets

#

still on the fence if it is easier to build a new one from an archetype or instance the old one and remove everything relevant to rendering

amber flicker
#

it sounds to me like the data might be better elsewhere - e.g. a separate entity, hashmap or something.. but I wouldn't worry about refactoring unless it becomes a bottleneck

pulsar jay
#

yeah makes sense. thx for the input

acoustic spire
#

How to mock DynamicBuffer? I'm using Add which does not override any interface.

hollow sorrel
#

@acoustic spire tbh I wouldn't bother with mocking, especially not dynamicbuffers since you should be able to assume things like this always work

acoustic spire
#

Just trying to reuse my ecs functionality in editor scripts. All I need is to replace dynamic buffer with managed collection since DynamicBuffer is strongly tied to entity manager and ECS.
Or mb I should try to get access to editor world and reuse the entire system instead.

hollow sorrel
#

ah I see, thought you were talking about unit testing

#

dunno what your setup looks like but could you just make an overload that takes a collection instead of dynamicbuffer? or use buffer.asnativearray

acoustic spire
#

Does NativeArray from DynamicBuffer reflect changes to the buffer?

#

DynamicBuffer is dynamic though. Can't really just replace it with fixed size array. It looks like would be better to create either wrapper structs around Add or just manually tick a temporary world in MonoBehavior

hollow sorrel
#

yeah it should reflect changes

#

but yea ticking an editor world is a good idea too (in general, dunno bout your use case), should even be builtin already, defaultworldinitialization.init with (true) for editor world or something if i remember right

#

tho that one doesn't manually tick

dark cypress
#

What's the difference between Job dependencies and UpdateAfter/UpdateBefore?

zenith wyvern
#

Job dependencies determine the order of jobs, UpdateBefore/After determines when systems OnUpdate methods are executed on the main thread

slim nebula
#

i know this question is subjective but... what should I use for animation character when using dots? I tried kinematica, and although I got it working, it seems that it doesn't play nicely with other animation stuff. or I'm misunderstanding things... What animation packages/components are people using with dots with success?

#

maybe these rigs and contraints just work on kinematica I dunno... gotta try it I guess

karmic basin
#

I hope i can use kinematica one day but in my mind it's still early tech

slim nebula
#

yeah it doesn't even build with latest packages anymore. I've created my own fork to deal with it. apparantly there's a decent motion matching package on the packagee store that's a bit more fully featured....

karmic basin
#

ANimation samples were updated with skinned meshes examples, but according to thelebaron, it's not finished yet #archived-dots message

slim nebula
#

I guess I want to choose the correct underlying unity tech before I go too far into packages though

karmic basin
#

It sure can be hard to tech-lock when underlying packages are evolving as much :/

safe lintel
#

so theres also the basic gpu animation package as well that joachim open sourced on github if you need like 100k characters with zero animation blending. afaik they wouldnt support physics ragdoll setups either

#

you can use mecanim which is tried and trusted but obviously doesnt really scale too well and means mixing gameobjects

slim nebula
#

could mecanim do dozens or maybe a few hundred characters?

safe lintel
#

or you can use dots animation which has a lot of rough edges, notably no visual node setup(at the moment but its coming, eta unknown)

#

dozens yes, hundreds eh not sure? maybe?

slim nebula
#

dots animation looked very incomplete and was hard for me to find information on issues

safe lintel
#

pick your poison πŸ™‚

slim nebula
#

is mechanim synonymous with the gameobject animator and rigging? or does it use that? or how are those related?

safe lintel
#

yes

#

yeah mecanim is the current gameobject workflow. i think its the name of the company unity originally bought and then integrated to what we know as animators, animator controllers etc

slim nebula
#

ah ok

#

i mean kinematica uses some of those components

#

I wonder if maybe I can indeed mix and match what kinematica is doing and mix that with rigging (IK, etc)

#

I guess I'll just have to try it and see if it works

safe lintel
#

didnt they pause work on kinematica?

#

or pause releasing packages for it

slim nebula
#

yeah. did they say for how long?

#

I guess it really needs dots animation packages to be finished before they can continue...

safe lintel
#

id assume they need to align it more with dots animation

slim nebula
#

I guess that probably means years...

safe lintel
#

what kind of game are you making anyway?

slim nebula
#

just fps

safe lintel
#

i saw that a while ago, really impressive for a one man job

slim nebula
#

I wonder if it supports rigging constraints and IK

#

Works with most IK systems straight out of the box ***

#

probably better documented than kinematica

#

i might have to try this... I dunno

#

w/e well thanks for the overview @safe lintel I think I understand more now

dark cypress
zenith wyvern
#

Job dependencies are a completely separate thing from ECS systems. You can micromanage how jobs are scheduled within a system or even between systems by passing around job handles if you want. Typically you can just ignore them and dictate how your game behaves based on the order of systems. Obviously if you have a system that spawns entities then a system that destroys them, you're going to have very different results depending on which one runs before the other.

#

Unity uses job handles internally to manage dependencies between systems if two different systems read from/write to the same component. But it has no way to know what logic you're going for just from that.

dark cypress
#

For example: If I schedule a job that moves some entities, and then immediately after schedule another job that moves them differently, they are guarenteed to run in the order scheduled, and the latter job will be dependent on the former because both write to Translation?

zenith wyvern
#

Are you talking about jobs scheduled in a system? Two jobs in the same system? Two jobs in two separate systems?

#

If they're in separate systems and they're both writing to the same component I'm not sure the order is defined in any meaningful way. It might just be based on how the systems are named for all I know.

dark cypress
#

Wow, that's something that isn't very well mentioned in the docs.

zenith wyvern
#

If they're in the same system then yes they will run one after unless you mess with the job handles yourself.

dark cypress
#

So I need to pass the handles to guarantee inter-system order, and not just UpdateBefore/UpdateAfter.

zenith wyvern
#

I mean...what would you expect it to do? How do you expect it to know what order you want those systems to run in if you don't tell it?

dark cypress
#

Then I don't get it.

hollow sorrel
#

if writing to same component then they should run in order of scheduling

#

afaik

zenith wyvern
#

But if you don't specify the order of the systems, how do you know which one gets scheduled first?

#

Probably by name right?

dark cypress
#

I specified in the question that I schedule 2 jobs 1 after another. If I schedule a job that moves some entities, and then immediately after schedule another job that moves them differently, they are guarenteed to run in the order scheduled

#

I guess that statement is correct then?

zenith wyvern
#

If they are in teh same system yes.

dark cypress
#

What if they are in 2 systems, and 1 runs after the other?

zenith wyvern
#

Then yes

hollow sorrel
#

oh that, yea if you change name it changes ordering (tho dunno if it's actually related to name or just triggers a change), but it'll be the same ordering for the entire runtime

dark cypress
#

Okay, thank you.

#

Now the scheduling finally starting to look less magical.

light mason
#

Wondering if someone could help me with question

#

when coverting an GO to an entity I dont see a scale component data

#

i see the Local

#

LocalToWorld , translation and rotation

#

so i need to do something so see scale

#

or do i have to set scale through local to world

worldly pulsar
#

I'm pretty sure the default conversion never adds the Scale component. NonUniformScale is added if scale is not (1,1,1), otherwise it's just Translation/Rotation

zenith wyvern
coarse turtle
# light mason so i need to do something so see scale

if you want scale from the LTW matrix, you can grab c0.x, c1.y, c2.z (which is the diagonal of of the 4x4 matrix) if the Scale/NonUniformScale components aren't added
See @worldly pulsar's msg below (I forgot about that case)

worldly pulsar
#

You can't if the matrix has any rotation in it (e.g. rotation matrix for 90 deg around Z has c0.x = c1.y = 0)

safe lintel
#

just add the scale component πŸ˜‰

void girder
#

Why are we unable to call SetSharedComponentData with an EntityQuery on a entity command buffer?

#

Only SetSharedComponent can take in an entity query

light mason
#

Ok thank everyone

#

I added scale seems to be the simplest solution

dark cypress
#

Can't believe there's still no easy scale authoring in the inspector tbh.

forest pike
#

Just to confirm:

nativeArray[0] = 0;
nativeArray2 = nativeArray;
nativeArray2[0] = 1;
nativeArray[0] == 1 (?)
nativeArray2 = nativeArray;
nativeArray2.Dispose();
nativeArray still valid?
north bay
#

'nativeArray' won't be pointing to valid memory anymore since you disposed 'nativeArray2' which points to the same memory as 'nativeArray'

forest pike
#

okay cool

light mason
#

does anyone have a code example i can look at for adding a component to a child entity using Entities for each

#

currently im doing this

#

Entities.ForEach((..... ref DynamicBuffer<Child> c) => { EntityManager.AddComponentData(c[1].Value, new MyComponent{Value = 1.1f} ); ...

#

as .Run() no WithoutBurst() and WithStructuralChange

#

Im in tiny it impossible to see why its failing ...

safe lintel
#

you're making a structural change though

zenith wyvern
#

What's the error you're getting?

#

If it's not showing up in the console try running your game from a terminal. As idiotic as it sounds that's helped me track down a few obscure problems

#

Since it will show the exception in the terminal at least

light mason
#

who do i run tiny in ternimal

#

who

#

how

zenith wyvern
#

From command prompt (or whatever terminal for your system) in your build directory, run the exe

light mason
#

so buid to standalone then run the game?

zenith wyvern
#

Yeah

light mason
#

ok let me try that thank you

#

do yo see any isues with the code above

#

can i pass a buffer in like that ?

zenith wyvern
#

I don't see an issue with it assuming you're using WithStructuralChanges and assuming that index is valid

#

I mean you should probably be passing your buffer as in if you're not writing to it but that wouldn't cause an exception

#

In Tiny you should always be building to standalone for debugging by the way, the editor can attach to your game when you use build and run and give you exceptions (usually). Plus build times are way faster than other targets

light mason
#

ok that a good tip

#

thank you

forest pike
#

How do I conditionally dispose NativeArrays in a struct my job uses? I have a 3x3 kernel of chunks with most of the allocation being persistent, but if I'm on the edge of the world I JobTemp allocate some empty arrays (because null isn't allowed). I'd like to only dispose of the JobTemp arrays.

zenith wyvern
#

I don't think there's a built in way to tell how a native container was allocated. You need to track it yourself

jovial bobcat
#

How do I get dots

safe lintel
#

the pinned message has more info @jovial bobcat

ocean tundra
#

Whats this new .WithFilter i see mentioned on the fourms?

zenith wyvern
#

It lets you specify a list of entities - the query will only accept those entities as valid (assuming they also match the query)

#

I haven't tried it, I think I read it's not working right yet

ocean tundra
#

Oooo interesting

#

i assume those entities are in a native collection of some sort?

zenith wyvern
#

NativeArray

ocean tundra
#

whats the use case for it? I'm struggling to see uses for it

#

i guess optimisation? i could have my own way of tracking entities that need to update and feed that into it

zenith wyvern
#

Exactly

sleek idol
#

hey guys just found out about this discord after months of scratching my head, are the devs on here at all or just users?

ocean tundra
#

just users i thnk

safe lintel
#

like once in a blue moon a dev might say something here

sleek idol
#

what are you guys working on?

#

i'm making an rts with ecs

ocean tundra
#

im working on networking for a rts game πŸ˜› and then eventually a rts too

sleek idol
#

what sort of network stack are you using? we tried with unity netcode but didnt go so well

ocean tundra
#

yea not netcode, im stealing some bits and aiming to use unity.transport

safe lintel
#

retro fps

sleek idol
#

is dots useful for fps?

safe lintel
#

well, i think so otherwise this wouldve been a colossal waste of time πŸ˜„

#

i mean it could still be a colossal waste of time

ocean tundra
#

πŸ˜›

sleek idol
#

the thing we found is that ECS makes it possible to have zillions of things which is great, but syncing zillions of things over the network was extremely challenging, and actually we are limited by users upload rate, like lots of people have 8mbps upload rate in europe, so you got to fit everything into that

safe lintel
#

my brain isnt powerful enough to do networking unfortunately

ocean tundra
#

yea im coping planetary annihilations tech so i dont need to sync everything, and its wayy easier then lock step

sleek idol
#

PA did the stream of curve data right?

#

we looked at that but didnt work out with our goal of 10k units

ocean tundra
#

yup

#

supports way more then 10k

sleek idol
#

so we are lockstepping just small parts of the system (unit movement and firing) and everything else we stream out (eg bullet should die, hp should reduce)

ocean tundra
#

but costs a ton of memory on the server

safe lintel
#

i remember reading a while ago that eventually they wanted to support the lockstep model but id assume any meaningful sample for that is still ages away

ocean tundra
#

hmmm never seen that

#

well hopfully it will work well πŸ˜›

sleek idol
#

we did some math on working out how to send out unit-pathfinding-changes for 10k units and it was most of our upload budget already

ocean tundra
#

hmmm what are you sending? as you dont need to send it all at once, just for the units near the player and only there next 1-5 seconds of movement

sleek idol
#

"just for the units near the player"
well with a minimap that is nearly everything

#

we have a flat map (a square not a sphere) so assuming you have good intel you need position updates on everything

ocean tundra
#

yea minimap is annoying, havnt touched on that yet

sleek idol
#

do you have a link to your project i can check out?

ocean tundra
#

na nothings open or public πŸ˜› its WAYYYYY early

sleek idol
#

its nice to have some people to talk to about ECS

ocean tundra
#

but for minimap i was planning something like a quadtree, where where each grid gets set to a color depending on number of units and thats all thats synced

#

well less as its only changes

#

and its not a quad tree, its a fixed grid sorry

#

so basily ill be syncing a low res map grid, and then only changes to that grid every X (1 second)

sleek idol
#

kinda like a heat map of unit count ?

ocean tundra
#

yea basicly

sleek idol
#

if thats enough that sounds good

ocean tundra
#

yea it depends on what info you need

#

in that it would only be friends/enemies

#

but ill also want something like events (being attacked here, aily pinged here ect

sleek idol
#

those should be fairly small i guess

ocean tundra
#

yea hoping so

#

honestly just building all the networking is alot right now, but when i get a bit further along im planning to open source it

#

tho im not sure if i could.... as i plan to copy code from unity.netcode.... i should check that license

sleek idol
#

we were heavily inspired by some stuff from there too - they way they bootstrapped in client/server worlds was handy

ocean tundra
#

my early versions worked really well, but the inbuilt delay was annoying as, i will need to cover that by client animations and probably make it dynamic in some way

#

yea its pretty good, just not for rts πŸ˜›

sleek idol
#

what delay?

ocean tundra
#

the server needs to run a tiny bit ahead of the clients, (about 200 ms seems best to deal with network lag, but lan could run fine at 50ms) so when you tell a unit to move if your looking for it you can see the delay

sleek idol
#

is that really netcodes fault though? i think you'd run into that issue on any network platform ... my ping (from aus) to europe is 300

ocean tundra
#

no that was coded in on purpose, the curves only work if you have the next curve ready to go in time on the client, otherwise it looked terriable

#

tho some of it was a mistake, as i had the server updating only every 200 ms,

#

only some things should be at the low server tickrate

forest pike
#

what's a good design pattern for "fake nullable" native arrays? i've got a 3x3 kernel of chunks that I use to update my voxel world, but if the kernel is off the edge of the world I need some way to know, a valid placeholder array, and a way to dispose of the placeholder array. i tried creating an "empty" array and passing that to the kernel constructor so it can replace chunk data with the empty one if it's out of bounds, but now the safety checker is complaining about multiple jobs having access to that empty array. i can't really mark it as read only because it needs to fill the place of read-write arrays.

#

Okay, I tried [ReadOnly][DeallocateOnJobCompletion] on the "empty" array and just allocate it during the job, but now I get aliasing The writable NativeArray UpdaterJob.kernel.se.field.data is the same NativeArray as UpdaterJob.kernel.empty.field.data, two NativeArrays may not be the same (aliasing).

ocean tundra
#

it sounds like you need some sort of flag to process or not

#

i honestly dont know the answer for fake nullable arrays but cant you just have a bit flag to check to see if you should process edges or not?

forest pike
#

The issue is, if there's no valid data to fill one corner of the kernel with, what do I fill it with? I can't leave struct members uninitialized...

ocean tundra
#

fill it with default?

forest pike
#

And then, if I allocate an empty array for each out of bounds chunk, how do I conditionally dispose of the temp arrays on job completion?

#

Default: The NativeContainer UpdaterJob.kernel.se.field.data has not been assigned or constructed. All containers must be valid when scheduling a job.

ocean tundra
#

honestly no idea without understanding the complete code

#

i would still have a bunch of flags/bools and check those

#

but im definitly not understanding the whole thing

zenith wyvern
#

My brain can't make it past the word "kernel"

forest pike
#

lol

#
    {
        public ChunkData center;
        public ChunkData n;
        public ChunkData ne;
        public ChunkData e;
        public ChunkData se;
        public ChunkData s;
        public ChunkData sw;
        public ChunkData w;
        public ChunkData nw;
        [ReadOnly][DeallocateOnJobCompletion]
        public ChunkData empty;

        public ChunkKernel(VoxelBuilder terrain, int i, int k)
        {
            int max_chunk = FIELD_SIZE / CHUNK_SIZE - 1;
            empty = new ChunkData(Allocator.TempJob);
            center = terrain.chunks[i, k].data;
            n = (k < max_chunk) ? terrain.chunks[i, k + 1].data : empty;
            ne = (i < max_chunk && k < max_chunk) ? terrain.chunks[i + 1, k + 1].data : empty;
            e = (i < max_chunk) ? terrain.chunks[i + 1, k].data : empty;
            se = (i < max_chunk && k > 0) ? terrain.chunks[i + 1, k - 1].data : empty;
            s = (k > 0) ? terrain.chunks[i, k - 1].data : empty;
            sw = (i > 0 && k > 0) ? terrain.chunks[i - 1, k - 1].data : empty;
            w = (i > 0) ? terrain.chunks[i - 1, k].data : empty;
            nw = (i > 0 && k < max_chunk) ? terrain.chunks[i - 1, k + 1].data : empty;
        }```
#

this should give you an idea

zenith wyvern
#

Trying to pass empty arrays into a job that you just end up disposing doesn't sound right though

forest pike
#

it's painful but necessary since you can't nest nativearrays

#
{
    public NativeArray3D<int> field;
    public NativeArray3D<float> field_density;
    public NativeArray2D<byte> field_heightmap;
    public Vector3Int mins;
    public Vector3Int maxs;
    public int writeCount;```
ocean tundra
#

πŸ˜›

#

my brain hurts

forest pike
#
{
    public NativeArray<T> data;
    public int width;
    public int height;
    public int depth;
    public NativeArray3D(int width, int height, int depth, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
    {
        this.width = width;
        this.height = height;
        this.depth = depth;
        this.data = new NativeArray<T>(width * height * depth, allocator, options);
    }```
zenith wyvern
#

Is this using ECS?

forest pike
#

no, just jobs

#

I found [NativeDisableContainerSafetyRestriction], but it doesn't seem to travel down to the nativearrays in the chunkdatas and I still get aliasing errors

zenith wyvern
#

AFAIK the safety system will try to prevent you from having a struct with two native arrays that point to the same location in memory in a job. In this case I guess that would be the ones you're assigning your empty array to

#

Even if you use that attribute on all your chunkdatas it errors on you?

forest pike
#

yeah

#

is there some attribute I need to put on the chunkdata struct?

zenith wyvern
#

I would have thought that if those were causing the safety issue that putting the attribute on the container struct would have stopped it. Of course that might be a really really horrible idea depending on what you're doing with these arrays in your job, but I guess that's a different issue

light mason
#

Does Tiny support shadergraph, the dice doesn’t mention it specifically

zenith wyvern
#

No

#

It doesn't support any custom shaders yet

light mason
#

Dammmmm

#

Can I achieve shell shading in a render pass or some other way

forest pike
zenith wyvern
#

Yeah so it does appear to be what I thought

#

You could try adding that attribute to your arrays in the struct itself, really though I think you should just rethink the structure of your data. The ChunkedList I linked, or maybe a NativeStream or NativeMultiHashMap

zenith wyvern
forest pike
#

yeah, I trust that my code is safe so I'm just putting the attribute in all the dimensions of nativearray

light mason
#

I had an alias issue too interesting enough today

forest pike
#

thanks for helping me!

light mason
#

I gave up and split into 2 jobs

zenith wyvern
#

Well in this case they are aliasing but it doesn't really matter for what they're trying to do

#

Just the safety system is being very protective

light mason
#

I thought I would throw something on chat sice I’m away in the helped end but never helping

#

One day

forest pike
zenith wyvern
#

Disable safety checks

#

Those red chunks are from editor-only safety checks

forest pike
#

oh okay

zenith wyvern
#

Aka disposesentinels

forest pike
#

how do I do that?

zenith wyvern
#

Jobs->Leak Detection->Off Jobs->Burst->SafetyChecks->Off

#

Just remember to turn them back on. Unless you don't make mistakes

forest pike
#

now I can load up the job execute functions with stuff

sly jasper
#

If I want to try the ECS Visual Scripting, which version should I choose? Seems the 0.5.0 version is weird compared to the versions in youtube tutorials

zenith wyvern
#

I think the dots visual scripting was put on hold while they develop bolt integration

#

Latest version was drop 11 I think

#

But they aren't actively releasing it or keeping it up to date with new versions afaik

light mason
#

im really need some advice debugging here

#

in accessing children of an entity prefab. but keep getting a scrip error

#

.ForEach((Entity e, DynamicBuffer<Child> c, ...

zenith wyvern
#

What's the error

light mason
#

error is this

zenith wyvern
#

You can just do l.Value.Equals(gridPos)

light mason
#

yea that i should do for sure

#

but it not the error

#

errro is when i intoduce the dynamic buffer

zenith wyvern
#

Uh, can you be more specific

light mason
#

ok so this is waht i get

zenith wyvern
#

Why aren't you passing your buffer as in or ref?

light mason
#

desperation at this point

#

passing in as neither also fials

zenith wyvern
#

Did you try running your game from a console?

light mason
#

yea

zenith wyvern
#

Same exception?

#

It could be because you're causing structural changes before you access the buffer. All dynamic buffers are immediately invalidated from structural changes. If you move the Debug.Log(c) to the top does it still error?

light mason
#

let me test

zenith wyvern
#

Either way don't pass your buffer without ref or in

#

I'm surprised it would even compile with that

light mason
#

i seem to make broken thing compile... it my curse

#

no error

zenith wyvern
#

Right. So the solution is to access your buffer before structrual changes or just use a command buffer

light mason
#

ok let me test that... thank you

sly jasper
zenith wyvern
#

Yup they are focusing on gameobjects for now. I guess the plan is to integrate dots support down the line

#

So it won't be two separate things, you will use one solution for both ecs and gameobjects. Thats the long term plan afaik

pulsar jay
#

I am trying to sort a dynamicbuffer and copy the first n elements into another dynamic buffer. What is the best way to achieve this?

#

I am currently trying to intepret the source buffer AsNativeArray then use Sort and then used Slice to get the first n elements from it. But AddRange does not take a NativeSlice 😬

warm osprey
#

Maybe AddRange(mySortedNativeArray.GetSubArray(0,n)) instead of using slices?

sleek idol
#

myNativeSlice.CopyTo(myNativeArray);

#

oh you want a buffer

#
            myNativeSlice.CopyTo(myNativeArray);
            myDynamicBuffer.AddRange(myNativeArray);```
?
pulsar jay
#

@warm osprey didnt know about GetSubArray. Thought thats what slices where meant for

#

@sleek idol guess that would also work but GetSubArray seems to be more direct

warm osprey
#

Can someone tell me how to deal with disposing several NativeLists created in OnUpdate() that are needed in a scheduled job? If I dispose them at the end of OnUpdate(), isn't there a chance they might be disposed before the scheduled job concluded? It's for implementing a resizable pool. So first I need to check the Entities that are still "free to use" (which is what I put in the NativeLists) and then I use those in the subsequent job (or if too few are free, instantiate new ones).

zenith wyvern
dark cypress
#

You can use .WithDisposeOnCompletion in ForEach as well.

eager jungle
#

Hey, I read the following in the Entity Queries doc today, but I'm not sure how this is supposed to be used. Can it be used with Entities.Foreach or we have to manually iterate chunks? in the later case, what's the most straightforward way to do it?

Do not include optional components in the EntityQueryDesc. To handle optional components, use the ArchetypeChunk.Has method to determine whether a chunk contains the optional component or not. Because all entities within the same chunk have the same components, you only need to check whether an optional component exists once per chunk: not once per entity.
https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_entity_query.html

pliant pike
#

I just had a weird case where .WithDisposeOnCompletion doesn't work in a job using WithoutBurst().Run() πŸ˜•

zenith wyvern
#

Because there's no jobhandle in that case

coarse turtle
pliant pike
#

I guess that makes sense

eager jungle
#

@coarse turtle thanks. Do you mean that if i use Entities.Foreach, the filtering is automatically done on the chunk? what if i want to make my code less verbose and not execute a portion of the job code based on the presence of a component for example (without having to duplicate my foreach)? do i need to use a cdfe?

coarse turtle
#

Probably you'll need a ComponentDataFromEntity, IJobChunk is pretty forward because you can do chunk based logic.

var data = GetComponentDataFromEntity<A>(true);
Entities.ForEach((Entity e, ref T a, ref U b) => {
  if (data.HasComponent(e)) {
  // ...
  }
})Schedule(...);

// As opposed to
struct JobChunk : IJobChunk {
  public void Execute(ArchetypeChunk chunk, ...) {
    if (chunk.Has(SomeChunkType)) {
       ...
    } else {
       ...
    }
  }
}
eager jungle
#

Basically what id like to do is: Entities.Foreach(Foo f, Bar b, Chunk theChunkImIn){ if(theChunkImIn.HasComponent(...)){ } }

#

yea OK

zenith wyvern
#

You can also just run two foreachs

#

One .WithNone the other without

eager jungle
#

@zenith wyvern wanted to avoid that, bc code is the same for the most part

zenith wyvern
#

Essentially equiavalent to the branch inside an IJobChunk

#

Static functions can help a lot in those cases

#

But yeah, you're going to pay a heavy cost using a cdfe inside a foreach

#

Not a big deal for small entity counts but it adds up fast

eager jungle
#

I get the static functions idea, I thought about it, but from a readability standpoint, that's not ideal...

#

at least in my case

#

thanks guys!

#

ive got another one maybe while Im here, do you know how does the registered queries on SystemBase behave with system inheritence?
I've got something like: MySystem : SignalSystem, and SignalSystem : SystemBase.
I've just noticed having one GetEntityQuery in MySystem completely overrides any query (GetEntityQuery, Entities.Foreach...) that got registered in code defined in the inherited system SignalSystem. That doesn't affect GetSingleton, HasSingleton (at least)
Any info?

coarse turtle
#

maybe use a RequireEntityQuery in your MySystem class in the OnCreate overridable method? I don't tend to use much inheritence with Systems

eager jungle
#

RequireEntityQuery would make the system run every frame, which is precisely what i want to avoid

#

i mean, this is not accurate. It's just bypassing everything, this is what i want to avoid

#

I want the system to run only when either one query from SignalSystem or MySystem is valid

#

currently, if i have no query in MySystem, it will run only when one query from SignalSystem is valid, but if i add any query in MySystem, it will only care about that one, and not about the queries from SignalSystem anymore

zenith wyvern
#

You can use EntityManager.CreateEntityQuery to avoid implicit system queries

eager jungle
#

@zenith wyvern I do for queries that I know shouldn't trigger the system by themselves. I just wanted to control when my system is running with registered queries, but bc of that inheritence problem, its harder

warm osprey
# eager jungle I want the system to run only when either one query from SignalSystem or MySyste...

You could have an array of EntityQueryDesc in SignalSystem. In SignalSystem you add it's EntityQueryDesc in OnCreate. In MySystem, you execute base.OnCreate(); and then add your MySystem EntityQueryDesc to the EntityQueryDesc array. Then you use that array for RequireForUpdate(GetEntityQuery(EntityQueryDesc array)). This way, the System will Update if either one of the EntityQueryDesc returns something.

eager jungle
#

@warm osprey thanks, that's a good idea. I've though of some ways to fix it, and this is definitely one of them. I'm just unsure of what's the current behavior with inheritence... that's my question

slim nebula
#

do blobs move? if I keep a reference to a struct in a blob, will that reference become invalid at some random point later? or does it stay in place until I dispose?

zenith wyvern
#

Blobs stay valid until you dispose them. I don't think they serialize automatically though, you need to handle that yourself

slim nebula
#

thanks. I think i got writing and reading down. not sure if anyone knows: does netcode just magically transfer blobs if I send a ICommandData with a blob asset reference field? or do I need to write special things?

#

I plan to transfer my randomly generated level data to the client so it can lazy load things as needed

karmic basin
#

πŸ€” Didn't try to send a BlobAssetReference yet. If not, you can write your own serializer anyway

#

can't you send the seed and re-random-gen the level on the other side ?

#

if you can reproduce result 100%, it will be way cheaper πŸ™‚

pulsar jay
#

Im curious if anybody has a nice solution for planning out systems? Like a special type of flow chart or sth.?

slim nebula
#

versioning is an issue. it's easier to just send a quick blob I think. It won't be much data

zenith wyvern
pulsar jay
#

Thx @zenith wyvern thats a good starting point

#

I am currently trying to approach it more from a flow perspective though

#

Like following one Component (in the current case Buffer) through systems and how they manipulate it

#

I think its mostly about planning out the order of systems. Not sure if the sheet from the best practice guide is helpful with that

zenith wyvern
#

Probably a good request for that best practices thread on the forums

#

You can use the entity debugger to get a nice visualization of system flow, but obviously that only works after they're already written, so maybe not so helpful during planning

pulsar jay
forest pike
#

I want to build some mesh data in a job and update the mesh on the main thread. How do I know when the mesh is complete? Should I give the gameobject a handle to my job?

forest pike
#

How do I access a job struct after it's been completed?

safe lintel
#

use nativearrays to pass around data from a job

forest pike
#

okay

zenith wyvern
#

To check if a job is complete on the main thread you have to store the job handle and check IsComplete every frame

light mason
#

in tiny there is this method

#

World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName("Name");

#

so my question is this, want to just have an enum w names ,

#

how do i get my enum to string

#

ToString is not implemented on System.Object for the Tiny profile. Please override ToString in the derived class if it is required.

#

is the error message

#

i really just want a good way to store my names and reuse.

#

typing them our everywhere is leading to many mistakes

gusty comet
zenith wyvern
#

NonUniformScale is a separate component. As for the matrix - it's a standard model matrix, there's tons of resources online about how it gets interpreted along with the cameraviewmateix inside shaders to give you your final rendered mesh

#

Nothing unique to dots

#

You can mostly ignore it and use float 4x4.TRS

#

Or just use the separate translate rotation and scale components

gusty comet
#

Yea - that's what the example I saw said but wasn't sure if I should understand the background or just go with it.

zenith wyvern
#

The transform system is pretty complicated. Personally I ignore it as much as possible and just use the simpler components

gusty comet
#

You mean the localtoworld system is complicated and you just use Rotation and Translation?

sleek idol
#

see NonUniformScale

zenith wyvern
#

There isn't really a localtoworld system, I more meant the innards of the whole transform system in general. Just the Translation/Rotation/Scale components should be fine for 90% of use cases

gusty comet
#

Yea I did actually see that later in the documentation when I was scrolling down. I'm not sure its ordered in a very good way and it just kinda dives right in without any kind of introduction. I guess that's just because DOTS is still experimental and mostly being released to users so the advanced users can test it

zenith wyvern
#

I've been complaining about that page for a year now, hahah. It really is a bizarre introduction but it does explain how the components are combined at least

gusty comet
#

It should NOT be entitled "Creating Gameplay->Transforms" for sure.

zenith wyvern
#

100% agree with you on that

light mason
#

is there a utils to create unique ids in tiny

ocean tundra
#

i used guids for a while

#

they should still exist in Tiny

karmic basin
#

@gusty comet make sure you click that blue button at the top of the page to view latest version, we are at 0.17 now

gusty comet
#

@karmic basin Interesting - I found it via google I didn't think it would link me to old versions. Thanks

karmic basin
#

you're welcome. They are pinned in this channel, and you can also bookmark with @latest to make sure πŸ™‚

karmic basin
gusty comet
#

Speaking of staying up to date, how confident should I be that the examples in the samples repository are not outdated? Are they being pretty good about updating the old code as they depreciate old methods of doing things?

#

Or will I find "bad" ways of doing things in the samples repo?

karmic basin
#

They update it yeah

#

and even cross-packages: they also updated netcode and physics packages with release of 0.17

#

can't talk about animation package yet, I don't follow closely yet

gusty comet
#

I know the unity physics samples are not reading any inputs for me but I've just started to dive into what's wrong

gusty comet
#

var input = GetSingleton<CharacterControllerInput>();

Should I see an entity called CharacterControllerInput in my entity debugger? Because I don't and maybe that's the issue?

#

Ah I can find it - it's called "Entity 1" instead. Either way its not reading my input values so maybe a problem with the input system package

karmic basin
#

Just to make sure

#

CharacterControllerInput is a ComponentData

#

GetSingleton just tells to Unity you put it only on 1 entity

#

I guess it optimizes the query, (I didnt bother to even check)

gusty comet
#

Yea - it's basically a singleton entity. I don't know if its for optimization or if it's just to keep the code "neat" ("neat" in this case is more complex but "neat" for advanced users). Either way, I do actually have the singleton it is just not being assigned any values when I provide inputs. Input debugger is showing that my inputs are being detected so something in the code that updates the singleton to correspond to my inputs is not working for me

rare dew
#

@karmic basin do you feel like help workshopping some multiplayer support in my jobs system with the new input system?

#

I am thinking of writing a blog post

stone osprey
#

So this is more a general ecs question, not dot specific. Lets say we wanna save our entities and their components in a relational database. We would have the problem that the database-id for each entity and component is different than their id on the client. So heres an little example, an Inventory{ Set<Entity>... } : IComponentData, as you can see our inventory references item entities by their entity-reference. Kinda makes sense and works. But if databases comes into play we couldnt do that anymore, so we would need some kind of assign each entity its database-id. So i came to the conclusion to give every entity an "Identity{ long databaseID }" and each component also includes such a databaseID referencing to its database table entry. This makes an entity look like this : Entity{ Identity{ id: 1231884812 }, Inventory{ id:9994922, Set<Identity> items }} as you can see we are now forced to reference "Identity" components instead of the item entities theirself. This way we would always need to query for the actual entity by its identity database id. Isnt there a smarter solution ?

#

Entities.ForEach((Inventory inventory) => { var entity = FindEntityByDatabaseID(inventory[0].databaseID); }) kinda sounds expensive right ?

karmic basin
rare dew
#

Fair fair πŸ‘

karmic basin
#

I'm happy you understand πŸ™‚

karmic basin
zenith wyvern
#

I mean it's not an actual database but you can basically think of it that way

karmic basin
#

Yeah but I think he's talking about persistence ?

stone osprey
#

@karmic basin @zenith wyvern For example a multiplayer server, we need some form of persistence. And if there hundred thousands of entities in the world, normal serialization isnt the best option here. Yes i am talking about persistence ^^ And of course... what do you mean you would bother with the db only when saving or loading stuff ? Well i understand that, but the database cant reference entity ids on the clients... Therefore the idea with the identity component.

gusty comet
stone osprey
#

And its kinda hard to only use the database for loading and saving operations. That requires some sort of automatic reference resolving. For example if you load an "Inventory{ Set<long> items}" component from the database, you would need an algorithm that converts this into an entity. So i thought the identity-component id is the best way so far

karmic basin
#

I mean that the client get the relations from your db, spawns entities in your world, then the rest of your client forgets the db ids. Until you save at least πŸ€”

zenith wyvern
#

"For example if you load an "Inventory{ Set<long> items}" component from the database, you would need an algorithm that converts this into an entity." Isn't that how serialization generally works in games?

#

You convert to and from your serialized format only when you specifically need to read or write to disk

karmic basin
zenith wyvern
#

Trying to deal with your serialized format at runtime when you don't need to doesn't seem right

stone osprey
#

Hmm... alright, then you would need to write the queries and the algorithm for the convertation by yourself. I only know hibernate so far and that is using class mapping. So you could load in an predefined "Player" class and it constructs this class with stuff from the database using reflection. But in this scenario we would need to write another converter that converts this class into an PlayerComponent for the ecs. This also sounds strange, like double the amount of work

karmic basin
#

Yeah I would only translate when loading client (or room, or whatever zone) or leaving

zenith wyvern
#

Have you actually tested just serializing your whole world using SerializeUtility? If you compress the output it might not be as bad as you think

#

And it's very very fast

stone osprey
#

Its an general ECS question ^^ Im working with a java based ecs on the serverside. This one also supports json serialization but its not recommended for large amounts of entities.

karmic basin
#

How often do you need to persist state ?

stone osprey
#

Heres an example of how hibernate does it... I basically just tell hibernate to load the "Inventory.class" from that id and it constructs an class from it. Then i take this class and add it to an entity. But well... it references an database object instead of an entity... @karmic basin Every 5 minutes ^^

karmic basin
#

Yeah it brings you a Model, web-style πŸ™‚

#

I guess that's okay to add your own serializer for specific cases

stone osprey
#

And it works pretty fine... but well... its not that clean because i need to iterate over database ids instead of real entity-references. But having a "Inventory" class for loading and an "InventoryComponent" for the ecs itself is also weird due to the duplicated code

karmic basin
#

5 minutes is not scary, I thought you were gonna say each frame 😱

karmic basin
stone osprey
#

Thats right :/ loose coupling is important. Im still a student and never worked in the industry, so i have no idea what the industrial standard for such things are. Do they really split it up into Database-Classes and ECS Classes and then convert the database classes to the ecs classes ? ^^ I guess i have the same problem with NoSQL aswell, because the entity ids arent real ids and change the next time i load the stuff back in

karmic basin
#

Do they really split it up into Database-Classes and ECS Classes and then convert the database classes to the ecs classes ?
You said it, "loose coupling is important". Allows more flexibility, easier upgrades, fine-tuning of platforms differences.... (I sure forget a lot of advantages). Of course like you said at the expanse of "double" the code.

#

Your model (what you call ECS classes but can be of any pattern) is your data representation at runtime. Your db, the persistent version.

#

Even the fields your data holds don't even match 100% between runtime and storing in db, if that helps you accept the differences more easily

#

Anyway Im' getting off-topic I guess

#

gtg eat, see ya

gusty comet
#

Can someone explain the syntax here?

#if UNITY_INPUT_SYSTEM_EXISTS
    ,
    InputActions.ICharacterControllerActions,
    InputActions.IVehicleActions
#endif
{```
coarse turtle
#

if the UNITY_INPUT_SYSTEM_EXISTS is defined - then DemoInputGatheringSystem must implement the InputActions.ICharacterControllerActions, InputActions.IVehicleActions

#

so you would check the Scripting Defines in the Project Settings -> Player

zenith wyvern
#

I doubt that would be in project settings, I assume it's defined from a script in the input system package

coarse turtle
#

yea there might be a line with #define UNITY_INPUT_SYSTEM_EXISTS

zenith wyvern
#

Or that's the idea at least

gusty comet
#

Yea I knew the whole #if UNITY_INPUT_SYSTEM_EXISTS thing I just wasn't sure what was with the ,'s and statements inside there

#

Oh I think I got confused by the spacing

#

That is because C# is not space sensitive

acoustic spire
#

Does it make sense to prefer reusing entities instead of removing and creating them again for performance reasons?

#

By reusing I mean clearing dynamic buffers and altering components

ocean tundra
#

@acoustic spire Probably not

#

mainly focus on reducing structural changes (adding/removing) components

keen spruce
#

It might make sense if you avoid all structural changes? or your changes are tag only with an EntityQuery thats very fast too

ocean tundra
#

I dont thing its possiable to have 0 structural changes, but just not going crazy and adding/removing TONS of components from tons of entitys

gusty comet
#

@acoustic spire From what I've heard watching advocates of DOD and coding with Cache in mind in general is that your CPU is actually idle 90% of the time even at 100% utilization because it is always waiting for new cachelines (with OOP-style code). So I guess the most important thing to consider with performance is that all your data is coming in a predictable way in a cache line that can be used for multiple instructions and that how that information is processed is almost irrelevant. From what I understand when you change the archetype of an entity it will move it to be with other archetypes so shouldn't be a difference between new entities and reused entities - it still moves the data around.

keen spruce
#

if you can use an EntityQuery to select chunks of entities there are efficiencies there when removing or adding on whole chunks

ocean tundra
#

@gusty comet Sounds right, the expensive part is when you change a archetype, that move data cost can get expensive

#

@keen spruce yea ive seen those new methods

#

havnt used them yet

acoustic spire
#

Changing archetype is adding a new type of component, right?

ocean tundra
#

yea

gusty comet
#

Or removing

ocean tundra
#

but honestly i wouldnt stress too much about it early on

#

even if you code poorly DOTS will still beat GO's

#

and there are soooo many ways to optmize when you need it

keen spruce
#

if your problem is one that lends itself readily to DOTS

#

ie doing the same thing on a lot of instances of the same data

ocean tundra
#

true, tho i find all my game ideas would work really well in dots

#

and i think most games have 'lots' of the same stuff

gusty comet
#

The word choice is basically that an Entity should not be thought of as a "container" of components because its not. The "archetype" is what kind of data the entity has an entry for - the entity itself does not hold data

ocean tundra
#

Entity = id

#

thats how i think of it

keen spruce
#

sure, but some of the best performance optimizations come from SIMD data types native containers, jobs and burst so you can use that well enough in standard GO

gusty comet
#

Yea all your data is in an array and the entity is like 'i' in a standard for(int i =0; i>size, i++); Its just an integer

ocean tundra
#

and ECS as a big sql database, each archetype = table, and each coloum = component

gusty comet
#

I actually find the whole ECS/DOD approach to be way more straightforward than the devs are making it out to be. The problem with DOTS right now is not that ECS is confusing its that their syntax uses EXTREMELY advanced C# syntax with lamda expressions all over the place.

ocean tundra
#

same, i love the core ideas

#

the c# syntax isnt that bad at least compared to manual jobs

gusty comet
#

This kind of syntax is really only taught at graduate level computer science courses. Those who are self-taught or have only high school / early college knowledge have no idea what lamdas are

ocean tundra
#

but it could be better

#

πŸ˜› I was self taught

#

and i had no clue what lamdas were for ages

#

but they arnt hard

worldly pulsar
#

I wouldn't call lambdas an advanced feature... like, all of LINQ is lambdas

keen spruce
#

the main thing you want is that the main heavy lifting code is working on sequential data and can take advantage of cache as much as possible so you hit main memory less often on the hot path.. most of the rest of the code isn't critical to performance because you only need a couple instances of random access

gusty comet
#

I mean I actually took a few graduate level programming courses when I was in college for mech engineering. They weren't even mentioned.

Of course, there's always been the ridiculous stereotype that Unity is for "entry" level game development and UE4 is where all the big boys are. I started with UE4 and quit because I got frustrated with all the handholding and Unity is WAY more complex if you don't just copy paste other peoples code (which is why Unity gets that rap)

zenith wyvern
#

Lambdas are a core feature of C#, they aren't that bad. But the way they use them, I can see that being confusing. You're just defining a function that gets analyzed and generated into a complicated job struct

#

Not very intuitive if you're just starting out

keen spruce
#

The best way to approach it is to just make it work as simply as possible and most code will not need to be optimized much at all.. whenever you see something is too slow start to optimize

ocean tundra
#

I do think unity should expand/explain the code gen part more, Its very very cool, but its another magic black box that we cant really do much with

zenith wyvern
#

Being able to see the genned output in the inspector is as good as any explanation they could give

ocean tundra
#

yea that helps

zenith wyvern
#

They should definitely do a better job of highlighting that feature for debugging/learning purposes

gusty comet
#

Yea that's the problem I have with the way the devs are handling it though. The devs are too big brain with their sample code it doesn't show a simple implementation of ECS it shows a really advanced implementation of ECS. If the whole point of using DOTS is that CPU speed is irrelevant when its not cacheing the data correctly (because it's always waiting for new cache lines) then why are they trying to make their actual system/process code as efficient as possible. It should be almost irrelevant as long as they set up their data correctly.

#

If they would add some documentation to the Unity Physics use case examples I think that would go a long way

ocean tundra
#

i really dislike the physics implementation, dosnt feel like DOTS to me

#

like why cant layers and collions just be components

#

like you define 2 entityquerys for a collion mask

gusty comet
#

Probably still a big WIP - they want to get everything working on DOTS first before they make it look like DOTS

keen spruce
#

also the physics in dots is designed by physics engine experts not unity/dots experts

gusty comet
#

That's also true. I'm having the same experience with the Input System. It feels like they tied it into DOTS when they should have just remade everything minus the backends in DOTS. Maybe they will at some point but their first step is to make it so you can actually make a full game with DOTS first.

safe lintel
#

i trust the havok guys to know whats best, but you could ask em why layers arent components, theyre pretty open. i had never actually considered that before

vagrant surge
#

you now the fun thing? Ive been remastering/porting a 2002 bullet hell game

#

and its as data oriented as it gets

#

there is a single array that holds every bullet

#

and a struct for boss, and other struct for player

#

and thats it

#

there is 1 single function that takes a bullet struct and updates its state. 0 abstractions, runs somewhere around speed of light

#

more than anything, DOD is coming back to the roots

#

do you need a Bullet class

#

and a HomingBullet subclass

#

and virtual Update

#

and a Renderer connected to the bullet

#

etc

#

fucks given = 0, just an array of 1024 of these

#

and its the entire game

#

in a way, DOD is about removing the bullshit, and focusing on what you need for your game

#

dod isnt about arrays and cache optimized stuff, but about removing abstractions and doing what you need, and then you can optimize it very well

gusty comet
#

I firmly believe DOD is just as easy to understand as OOP. I have no idea why the devs are trying to brace us for this new methodology it makes complete sense and isn't really more complicated than OOP. It's the syntax that's way more complicated - not the design approach itself

vagrant surge
#

the problem unity has is that DOTS and ECS has no editor support

#

so its ultra-expert only

#

you need to roll your own renderer for ecs ffs

#

and input system

#

and physics

#

using ECS in unity is super stupid right now

#

you will end quicker if you just make your own engine

agile dome
#

Even physics?

ocean tundra
#

?? theres DOTS editor tools, hybrid renderer (yes its bad but works) and physcis?

agile dome
#

Thought we had 2 physics engines to pick from

vagrant surge
#

yes, and both are mediocre

#

for now

#

the renderer is also very mediocre and breaks constantaly (also for now)

#

the editor tools arent enough. You still cant click on entities in the editor

#

and conversion workflow is a disaster that should have never happened

ocean tundra
#

?? you can click on entitys in the new entities window

gusty comet
#

I mean you make your own engine you're gonna have to make your own rendering system...and physics system...and input backends. Hooking Unity DOTS into Unity's existing architecture is a pain the ass but its better than throwing out the existing architecture.

Do I think it would have made more sense for Unity to split into two editors/engines? Yes. But I'm not ready to concede you're better off making your own engine...

ocean tundra
#

and i actually thing conversion is good, works well for me

vagrant surge
#

its easier to use SDL input that to find a way to use unity input in ecs

gusty comet
#

On input maybe. Rendering and physics no

vagrant surge
#

for rendering thats the harder thing, but there is stuff like Filament

#

i dont mean split

safe lintel
#

im so far from being an expert πŸ˜…

vagrant surge
#

i mean we are closing into 3 years of unity ECS

gusty comet
#

And lighting and particles and destruction system....

vagrant surge
#

and Entitas in 2016 had far better editor support

#

and still has

#

i dont know why but unity just refuses to have proper editor support for stuff like hybrid

#

it would only take them a few days

#

interesting enough, unity is falling behind quite hard on ECS tech

#

the C library Flecs does the same that unity ECS does, but has far more features

gusty comet
#

I mean we do have the entity debugger which is a pretty good tool

#

I believe one of the reasons for DOTS they cited was they wanted to bring more of the code into C# so users can modify or reimagine it. It's essentially getting more open source which yes means more complicated

vagrant surge
#

i dunno what they have been doing this last 2 years

#

seems like all unity does is spin in circles

#

when i started following the ECS stuff from unity when they first launched it, i wouldnt have ever imagined that 2 years later they would be at more or less the same spot

gusty comet
#

For me I'm stuck with DOTS. Unity w/o DOTS is not performant enough for open world games and Unreal Engine gets way too complicated when you step outside of the bounds of what it has prewritten for you. Their character controller is about 50,000 lines of code in C++ spread across multiple classes. If the character controller works for you great you don't need to worry about it but if it doesn't good luck. Cry Engine is even worse. Godot isn't quite ready yet...

vagrant surge
#

What people do in unreal is that they shelve the entire game framework

#

gam framework is a relic from the 90s

ocean tundra
#

na unity looks like any standard software product company to me
they have been growing super fast, so lots of new devs and tech debit kept growing
Leaders/marketing has expanded unitys targets (Movies, Architecture)
and core tech people have been voicing issues for ages, they finally got enough power to start changes but they cant just break things for everyone

vagrant surge
#

best is to not use it

#

and run your own code architecture

#

in fact, its super widespread

safe lintel
#

i dont think you can reasonably compare flecs to unity's ecs, given someone of my ability can make something with dots right now but using some standalone thing would take me forever to decipher and integrate to other systems

vagrant surge
#

basically every relatively big ue4 project just ignores BPs and the game framework

#

runs their game sim on just normal Cpp and hook it to ue4 for display

#

@safe lintel flecs ecs right now is more featured and advanced than unity ecs

ocean tundra
#

many games do that in unity too

vagrant surge
#

of course, it doesnt have the rest of the engine

#

what people are doing with flecs is to hook it to UE4

ocean tundra
#

rimworld being a good example

vagrant surge
#

you end up with a fairly similar environment as unity

gusty comet
#

Yep and UE4 is TOTAL CRAP when you take away blueprints. I can't tell you how many times I had to restart the editor because it doesnt sync with visual studio very well and it takes about a minute on a 3950x to compile a very basic project.

vagrant surge
#

of an ECS lib not attached to the engine

gusty comet
#

Not to RUN the project to COMPILE it which you need to do every time you would just do CTRL S in Unity

vagrant surge
#

opening times are a disaster...

#

there are some ways to sidestep it, but its mostly mitigation

#

no matter what happens ue4 (and ue5) will never get to the workflow of unity

#

tho maybe they are working on something

gusty comet
#

UE5 is a joke - it's just like a normal UE4 update they're not actually changing the editor at all

vagrant surge
#

when they were demoing some fortnite dev tools, they had some live link stuff that would connect to a network game and perform edits live

#

and lots of leaks about a ue4 ecs

#

which i wonder what they will do

gusty comet
#

Its nothing like UE3->UE4 which was an actual new engine pretty much. UE5 is a marketing gimmick for a new version of UE4

vagrant surge
#

it will be a bigger change

#

but more like 4-5 engine updates at a time

#

and big change in internals

gusty comet
#

Slightly - but it's not enough to justify calling it "UE5" like its some totally new engine.

vagrant surge
#

i would say its definitely justified

#

quite a lot of breaking changes are being done

#

tho projects will be porteable

#

that does scare me...

#

the goddamn ghost from the 90s game framework still being a thing

gusty comet
#

I mean I think Unity had more justification with DOTS to call it "Unity 2" or whatever if they wanted to

vagrant surge
#

only once its done

#

so around 2025

#

being generous

gusty comet
#

I dont think it will ever be done. Project Tiny may be done by 2025 but it won't be 'done' then

vagrant surge
#

not if they pivot it again

#

they did restart it like 3 times after all

#

kind of a shame, the idea of unity tiny is quite great

agile dome
#

Seems like it has been pretty consistent so far?

#

For the current iteration

vagrant surge
#

did they fix the samples?

#

last time i checked they were super broken

#

also conversion pipeline for tiny is such a mistake

safe lintel
#

sames have been kept reasonably up to date afaik

vagrant surge
#

as you are kinda forced to convert your entire scene

#

for tiny to work

agile dome
#

Pretty much only played with the racing demo, which was fine the last time I checked it

#

... the lack of play mode though

vagrant surge
#

i remember when i ran it through profiler

agile dome
#

Talk about lack of editor support

vagrant surge
#

and found that unity (on tiny at least) has such a huge overhead "per system" of the ECS, that you can run an entire equivalent game-sim in Flecs in just the time it overheads in acouple systems

safe lintel
#

not being able to play it right in the editor is kinda my biggest issue for not really testing it out further

gusty comet
#

Samples are always going to be broken when they're constantly updating them to match beta changes...

vagrant surge
#

about 0.2 ms overhead per system is insane

#

given that the bullet hell i talked about does its entire game state for 800 bullets in 0.1 ms

#

@gusty comet yet ue4 manages to keep all its samples and projects up to date

#

not really because they fix them evry time, but because they avoid code breakage

gusty comet
#

They're not converting from OOP to DOD

vagrant surge
#

@safe lintel honestly, right now if you are doing 2d games, grabbing something like SDL and an ecs and just doing it in C will end up being more efficient

#

(if its a pixel art simple 2d game)

gusty comet
#

Unreal Engine has nothing on Unity when it comes to writing code. It literally takes minutes to compile and the debug support is AWFUL

vagrant surge
#

debug support in unreal is lightyears ahead of unity

gusty comet
#

On literally anything else UE4 might have the advantage

vagrant surge
#

its slow yes

#

but unreal debugging its not even close

#

you can debug the engine

#

on unity you cant

#

and ue4 has myriads of debug tools

#

that unity doesnt have

gusty comet
#

Oh god no debugging on UE4 is why I left UE4

safe lintel
#

nah, not for me same reason as flecs isnt for me either. learning a framework and trying to integrate it to other frameworks to complete something(also c/c++) is just out of my league. dots is kinda sorta there, i mean enough for me to have an fps going without being an expert

vagrant surge
#

unity doesnt have:
network bandwdith profiler
replay system
high end logging system
debug draw system
screen counters in 1 line
many object inspector type things

gusty comet
#

Of course you cant debug the engine in Unity its not open source that's not really related to debugging your game though...

vagrant surge
#

it is

#

for very simple gameplay things, ye, you dont need the engine

#

but when you have an engine crash

#

which is similarly common in both engines

#

in unity you can just cry

#

in ue4 you can attach VS and see why it crashes

gusty comet
#

Unity has never crashed for me, UE4 has crashed at least a hundred times

vagrant surge
#

and then find what you were doing wrong

#

ive had huge issues when porting unity projects to console due to very bad debugging support

#

unity really isnt very stable on consoles

gusty comet
#

And I do so love t he bugs that you can't figure out how to solve in Unreal and then you figure out that your code is actually right it's just the editor needs to be restarted randomly sometimes to get everything to update properly

vagrant surge
#

or when the original authors of the code didnt knew to program and do insane stuff

#

one of the reasons i was interested on DOTS unity is because they were saying that they would have the DOTS parts as "open source"

#

i cant take unity seriously due to the closedness

#

itsfar too much of a risk, and just breeds rituals of "praying to the machine" to hope something fixes itself

gusty comet
#

I'm not 100% convinced on Unity. I basically find everything other than implementing code to be way easier in UE4 than Unity. But the coding experience in UE4 is so bad I am willing to tolerate the headaches from Unity's other systems if it means I dont have to code in Unreal.

vagrant surge
#

precisely that is one of the selling points godot is getting lately

#

right now godot is a tech disaster as the engine lead doesnt believe in "optimization"

#

but usability is good

#

will probably reach unity low end stuff fairly quick

gusty comet
#

Well base Unity (pre-dots) doesn't believe in optimization either

vagrant surge
#

godot is slower than even that

gusty comet
#

ouch

vagrant surge
#

dude didnt even implement LODs

#

or culling

#

had fancy PBR and dynamic GI tho

#

couse that sells the engine damn nice on twitter

gusty comet
#

Wait they really have PBR but no LODs?

vagrant surge
#

they had dynamic GI but no LODs

gusty comet
#

Crossing that off my list of engines to try

vagrant surge
#

even on the godot 4.0 refactor he focused on getting really fancy dynamic GI before getting lods

#

or culling

#

twitter driven development lmao

#

dude also shit-talks ECS and DOD

gusty comet
#

Yea I mean if you actually want to make a full game as an indie developer sadly your only real two options are Unity and UE4.

#

And they are so different from one another there's really no option if you're looking for something in between

vagrant surge
#

if its a very simple 2d game, its possible to use your own engine

#

if you are good enough of a coder

#

by doing that you can reach the Ultimate workflow speed

#

making "mario maker" in your own game as level editor

#

but thats for pixel art type stuff mostly

gusty comet
#

Well yea I mean you can write PONG in java. I mean like lets say you're making a game like .... minecraft or terraria level. Where its achievable to actually complete the game as an indie but its not Pong

#

Though I think Terraria actually doesnt use an engine

vagrant surge
#

neither does minecraft

#

Minecraft is also a very popular "first project" for people making their own engines

#

making minecraft on your own engine is actually easier than doing it in unreal/unity

#

as you can just render the voxels directly as you want, instead of having to find the proper way to send the meshes to gpu in your engine of choice

#

there is a dude on the Flecs discord literally making terraria/starbound

#

looks the same

slim nebula
#

what's the easiest way to get PhysicsWorld.CastCollider to ignore triggers?

#

I guess this doesn't apply to unity.physics

#

doesn't seem to work

#

the hits seem to have a rigidbody index even though they don't have a rigidbody on them

#

not sure how to tell if it's a trigger. Should I just get the collider component and check "istrigger" on it when the hit is added to the collector?

#

or maybe just check if it has a real rigidbody component on it?

safe lintel
#

thats for physx, let me see if i asked this question on the forums

slim nebula
#

I'm having trouble finding the answer for this for dots. so many results for the old physics

gusty comet
#

I get sub 2 second live coding compile times on UE4, I can literally change 1000 lines of cpp and it'll work without closing the editor, 100% of the time.

safe lintel
#

i think you can handle this in several ways and there may be a better way out there but here are my ideas:
you can set the layer of the collider to ignore colliders that are triggers(might be the easiest) so when you cast you dont have to do any specific checks
or query the material of the collider if its enabled for collision/trigger status when you get the collider

gusty comet
#

afaik that is not a thing in unity at all

#

ue4 vs unity in coding is a comparison of strengths and weaknesses. Neither side wins. Both sides have their ups and downs

slim nebula
#

@safe lintel how do I query the material of the collider?

#

like get some component on it?

safe lintel
#

trying to look it up

#

sec

slim nebula
#

ahhh i see this where the collider is created: var filter = new CollisionFilter { BelongsTo = 1, CollidesWith = 1, GroupIndex = 0 };

#

so can probably update that somehow

#

I guess tho I want it to trigger my triggers, but I don't want my character controller to have forces applied to it.

#

so I feel like the query is the right place for this, not the collider, but maybe I"m not 100% understanding

#

but I dunno how to query that

#

😦

safe lintel
#
        public static Material GetColliderMaterial(ref PhysicsCollider collider)        {
            Material material = Unity.Physics.Material.Default;
            Assert.IsTrue(collider.Value.Value.CollisionType == CollisionType.Convex);
            unsafe            {
                var colliderPtr = (ConvexCollider*)collider.ColliderPtr;
                material = colliderPtr->Material;
            }
            return material;
        }
        public static void SetColliderMaterial(ref PhysicsCollider collider, Material newMaterial)        {
            Material material = Material.Default;
            Assert.IsTrue(collider.Value.Value.CollisionType == CollisionType.Convex);
            unsafe            {
                var colliderPtr = (ConvexCollider*)collider.ColliderPtr;
                colliderPtr->Material = newMaterial;
            }
        }
        
        public static void SetColliderMaterialCollisionEvent(ref PhysicsCollider collider, bool enableCollisionEvents)        {
            var material = GetColliderMaterial(ref collider);
            if (enableCollisionEvents)            {
                material.CollisionResponse = CollisionResponsePolicy.CollideRaiseCollisionEvents;
                //material.Flags |= Material.MaterialFlags.EnableCollisionEvents;
            }            else            {
                material.CollisionResponse = CollisionResponsePolicy.Collide;
                //material.Flags &= ~Material.MaterialFlags.EnableCollisionEvents;
            }
            SetColliderMaterial(ref collider, material);
        }
slim nebula
#

whoa

#

ok so I'd check material flags for trigger or something?

safe lintel
#

yeah should be able to query the colliders material if its a trigger or not, i dunno if theres a better solution and i havent looked at this code in ages

slim nebula
#

I guess I need to somehow get a PhysicsCollider for that

safe lintel
#

though setting up layers to ignore it in the first place might be the more effecient way

slim nebula
#

the collider case collector only returns a collider key. not sure how to get the physicsCollider from that :S

#

but how would layers work? I want the player to trigger the trigger, not stand on the trigger

#

if I set the layers so they don't collide, then won't it also not collide for purposes of processing the trigger being hit?

safe lintel
#

thought you said you wanted to ignore the triggers? im confused πŸ™‚

slim nebula
#

I want to ignore triggers for my ColliderCast, because my character controller is using the result to handle movement

#

but I need unity.physics to tell me what triggers it collided with so I can do things like open doors etc

#

how is this not just a simple bool

#

I'm so confused 😦

#

fuck is the point of a trigger checkbox on the collider if half the things just ignore it

safe lintel
#

probably many ways to handle it but could just do another cast specifically for triggers? and the have movement cast ignore triggers

slim nebula
#

ok

#

how do I get the movement cast to ignore triggers tho?

#

I have to update the collider material 2ce per frame?

safe lintel
#

are you casting with the entity's collider?

slim nebula
#

I'm casting with my player's capsule collider, yes

#
            SelfFilteringAllHitsCollector<ColliderCastHit> hitCollector = new SelfFilteringAllHitsCollector<ColliderCastHit>(stepInput.RigidBodyIndex, 1.0f, ref castHits);
            ColliderCastInput input = new ColliderCastInput()
            {
                Collider = collider,
                Orientation = transform.rot,
                Start = transform.pos,
                End = transform.pos + displacement,
            };
            world.CastCollider(input, ref hitCollector);
safe lintel
#

so id make a component that stores a physics collider. in conversion, make another collider using the same shape parameters as your original on that entity and change the layer to only react to the layer that has your triggers, then in your system at runtime cast for triggers

#

though i dont know if this is the best way, just how I would tackle it πŸ™‚

slim nebula
#

hm ok. that sounds doable

#

thanks

slim nebula
#

ok I must be stoopid

#

how do I change the physics layer

#

is it just the layer at the top?

#

I've skimmed through like 5 youtube vids now reeeeeee

safe lintel
#

no, either using the Physics Authoring components or making a layer field manually in your authoring script and setting it there

slim nebula
#

I just saw this new component. ok cool

#

these authoring fields now make sense instead of being trash. thanks!

pliant pike
#

I dont suppose anyone knows how Unity chooses what systems to run say if you have two systems named the same and one is in a namespace?

slim nebula
#

I would hope that it would consider them as two separate systems and run both. but I haven't tested this myself

#

the whole point of namespaces is to have the same names. if unity doesn't treat these as two distinct types then something very unusual is happening there.

pliant pike
#

that's what I thought it might

#

it seems like its running the one in the namespace only

slim nebula
#

do you have "show inactive systems" checked in the entity debugger?

#

you could try [AlwaysSynchronizeSystem] on the system to help debug too

pliant pike
#

yeah I found that

#

I can see both systems in the profiler one's being run and the other is not

#

I don't really want both to run I was just curious

slim nebula
#

one probably isn't being run because no entities apply to it

#

(or because an exception was hit in another system before it got a chance to try and run it)

pliant pike
#

probably, but how is it picking which one to run first

#

the code in both is identical

#

in theory they should both be run

slim nebula
#

if you want to specify which one to run first you can use [UpdateAfter(typeof(whatever))] on your system

#

or UpdateBefore

#

but

#

I"m not sure the order is super deterministic. I think it's based on dependencies or something.... maybe it's alphabetical but... I wouldn't rely on it

#

if you NEED an order then use the UpdateBefore/After attributes to enforce the order

pliant pike
#

yeah I know, its just a curious confusing thing πŸ˜•

slim nebula
#

took me way too long to figure out CollisionFilter properties are masks and not just layer index number values

#

but got it workin. thanks again @safe lintel

gusty comet
#

So why do I need to SetSingleton every frame?

#

IE ``` protected override void OnUpdate()
{
if (m_BipedInputQuery.CalculateEntityCount() == 0)
{
Entity ent = EntityManager.CreateEntity(typeof(BipedInputComponent));
EntityManager.SetName(ent, "Input Singleton");
}

    m_BipedInputQuery.SetSingleton(new BipedInputComponent
    {
        Movement = m_BipedMovement
    });

}```
#

(which is basically from the UnityPhysics mine is just called a Biped and I set the name so its not called "Entity 0" in the debugger)

ocean tundra
#

does m_BipedMovement change every frame?

#

thats the only reason to setSingleton every frame

#

also wrap EntityManager.SetName(ent, "Input Singleton"); in #IF EDITOR

gusty comet
#

Ah - the value should yes. I guess I thought SetSingleton was just making that entity the singleton I didnt think it was actually updating its data

ocean tundra
#

sweet

pliant pike
#

how do you properly disable a system I've put Enable = false; everywhere and the only place it seems to work is in the OnCreate() πŸ˜•

#

and by the way I've found out it does run both systems if they named the same

zenith wyvern
#

Enable= false does work in OnUpdate, I've used it many times

pliant pike
#

I don't know it's weird I've got two systems named the same and one seems to work and one not it's confusing trying to figure out which is run, they both show they are running in the profiler no matter where I put the enabled πŸ˜•

safe lintel
#

why not rename one πŸ™‚

pliant pike
#

that's way to simple of a solution leahWTF

slim nebula
#

put a debug.LogError in one but not the other

pliant pike
#

the one I've disabled there is running harder than one I havent

#

yep its running the one I've put enabled = false, everywhere πŸ˜•

#
protected override void OnUpdate()   
    {
        Enabled = false;
        Debug.Log("This is ridiculous ");```
#

its hitting that, I even put a debug.log in the other system and it doesn't activate at all πŸ˜•

slim nebula
#

enabled = false will make OnUpdate not get called again but the code is already running

#

you'd need cs enabled = false; return;

#

setting a boolean can't terminate a function

pliant pike
#

ok yeah that's a good point

slim nebula
#

if you want it never to run then set Enabled = false in OnCreated

#

the other one probably doesn't run because there are no entities that apply to it

pliant pike
#

still I put enable = false in OnStartrunning() too and that didn't work

slim nebula
#

yeah I dunno the timing of that one

#

not sure where the enable check is relative to that

ocean tundra
#

pretty sure OnStartRunning is triggered right before onupdate IF then entity query has started matching and Enabled has changed from false to true

slim nebula
#

if it's per frame it probably finishes everything in the frame before the next check of Enabled

ocean tundra
#

or something like that πŸ˜›

#

it wont fire every frame

slim nebula
#

sorry im guessing I have never used it

ocean tundra
#

i used it like 2ce πŸ˜›

pliant pike
#

yeah onstartrunning I've had weird behaviour from that before

ocean tundra
#

better to have stuff in oncreate which only happens once

pliant pike
#

like double the amount of entitys created if I've used it for that

slim nebula
#

yeah everry example I see uses oncreate

safe lintel
#

just a reminder onstartrunning is a bit like onenable, it might happen multiple times

#

it happens any time the entity query count goes from 0 to 1 or more

ocean tundra
#

yea onenable would be the old equivant mb method

safe lintel
#

oh yeah you said that above, sorry didnt read πŸ˜„

pliant pike
#

np yeah I like to learn these things the hard way leahWTF(I dont really)

ocean tundra
#

all of dots is the hard way

#

πŸ˜›

pliant pike
#

yeah I don't mind I enjoy it, otherwise I would have gave up ages ago

#

OOP I probably really would have, I hate OOP leahA

gusty comet
#

So there's not float3 '.size' function right? float3's don't have any functions?

ocean tundra
#

what is size on a normal vector3?

#

it probably exists in the math library just under a different name

#

well unless im dumb theres no verctor3.size?

gusty comet
#

I mean sqrt(x^2 + y^2 + z^2)

#

I guess w/ vector3 it was called magnitude

gusty comet
#

Thanks....I actually could not find an API on Unity.mathematics anywhere

ocean tundra
#

all the docs are in the pinned message

#

tho they kinda suck

gusty comet
#

Yea...the pins here seem to be better than google or the forums for finding info

ocean tundra
#

haha yup

gusty comet
#

So am I crazy or is the movement component system in the examples actually a terrible implementation? It looks like they just took the OOP code and ported it to DOTS which is exactly what they tell us not to do. Is it just a proof of concept / here it works or is it actually how we're supposed to implement a movable character?

safe lintel
#

can you link it?

gusty comet
#

I mean for one thing they've got system code in the same file as their authoring / convert to entity code

safe lintel
#

ah thats way out of my league for judging πŸ™ƒ

zenith wyvern
#

I got the impression that was just thrown together for the dots fps sample. Not indicative of what you "should" do I think

#

Like the rest of that project it seems like they just mashed a bunch of stuff together to make the stage demo work

gusty comet
#

That's the impression I got but wanted to make sure

zenith wyvern
#

The single component with like 15 different pieces of data is a bit of a red flag

#

But hey, if it works it works

safe lintel
#

i feel like you need a lot of data for a character controller(so personally dont see it as a red flag) but tons of the other demos are/were really odd mixes of monobehaviours and dots and definitely felt hastily put together. this one is all dots though so i dunno if its that questionable?

gusty comet
#

Yea I have no idea whether I will ever wrap my head around writing code that responds to collisions without just using rigidbody and letting that do it for you

#

Before we had the charactercontroller which could do that but now that's been ported into c# through ECS and is implemented poorly so like...not sure what to do on that

#

Collisions are the one thing that is easier to work with (coding-wise) in UE4

#

I'm not sure how good this blog is but its the only thing I could find on this subject https://www.vertexfragment.com/ramblings/unity-dots-character-controller/

coarse turtle
#

seems pretty decent, looks like my 2d character controller

gusty comet
#

Dec 2020 too so not that old, should be up to date (which is rare)

coarse turtle
#

yeah - there is an open issue for a collision bug so you'll prolly be able to accommodate it

gusty comet
#

I actually don't even have the input working with a fresh samples project. The singleton does not match my inputs

#

Basically copy pasted the code into my project and it worked. The input system backends are enabled so idk

safe lintel
#

im personally looking forward to philsa's dots character controller when he releases that. i ported ufps over to dots for my current solution but it has a lot of jank and could probably use a rewrite as it was the first thing i did with dots, though it pains me to think about redoing it all

ocean tundra
#

Hi all, anyone know if its safe to save ComponentType in a buffer?

#

does the component type mapping to a type ever change/become invalid?

zenith wyvern
#

Yes ComponentType is safe to use in components and jobs/burst

#

Not sure when typemapping happens or how stable it is

ocean tundra
#

im saving it at conversion

#

so during conversion i add some componenttypes into a buffer element and attach that to a entity

#

hopfully it will be safe

ocean tundra
#

Does WithChangeFilter trigger on the FIRST frame if the entity is created from conversion (loading a subscene)?

vagrant surge
karmic basin
#

I think I'll read that one toohttps://ajmmertens.medium.com/why-storing-state-machines-in-ecs-is-a-bad-idea-742de7a18e59

Medium

Problems and solutions for implementing efficient state machines in Entity Component Systems

#

That title hooked me πŸ™‚

karmic basin
vagrant surge
#

@karmic basin thats the author of Flecs

#

he manages to do, alone, more than the entire ECS team in unity

#

Flecs is quite advanced and has features for days

#

from my tests is also same performance tier than unity ECS, if not faster at some things

#

similar archetype-based ECS, but he has some pretty insane tech on the internals

#

for example adding and deleting components in flecs is much faster than in unity ECS

#

at no perf cost on the other operations

#

accessing the components of other entities (outside of iteration) is also much faster, specially if you use its "reference" types, which cache parts of the internal ECS state to accelerate the "entity.getcomponent" call

karmic basin
#

Yeah I saw that, though I'm not interested in switching to C/C++ atm

#

But it's great to see other approaches

acoustic spire
#

Conversion world is included in release build or its results are "baked" in final scene? As far as I understand when a subscene is loaded it gets converted so conversion should happen in runtime anyway

amber flicker
vagrant surge
#

@karmic basin flecs is C, so it has C# bindings

acoustic spire
#

So that means that in release build there is no conversion right?

vagrant surge
#

ive heard of some people using it in unity

#

tho i dunno how well it works vs unity ecs

#

definitely more featured and far more flexible, but i wonder about the overheads

amber flicker
#

unless you do make use of runtime conversion

zenith wyvern
#

If you're using subscenes it should work on the first frame afaik

coarse turtle
pliant pike
#

you can use Debug.Log's in jobs right?

coarse turtle
#

Jobs yes, but not with Burst since it will detect the message as a string which isn't supported

pliant pike
#

can you not use this in bursted jobs Debug.Log($"The celldudes positios is {comparisonArray.Length}");

coarse turtle
#

yea, you can't use it. burst doesn't support interpolated strings - it will throw an error

pliant pike
#

it didn't throw an error so it must mean the job isn't running πŸ˜•

coarse turtle
#

well, if burst is disabled in the editor it would run

#

I'm assuming you don't see the log message right?

pliant pike
#

yeah I've tried withoutburst().run() etc

coarse turtle
#

hmm yeah it's probably not running then

pliant pike
#

its confusing I have the data being created in the components and yet the debug logs aren't showing

coarse turtle
#

got some code you can show?

pliant pike
#

I dont think its anything wrong with the specific code but...

coarse turtle
#

I guess the EntityDebugger can show you if your queries exists for the Job if you're using a ForEach

pliant pike
#
Entities.ForEach((ref CellData cooldata, in DynamicBuffer<FlowfieldVertPointsBuff> flowverts) =>
            {
                cooldata.cost = 1;
                for (int j = 0; j < comparisonArray.Length; j++)
                {
                    var tempobsbuff = comparisonArray[j];

                    Debug.Log($"The celldudes positios is {comparisonArray.Length}");

                    Debug.Log("Why isn't this displaying");

                    var tempbool = (flowverts[0].Float3points.x <= tempobsbuff.c0.x && flowverts[1].Float3points.x >= tempobsbuff.c1.x)
                                && (flowverts[0].Float3points.y <= tempobsbuff.c0.y && flowverts[1].Float3points.y >= tempobsbuff.c1.y)
                                && (flowverts[0].Float3points.z <= tempobsbuff.c0.z && flowverts[1].Float3points.z >= tempobsbuff.c1.z);

                    if (tempbool)
                    {

                        cooldata.cost = byte.MaxValue;
                        //Debug.Log("The values are" + cooldata.cost);

                    }
                }

            }).WithoutBurst().Run();```
coarse turtle
#

what's comparisonArray.Length? I imagine if it has a size of zero, your log statement would never show

pliant pike
#

yeah it comes from the job just above

#
var comparisonArray = new NativeArray<float3x2>(colliderents.Length, Allocator.TempJob);

            Entities.ForEach((int entityInQueryIndex, DynamicBuffer<ObstacleCollisionVerts> obbybuffer) =>
            {
                float3x2 tempfloat = new float3x2 { c0 = obbybuffer[0].float3verts, c1 = obbybuffer[1].float3verts };
                comparisonArray[entityInQueryIndex] = tempfloat;
            }).ScheduleParallel();```
#

the annoying thing is this code works exactly like it is but not in a namespace

coarse turtle
#

i'm not sure what you mean by that

pliant pike
#

I'm basically trying to tidy up my code by putting it in a namespace

#

so I created a new script and put it all in there and deleted all the junk

#

while keeping the old one with all the junk just in case

coarse turtle
#

o

#

yeah I guess I'm not too sure then, it could be a missing component in the entities, colliderents.Length is a size of zero πŸ€”

pliant pike
#

yeah in the new script the array size is zero but in the original it actually is 178

#

but even with that the values are getting set somehow from somewhere else maybe, I can't think of where else πŸ˜•

#

the code is identical too, I just copy pasted the code over(while deleting commented out code) except its in a namespace

#

maybe I should send a bug report πŸ€”

#

but then its probably a bug only I would be to stupid to encounter

coarse turtle
#

you can try the step debugger in your IDE and step through the code to see what's going on

pliant pike
#

it's usually kind of flaky when I use it and never help that well but I guess I could try

acoustic spire
#

What's workaround for storing HashMap in a component? I need a hashmap per component

stone osprey
#

When we serialize entities in dots... their structure and values are getting saved into a binary file right ? So what happens if we load those entities back into our game BUT we wanna change their structure as well ? An great example is an MMO... we define our first version of our archetypes and entities, players play and their entities get saved. Now a few weeks later we wanna publish an update and many components and initial values changed. How do we update those old entities to their new version ?

coarse turtle
stone osprey
#

And i think this update issue is a pretty common one... we often change the structure of entities. So how do we update those old serialized ones into "new" ones ?

acoustic spire
coarse turtle
#

it sounds like not baking entities would be a way to go. You could have the minimum components on the entities baked and then have a runtime system to bulk add new components to those entities @stone osprey

stone osprey
#

@coarse turtle Can you explain that a little more ? ^^ Like we check all entities upon loading if they are "old" and if they are old we convert them into their new types ? Or did i missunderstood that ?

coarse turtle
#

well my thinking is -> you pull your data from wherever and you construct a collection of components -> add them to the entities (I think there's batched apis for EntityManager, but I forget which ones you use)

#

you're not baking data if your archetype is going to change. But let's say you bake the entities initially with xyz archetype, but change it to abc archetype, wouldn't you need a patch for your game anyways if the structure of those entities change to accommodate for systems that relied on xyz structure?

zenith wyvern
coarse turtle
#

neat did not know that

zenith wyvern
#

As long as they only reference local variables

stone osprey
#

So we basically never serialize any entity that is going to change ? Is that what baking data means ? This actually sounds pretty bad in terms of flexibility :/ But when we change their archetype and their values we should simply run some sort of query that patches the components that changed in the database/file ?

coarse turtle
#

well baking data (entities) would just mean you're preparing the structure of the entities with whatever initial data they require

#

you can bake the entities and then do some manipulation on it, but idk how volatile you want your entity structures to be. So baked entities with components x, y, z can be come entities with components a, w, z through some system which changes the baked entities based on your new structure

#

imo, it sounds like you're circumventing an issue which is you don't know what structures your entities should be so I think it might be better to not embed the entities structure and just generate it on runtime. I do something similar where I just build the entities on runtime because data from an external source changes

stone osprey
#

Oh well... thanks :/ i see this is gonna be much harder than i thought.

#

I hate persistence... why cant we just call .save(); or .update(); on any object and it does all the boring stuff on its own

coarse turtle
#

well if you wanna do like save you could probably just write the data needed to a structure you can understand

#

and if your entity archetype changes, have a system to restructure the components into something more tangible that you need now

#

well that said I have no experience with any MMO dev - so take what I said with a grain of salt and that's just my naive approach πŸ‘€

karmic basin
#

Player data will be saved on server though ? πŸ€” So when you patch the server and the client to new version, you also prepare a migration script for your db (or save files, or whatever persistence source)

#

save file or db entry knows and keep track of lastClientVersion of course

#

and your patcher have methods for migrateFrom122To123(), migrateFrom122To235() to migrate from 1.2.2 to 1.2.3 or 1.2.2 to 2.3.5 in these examples

#

as much as any previous versions you wanna support

#

Welcome to Agile Software Dev lmao

#

it's pure hellfest happiness

stone osprey
#

Well that makes sense... so before each archetype change requires a script that updates all involved persisted entities. I actually have the feeling that this whole persistent topic comes way to short. We need more papers, examples or blogs about this whole saving, loading and updating of entities.

karmic basin
#

Yeah on Unity it's rarely talked about

#

Studios keep it for themselves I guess, and indies are just happy when they manage to get it to something vaguely right for their purpose ? πŸ€·β€β™‚οΈ

#

BUT you can get inspiration from software dev world

#

where constant updates releasing is more mature

#

so before each archetype change requires a script that updates all involved persisted entities
Just to be sure we're on the same page here. You don't plan to do it at runtime, right ? Your patcher forces everyone to download latest client version, which connects only to latest version servers. So you mutate persistent data only once, when the server-side patcher runs.

#

You don't really want to support older live versions

#

Hope that helps

pliant pike
#

I don't suppose anyone knows how comes there's two SimulationSystemGroups run in the first frame?

#

I think that's what's related to my problem above

karmic basin
#

From same World ? Is that even possible ?

stone osprey
#

@karmic basin Yes it does, thanks ^^ And of course i would run the script before the version goes live and only on the server πŸ˜„ nevertheless... json sounds great but i still cant decide between full serialization of every entity as json or some ORM mapping approach that saves the components in database tables

#

Or even if i just take a SQL database and use json fields :p

karmic basin
pliant pike
#

end of one sim group and beginning of next in first frame unless I'm mistaken πŸ˜•

#

the two systems are in those separate sim groups

#

the ones that doesn't work are in the first group

#

maybe that's because the subscene converted entities don't exist yet

#

maybe I should stop relying on loading and starting things on the first frame πŸ€”

slim nebula
#

how do I define physics categories?

#

my stuff works fine without them being defined but... it would be nice to define them. google just keeps giving me results for non-dots physics 😦

zenith wyvern
#

You need to create a physics category names asset

#

There's an option for it in the right click context menu somewhere

slim nebula
#

got it. do I link to this somewhere or put it in my scene or?

zenith wyvern
#

It's an asset so it just sits in your assets folder and the inspector automatically links to it

slim nebula
#

oh yeah I see it just works... ok

#

thanks!

acoustic spire
#

Is it possible to make job work during multiple frame updates? E.g. for some heavy operation in background

deft stump
#

yeah

acoustic spire
#

any references how to do that?

deft stump
#

pseudo code incoming

#
JobHandle myJobHandle;
Actual_Job actual_Job;
bool isSched;
void Update
{
    if (!isSched)
    {
        isSched = true;
        actual_Job = new Actual_Job();
        myJobHandle = actual_Job.Schedule();
    }
}
void LateUpdate
{
    if (myJobHandle.IsComplete && isSched)
    {
        isSched = false;
        myJobHandle.Complete(); 
        //dipose natives here
    }
}
#

sorry haven't touched jobs in a while

#

but hopefully you'll be able udnerstand

#

for native collections, you can use Permanent so it'll go over the 4 frame limit that TempJob has

acoustic spire
#

not so difficult as I expected. Thanks

whole gyro
#

I'm confused... according to the docs, Debug.Log works with Burst if using string literals. But when I add a GetComponent call inside my ForEach lambda, I get an error. Anyone know why this isn't working? Is this a bug in Burst?

[UsedImplicitly]
public class MySystem: SystemBase
{
    protected override void OnUpdate()
    {
        Entities
            .ForEach(
                (Entity entity) =>
                {
                    Debug.Log("This is triggering an error");
                    var comp = GetComponent<MyComponent>(entity);
                }
            ).Schedule();
    }
}

Error:

error Assets\Scripts\Systems\MySystem.cs(13,9): error DC0002: Entities.ForEach Lambda expression invokes 'Log' on a MySystem which is a reference type. This is only allowed with .WithoutBurst() and .Run().
#

As soon as a I comment out the GetComponent line, the error goes away. The annoying thing is that this error prevents entering playmode, even when burst compilation is disabled.

pliant pike
#

have you maybe tried it this way Debug.Log($"This is...

whole gyro
#

yeah, still get the error

stiff skiff
#

I actually wonder if calling Complete on a default JobHandle completes instantly

#

or break

zenith wyvern
#

Some issue with code gen, it should be fixed in next version

dark cypress
#

Wait, we can call GetComponent in Burst instead of passing ComponenData now?

ocean tundra
#

@karmic basin @zenith wyvern Thanks for the answers guys, in my testing in seems to fire on the first frame, was having another bug which was making me think it wasnt

#

@whole gyro Very confused with that, why do you have a GetComponent Call inside a foreach?

frosty siren
#

Mmm, guys, pls help. I use ISystemStateBufferElementData to cleanup entities after they was destroyd. So to access this buffer i use WithNone<CommonComp>.Foreach((Entity, ISystemStateBufferElementData) => {}). But what i see in inspector is when entity destroyed it's instead of disappearing just got new component "Cleanup Entity". What is it? Why? πŸ™‚

ocean tundra
#

@frosty siren I dont think the entity is destoryied, have you double checked the index and version? what used to happen is all other components would be destoried

zenith wyvern
#

Has been that way for a couple versions now

ocean tundra
#

oh cool

frosty siren
#

when ISystemState components not deleted from entity it wouldn't be recycled, so entity will have the same index and version, i guess

zenith wyvern
#

Yeah unity won't actually destroy the entity until you manually remove your systemstate component

frosty siren
#

But i do, well...try to do. But entity just look like this when i trying destroy it, and system can't access it

zenith wyvern
#

Are you trying to destroy the entity, or are you removing your component?

#

You need to remove the component

frosty siren
#

First i destroy it, then in system that uses ISystemState compont i do my logic and then remove ISystemState components, so entity can be recycled. All as usual

#

In a screen i attached Linked Entity Tag is still on entity, but it should be removed, cause this is common IComponentData

zenith wyvern
#

LinkDataElement isn't a state component?

#

If not then I'm not sure what the issue is, weird

frosty siren
zenith wyvern
#

Then you need to remove that buffer before the entity will be cleaned up by Unity right?

frosty siren
#

i mean LinkDataElement is state component. And i need to remove it at "clean up" stage

zenith wyvern
#

I'm not sure what the confusion is here. Unity won't destroy an entity until all system state components are manually removed by you

frosty siren
#

The problem is it seems like unity is trying to remove it (some CleanupEntity component added, btw what to use it :)), but LinkedEntityTag is not remove being just IComponentData

zenith wyvern
#

Oh so you're saying when you destroy an entity with your state components it doesn't remove some other non-state components before your cleanup system runs?

frosty siren
#

yes)

#

omg it's so complicated be not native speaker πŸ™‚