#archived-dots

1 messages Β· Page 162 of 1

tardy spoke
#

@minor sluice @amber flicker @tight blade @coarse turtle

First test of my garbage now that it's working, haha. It works surprisingly well... I'm not sure why that is. For example, in the video I didn't move the world 20km upwards as well, but I tried a test like that and it worked the same - it was exactly the same. Shouldn't the physics world be "bouncing" the character around a bit, affecting the camera? There must be some rendering going on relative to the camera or something compensating? I'm just surprised it's working this well and wondering what I did wrong/what's going on, haha.

https://youtu.be/l_ameCgMiH0

spring hare
#

Also does that scheduling time change reliably based on the job’s dependencies and number of scheduled jobs waiting on the local thread?

tawdry tree
#

Pretty sure the overhead for scheduling is pretty much static. Some diff based on circumstances, of course, but i reckon we're talking within one order of magnitude, and probably more like slowest ~= 2x fastest for normal cases.
(Caveat: Some idiot always find a way to break the system, one way or another 😜 )

spring hare
#

Do you have a good sense of the per-schedule cost?

#

In a build on Xbox or PS4 or just a mid-range PC

#

Seeing ~0.10ms for scheduling 18 jobs with various dependencies when testing in editor, build pipeline got a bit messed up today so I haven’t been able to check a build

#

That 0.1ms seems pretty steep though

#

That’s with jobs debugging off

#

Was wondering if that would collapse at all in a build, and how much

safe lintel
#

its definitely less in a build but at the same time still exists(if you disable jobs you get higher fps). i get like 300fps in a build, but if i reduce job threads to 1(not sure how to disable) the fps in a build goes up to 600. didnt test ms, also for some reason my editor is stuck with vsync on and disabling vsync has no effect so not sure what the actual numbers there are

humble mason
#

So, I have two different entity types and I'm trying to access both inside one ForEach. To do that I'm using GetEntityQuery.ToEntityArray(Allocator.TempJob) and then var myComponent = GetComponent... to grab a specific the first group of entities and I have access to the other entities from the ForEach lambda. My issue is that anything i write to the variables inside myComponent never shows up in the original entity that holds that component.

my TL;DR question is: how do I write to the variables of a component if i gain access to that component trough a GetEntityQuery and GetComponent? Thanks ❀️

tardy spoke
#

Can you not grab the components in the forEach loop itself?

#

Oh, two different entities, gotcha

#

Or are you trying to write to the OTHER component, in which case you might have to "flip it around" or something

#

Also are you getting any errors or anything when it's trying to make those changes? Because to me it sounds odd to be reading from data you are writing to in an ECS system? Do you need to be using an Entity Component Buffer or something?

#

I would imagine you would use the Entity Command Buffer which would then write the changes on the next "sync point".

You're probably writing the changes back to that nativeArray instead of the entities' Component values themselves so the changes never get "applied". That may be why you're not getting any errors as well?

humble mason
#

@tardy spoke yes I think I'm writing back to the nativearray. I was under the impression that it was pointing to the original data location

#

I'm in the process of looking up the entity component buffer now πŸ™‚

#

Yes, so you're absolutely right, for some stupid reason I thought that the nativeArray was a way to access the component data directly, like a thread-safe pointer or something (wouldnt that be cool)... Turns out it's just a copy that gets discarded, essentially an unrelated malloc

mint iron
#

@spring hare these numbers are a year old or something but 0.0040 was expected for simple IJob in editor on a windows PC about 7 years old, 0.0005 minimum possible when running two identical jobs back to back. 0.01 is more likely, anything to do with chunks or complicated structs would probably be in the 0.01-0.02 range. So your number is about 0.0055 which sounds about right.

spring hare
#

Thank you, really appreciate the sanity check there.

tardy spoke
#

Yes, so you're absolutely right, for some stupid reason I thought that the nativeArray was a way to access the component data directly, like a thread-safe pointer or something (wouldnt that be cool)... Turns out it's just a copy that gets discarded, essentially an unrelated malloc
@humble mason lol no worries man, I do that kinda thing all the time. Happy to help. 😎

#

Basically an ECB is just a way to "delay" actions until the next "sync point" where all threads finish so changes to stuff in memory can be made (I think that's how it works?) . The ECB just stores all the changes you want to make, then plays them back at the next "sync point". It seems a lot more confusing than it is. Basically the changes that need ECB's are anything that changes the structure of an entity, adding/removing a component. Modifying a component's value can be done multi-threaded somehow by magic in Unity's threading system

#

@deft stump i'm trying to build for Android on 2020.1 and also experiencing some weird errors. On mine it's freaking out about DOTS stuff, specifically ECS related errors.

deft stump
#

SetName is editor only @tardy spoke

#

and I'm not using the classic build pipeline, btw. I'm using the new one: SRB

tardy spoke
#

The scriptable one?

#

Maybe I'll switch to that one once you get it working, hahah

#

Hands up who would buy my game?

#

I call it Redline.

deft stump
#

The classic build pipeline does work for dots

#

if you dont have any subscenes

#

it will work just fine

tardy spoke
#

Ah, gotcha. Yeah, no subscenes yet... just trying to get my world to render now.

#

Hmm. It's rendering but ECS appears to not be running.

pallid carbon
#

I'm currently working with boids and I'm able to put maybe a thousand onscreen at once. I'd like the boids to react when shot with a bullet (a bullet object, not a raycast). However, I can't put a collider on the boids since 1000 colliders slows the game to a halt. Any ideas?

minor sapphire
#

Redline is the game I've been waiting my whole life for.

#

@pallid carbon I had 10k ships shooting each other at 60fps on my 6-7 year old i5.

#

1000 colliders is completely doable πŸ˜„

pallid carbon
#

I'm using a compute buffer right now, i couldnt get the ECS Samples package working due to broken dependencies. any tips?

minor sapphire
#

well I was using unity physics, that's about it πŸ˜„

#

this was before havok was released, have not tried havok

#

are you saying that with unity physics it's killing fps?

#

as in the dots physics

pallid carbon
#

I could put 1000 ships onscreen, then add a collider to each and BAM, 1 fps

#

no, i'm not entirely familiar with DOTS physics. I must have mistaken compute shaders being a part of DOTS

minor sapphire
#

oh you're using the traditional colliders?

pallid carbon
#

ye

minor sapphire
#

on traditional game objects?

pallid carbon
#

ye 😒

minor sapphire
#

just figured cuase you're in the dots channel you meant the new dots physics

#

ok, my tip is to use dots and enjoy the performance πŸ˜„

#

would be perfect for boids

pallid carbon
#

alright. tips to get started? the pinned stuff?

minor sapphire
#

yeah

#

it's a bit of a learning curve

#

and also it's not in production so not a good choice if you need something in production soon

#

and also still lots of limits

#

so read about what it can and can't do and then choose πŸ˜„

pallid carbon
#

Alright, thanks for the advice

minor sapphire
#

PC Build for my little DOTS ships experiment

pallid carbon
dull copper
#

DOTS isnt automatically even better for perf atm

#

In my testing rendering was slower and less functional. Physics choked even with few rigidbodies at higher update rates (where builtin physx just flies)

#

How I see it, you either have to do some ecs favorable brute force computing or just like the cleaner ecs code structure to pick dots today

#

And yes, I tested with hybrid v2

#

Then add on top that I even have to manually limit job system to only use few threads or it will totally tank the perf on stock dots packages....

#

It is just really far from perf by default atm

half jay
#

Im trying convert loaded list of addressables which store gameobject prefabs. I have this conversion component which het this List of addressables and should create same entities count as count of list but always getting one entity. Cycle calling properly but always PrimaryEntity same not different

gusty comet
#

What is the buffer component equivalent of entityManager.AddComponentData?

minor sluice
#

entityCommandBuffer.AddComponent

amber flicker
#
var buffer = GetBuffer<MyBuffer>(entity);
buffer.Add(..);``` is what you're after maybe
deft stump
#

Then add on top that I even have to manually limit job system to only use few threads or it will totally tank the perf on stock dots packages....
instead of scheduling jobs, all I'm doing is just running them on the main thread.
even with my hundred of bullets bullethell game, run > sched...

amber flicker
#

Just to make the point explicitly, whilst the cost of Schedule is fairly constant, the cost of ScheduleParallel varies roughly linearly with number of workers and so can quickly add up on a high core count. Speeding up schedule overhead is currently high on Unity's list I believe.

gusty comet
#

okay here's a big performance Q I need help with

#
        public Chemical Chemical;
        public ChemicalState ChemicalState;
        public float Matter;
        public float Temp;

With this struct, I can always know what ChemicalState is based on Chemical and Temp because Chemical has BoilingPoint and MeltingPoint data and we have the Temp right there.

#

The problem is, I probably need that ChemicalState enum directly in that struct. If I have to run Chemical.GetState(temp) over and over again every time, it'd be a serious performance issue

#

so is there any way to do new ChemicalComposition { Chemical = x, Matter = y, Temp = z } and have ChemicalState implicitly set?

#

I could just use a constructor but it seems like they really don't want you to use constructors on these structs

#

and there is really never an instance where ChemicalState would not be what is logical for the Chemical and Temp properties to decide.

#

I could use a public ChemicalState ChemicalState { get { whatever; } } but that doesn't feel any different than calling a function. Pretty sure that's what it is.

#

just going to use a constructor for now

odd ridge
#

@mint iron @zinc plinth when I use native arrays to iterate over data so that I can simd the computations, do my arrays have to be a size multiple of the width of my simd? for example, I want to add ints together. if I use 128 bits wide simd, do I have to make my native array a multiple of 4 so that I can compute in batches of 4? what if I have 3 pieces of data? will the simd compute the extra 1 as garbage? will the nativearray adjust the memory layout to always be a multiple of the simd width?

manic reef
#
        public Chemical Chemical;
        public ChemicalState ChemicalState;
        public float Matter;
        public float Temp;

With this struct, I can always know what ChemicalState is based on Chemical and Temp because Chemical has BoilingPoint and MeltingPoint data and we have the Temp right there.
@gusty comet Maybe it will be easier to introduce a static function CreateChemicalComposition(x, y, z)?

gusty comet
#

I actually think the best idea would be a constructor because I just realized I probably want a lot of other derivative values in that struct.

mint iron
#

@odd ridge I know it will work if you use float4/int4/bool4 arrays. In that case Burst definitely knows what you want and how to handle it. There has been talk of an ability to have things compile SIMD from single value arrays like NativeArray<float> which makes sense because you can process it 4 values at a time, and if length is not a multiple of 4 then it will just have some garbage processed as well in the last iteration. I have done this manually by setting the length to the next multiple of 4 and reinterpreting the array type but i am not sure if unity does that automatically. Would love to see some tests on it.

#

the case i'm thinking of i just had a float* and just changed it to float4*

odd ridge
#

@mint iron does your code work with regular float arrays, but only reinterpret to float4 for the simd part? I'm confused how I can create single entities if I have float4s

mint iron
#

i'm not sure how it turns out in a ForEach for example, i would expect/hope that if you have a simple enough loop it can at least do a small amount of SIMD per each chunk, but the chunks aren't accessed sequentially so its going to be slower than if you just had it all pre-grouped into a big array.

#

components are stored together so it shouldnt matter if you have a component with a grouped value as float4 or 4x the components with individual floats. if you accessed it with an IJobChunk for example, you just get the array of components and reinterpret it as float4. but sadly a lot of my SIMD work so far has been using burst outside of ECS, so im not sure how much help i can be there

odd ridge
#

okay thanks

mint iron
#

it would be cool to come up with an example project showing how common things get auto vectorized in ECS.

small arch
#

how do i give my job an array? it says that my array is not a value type and job structs may not contain any reference types

minor sluice
#

NativeArray instead of regular array

small arch
#

but can i do a multidimensional native array?

#

NativeList<int[,]> doesnt work: the type must be a non-nullable value type

minor sluice
#

oh

small arch
#

i think i found it

minor sluice
#

you could either flatten it out

small arch
#

nativehashmap

#

or something

minor sluice
#

or that yeah

small arch
#

i'll try that, thanks

deft stump
#

you can't do multi-d native array

#

and nativehashmap isn't a multi-d array

#

it's a key,value pair similar to the dictionary.

#

if you want to pass a multi-d array, flatten it first

small arch
#

why wouldnt hashmap work

minor sluice
#

basics to flatten,
the array size is basically [rowSize * columnSize]

#

to store a value:
array[row * rowSize + column] =

#

same with retrieval

#

hashmap is like a dictionary, it is a different use case

#

you map a value to a specific key, but in an array, you map a value to an index

#

and if you iterate over all indices of the array, you can get the row and column values like so

int row = i / rowSize;
int column = i % rowSize;
small arch
#

uh oh... does the hashmap start automatically formatting what i write?

#

because thats whats happening right now

#

after i've made that table

deft stump
#

what you mean auto formatting?

small arch
#

when i press specific letters like T in visual studio it lags for a second and i get this

#

and i get letter doubling now

#

so when i type something it types it twice

#

lol

deft stump
#

that's probably visual studio effing up

#

and also, using hashmap to store your multi-d array is a big no-no.
your key's essentially needs to be unique.
so what will be your key? your row? your column?
either way you need to repeat a key to store the next cell, which will result in overwriting the previous value.

minor sluice
#

if your use case is a 2 dimensional array, I would really just use a flattened 1 dimensional native array and leave the hashmap for a different usecase

small arch
#

yea i had a premade table and didnt feel like formatting it

#

i think i legit have to reinstall visual studio

#

lol

deft stump
#

for something that large... flattenning it will help your cpu, dots or not.

tardy spoke
zinc plinth
#

please use github with markdown if you want us to contribute

tardy spoke
#

Yeah, I'll switch it over if there's any interest / people actually using it.

#

Also I could just give people access to the Google sheet that that site loads if they wanted to add resources in the meantime.

deft stump
#

it's honestly more accessible for programmers to have stuff in github, imo

#

let's face it. github is facebook for devs

#

(change my mind)

tardy spoke
#

... no one is going to add any resources to this

#

lol

#

If you PROMISE to add some resources I'll throw it on Github for you.

#

Hahahah

deft stump
#

also alex, there is a much quicker way to install dots rather than going to the manifest file.
go to package manager -> press the "+" symbol -> add pacakage from git URL -> type: com.unity.rendering.hybrid -> press add then wait, because it takes a while to clone it to a temp folder in your pc.

tardy spoke
#

Yeah, that's probably a better approach is it'll get the newest version as well

#

Moving the page over to github pages now...

small arch
#

how do i do NativeList = NativeList

#

because i get an error that native array has been deallocated

deft stump
#

What are you trying to do?

small arch
deft stump
#

Compare? Or get the nativelist back from a job to the mainthread?

small arch
#

i made a new NativeList outside of the job and one inside of the job... then filled the list outside of the job with data... and said terrainMap(nativelist inside of the job) = terrainMapNative (native list outside of the job)

#

i need to get all the data into the job

manic reef
#

@small arch off topic but I recommend you to set initial capacity for the list. It will save you some performance and memory

small arch
#

ok

deft stump
#

have youyou newed your terrainMapNative?

small arch
#

terrainMapNative yes top line in the first image

#

terrainMap... no

#

error btw

tardy spoke
zinc plinth
#

@small arch try to use Unity.Mathematics stuff over Vector

#

so int3 here

small arch
#

i dont think vector is the problem in this case, i think it's terrainMap or terrainMapNative being deallocated for some reason, both of which have float values and not vector

#

unless you were talking about improving performance, which i might try

tardy spoke
#

hmm, this is weird. ECS runs in editor, but doesn't seem to run on Oculus Quest.

Just have a rotating cube and it doesn't want to rotate. Odd.

#

Login + collaborate issues

odd ridge
#

does the hybrid renderer work with URP?

safe lintel
#

Lateat package seems to clear up my stability issues with urp(the samplescene was crashing unity on play previously)

#

That said its still limited as their focus appears to be on hdrp, but the docs show whata supported by the hybrid renderer as far as features

tardy spoke
#

I've been using it without too many issues.

tardy spoke
#

Is there some sort of ECS initialization procedure for mobile?

In this video in VR (Oculus Quest, which is Android) you can see the left cube is rotating which is a monoBehaviour. The right cube is ECS, and it rotates when you hit "play" in Unity but not when built to Android. Hmm.

north bay
#

Does logcat say anything?

rancid geode
#

@tardy spoke is managed code striping on in the Project Settings?

tardy spoke
#

@sage gate disabled

#

@north bay I'm not sure, haven't really set up debugging tooling for Quest yet but it would sure be helpful, haha. Looking into how to get it's logs now.

coarse turtle
#

using their build pipelines? πŸ€”

tardy spoke
#

The build pipeline is fairly standard

#

Not using scriptable one or anything

rancid geode
#

oh, ECS only works with the Scriptable one (if you are using the standard Build Window it won't work)

tardy spoke
#

lol... well I'm glad that's the solution. never heard that before.

rancid geode
#

correction: seems like only the subscenes requires the new build workflow, still I would give it a shot before anything else

tardy spoke
#

Ah, interesting. I see there seems to be very little documentation on SBP.

#

I hope it's simple... I feel it may not be... haha

hybrid wind
#

is DOTS stable enough to use in 2020.1?

craggy orbit
#

no. which is why Unity has hidden it from the package manager

hybrid wind
#

big yikes

tardy spoke
#

What's stable "enough"?

tardy spoke
#

Yeah SBP looks like a huge pain to set up just due to the lack of documentation

coarse turtle
#

I'd look at the entity component system samples - I pretty much followed the example there to see how to set it up

tardy spoke
#

They all use SBP?

coarse turtle
#

I cant remember exactly, if it applied to all samples

tardy spoke
#

Yeah, looking at them now - how much work is this SBP thing really? Am I defining literally every build option or do you define the build options regularly (in Unity, IE selecting things like mipmapping etc in the UI) and it's working at a higher level than that?

#

My biggest concern is how to I have it send it to the Oculus Quest? I'll probably have to manually upload it every time, haha

coarse turtle
#

The settings are pretty high level - I think for most intensive purposes you just set up a common build dependency and then the platform you want to publish on effectively.

#

IIRC, most settings can really be found in Project Settings -> Player per platform

tardy spoke
#

I think there was something wrong with the import of that synty asset when I copied it in, I think I applied a mesh renderer or something to an object that shouldn't of had one and it was breaking the hybrid renderer

tight blade
#

damnnnn. well... thats what I get for relying on sequence order in an entity query.

tight blade
#

^ haaaa

tardy spoke
#

"This package provides support for building DOTS based projects to Android." it sounds like something I'd be interested in

tight blade
#

"yeah I bet you would" says the docs

#

hey no one happens to know if theres some way to modify a particular entity query such that they always return entities in offset order (like order in which they were created), would they? I realize thats just about certainly not a thing, but I thought I'd ask

tardy spoke
#

could write data to a component in them upon creation that has the order?

tight blade
#

yeah, there are a number of methods that would come down to "sort them"

tardy spoke
#

You want to sort something without sorting it?

#

People in hell want ice water

tight blade
#

yeah, thats more or less exactly what I want

#

or rather I want it sorted without sorting it.

#

and some ice water.

tardy spoke
#

What if you mark which one is the first one in memory

#

and then you know every one it selects next to it in memory was sequentially the next created?

#

... is that a thing?

tight blade
#

I think basically what's happening is that chunks are out of order. I was basically trying to make a system that works on 2 different archetype queries (because they're different physics objects) and operates on pairs of data, but it seems the query has the freedom to reorder the chunks it serves from. So if I did have to sort it, presumably I'd only have to sort the chunks, which is nice, but it'll take a good bit of work to tear apart the entity manager to build my own

#

like, to be more explicit, I create these physics entities in pairs, so I had a system that queried both types of entities and paired them up. the problem is one of the queries reordered the chunks, the other didn't so the pairs stopped being consistent

tardy spoke
tight blade
#

yiiiikes

#

thats such a bummer

tardy spoke
#

Dreams crushed

tight blade
#

another early adopter gut punch

hollow sorrel
#

you can build to android

#

you just have to make a build config asset

tardy spoke
#

... I'm liking what you're saying

#

Does it relate to using the Scriptable Build Pipeline or something?

hollow sorrel
#

create > build > empty build config

#

coulda sworn they had some example configs too but dunno where they went

tardy spoke
#

@hollow sorrel I can build with the regular build thing to Android/VR, but ECS doesn't work. Is that expected?

And the resolution is this fancy "build config asset"?

hollow sorrel
#

yes

#

regular build doesn't support subscenes

tardy spoke
#

It's not in a subscene

hollow sorrel
#

yea might not support ecs outside subscenes either dunno

#

do you have the scriptable build pipeline and platforms packages?

tardy spoke
#

Yes

#

oh platforms... maybe not

#

Any idea what it's called? DOTS platforms or something?

hollow sorrel
#

there's a base one called platforms and then another one for each platform

#

just platforms

tardy spoke
#

ah

hollow sorrel
#

ye

tardy spoke
#

And I ALSO need the specific one?

#

Can doooo

#

How did you even figure this out? Hahah

#

I've got both installed now though

hollow sorrel
#

there was a forum post when they introduced it, can't seem to find it tho

tardy spoke
hollow sorrel
#

oh i guess the example one only shows after you install the specific platform package

#

that explains that

tardy spoke
#

There's gotta be a manual or some shit somewhere, right?

hollow sorrel
#

not that i know of, but most of these settings are just a mirror of what the old build settings are so you could look up the docs for that

#

only difference is you get to choose what settings you specifically need rather than have literally all of them at the same time

tardy spoke
#

Will it just default the settings that are not selected? Do I have to throw any of this entities stuff in to have it compile to DOTS or is it... smart enough to figure that out? Haha

hollow sorrel
#

yea should be default if not selected

#

and no i don't think there's dots specific settings at least not when i last checked

tardy spoke
#

hmm

zinc plinth
#

@tardy spoke can't you live debug your android build ?

tardy spoke
#

@zinc plinth Haven't really looked into it too heavily yet, but I'm sure there's some tooling for it

zinc plinth
#

I would have started by this personally

tardy spoke
#

Yep. It built but made no difference. Will have to get the debug info from the Oculus Quest itself to see why it's so angry.

tight blade
#

anybody know anything about sorting nativearrays? rather than sorting the array in place, id like to get an array of indices for the rank order of a native array according to some key.. Is there an API that exists for that or do I have to put my datastructures and algorithms hat on?

zinc plinth
#

@tardy spoke I meant as in being able to get the log outputs of the build, so that you can print in your systems to see where you get errors and get the error logs

tight blade
#

ehm, maybe on a more fundamental C# level does anyone know how I would sort an array of Unity.Mathematics.Int2? the nativearray sort extension requires an IComparable type.. presumably there's some way to cast the NativeArray<int2> into something that works with the .Sort() ? I'm not a great C# guy...

#

oh I can define and create a Comparer class... OOP...

half jay
#

but im confused Buffer with element and im checking component for exists

amber flicker
#

@half jay I think you're using EntityManager to make structural changes to your entities whilst iterating a buffer - this causes the buffer to become invalidated for safety. On line 78 if you add .ToNativeArray(Allocate.TempJob) (syntax from memory) then dispose of children after the for loop, that should do what you want I think

half jay
#

@amber flicker ty it works

pliant pike
#

random question is there any way of locking a dynamicbuffer, like after creating it to the correct size I don't want to be able to change its size or the order of the elements

pliant pike
#

stupid question but does anyone know why this works

#
 DstEntityManager.AddBuffer<CurrentFoodPricesBuff>(GetPrimaryEntity(tempent));
            DynamicBuffer<CurrentFoodPricesBuff> tempdynam = DstEntityManager.GetBuffer<CurrentFoodPricesBuff>(GetPrimaryEntity(tempent));

            for (int i = 0; i < woggle.Count; i++)
            {
                tempdynam.Add(woggle[i].Price);  
            }

            DstEntityManager.AddBuffer<CurrentItemStock>(GetPrimaryEntity(tempent));
            DynamicBuffer<CurrentItemStock> tempothdynam = DstEntityManager.GetBuffer<CurrentItemStock>(GetPrimaryEntity(tempent));

            for (int j = 0; j < woggle.Count; j++)
            {
                Currentstock currentstock = new Currentstock { BackroomStock = 0, ShopfloorStock = 0 };
                tempothdynam.Add(currentstock);
            }```
#

but this doesn't

#
 DstEntityManager.AddBuffer<CurrentFoodPricesBuff>(GetPrimaryEntity(tempent));
            DynamicBuffer<CurrentFoodPricesBuff> tempdynam = DstEntityManager.GetBuffer<CurrentFoodPricesBuff>(GetPrimaryEntity(tempent));

            DstEntityManager.AddBuffer<CurrentItemStock>(GetPrimaryEntity(tempent));
            DynamicBuffer<CurrentItemStock> tempothdynam = DstEntityManager.GetBuffer<CurrentItemStock>(GetPrimaryEntity(tempent));

            for (int i = 0; i < woggle.Count; i++)
            {
                tempdynam.Add(woggle[i].Price);
                Currentstock currentstock = new Currentstock { BackroomStock = 0, ShopfloorStock = 0 };
                tempothdynam.Add(currentstock);

            }```
#

the second bunch of code I get an error saying cannot access buffer due to structural changes

zinc plinth
#

get your buffer from the Add, don't fetch it afterwards..

opaque ledge
#

when you add an item to dynamic buffer its a structral change i think, so that invalidates other buffers you might have reference to

zinc plinth
#

yes ^

pliant pike
#

well that's just weird it invalidates all other buffers leahWTF

zinc plinth
#

set your size with ResizeUninitialized, then add your elements by using AsNativeArray

#

and if you exec a structural change every buffer gets invalidated yes

pliant pike
#

fair enough, thanks guys

opaque ledge
#

i think the reason why adding/removing to/from a dynamic buffer is a structral change is because Unity might move the dynamic buffer to heap if you exceed initial capacity, so it does some chunk stuff

zinc plinth
#

^

deft stump
#

doesn't it allocate a new chunk for it?

#

okay

#

I dont understand this error

pliant pike
#

maybe its a class?

solar spire
#

PlayerData is a struct

pliant pike
#

I've had similar errors though where I've had to assign to a tempvar and then reassign that to the var that I want

solar spire
#

you need to do the normal thing where you cache a variable

#

and reassign it to the array

deft stump
#

so

psdata[i] = new PlayerData {value = 0;}
solar spire
#

same as you do with Vector3's and transform.position

#

where you can't just go transform.position.x = 1

tardy spoke
#

ADB logcat logs for Oculus Quest VR headset.

Seems to have some sort of error with burst compilation?

Could that explain ECS not working and the rest of stuff working? I guess it could since my monobehaviours don't use any jobs or anything I guess burst would touch...

safe lintel
#

@amber flicker do you know if that happens when you use withstructuralchanges too?

amber flicker
#

@safe lintel not sure i understand the question well... WithStructuralChanges is saying you intend to make structural changes - therefore unsafe to e.g. iterate in a buffer and you will need to create arrays and dispose of them as above.

rancid geode
#

@tardy spoke looking like a code stripping issue, IL2Cpp doesn't allow to totally disable it, so the way to fix that would be to add an link.xml and force include everything from Burst/Entities there

but this is more of a guess, haven't used Entities/Burst with Android/Quest builds yet

tardy spoke
#

@rancid geode thanks for the advice, but I'm unfamiliar with the SBP entirely, and without a manual I wouldn't be sure how to do that, haha. Any resources on adding that link.xml to include those? I'm just downgrading those packages for now to see if that fixes it.

#

Also should I be switching the build from mono to IL2CPP?

rancid geode
#

@tardy spoke actually this is not directly related to SBP itself, but how code stripping works. just add a link.xml file anywhere in your Assets folder or sub-folder and include the following content:

<linker>
  <assembly fullname="Unity.Burst" preserve="all" />
  <assembly fullname="Unity.Entities" preserve="all" />
</linker>

you may add more assemblies there as you wish

tardy spoke
#

Very interesting... Not sure how you learned this stuff but it's useful info to know, haha.

safe lintel
#

oh I see, need to drink more coffee

rancid geode
#

Also should I be switching the build from mono to IL2CPP?
@tardy spoke hmm, though that you were using IL2Cpp already, not sure if Mono has any forced stripping

tardy spoke
#

Nah I had it on mono, I tried IL2CPP and it built successfully. Could try again

rancid geode
#

I suggest you to open a thread on the DOTS forum anyway, Unity staff usually replies with any known workaround for issues like that

#

Very interesting... Not sure how you learned this stuff but it's useful info to know, haha.
@tardy spoke neither do I to be honest haha this is the kind of stuff that just happens to be an issue to you once and then you never forget about haha

tardy spoke
#

Yeah, well they'll probably want to be aware that Entities 0.13 potentially breaks Burst on Android, hahah

#

OT how many people here use Unity collab vs something like Github? Collab seems pretty... flakey.

hollow sorrel
#

@tardy spoke i once worked for a company that used collab and i wrote an essay to convince management to switch to git that's how much i hate it

#

dunno how much it improved since then but at least at the time it's a total noobtrap that makes you think this is how version control normally is and you'll start to hate programming and think the future is bleak because of it

#

maybe develop a drinking problem in the process

tardy spoke
#

Yeah I've noticed I've been drinking heavily of late

north bay
#

I still get flash backs of that "Checking For Changes" thing

tardy spoke
#

Lol, well, the weird thing about it is I don't think it actually cache's changes of Versions of Unity... it operates in a weird manner. It should store the entire state of the project if you restore, and like close Unity and go ACTUALLY back to it, but it seems like it uses some strange workarounds.

#

I don't feel very confident I could restore a project without errors

#

So then you end up deleting the library to redownload all packages and then for some reason it thinks that you need to re-sync with the server, and you can't do a force push overwrite, hahahaha

north bay
#

We switched from collab to plastic, handles big projects really well.

tardy spoke
#

Yeah, give me an alternative

#

My friend and I tried to use Collab JUST to build the world scene and it was a disaster. His changes would overwrite mine, vice versa, which they advertised it could do... we never got it to work a single time.

hollow sorrel
#

couple of cons from my notes 2 years ago apparently

  • slows down your unity startup because it has to index your collab files every time
  • no branching
  • can't search commits
  • can't see per-file changes
  • UI doesn't show more than last 5 commits or you gotta scroll through a paginator 5 commits at a time if you want to see older history
  • can't easily ignore certain files from your commit (as in pick the stuff you want to commit, leave your local debug changes local instead of commit that to server)
#

some of these might've been fixed since then

tardy spoke
#

no branching is reason enough

#

I mean branching isn't as common in game dev as it is in other stuff, but still for little experiments and stuff it seems pretty important

north bay
#

- slows down your unity startup because it has to index your collab files every time
That's such a big minus, especially for something like dots where your project potentially crashes 5 times a day.
Just having to wait 10 minutes every time so that the freaking Checking for changes goes away.
Unusable for bigger projects

hollow sorrel
#

give me an alternative
i use https://git-fork.com/ as client, github/gitlab for hosting private repos (they're both about equal pros/cons now i think so dunno which one i'd recommend)
there's a ton of different git clients or just commandline that some ppl use so might wanna check out others if you don't like fork, this is just what i settled on after trying the others

tardy spoke
#

Hmm, yeah might just go github, my project uses all vertex colors so it isn't huge in filesize or anything

#

my company used gitlab but I think for some reason is switching to github, I'll have to ask 'em why. I think it's something to do with CI runner reliability or something esoteric.

#

I feel Unity may want to develop experimental packages as "one package" at first and split the packages up when they're more mature/stable.

#

Based on how changing one dots package.... destroys the universe.

#

W/ a bi-weekly release cycle or something

amber flicker
#

two more important collab notes (though I must confess I sometimes use it for temp, one person projects when I'm v lazy) - deleted files are gone forever(!!!) and yea.. sometimes collab.tick() will just randomly make the editor extremely unresponsive (600ms main thread hang per frame or smth) I presume if it's struggling to reach the server or smth

tardy spoke
#

Welp. This is it. I downgraded to entities 0.11. If the ECS cube still doesn't rotate in Oculus VR... I will... continue trying other solutions. But I'll be upset about it.

amber flicker
#

you have a cube that's rotating in a build but not on oculus?

tardy spoke
#

Yes

#

It works now

#

Lol, I spent 8 hours on this problem. Just solved it by downgrading entities and related packages to 0.11.

amber flicker
#

oof

#

android build issue?

tardy spoke
#

Yes, I'm sure it affects Android in general. This is what it looks like when it's working

#

Which is weird because it still is like "I can't find burst!"

amber flicker
#

huh.. wonder if it works with 0.13 with burst disabled?

north bay
#

As far as I'm aware it will just run the code normally if it isn't able to locate the burst generated dll

tardy spoke
#

@amber flicker tried that, nope

#

the burst error is actually in both, but one still runs

#

However... I think this made me go back to the old version of hybrid renderer which I don't think has that DisableRendering tag which ... makes my project pure shit.

amber flicker
#

hopefully they'll fix it soon - your floating origin stuff is working well though?

tardy spoke
#

Uhh ... yeah it seems to have survived the downgrade hahah

#

did you see the vid I made of it a couple days ago?

#

entityManager.SetName(physicsFacadeEntity, "PhysicsFacade"); <-- is there an ECB compatible way to set an entities name or no?

amber flicker
#

there isn't

deft stump
#

no

amber flicker
#

yea think I did see the vid

tardy spoke
#

Good.

#

That'd be too convinient.

#

I like to struggle through EVERYTHING.

amber flicker
#

think strings just = pain generally

deft stump
#

setname is, again, an editor only thing for your convenience during debugging.

#

it makes sense that ecb doesn't have it

tardy spoke
#

by editor only you don't mean mono behaviour, you mean like actually a unity editor asset or what?

deft stump
#

untiy editor

amber flicker
#

it gets stripped in a build

tardy spoke
#

ah

amber flicker
#

on the plus side.. no 1000's of gameobjects floating around with string names 'GameObject (3)' for no reason πŸ™‚

safe lintel
#

that really makes my ocd flare up πŸ˜„

tardy spoke
#

Which obviously made the DisableRendering tags not work haha

#

Is it generally better to build with IL2CPP or Mono?

deft stump
#

IL2CPP

tardy spoke
#

I notice it takes longer lol

deft stump
#

because it's converting it to C++ code

tardy spoke
#

I watched some videos but wasn't really sure of the benefits, though it sounded like there were some

#

Coolness.

deft stump
#

obvious benefit is your game will run faster if you build with il2cpp

tardy spoke
#

Also this is super enlightening for anyone making mobile games. This guy from Oculus rips apart URP for all the unnecessary crap it does out of the box and shows how to optimize it.

https://youtu.be/PUK2-GzXuso?t=1776

amber flicker
#

Speed dif pretty minimal when I checked before - good to know you can build both but while deving faster builds wins for me

tardy spoke
#

Yeah, I would do mono for quick builds and experiment with the other for production builds

#

Also amazingly 3 cubes and a sphere with a simple vertex color shader I made sits at 70% GPU usage on the Oculus Quest. What a power house.

#

Gonna need to look into that...

north bay
#

Does IL2CPP actually use burst?

#

from 5 min mono build time to 27 min il2cpp

#

And from 15.55ms mono to 23.47ms median frame time il2cpp

tardy spoke
#

Woah. New controller input system is awesome.

zinc plinth
#

seems like a bit of a pain to make work with dots tho

tardy spoke
#

really why's that @zinc plinth ?

#

Just due to implementing them into various systems?

zinc plinth
#

you can't use systems you have to use MB that's the thing

#

at least that's how I understood it

#

and I can'(t really find docs on this either

mint iron
#

they've provided no good way of connecting it with dots. I've seen code where people wire the input action events to create stuff in dots, like modifying a singleton or setting an event entity.

#

You can quickly dump the input buffer to a component which is actually quite nice and extremely fast, just one block copy to a locked chunk ptr. But, you wont be able to use the actions mapping system which is kinda the best part of the new system.

zinc plinth
#

yea..

#

for now I have a InputController MB that does some dots stuff in World.Default....; which isn't the best

mint iron
#

i came up with a MB mapping of Action to ECS component, and then the rest is automated posting actions as event entities with my events system. But there are still some issues to iron out.

zinc plinth
#

do you bundle all your actions in a single singleton component or 1 component per action ?

mint iron
#

its a seperate entity each time with a component containing the action info

zinc plinth
#

hoo ok

mint iron
#

yeah, i mean, for some actions its putting through a hundred events per frame which is wasteful

zinc plinth
#

aight thanks, I'll take a look at it

#

huuuh, that's a more convoluted setup than I immagined

#

trying to find the problems I would have if I just create a InputStateComponent with all my actions and just use it as singleton in my systems

mint iron
#

the ClassTypeRef by Rotorz lets you have a UI dropdown of components implementing an interface, which is cool because then you can associate an input action with a component

#

then in that interface (derived from IComponentData) have a method so the component can set its own data based on the action.

#

and then u just need to marry the two sides, in a system or whatever, that for each action, passes the data to the component, and sets it on the singleton

tardy spoke
mint iron
#

πŸ™‚ that works, but the actions are the cool part

tardy spoke
#

Oh, didn't even know that was a thing, haha.

I was just looking for a simple way to swap from keyboard when I hit play in Unity, to VR controls when I do a build. It's soooo annoying to put on and take off a VR headset ALLLLL the time.

mint iron
#

the idea that you setup logical things that happen like 'Punch' or 'Jump' and then there is a mapping UI that you rebind those things to, for like a gamepad it might be the X button, and for keyboard it would be the ENTER key etc.

tardy spoke
#

Yeah, isn't that what I did? πŸ™‚

#

... I hope

#

It's what I'm trying to do anyway. Painful though because Oculus seems to be in the middle of ditching their own stuff in favour of generic XR stuff, so it's kind of anyone's guess as to what will actually work right now hahah

#

I guess it's the generic "drivers" now because it just worked for the first time, haha.

north bay
#

Can you modify the KeyCode for the mapped actions through code?

tardy spoke
#

It's been so long anything in my project has actually worked without taking days of troubleshooting I'm actually in shock.

#

@north bay it compiles it all down into code that looks like this

#

So seeing as it's embedded in some sort of JSON thing I guess... probably not?

zinc plinth
#

@tardy spoke use a control scheme for each "way"/device you want to use for tht input

#

so that it doesn't look like a mess in the window and you can edit them easier

deft stump
#

here's my implementation of new input system w/ dots

#

making this work was quite the endeavor

tight blade
#

Sorry to cut in, @deft stump, that sounds awesome. -- anyone a decent hand with quaternions? I want to "set" a quaternions EulerX and EulerZ to 0 while maintaining its current EulerY (want to level its orientation while maintaining its heading). would be great to just say

localToWorld.Value = float4x4.TRS(localToWorld.Position, quaternion.EulerXYZ(0, localToWorld.Rotation.toEuler().y, 0), 1)
#

but alas, there is no such thing as .toEuler()

deft stump
#

rotation?
there is a rotation component you can manipulate though

tight blade
#

its a child. I need it to be world level

tardy spoke
#

I'm pretty sure there is a Euler method available or something

#

for the new math library

#

thought I saw it

tight blade
#

there are a lot of forum posts asking for such a functionality, and a lot of resistance to creating it

tardy spoke
#

really? Hmm

tight blade
#

rotations are more efficiently stored as quaternions, and there converting to Euler is actually really complex, apparently.

tardy spoke
#

I usually do something like quaternion.AxisAngle(math.up(), degrees).

tight blade
#

there's a math.up?

tardy spoke
#

πŸ˜‰

#

Not just a pretty face

tight blade
#

huh. now, I have no idea what quaternion.LookRotation actually does... but based purely on how that function sounds, I wonder if I can do quaternion.LookRotation(localToWorld.Forward, math.up())

tardy spoke
#

Hmm, I wonder if you're trying to do something similar to my setup.

Are you trying to do a character controller that "stands up", moves where it's looking and doesn't have "vertical" mouselook?

tight blade
#

not quite, but the intermediate problem may be the same. I need to keep an object level that is still looking the same direction as the character so that I can detect the relative position of other objects nearby

tardy spoke
#

oh,

#

check this out

mighty whale
#

So hum is there anyway to use a Dictionnary with custom type in a ScheduleParallel job ?

tardy spoke
#

This is a bit confusing probably, but this is how I "parent" a camera to a movable character so it copies their movements directly. I believe you could just put an offset.

#

not sure how you would put the offset to local to world, but could also use translation I think

tight blade
#

right yeah. that would copy the x and z orientation, though

#

I need to only copy the y orientation

#

which is tricky

tardy spoke
#

physicsFacadePlayerCamera.value.transform.rotation.y = transform.value.y ?

#

I think I must be missing something lol

#

Either I'm getting SUPER GOOD at this, or I'm so bad I don't understand what you're talking about at all. Most likely the latter.

tight blade
#

you can use it in a schedule parallel, @mighty whale , you just need to do it without burst

tardy spoke
#

could you not also physicsFacadePlayerCamera.value.transform.rotation.z = 0; or whatever?

#

why u gotta be all fancy with the quaternions bro!?

tight blade
#

hahaha, how are you using a transform in an entity?

tardy spoke
#

Translation*

#

sorry, I get 'em mixed up. TOO MUCH KNOWELDGE.

tight blade
#

wait what now? thats now what your code snippet does

tardy spoke
#

No? But you don't have to be me. You're free to be your own man.

#

Oh yeah because the rotation is a quaternion you mean?

tight blade
#

but... Translations dont have a rotation...

tardy spoke
#

and that's why you need the Euler angle conversion? hahah

tight blade
#

cause they're... translations..

tardy spoke
#

Right, you know what I mean.

#

Or probably not.

tight blade
#

I feel inconsistently successful at being sure of what you mean

tardy spoke
#

πŸ€·β€β™‚οΈ I dunno, maybe if I was more sure of what you mean I'd be able to figure out a solution, but most likely... not.

tight blade
#

because yeah, basically, if I could just access and change the y value directly I would

tardy spoke
#

For the Y on the rotation?

#

right?

mighty whale
#

@tight blade Thanks ! however it seems i'm getting the same error when i do without burst and schedule parallel

tight blade
#

right, yeah. But remember, Rotation.Value.y does not refer to its rotation on the y axis, it refers to its position on a 4 dimensional hypersphere... cause quaternions

tardy spoke
#

Gotcha, because you can't transfer to EulerAngles. Right.

tight blade
#

right, yeah

#

@mighty whale hmm, what dictionary type are you using?

mighty whale
#
protected override void OnUpdate() {
  Dictionary<Model.WorldType, World> worlds = Universe.worlds;
  Entities
    .WithName("ChunkMeshUpdate")
    .WithAll<MeshUpdate, RenderBounds>()
    .ForEach((
      Entity entity,
      in Translation translation, in WorldType worldType
    ) => {
      // use of worlds somewhere
    ).WithoutBurst().ScheduleParallel();
}
tardy spoke
#

Toss RotationEulerXYZ : IComponentData on it?

#

so it has Eulers?

#

I think that's a thing @tight blade

mighty whale
#

i'm using custom types inside, is that what causes the problem :v ?

tight blade
#

what?

#

if thats a thing...

deft stump
#

alex, they already have a rotation component if you convert your go's

tardy spoke
#

@deft stump nah we're trying to find a way to use EulerAngles from a quaternion with unity.math

amber flicker
#

yea - be sure to look at latest docs - if you replace Rotation with one of those, that will probably do what you want

deft stump
#

you're trying to set a rotation right?

tardy spoke
#

Hmmmm yea apparently that's not a thing anymore.

tight blade
#

ah yeah @mighty whale that code is not parallelizeable because you're giving multiple threads write access to the same piece of data

amber flicker
#

though just a thought - does the entity need to even rotate in the first place?

mighty whale
#

ah but I'm only reading from it though

tardy spoke
#

Does anything REALLY need to rotate? πŸ€”

#

Like NEED to though...

amber flicker
#

only perfect spheres

tardy spoke
#

Like the Earth. Or the sun. πŸ€·β€β™‚οΈ

deft stump
#

yes.

tight blade
#

I wonder if theres a way to mark it as a read only. like copying the value into each

amber flicker
#

what sets the rotation in the first place?

tight blade
#

it seems whatever Entities.ForEach is doing isnt smart enough to realize that intention, @mighty whale

amber flicker
#

is it physics?

deft stump
#

doesn't quarternion.Euler take in radians not degrees?

amber flicker
#

yes - that's correct - though we're talking about converting quaternion to euler

tight blade
#

right. yeah this matches my use case precisely.

#

probably. Im trying it now.

deft stump
#

yes - that's correct - though we're talking about converting quaternion to euler
aaaaaaaaah...
so that's what we're discussing...

tardy spoke
#

So weird... the camera rotates WITH the character in Unity with a mouse, but then the character rotates but the camera doesn't on Oculus Quest. πŸ€” Gonna have to redesign mah whooooole gameeeee....

amber flicker
#

isn't it just because the oculus sdk overrides the camera?

tardy spoke
#

... shit I hope not

#

I dunno the camera still does some things "right".

#

like the camera moves with the character as expected, but it doesn't rotate. It could be because it replaces it behind the scenes, but it's a regular XR VR camera with just the tracked pose driver on it.

#

Hmm maybe I can parent the camera to the player themselves so if it does get replaced it should still rotate... actually I think that already is how it works.

amber flicker
#

your character never leaves 0,0,0 though right? so it might appear to be moving with the camera but not? πŸ˜„

tardy spoke
#

It's so confusing πŸ€”

#

Haha yeah I have cameras on both characters and the physics one does follow along and copy it's rotation and stuff.

#

Hmmmmmm...

tardy spoke
tight blade
#

ehhh. unfortunately RotationEulerXYZ doesn't help me :C

#

its the local rotation. I need the world rotation. Although this may have given me inspiration on how to solve this.

tardy spoke
#

@tight blade Always glad to inspire others.

deft stump
#

so I can't change texture of a material in runtime?

zinc plinth
#

Use material property blocks hybrid renderer equivalent

deft stump
#

material property blocks?

#

aaaaaaaaah. you mean that...

acoustic spire
#

Hello. After watching a couple of tutorials about DOTS I wonder how would one organize a voxel engine for Minecraft clone game. Would it be more performant to keep using chunks of blocks (basically, mesh per chunk) instead of assigning mesh to every block?

opaque ledge
#

you can find plenty of discussion of that topic in DOTS forums

odd cipher
#

I would still recommend having one mesh for a chunk instead of individual blocks, otherwise you would still have plenty of lag even with DOTS @acoustic spire

deft stump
#

Hrmmmm

zinc plinth
#

There's Γ  lot of optimization for how minecraft renders it's terrain

#

It's not just 1 block = 1 mesh

#

Otherwise
1 your cpu would be pinned by culling alone
2 your vram would also be full instantly

acoustic spire
#

Thanks

#

Also, my Rider doesn't see Unity.Entities but I have the package installed. Did I miss something?

hollow sorrel
#

@acoustic spire are you using an asmdef file?

acoustic spire
#

yes

hollow sorrel
#

gotta add it there too

acoustic spire
#

Ah, ok. Thanks

zinc plinth
#

always start unity first then rider/vs; otherwise yes you'll have problems with assembles

acoustic spire
#

Bug or I use it wrong?

#
System.NullReferenceException : Object reference not set to an instance of an object.
   at Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow(AtomicSafetyHandle handle)
   at Unity.Entities.DynamicBuffer`1.CheckWriteAccessAndInvalidateArrayAliases()
   at Unity.Entities.DynamicBuffer`1.EnsureCapacity(Int32 length)
   at Unity.Entities.DynamicBuffer`1.ResizeUninitialized(Int32 length)
   at Server.Chunk..ctor(World world, Int32 x, Int32 y, Int32 z) in C:\Users\xotonic\CraftAndSlay\Assets\Scripts\Server\Chunk.cs:line 52
   at Tests.BasicTest.ChunkSizeIsComputedCorrectly() in C:\Users\xotonic\CraftAndSlay\Assets\Scripts\Tests\BasicTest.cs:line 96
acoustic spire
#

Btw, what would be an alternative to Block[] in a component?

opaque ledge
#

FixedList<Block>

#

i am not really sure if you can just create a dynamic buffer like that

#

they suppose to live on entities i think, just create a dummy entity and place your dynamic buffer there thru entity manager

zinc plinth
#

you don't create a dynamic buffer, the EntityManager does it's stuff for you

#

and if you have an array of data in a ICD it's way better to just make it a IBED

#

unless you have a really strong reason not to and you know what you're doing

acoustic spire
#

Yeah, got it. I wanted not to bring entityManager in instantiation of my ICD

#

ty

acoustic spire
#

Do I need to adjust render bounds manually?

#

RecalculateBounds didn't help

acoustic spire
#

Solved. I updated to 2020.1.0f1 and added mathematics.extensions to assembly definition. Dunno what actually fixed this πŸ˜„

lusty otter
#

I see a common pattern being allocating a TempJob native array as input/output for a job, and then disposing it when the job is done.

#

Why not allocate a Persistent one once at set up, use it throughout its lifetime (assuming jobs won't overlap) and then dispose it at the end?

opaque ledge
#

well you shouldnt dispose it if job is running multiple times, apart from that, its a good question

deft stump
#

I actually want to answer but i stopped and thought about it...

#

maybe because it'll be a pain to manually dipose if you have lots and lots of persistent native arrays?
lots of room for faults to happen

tawdry tree
#

You might also need to resize it, which has the same affect as just using it temp

lusty otter
#

Hmm, I don't supposed there's any more overhead in accessing/writing a Persistent allocated one comparing to a Temp/TempJob one?

#

The only difference from what documentation says, seems to be just allocation speed/cost.

#

In that case assuming I can manage correctly disposing and array size won't change, I think one allocation then reusing is just better.

scarlet inlet
#

Hello, sunday question, I was wondering how c# copies large structs when we just assign structs and how burst behaves. Have you ever done any test about it?

north bay
#

I think C# breaks at a certain size, i remember this from a "bug" with Dots Netcode: InvalidProgramException: Passing an argument of size '10568'

stiff skiff
#

I mean, thats just a struct thats too big

deft stump
#

and that applies to only 1 struct. not the collective

zinc plinth
#

for ppl wondering about creating game with dots, streaming the very beginning of my city builder

#

hope this doesn't qualify as ads against the rules ?

opaque ledge
#

should be fine i think, you might put it to #archived-resources instead? not sure, worst thing that can happen is moderator will just guide you to right direction

zinc plinth
#

done

hollow jolt
#

where to get started if i want to implement existing coroutine code ( fill bucket for texture2d ) into multi threading ?

zinc plinth
#

rewrite your coroutine with jobs

hollow jolt
#

do i need all the ECS packages* for that or can jobs be used on its own ?

deft stump
#

you can use jobs and burst on its own

hollow jolt
#

any suggestions for reading materials ? search engine brings up unity jobs "careers"

deft stump
#

search for unity job system

#

or unity C# jobs

hollow jolt
#

true

hollow jolt
#

what is this burst compiler black magic ? ( y is it so fast )

#

will it be auto enabled on compilation to androind / ios ? ( i see u need to enable burst in the context menu under jobs > burst > enable burst compiler )

opaque ledge
#

i think there is a setting for that in project settings (to enable/disable burst in build)

hollow jolt
#

anyone knows what is the optimal way to to make a jobs to work with texture2D getpixel / setpixel ?

lusty otter
#

Don't use them to begin with.

#

Pass in all the necessary information you will need for the job, and pass out all the output you need, then do one SetPixels.

hollow jolt
#

InvalidOperationException: FloodFillJob.outMap is not a value type. Job structs may not contain any reference types.

how do i pass Color32[] data outside of the job ?

[BurstCompile]
public struct FloodFillJob : IJob
{
  // ...
  public Color32[] outMap;
  public void Execute( ) { 
    // ..
    outMap = WriteMap.ToArray(); // NativeArray<Color32>
    WriteMap.Dispose();
  } 
}
opaque ledge
#

you cant, you have to use NativeArray instead of Array or List classes

#

so create native array out of array, use that inside the job and after you schedule your job do .Complete() and you can use your native array safely

hollow jolt
#

is it normal to dispose a native array outside of the job execute ?

opaque ledge
#

yeah, so you create the native array with Allacator.TempJob, and after you are done with your native array you dispose it

#

so you dispose the native array outside of the job, not inside

hollow jolt
#

so Allocator.Temp is inside the job , while Allocator.TempJob is outside the job ?

opaque ledge
#

to use a native array ? yeah, if you want to just create a native array inside the job for internal usage you go with Allocator.Temp, but if you are passing a native array to a job then you creat the native array with Allocator.TempJob

hollow jolt
#

i see, thanks

#

looks like it doesn't like native queues

#
D:\UnityGitMy\__project__\Library\PackageCache\com.unity.collections@0.9.0-preview.6\Unity.Collections\NativeQueue.cs(96,17): Burst error BC1042: The managed class type `Unity.Collections.NativeQueueBlockPoolData*` is not supported. Loading from a non-readonly static field `Unity.Collections.NativeQueueBlockPool.pData` is not supported

 at Unity.Collections.NativeQueueBlockPool.get_QueueBlockPool() (at D:\UnityGitMy\__project__\Library\PackageCache\com.unity.collections@0.9.0-preview.6\Unity.Collections\NativeQueue.cs:96)
 at Unity.Collections.NativeQueue`1<FloodFillJob.Point>..ctor(Unity.Collections.NativeQueue`1<FloodFillJob.Point>* this, Unity.Collections.Allocator allocator) (at D:\UnityGitMy\__project__\Library\PackageCache\com.unity.collections@0.9.0-preview.6\Unity.Collections\NativeQueue.cs:276)
 at FloodFillJob.Execute(FloodFillJob* this) (at D:\UnityGitMy\__project__\Assets\Project\Script\Vector\FloodFillJob.cs:50)
 at Unity.Jobs.IJobExtensions.JobStruct`1<FloodFillJob>.Execute(ref FloodFillJob data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex)
opaque ledge
#

you seem to be using classes, you cant use any class inside jobs

hollow jolt
#
NativeQueue<Point> Q = new NativeQueue<Point> ( Allocator.Temp );
// .. error points me here ( an empty line between those two ) 
Q.Enqueue ( new Point { x = x, y = y , d = FillDir.Start } );
#

Point is a struct

#

FillDir is an enum

opaque ledge
#

hmm

#

can you perhaps upgrade collections package ?

hollow jolt
#

sure

#

looks like its the latest

opaque ledge
#

thats Collaborate package πŸ˜„

hollow jolt
#

oh lol forgive my 4 am eye sight

opaque ledge
#

dw, happens to best of us

hollow jolt
opaque ledge
#

are you using 2020.1 ?

hollow jolt
#

2019.4.f1

west shore
#

Is 2017 unity still good

hollow jolt
#

i think i upgraded some packages

#

just because latest packages where available

#

not sure if it was this one or the Jobs one

opaque ledge
#

kinda sounds weird tho, can you show us the code where you create the array, pass it to job and dispose ?

hollow jolt
#

sure

opaque ledge
#

what burst package you are using ?

#

what version i mean πŸ˜„

hollow jolt
#

1.3.3 <---- using this one atm

#

the next one after the verified one ( 1.2.3 )

opaque ledge
#

alright, can you show the code

hollow jolt
#

this is how i use it :

var map = new NativeArray<Color32>( Image.texture.GetPixels32(), Allocator.TempJob );

var fillJob = new FloodFillJob
{ 
    TextureWidth = Image.texture.width, 
    TextureHeight = Image.texture.height,
    outWriteMap = new NativeArray<Color32>( Image.texture.width * Image.texture.height, Allocator.TempJob ),
    fillColor = Color.white ,
    tollerance = tolarance,
    x = pixel.x, y = pixel.y,
    ReadMap = map
};

JobHandle jobHandle = fillJob.Schedule();
jobHandle.Complete();

var color32Arr = fillJob.outWriteMap.ToArray();

fillJob.outWriteMap.Dispose();
map.Dispose();

if( fillJob.outCount < 1 ) 
{
    Destroy( targetTex );
    Destroy( activeGo );
    return;
} 
        
sr.enabled = true;
sr.color = fillColor;

activeGo.GetComponent<SvgFilledItem>().fillBounds = fillJob.outBounds;
        
targetTex = null;
activeGo = null;

targetTex.SetPixels32( color32Arr );
targetTex.Apply();
#

so roughly speaking im creating NativeQueue inside the execute

#

and the other two native arrays are created outside of the job ( and they are disposed there as well )

#

2 textures in play

#

image.texture to read info from

#

outWriteMap is the populated data that the job does

opaque ledge
#

so what happens if you comment out Q.Enqueue ?

hollow jolt
#

when

#

the 2nd line ?

#

after it has been declared *

opaque ledge
#

yeah

#

"Q.Enqueue ( new Point { x = x, y = y , d = FillDir.Start } );" this line

hollow jolt
#

it will not enter the while loop

opaque ledge
#

yeah but does it output any errors ?

hollow jolt
#

D:\UnityGitMy\__project__\Library\PackageCache\com.unity.collections@0.9.0-preview.6\Unity.Collections\NativeQueue.cs(96,17): Burst error BC1042: The managed class type `Unity.Collections.NativeQueueBlockPoolData*` is not supported. Loading from a non-readonly static field `Unity.Collections.NativeQueueBlockPool.pData` is not supported

#

dang

#

ill try downgrade burst

opaque ledge
#

well i actually never done anything with native queues, but could be a package problem with burst or collections

#

in 0.9 patch notes it says "Updated package com.unity.burst to version 1.3.0-preview.11"

#

perhaps try that burst version ?

hollow jolt
#

i am using 1.3.3

#

oh ok

opaque ledge
#

ah saw this

#

apperantly, nativequeue being created inside the job is not supported

hollow jolt
#

hmmmm

opaque ledge
#

perhaps create one outside of the job and send it to job emtpy ?

hollow jolt
#

lol that's relatively easy

#

ill try that

opaque ledge
#

alright let me know if it works so i can go to sleep πŸ˜„

hollow jolt
#

lol ok 1 sec

#

hmmm i see no errors

#

i think it works ... ? can't say for sure but thanks so far ill figure out why its showing no changes compared to the coroutine method

opaque ledge
#

haha alright^^

hollow jolt
#

have a good one

tardy spoke
#

Hmm now that I've done the continuous floating origin test, I'd like to try it the "tile based" way, where instead of the level moving around the player continuously, the origin "resets" at when you cross into another "tile" - which in this case would be a subscene. I feel that this approach will actually likely end up being simpler even though the mechanism of how it keeps the player near the origin is initially more complicated.

I have concerns about splitting the rendering and physics meshes like how I did on my first test will compound in complexity as more systems/functionality is added. It also seems unnecessarily mentally fatiguing to always be considering how the visuals don't actually line up with the physics representations, and how to program systems with that in consideration.

Also, question - does DOTS physics handle "static" stuff in the same way the older physics system did, where it actually optimizes physics calculations some way for those entities it knows will never move? Or is a collider simply a collider as far as it's concerned?

minor sluice
#

afaik, it is similar to the old physics system,
like static colliders won't be checked against other static colliders

tardy spoke
#

@minor sluice can they be "moved" now, per chance? Haha πŸ™‚

#

Because that would solve a looooot of issues for me

#

Moving 10,000 physics objects that are not checked against eachother can probably be done in under a frame without interrupting the player experience, I thiiiiiink.

10,000 physics objects that have to recalculate all their physics interactions I think might cause the game to pause for a second when moving the entire level and player.

#

I guess i'll find out. Worse comes to worst I'll just put a "loading" screen or something for the half second or whatever it takes to calculate and move the level / player.

minor sluice
#

taking a look into "BuildPhysicsWorld", there seems to be a check between the current and previous number of static bodies, among other things and this comment:

// Determine if the static bodies have changed in any way that will require the static broadphase tree to be rebuilt

so I assume that the world is rebuild on demand and there is also a job to check if existing bodies changed

#

so probably means there is quite a bit of optimization in ecs physics too for keeping static collider world layout

tardy spoke
#

Hmm, yeah that sounds as if the relationships are kept the same it's smart about it

minor sluice
#

but if it is similar to physx, apparently there was a time where moving static colliders was expensive, but not anymore

tardy spoke
#

I thought if you moved a static collider it would glitch out and give you an error?

#

without DOTS

hollow sorrel
#

i imagine it'll be fine but if you find it's not you could overengineer the fuck out of it and split every tile into a seperate physicsworld

tardy spoke
#

Is there no physics optimizations between subscenes that is somewhat similar to that?

#

I doubt they use physicsworlds since that would interrupt physics calcs that cross between subscenes

minor sluice
#

because for a while there was the advice to not move static bodies and use rigidbodies for objects that you move, but I think I once found that it is cheaper to move a whole bunch of static objects than it is to move the same number of kinematic rigidbodies

tardy spoke
#

but surely it's only performing physics calcs on loaded subscenes only, and that oughta do?

hollow sorrel
#

subscenes just dump everything into your default conversion world

minor sluice
#

no, it doesn't matter, fortunately unity and the other engines usually do are pretty forgiving there

#

I always only use static colliders if i don't strictly need interactions between those 2

#

like a game that has plenty of enemies, but they only need a collision against a bullet, I might only give the bullets a rigidbody

tardy spoke
#

it's nice to have that ability to create the smaller physics worlds if necessary.

I wonder if it's possible to just tag everything that's more than say 200 feet from the player with "ExcludePhysics" if that would help

#

Depending on how they handle that, you would re-initializing the physics interactions between objects "over time" as you move around the world... if that's how it works.

minor sluice
#

in regular physics, I think there is a setting when the physics world is recalculated, by default that only happens in the fixed update state,
maybe before that happened when you move a static collider too perhaps, and that is why it wasn't as performant?

the only downside with the cheaper approach is that you might move an object and then raycast against a world state where the movement wasn't applied to the world yet (not sure if unity performs the recalculations here if the raycasts are triggered too, I don't think so)

#

I think I'd just try and see what the profiler says about it, or if it is an issue ^^

zinc plinth
#

streaming ecs dev again acegikSparkles

hollow sorrel
#

yea the seperate physicsworlds is just my mind wandering off not an actual suggestion, i'd prob do that if it was multiplayer because then you can't simply origin shift but other than that the other way is prob better

tardy spoke
#

Well, eventually it will be multiplayer, not sure why you can't origin shift in multiplayer?

hollow sorrel
#

oh in that case

#

because the server needs to calc everything at the same time right

#

for players that are at both opposite ends of the world

minor sluice
#

origin shift only works if there is one player, or a few players around the same spot

tardy spoke
#

You would need a layer that converts the player's "real world locations" (non origin shifted) to the relative locations for all the players

#

I dunno if that's possible, but that's what I figured the approach would be ^

#

So you're saying the one big physics world would be too big for the server to handle/compute?

#

I figured the server would load a copy of the world, spawn enemies in it and then translate the locations of those enemies to appear to player's relative locations based on the player's "real world location". Same thing with other players, etc.

minor sluice
#

you could probably use some relative coordinates of a shift for certain areas of objects you expect to interact and then reapply those results back to the actual world, no idea how this is usually handled though

hollow sorrel
#

you can but as long as they're part of the same simulation their relative locations is still going to have precision issues
like if one player is at pos 0 on tile 0,1 and the other at 0,5 then you can't just set both their physics position to 0 because they'd overlap right

#

so they'd still have to be 500000m apart

#

unless you seperate your simulation into multiple tiles

minor sluice
#

the issue with the all enemies relative to each player approach is that it could get expensive the more players there are I assume

tardy spoke
#

Oh, I figured the server was doing the calculations based on their "real world positions" in the real world.

For me, the origin shifting is basically solely for to fix the display jitter issues, the physics inaccuracies up to a half inch or whatnot are really not a primary concern of mine... that is until they start causing some real issues and stuff, hahah.

minor sluice
#

if you have to relativate all close positions per player, but maybe you could just take each of the colliders that could realistically collide for a player and then do a local simujlation

tardy spoke
#

@minor sluice yeah that's actually a good point because you potentially have an exponential calculation there that could quickly get out of control

hollow sorrel
#

i think even if i didn't care about physics jitter (i do) i still would do the tile based approach in mp

tardy spoke
#

Yeah, you could do a "local" physics calculation and have the server just verify the calculation is within reason/realistic

hollow sorrel
minor sluice
#

oh, I know this person, he is also trying to develop and open world multiplayer game with large map

#

also great to see joachim giving input on those topics

tardy spoke
#

@minor sluice I was planning on a having the server "foreach" each player and only show enemies near them, and ignore calcs on all enemies wandering the world that can't be seen/are not near, but yeah, I do wonder about the scalability of that regardless, haha.

#

I wonder if that's enough or if you'd still run into issues with that calculation becoming too massive.

#

If you want to run a simulation over 100*100km with a reasonable simulation density, you need to go with a MMO style simulation approach at that scale for the server. This means splitting the world into tiles and doing simulation only in one tile and having neighboring tiles loaded as read only data. Most likely scaling the simulation across multiple machines.

Lol wow that sounds complex

minor sluice
#

since the new packages basically have the source available in the package cache, I wonder if someone will "just" reimplement the current physics solution with doubles instead of floats.

probably needs a try, here the expensive thing might be the range checks around each player, would be easier to just have a tiled world and take all entities that are in the same or maybe also adjacent tiles, then it might not be that expensive

tardy spoke
#

luckily my map is only 20km squared and I could make it smaller if necessary

minor sluice
#

but again, never made a game world on that scale

hollow sorrel
#

btw you mentioned you didn't notice physics jitter if you only shifted rendering

#

you're making a vr game right?

#

might notice physics jitter with motion controls

#

i would imagine

tardy spoke
#

Yeah, you totally could get some weird interactions for sure at the edges of the worlds picking up objects like guns and stuff.

#

I don't think there's any "free lunch" here. I think something is going to have to be sacrificed to make it "work". I've considered even having it so you can't actually pick up objects at all and there are no true physics objects in the world, just ones you select from an inventory that are calculated with your local physics.

I'm trying to find a simple approach that will work, rather than a "perfect approach", because sheer size of the project is already immense anyway and I'd rather have something that is playable and fun to work on than some technical marvel that is just overwhelmingly complicated and never gets anywhere near finished.

hollow sorrel
#

yea that's fair

tardy spoke
#

I have a feeling getting the XR interaction toolkit to work with entities may also be interesting... haha. There's all these unknowns on a project this size.

hollow sorrel
#

wouldn't consider mp in that case hahah but up to you

tardy spoke
#

mp?

hollow sorrel
#

multiplayer

tardy spoke
#

Oh, yeah - haha. It's a learning project and I've always been interested in that aspect. Yeah, definitely increases difficulty a ton.

#

For the tile origin based shifting system, not sure if anyone is familiar, but at what exact point would you have it shift the origin? as soon as they cross from one sub-scene into the next? Or possibly fairly continuously, like every 10 seconds whether you've moved anywhere or not - though I'm pretty sure that's not how it's usually done.

#

Actually I wonder if you could just do the CFO (continuous floating origin) method with subscenes but without splitting the display/physics world apart since you're only loading a part of the world at a time... hmm. That may actually be the "easiest".

hollow sorrel
#

if i remember right you have sub-cm precision until like 10km distance right
so you shouldn't have to shift that often, doing it when crossing subscene/tile sounds fine

tardy spoke
#

Yeah, it would definitely be fine.

#

I'll do the CFO experiment with the subscenes first and see how that works, because I already have most the scripting done for that experiment anyway. Then if that has issues I'll try the tile one to see how that goes.

hollow sorrel
#

CFO as in moving the world around the player?

tardy spoke
#

Yea

#

Why? Do you see an immediate issue? Hahah

hollow sorrel
#

just that it would cost more performance

tardy spoke
#

Oh, yeah, true

#

Yeah, you're right, and on mobile too (target platform is Oculus Quest, which has the power of a google pixel 2 phone)... hmm... that is a lot of wasted performance

craggy orbit
#

i can't find very much on .Schedule() vs .ScheduleParallel(), but im guessing that Parallel schedules jobs across multiple threads. am i correct in this assumption?

tardy spoke
#

@craggy orbit I believe so. I think .Schedule() also will schedule across multiple threads if it "decides" that's the most efficient approach, but don't quote me on that.

zinc plinth
#

@tardy spoke no schedule is 1 thread only

#

that's the point of IJobParallelFor, multithreading a job

#

not every job can be split in bits

tardy spoke
#

Ah, right, so schedule is just "run" but not immediate then - gotcha. Makes sense.

zinc plinth
#

run is to run on main thread

#

schedule is job workers

tardy spoke
#

Ahhh, okay, I gotcha. Haha. Good to know.

craggy orbit
#

thanks for the clarification, you two. seems i should be using ScheduleParallel when possible then πŸ™‚ thanks!

tardy spoke
#

Hmm. Ideas for how to calculate from the player to the closest pound on a SubScenes' bounding box? I have a math.distance but it's currently calculating the distance to the centre of the subscene, I believe. The subscene's bounding box is also in a min/max format.

I figure I could use that min/max and make a plane, and then figure out the closest point from that plane to the character. Or just treat the "sides" of the plane as four seperate lines and do some math to calculate the closest point on each and just use the smallest result.

craggy orbit
#

should physics be taking up 4.5 ms to force complete the ParallelCreateContactsJob and ParallelBuildJacobiansJob jobs every frame with only 1200 entities? i feel like it used to be more performant

#

this only works if the player is outside of the bounds though, as far as i can tell

deft stump
#

@craggy orbit
schedparallel schedules jobs across multiple threads if you're working on entities across multiple chunks
1 chunk = 1 job.
sched will only work on 1 thread even if you're working on entities across multiple chunks

hollow jolt
#

how can we pass data outside a job system ?

#
[ // Inside IJob struct :: Execute method // ]
{
  ...
  // last line of function
  Debug.Log("Out Count = " + outCount ); /// valid value something like 203986
}

[ // Outside Job // ]
JobHandle jobHandle = meJob.Schedule();
Debug.Log("1. C=" + meJob.outCount ); /// 0 -- data is lost ?
jobHandle.Complete();
Debug.Log("2. C=" + meJob.outCount ); /// 0 
hollow jolt
#

ok i figured it out , the main thread holds a copy of the IJob item , i used a results int native array to read & write data

amber flicker
#

Anyone know if it's possible to run a system before monobehaviour Start()? (but after a subscene's entities exist)

#

I've managed it by manually calling update if the system hasn't yet run but I'd like to know if there's a better system group to run it in or something

hollow jolt
#

@amber flicker iirc usually Awake executes first inside monobehaviour then OnEnable then Start , if u want monobehaviour independent execution look at RuntimeInitializeOnLoadMethodAttribute : https://docs.unity3d.com/ScriptReference/RuntimeInitializeOnLoadMethodAttribute.html
it has the following load method types :

AfterSceneLoad - After Scene is loaded.
BeforeSceneLoad - Before Scene is loaded.
AfterAssembliesLoaded - Callback when all assemblies are loaded and preloaded assets are initialized.
BeforeSplashScreen - Immediately before the splash screen is shown.
SubsystemRegistration - Callback used for registration of subsystems
amber flicker
#

Thanks @hollow jolt but those are for static methods and not related to systems & ComponentSystemGroups. I think the lazy init I have now is fine but I think I would like to better understand the execution order wrt Awake, Start, InitializationSystemGroup, SimulationSystemGroup and for each of those when entities from a subscene 'exist' or are loaded

tardy spoke
#

@craggy orbit yeah I think that method would work totally fine for what I'm doing. One problem I seem to have discovered though is subscenes seem to always originate at 0,0,0, including their bounding box. Yikes.

In the code monkey video he just uses the subscene object's position to load each one and moves it to the middle of the subscene, but as he mentions, that's not a great practice and the Unity editor even pops up with a warning when you move a subscene's origin away from 0,0,0.

I'm thinking there's gotta be a simpler way. Plus for myself, checking distance to the subscene's outer bounds vs an arbitrary point in the middle is likely a better more flexible solution. πŸ€”

#

I wonder if components can be added to Subscenes, like if I could just add a WorldRenderBounds or something to it somehow.

hollow sorrel
#

@tardy spoke why not just move every object by origin offset after loading the subscene

tardy spoke
#

The objects are in the right places, just the bounds of the subscene are forced to originate at 0,0,0 regardless of where the objects are.

hollow sorrel
#

ah

#

didn't know subscenes have a bounds

tardy spoke
#

It would make sense to me from a utilitarian point of view to have a worldrenderbounds type component on them because you know the majority of people are going to use them for streaming type loading... not sure what solution they're expecting to be used for that.

mint iron
#

i'd think you'd want everything in the subscene to be relative to the subscene, and a layer that translates into world space. Then you can move the subscene anywhere you want, because the world positions are dynamically calculated.

tardy spoke
#

@mint iron I agree, but I'm not sure how I would go about implementing that. Subscenes can't be "moved", they only seem to maintain a position from 0,0,0 it seems.

mint iron
#

It is weird that there isn't a built in system for that, what is the SceneBoundingVolume used for?

tardy spoke
#

Totally. I'm not sure what it's used for, haha.

mint iron
#

i wonder about a couple things, is it dynamically calculated based on the contents of the subscene? what happens if something is in the subscene and outside this area?

tardy spoke
#

It's based on the contents

#

It seems to work like you'd expect except always includes the origin point within it's boundaries

mint iron
#

interesting

tardy spoke
#

They're using it like how you would expect it to work. I wonder if it's a bug/glitch ?

dark cypress
#

Is there a way to create a prefab without translation? I want to make some event entities and entities that don't need translation in any way and don't want the component there.

#

I know I can create an archetype programmatically, but I was hoping there's a way to do it with authoring.

amber flicker
#

there will likely be a way to do it in the future - Topher (Unity) on here previously mentioned he thought it would be a good idea at any rate. In the meanwhile, either via code like you say or else modifying your entity prefab by removing Translation before instantiating them for events

dark cypress
#

Cool. Good to know it's on the radar. I'm assuming there's virtually no performance impact if you have an unused translation component on a bunch of entities right?

amber flicker
#

It depends on the scale but certainly, I'd be surprised if that ever became a practical bottleneck

#

that said, it will be updated by the transform system etc if you have many thousands around at one time so I would remove it from the entity prefab

dark cypress
#

Understandable. Thank you.

safe lintel
#

new animation package, 0.6.0p2

#

seems like it brings it in line with the most current entities and hybrid packages, though its further and further out of sync with the samples now 🧐

zinc plinth
#

wasn't someone in here making a neat thing for dots animations with a good ui ?

safe lintel
#

⬆️ Timboc

zinc plinth
#

ha ye

last jasper
#

Hello! Is this the place for tiny questions aswell?

#

Specifically, I was wondering if tiny's renderer supports any custom shaders yet, or material properties - in my particular case, to implement 'team colors' on some ship sprites, but the quesiton is more general

opaque ledge
#

maybe somone knows the answer but i rarely see tiny stuff being discussed here, you should ask your question to tiny forum

#

you might get better/faster help

last jasper
#

thanks CurlyOne

zinc plinth
#

do you know which system adds the Child buffer to entities ?

#

nvm found it

#

(it's ParentSystem)

knotty delta
#

How do i name Entities when i instantiate them? All my Entities are called Entity 1, Entity2,etc and it's confusing when debugging with the entity debugger.

hollow sorrel
#

@knotty delta entitymanager.setname

knotty delta
#

@hollow sorrel Thanks a lot!

ocean tundra
#

@knotty delta make sure to wrap that call in a #IF UNITY_EDITOR

#

as it dosnt exist in build

zinc plinth
#

Huuh good to know

#

Fuck

ocean tundra
#

yea was annoying to discover

#

names are a editor only feature

zinc plinth
#

I use names as field name for a codegen'ed struct containing entity prefab I_NotLike

#

Damnit

#

Giess I'll need a class ICD then --'

ocean tundra
#

I am a version or 2 behind now

#

you can tell pretty quickly if you do a build

#

the compile will fail almost right away

spark glade
#

seems like it brings it in line with the most current entities and hybrid packages, though its further and further out of sync with the samples now 🧐
@safe lintel no surprise here 😭

#

And still no mention of URP πŸ‘Ώ

last jasper
#

What's the issue with URP?

amber flicker
#

Oh I think it's something like only supports 1 main light, no baking, light probes, issues with the batcher? etc etc

stone osprey
#

So how exactly does the job system work ? We schedule a "piece" of code into a job which gets executed parallel on a different thread... right ? Is there a way to register a callback getting executed once the job finishes ?

tight blade
#

@stone osprey its more like js promises. As long as you have a reference to the job, you can tell other async code to wait for that to finish, or you can have your synchronous code explicitly wait for that to finish before continuing.

#

the JobHandle API is what takes care of all of that

stone osprey
#

Ah thanks ! πŸ™‚

mystic mountain
#

Hmm, so I just came back from being away for a month and I updated some packages, it says I get error of The type or namespace name 'Scenes' does not exist in the namespace 'Unity'
But I can clearly see it when I check the packageCache, anyone bumped into something similar?

opaque ledge
#

i think it was moved to some different name space

mystic mountain
#

I see, it moved from hybrid assembly.

amber flicker
#

hhmmm anyone know if it's possible to e.g. search at edit-time for ICDs in a SubScene that's closed? Sounds unlikely doesn't it. I guess you'd need to somehow stage/open it when searching. Edit: seems if you open just like any other scene it works so will go with that.

granite spoke
#

Hey guys! I'm new to Unity's discord server. We are doing the pre-production of a game with DOTS. What could be helpful to share with everyone? Other than asking questions of course πŸ™‚

amber flicker
#

Nice - what type of game and what's been the hardest problem so far?

tardy spoke
#

@granite spoke this is a list of resources I put together for myself of recent DOTS materials. Anything along these lines is definitely helpful - really, the most helpful thing is just having RECENT demonstrations of solving common gameplay stuff in DOTS. https://sites.google.com/site/unityecsresources/

It would be interesting to see for example implementations of questing systems, or just other gameplay systems in general. Realistically anything well instructed and recent is worth it's weight in gold, haha.

granite spoke
#

@amber flicker @tardy spoke It is a sandbox game with crafting as the main focus. You live in a world containing mines and people and stadiums which you can run shows in

So far we solved quests, inventories and general gameplay systems. about 3.5 weeks into pre-production

#

I'll try to post relevant material soon here or as a blog on our site/gamasutra and post a link here

#

it is truly a delight

#

If you are looking for generic systems like OOP then you'll not find it but we have rules for solving quests which are pretty elegant if you get used to them. For example you have a Task component and it contains only task type and generic info (few fields) Then each task type (quest type) has its own special components (e.g. timeBasedTask, CounterTask) and each of these have a separate system which checks for entities with Task, [TaskSpecificComponent] and ActiveTask component and keep track of the task's progress. we also keep data regarding what is going on in the world in separate NativeArrays which keep track of the show's stats in the stadium for the tasks.

Will write as a post soon

deft stump
#

So that results in plenty of systems... huh

#

for curiosity's sake, how many systems do you have right now?

#

because my system's folder is getting bigger and bigger

tardy spoke
#

@granite spoke Would definitely be interested in seeing that quest system for sure. I believe there is no tutorial or tech demo of a quest/task system for ECS to date on YouTube, so might be a good opportunity for some exposure for your company.

stone osprey
#

Does it make sense to chain jobs ? For example Job 2 should get executed after Job 1 ? This way we could reduce load on the main thread but its still not getting executed parallel

zinc plinth
#

some jobs can require the result of a previous job, so yea it makes sense to chain them

#

if you shedule 2 jobs they get added to the dependency one after the other by default anyway

stone osprey
#

@zinc plinth Thanks ! But how do we actually pass data from the first job into the second one ? ^^

zinc plinth
#

pass your native array from the first struct to the next

tardy spoke
safe lintel
#

@granite spoke are you using the animation package for this? or how are you handling animation?

tardy spoke
#

https://youtu.be/F7JOH3r3-vA Lol, I made this video and I was going to ask if anyone knows how to solve this strange issue. Upgrading entities from 0.11 to 0.13 fixed it ... too bad entities 0.13 doesn't run when I build it to VR, hahaha. DOTS life yo. πŸ€¦β€β™‚οΈ

safe lintel
#

wait he mentioned its a crafting game, but the link is a top down shooter?

tardy spoke
#

oh sorry

#

wrong name

#

Corrected now. Got the two projects mixed up.

safe lintel
#

ahh an ecs dungeonkeeper project 😍

tardy spoke
#

Haha it's so dope, but the dude is mad skillz

tight blade
#

anyone know how to inspect the order of conversion systems?

tardy spoke
zinc plinth
#

if you create a system mid frame and the new system is placed after the one currently running, will it Update within the frame ?

edit: streaming again

tardy spoke
rancid geode
#

maybe SceneName is Editor-only thing?

tardy spoke
#

Oh, that's probably right

#

Damn I was only using those for some debug.logs haha

opaque ledge
#

oh man, Dungeon Keeper 2 was my first pc game πŸ˜„

safe lintel
#

rip bullfrog

tardy spoke
#

bullfrog was awesome. Syndicate and theme hospital and stuff.

opaque ledge
#

never did subscenes \o/

tardy spoke
#

If you ever do, here's a handy trick for subscenes. If something isn't working, restart Unity and 90% of the time it will start working.

coarse turtle
#

sounds like my initial experience w/ subscenes

amber flicker
#

Yesterday I finally found one subtle thing about subscenes that I feel happier about now it’s explicit in my understanding. In case it helps anyone else - I think entities from a converted subscene are present on the first frame only if the subscene is open - otherwise they don’t exist until the second frame. 😬

tardy spoke
amber flicker
#

So if you did something like eg cache a reference to an entity on start it may work with the subscene open but not closed.

tardy spoke
#

like open in the editor, right?

#

Not active/inactive?

amber flicker
#

Correct

#

They β€˜load’ after the other gameobjects in the scene.. I understand using MB’s isn’t the ideal workflow but honestly I think they should have them loaded in by awake like everything else in the scene. I posted on the forums about it πŸ€“ (https://forum.unity.com/threads/subscene-timings.944961/)

#

But I don’t expect it to change

tardy spoke
#

MBs?

#

ah, monobehaviours, right

amber flicker
#

Ah sorry yup

tardy spoke
#

Yeah, I'd like to learn about initialization orders and stuff because the majority of my issues stem from that

tight blade
#

oh man. if anyone finds any good resources regarding that, definitely circulate them here

dark cypress
#

Where can I find some examples of procedural meshes in ECS?

tardy spoke
#

Hmm, any way to do MathF approximately but with the ECS math library?

rancid geode
#
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool Approximately(float a, float b)
        {
            return math.abs(b - a) < (double)math.max(1E-06f * math.max(math.abs(a), math.abs(b)), math.FLT_MIN_NORMAL * 8f);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool Approximately(double a, double b)
        {
            return math.abs(b - a) < math.max(1E-06 * math.max(math.abs(a), math.abs(b)), math.DBL_MIN_NORMAL * 8);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool Approximately(float a, float b, float tolerance)
        {
            return math.abs(a - b) <= tolerance;
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static bool Approximately(double a, double b, double tolerance)
        {
            return math.abs(a - b) <= tolerance;
        }

those are some I have been using myself

tardy spoke
#

Awesome, thanks πŸ˜„

#

@amber flicker I can tell you there are some interesting challenges caused by moving the entire level occasionally since subscenes are loaded async, haha. There's a flag to disable async loading i'll experiment with but that's probably not a great idea.

#

Trick is you can't seem to access "inside" a scene to move a root object if the scene is closed... I don't think?

#

(You also can't just move the translation of a scene itself, pretty sure).

granite spoke
#

@tardy spoke we have about 50 at the moment and yes i expect a DOTS based game to have 1000 to 2000 systems at the end if it is not too big.

@safe lintel Not yet. For now we are not doing animations but when we come out of pre-production that package should be ready. We are using cinemachine in the main thread and also old uGUI and not UI Toolkit (a.k.a UI Elements) for now.

What we need to be able to ship is a deferred renderer for URP since we have lots of lights for our show system and balls in stadiums and also animation package but having cinemachine and UI Toolkit for ECS can help as well. otherwise we have everything that we need for the moment. Of course later on if we want to add multiplayer we will need more ready NetCode but since I'm a multiplayer developer, I'm just trying to keep systems multiplayer ready for now and can deal with that later on. At worst we need to use the transport layer and write our own high level stuff which is not good for our budget but it is in my set of skills so i don't worry on that too much.

The game couldn't be done without ECS due to the number of balls and crafted cars and aircrafts in the world at the same time

amber flicker
dark cypress
#

Unity is telling that to not convert GOs to entities at runtime I need to put them in a subscene. Can I do that with prefabs, or is that for scene objects only?

mint iron
#

you should be able to have a prefab in a subscene convert properly

#

interesting though on the runtime warning, we had been told by topher quite a while ago that conversion outside of a subscene is not going to be supported, makes sense they're now warning people about it.

amber flicker
#

you can create a single 'Prefab' subscene and put all your prefabs in there but I hope in the future there is some kind of pure prefab equivalent

opaque ledge
tight blade
#

Man, this is a real bummer. Ive been operating on PhysicsVelocity this whole time naively hoping it was as simple as that. But no, it turns out that an Entity's actual physics data is in a MotionVelocity and MotionData struct owned by the world and not in a component.

tight blade
#

no chance anyone here knows of a way to update motion data directly, is there?

deft stump
#

goddammit unity

#

XD

#

37 minutes and 14 seconds!

mint iron
#

i tend to kill the process at 1 minute, but my projects are small

deft stump
#

well I'm killing it

hollow sorrel
#

@tight blade what's your issue with using PhysicsVelocity directly? 90% of the time this comes up it's a scheduling order issue but i don't wanna assume

#

it's true that the 'actual' motion data is owned by physicsworld but you won't need to touch this 90% of the time

#

think of ECS like an interface layer
ecs components get converted into physicsworld, physicsworld does a step on its internal data, physicsworld converts internal data back to ecs components

#

afaik this is mainly so that you can just drop in Havok for the physics step part and still use the exact same ecs components as you would with Unity Physics (not-havok)

tardy spoke
#

@tight blade what behaviour are you trying to achieve by affecting the physics stuff directly?

tight blade
#

Sorry shopping! One sec!

#

Effectively, I want to only allow something to roll in one direction, and I want it to roll in that direction with no inertia acting against its rotation

#

If you set inertia to its lowest effective value at 1E-10F, cancelling angular velocity in a particular direction will have no effect. The ball will still rotate, even with an angular velocity of 0

#

Regardless of when you run the system that zeroes out the angular velocity

tardy spoke
tight blade
#

Yeah, not really, because I need the inertia in one direction, but not the other

tardy spoke
#

Hmm, yeah, I could see that being tricky

tight blade
#

So the idea was to just set inertia to 0 in both directions and cancel the velocity in one direction

warped trail
#

reset angular velocity after simulation?

tight blade
#

Doesnt work. The rotation has already been resolved from the collision.

warped trail
#

and roll back

tight blade
#

Rolling it back doesnt help because the thing its attached to has already been pulled by its rolling along the ground

#

The actual rotation doesnt matter, it's the rotational movement and its effect on connected entities that needs to be prevented

#

Preventing angular velocity doesnt work because the contact with the ground transfers the impact * inverse inertia calculation directly into the motion data

#

Which is then subsequently transferred into the angular velocity as a way to preserve it for the next frame

#

But cancelling the angular velocity does not prevent the motion data already calculated for that frame from applying movement to the system

#

Basically I'm trying to intercept the momentum, not the velocity

#

And that's not accessible, which is reasonable.

#

I'll figure something out.

tardy spoke
#

It'll be interesting to see what your solution is and how hard it is to implement

tight blade
#

To test this by the way, have a sphere with inertia set to 1E-10F on all axes and then attach a system which sets its angular velocity to 0 every frame. Then drop it on an incline

#

You'll see it roll downhill

#

Even though angular velocity is 0

#

And it wont matter when you set the system to run

#

And the reason I'm doing this, by the way, is to have friction that only applies in one direction. When the wheel locks up and isnt allowed to move, the ball skids and applies friction to the system. When the ball rolls, friction isnt applied, like when you're on rollerblades. If you move laterally, the friction from the wheels makes you skid. If you move in line, the wheels roll

#

So, the idea here is that I want roller blades that dont roll backwards. Only forwards.

tardy spoke
#

Interesting. I wonder if Havok has any abilities or anything around that

tight blade
#

That's an interesting thought. I should probably try it anyway, if for no other reason than to see how deeply locked into the Unity Physics implementation I've gotten myself πŸ˜…

tight blade
#

I think the biggest issue is that one doesn't get access in PhysicsVelocity to the immediate result of collision

acoustic spire
#

I'm procedurally generating mesh and it ignores directional lighting. The cylinder is classic GameObject and it has same material. What can be the problem?

#

Component data is set here:

   entityManager.SetSharedComponentData(entity, new RenderMesh
   {
       mesh = mesh, // vertices & indices only
       material = atlasMaterial // basic diffuse atm
   });
zinc plinth
#

read the code of what you're using, the fact that all entities code is OS is amazing and should be taken advantage of

acoustic spire
#

adding it didnt help though

zinc plinth
#

create a debug shader and check your normals

#

and/or your uvs

acoustic spire
#

yep, I forgot about vertex normals

half jay
#

After upgrade project from 2019.3 to 2020.1 and launch it on Android getting error

#

Busrt 1.3.3, Entities 0.13.0. Using all last version of depending packages

finite breach
#

What function does !HasComponent<LocalToWorld>(target.entity) inside a Entity.ForEach use internally? Is it better to use ComponentDataFromEntity and WithReadOnly?

amber flicker
#

@finite breach that is what it compiles to (XXXComponent = CDFE) - they're equivalent I believe πŸ‘

#

if it's in the hot path and you're testing for the presence of a component, you may want to consider IJobChunk or similar

finite breach
#

@amber flicker Thanks! I found the old forum thread again too. Fetching ComponentDataFromEntity before the ForEach is slightly faster. But as always with DOTS, the gain is probably negligible if running it on a very small number of entities.

amber flicker
#

hmmm I wouldn't expect a difference in speed in a built with safety checks off if they're both checking inside the loop

finite breach
#

@amber flicker The difference, I believe, is HasComponent, would trigger the ComponentDataFromEntity() call on every ForEach, whilst assigning ComponentDataFromEntity to a variable before the ForEach would result in 1 ComponentDataFromEntity() call.

zinc plinth
#

urggg, I thought Mesh was a struct and was like Awesome I can throw my mesh combining in jobs

but turns out that nope, it's a damn class --'
so I either have to copy every damn field and somehow do the combining myself, or just give up on jobs..

#

it sucks

#

one good thing I guess is that this is big SIMD potential then if I do it manually

amber flicker
#

@finite breach oh really? did you check out the compiled code? A bit surprised if it doesn't compile down to the same thing but good to be aware of.

finite breach
#

@amber flicker I didn't go into the compiled code. That's what I concluded from the post, but again it was from 2018 so they might have optimized it. I'll check out the code.

finite breach
#

@amber flicker Seems the compiler handles it nicely now and does exactly the same thing, if not better because it gets moved to a IJobChunk automatically with the extraction of the ComponentDataForEntity outside the loop

amber flicker
#

sweet - thanks for following up

rancid geode
#

Almost nothing from 2018 is valid today, 2018 version has many major differences to how things are now

finite breach
#

Yeah I know, it has been 3 months since I used dots and I am checking up on the changes again 🧐

opaque ledge
half jay
#

@opaque ledge not rly. I deprecated Entities to 0.11.0 still have this error but without Out of memory. Found this solution which was described two days ago.
https://answers.unity.com/questions/1755666/cannot-load-lib-burst-0-0-on-android-builds.html

tight blade
#

@zinc plinth ohhh damn that sucks. what a bummer. mesh isn't a struct?

zinc plinth
#

Mesh is a class, renderMesh is a struct ISCD

#

So bye-bye jobs

#

Cuz m not rewriting CombineInstance by hand

tight blade
#

uggggh

zinc plinth
#

At least I only have to combine my meshes once so..

#

Just. More loading time I giess5