#archived-dots

1 messages ยท Page 200 of 1

robust scaffold
#

Interesting. Yea, compute shaders currently are not agreeing with me at all. Might return to Jobs since, despite being a lot slower, they are much easier to implement and debug.

zenith wyvern
#

That's my implementation, about as simple as it can be while still being generic

#

It works well enough for me

robust scaffold
#

Hm, I recommend you put [NoAlias] in front of all the native containers inside that struct if you're using it in bursted code.

#

Burst compiler can not automatically identify that pointers (aka native containers) inside a struct do not point to the same block of memory so it compiles conservative code.

#

You might, probably not, get better performance if you just add that tag to the inside of your struct.

zenith wyvern
#

Ahh, I still have like no idea how noalias works, I'll give it a shot and see if it makes a difference

robust scaffold
#

It'll also depend on how you're accessing the data but NoAlias has no downsides to adding it so eh, give it a shot.

zenith wyvern
#

If there's no downsides why wouldn't they make it the default?

robust scaffold
#

Because if the pointers do point to the same block of memory, things break badly.

zenith wyvern
#

Doesn't seem like it makes a difference in this case. There's a lot of random access going on so I wouldn't expect burst to perform any miracles in this case

robust scaffold
#

Yea, aliasing is basically chunk copying / modifying memory. You'll need to be running a for loop for every single aspect of the container for it to apply.

#

Well at least UI toolkit has been updated to 2021. Lets see if it still breaks with Entities.

pearl pulsar
safe lintel
#

no, someone did release their own pure dots ui solution though

pearl pulsar
#

The major addition to this preview is the first iteration of UI for Project Tiny. The initial plan for UI was to deliver a subset of UI Toolkit (formerly known at UI Element) but we decided to postpone this approach and instead offer a more lightweight UI system inspired by Unity UI (UGUI). In this first version, UI for Project Tiny includes support for Image, Button, Text, Toggle, Sliders, Rect Transform and Canvas UI components. Note that this is not a complete UI system yet, see the documentation for more details on UI. The TinyRacing, TinyTime, TinyAquarium samples have been updated to use the UI system, so you can jump right there once youโ€™ve read the doc.
It's still -really- rudimentary at this point I see

zenith wyvern
#

I wouldn't take anything that Tiny is doing as an indication of what an official dots solution would look like

#

They're kinda doing their own thing

pearl pulsar
#

Right. Thanks for the clarification on that.

Speaking of Tiny, I wanna take another crack at that for a bit. Anyone able to build Tiny projects mind sharing their current .vsconfig so I can sanity check my own against that? (Visual Studio Installer > More > Export configuration). Thanks in advance!

ocean tundra
#

hey all
Any ideas on the best way to sync data between 2 worlds?
Should the Simulation world push the data to the Rendering world (Sim => Rendering)?
OR
Should Rendering pull from Simulation (Rendering <= Sim)?

ocean tundra
#

im thinking pull, but what to hear what others think

gusty comet
#

So how long till unity releases a random api for jobs?

#

Has this been discussed?

ocean tundra
#

@gusty comet as in Math.Random?

gusty comet
#

Doesn't work good in parralel jobs

zenith wyvern
#

I actually saw a mention of how they recommend using it in jobs in that new doc they just put out

gusty comet
#

and returns the same result on a regular basis

ocean tundra
#

theres a new one in the new math library

gusty comet
#

link?

#

Please xd

gusty comet
#

this is what im using now

#

and its still not as random as id like

zenith wyvern
ocean tundra
#

well all random in computers is pretty bad

#

๐Ÿ˜›

zenith wyvern
#

Scroll down a little from there

gusty comet
#

I have tried both suggestions

#

and still get the same random number on occasions

#

I think since i just need a random number between 0-1 I will add them all to a native list

#

and remove/add as they're used so I don't get the same number

ocean tundra
#

yea so true random does give you the same number again

#

random like your describing isnt true random

#

your idea should be good tho

pearl pulsar
ocean tundra
#

haha

gusty comet
#

is there somewhere I can read about the entityDebugger

#

so many colors that aren't defined

#

red/white/green what are the differences?

ocean tundra
#

all the docs are linked via pined messages

#

top right of discord

#

if that dosnt help theres not exactly alot more ๐Ÿ˜ฆ

#

best bet would be to read the code

gusty comet
#

Yeah might have to the info isn't readily available anywhere i've looked

#

unlucky

ocean tundra
#

the magic of dots

#

๐Ÿ˜›

karmic basin
#

more like a balanced distribution, whatever it is called ๐Ÿค”

#

unsorted round-robin ? ๐Ÿคทโ€โ™‚๏ธ haha

pearl pulsar
#

Is it at all likely that Visual Studio Community or using Unity Personal would be the root cause for Tiny Projects to not build?

#

This is dependency/package-resolution stuff that seems to be failing so it seems unlikely to me but that's what I'm using at the moment to try this out

#

Nothing about license version is specified in the google doc either - only 2020.17f1 or later.

lucid lake
#

How do I properly install all the packages for DOTS? I am using the latest platform, 2020.2.3f1.

#

I found out about the manifests.json, so i am trying that.

zenith wyvern
#

What errors are you getting?

pearl pulsar
#

same as before unfortunately

zenith wyvern
#

Oh, and that's just from a base project, nothing changed?

pearl pulsar
#

From one of the project Tiny samples, nothing changed at all

zenith wyvern
#

Did you try one of the other samples? I've only used the 2D sample and the 3D runtime geometry samples for this version myself

#

And did you try posting about it on the Tiny forums?

#

They're usually pretty responsive

pearl pulsar
#

I have them all pulled so I can give it a shot in a second. I'm about to add to another thread in which a guy is experiencing the same thing

#

We're probably both doing the same silly thing

zenith wyvern
lucid lake
#

@zenith wyvern Thanks

gusty comet
# karmic basin Well then you're not asking for random

Yes basically but usually randomizing it works good enough, unfortunately with ParralelJobs, that isn't exactly the case. I was generating a random number 1000 times between 0-1 and anywhere between 1-600 of them would get the same value every frame depending on some unknown factor (my guess is app startup time).

#

I was able to get it to work thanks to the article sark sent, but its still not ideal and completely mind boggling to me they haven't just made UnityEngine.Random.Range thread safe, considering how often it is used.

frosty siren
#

Hi guys, i recently has added a dots editor 12 which provides better entity inspector. And it's awesome but for some reason it doesn't update DynamicBuffer value in inspector. Is it package limitation / known bug or i do something wrong maybe?

ocean tundra
#

@frosty siren Whats your versions? I'm using all latest and use a ton of dynamic buffers and it works fine

frosty siren
#

unity version? 2020.2.1f1

ocean tundra
#

hmm im actually on the latest beta

#

well b3, probably not latest now

pearl pulsar
ocean tundra
#

How do i Parallel write to a dynamic buffer?

#

using GetBufferFromEntity

#

I get this error:

is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
zenith wyvern
#

You don't. At least not in a safe way. You'd have to retrieve it on the main thread and pass it into job with safety checks disabled

ocean tundra
#

yea that dosnt seem like a good idea

zenith wyvern
#

You need to either structure your job around including the buffer in the query or just run it single threaded

ocean tundra
#

yea i might try flipping it, instead of all my source entities writing into the single buffer, the job could be the single buffer reading from all the source entities

#

if that makes sense ๐Ÿ˜›

#

but it can wait, single threading it works for now

zenith wyvern
#

If you know for sure you're not writing to the same index from different threads you could just disable safety checks. If you can't guarantee it though then yeah you need to rethink it

gusty comet
#

Is there a way to see if an entity has a component with a command buffer?

#

or can I just call RemoveComponent without any care if it actually currently has it?

ocean tundra
#

@zenith wyvern na im definitly writing to the same index
my setup is many entitis, writing to few entities but always adding to the buffer

#

@gusty comet no command buffer is write only but i do think remove component is safe if the entity dosnt have the component

gusty comet
#

lets find out

gusty comet
#

@ocean tundra works fine

torn kestrel
#

I ended up writing a few systems to generate an icosphere and a half-edge data structure and its sooo dang quick compared to when I did it with gameobjects

gusty comet
#

Can you use ecs in editor scripts?

ocean tundra
#

@gusty comet What sort of editor script?

#

Full DOTS (so entities and systems) have a editor world, or you could create a new world and manually update it

gusty comet
#

I am trying to create something like easy3droads

#

and imo dependency management and such is simple af in dots

#

so i was gonna make the editor scripts use dots since stuff like this can be resource consuming as is

ocean tundra
#

hmm i would just build it into the authoring flow

#

im not sure but the built in editor conversion world might have a way to render

gusty comet
#

that has me on a side thought now haha

ocean tundra
#

so your authoring gameobjects can be dumb and generate meshs ect then in editor it can just render the output like it would in runtime

gusty comet
#

is the mesh renderer unity provides for dots usable in parralel jobs?

ocean tundra
#

what do you mean by usable?

gusty comet
#

can I tell it to render stuff in parralel jobs

#

i've never looked into it at all yet

ocean tundra
#

the render mesh stuff is a component you put on a entity

#

and assign mesh/material

gusty comet
#

and it renders it inteernally?

ocean tundra
#

yea

gusty comet
#

i don't have to create a system?

#

awesome

#

hows it perform?

ocean tundra
#

internally its all magic

#

ummmmm

#

ok

#

๐Ÿ˜›

#

it will be better but right now its very wip

#

it managed megacity well tho

gusty comet
#

is changing the mesh expensive?

ocean tundra
#

yes

#

any mesh stuff is expensive

gusty comet
#

sucks

#

the unity animation package isn't the most usable rn

ocean tundra
#

and i think theres a single threaded bit/bug in the current hybrid renderer for uploading the mesh to the graphics card

#

yea thats terriable

#

but i think building on what unity have confirmed is the 'future' is probably the best way

#

the whole authoring/conversion flow has been said to be the way to use entities so start with that

gusty comet
#

so I was going to compensate by generating a mesh for each keyframe of each animation at edit time and change the mesh at runtime but that doesn't sound very practical if changing mesh is expensive

ocean tundra
#

also those conversion systems cna use jobs and burst and all that

#

well dont change the mesh then

gusty comet
ocean tundra
#

instead take the entity and create many entitys with render mesh for each frame and then add Disable to them

#

yea somewhere it says that convert to entity will be removed

gusty comet
#

I don't use either tbh

ocean tundra
#

you can still manually create entities from code tho

gusty comet
#

ok good

ocean tundra
#

i dont think they can remove that

zenith wyvern
ocean tundra
#

yea thats a good point

#

@gusty comet is there a way you could get by without animations for now?
My plan is to get all the core bits working and add animations later

gusty comet
#

@ocean tundra ofc i can, but the game just kinda looks awful with every ai and the character in t pose, if i wind up having to do t hat I will just make everything capsules for now xd

ocean tundra
#

haha yea i had that

#

i started using models in different fixed poses instead

#

still bad but at least not T's

gusty comet
#

Is there any other option?

ocean tundra
#

fight the animation package untill it works?

gusty comet
#

How did they animate the entities in the nordeous demo that they showed when ecs was first annoced

zenith wyvern
#

Gpu skinning I believe

ocean tundra
#

thats released somewhere

#

but pretty sure they took all that and built it into the animations package

rugged lark
#

@zenith wyvern can you talk to me about rendering and animating sprites within the context of DOTS? I want to create a bunch of pre-made pixel art tiles and draw them in when I render my tile entities

zenith wyvern
#

How are you rendering? Hybrid renderer?

rugged lark
#

I've currently got it setup to use Hybrid, yes.

#

But I'm not married to anything I'm still just prototyping

#

Hybrid V2 if that matters.

zenith wyvern
#

What I would do is figure out how to set per-instance uvs using hybrid renderer's material properties and use those to set your per-tile uvs

#

If you're not familiar with manipulating mesh uvs in code you should just create a simple project without ECS in it and read some tutorials on building and manpulating a plain unity mesh in code

#

Once you have a grasp on that the rest should be pretty easy

#

If all your sprites have the same mesh/material then it should be super efficient too

rugged lark
#

Okay, so I'm just rendering a small quad mesh for every tile. I don't know what mesh uvs are so I should go and figure that out.

zenith wyvern
#

Once you figure out how to swap out which sprite is displaying on a unity mesh by switching out the uvs in code it should make a lot more sense

ocean tundra
#

How do i disable live link for a specific world?

zenith wyvern
#

Also depending on how many of these sprites you're going to have you could get away with just using plain unity sprites attached to entities as hybrid components. It won't scale that well but you'll get the huge benefit of being able to use all the existing 2D tools for animation/lighting/whatever

rugged lark
#

I'm wanting to build an alife sim and high entity count is sort of what made me chase DOTS so I'd like to do whatever I need to lay a good efficient groundwork early ๐Ÿ™‚

zenith wyvern
#

In a recent project I just finished we could easily have a few thousand hybrid sprites running around, didn't get to the point of animating them though

rugged lark
#

I guess now is a good time to ask, does Hybrid Renderer v2 automatically cull the entities that are off frame?

zenith wyvern
#

Yeah

ocean tundra
#

you could do a hybrid approach but manage the linked gameobjects yourself, disabling and recycling the ones out of view
that way you get all the goodness of current 2d tools and most of the scale of dots

rugged lark
#

Well I'll head in that direction and see what I bump into. Thanks all.

ocean tundra
#

I wish unity made all their things public, All i need todo to disable live link in a world is get the LiveLinkRuntimeSystemGroup and disable it
but its private!!!

rugged lark
#

@zenith wyvern when you talk about switching out the UVs in code, are you talking about rendering just a portion of a Mesh UV and changing which portion that is?

zenith wyvern
#

Yeah

#

That's how you switch sprites on a sprite sheet

rugged lark
#

Okay. So is it better to have bigger spritesheets or a lot of spritesheets

zenith wyvern
#

The more sprites you can get in one texture (within reason) the better, since it means more meshes can share the same material which means less draw calls

rugged lark
#

Yeah it's the "within reason" I'm curious about.

zenith wyvern
#

AFAIK you should aim for some power of 2, not sure what the reasonable limit is though, I'm sure there's some technical reason to not go above a certain size

rugged lark
#

How do you handle converting the UVs into individual sprites? I guess what I'm asking is what is your workflow for carving a spritesheet into individual UV squares

zenith wyvern
#

In my roguelike I use Code page 437 ascii for my art, and I have the benefit of many pre-prepared ascii sprite sheets made by other people. In my rendering code I can calculate the uvs for a single tile from the size of the sprite sheet and the the "uv index", aka the x and y position of the sprite on the sprite sheet, since all my sprite sheets have the same amount of sprites (16x16)

rugged lark
#

Okay. Thank you for that.

zenith wyvern
#

You can also use Unity's built in sprite slicing tools to build unity sprites, then get your uvs from those during conversion and convert them into an ecs friendly format if yo uwant

rugged lark
#

Have a good night. I'm going to play some Valheim for a few then head to bed.

cerulean forge
#

What's a common way to model events in Unity's ECS?

I'd like to model an 'OnCollisionEnter' event for entities. My first thought was to have a 'Dynamic Buffer' on the entity for these events and add an event to the list whenever a new collision was detected, then have a system run at the end of each simulation step and clear this buffer for every (collidable) entity. I feel like that should work, but not sure if I'm missing a more obvious way to model events instead?

pulsar jay
#

@cerulean forge There are several approaches. You could either add a Tag component (e.g. OnCollisionEnterTag), use a buffer as you mentioned, create a new entity with a component storing the info relevant to the collision or take a look at some of the open source ECS Event systems that have been built on either of these solutions

#

I have not found a solution I am fully satisfied with though...

cerulean forge
#

(1) Is adding/removing components like that cheap? I didn't really dig in to the 'archetypes' too much yet, but I was under the impression that you should avoid adding/removing components every frame.

(2) An issue with adding a tag component would be the fact that you might have simultateous collisions with multiple other entities, so you need multiple components of the same type? Is that a thing?

(3) I don't dislike having a separate entity for the event, but the problem there seems to be that I can't query that. E.g. If I want all the collisions between entities with a 'Damage' component and a 'Damagable' component, I'll have to loop through all the collision entities and use the EntityManager to fetch each involved entity and check for the existence of certain components. A dynamic buffer doesn't solve that issue completely, but at least you don't have to check 'both sides' (e.g. have a query for all entities that have a 'Damage' component and a 'Collision' component and for each of those check what entities they are colliding with through the EntityManager, and whether those entities have a 'Damagable' component.

rare dew
#

adding tag components are practically free

pulsar jay
deft stump
fading nest
#

Hey

Is there a simple way to do audio in DOTS, I'm not finding much online in the way of basic examples such as a system that does something like

foreach entity
     if(entity.condition)
        play sound
deft stump
#

once you change an entity's structure. it needs to move to its matching archetype

rare dew
#

but do you change the structure by adding tags?

#

also please, can we have .net 5 in Unity soon plz?

pulsar jay
#

@rare dew sure it changes the archetype. It has to move so you can efficiently query and iterate it

#

@cerulean forge as I mentioned there is no silver bullet that I am completely satisfied with

pulsar jay
#

It also depends on what you want to achieve. If you want a system that handles all collisions 3) would work well

rare dew
#

but is it expensive to add and remove components from entities?

pulsar jay
#

If you just want to handle entities with specific components you should probably account for that in the code that would trigger your collision event

#

@Inuk depends on what you count as expansive. As I said it enables to work on that data efficiently later on

#

There are basically just 2 options: Sort them and work fast. Or avoid sorting and work slowly

#

depends on the task you want to achieve

deft stump
cerulean forge
#

Alright, thanks for the input. I'll mull it over a bit more ๐Ÿ™‚

#

But multiple components is not really a thing, right? Nor is querying multiple entities as if performing a 'join' operation (e.g. have a collision event with pointers to two entity ID's, and treating those as foreign keys to the actual entities, and then being able to query based on these entities' components?)

rare dew
#

there's dots physics

cerulean forge
#

I'm avoiding dots physics as it's still very experimental. (which does mean I have to do some awkward patching like this in my architecture)

#

My game uses mostly 'regular old unity' stuff, I just like to process some of the game logic in an ECS manner.

cerulean forge
#

Oh I see. What's the trade-off between multiple components and DynamicBuffer?

pulsar jay
#

@deft stump but not multiple components of the same type (as far as I know) which is what @cerulean forge asked for

#

thats what you usually use a dynamic buffer for

deft stump
cerulean forge
#

Alright ๐Ÿ˜„

#

@pulsar jay and no 'join' for queries, right? ๐Ÿ™‚

pulsar jay
#

Join? ๐Ÿค”

cerulean forge
#

As I described above. Treat an entity index in a component as a foreign key, and iterate both entities at once. (a bit like an sql join)

#

I'm having a peek at the documentation, since I didn't read up on 'manual' queries yet.

pulsar jay
#

well I guess there are cases where you have to do that

amber flicker
# deft stump It's not that it's expensive. It's pretty fast. but the moving the entity to ano...

@rare dew so I may have misunderstood what @deft stump was trying to say but:

  • Add/remove components is not "that" expensive compared to monobehaviour equivalents. That said:
  • Add/remove of a component does cause a change to the archetype of that entity. How costly this is varies. If it becomes an archetype that already exists, and there's allocated space available for another entity in that chunk, groovy. If not (or even if so but it leaving it's existing chunk affects thing), it can cause a bigger shuffle to entities. Still, not usually a big deal.
  • If you're doing a few hundred operations a frame, you probably don't want to be doing it
  • Add/remove has to be done on the main thread so causes a sync point. You want to avoid doing this usually anywhere but start or end of frame. This is what Entity Command Buffers are for: queue these operations for e.g. start/end of frame.
amber flicker
# cerulean forge But multiple components is not really a thing, right? Nor is querying multiple e...

Multiple components is conceptually an array of a component type associated with an entity. This usually takes the forum of a DynamicBuffer. As for foreign keys etc, I'm not 100% on what you're asking but you can store an entity in a component and you can find data using that entity as a key. It's called GetComponentDataFromEntity<T>() but when you're writing code in a SystemBase you can just use e.g. GetComponent<Blah>(someEntity); - this is a random memory access but in general you don't need to worry about that until you're talking about a heavy optimisation pass.

rare dew
#

so if I do it every once in a while, it shouldn't be anything significant?

amber flicker
#

yup, totally - and if eventually you profile and find that it is, there are strategies

pulsar jay
#

I just encountered a problem with spawning entities. As I use the BeginInitializationCommandBuffer and the custom systems usually run before the Transfom Group they always run at position 0 the first time they run

#

Am I missing sth or is the only solution to move every system that depends on positions to the end of the simulation group (after transforms group)

amber flicker
# pulsar jay Am I missing sth or is the only solution to move every system that depends on po...

How you handle it is up to you but understanding and managing the order of your systems is very important.
When the Transform system runs, it uses all the e.g. positions, rotations & scales in a hierarchy and calculates the final matrix. Therefore, you can either a) Spawn before the Transform system runs or b) Spawn after Transform but before render, in which case set your LocalToWorld matrix manually or c) spawn after rendering.

pulsar jay
#

Spawn exactly before the transform group could also be an option I guess. But to my surprise there was no commandbuffer at the beginning of this group

amber flicker
#

a command buffer would be a sync point - you generally want to avoid these mid-frame

pulsar jay
#

yeah I thought so

amber flicker
#

similarly, ideally you wouldn't instantiate an entity in the middle of a frame.. but if it doesn't happen frequently, nbd

pulsar jay
#

so I would have to either update the LTW manually or move all my systems that read position behind the transform group

amber flicker
#

well.. I don't know what's best in your case without knowing more. However "moving all my systems" should be pretty easy if you've got them all running on a ComponentSystemGroup - you can just add e.g. [UpdateBefore(TransformSystem)] above it. If it were me I might think if it was better to instantiate at the beginning of the next frame or something instead.

pulsar jay
#

its basically the targeting systems that find valid attack targets and the attack systems that execute the attacks on the found targets

#

I just added an entity that attacks once and then gets destroyed which makes the problem obvious as it attacks at 0 gets moved to its position and then gets destroyed

#

but obviously that problem also happens for the things that live longer (but only for the first frame)

amber flicker
#

It's certainly a common thing people run into but I see it as something to understand and then pick your preferred behaviour. Hopefully now you can better understand how to get the behaviour you want? But let me know if you have questions.

pulsar jay
#

Yeah thx. I guess I will try moving it to the end of the frame and see how it goes

covert breach
#

Does anyone know what the difference between GameObjectConversionSystem.AddHybridComponent() and EntityManager.AddComponentObject() on the destination entity manager is?

torn kestrel
#

I think the main difference is that AddHybridComponent creates a companion gameobject and keeps it linked with the entity

thorny halo
#

Hello, I'm using a NativeArray<int> in a struct. For some reason this breaks VS intellisense, if i do "struct_instance.", it doesn't pop any public methods of that struct nor public fields. If you use that struct in another struct, all intellisense for that struct is broken as well. Here's an example - https://pastebin.com/pVFBmGie. Does anyone know how to fix this?

karmic basin
#

I think you mixed with a DynamicBuffer ?

#

a DB in a component, that you can get in your system as a NativeArray

pearl pulsar
#

Archetypes seem to be denormalization of data that was previously normalized from breaking down from objects/OOP to separate components. Am I understanding the usage pattern and performance tradeoffs right by relating it to SQL databases here?

rare dew
#

I believe that's what unity themselves does when they explain it

deft stump
fading nest
safe lintel
#

unfortunately theres not really a simple audio solution yet(besides old gameobject workflows)

zenith wyvern
fading nest
#

I see, so a component who has an entity which points to a gameobject which has an audiosource?

zenith wyvern
#

More or less yeah. The gameobject becomes a hidden detail in this case, you're only concerned with the monobehaviour attached to the entity

#

That's what hybrid components do automatically

fading nest
#

okay

#

thanks for your help, I will go with this

safe lintel
#

man, wheres that dots blog post

chrome mirage
#

Supposing I want to start using and fully learning DOTS.. where would you recommend I should start? I did a DOTS workshop 2 years ago, and most of what I did is outdated, so I'd like some direction. No need to be spoonfed, just want to know where to start

robust scaffold
gusty comet
#

Is there a way to create an entity in a non job thread?

#

One i've created with c# threads

chrome mirage
#

I wanna learn the DOTS workflow, basically

robust scaffold
safe lintel
ocean tundra
#

@gusty comet I would create a Command Buffer on the new thread (or create on main and pass into the thread) then trigger the playback later on main thread

#

not 100% sure it would work, but i am pretty sure (90%) that you cant use entity manager on other threads

karmic basin
#

I'd add some Unite videos on Youtube, still relevant if young enough

#

and talk with us here ๐Ÿ™‚

#

Finally one or two blogs find useful things too

chrome mirage
#

I'll get a DOTS practice project going, try to recreate unity's samples and use the course as a guide

pliant pike
#

if you have a bunch of jobs in a system in order, then the dependencies are supposed to be automatic arent they?

#

it doesn't seem to be in my case, maybe because I have a `ToComponentDataArray<CellData>(Allocator.TempJob); in the middle between them ๐Ÿค”

pliant pike
#

next I tried using ToComponentDataArrayAsync to manually create a dependency and I get haywire results ๐Ÿ˜•

torn kestrel
robust scaffold
#

Just create the entities in the main thread.

#

Also, that's a lot of buffers. If Entities e contains HePoint buffer component, you can just access it using the foreach lambda variable. Use in DynamicBuffer<HePoint> hePoints then use the for loop.

#

The only reason you want to pre-call access to the buffers is when you use one of the struct based Jobs. Lambda is really convenient that it does all the GetBufferFromEntity for you.

torn kestrel
#

Thanks!

safe lintel
#

i disagree with that statement on ecbs, there shouldnt be any showstoppers regarding them and you should definitely use them if the case calls for it.

pliant pike
#

I don't suppose anyone knows if its possible to create a Jobhandle for ToComponentDataArrayAsync<>

coarse turtle
ocean tundra
#

Agree with @safe lintel ECBs rule

ocean tundra
#

use Handle as a input to schedule or schedule paraell

#

or combine it with Dependancy if your doing more nomal stuff eg Entities.Foreach

coarse turtle
#
entityQuery.ToComponentDataArrayAsync<T>(Allocator, out JobHandle handle);

var newDeps = Job.WithCode(() => { ... }).Schedule(Dependency);

Dependency = JobHandle.CombineDependencies(handle, newDeps);
pliant pike
#

I thought it was to pass in a dependency

coarse turtle
#

out parameters have to be assigned before the method finishes its scope

#

so ToComponentDataArrayAsync would have to assign the out JobHandle handle

pliant pike
#
JobHandle Jobuno = Entities.WithName("ResetCostandBestCost").ForEach((ref CellData celldudes) =>
        {....
        }).ScheduleParallel(this.Dependency);
var TempCelldata = CellDataQuery.ToComponentDataArrayAsync<CellData>(Allocator.TempJob, out Jobuno);```
#

so I'm guessing thats not valid

ocean tundra
#

you might need to combine the final dependancy and assign it back to dependancy ๐Ÿ˜›

#

Dependency = JobHandle.CombineDependencies(handle, newDeps);

#

wait think i read that wrong

#

Jobuno is a depenancy you want to pass to ToComponentDataArrayAsync?

pliant pike
#

yeah

#

I get all kinds of errors if I don't use this.completedependancy() after that job

ocean tundra
#

no clue how to do that sorry

#

complete will cause a sync point i think (wait for all jobs to finish)

pliant pike
#

and that's a syncpoint so I'm wondering if I can do it without a sync point

ocean tundra
#

so not exactly great for performance

pliant pike
#

yeah

ocean tundra
#

why do you need the data on the main thread?

#

can you have another Entities.Foreach after?

pliant pike
#

I don't the first job resets the values, then the second job uses those values

ocean tundra
#

so why are you using ToComponentDataArrayAsync? thats for main thread stuff isnt it?

coarse turtle
#

Well ToComponentDataArrayAsync allows you to schedule data collection and use it for a threaded job later

ocean tundra
#

oh i see

#

so you schedule the data collection and pass that into something like Job.WithCode

pliant pike
#

oh I didn't realise it worked like that, I just saw the jobhandle stuff

ocean tundra
#

the job handle will probably need to be passed into the jobs schedule method (Job.WithCode(STUFF).Schedule(dependancy))

torn kestrel
#

I got this system and for some reason halfEdges and hePoints comes back empty (the data is populated in the entity debugger). points comes back with expected data. I've switched to Run() to run on the mainthread for debugging. not sure whats up, any suggestions?

safe lintel
#

youre positive its the right entity?

torn kestrel
#

there's only one right now for testing haha

zenith wyvern
#

So instead of CopyFromData you run a ForEach and set the values manually

#

Typing on a phone sucks

zenith wyvern
torn kestrel
#

I figured it out, it was a silly mistake. I was triggering my HalfEdgeInit system at the same time as the HexGridGenerator system

zenith wyvern
#

Ahh yeah. Update order stuff is annoying to figure out

torn kestrel
#

I added the tags to trigger the systems at the same time in another system instead of separately

#

atleast i learned a good amount debugging this xD

#

I have to say even while figuring out the ecs/dots approach the performance i'm getting doing these subdivisions generating icospheres is insane. even my laptop does it ridiculously fast compared to the old GameObject way I tried.

#

on my main pc with an i7700k takes about 19 seconds to do 8 subdivisions from the time I hit the play button. with the gameobjects method I think my PC was struggling to do 7 subdivisions without freezing lol

robust scaffold
#

Of course, making it work is a lot more difficult.

torn kestrel
#

yeah I've been reading up on compute shaders

#

I've seen some stuff mentioned about GraphicsBuffer to replace Compute Shaders

#

but I need to do some more reading

#

right now my brain is recovering from all the reading I did on generating meshes and data structures

robust scaffold
torn kestrel
#

haha what a shocker xD

robust scaffold
#

Only part that works is StructuredBuffer and IndirectArguments. Nothing else works.

torn kestrel
#

thats why Im using hybridcomponents for my main planets so they dont get rendered with the hybrid renderer

robust scaffold
#

The only reason to use HybridRenderer is to use Havok Physics. No other reason to do so because you also have IParallelForTransform to move Mono Gameobjects. And gameobject rendering is much better optimized.

torn kestrel
#

compute shaders definitely seem like something that would benefit me a lot for this project but just need time to figure them out.

#

ah right on, so is it best to just avoid the hybrid renderer totally?

robust scaffold
#

Yea, I'm in that boat as well. Struggling to get a single quad rendered.

#

Yea, avoid Hybrid. Use base Entities packages.

#

ECS works perfectly and as intended. Some of the visualization and the whole ISystemBase is slowly being rolled out but the future is bright. Hybrid Renderer was a mistake.

torn kestrel
#

yeah the rendering side of things is confusing

zenith wyvern
#

And really if you want to render more than a few thousand entities its the only option unless you get into low level gpu stuff

torn kestrel
#

@zenith wyvern ah thanks that seemed to be the general consensus ive been reading online.

light mason
#

any one notice the build configs in editor killing unity

#

seem like if i doc it

#

or maybe its any layout off the default

#

yup docking the Wasm property kills Unity editor

light mason
#

wondering anyone know how to disable a sprite render in tiny

pliant pike
acoustic spire
#

I want to trace Camera's properties in ECS. What's more optimal: one system that queries camera object and copies its pos & lookat values to separate ecs component or querying the camera object in multiple systems on demand?

worldly pulsar
#

Depends on what you mean by "optimal"

#

In terms of performance the difference is unlikely to be noticable

rare dew
#

My entities won't render, but they do appear in the entity debugger and Hybrid Rendere V2 seems to be running proberly

#

I'm having game components in a sub-scene

#

(If I use the to entity script, they won't render either)

karmic basin
#

Pure ECS ? converted gameobjects ?

rare dew
#

@karmic basin it's game objects inside a subscene

karmic basin
#

strange

rare dew
karmic basin
#

go has a mesh renderer right ?

#

yeah ok

rare dew
karmic basin
#

hmmm I dont see it converted

#

SHould say so at the top of inspector

#

and "by subscene"

#

uhm

#

save subscene ?

rare dew
#

it is saved

#

that's an old vid

karmic basin
#

scene is autoload ?

#

yo uhave the define for HR v2 ?

#

sorry just throwing everything that comes to mind

amber flicker
#

try disabling srp batcher potentially

rare dew
#

I'll look into it when I get back home

zenith wyvern
pliant pike
#

yeah no worries Sark, I changed both to a foreach it seems easier that way, I can dispose of the nativearrays more easily also

#

its not like its much code just this

#
var celldatacount = CellDataQuery.CalculateEntityCount();
        NativeArray<CellData> TempCelldata = new NativeArray<CellData>(celldatacount, Allocator.TempJob);        Entities.WithName("CollectAllCellData").ForEach((int entityInQueryIndex, ref CellData celldudes) =>
        {
            TempCelldata[entityInQueryIndex] = celldudes;
        }).ScheduleParallel();```
lucid lake
#

Anyone know of any tutorials out there using the latest ECS 0.17 package to get an understanding on how to use this?

karmic basin
#

Well, manual has been updated and also the official github ECS samples are up-to-date

light mason
#

does ecb not support setEnabled

#

this is just setting componentData right

safe lintel
#

what is setEnabled in this case?

lucid lake
karmic basin
#

Start with the Hello Cube

#

clone the repo in local, it's easier to explore. And go to the next project in order (they are indexed)

#

It will introduce you to ECS concepts step by step

#

There's a smooool README in each folder to explain you in a few lines what they try to show you

#

I can find tutorials/videos but they use older versions of ECS or is a hybrid approach.
You can still understand the idea if they are less than, let's say 6-12 months old, then review the changelogs of each version to migrate your project.

#

Yes this involves a lot of work, but that's part of the fun that's expected if you jump so early into preview packages like DOTS

#

though ECS is kinda stable now really

#

Regarding the hybrid approach, that's the recommended workflow anyway

deft stump
light mason
#

Iโ€™m trying to disable entities

#

But I seen now it actually adding a disable component

#

And itโ€™s a structural change

#

But ECB does not have SetDisables only entituManager

deft stump
#

then why not just add the Disable component via ECB?

lucid lake
light mason
#

Iโ€™m in tiny

karmic basin
light mason
#

The setEnables traverse children too so I was hoping to use that

karmic basin
#

So you start from gameobjects, and convert to entities and/or use Jobs to perform heavy computation

#

but nothing wrong to migrate to Systems just for fun, even if no perf needed

lucid lake
karmic basin
#

ECS and Jobs are ready enough already to begin playing with it

#

Every other package.... well I'd say only for the more curious

safe lintel
#

theres basically no roadmap, everything is "at some point"

deft stump
#

plus the fact they're not being open with the community on what they're working on next

rare dew
#

Burst and Maths is already released

#

so in a sense, DOTS is already "out"

deft stump
#

partly

#

Jobs, Burst and Math is out

#

but still not the full stack which was promised for 2019

#

and then never mentioned ever again of when it'll get fully released

rare dew
#

wait jobs as well?

deft stump
#

Jobs is already production ready

rare dew
#

what is jobs worth without entities? ๐Ÿ‘€

deft stump
#

heavy duty math operation like pathfinding

#

or you can make your own particle system with jobs

#

now that I think about it. Jobs and C# async are in the same boat.
they can't really do anything with Unity's API

rare dew
#

I believe Jobs rely on entities, but I may be wring

hollow sorrel
#

job system was added before DOTS was even a thing

safe lintel
#

other way around, entities relies on jobs

#

but jobs are built into the engine/editor core, the package just adds a few new types

rare dew
#

oh interesting

hollow sorrel
rare dew
#

So jobs can also manipulate mono behavior?

hollow sorrel
#

no

rare dew
#

oh

gusty comet
#

So what is project tiny...is it like...a seperate editor?

#

Everything I read on it assumes you know what it is...

zenith wyvern
#

It's a set of packages that you use in the normal unity editor. When you build a tiny game it can't reference anything to do with UnityEngine

#

The getting started guide goes over it all in detail

pearl pulsar
#

I think the most compelling reason to give Project Tiny a shot is that it's more paved if you want to have both WebGL build and DOTS enabled.

#

At least that's why I wanted to try giving it a shot ๐Ÿ˜›

deft stump
#

and yes

#

it has its own editor

zenith wyvern
#

What do you mean? It uses the normal unity editor

#

There's no restrictions whatesoever when you're authoring

deft stump
#

oh right uuugh 3AM idiocies.
Tiny is a package

#

I need to freaking sleep

rare dew
#

@karmic basin I fixed the thing with the entities not rendering

#

By turning off HR V2

#

this of course implies I've set up URP wrong

#

can someone real quick TL;DR me the dots editor?

safe lintel
#

if you didnt have the srp batcher on with v2 enabled, hybrid renderer wont work

lucid lake
#

Would you want to use DOTS for player movement?

rare dew
#

@safe lintel I got it working with V2 now!

#

Didn't know how to apply the URP asset ๐Ÿ˜ฐ

ocean tundra
#

@lucid lake strange question, you want to use DOTS for EVERYTHING!!!!

lucid lake
#

If that is the future lol

#

I understand it is used for performance when many entities are performing similar tasks. But when don't you use it?

ocean tundra
#

i do pretty much everything in DOTS atm, but theres large things that will need old gameobjects

#

like particals

#

sounds

#

pathfinding is a weird hybrid

rare dew
#

I very much love how systems and entities are tied together

#

I find it oddly beatiful

#

I have to say however, I really don't like the magic of systems

ocean tundra
#

what magic?

#

the code gen?

rare dew
#

That you just make a system and the compiler just kind of... runs it

ocean tundra
#

you can see the intermediate output

#

go to DOTS => DOTS Compiler => Open inspector

#

personally i think its great, you used to have to write SOOOO much code, now we get a nice clean API

#

and the cost of code gen is so worth it

#

and if you really really need to you can copy the intermediate output and edit that

pearl pulsar
#

Oh yeah you can view both that and the burst-compiled IL for a given system, right?

ocean tundra
#

yup

#

im not good enough to understand IL tho

pearl pulsar
#

Is that only available within the Unity editor or is there a way to do that through command line and spit that out into a file?

ocean tundra
#

probably only via editor

#

but you could probably make a editor script to respond when calling unity via commandline

#

using -batchmode ect

#

the hard part would probably be finding unitys code that does the code gen

karmic basin
gusty comet
#

what is the status of DOTS right now?

ocean tundra
#

ummm some core bits a good and stable

#

but many many other bits are missing

#

and some core bits still are having API changes

gusty comet
#

@ocean tundra Like DOTS animation

ocean tundra
#

yea animation is pretty poor

#

but also things like particals

#

dont even exist yet

gusty comet
#

@ocean tundra How is the pace of development coming along?

ocean tundra
#

it feels like its slowed down ๐Ÿ˜ฆ

#

im not sure it actually has, but new updates seem slower and not a huge amount of new communication/future plans have been happening

#

at a guess i would say unitys new focus on stability has caused them to have to slow down a bit

#

but it could also be that the core DOTS(ECS) team has started looking at other packages (like particles? ) and havnt really said anything

#

honestly dont really know

gusty comet
#

Ok so when you describe the "Core" what does that include

ocean tundra
#

Job system - good
Burst - Good
ECS - good but still undergoing API changes + new features were discussed months ago with no releases yet

#

and then things like
Editor Tooling (inspectors) - rough , latest release feels ok but still dosnt quite merge right with existing Unity flows
Editor Tooling (conversion) - poor docs/communication, old parts they have confirmed to be removing ages ago still exist and new stuff has all sorts of issues
Maths - good
Physics - okish, still undergoing changes and kinda dosnt feel like DOTS

#

oh and the hybrid renderer
very poor ๐Ÿ˜› low to no docs and everyone seems to have some sort of issue with it

gusty comet
#

I hear they are going to release it in 2020 versioin as LTS

ocean tundra
#

ive never heard that

gusty comet
#

Any timeline on when 2020 will be released?

ocean tundra
#

no clue sorry

#

and i doubt DOTS will be marked as released (yet alone LTS) any time soon
not with unitys new focus on stability, the core might work but doing anything real with it requires rebuilding wayyy too much

karmic basin
#

so lets hope end of next month

ocean tundra
#

yea but no way dots will be 1.0ed or released with it

#

its not even in the package explorer as preview any more

karmic basin
#

Yup

gusty comet
ocean tundra
#

got to share some code

#

but looks like your using a native collection wrong

#

at a guess your creating a native collection without using Temp and not disposing it

gusty comet
#

also disabling that script same happens idk where is issue

ocean tundra
#

was expecting a system?

#

where does it say the allocation is happening

gusty comet
ocean tundra
#

something todo with netcode

#

no clue on that sorry

#

probably a bug within netcode

gusty comet
#

ohh

#

maybe i will try restarting unity after install netcode

ocean tundra
#

netcode is very very early

gusty comet
ocean tundra
#

no chanel for netcode

#

maybe networking might know

#

theres a networking Dots fourm

gilded bay
#

I'm looking to multithread pathfinding AI using the job system

#

can someone point me in the right direction?

deft stump
#

reading through DOTS best practices

#

it's kinda funny they're suggesting to Schedule when Run has little overhead.

#

There are plans for future versions of the Entities package to include an optional Enabled flag, implemented as a bit-field in a chunk component. This should provide a good balance between storage space for the flag bits, CPU cache bandwidth, Burst codegen, and should handle the tricky maintenance (for instance, rearranging the bitfields as a result of structural changes) automatically. When itโ€™s available, this might be the best option for entities with very frequent state changes, but in most cases, a tag component would still be preferable.

Oh Unity, you're such a tease uwu

safe lintel
#

i wish i had one of those newer amd cpus to test to overhead of scheduling with tons of cores

light mason
#

quick question

#

camera is automatically converted

#

can i just do an entities for each on Camera and LocalToWorld component if i need to grab the world space of the camera

amber flicker
untold sorrel
#

Reality check: DOTS Animation doesnโ€™t support skinned bone animation yet, right?

slim nebula
#

I was able to get one skin to work with thoughts animation but the instant I added a second one both of them messed up hard

#

I needed to get a hdrp lit shader graph version from GitHub and add texture coordinates or something to it

#

I don't think it's actually ready...

#

Also this is 2020.1 so maybe something changed

#

@untold sorrel

gusty comet
#

its possible to use hdrp with dots? i mean basic render pipeline works better than hdrp and idk

slim nebula
#

I mean I've been using hdrp with dots but I'm really just starting so I'm not sure what kind of ceiling I'm going to hit

untold sorrel
#

Yes. HDRP is the most supported renderer for use with DOTS. Itโ€™s also the one Unity recommends you use for ECS content right now.

torn kestrel
#

Hdrp is better than urp for dots?

karmic basin
#

I mean I'm going for mostly unlit rendering anyway, I don't need HDRP

pliant pike
#

talking about scheduling overhead which would you guys choose?

#

schedule single or schedule parrallel in this case

#

schedule parallel has a lot of overhead its not really much faster than singlethreaded, and it loads all the cores so not room for anything else

karmic basin
#

Yeah you might be too soon for optimisation. I would go for Schedule for now. Although I'm not one of the most knowledgeable yet on the topic
Is it a stress-test or normal conditions ?

pliant pike
#

stress test 1 million entitys

deft stump
#

I'd go for Sched parallel in this case

karmic basin
#

I'd go for schedule and keep profiling the more I add systems, until I see one bottlenecking

deft stump
#

but assuming you only have a handful of entities to loop through,
.Run() is way better

#

I'm still baffled why DOTS best practices is suggesting schedparallel as like the default.

pliant pike
#

I'm going to try and avoid using run() as that guide advises, even though it is faster

deft stump
#

then fall back to sched -> run

amber flicker
# pliant pike

I'm not totally convinced this exactly equivalent work - are you doing an extra copy back with the sched parallel or something? At any rate, as posted above, this somewhat matches the trade-off I've seen. Usually many x total amount of work done for small gain to single thread. Obviously here Schedule() is better I'd say but over a certain number of entities, you'll need scheduleparallel. Hopefully you never need to do it for lots in practice.

pliant pike
#

I don't know if I'm doing anything wrong with the copy backs I'll have to check with their versions

#

but yeah maybe I'll stick with parrallel for now, the total sum time is less and its in one frame

#

CopyFromComponentDataArray() is about 40ms faster, maybe they are using chunks or something its not really much faster plus I have to create sync points to use it so not worth it

rare dew
#

Well depends on your usecase I suppose

deft stump
acoustic spire
#

Will GL API work in bursted jobs? ๐Ÿค”

rare dew
#

But still, by assumption was that best practices where to use Run()

amber flicker
pliant pike
#

yeah your just junking up the main thread if you use run() all the time

#

you have to look at it holistically, its not about how individual systems runs it's about how they all run and work together

rare dew
#

Besides the attribute which tells a system to run after another, are there any way to determine the order?

#

Or is it "whenever", and with that asked, what about systems which are scheduled, will they also just run whenever convenient regardless of when their "sibling" (clone? other instances??) run as long as you don't have the shedparallel?

pliant pike
#

you can use SystemGroup

rare dew
#

Oh I didn't know I had to use system groups, interesting

karmic basin
#

You don't have to

#

You can use existing ones (and sometimes should)

#

but it's a convenient way to make your own groups

#

sometimes ๐Ÿ™‚

untold sorrel
#

Maybe Iโ€™m missing something about your use case, but the advice Iโ€™m reading here seems incorrect:

ScheduleParallel() is absolutely ready to use, and quite performant. Further optimizations to scheduling overhead may come in the future. But even now - the cost of scheduling a job across threads is usually dwarfed by the speed you gain by spreading out your job work across multiple threads. ScheduleParallel() has been the default go to for most job situations since Unity introduced the method. Thereโ€™s no need to avoid it - itโ€™s not unstable, and itโ€™s usually preferable.

#

I would usually only avoid it if I could guarantee my jobs would always only iterate over a few entities. Even then, the best practice would be AB testing to see which is faster, but I wouldnโ€™t avoid ScheduleParallel out of an assumption that itโ€™s not ready. It is.

pliant pike
#

well like those images above show ScheduleParralell() takes 3.ms across 14 threads which is a total sum time about 40ms, whereas Schedule() is roughly 6 ms on 1 thread total sum time

amber flicker
untold sorrel
#

Youโ€™re both right about your use cases - for sure. But - Iโ€™d argue that those hardware situations fall well outside the norm of what most Unity games are likely to run on.

#

The proper case to use ScheduleParallel() falls in a sweet spot, in which your job is doing enough work to offset the cost of scheduling a job to begin with - and in which your thread count is low enough that each thread would be doing enough work to justify the split

#

But - most gaming hardware today has between 4-8 cores. Maybe 2 or 16 at the fringes. And in cases when your jobs are doing enough work to make parallel scheduling worth it, then ScheduleParallel() is a great option.

#

If your jobs arenโ€™t doing enough work, or if you have a very high thread count, use Schedule() or even Run().

#

But - AB testing and profiling is usually always the best way to find out. What I thought was happening, is that the OP had the impression that ScehduleParallel() wasnโ€™t ready to use - as in, it was unstable. That isnโ€™t true - no reason to avoid seeing if itโ€™s a good case for your jobs. ๐Ÿ™‚

#

Also worth noting that the second problem (jobs being spread across thread counts too high to be worth it), is something a unity can likely improve in their own scheduling code going forward. I hope so!

amber flicker
#

I could nit-pick a few of those points (e.g. I think most things we write now will be most likely going to run on 8+ cores) but I somewhat agree. It's also true that giving a job more work helps. Though even then, I haven't seen decent scaling on any jobs completed per frame. Being that a lot of us have to write code not knowing what quantiy of entities or what platforms the code will run on, it's not very possible to just pick one. Coding it to dynamically switch is also a big pain right now. They've stated they don't want to have any kind of dynamic switching because they want the scheduling to just be fast enough. Which sounds great but I don't know what gains we can expect in reality. Right now, with my practical use-cases, it's an absolute brutal trade-off. Either eg. 5ms on main thread or 2ms main thread, 50ms total.

untold sorrel
#

Perhaps later on, weโ€™ll be able to give the jobs scheduler hints about how wide to go with a given job. But like you said, that need could change with the number of entities being worked on. Itโ€™s a tricky engineering problem, for sure!

amber flicker
#

e.g. you could in theory set the number of chunks you wanted to switch on pretty easily

untold sorrel
#

Hmm..Well if one thing is likely to drive their choices (hopefully), itโ€™s the raw performance numbers. If their current approach doesnโ€™t work well in valid use cases, hopefully theyโ€™ll consider all options.

#

Thankfully a change in the scheduling code might not rip up their existing API too much

gusty comet
#

i tried installing same packages from sample from github repo

#

but still its doing that

#

when i tried sample assets from github repo that thing was working

safe lintel
#

btw @untold sorrel did you look at the current animation samples? if that isnt skinned bone animation I dont know what is

#

@amber flicker where did joachim shoot that idea down?

#

That sounds kinda good to me but then again Iโ€™m using unityโ€™s jobs because Iโ€™d have no idea how to do multi threading without it ๐Ÿ˜€

rare dew
#

pfft

#

Just singlethread your jobs

#

who needs more than one thread anyways

#

(please note I'm just jesting)

gusty comet
#

someone knows how i can fix allocation warnings?

rare dew
#

are you deleting stuff yourself?

gusty comet
#

uhm?

#

i just installed entities package and started playmode on default scene

#

with netcode

rare dew
#

So you have done nothing besides that?

mystic bay
#

hi i was directed towards this channel as to my issue

#

my sprites are not rendering and giving me this error

#

its not rendering the floor sky and wall

#

is there someone who can possible help me?

#

please

#

pretty please?

rare dew
#

Stop begging

#

Sorry

safe lintel
#

if you call yourjobhandle.Complete(); on spriteshapegenerator does it work?

mystic bay
#

can you direct me to how i can do that as im not sure i see sprite shape generator nor know how to code the call

#

i have sprite shape controller sprite shape renderer and mesh renderer

safe lintel
#

oh its a package

mystic bay
#

how can i get it?

safe lintel
#

you already have it, it says so in your error that its in your PackageCache. When I first read your log I thought it was your own code throwing the error.

glacial bolt
#

@mystic bay Are you sure you wanted to use dots for your first project?

mystic bay
#

i was directed to this section by inuk

#

no but i didnt mess with anything

rare dew
#

Well that's because I saw the jobs part of the code

mystic bay
#

do i have to active some sort of code for this to fix the error?

glacial bolt
#

You should start with any basic course or tutorial pinned in #๐Ÿ’ปโ”ƒcode-beginner . This is an advanced system, and it is still under development.

mystic bay
#

but i didnt touch any of it

glacial bolt
#

You are using its components without knowing what they are.

mystic bay
#

im not using spriteshape generator

#

i added a td object

#

2d

#

and i just wanted to make it look like a floor

safe lintel
#

id guess you might need to add a profile to the sprite shape controller?

mystic bay
#

is there a way to not have to mess with this issue by importing an image

#

to not have to deal with the cod

#

e

forest pike
#

Is it possible to use the Jobs scheduler without safety features?

mystic bay
#

i dont know how to fix it

#

how can i disable safety features

forest pike
#

i'm not answering your question that's my own question lol

glacial bolt
#

@mystic bay You are looking for basic 2d tutorial, nothing to do with #archived-dots You shouldn't probably even trying to use Sprite Shape package as well at this point. You should learn on basic 2d components first.

forest pike
#

Is the blittable types restriction a fundamental limitation, or can it be disabled?

#

The Jobs scheduler makes good use of all available cores and I want to take advantage of that, without copying megabytes of memory every frame.

amber flicker
#

You can use class blah : IComponentData instead of struct blah : IComponentData for working with ECS when you have managed types. These can't be bursted however or used across threads. Afaik doing so can never really work. Instead focus on preparing your data and then copying back the results.

#

You can add various attributes to disable the safety features but.. you mostly shouldn't except in the case you're writing to a container in parallel and are very confident you're writing to unique keys in the job.

safe lintel
#

afaik cant use class components with jobs though

amber flicker
#

yes, exactly - amended thanks

safe lintel
#

what are you actually trying to achieve though? copying megabytes is somewhat vague, and imo you might be too reliant on old oop thinking if you are adamant on finding a way to use managed types in jobs

forest pike
#

So I'm making a Minecraft clone or whatever with voxel terrain, and I need to update each chunk and run some simulations each frame. If I've written to a chunk, I also need to update the mesh. With 256 chunks, it's about 19 megabytes.

public struct ChunkData : System.IDisposable
{
    public NativeArray3D<int> field;
    public NativeArray3D<float> field_density;
    public NativeArray2D<byte> field_heightmap;
    public Vector3Int mins;
    public Vector3Int maxs;
    public int writeCount;
}```
#

My plan was to take a leaf from Noita's book for multithreading: https://www.youtube.com/watch?v=prXuyMCgbTc&t=11m8s

GDC

In this 2019 GDC session, Nolla Games' Petri Purho talks about the technical details of Noita's physics engine, including scaling up the falling sand simulation to support large continuous worlds and integrating destructible rigid body physics, while demonstrating the emergent physics based gameplay.

Register for GDC: https://ubm.io/341ZiaZ

Jo...

โ–ถ Play video
#

That way, I can update each chunk in place concurrently, 64 chunks at a time.

#

I tried doing this with slices:

    {
        return new ChunkSlice
        {
            field = this.field.Slice(),
            field_density = this.field_density.Slice(),
            field_heightmap = this.field_heightmap.Slice(),
            mins = this.mins,
            maxs = this.maxs,
            writeCount = this.writeCount,
        };
    }```
hollow sorrel
#

@forest pike that's fine, think of nativearrays as pointers to your actual data, you're not copying the entire nativearray if you're passing it to a job

#

just the pointer to it

forest pike
#

okay, so it's not copying the whole array when I copy the ChunkData over?

hollow sorrel
#

nop

forest pike
#

so then it's just a code structuring problem. I wanted to get a 3x3 kernel of chunks to pass to my job: public struct ChunkKernel { public NativeArray2D<ChunkSlice> chunks; }

#

but at runtime, I get:InvalidOperationException: ChunkSlice used in NativeArray<ChunkSlice> must be unmanaged (contain no managed types) and cannot itself be a native container type. Unity.Collections.NativeArray`1[T].IsUnmanagedAndThrow () (at <e98ed0368295432e8c11e52d6243ee11>:0) Unity.Collections.NativeArray`1[T].Allocate (System.Int32 length, Unity.Collections.Allocator allocator, Unity.Collections.NativeArray`1[T]& array) (at <e98ed0368295432e8c11e52d6243ee11>:0) Unity.Collections.NativeArray`1[T]..ctor (System.Int32 length, Unity.Collections.Allocator allocator, Unity.Collections.NativeArrayOptions options) (at <e98ed0368295432e8c11e52d6243ee11>:0)

hollow sorrel
#

what is chunkslice

#

what does nativearray2d.slice() return

forest pike
#

a slice to the underlying NativeArray

hollow sorrel
#

what type is a slice

forest pike
#
public struct NativeArray2D<T> where T: struct
{
    public NativeArray<T> data;
    public int width;
    public int height;
    public NativeArray2D(int width, int height, Allocator allocator, NativeArrayOptions options = NativeArrayOptions.ClearMemory)
    {
        this.width = width;
        this.height = height;
        this.data = new NativeArray<T>(width * height, allocator, options);
    }

    public NativeSlice2D<T> Slice()
    {
        return new NativeSlice2D<T>
        {
            width = this.width,
            height = this.height,
            data = this.data.Slice(),
        };
    }

    public T this[int x, int y]
    {
        get
        {
            return data[y * width + x];
        }
        set
        {
            data[y * width + x] = value;
        }
    }

    public void Dispose()
    {
        data.Dispose();
    }
}
#

NativeSlice2D is the same as NativeArray2D, just without a constructor and with the NativeArray replaced with a NativeSlice

hollow sorrel
#

oh

#

you can't nest native collections

forest pike
#

yeah

#

so how am I to write code that is aware of the spatial layout of the chunks?

hollow sorrel
#

misunderstood your initial question, but yea there's no way around that, it's a fundamental limitation

forest pike
#

So if NativeArray doesn't copy its buffers, the slice usage is basically useless?

hollow sorrel
#

it's not useless

#

tho for your use case i suppose it is

forest pike
#

so I have to do this? ``` public struct ChunkKernel
{
public ChunkData center;
public ChunkData n;
public ChunkData ne;
public ChunkData e;
public ChunkData se;
public ChunkData s;
public ChunkData sw;
public ChunkData w;
public ChunkData nw;

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

is there a way i can make working with this less painful?

hollow sorrel
#

def not that

#

trying to remember what clean solution someone had

#

don't remember but anyway you could use UnsafeArrays and put collections in there, but you need to remember to dispose of them

forest pike
#

what namespace is that in?

hollow sorrel
#

ohyea also not sure if that NativeArray2D struct will work in a job since it holds a NativeArray = nested collection as well

#

ah UnsafeList sorry, seems unity didn't bother implementing unsafearray

forest pike
#

I don't get runtime errors when including a ChunkSlice in my job

gusty comet
#

@rare dew wdym some beside that

rare dew
#

please don't just @, reply gives better context not just to me but ither people as well

gusty comet
forest pike
rare dew
#

not that I think it does

forest pike
#

what about UnsafePtrList

gusty comet
hollow sorrel
#

@forest pike yea i think if going that way you'd have to use UnsafeList all the way instead of NativeArrays

gusty comet
#

i think i something missing

#

idk where maybe some config

gilded bay
#

Correct me if I'm wrong, but navmeshquery can be called inside the Job system right? So I just plug values into it and now I have multithreaded pathfinding?

#

I feel like I'm missing a step

#

I would have to make the job return the new position value of the NPC and apply the NPC's value outside of the job right? I've never done pathfinding before, just trying to get the hang of it

zenith wyvern
#

If you're going to have one huge container that holds your whole world you might as well just do it in oop, it'll be easier and probably faster

#

When I did this I had a single NativeHashMap<int3,entity> that I passed to jobs. The entity being the chunk containing a buffer of blocks

#

You can use BufferFromEntity to access block data from an entity

#

Then you can easily convert to/from block positions from the chunk index and local index

light mason
#

Wondering if anyone has some idea how I can draw a line in tiny

#

Bรฉzier curves type of thing

#

We have no line render in tiny right ?

cerulean forge
#

There is a EntityManager.HasComponent but I can't find a EntityManager.HasBuffer. How would I check if an entity has a buffer of a certain type?

safe lintel
#

Use hascomponent for the buffer

cerulean forge
#

Oh, I see :D. Thanks!

acoustic spire
#

Is the order of entities in query always the same as the order of insertion of these entities? I create entities through ECB in main thread and sometimes query.ToEntitiesArray() has different order

deft stump
#

yeah you should assume that you're not guaranteed of order.

acoustic spire
#

so what's the common pattern to have them ordered then?

#

I think about a separate entity containing dynamic buffer of these entities. Or just sort it after querying

deft stump
#

why do you want them ordered / sorted anyway?

acoustic spire
#

Because I can compute only the index of entity I need to process and nothing else

acoustic spire
# cerulean forge What do you mean by this?

I have entities that represent chunks of voxels in a scene. When I need to get information about a particular voxel I compute in which chunk the voxel is stored then I query all the chunk entities and access needed chunk by the computed index.

cerulean forge
#

So you have an entity with a 'VoxelChunk' component? And you want access to that component, and you know which entity you are looking for? Then why not call EntityManager.GetComponentData<VoxelChunk>(new Entity() { Index = computedIndex, Version = version });?

#

Can anyone confirm that using Acion and Func is not allowed in jobs (or anything burstable)?

#

If that's the case that would be a huge bummer ๐Ÿ˜ฆ

zenith wyvern
#

Correct. But we have burst FunctionPointers

cerulean forge
#

Oh man ๐Ÿ˜ข

#

Will a job without burst still run on multiple cores? In other words, do you still get some performance benifit in using ECS without burst?

zenith wyvern
#

You should profile, but in my experience no. Most performance gain comes from burst

pliant pike
#

if you have the data structured correctly you do still get a bit of a speed up compared to monebehaviour

acoustic spire
cerulean forge
#

Man, I'm really bummed out by this :(. No Action / Func means no quick easy abstractions. Burst has been a pain in the ass already but this is probably the nail in the coffin for me. I might stay with ECS without burst just because I prefer to build up the game this way than with OOP. But I had hoped things would go a lot smoother :/. Will these delegates ever be burstable, or is this impossible because of some hard technical limitation?

cerulean forge
zenith wyvern
acoustic spire
cerulean forge
acoustic spire
#

yup. I forgot that I use GetBuffer() unpredictable number of times inside my algorithm

north bay
#

You can call into managed from burst using function pointers @cerulean forge

#

Or what is your use case for actions/funcs?

acoustic spire
#

I don't get it. Is using interfaces in Burst allowed or not?
I'm using a struct that implements one method and see this

Burst error BC1020: Boxing a valuetype `Game.BlockProvider` to a managed object is not supported
zenith wyvern
#

It's allowed with generic type constraints

#

And your type still needs to be a struct

acoustic spire
#

Yeah, just found that on forum. Making stuff work in burst is a quest ๐Ÿ™‚

cerulean forge
#

I already gave up and I'm back to non-dots unity programming

untold sorrel
#

Does anyone here know how to load a Subscene at runtime? Do you just load itโ€™s parent scene using the SceneManager?

north bay
#

Depends, do you load the parent scene anyways? Just load the entire scene (with AutoLoad active on the SubScene monobehaviours).
Otherwise use SceneSystem.LoadSceneAsync

untold sorrel
#

Loading the entire scene does not seem to also load my subscene. Even if o have the parent scene open in the editor, if I hit play after Iโ€™ve closed the Subscene (which should run it through a conversion process), none of its entities will appear in the Entity Debugger.

north bay
#

You have AutoLoad on the subscene ticked and you aren't using NetCode?

untold sorrel
#

Yes.

#

Both of those things are true

#

May be important: my Subscene is closed and unloaded.

#

Same result though, if itโ€™s loaded but still closed

#

The only way I can get the entities to show up is if the Subscene is open in the editor, which defeats the point.

#

Ah, looks like the Entity Debugger just wasnโ€™t retaining the entity names from before it was a Subscene. That makes perfect sense.

#

So my entity which was named โ€œTestEntityโ€ in the debugger when the Subscene was open, was now named Entity 542, and it got lost in the mix.

#

Makes sense. Entities donโ€™t retain their names unless immediately converted from a GO

#

They donโ€™t need names

dark cypress
#

What's the difference between a system that has 2 queries and schedules 2 jobs and 2 systems that have a query+job each?

#

Barring dependencies.

pliant pike
#

you'll have a sync point between the 2 separate systems and a job each

untold sorrel
#

Why would that create a sync point? There isnโ€™t automatically a sync point between every system.

pliant pike
#

well yeah potentially then I guess

untold sorrel
#

@dark cypress There isnโ€™t much functional difference between the two. Iโ€™ll list some differences itโ€™s good to know about:

#
  1. The time is takes for a system to update isnโ€™t always negligible. One system scheduling two jobs will usually be faster than two systems each scheduling one job. But - organizationally, that may not always be the best approach. I general, I try to have one system per โ€œtaskโ€, so as long as all the jobs being scheduled by one system could be considered โ€˜stepsโ€™ on the way to finishing one piece of work, then Iโ€™ll group them into a single system. If not, then Iโ€™ll divide them up and eat the extra system update cost.
dark cypress
#

Thank you, makes sense.

untold sorrel
#
  1. There are some quirks to know about how Unityโ€™s automatic dependency management. For instance: if you call ComponentSystemBase.GetBufferFromEntity<T>() for the same type from two different systems, Unity will automatically create a dependency between those systems. Jobs scheduled by those systems wonโ€™t be able to run in parallel. But if you scheduled both of those jobs from the same system, they could.
light mason
#

wondering if somene could help me out please

#

im working in tiny and for the live of me i cant seem to scale an object up in Y

acoustic spire
#

What's difference between GameObjectConversionSystem and IConvertGameObjectToEntity and which one is preferable?

acoustic spire
#

Also, have someone had a problem that a single GameObject gets in conversion system twice when "convert and inject game object" is enabled? It is ok when GO gets destroyed though

#

Alright, it looks like my conversion system runs twice

#

Hmm. Fixed that getting rid of subscene since object is detected by both conversion worlds per scene.

untold sorrel
#

What's difference between GameObjectConversionSystem and IConvertGameObjectToEntity and which one is preferable?
@acoustic spire

#

GameObjectConversionSystem and iConvert are both run at similar times, and do similar conversion work. Technically, you could write your own conversion system which grabs all GameObject components of a type and runs them all through a conversion step, which would replicate the behavior of IConvert.

#

One isnโ€™t preferable over the other, but a conversion System offers you some power that IConvert doesnโ€™t. For example, if you wanted to collect data from all authoring components of a type, and then store some data from each of them into a single NativeArray, that would probably be much easier and cleaner to do with a conversion system.

#

You can also have more control over when a conversion system runs, using the UpdateInGroup or UpdateBefore/After attributes. There are multiple system group steps involved in the conversion process - for example, Unity doesnโ€™t add โ€˜Parentโ€™ Components to entities until after all GameObjects have gone through the conversion process. Thereโ€™s a system group which runs after that step as well. So if you need to access your entitiesโ€™ Parent components as part of your conversion code, you would need to make sure your conversion system ran in that group.

#

(I apologize that I canโ€™t remember the specific name of that group, atm)

acoustic spire
#

Great answer. Thanks!

dark cypress
#

How do I make child render meshes not lag behind 1 frame when changing position on an entity?

#

This code makes the entities appear instantly at the desired locations, but the child render meshes of those entities are at origin for 1 frame.

acoustic spire
#

I can't use empty args lambdas in a single job?

Job.WithCode(() => DrawAxes()).Run();
Zero-size empty struct `Game.DebugRenderingSystem/Game.<>c__DisplayClass_OnUpdate_LambdaJob0` is not supported. To fix this issue, apply this attribute to the struct: `[StructLayout(LayoutKind.Sequential, Size = 1)]`.
hollow jolt
#

what are the advantages of Hybrid urp ? im looking at the ecs samples - Hybrid URP Samples Project

#

can it still be used normally without ecs , but only for specific cases like 1000 bullets run on hybrid for what i assume will have better performance ?

torn kestrel
#

hybrid renderer doesnt render regular game objects it renders entities

#

you can use the hybrid renderer package and game objects at the same time though

#

all depends on what works best for how your scene is composed

gusty comet
#

I have some issues when I install dots into an HDRP preset project.

I do not have these issues if I make a 3D project and install dots and then install HDRP manually. Is there a specific order we're supposed to install these packages in to get it to work right?

torn kestrel
#

should work just fine I just set up a new HDRP project and added the DOTS packages no problem the other day

#

are you using a beta version?

safe lintel
#

shouldnt be issues installing dots alongside an existing hdrp project, if there are and you can reproduce it, its probably worth submitting a bug report

light mason
#

Any one have a simple toon shadergraph shader i can test in tiny

zenith wyvern
#

Afaik custom shaders aren't properly supported yet in tiny. I wasn't able to get them working at least

half jay
#

Can i use collection as field in IComponentData?

north bay
#

Only the Unsafe* ones not the Native* collections

last jasper
#

For really simple systems (eg, ForEach updating all Positions by Velocity *dt) will burst autovectorize the resulting loops?

#

(specifically, does generated assembly use scalar or vectorized ops?)

half jay
#

I have system like this and im getting problem when adding entity to LinkedEntityGroup id of added Entity always negative. So look like i should add entity to LinkedEntityGroup after playback and devide system into two jobs ?

stone osprey
#

When does it make sense to combine components ? Im currently working on a buff system... so my player has a max health and a current health. Those are two seperate components : Health{ float health } and MaxHealth{ float maxHealth }... I bet this is a bit too atomic, right ? Is there some sort of rule or guideline for splitting or combining components ?

hollow sorrel
#

@stone osprey there's very little downside to splitting up, so I'd say only if you can make the assumption they are always both present + always both iterated on then it makes sense to merge

#

if sometimes you want to iterate only health and don't need maxhealth from certain systems, then makes sense to split because iterating just health will be faster than merged

#

tho I guess with such small components (1 float) it's not a massive difference so architecture is worth considering too, if 90% of the time you iterate both then not worth splitting for that 10%

stone osprey
#

@hollow sorrel Thanks ^^ I guess then im gonna merge them... atleast i cant find any case where i only need to iterate over max health... and every health kinda needs a max health too for healing purposes. Thanks ๐Ÿ˜„

stone osprey
#

Buffs... well... my current approach is that each buff is one entity and gets processed by its own system. For example a physical buff system adds a certain value to the physical damage of each entity. But im running into a problem, order... lets say i wanna have a percentual physical damage buff which increases the overall damage by 10%. How do we make sure that this system runs after all buffs were applied ? Otherwhise it will calculate wrong values :/

zenith wyvern
# half jay

You need to use ecb.AppendToBuffer to add a newly instantiated entity to a buffer. Only the CommandBuffer that created the entity can correctly adjust the entity id when playing back later in the frame

#

Also Im not sure why you aren't including your dynamic buffer in your query instead of using bfe

zenith wyvern
half jay
zenith wyvern
#

It's the second argument.

safe lintel
#

oh neat, there are finally hybrid rendering samples in the samples repo

#

i didnt realize lightmap baking actually was working!

stone osprey
#

@zenith wyvern Thanks that will work ^^

stone osprey
#

I bet theres no way to get around ordering/sorting systems, right ? I have a bunch of systems where the order does not matter... but those buff systems are killing me :/

zenith wyvern
#

You can create your own ComponentSystemGroups and order those relative to other groups as well. Should cover almost any use case.

pulsar jay
#

How is SetBuffer supposed to be used? I was creating an entity from an archetype and was trying to add initial elements to its buffer. But SetBuffer does not take any data?

zenith wyvern
#

AFAIK SetBuffer functionally clears an existing buffer and returns it. You can add to the returned buffer

pulsar jay
#

I guess when instancing from an archetype AppendToBuffer should do the trick

stone osprey
#

@zenith wyvern Alright, thanks im gonna look into them ^^

pulsar jay
#

@stone osprey I also just recently figured out how important that whole sorting thing is ๐Ÿค”

stone osprey
#

@pulsar jay It really is... well the most standard stuff works without sorting, like movement and stuff. But once real gameplay comes into play its a pain to order the systems ^^

pulsar jay
#

but the cool thing is SystemGroups are also systems and can have conditions on when/if to trigger systems in its group. I think I will have a lot of use cases for these kinds of hierarchies

stone osprey
#

This brings me to another issue... the amount of systems... in my "buff/debuff" system i go with a pretty modular approach, that means i have a "PhysicalAttackBuff(float)" with a "PhysicalAttackBuffSystem" that loops over them to apply the damage factor. 1 Buff = 1 System... great to expand but a lot of boilerplate code. It would be great to have some scripting here, but im not that sure if its so smart to reference a "IBuff" interface or similar to replace the system logic ( IBuff{ apply(...); } ) due to the serialization later on :/ Any ideas on this topic ?

#

@pulsar jay Thats actually cool ๐Ÿ˜ฎ didnt knew that, but that sounds great

pulsar jay
#

Not sure if interfaces work well with ecs as I guess you cannot use them in entity queries

stone osprey
#

@pulsar jay Glad to see that im not the only one with this approach... currently i requestion many of my design decisions because there so few examples ^^ As far as i now you can use them when you use a class that extends IComponentData... but yeah... actually its evil oop stuff ^^ thats why i cant really decide between both variants

pulsar jay
#

but if you use interfaces do they work in foreach queries? I cannot think of a way that would work as the archetypes need a specific type to define its chunk

#

if you have multiple structs with the same interface they would (possibly) still require different memory layouts as the interface does not say anything about its fields

#

so they could not share a chunk which means you cannot query for an interface

#

I didnt try it but if querying does not work interfaces wont really help with reusing code

last jasper
#

@stone osprey you can implement a generic system and satisfy the implementation of an interface on your struct

pulsar jay
#

@last jasper but how would you query for components implementing this interface?

ocean tundra
#

@pulsar jay pretty sure you cant use interfaces in a ForEach

#

my vote is to use code gen

zenith wyvern
#

You can't use any generics in a foreach as far as I know. You can use them in jobs though, including IJobChunk

ocean tundra
#

yup

#

super annoying

zenith wyvern
#

So you can create a generic system like Elliot said and use type constraints for your derived components

fallen zephyr
#

Hey guys, how does ECS deal with event based stuff like effects? Lets say I want to be able to create an extendable system where different systems can apply modifiers to a player damage taking. In normal unity I'd use an on damage event and subscribe to that. How would I do it in an ecs?

ocean tundra
#

Ive seen lots of people using 'event entities'

#

so create a new entity, add your event types, then your systems to react to the event can run

#

to make it extendable other systems (yours or other devs) can run before your final cleanup system runs

fallen zephyr
#

So I'd create an Entity with a damage event component and all systems would react to that

ocean tundra
#

there is also a Event system in the unity Fourms, which are more event publisher subscriber model

#

yea

#

@fallen zephyr the issue with the event entities is there usually a frame delay
as you cant use EntityManager in a job to create entities

zenith wyvern
#

There won't be any delay if you don't use command buffers and you order your systems properly

#

You can also just use a dynamic buffer that fills with events and clear after processing if you want to avoid structural changes

fallen zephyr
#

I'm actually not using unity ecs

#

So my solution needs to be non unity ecs specific

#

But thanks for the help guys

ocean tundra
#

hmm that sounds tricky

fallen zephyr
#

I think I'm going for the event entity style

last jasper
ocean tundra
#

I think the issue with that is where the dynamic buffer lives
If its a singleton entity then you could have many entities trying to write into a single buffer, meaning you cant use schedule parallel, but you could have many 'event' buffers on the actual entities

#

I actually use that idea, many source entities write into a single dynamic buffer

#

never thought of it as a event system tho ๐Ÿ˜›

last jasper
#

Use case of the above system - you have different equipment which can be added/removed from a space ship, and modifies things like Thrust based on what the equipment is

#

@pulsar jay so you write an abstract system, which specifies generic types which must implement your interface, then inherit that abstract system<T...> to specify the actual T. I couldn't find a way to automatically implement it for all structs implementing an interface, for that you could presumably use templates

last jasper
# fallen zephyr Hey guys, how does ECS deal with event based stuff like effects? Lets say I wan...

Here's a specific example that might be of interest to you - It's a CalculateRangeEffectivenessSystem, which basically alters the strength of any Effect (could be damage, could be healing - they just have to be an entity with both LinearEffectiveRange and Effectiveness) based on the distance between user and target: https://github.com/ElliotB256/ECSCombat/blob/master/Assets/Battle/Combat/Calculations/EffectiveRange/CalculateRangeEffectivenessSystem.cs . In this setup, all actions (attacks, healing) are individual entities, which are spawned when a tool is fired or a tool is used.

gusty comet
#

someone have example of dots occlussion culling?

ocean tundra
#

im not sure but i dont think thats done in DOTS

#

instead i think its in the render piplines

safe lintel
#

theres a sample in the hybrid renderer samples for occlusion culling

ocean tundra
#

Oooo very cool

safe lintel
#

they were released fairly recently

ocean tundra
#

so many new samples

karmic basin
#

True. Skinned meshes are good to go now ?

safe lintel
#

sort of? afaik its still considered experimental(whatever that means given dots is preview), and the visual scripting part of animating is kinda not there, all animation examples focus on code based stuff

karmic basin
#

I see. I'll wait more, don't need it yet ๐Ÿ™‚ Thanks

toxic crest
#

Hi all ๐Ÿ™‚ Looking for some feedback from some people fairly experienced in both dots and standard game object architecture. I'm coming back to Unity after quite a long break and was figuring since I'm re-learning a bunch of stuff anyway, maybe I should just start right into dots/ecs since it does looking its going to be the future of Unity anyway.
Is it a bad idea to consider starting now into a dots/ecs project intended to actually be released at some point or is it stable enough to potentially release in its current/near future state?
Also, are there any serious considerations that may be a deal-breaker at the moment for choosing dots/ecs?

zenith wyvern
#

ECS is not stable or production ready and it won't be for a long time, probably a year or two at least at this rate

#

Jobs and burst are stable and fine to use

toxic crest
#

I did see mention somewhere about hybrid game objects being able to fill in the gaps for certain systems not yet there in ecs. Is it pretty limited what can be hacked together with hybrid gos?

zenith wyvern
#

Any monobehaviour can be attached to an entity using hybrid components, and it does work well. You don't get much performance gain from that though

toxic crest
#

ok thank you. I might just stick to the standard workflow and play with dots on the side to familiarize while things develop then. Anyone else with feedback just @ me ๐Ÿ™‚

sly jasper
#

I am new to dots and I am studying the github sample project.
If I want to see the script of the system in the entity debugger, is there any shortcuts to do so? or I have search through all folders?

ocean tundra
#

@sly jasper honestly i've never tried to go from unity to code with ECS

#

i would guess that the feature is missing

#

i always use Ctrl + T in Rider to go to the file

coarse turtle
#

I just use ILSpy and look at the assembly

ocean tundra
#

i assumed lee was talking about the actual code, not any complied/code gened ones

coarse turtle
#

Yeah I just use it to browse the source code ๐Ÿค”

sly jasper
#

I've got another question:
Is it possible for rigidbody to interact with physics body?
I want to only make my bullets ECS and preserve the current gameplay/physics logics. Is it possible?

zenith wyvern
#

What do you mean by making your bullets ECS? What bottleneck are you trying to reduce?

sly jasper
#

I want to, say, having 10k-100k bullets in scene, but with just a few player/enemy.
So if I can make a hybrid ECS only on the bullet movement part, there are much less items I need to work on.

zenith wyvern
#

In order to make them work with built in physics they would need to be gameobjects, and afaik Unity can't handle nearly that many gameobjects, with or without built in physics

#

If you make them pure entities and do the collision handling yourself it would work, but it would be complicated. Or you could make the bullets entities and generate collision data from your scene every frame and use dots physics. It should be pretty fast if there are so few gameobjects

sly jasper
#

I think the last option you proposed is something I want to achieve, but I am not sure how to generate the collision data.
If I mark my gameobject 'ConvertToEntity', seems it lost its original component logics. If I dont make it 'ConvertToEntity', there is no collision at all.

zenith wyvern
#

Are you using dots physics or built in?

sly jasper
#

Installed UnityPhysics package. Using physics shape, and physics body for bullet, keeping rigidbody for player

zenith wyvern
#

It's a bit complicated then since you're trying to use both physics at the same time. Normally I would say use hybrid components but you can't because that requires you to give up on built in physics. I guess you would need to convert using the "ConvertAndInject" setting in ConvertToEntity and then sync the player entity's dots collider to it's gameobject position every frame.

#

Normally with hybrid components it goes in the other direction - gameobject positions get synced from entities. It's going to be an uphill battle doing it the other way

sly jasper
#

I see. I have some ideas now, thanks

ocean tundra
#

whats the best way to disable physics simulation from a world?

#

note i still want to be able to do things like raycasts

#

but i dont need collisions or actual physics

viral comet
#

Hi guys! Is it possible to somehow place my custom EntityCommandBufferSystem right after the BeginSimulationEntityCommandBuffer ?

light mason
#

Entities.ForEach((Entity e, ref LocalToWorld l)=>{ l.Value = loat4x4.TRS(new float3(l.Position.x, 2f, l.Position.z), l.Rotation, new float3(2.0f, 2f, 2.0f)); .........

#

can i do this

#

it doesnt seem to error but im not seeing any of the transformations at run time

viral comet
ocean tundra
#

@light mason that code looks fine

#

for a temp test duplicate LocalToWorld and set that value too

#

just to make sure its correct

#

at a guess i would say the transform system is overriding your custom localToWorld

#

its usually better to just modify the 'simple' types like Translation

#

you would need to remove those in order to manually set localtoworld

light mason
#

can i set scale without localToWorld

ocean tundra
#

yup

light mason
#

really

ocean tundra
#

of couse

light mason
#

as in Scale IComponet

ocean tundra
#

2 sec and ill see if i can find it

light mason
#

i think last time is use Ecs that was not avaliavle

light mason
#

or i had bad info

#

Sweet mother

ocean tundra
#

theres Scale

#

and NonUniformScale

light mason
#

thank youj

#

this will make life a bit more simple , thank you

ocean tundra
#

all good

pulsar jay
#

How can I check if an entity has a buffer? There is HasComponent() but there is no HasBuffer(). I suppose just calling GetBuffer might throw an exception if the entity does not have this kind of buffer?

amber flicker
pulsar jay
#

I tried but it complains that it has to be of type IComponentData

amber flicker
pulsar jay
#

no I am using ECB ๐Ÿ˜ฌ

north bay
#

BufferFromEntity has a HasComponent method if I remember correctly

pulsar jay
#

@north bay you mean BufferFromEntity checks if the buffer exists?

#

I am using GetBuffer but that calls BufferFromEntity internally

#

@amber flicker strange that EntityManager.HasComponent takes buffers but ecb does not

north bay
#

No I mean that the struct BufferFromEntity<T> has a method with which you can check if an entity has the buffer

pulsar jay
#

@north bay do I have to user IJob in order to use BufferFromEntity? Looks like its supposed to work with injection?

#

Or can I just create it via new:

var b = new BufferFromEntity<IgnoreTarget>();
b.HasComponent(entity);
north bay
#

You can call GetBufferFromEntity<T> above your lambda and use that

pulsar jay
#

I am afraid I cannot. Because I get the entity I need the buffer from from a component in the lambda

north bay
#

What do you mena? Did you use ComponentDataFromEntity before?

#

It's just an access wrapper around the component type

pulsar jay
#

Just figured out I was wrong. In this case it should work as I need the buffer from the current entity

north bay
#

            Entities.ForEach( ( Entity entity, in Comp a ) =>
            {
                if (whatEverFromEntity.HasComponent( entity ))
                {
                    
                }
            } ).Run( );```
pulsar jay
#

yeah thanks this should work

#

I just thought I was needing the Buffer not from the current entity the system iterates on but from one referenced by a component

#

so in this case it would not be possible do get the buffer before the lambda

north bay
#

It would

#

GetBufferFromEntity doesn't care what entity you pass to it

#

It doesn't even know what entity you iterate upon

pulsar jay
#

Oh I see I have to pass the entity later on ๐Ÿ˜…

#

It is just so confusing as the name implies that it is getting a buffer (like right now)

north bay
#

Yea.. standard dots stuff

#

You just get used to the weird API lol

pulsar jay
#

So that works thx

#

Maybe another small question: Is there an easy way to copy the buffer onto another entity?

#

What I am trying to achieve is copy the buffer to a new entity and add the current entity to it

#

Its basically a history of entities that have been "visited"

#

Currently I just itarate it but maybe theres a better way?

var ignoredArray = ignoredTargets.AsNativeArray();
foreach (var ignored in ignoredArray)
{
    ecb.AppendToBuffer(entityInQueryIndex, entity, ignored);
}
amber flicker
#

Looks fine to me. Though depending on your setup, instantiating an instance of the existing entity may be quicker.