#archived-dots

1 messages ยท Page 182 of 1

shy pilot
#

and type com.unity.entities

pliant orbit
#

Cool yeah okay that works

#

Thank you

shy pilot
#

here's a list of packages you can't get just in case you need it

#

(apologies for the B R I C K of text, couldn't get spoilers to work :()

#

you know what this link does a better job

dull copper
#

was this mentioned here?

#

All DOTS packages are scheduled for new releases the week of 27 Oct

#

kinda weird way to put it but they probably just mean some time during next week

amber flicker
#

there was another post mentioning end of oct which I linked but good to have a specific week... feels more likely to actually happen ๐Ÿ˜…

dull copper
#

there's no week left in Oct after next week though ๐Ÿ˜„ but I guess now we know it's not happening this week

deft stump
#

Imagine waiting 1 whole week for a new releases...
crossing fingers that enable/disable components is now added

amber flicker
#

I'm guessing it's mostly the rework of codegen stuff? don't understand why they can't say what's in 0.16.. so frustrating

dull copper
#

I was just about to test few things in unity physics perf wise but knowing this I'll just wait for next package

#

imagine if they had like open development in github :p

#

it feels like some key people at Unity like to surprise users rather than do the dev openly

hearty aurora
#

Hey guys I have a doubt regarding installing Unity
when I install unity it automatically installs 32 bit version but my computer supports 64 bit version. So, can someone please help me how to download 64 bit version of unity.

dull copper
#

what

tawdry tree
#

First off, this is the wrong channel for that

#

But second, are you using the Unity Hub or direct download?

hearty aurora
#

k sorry

#

direct download

dull copper
#

afaik there isn't even 32bit version of Unity editor anymore

#

it's been 64bits since Unity 5?

hearty aurora
#

I want a 64 bit version

dull copper
#

that's like.. since 2014 or something

tawdry tree
#

How do you even do a direct download?

dull copper
#

you can get direct download for installers

hearty aurora
#

but when I download from their site automatically 32 bit version is downloaded

deft stump
#

just download unity from the unity hub

tawdry tree
dull copper
#

this is totally wrong channel for this

tawdry tree
hearty aurora
#

k sorry for that

dull copper
#

I'm only saying this because it really sounds like there would be tons of beginner follow up questions to that

amber flicker
#

just added to that post asking what the high level changes we should expect are ๐Ÿ˜… ๐Ÿคž ยฏ_(ใƒ„)_/ยฏ

hollow sorrel
#

hope they update everything at same time (physics package etc)

dull copper
#

I was about to say that "all dots packages" doesn't necessarily mean physics ๐Ÿ˜„

#

in past they've treated it bit differently

#

but one can always hope

#

there was another post mentioning end of oct which I linked
@amber flicker you still have this link?

#

I tried to scroll back a bit but didn't spot anything

dull copper
#

ty

#

wonder if we'll get that DOTS blog post once we get updated packages :p

#

I did read the comment from Joe on the forums earlier

#

(about blog post taking some time still)

amber flicker
#

might have missed that - have a link handy?

amber flicker
#

ah yes I had read those, thanks

dull copper
#

hmmm We have more than ~60 engineers full-time working on DOTS.

hollow sorrel
#

anyone know if you can set a specific GameObjectConversionSystem's target world? instead of the DefaultGameObjectInjectionWorld

tawdry tree
#

IIRC the gameobject conversion happens in two steps:

  1. It creates a new world and builds the entity there
  2. Then it copies the entity over to the main world.
    What you want is to get that temp world in #1? Pretty sure you can only do that in conversion scripts
amber flicker
#

I don't know the answer. Reminder that these api's are fairly unfinished and it's not necessarily a supported use-case. But maybe it is. If you did the above then copied all entities to your custom world, I guess you'd then destroy that conversion world and hope the system that would have copied it to main doesn't run? Guess this journey will take you through the source code. Otherwise maybe it's easier to mimic what the conversion stuff does - creating a second temp world for conversion yourself then copying back?

tawdry tree
#

As always, depends on the use case - what are you trying to accomplish?

maiden delta
hollow sorrel
#

copying to a different target world in #2 would be fine too, just wanna be able to specify it on a conversionsystem basis
if i do the conversion manually like timboc said i think it's doable (without subclassing GameObjectConversionSystem) but if there's a built in way that'd be easier

#

as for the use case, i've got a simulation world and a render world, just trying to get something to show up in render world directly without going through simulation

maiden delta
#

anyways, how do i set center of mass from code in unity physics?

hollow sorrel
#

@maiden delta the PhysicsMass component has a centerofmass property

maiden delta
#

Entities.ForEach cannot use component access method SetComponent that needs write access with the same type Translation that is used in lambda parameters. why? im setting translation of the other entity

hollow sorrel
#

not sure what that means

#

could you post code?

maiden delta
hollow sorrel
#

guessing it's because you pass Translation as in but are also setting it

#

in = readonly

#

ref = also write

maiden delta
#

thats dumb

#

the safety check or whatever this is needs to be somehow adjusted to check if it's actually the same entity

hollow sorrel
#

how is it going to know the entity you're setting isn't also in the same chunk

rancid geode
#

@maiden delta just remove the in parameter and use GetComponent to get it from your current entity too

maiden delta
#

yeah thats what im doing @rancid geode

olive kite
#

is there a better way to structure getting information out of entities.foreach? I am creating a nativeArray is there a way to know how big to make the array ? i feel like i am missing something

tawdry tree
#

Get structure information out of foreach?

olive kite
#

yeah

tawdry tree
#

If you mean get amount of entities matching a query, you could use the entityquery estimate count thing, I think?

#

But also, nativearrays apparently rescale if needed? No idea if that's safe, but honestly I'd just start it off at a good estimate

#

So to begin with, intentionally make it lower than it needs to be (size 0?) and see if it explodes

olive kite
#

that's what im going currently, the calculate

tawdry tree
#

if it doesn't, then you can safely use a "probably big enough" size

olive kite
#

oh they do?

tawdry tree
#

The docs said something about that, or rathjer implied from the methods they had and stuff

olive kite
#

yeah that would be fine, just didn't know if there was a way to get an exact count prior

tawdry tree
#

It does say estimate, so not sure if it's guaranteed to be accurate

stone osprey
#

Back with some design questions :/ Im trying to design some sort of inventory-items relation. Inventory is attached to the player and item is its own entity. So the inventory is pretty much only a list of entity-ids. I want to react to "changes" or "events", for example when the item was modified ( amount... ) or when a new item was added to the inventory... Would you use events for this ? Or would you simply mark the entities ? // Mark Item, Mark Inventory... {Item, Changed} => ... {Inventory, Changed} => ... ? What would you stick with ?

#

One problem is that when i mark the inventory entity with "Changed", i dont know what item exactly was added, removed or modified

amber flicker
#

@stone osprey what kind of things do you want to happen in response to the event?

stone osprey
#

@amber flicker Debug logging, Applying of effects that modify stats, sending network packets, marking entities for being saved to the database, merging of items ( stackable items ) :/

amber flicker
#

I think some people might go the events route. In particular I think Tertle said he mostly used his event system for debugging. I would probably do these all with Tags/Components. E.g. InvetoryUpdate { bool Enabled } - when enabled effects/stats are modified/recalculated, network packet is sent, items are checked if they can be merged.. maybe?

stone osprey
#

@amber flicker Thanks, thats properly the right way ๐Ÿ™‚ Any tipps on storing what item was "modified", added or removed in the inventory ? Should we just store them in a several component like "AddedToInventory{ list of entities }" ? ^^

amber flicker
#

I think (it depends) I would try and make things independent of what's been added. When does it really matter?

stone osprey
#

That sounds logical... so instead of listening to to the inventory, we would attach the logic we wanna execute to the item itself... thats a lot cleaner, thanks ๐Ÿ™‚

amber flicker
#

I don't know about attaching the logic to the item - perhaps that's a good idea ๐Ÿ™‚ - more just that I would try to make things work without requiring a pre-existing state. i.e. rather than have a system that adds/removes meshes to a character based on what's equipped, have a system that sees the equipment has been updated, set all those meshes to be enabled and disable anything else. Stateless basically.

stone osprey
#

Ah i see ๐Ÿ˜„ well that would fit perfectly in this situation... an ecs architecture just offers so many different ways... its kinda hard to keep the overview ^^

amber flicker
#

totally.. just to add my usual caveat... I don't see myself as an expert, just offering up how I'd think about it.

stone osprey
#

@amber flicker And thats totally fine ๐Ÿ™‚ Im glad for any feedback and thoughts... this is the only way to improve ^^ I had a time where i coded everything like i wanted ( or thought it would be the best way ) and it turned into a real mess ๐Ÿ˜„

foggy stream
#

@tawdry tree Forget about it, Iโ€™ve given up on DOTS. Iโ€™m still gonna try to implement a slower custom ECS in my game. It should take less long to implement.

stone osprey
#

@foggy stream You could probably look into Entitas for C#

safe lintel
#

@dull copper did that number seem more or less than what you were expecting?

foggy stream
#

@stone osprey Thanks for the link, Iโ€™ll take a better look at whenever Iโ€™ll use it or not later.

dull copper
#

@safe lintel it's a lot but I do get they have people split into numerous teams and only fraction actually work on ECS core itself

tawdry tree
#

TBH ECS core is quite usable already. There are points to be improved (enable/disable, anyone?), but what stops most people from doing anything useful with ECS now is all the auxiliary libraries for physics, animation, and whatnot

low tangle
#

scope of the game matters a lot

safe lintel
#

the enable/disable thing surprises me given how many people kinda seem to make it sound like a huge issue vs say like audio, animation, pathfinding etc

low tangle
#

its not that big of a deal, but everyone is obsessed over performance. wanting to get rid of the tag component chunk copy cost

tawdry tree
#

Enable/disable is just a nice convenience feature really, and one I can't imagine being too complex

low tangle
#

but it doesnt work on 1mill/frame REEE

#

what about, ya know, doing the rest of your game structure where your gonna loose the rest of your perf first?

safe lintel
#

im more in the camp of give me features ๐Ÿ˜ฉ

low tangle
#

yes

#

UECS needs a bit more features

#

I wish the internal type manager was easier to work with for networking

#

ended up going with hand rolled codegen

tawdry tree
#

Physics and animation should at the very least work, and work easily, since those are oh I don't know, used in 90% of projects?

low tangle
#

yep

safe lintel
#

need a #srplife equivalent for dotslife

low tangle
#

I absolutely loathe SRPs

#

everything about them

safe lintel
#

tbh the whole build your own srp if urp or hdrp doesnt work seems like a massive undertaking, i dont understand how anyone could really look at it and think it looks like a good place to roll your own given how long its taken unity to get to where they are with either rp

dull copper
#

I'm more in camp of give me proper editor experience

#

as for custom srp, it's not really meant for average indie dev to roll their own solution

low tangle
#

I don't like core rendering systems being in slow c# instead of cpp

dull copper
#

how I see it, it's only a thing for people either interested on fiddling with renderers or bigger teams that have dedicated people building this tech

low tangle
#

been digging though a lot of unreal the last few weeks and damn I wish we could just interface with unity though cpp

#

yeah fixed workload games, where you dictate what shader passes, shader workload you might have

dull copper
#

cpp is not very nice to iterate code with

low tangle
#

its perfectly fine

dull copper
#

spend a little more time in unreal then ๐Ÿ˜„

#

I mean, you wait for it to build something all the time

low tangle
#

nah I can't stand the data size

#

on my internet I've wasted 3/5 work days last week just waiting on uploads and builds

safe lintel
#

i would imagine any big company wanting to take this on a significant custom srp would probably just go with their own engine entirely?

dull copper
#

I'd love to have c++ api on Unity too, but mainly because it would be nicer for native plugins

low tangle
#

some companies dont want to switch from unity

safe lintel
#

as for proper editor experience, id like to see this too but this also seems really far away

low tangle
#

shader compiling was far longer than cpp build times in unreal, the last several weeks. the raw engine build did take 45min though. but that was once per type (debug, shipping) @dull copper

dull copper
#

you'd really want some high end rig for ue4. shader compilation times are tolerable on high core count cpu's

#

I think I last timed 4.22 or 4.23 for raw engine build and it was like 1h 15m on my old i5 and 20 minutes on ryzen 3900x (13 minutes for actual engine rebuild without tools getting rebuild)

#

you can imagine the time savings on the longer run on faster computers if you work with unreal

dull copper
#

I'm actually most impressed on the improvement on 3900x for those shader compilations, they used to take forever

#

can only imagine how fast it is on modern threadrippers

low tangle
#

for sure

#

on my old xeon server it isn't very fast either doing CLI builds

#

but I think unity builds should be faster (il2cpp)

dull copper
#

Unity can multithread builds now better too

#

2020.2 made IL2CPP processing MT

low tangle
#

which version, I'm currently on 2019.4

#

ah

#

I can go to 2020.1 but not .2

dull copper
#

actual cpp builds have been MT always on windows afaik but not the conversion, it's been single threaded before

low tangle
#

yeah it was

dull copper
low tangle
#

ty

dull copper
#

For 6-8 core machines the conversion process will see roughly a 60-65% decrease in conversion time. On a 64 core machine conversion time decreased by 73%.

#

not the best scaling for a lot of cores apparently ๐Ÿ˜„

dull copper
#

yeah I know ๐Ÿ˜„ still funny how it goes

low tangle
#

always love it

#

50-75% parallel then

dull copper
#

in DOTS you even get worse perf the more cores you give to it :p

#

so it goes negative

low tangle
#

yeah stupid ass scheduler

dull copper
#

I'm still hoping to see them allowing us to limit max worker amount per schedule etc

#

or per system, whatever makes more sense

low tangle
#

I'm currently dialing back most of my ecs systems, shifting to managers scheduling bursted jobs

#

yeah that would be nice

#

or them redoing the scheduler totally

#

theres a lot of other ways to do it than just work stealing with a DAG

safe lintel
#

wonder if the scheduling is on their radar

low tangle
#

I think it is, remember seeing them working on it to make the cost less

dull copper
#

I think so too

#

pretty sure Joachim mentioned they are going to handle the non-bruteforce cases better as DOTS needs to perform on lesser scale simulations as well

#

and Physics talk from Unite Now did say they want to be able to run Unity Physics at user set worker thread count which wasn't possible by the time they made that video

#

we all know that DOTS can be nice for brute force simulations but I need it to do regular gameplay scenarios well too

safe lintel
#

yeah saw that earlier, im really skeptical of what the non dots version looked like

dull copper
#

I'm going to go and guess it was just some trivial setup where they did it single threaded

#

and not using TransformAccessArray etc

low tangle
#

stop using fps

#

frame time in ms

safe lintel
#

stop spinning cubes! make meaningful tests!

dull copper
#

we should have some bot that does inverse for fps every time you type it in gamedev context :p

low tangle
#

yes

shy pilot
#

is it possible to have mulitple sharedcomponentdata on one entity?

low tangle
#

yes

shy pilot
#

thanks

#

one other question

#

is it possible to avoid this if i want to get some information from a shared component without sacrificing ScheduleParallel()?

#

is there a way of storing a reference to the sharedcomponentdata on another component or something so i can access it?

low tangle
#

been awhile since I did, but yeah you can, it involves caching the shared components into a array for the job

shy pilot
#

ok, thanks

#

so i'd need to ditch SystemBase?

zinc plinth
#

@shy pilot most of the time I advice to just use the jobs structs instead of Entities.ForEach

#

also, you can't have reference types in jobs outside main thread

#

so if your shared component is a reference type then it'll have to run singlethreaded on main thread

#

which looses the point of jobs really

#

if there is some way you can make that type a value type I would strongly suggest you to do it

#

and no you shouldn't ditch SystemBase

shy pilot
#

ok @zinc plinth so you're suggesting i just turn my component into a normal IComponentData and just deal with having all that wasted memory?

#

can anyone provide an example of entities.foreach-like behaviour in a job?

zinc plinth
#

you can completly have value type shared components

shy pilot
#

i just can't access them from within a parallel job?

zinc plinth
#

create your struct, copy your shared compient inside the struct as you would for any other value type/native container

#

the restriction is on reference type, some value type data comming from a shared component doesn't matter at all

shy pilot
#

ohh

#

ok, thanks for clarifying :)

shy pilot
#

in the job if i try to do this

NativeArray<SpeciesSharedDataComponent> speciesComponents = chunk.GetNativeArray<SpeciesSharedDataComponent>(speciesTypeHandleAccessor);
#

i get a boxing conversion error

shy pilot
#

hmm

#

does anyone know if it is possible to store an array inside a component (not on an entity with a dynamicbuffer)

shy pilot
#

can you just declare a dynamicbuffer from within?

coarse turtle
#

Well you can store a pointer inside a component or an UnsafeArray inside a component, which you can treat as an array - you'll need to manage the memory when you destroy the entity - so you can dispose the memory allocated

shy pilot
#

hmm

#

can you just do something like this?

public struct TestBufferComponent : IComponentData
{
    public DynamicBuffer<FixedString64>       fixedStringBuffer;
}
coarse turtle
#

No

#

Well truthfully I've never tried, but I imagine you might need to figure out how to allocate a buffer inside a component. Not sure if there's any convenient functions to do so.

#

You could do

public struct TestBufferComponent : IComponentData
{
  // Just need to manage this UnsafeList to free up the memory
  // when you don't need it
  public UnsafeList<FixedString64> fixedStringBuffer;
}
#

Is there a reason you can't just use an IBufferElement/DynamicBuffer?

craggy orbit
#

if i've got one value (like maybe an int or float) that i use in jobs that's the same across the project, would it make sense to turn that value into a shared component or would my current approach of having a manager monobehaviour (for editability) be better?

deft stump
#

do you think this one value would change?

#

if not, and it's constant, then yeah go for it. make it a shared component.

hollow jolt
#

im getting

IndexOutOfRangeException for IJobParallerFor in ReadWriteBuffer

are we limited to the specified range given per batch ?

public struct ComputeNormals : IJobParallelFor
{
    [ReadOnly] public NativeArray<float3> verticies;
    [ReadOnly] public NativeArray<int3> triangles;
    public NativeArray<float3> normals;
    
    public void Execute( int index )
    {
        int3 triangle = triangles[ index ];

        normals[ triangle.x ] = math.cross
        ( 
            verticies[ triangle.y ] - verticies[ triangle.x ] , 
            verticies[ triangle.z ] - verticies[ triangle.x ] 
        );
    }
}
amber flicker
#

Fyi โ€œEnable / disable component feature is planned to land sometime in Q4 2020โ€

hollow jolt
#

wdym

deft stump
#

Fyi โ€œEnable / disable component feature is planned to land sometime in Q4 2020โ€
@amber flicker hope it's true! I need that in my life!

hollow jolt
#

i added [NativeDisableParallelForRestriction] and it seemed to solve the error , anyone knows what is it and how does it impact the performance ?

dull copper
#

so next year it is

deft stump
#

YAY!

#

That's very exciting news

hollow jolt
#

anyone ?

#

the docs are missing

dull copper
#

I really dislike the most that we don't have any kind of dots roadmap, even for things that are actually on their way already

#

I can see that they don't really have a solid plan they can share and things change all the time but they do know what's coming up in near future

#

would be nice for users to get heads up on these so they don't create complicated workarounds for things that are about to get fixed on next release

hollow jolt
#

what are the downsides of using NativeDisableParallelForRestriction ?

amber flicker
#

@hollow jolt mostly that if you write to the same index from multiple threads, it's not guaranteed what data you'll end up with. So you only use that attribute when you are sure you're not writing to the same index from different threads.

hollow jolt
#

i see

#

IJobParallelFor shouldn't call the same index twice , doesn't it ?

#

When a worker has finished all its work, it looks at the other workersโ€™ queues and tries to process some of the items assigned to another worker.

#

^ IJobParallelFor

#

is that what u meant ?

hollow sorrel
#

@hollow jolt when you pass in those NativeArrays, you could write vertices[0] = 3f; and it'd set that index in multiple jobs, possibly at the same time, so unity's safety check prevents you from that possible scenario
if you only use the index of parallelfor it's not gonna set the same twice, but unity doesn't know that, so that's why you have to disable it manually

hollow jolt
#

brilliant , thanks

hollow jolt
#

was looking at mathematics source and there is a bunch of aggressive inlining, any advantage of using that over inlining the same thing directly ?

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float3 operator / (float3 lhs, float rhs) { return new float3 (lhs.x / rhs, lhs.y / rhs, lhs.z / rhs); }
quaint niche
#

Hi,
Is it possible to make entities using Unity Physic collide with object having collider in an Hybrid System ?
A bit more of an explanation.
I'm using Mixed Reality Toolkit (MRTK) and I play with Unity DOTS.
MRTK provide a spatial mesh with a collider, but this is not Unity Physics. I have some characters and want them to walk on this spatial mesh, but they are using Unity Physic.
Is it possible to make the characters walk on the spatial mesh ?

hollow sorrel
#

@quaint niche you'd have to convert the collider to a unity physics collider

pulsar jay
#

Is it possible (or does it even make sense) to reference other components in a component or is it only possible to reference other entities?

#

For example if I collect a Dynamic Buffer of enemies I guess it would have to be a list of Entities or can I somehow reference e.g. Health components directly

deft stump
#

I feel that components referencing other components is creeping into OOP, imo

#

then again, it IS convinient

amber flicker
#

IComponentDatas are value types... bit weird to think of a float referencing a float (in a general sense) for example

amber flicker
#

@hollow jolt afaik AggressiveInlining means at compilation time the content of the method is copied in place - avoiding the overhead of the function call. For heavily reused methods this can add up. One downside is it can confuse VisualStudio line number navigation.

frosty siren
#

Hi all. What the right way today to authoring IBufferElementData with Entity field (1 field)? I thought GameObjectConversionSystem.GetPrimaryEntity(UnityObject) will work. And it works if converted entity was with option Convert and Destroy. But it won't work with option Convert and Inject GameObject. What a black magic?

tawdry tree
#

So you have a GO you're converting
And you want to grab the entity struct from the converted GO...
And save it on that same entity?
Or am I misunderstanding here?

frosty siren
#

I have some GOs in scene that will be converted. One of them need to grab others and save on himself. I tryed to play with it and find out that it problem happens only if linked entities are childs of converted gameobject

tawdry tree
#

The conversion workflow in general does not like hierarchies, IIRC

frosty siren
#

I'd rather know this beforehand๐Ÿ˜„

pliant pike
#

I don't really understand subscenes it seems like I can't use them to get access to the entities converted in them ๐Ÿ˜•

pulsar jay
#

@deft stump @amber flicker thx makes sense. Just wanted to make sure that Im not missing something

frosty siren
#

want little page in dots docs with just one string "And remember NO HIERARCHIES"

amber flicker
#

that's not particularly true about hierarchies and conversion workflow. That said, it certainly isn't seamless. In particular, Convert & Inject has some quite unintuitive behaviour imo - I would always try and avoid specifically that mode myself.

#

@pliant pike wdym?

pliant pike
#

I think I get it I cant have an empty object and then have a bunch of scene items within that

amber flicker
#

Don't really understand that.. but ideally you don't want to be creating a hierarchy if you don't need one

pliant pike
#

yeah I didn't realise that

#

its just easier to put a bunch of your scene objects into an empty object and then right click create subscene

amber flicker
#

I understand it can be useful for grouping. FYI you can right-click a selection of gameobjects and create a subscene from everything selected.

pulsar jay
#

Regarding hierarchies I found that having them for debugging reasons while developing helps. The hierarchy in the new entity window helped me a lot compared to the entity debugger

#

It would just be great if it could also show a hierarchy by linked entity groups and not just parent/child relationship

pliant pike
#

yeah its confusing when the converted entities don't appear in the entity debugger

fringe sinew
#

I want to ask some questions regarding Hybrid Renderer V2

#

In particular about the giant computebuffer

#

I understand the basic gig: fill that giant compute buffer and then sample per-object/entity data from it.

#

Kinda a bit like SRP Batcher's per-object cbuffers that are being bound with offsets.

#

Correct me if I'm wrong.

#

However, I don't understand how it works exactly.

#

Imagine this: we're in a vertex shader and we wanna get an L2W matrix. Nice of, say, URP to define those for us, right?

#

But it's sampled as a macro and the whole way through there is not a single variable that determines the address offset nor strides

#

Finally, I don't understand how the computebuffer is laid out internally.

#

Let's imagine a hypothetical situation that we have 9000 materials that just use per-object data (say, 7 float4 for ambient probes and an L2W matrix)

#

Now, let's create (or better yet, load from an assetbundle) a material that has one per-object override for material's color/secondary color/normal scale/etc. What happens now?

stone osprey
#

Would you rather use extensions, component methods or some sort of ecs events to modify a certain entity/component ?

#

My case : Working on an inventory mechanic, when an item gets removed, added or updated i need to mark that entity and the inventory entity itself. I need this quite often so im not sure if i simply should duplicate that code, put it into a extension, component method or create a ecs event for this operation

tawdry tree
#

By "quite often" I assume you mean done from several places in the code?
How often does it happen in terms of perf, though? (max and average) Several times per frame? Once a frame? Once every few frames? A couple times a sec? Once a sec? Every few secs?

#

Using an event sounds like it might be the most "correct" way to do it, but also like probably the most PITA way to do it. You should most definitely not duplicate the code, if nothing else make it (a) static method(s) (possibly extension). Component method also sounds like it might make sense, but that sounds closer to OOP than you might want to go. I'd say it's probably fine if a utility kind of function, but would prefer it in some outside function, and write it as functional code (meaning, no state change, just data in/out)

steady blaze
#

question: is Jobs and/or Burst Compiler a part of DOTS and therefor in development-stage or is it production-ready?

opaque ledge
#

i think Jobs and Burst is production ready

little moon
#

@fringe sinew I'm curious as well actually. Maybe let's ask in DOTS forums

fringe sinew
#

I'm currently looking at the code. With pain and the help of a rubber duck I could peace quite a bit of it.

#

it's a bit convoluted, I'm still trying to figure out how memory is managed (specifically with entity archetype chunks).

#

On GPU, this whole thing is extremely simple if you get past the macro-filled hell of an hlsl file for DOTS Instancing

#

Your shader gets a CBuffer that contains metadata about properties. You also get an instance id (this one seems to be set up under Unity's hood).
Metadata describes the start memory address of properties block and if it's overridden with a component data (if not then tries to point to default data).
By using metadata info and the instance id you can look up the address of the final data in the giant ComputeBuffer.

glass tiger
#

are there any good up-to-date tutorials/resources for learning dots ECS aside from the entities package documentation? the ones I've found so far seem to use deprecated APIs so I'm not sure if they're still relevant

brazen storm
#

Anyone know how to get a terrainMesh into an ECS system? I need the bounds and a few heights. Mega appreciate any direction here!!!

radiant sentinel
#

Hello, i need GetHashCode at parallel jobs or Random function. I have tested unity mathematics random , but it is not working correctly when i set different seed on each job of parallel scheduled job.

#

Can i generate random number base on perline noise?

#

Mathematics random, always generating 0 between 0 and 2. But the seed is different.

steady blaze
#

@radiant sentinel as far, as i can see Unity.math has some kind of Perlin noise, but don't know how to set a seed for it. only thing I've tried on dots is this tutorial:
https://www.raywenderlich.com/7880445-unity-job-system-and-burst-compiler-getting-started#toc-anchor-001

raywenderlich.com

In this tutorial, youโ€™ll learn how to use Unityโ€™s Job System and Burst compiler to create efficient code to simulate water filled with swimming fish.

pliant pike
#

you have to set the random number back to itself for it to work correctly I believe

steady blaze
#

this code snippet seems to be for the perlin noise private float Noise(float x, float y) { float2 pos = math.float2(x, y); return noise.snoise(pos); }

#

@pliant pike thx.

#

hm, so the jobs system can also be used for stuff that does not run between update and lateupdate, right? like to split terrain generation on multiple cores, which happens when you move on and the code needs to generate new chunks

slim nebula
#

any help would be appreciated

distant imp
#

Hello, I'm following this doc about writing shader in URP (https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@10.0/manual/writing-shaders-urp-unlit-normals.html) and this specific shader is to visualise normal vectors. I've created a material with this shader.
The sphere on the left is a game object with a ConvertToEntity component and the sphere on the right is created in code with the following:

var entity = entityManager.CreateEntity(typeof(Translation),
                                        typeof(Rotation),
                                        typeof(RenderMesh),
                                        typeof(RenderBounds),
                                        typeof(LocalToWorld));

entityManager.AddSharedComponentData(entity, new RenderMesh { mesh = mesh, material = mat, });

Assume that the mesh is the same primitive sphere mesh and the material is the same material. Any idea why I'm getting different results?

steady blaze
#

so i.e. I want to draw some chunks of a mesh (lets say 27 meshes), i could use a ParallelFor job with Execute (int i) and this execute, i put the code to draw one chunk, right? (i is the index of that chunk)

craggy orbit
#

i is the entity index (in a ParallelFor job)

#

or rather, the index of the iteration you're currently in

#

it can be the entity index, if you set it up that way

#

if you want Chunk based jobs, look at IJobChunk

hollow jolt
#

what's the best alternative to dynamically sized lists when using Jobs ?

#

im guessing using Linq's Append on NativeArrays* would slow it down too much

untold night
#

NativeStream should be what you want

hollow jolt
#

when using writer.BeginForEachIndex( index ); then writing data into it there is no need to keep element size consistent per index , is that true ? ( ie performing different amount of write calls per index )

hollow jolt
#

Looks like stream can't read/write from the same index multiple times , is there anything else i can use similar to a List that can be resized ?

tawdry tree
#

What's the use case? Is this data on entities, or collections of unknown size to be used within the job(s)?

#

Just gonna point out that NativeList<T> is a thing. If it is not default, you can find it in the collections package.

slim nebula
#

[unity.netcode] What's the best way to get the prefab for a specific ghost. Should I create an enum for the indexes that reflect the ghost collection?

#

I will award 10,000 e-peen points to the one who answers my question

steady blaze
#

uhh, don't understand, what's the differnence between iterating through single objects (or blocks) or chunks of them. it should be quite the same, from code.
i really have to check, what this is all about

slim nebula
#

my understanding of chunks is that it's a mechanism to support optimization by letting multiple systems run on the same chunk

#

but if every system is using a unique chunk then it doesn't really do anything

steady blaze
#

if i iterate through each block by index or through each chunk of blocks, each has an index i - and some code to execute then inbetween serially.

slim nebula
#

(but I'm kinda a newb so take that with a grain of salt)

#

oh, that I don't know sorry

steady blaze
#

hmm

#

so you mean, IJobChunk could split up the sub-indices to different trheads, so normally think of entity and chunk. so it can split up the entities in addition to the chunks?

the point in my case, i need to have each calculalte each block after the other, otherwise the shared vertices won't work.

#

that's why i want to have like 5x5x5 chunks and each chunk should be done serially, but the chunks can be done in parallel. that's the idea.

amber flicker
#

a chunk is a block of memory. A chunk can only store entities of one particular Archetype.
Archetype: An entity with a Component A has a different archetype then e.g. an entity with a Component A and a Component B.
This (chunk) block of memory is filled with as many entities as will fit, contiguously. The more components your entity has (and the bigger they are), the fewer can fit in a chunk.
Now you have all the data packed together, the cpu can load the whole chunk into L1 cache at once - so it's now able to operate on those entities very fast. This is really important.
An added bonus is that it gives nice sized chunks of memory for each worker thread to work on separately. E.g. thread 1: process chunks 1-4, thread 2: process chunks 5-8.

steady blaze
#

ok, what try to do is marching cubes, so by block i did not mean, memory, but visual block.
atm it is just a regular C# script, serially optimized so that it calculates each vertex only once, but it has to run block by block, otherwise it would get messed up.

tight blade
#

if you depend on a particular order then I'm afraid neither IJobParallelFor nor IJobChunk are going to help you @steady blaze

#

youll have to find some way to break your dependency on order

#

alternatively, you could make each block its own job that depends on the output of the previous job. they wouldn't be run in parallel, but at least you could keep moving on the main thread

#

if you do that, you just need IJob

steady blaze
#

I meant, the chunks (areas of i.e. 16x16x16) can be processed in parallel, but the inside of each chunk serial.

tight blade
#

hahaha, @steady blaze youre going to need to come up with some new vocabulary for your internal organization of entities. if you keep referring to them as chunks, youre going to drive everyone here crazy ๐Ÿ˜‚

steady blaze
#

so, i have i.e. 5x5x5 chunks and want to calculate 125 chunks, each inside serially, but all of them parallel

tight blade
#

"chunks" are a very, very specific thing in Unity ECS land

steady blaze
#

it's voxel landscape, they are typcially divided in chunks

tight blade
#

right, I know minecraft calls them chunks

#

the trouble is, in Unity ECS, chunks refers to the way things are arranged in memory, not a spatial partitioning scheme like in minecraft

steady blaze
#

dont know what other terms i could use

#

i see, the same problem with blocks

tight blade
#

well, blocks is a little better, actually. I see in the stuff above they got interchanged. I mean theres no one forcing you, but I'd use "spatial partition" if I were you. thats a term that people on the forums use

#

but anyway, back to your question

steady blaze
#

but I could use IJobsParallel to calculate each chunk of voxels serially but have the chunks calculate in parallel, if I give each chunk an index i?

tight blade
#

lol, im so sorry to do this to you, but Im immediately confused by the dual use of the word chunks again

#

which of those uses were referring to the spatial partition, which were referring to ECS chunks?

steady blaze
#

forget the chunks, just the IJobParallel will calculate each index serially?

tight blade
#

nope. in parallel

steady blaze
#

i mean what needs to be done at index 0 serially, at index 1, โ€ฆ serially, but all indices in parallel

tight blade
#

oh, I see. it depends on how you code it but yea

steady blaze
#

or will it mix stuff up within one index?

tight blade
#

nah, theres no magic. its not going to rip apart your forloop and hand some of it off to another job lol

#

I don't blame you for asking though. theres a lot of places where there is magic

steady blaze
#

ok, then it should be fine. i am just a bit confused, as it's new to me.

tight blade
#

yeah, I hear you

#

i feel bad for you because that was a really easy question for anyone here to answer, but we all got confused by the use of "chunks" ๐Ÿ˜‚

steady blaze
#

just a little tutorial yesterday, first contact with the Jobs system

tight blade
#

ah, well, welcome. Its a bit of a mess in the dots world right now, but we'll do our best to help where we can

steady blaze
#

thank you anyway ๐Ÿ‘

slim nebula
#

anyone here familiar with netcode? I just have a small "best practice" question. plz

rancid geode
#

if you depend on a particular order then I'm afraid neither IJobParallelFor nor IJobChunk are going to help you @steady blaze
@tight blade IJobChunk will only be processed in parallel if you use ScheduleParallel, you can process the chunks linearly in another thread by using ScheduleSingle instead

steady blaze
#

@rancid geode as far, as i unterstood, IJobParallelFor should work, as the code that is in Execute (int index) should run normally (so step by step) for each index, so i.e. all code for index 0 should run serially, all code for index 1 too, etc. โ€ฆ
but there can run many indices in parallel.

#

or did i misunderstand something?

btw. what is meant to be a chunk in the ECS system? some kind of group of entities? only tried the jobs so for (and very basically) - will now have a look at the ECS system.

rancid geode
#

@steady blaze correct, IJobParallelFor gives you much more control over that

steady blaze
#

ok, fine then!

rancid geode
#

or did i misunderstand something?

btw. what is meant to be a chunk in the ECS system? some kind of group of entities? only tried the jobs so for (and very basically) - will now have a look at the ECS system.
@steady blaze a chunk รฉ a block of memory with entities that belong to the same archetype and have the exact same shared components (compared by values)

steady blaze
#

@slim nebula what kind of netcode? did some sockets long time ago and later unet, which is now deprecated.

slim nebula
#

unity.netcode

#

I want to know what's the best way to get the prefab for a specific ghost. Should I create an enum for the indexes that reflect the ghost collection?

steady blaze
#

@rancid geode ah ok, thx.

slim nebula
#

it used to create a class per ghost, but I assume that was removed to prevent chicken and egg bullshit regarding code generation

#

but I dunno what's supposed to replace that mechanism

#

in netcode 0.4

steady blaze
#

sorry, don't even know a ghost. Is the unity.netcode finally a new system or still the old?

slim nebula
#

yeah it's a dots based networking thing

#

but nobody seems to use it? I dunno

steady blaze
#

ah, ok that's interesting!

#

not yet, but maybe at a later date

slim nebula
#

I guess I'll just create an enum for now. Seems like less overhead than a tag component per ghost

steady blaze
#

if it's part of the new dots system, then it is of course interesting, as it should be future proof then

slim nebula
#

but I guess I still want to ask someone who knows. I'd prefer to use best practices

steady blaze
#

@slim nebula Do you have a link to the new networking system?

steady blaze
#

thanks! that sounds very interesting

slim nebula
#

so in 0.2 you could do var ghostId = NetCubeGhostSerializerCollection.FindGhostType<CubeSnapshotData>();

#

where CubeSnapshotData is the generated type for your ghost

#

but in 3 and up it looks like they are using a tag component?

#
            for (int ghostId = 0; ghostId < serverPrefabs.Length; ++ghostId)
            {
                if (EntityManager.HasComponent<MovableCubeComponent>(serverPrefabs[ghostId].Value))
                    prefab = serverPrefabs[ghostId].Value;
            }```
#

MovableCubeComponent

#

to identify the ghost

#

but

steady blaze
#

sadly i don't even know what a ghost is, but hopefully in a few days โ€ฆ

slim nebula
#

a tag component is 2 words and 3 punctuation, then add it in the unity editor to the ghost. An enum would be one word and 1 punctuation with no addition to the editor.

#

ghost is a entity

#

that uh

#

has data

#

that gets synced between server and client

#

so I need to instantiate this ghost prefab, so that it's data can be synced accross the network or w/e

#

just trying to get the right prefab out of the collection I guess. Not sure what the intention is I guess

#

the FindGhostType function was not mentioned in any of the netcode changelogs so it's unclear

timber ginkgo
#

if i am using .ScheduleParallel() with a dependency, is it necessary to call job.Complete() on the job being used as a dependency?

#

in theory, if i call secondJob.Complete(), and firstJob is its dependency wouldn't it be better not to call firstJob.Complete() to give the scheduler more wiggle room?

tight blade
#

@rancid geode yeah, but unfortunately even though its in serial the order is not deterministic. chunks could get merged at any point, thereby changing the entity order in processing

hollow mist
#

@slim nebula I'm not sure what's "best" way is, but I just created a component and attached it to my player, then checked for the existence of that component on my ghost prefabs

slim nebula
#

ok. that seems to be what they do in the sample too

#

it's just different than 0.2 suddenly with no explaination I guess

#

but I appreciate hearing your experience!

#

thank you

hollow mist
#

yeah I've had some bumps when upping versions and having things break as well

slim nebula
#

yeah I still got a bunch of stuff to fix I assume but just needed to get over that hurdle before I could continue

#

gotta delete all my serialization thingers I think?

hollow mist
#

I've also found myself wanting some additional clarity WRT the player spawning, so I've done some stuff to identify when a player is spawning "locally" on the client machine vs. the server which was helpful

slim nebula
#

cause it generates it now I think?

#

makes sense

hollow mist
#

yeah there was a fair amount of deletion involved in the latest bump IIRC

slim nebula
#

which I'm all for. love it

hollow mist
#

but it was nice because yeah, I believe a lot of the boiler plate we had to do before is now generated

slim nebula
#

yeah and this chicken and egg crap is gone (re code generation)

hollow mist
#

there's also no more "generate code" buttons in the ghost components, which is scary and nice

#

"it just happens"

#

"magic"

#

but I've not had issue yet

#

I'm still gaining my footing with ECS, but the last bump for netcode was a good step

#

by chance, have you had any issues with flickering objects when they're in your server world? and are you using ecs subscenes or the old convert components?

#

those are two hairy areas I've still not resolved

slim nebula
#

I'm using convert components. subscenes weren't a full solution when I last worked on it. I guess I should convert everything to use subscene stuff

hollow mist
#

I'd recommend not to yet as I ran into issues when I tried

slim nebula
#

I have not seen flickering objects myself unless I've effed up the position on random frames in my own code

hollow mist
#

I don't think they're ready to take over

slim nebula
#

ok

hollow mist
#

which is odd to me (unless I'm wrong) because the convert components are deprecated now

#

(still work, but have deprecation warnings)

#

the flickering I'm talking about is rendering flickering -- not positional

slim nebula
#

no I dunno

hollow mist
#

particularly, when something is not in shadow, it flickers between black and lit

#

now you got me on a roll (I've not had an in-depth convo with anyone using netcode yet!) -- how are you doing your movement code? manually adjusting the translation value?

slim nebula
#

on the server I'm using physics, on the client I'm manually doing movement to a predicted invisible object, then I'm rubberbanding to that object as it jumps due to prediction errors

#

my plan is to rewrite the unity.physics layer between havok and my code to handle physics prediction

#

the dots sample has physics prediction, but their physics are completly custom, written in the sample code

#

so if the player tries to walk on a moving object it'll be all messed up, but that can't happen in the demo without modifying it

#

anyway, then the idea would be to run physics for each prediction step

#

so that there's less visual rubberbanding (only due to other clients inserting commands between predicted and server frames in the client)

hollow mist
#

well, you're clearly more advanced than I in this area lol

#

I tried using unity physics in conjunction with netcode, and it resulted in incredibly choppy movement

#

and my understanding of how it all works is too basic at this point to meaningfully understand why on my own, let alone how to resolve it

#

but my googling pointed me to a forum post where unity devs said the two won't place nicely right now, but they hope to make them do so in the future

slim nebula
#

i mean the dots sample uses both together

#

but yeah there's stuff regarding physics steps etc

#

like

#

by default the server used constant physics time steps

#

and the client doesn't

#

so

#

if the client is pressing "move forwards"

#

the server might process 10 frames in a second (it's way higher, but just for sake of discussion)

#

but maybe the client FPS is low and they only get 5 frames

#

the ghost prediction system will only run 5 times on the client

#

so you need to do fancy things with input to ensure that things are accounted for

#

if the client lets go at frame 7

#

when do you stop processing it on the client?

#

the solution I did was to just have the same physics steps on the server as the client

#

there's some hacks you can do to get the physics and netcode to behave that way

#

but yeah it's not pretty

#

accellerating forwards for 1 second, then left for 1 second, is not the same thing as accellerating forwards and left for 2 seconds

hollow mist
#

hmm, perhaps you're referring to a different sample than I tried (it's been a while) but the one I tried to get up and running wouldn't compile for me, and I hadn't messed with dots much nor netcode at all yet, so the code was meaningless to me at the point... but IIRC the sample I used (maybe it was the FPS sample) didn't use unity physics -- it did raycasts

olive kite
#

Is anyone really familiar with the Physics Debug Display in Unity.Physics? I am getting weird results when I calculate collision details from: collisionEvent.CalculateDetails(ref physicsWorld); but the debugger has the exact impact spot marked with an emblem, so I am curious where it is getting the data for collisions. When I run ICollisionEventsJob it doesn't trigger on fast projectiles and the impact spot is calculated to be behind the object, hiding the vfx. Does anyone know where the collision events are stored or pulled from for the debugger?

slim nebula
#

yeah. it used havok I think and custom physics. collider casts and raycasts you're right

#

I think it references the unity.physics package, but yeah it's not like using it

#

(sorry I dunno about physics debug)

hollow mist
#

oh okay, so the sample you're referencing isn't using the physics collision resolution out of the box and whatnot

coarse turtle
#

if i am using .ScheduleParallel() with a dependency, is it necessary to call job.Complete() on the job being used as a dependency?
@timber ginkgo It kind of depends on what's being read/written in the jobs, but generally if they're structured nicely you don't need to call the first job.Complete()

#

So you can have your first job, do some data writing, and your second job, read that written data, and just have those jobs chained.

var job1 = new Job1().ScheduleParallel(...);
var job2 = new Job2().ScheduleParallel(..., job1);

// Maybe some other logic here

job2.Complete();
timber ginkgo
#

what do you mean by chained? @coarse turtle

coarse turtle
#

By chained, I just mean passing in the JobHandle returned from scheduling your first job, into your subsequent job(s)

timber ginkgo
#

oh ok i read that wrong

#

sorry

coarse turtle
#

no worries

timber ginkgo
#

my mind inserted a "dont"

#

lol, thank you so much

#

i cant explain it lol

#

late onset dyslexia

#

brain be like

#

ship it!

coarse turtle
#

lol no worries

timber ginkgo
#

i just find it hilarious that brains are so falliable

#

perception rather

#

(or maybe its just me lol)

tawdry tree
#

The brain is stupid, fallible, and fallacious...
This is exactly why we have code reviews (and part of why pair programming).
"Of course it works, I made it, made sure it built, and tested it!"
"...did you really test it?"
"Yeah!"
"...cus' you forget the exclamation mark in the if, so it does literally the opposite of what it's supposed to."
"What? Huh, I guess you're right..."

low tangle
#

vison is super bandwidth limited apparently, read this good post on HN a few days ago https://news.ycombinator.com/item?id=24821389

fpgaminer

Also, I know what you mean but for completeness, random noise is learnable, we do this all the time.You are absolutely correct. The fact that brains learn randomness is mind blowing, and it has immense implications for our perception of reality.Let me take fellow HNers on...

timber ginkgo
#

        // populate native array
        for (int i = 0; i < gridCount; i++)
        {
            gridBlocksNative[i] = grids[i];
        }

        // create job, passing our populated array in job construction, along with other crap
        GridUpdateJobOneWay job = new GridUpdateJobOneWay()
        {
            GridDatas = gridBlocksNative,
            gridBlockSize = gridBlockSize,
            stepDuration = stepDuration,
            o2Viscosity = o2Viscosity,
            o2ConductionFactor = o2ConductionFactor,
            gridDimensions = gridDimensions
        };

        // schedule the job...
        JobHandle jobHandle = job.ScheduleParallel(gridCount, 16, **what_goes_here?**);

        jobHandle.Complete();```
#

I read the answer to this somewhere but i cant seem to find it again. what do i use as a dependency for the first job that I am scheduling?

#

just an empty job handle?

#

JobHandle sheduleJobDependency = new JobHandle();

#

ah yes, i think that's right

hollow mist
#

probable newb question here, but high level, if I have an entity existing in the world that over time will need to track certain "things" (by maybe just getting new data provided to it via a struct) -- what would be the best approach?

I've tried creating a component ThingTracker which has a DynamicBuffer<MyThing> and attaching it to my entity, but it's not coming together how I'd have anticipated it to

slim nebula
#

hmm I guess I have some scale issue

hollow sorrel
#

@low tangle how can mirrors be real if our eyes aren't real

#

that was an interesting read

#

makes me think of seperated sim/render in games

#

none of what the player sees is 'real', it's just a small subset of what goes on in the simulation, frustum culled etc

#

and even that is not always accurate, like when you're rendering interpolated positions instead of their 'true' physics position

#

the render world is just making stuff up

low tangle
#

exactly

#

it just needs to look plausible, good enough

#

in vr I've got to get that perfectly smooth framerate, because any stutters is obvious when its your actual vision

#

the actual visuals can be less detailed, but making sure the world is smooth is what tricks the eyes

hollow sorrel
#

yeah tru, goes even more so for vr

#

like with foveated rendering

#

player only gets like 10% of the actual information that the screen can display, rest is blurry

#

but that's good enough to fabricate the rest

timber ginkgo
#

If anyone could look over this method briefly for signs of blatant malpractice, I would be very grateful

#

it's 5 jobs being scheduled in a chain. Specifically im concerned if i am mis-ordering things in a way that will harm performance, and I'm wondering if i can parallelize things better instead of having one big chain of jobs. (I am updating results and disposing of 5 separate arrays at the very end of the method because im not sure when and where it might be safe to dispose of them sooner)

coarse turtle
#

looks fine at a glance, for disposing NativeContainers you can also try chaining them like so:

someNativeArray.Dispose(prevJob);
someOtherNativeArray.Dispose(prevJob);
#

so you dispose those tempjob arrays at the end of a scheduled job

#

another thing that I've done when just using Job structs, is just complete the jobs structs at the start of the next frame.

#

so in the Update call:

JobHandle prevJobHandle;
void Update() 
{
  // Complete the jobs from the prev frame at the start of the call
  prevJobHandle.Complete();

  // Maybe take the data from the jobs and apply them to w/e
  ...

  // Schedule all the jobs
  // Schedule Job1 and 2 to run indpedently
  var handle1 = new Job1().Schedule();
  var handle2 = new Job2().Schedule();
 
  var combinedHandle = JobHandle.CombineDependencies(handle1, handle2);
  // Let Job3 wait on Job1 and 2
  prevJobHandle = new Job3().Schedule(combinedHandle);
}
timber ginkgo
#

very interesting

coarse turtle
#

In the profiler, you'll see the jobs scheduled while the main thread is running so it's not a blocking call

timber ginkgo
#

i am doing this in fixedupdate, could i still gain from that strategy?

#

afaik, i could still see a benefit right?

coarse turtle
#

yeah - believe so (I haven't tried directly with fixed update)

#

but I don't see a reason on why it wouldn't work

timber ginkgo
#

i can see it being hugely useful in Update()

#

as far as i understand the unity loop, still will be useful to me

#

thanks so much for the guidance! I'm going to implement this

coarse turtle
#

np

timber ginkgo
#

(before implementing the above)

coarse turtle
#

yeah that main thread looks like it's waiting for the jobs to finish

timber ginkgo
#

quick question

#

where should i declare my native arrays?

#

does this imply a persistent allocation?

coarse turtle
#

It depends on the allocation type, for persistent allocation in a monobehavior, I put it in Start/OnEnable and release them in OnDisable

For TempJob, i usually just declare them before my job structs

timber ginkgo
#

oh ok i see. i can use the results, dispose them, and then re allocate them again

coarse turtle
#

and if I want to deallocate them in TempJob, usually a DeallocateOnJobCompletion attribute in my final job struct or I do prevJobHandle = someNativeArray.Dispose(JobHandle);

timber ginkgo
#

im actually wondering about allocation: i am running these jobs over and over again every tick; they're technically persistent

#

but i was told using tempJob should still be superior

coarse turtle
#

I believe there were a few blogs lying around on the performance of the different allocations by jackston durnst, but I haven't done direct tests. So it kinda depends, I've used persistent allocations and ptrs if I needed to share that data outside the MonoBehaviour

timber ginkgo
#

all of the jobs are using shared data to some extend, and i do have a crap ton of other monos accessing these data...

#

is this possibly the kind of situation where accepting a persistent allocation makes sense?

coarse turtle
#

probably

timber ginkgo
#

i am declaring and populating huge arrays every tick afterall

#

this has felt very wrong lol

coarse turtle
#

yeah might make sense, to use a persistent allocation ๐Ÿ˜…

timber ginkgo
#

jobs are fun lol

hollow sorrel
#

@timber ginkgo one thing with TempJob is that they automatically deallocate after 4 frames, so hypothetically if someone has your game running at a uncapped/high framerate to the point theres more than 4 between fixedupdates, it will throw errors

timber ginkgo
#

hah

#

that's hilarious and fascinating

#

Performance by Defau~ERROR

hollow sorrel
#

yea its a big pain, i dont get why they tie allocations to render frames, its used in a couple unity systems too like entitycommandbuffers, very annoying

#

started running into those errors after getting a 240hz monitor

timber ginkgo
#

poor unloved physics nerds lol

amber flicker
coarse turtle
#

ah smart ptrs ๐Ÿ‘€

timber ginkgo
#

not sure if this is related, but i am wondering if i really need to apply results and cannot just try and expose the native array to other monos lol

#

pretty sure unity will whack me on the head or that

#

like, if i have this dedicated persistent array stored in memory, do i really need to keep and constantly update a managed copy for normal code to access?

coarse turtle
#

I guess the question is: do you need the managed array?

timber ginkgo
#

my only worry is about parallel access conflicts that i dont yet fully understand

#

i think i get the gist when it comes to jobs

#

not sure what will happen when stuff starts reading from broader parts of the unity loop

coarse turtle
#

yeah you might run into a case where MonoBehaviourB accesses the persistent NativeArray<T> but Job1 is still writing into it

timber ginkgo
#

if the native array can act as a readable and writable public array, then i wont need managed

#

or at least modifiable

coarse turtle
#

hmm, well you can always try double buffering but im not sure how big your data set is

#

so you always have a complete copy that you can always read on, but it means you end up having 2x your allocation

#

one for read, one for write

timber ginkgo
#

right now im at like 50MB i think

#

i would probably be crazy to go 10x that

#

(given what it would reflect in terms of rigidbodies)

#

I might need to double buffer in any case; the grid update job has internal buffers that it is using presently to make the update logic be order independent , and i am forced to complete this job first so that other jobs can read or work on the data

#

If i am really careful, i should be able to use one array as the buffer being updated, and then switch to updating the other one on the next tick

#

after making the arrays persistent

timber ginkgo
#

this isn't crazy right?

#
    {
        materialPositionsNative.Dispose();

        windDatasNative.Dispose();

        heatDatasNative.Dispose();

        gradientDatasNative.Dispose();

        gridBlocksNative.Dispose();
    }```
#

(i mean, i should handle this on scene transitions, but this is the basic idea right?)

#

otherwise it would cause a small leak?

coarse turtle
#

Yeah that should be the idea

#

though if you disable the gameObject, would you end up reallocating when you re-enable your gameObject?

#

that might throw an error or warning

dull copper
#

@timber ginkgo I've always had better perf with persistent arrays when I need it on constant basis

#

it does make sense too

shy pilot
#

so guys

#

i'm a bit confused

#

i've been following codemonkey's quadrant systems tutorial for dots

#

and he uses a NativeMultiHashMap

#

but wouldn't it be much easier to use a normal NativeHashMap<NativeList>?

#

is there something obvious i'm missing?

rancid geode
#

You cant have a native collection of a native collection

shy pilot
#

ah ok

#

that would do it ๐Ÿ˜†

craggy orbit
#

is there a way to being trying to understand the Burst Inspector without knowing ASM, or should i start to learn ASM a bit? i have (what i thought to be) a medium complexity job, but the Burst Inspector shows hundreds of lines of stuff. afaik, less is better, right?

dull copper
#

Asm is always more lines than the higher level code

amber flicker
pulsar jay
#

I added physics bodies and shapes to my tiles and now I get this error: "InvalidOperationException: The BlobAssetReference is not valid. Likely it has already been unloaded or released."

amber flicker
#

Are you converting at runtime?

pulsar jay
#

yes

amber flicker
#

No idea if that's supported. It might be but it might be why... if you're not doing any blob manipulation yourself.

pulsar jay
#

is this connected to the BlobAssetStore I use to create the conversion settings?

#

because I just use it for instatiation via: using (var blobAssetStore = new BlobAssetStore())

#

so it gets released directly after prefab conversion

amber flicker
#

No idea how BlobAssetStore is supposed to work outside the context of a subscene (if at all) - should be easy for you to test. e.g. do you still get that error if you remove your code?

pulsar jay
#

well if I remove that part of the code there will be no instances at all

#

as long as there are no instantiated tiles it does not have errors

spare flare
#

i need hel

#

hepl

#

i wanna create a game without coding

#

how can

#

i do that

amber flicker
#

wrong channel @spare flare (if there is a right channel for this) - my suggestion would be to pay someone to make it for you

spare flare
#

pay someone

#

i dont have money

pulsar jay
#

I am trying to build a simple repro case

#

I just found out that the Prefab int the public field gets destroyed on conversion. Is this expected behavior?

#

Entity entity = GameObjectConversionUtility.ConvertGameObjectHierarchy(this.Prefab, settings);

#

It makes sense for scene objects but prefabs?

mild ledge
#

Guys, I'm a bit confused. Can I use jobs to spawn normal gameObjects as part of a pooling system or do they need to be entities ?

pulsar jay
#

Guys, I'm a bit confused. Can I use jobs to spawn normal gameObjects as part of a pooling system or do they need to be entities ?
@mild ledge I think jobs wont help you with that as the standard Unity API is not thread safe

#

Even entities cannot be created in jobs. You can only fill a command buffer that is executed later

#

I just found out that the Prefab int the public field gets destroyed on conversion. Is this expected behavior?
@pulsar jay Ok that was just a stupid mistake. Accidentally selected the scene instance instead of the prefab which gets converted and destroyed as expected

radiant sentinel
#

can you help me? i want know how to generate random numbers at my jobs.

dull copper
#

I'm looking at 2021.1.0a2 release notes, a bunch of these items were already in 2020.2 betas so it's pretty hard to tell without direct comparison to the notes which all items existed before

#

there are bunch of Burst improvements listed though

#

like... Burst: Add support for try/finally and using/foreach for IDisposable patterns.
Burst: A new option [BurstCompile(DisableSafetyChecks = true)] that allows per job or function-pointer disabling of safety checks. This allows users to have blessed code run fast always.

stone osprey
#

This is more of a general ecs problem im struggling with... How do we insert transfer data from one component into another one once ? Lets say we clone a "Tower-Building"-Entity, it comes along as a prefab and is filled with data already. Now our database loads a component "Structure" from the database and attaches it to the "Tower". When a player clicks on the "Tower" a system uses the already filled "OnClickPopUp" component from it and creates a popup. The problem here is that the component from the database should transfer some its data into the "OnClickPopUp", for example the structures name. Any idea how we could do that in an clean way ?

safe lintel
#

"blessed code" what, sounds like 40k shenanigans

radiant sentinel
#

Who know about randoms at Job system?

#

I really need help

glacial berry
#

Who know about randoms at Job system?
@radiant sentinel Here's what I do: 1. Outside the Entities.ForEach: var random = new Unity.Mathematics.Random((uint) UnityEngine.Random.Range(1, int.MaxValue)); 2. Inside the ForEach pass in the entityInQueryIndex: random.InitState((uint)(random.state + entityInQueryIndex)); 3. Get values as usual after that inside the ForEach: var randomDirection = random.NextFloat3Direction(); I hope that gets you going.

radiant sentinel
#

@radiant sentinel Here's what I do: 1. Outside the Entities.ForEach: var random = new Unity.Mathematics.Random((uint) UnityEngine.Random.Range(1, int.MaxValue)); 2. Inside the ForEach pass in the entityInQueryIndex: random.InitState((uint)(random.state + entityInQueryIndex)); 3. Get values as usual after that inside the ForEach: var randomDirection = random.NextFloat3Direction(); I hope that gets you going.
@glacial berry
I cant define random outside of job, because i have many entities and my seed is not a random number.

#

For example i want generate random number base on index of entities at each frame

rancid geode
#

@radiant sentinel if you always seed the same number each frame you will receive the same result each frame

#

you will need to initialize the seeds once and reuse it over-frames

radiant sentinel
#

@radiant sentinel if you always seed the same number each frame you will receive the same result each frame
@rancid geode
Each fram has different seed but the seed is calculated and is not random

rancid geode
#

@radiant sentinel then just use: var random = new Unity.Mathematics.Random(myCalculatedSeed)

radiant sentinel
#

Yes it always get me 0 from 0 to 2.

deft stump
#

does your calculated seed gives you 2 predictable results?

radiant sentinel
#

I want same result on multiple devices
@deft stump @rancid geode

rancid geode
#

@radiant sentinel everytime you use a seed X you will recevive a result Y, so if your calculated seed has a predictable range (like 1 or 2) you will always have the very same result range (like X or Y)

if I understood correctly, you are using the index of entities to calculate your seed, if you are doing that all entities on index 1 will always generate the very same result X every frame

#

you can create one random instance for each index (at the very begining) and just keep that random instance updated, instead of re-feeding the seed every frame

#

as long that the initial seed is the same for all devices, the results should be the same across all devices

radiant sentinel
#

@radiant sentinel everytime you use a seed X you will recevive a result Y, so if your calculated seed has a predictable range (like 1 or 2) you will always have the very same result range (like X or Y)

if I understood correctly, you are using the index of entities to calculate your seed, if you are doing that all entities on index 1 will always generate the very same result X every frame
@rancid geode
I understand this, i got Y as 0 for random seeds too. My range is 0 - 2
Thank you i should change core of algorithm

olive kite
#

Are the physics body and shape calculations supposed to be a lot more expensive than the standard rigidbody calculations? When i test with just 200 cubes with a box collider and rigidbody, i get 218 fps vs when I convert them to entities I get 125 fps

stiff skiff
#

Did you use the profiler to confirm its the physics?

#

The FPS stats indicator in the editor is extremely useless for performance comparison

olive kite
#

yes, the added time is in the physics step

stiff skiff
#

(Not saying you're wrong btw)

olive kite
#

i know, no worries

stiff skiff
#

What do the profiles look like?

#

I noticed that ECS physics has a higher base cost, but scales nicer

olive kite
#

ill grab them, one sec

stiff skiff
#

And the most recent version has a useless sync point in it, which you can remove if you "fork" it

olive kite
#

with everything else it has been great, but with rigidbodies for some reason it takes forever

#

hmm , i did not know that

#

also, isn't it supposed to ignore items at rest? the velocities are jumping all over the place at rest

#

2.32 ms is the heavy piece

#

and actually , when turning off entities and using regular cubes/rb, the floor is still an entity so the physics engine is still cycling:

stiff skiff
#

And this is with burst and jobs enabled?

olive kite
#

yep

#

on a 32 core cpu/rtx2080 ti

stiff skiff
#

What does the timeline look like (instead of the hierarchy) for the ecs one?

olive kite
stiff skiff
#

Oh wow

#

How many cubes was this?

olive kite
#

only 200

stiff skiff
#

Thats a LOT of jobs for 200 cubes

#

Could you check what jobs those are? And possibly check the entity debugger to see how your chunk utilization is?

olive kite
#

what is that at the bottom mean for the chunk util

#

yeah one sec

stiff skiff
#

I cant remember if thats 45 chunks with 4 entities, or 4 chunks with 45 entities...

tawdry tree
#

By scale it looks like one chunk of 1, and 45 of 4

stiff skiff
#

I think the latter, considering it matches 5 chunks

dull copper
#

@olive kite job system kinda fails on high core count cpu's

stiff skiff
#

Job system scheduler is pretty bad

tawdry tree
#

Or the opposite... that graph could have clearer UX...

dull copper
#

I only have 12 so 24 hw threads and that means job system automatically sets 23 workers for me but physics will choke on that worker amount already

stiff skiff
#

But it shouldn't be scheduling that many jobs though?

olive kite
#

oh really

dull copper
#

it really tries to split everything to all worker threads

#

making it super slow

stiff skiff
#

Yeah but it should split it to minimum 1 chunk a job, and there are only 5 chunks

olive kite
#

is there a way to limit the available

dull copper
#

you can only limit the total worker amount

stiff skiff
#

2020.1+ only

dull copper
#

I've found 4-6 workers to perform the best for me

dull copper
#

meaning, I can't stress the cpu 100% with this setup either

olive kite
#

interesting

stiff skiff
#

Seems its in 2019.4 as well

dull copper
#

there's also a commandline parameter

#

basically profiler is useless if you just cap the worker amount with that line on the docs

stiff skiff
#

I think its also in the boot.config for build out players

dull copper
#

because you'll still see 63 workers on that cpu even if you only use 4

#

only limiting the worker amount via command line parameter will make profiler only show the same amount of workers

olive kite
#

i set the worker threads to 6

dull copper
#

oh course your use case could have different results

olive kite
#

and cycle time is way down

#

that's crazy

dull copper
#

yeah it's kinda broken on modern high core count cpu's atm

olive kite
#

step physics world went from 2.5 to .6

stiff skiff
#

oh wow

olive kite
#

ms

dull copper
#

yes, that's in line with what I've seen

olive kite
#

geez, thanks so much

#

it was killing me

#

youtube guys getting 150,000 and i cant get 1000 at 60fps

dull copper
#

I mean I haven't seen that dramatic change but since we know how much it splits to workers, it has to be so much worse on that high core count chip

olive kite
#

yeah , that makes sense knowing it isn't optimized for high counts

dull copper
#

what sucks here is that you are essentially restricting the cpu from it's full potential

olive kite
#

right

dull copper
#

I've complained a lot of this and hope that some day they let you just limit individual schedulers or systems worker amount

olive kite
#

might be good anyways , going to port to console eventually

dull copper
#

because you could still totally run different systems parallel

olive kite
#

how many threads are the next gen?

#

16?

dull copper
#

something like that, yes

olive kite
#

yeah that would be ideal to limit ind schedulers

#

welp, I wasted about 3 hours on that haha

dull copper
#

anyway, I've done a script that lets me use keyboard at runtime to set the worker amount that also reports different systems cpu time in ms, it's been helpful for me to see where it starts to get bad

#

different systems have different ideal worker amount so need to balance that atm

olive kite
#

yeah you're right, you could limit systems to like 6 each and it could run multiple on different threads

dull copper
#

some systems run fastest even on 0-1 workers atm with DOTS

olive kite
#

yikes, going to have to keep an eye on it

dull copper
#

and now I'm talking about Unity's framework, DOTS physics, Hybrid Renderer v2, not about my own code

olive kite
#

right

#

yeah at 1 worker thread same performance as 6

dull copper
#

so today, it's not really "performance by default"

olive kite
#

actually , higher at 1

dull copper
#

but yeah, it's experimental stuff still

#

yeah I don't wonder

olive kite
#

5ms frames at 1

#

thanks again, i'm glad you had direct experience with this

dull copper
#

so, you are essentially not getting any benefits from job system at that point

#

only from burst and bit from ecs

olive kite
#

yeah it seems like that

#

burst is solid

dull copper
#

must be nice sitting on 32 core cpu with this setup ๐Ÿ˜„

olive kite
#

it's nice when baking

dull copper
#

3970x is awesome, I wish I had it

olive kite
#

their cpus are awesome now, the new line is even better

dull copper
#

yup

olive kite
#

RIP parallel

dull copper
#

I'm sure Unity figures this out eventually

#

some things still benefit from more workers

#

it's just their current stock systems really don't do that much, and where you get gains totally depends on your use case

#

typical gameplay scenario is not getting any gains

olive kite
#

it shouldn't be too hard to estimate jumping workers time vs time of operation and schedule based on that

#

what's that term called.. i forgot

dull copper
#

I've been meaning to post a sample project to the forums to demonstrate all this to get more attention over this but I then got other things on my plate and I haven't really gotten back to it

olive kite
#

ill probably post on it, considering my needs

tight blade
#

@olive kite context switching?

olive kite
#

thank you

#

yeah

#

sweet, my dots pathfinding is way faster now too

dull copper
#

lol

#

yeah, it still sucks

#

(not your code, but the situation)

olive kite
#

yeah it does

#

it's not mine, a* pathfinding project. wrote a few lines to attach it to the entities and it works perfect

hollow mist
#

can I have something like a NativeList on a component?

amber flicker
#

@hollow mist nope unfortunately

viral comet
#

Hi, everyone!
does ComponentObject produce garbage as well as the class version of IComponentData?

#

And is there a way I can prevent garbage allocations using class based components (maybe an interface to release component members)

hollow mist
#

@amber flicker do you happen to have a recommendation for a way to track things over time? consider a situation where my player will encounter certain things as it progresses through the world, and I want to keep a running tally of those things that they encounter

amber flicker
#

@hollow mist there are a few options - the most straight forward might be a DynamicBuffer - it's the equivalent of an array of IComponentData's

hollow mist
#

yeah I've taken some initial stabs at using that, but haven't succeeded yet

#

I'd have to add that to my entity via code after player instantiation, yeah? and from there, are there any limitations to how I can add to it? like can I do do via EntityManager or must I do so via PostUpdateCommands? (I'm still mentally working through understanding the differences between ComponentSystem, JobSystem, SystemBase systems... EntityCommandBuffer... etc. ๐Ÿ˜ so many things!

amber flicker
#

@hollow mist only around for a min but:

  1. Forget PostUpdateCommands, ComponentSystem & JobSystem - pretend they don't exist
  2. I think you can add an IBufferElement as part of an archetype exactly the same as an ICD (doesn't need to be after instantiation)
  3. Make sure you get the buffer: var buffer = EntityManager.GetBuffer<MyBuffer>(entity); before then adding to it: buffer.Add()
  4. I'd get used to EntityCommandBuffers (ecb) over PostUpdateCommands - it's creating a buffer of commands and then executing them later - hence this can come with it's own timing-related issues
hollow mist
#

hm, okay, I'll see what I can figure out

#

@amber flicker as for #2 -- what if I'm doing a hybrid player with the convert workflow?

#

also, thank you for your responses!

amber flicker
#

np - you can't use the [GenerateAuthoringComponent] attribute for buffers but you can do it by creating a custom conversion script - it's much more straight-forward than it might sound. If that answers your q.

hollow mist
#

gives me a jumping off point -- thanks!

amber flicker
#

๐Ÿ‘ good luck!

safe lintel
#

@hollow mist iirc you can have nativelist on class icomponentdata, limited to mainthread though

hollow mist
#

@safe lintel oh, thanks -- I'll look into that!

amber flicker
#

Thatโ€™s a really good point. Never really crosses my mind that that would be something someone wanted to do but youโ€™re totally right.

maiden delta
#

why are angular impulses weird in unity/havok physics?

dull copper
#

that doesn't really tell anything

#

weird how? how you set them? how they move things? something else?

maiden delta
dull copper
#

ok that explanation didn't really tell much either and video is just confusing, I have no idea what I'm looking at

#

I can imagine that's one reason why nobody has replied yet

maiden delta
#

i attached my code

dull copper
#

only way to figure out anything out of that is to look at the code itself

maiden delta
#

WRCarPhysicsSystem.cs (which is responsible for most physics of my car and all physics demonstrated in the video) is attached

dull copper
#

it's just, if you don't even understand the person's problem from video and description, there's quite high bar to even open the code snippet as you don't have a clue what to look for

maiden delta
#

the angular impulse/velocity stuff

#

i calculate it on lines 101-106 (with lines 48 and 50 related) and apply it on line 111

dull copper
#

I did look at the code and there's no way I'm going to decipher this ๐Ÿ™‚ You need simpler example if you want people to be able to help you

#

you are now asking people to actually first learn your implementation and then fix it for you, rather than help on angular impulses

maiden delta
#

jeez

#

thats gonna be really hard

#

the question is, how do apply angular impulse to a physics body similar to unity physx's Rigidbody.AddRelativeTorque? because when i do that, extra forces get in the way for some reason

#

the car in the video is supposed to only rotate on y axis when not affected by any other forces

#

and i only apply the angular impulse to local y axis, but it still makes the car rotate on other axes too

amber flicker
#

might be worth setting up the most simple ApplyAngularImpulse example you can and verify it doesn't work as expected. I could believe integration errors mean it eventually does spin wildly though.

dull copper
#

yeah, that's what I usually do when trying to figure things out, setup most simple scenario rather than trying to port whole codebase at once

#

basically, just put a cube there, disable gravity and try to spin it with angular impulse on it's local axis

hollow jolt
#

anyone knows how to do multidimensional array in DOTS jobs systems ?

steady blaze
#

@hollow jolt what i would do: use the index to calculate x, y, z from it.

hollow jolt
#

sure but i don't know in advance what size each portion would occupy

#

im looking to distribute 3d data points into a grid data structure to reduce the search space for local collisions in large meshes

maiden delta
#

so, my issue works only when the physics shape is a convex hull or a mesh

#

the angular impulse one

brazen storm
#

Hi! I am trying to access an Entity converted by an authouring monobehaviour in a system. the monobehaviour runs after the system OnCreate() and im unsure how to setup dependancies for it

#

any advice would be golden

coarse turtle
#

So you want to access the entity after it's converted and brought into the world?

Well for starters, what are you trying to do with the entity? Do you only need it once or are you trying to cache it for something?

brazen storm
#

Yes Im making a spawn grid component on the entity [using getbounds monobehaviour functions] and then using a system on the grid. does that make sense?

deft stump
#

you're trying to make a grid?

#

hrmmmm
for me, I would just tag the entity, then do an entities.foreach, querying the tagged entity, in OnStartRunning()
leave the OnUpdate() blank.

brazen storm
#

ok! I was doing it in OnCreate() !!!!!

#

thank you!

hollow mist
#

@amber flicker well holy hell, you can put [GenerateAuthoringComponent] on a buffer item!

amber flicker
#

oh can you? sorry I didn't realise ๐Ÿ˜„

hollow mist
#

no problem -- happy surprise!

tight blade
#

wait, but you can run systems on buffer components right?

#

I mean like natively without using the entity manager

amber flicker
#

if you mean lambdas or systems, sure

tight blade
#

okay, extreme example, if I made a "feather" component and each feather was added as a buffer component to an entity, I couldnt have, say, a system that processed feathers, right?

#

im trying to get at the one to many nature of buffer components. can I do an Entities.ForEach on feathers?

amber flicker
#

buffers work fine in the lambdas - i.e. you'd just do e.g. ..in DynamicBuffer<Feather> feathers...

tight blade
#

ah, yeah, thats not what I meant. Like I know I can process an array of data

#

I was just wondering if I could do
Entities.ForEach((Entity entity, Feather feather)=> {...})

#

see cause that would be weird, because in theory multiple of those iterations would be with the same entity

#

because feather is many to one

amber flicker
#

correct, that'd be odd - you'd instead do Entities.ForEach((in DynamicBuffer<Feather> feathers) => for(int i = 0; i < feathers.Length; ++i) { //smth }..

tight blade
#

oh thats interesting, I didnt know that was a thing you could do

#

hows that arranged in memory? seems like that couldnt be linear memory, right?

amber flicker
#

it is linear if your buffer is below the allocated capacity

#

i.e. the [InternalBufferCapacity(n)] attribute

tight blade
#

oh huh, thats cool

amber flicker
#

when you add an IBufferElementData with e.g. [InternalBufferCapacity(10)] you are declaring you basically want to add a 10 element array to every entity that has that buffer (at least, the capacity for 10 elements). If your array/buffer exceeds this capacity, I believe the whole array gets moved to the heap (so rand access) but it's still pretty quick. This is obviously a trade-off as the more elements you set to allocate, the fewer entities can fit in a chunk.

tight blade
#

thats pretty cool. lol i've been homerolling that

#

I made a struct with a number of slots and an integer to say how many of the slots were used, etc

amber flicker
#

yea, that's why DynamicBuffers are really nice - have linear access but then work just the same if and when the capacity is exceeded.

hollow mist
#

@amber flicker looks like there's a very specific way the generateauthoring stuff works on buffer items ๐Ÿ˜

hollow mist
#

yeah, if you add more than one property to the struct, it chokes... had to go with a custom conversion script (first one I've used!)

#

I got my whole system I was working on all functioning properly now though!

#

thanks for the nudge in the right direction ๐Ÿ™‚

#

pretty happy with it -- made a custom set of systems/components for setting up "trigger emitters" on objects, "trigger listeners" on other objects, and made it function so when a listener enters an emitter it'll track the interaction (enter/stay/leave) and delegate to the appropriate handling system depending on the type of the trigger as configured on the emitter ๐Ÿ˜„

olive kite
#

Hey what was the battle simulation called that they showed during Unite Austin that spawned 10,000 arrows in one frame?

safe lintel
#

nordeus tech demo

olive kite
#

awesome thank you @safe lintel

safe lintel
olive kite
#

oh awesome didn't know they had it available

brazen storm
#

I'm trying to assign to a Dynamic Buffer and I keep getting DC0033: Parameter 'buffer' is not a IComponentData / ISharedComponentData and is therefore not a supported parameter type for Entities.ForEach. Allthough i have copied verbatum ForEach lambdas to do this. Does ForEach not work with DynamicBuffer anymore?

craggy orbit
#

it should work. is the type of the buffer element IBufferElementData and the lambda type is DynamicBuffer<MyElementStruct>?

brazen storm
#

the type of the buffer element is IBufferElementData and it holds a float, and im passing DynamicBuffer<nameofthestruct>. just pasted from the manual and that failed

craggy orbit
#

need to pass it in with either in or ref

brazen storm
#

i tried both. maybe it's having two ForEaches in one file? I tried the commandbuffer too

craggy orbit
#

no that should be fine

low tangle
#

Your not storing that local var sum anywhere

#

Syntax seems off as well

brazen storm
#

Fixed it. lameful noob error which you need not know the details of. I will waste no more of your time.

low tangle
#

hey no worries my friend. I couldn't see it at first glance and I've been on the dots train since it came out

#

sometimes you just overlook the most simple things

brazen storm
#

tnx meng

deft stump
#

okay

#

what does this error mean

#

A Hybrid Renderer V2 batch is using the shader "Shader Graphs/Red Panel Graph", but the shader is either not compatible with Hybrid Renderer V2, is missing the DOTS_INSTANCING_ON variant, or there is a problem with the DOTS_INSTANCING_ON variant.

deft stump
#

welp it was just unity editor upgrade problems

north bay
hollow sorrel
#

i could imagine a full project recompile could take that long, but most of the time it should only be recompiling assemblies that changed so if that's the time you always get then sounds something weird going on

solar spire
#

There were some versions lately that had a regression causing extremely poor compile times, so upgrading Unity could also fix it

north bay
#

I just tried 2020.1.10 but i still have the same issue. My project is pretty big with +500 systems. @hollow sorrel I'll check that out thanks

hollow sorrel
#

my other guess would be if you don't use assemblydefinitions for your own code then making changes there will trigger a recompile of everything since the default assembly depends on everything automatically i think

brazen storm
#

Noob question. Instantiating with the entity manager, what's going wrong here? Also this does not allow for burst compilation??

deft stump
#

you can't use EntityManager w/ burst in Entities.ForEach

#

use EntityCommandBuffer instead

brazen storm
#

ah ok

pliant pike
#

basic question but what's the current best way to get two lists of the same component?, like I need to compare translations between two different sets of entities

tight blade
#

would ToComponentDataArray help you?

NativeArray<myComp> set1 = query1.ToComponentDataArray
NativeArray<myComp> set2 = query2.ToComponentDataArray

#

@pliant pike

pliant pike
#

hmm you wont get a conflicts error will you? Like I remember I got errors if you tried to get the same component twice in a job

tight blade
#

well, now the answer divides up a lot going into the implementation

pliant pike
#

like I was going to use this Entities.WithAll<TestObjectAuthoring>().ForEach((Entity inty, ref Translation trundle) => {

#

to iterate through the primary bunch and then compare each one of them against the target translation entities

tight blade
#

so, in that case youre only comparing one entity (at a time) to a list of entities, right?

pliant pike
#

yep

tight blade
#

where does that target entities list come from?

pliant pike
#

they have their own component tags, thats what I'm trying to figure out

#

I need to maybe get the entities reference attached to the component tag

tight blade
#

so, youre saying they originate from the results of a completely different entity query?

north bay
#

@hollow sorrel It looks like it's compiling once for 30 seconds than reloading and compiling again for 60 seconds or am i evaluating that wrong?

pliant pike
#

no I'm thinking maybe I should just do an entityquery for translation instead

#

and then use GetComponentData etc to get the correct entities

tight blade
#

Im not sure. Im still having trouble visualizing the approach and the problem

pliant pike
#

yeah maybe I'm not explaining it that well sorry ๐Ÿ˜†

tight blade
#

it sounds potentially like youre trying to solve the problem of having 2 different entity types interact with each other in a system

#

and unfortunately, pretty much all of the creativity in ECS design is about moving laterally around that problem.

pliant pike
#

say I have two groups of entities obstacles and movers which are both tagged differently

tight blade
#

when you say tagged differently

pliant pike
#

I need to compare the movers distances to the obstacles

tight blade
#

you mean they are different archetypes?

hollow sorrel
#

@north bay yeah seems like, no idea why it does 2 iterations, didn't see that before

#

also oooof that reload time

pliant pike
#

yeah its just the tag that is different currently though

tight blade
#

for most purposes it doesnt matter how different they are, just that they have any difference at all between their component makeup

#

if one set has components the other doesnt, then they arent the same set or subsets of each other

#

okay, so yeah, I guess it depends on how many of these obstacles and movers there are

#

you're basically talking about doing a combinatorial lookup between 2 different sets of entities

pliant pike
#

yeah I'm sure I did something like it before I just can't remember and not sure if anything had changed recently or what the best way of doing it was

tight blade
#

I dont think there will be a global way of doing it for quite a while. the problem space is pretty dependent on what guarantees your situation has available to it

#

lol, I wonder if you could just give those 2 types of entities an infinitely large collider and then just use the ITriggerEntitiesJob to process all pairs

pliant pike
#

yeah and the docs arent particularly great

#

like I need to get only the translation entities with a tag and it doesn't seem clear how to do that

tight blade
#

anyway, yeah. there are lots of ways to do this kind of thing. I have an example of one particular, rather complicated way of doing this in gist form on the wiki

#

there are a lot of complications that approach doesnt address, and my current implementation doesnt even calculate draft at all

#

in fact, thats kind of terrible. maybe dont even look at that, except to triangulate against other things youve seen

brazen storm
deft stump
#

um... i think it's because you disposed the commandbuffer.
hold on, I have an example script to show you

brazen storm
#

ok!

deft stump
#

here

brazen storm
#

thanks! not sure how to the job handle dependancy, i was disposing of the buffer wrongly

placid elk
#

struggling with Commandbuffer. can't seem to assign a component with it
@brazen storm You use Visual studio or code here?

brazen storm
#

I use VS code

placid elk
#

oh thx

#

Fix from [0.10.0] - 2020-04-28

deft stump
#

it has.
he was just implementing is ecb wrong

slim nebula
#

ok I'm hoping this is a simple yes/no question: Is it possible to add/remove entities/components from subscenes during runtime? Or are they basically static?

tawdry tree
#

Once a subscene has been loaded into the game, the entities within become normal entities, if that's what you ask. The subscene itself no longer really exists.

slim nebula
#

but there's no way to save changes back to the subscene right?

#

then close it and open it later and see those changes

stiff skiff
#

@hollow sorrel Yo, that compilation visualization package is AMAZING!!!!

#

I wish that was default Unity

lean raptor
#

How can I execute a raycast inside a Job? AFAIK, RaycastCommand can't be scheduled inside a Job, but I don't know which raycast I must do prior the creation of this job.

#

And the normal physic class doesn't work in jobs

rare umbra
#

Hello everyone! Quick question... what would be good to use for a backend database for DOTs? For games that manage your inventory authoritatively from the server. (Destiny, Diablo etc.)

Any good databases that play nice with DOTS?

hollow sorrel
#

@lean raptor ecs physics or physx?

#

@rare umbra i don't think the DOTS part is relevant if you're talking about backend, it's not like you're gonna store entity chunks directly

#

any database you'd otherwise use would apply the same to DOTS

lean raptor
#

@lean raptor ecs physics or physx?
@hollow sorrel Sorry, not sure what you means. Any physics is okay with me if I can do raycast-related stuff with it XD

hollow sorrel
#

sounds like you're not using ecs

#

you can't schedule physx raycasts from jobs

lean raptor
hollow sorrel
#

you can schedule the raycastcommands on main thread tho and await result

lean raptor
#

you can schedule the raycastcommands on main thread tho and await result
@hollow sorrel But I don't know which raycastcommands I need until I'm inside the job

hollow sorrel
#

then you'd need to schedule them after your job

#

so something like

#
  1. create commands/results nativearrays and pass them to first job
  2. schedule a raycastcommand with those same nativearrays with a dependency on first job (combine jobhandles)
#

should work i think

lean raptor
#

My code looks like:

void Execute() {
    InitializeStuf();
    if (Work(x))
        Other();
}
bool Work(x)
{
    if (Process(DoOneRaycast()))
        return false;
    
    DoOtherStuff();
    if (Work(x+y) && Work(x+z))
    {
        DoAnotherStuff();
        return false;
    }
    return true;    
}
#

Due the recursive nature of my code, I'm not sure how can I go back and forth between the main thread and the job to get the raycast done

hollow sorrel
#

anything recursive can be turned into iterative

lean raptor
#

Also, the execution of Work is very lightweight, so I think the overhead of one job per Work will be too high. (each Work is very fast, but I need to execute hundred of thousands of them, which is slow)

rare umbra
#

@hollow sorrel Iโ€™d need a good way to serialized and unserialize the data and keep them in sync though. Was wondering if there was anything off the shelf for that

lean raptor
#

I'll try

hollow sorrel
#

maybe you could bundle the work to all be done in a single job

blissful gorge
#

just wanted to celebrate some progress. I've had a hard time procrastinating on an IL weaving project I've been slowly cranking out. Today and last night I overcame much of that procrastination, and finally have simple structs generated from C# lambdas. Next is replacing references to lambdas to the codegen-ed structs.

I'm trying to make a API for converting C# delegates to structs. The goal is to have a Burst-compatible delegate that doesn't have the same limitations as FunctionPointer.

#

Not super far along, but just one step closer to finding all the issues of my IL weaving hahaha

shy pilot
#

is it possible to have a dynamicbuffer of fixedstrings?

deft stump
#

I believe strings aren't blittablr

opaque ledge
#

yeah you can @shy pilot

#

strings (class strings) arent blittable, but fixedstrings are

#

i generally used fixedstring32

shy pilot
#

ok thanks :)

shy pilot
#

can anyone tell me what is going on here

#

i get this error

#

*among many others

#
InvalidOperationException: CreatureComponent used in NativeArray<CreatureComponent> must be unmanaged (contain no managed types) and cannot itself be a native container type.
#
[GenerateAuthoringComponent]
public struct CreatureComponent : IComponentData
{
    public float health;                            //Current health of the creature
    public float age;                               //The age of the creature (in seconds)
    public CreatureState state;                     //The state of the creature
    public bool gregnant;                           //Is the creature pregnant
    public float gestationFinish;                   //When will the creature give birth (Live Birth Only)
    public GenderBase gender;                       //What is the creature's gender
    //public bool asexual;                          //Can the creature reproduce with the same gender
    public float food;                              //Hunger-bar for the creature
    public float water;                             //Thirst-bar for the creature
    public Entity attacker;
}
#
[System.Serializable]
public struct GenderBase
{
    public FixedString64 name;                              //Name of the gender
    public bool givesBirth;                                 //Is the creature capable of giving birth/laying eggs
    public bool seekMate;                                   //Should the creature actively seek a mate
    public DynamicBuffer<FixedString64> compatableGenders;    //List of genders that the creature can mate with
}
#

side note: is there a way to run complete on an entities.foreach that was called with schedule?

deft stump
#
public DynamicBuffer<FixedString64> compatableGenders;   

I believe this is your problem

#

That's, to my knowledge, not a properway to make a DB

#

and maybe also the

public GenderBase gender;

I've never tried a struct within a struct ICD.

#

and I believe it's crawling into OOP land

brazen storm
#

Hi. Trying to check one entity component values against several entity components. I'm thinking do an entity query for one and a .foreach for the others when component value changed.