#archived-dots

1 messages Β· Page 132 of 1

bright sentinel
#

Or else the hybrid renderer wouldn't really work

#

Like at all

zenith wyvern
#

You should really simplify your problem, break it down to a couple of different entities with RenderMeshes and you will see how it works.

#

If you want to have any kind of instanced rendering you need to either add a new material/mesh or use the SRP material properties

#

Which are barely documented right now unfortunately, but they do work with SRP9 and Hybrid Renderer v2 when you set everything up properly, from my testing

gusty comet
#

I'd love to test that but the SRP9 package has gone AWOL in the last day or two.

zenith wyvern
#

What does that mean

opaque ledge
#

you can find them in package manager

gusty comet
#

Absent Without Leave. It's missing from GitHub

opaque ledge
#

its in Graphics github now

zenith wyvern
#

You can get it directly through UPM if you're using a Unity version at or above 2020.1b3

gusty comet
#

Oh, cool! I'll go grab that then. It may not be documented, but it at least gives me something more than spinning my wheels

zenith wyvern
#

You just click the "all versions" thing in the package list and URP 9 shows up

gusty comet
#

Awesome. Going to back up my project, and get it converted over tonight then. Might sleep before playing with it.

#

I've been like a hamster in a wheel on this thing, and that hasn't happened in some years. It kept waking me up last night

zenith wyvern
#

Just keep in mind it's like brand new (for us), lighting doesn't work at all in URP, and there's almost no documenation

gusty comet
#

SRP9 works in HDRP though, right?

zenith wyvern
#

I haven't tried it but yeah as far as I know it works and is more fleshed out than URP right now

#

WRT to Hybrid Renderer that is

gusty comet
#

I saw that mentioned on the forums, and that's when I switched over, earlier today

gentle osprey
#

What would be the best way to store the previous values of entities? I'm toying around with a 2D game and was thinking of using the previous velocity and this frame's velocity to see if I should start a walking animation. Currently I was thinking of just creating a "previous velocity" component, and have a system running at the end of the frame that updates it.
(Also open to other ways of simple detection on whether or not movement has started to play animations)

gusty comet
#

Suggestion: Put previous velocity, current velocity, and future velocity all in an acceleration component. Update future velocity using an acceleration rate multiplied by time since the user began the triggering input. Reach a max velocity that syncs with your animation, and then set the acceleration to mask when it isn't synced (sleight of hand, to make it look good). Have the previous velocity field solely to detect deceleration outside the system that set it. This way, your animation can do the same thing in reverse when the player lets off the button.

#

Then you can adapt both velocity and animation to other triggers and events as well, automatically, just by manipulating the three tenses of velocity.

#

Example: user runs a character into a wall, velocity is set to zero, and that abrupt stop triggers the collide animation. User hits a patch of waist high water, slows down, and the animation automatically slows to match. etc

gentle osprey
#

I think i get it, though I didn't really understand what you meant with the: "and then set the acceleration to mask when it isn't synced"

#

And, I guess in that example, it's future velocity that's set to zero?

remote coyote
#

semi-dots/Netcode related, but anyone know if there's a way to call the new BuildConfiguration assets from command line?

stone osprey
#

How do i update a icomponentdata set ?

#

Can i simply do something like "myComponent.myvariable = 10" ?

remote coyote
#

Build configuration API has Build(), so I'll probably have to hook into a command line call in some custom way and forward it

stone osprey
#

I spawn only one entity archetype... but the entity debugger shows me two times the same entity... any idea why this may happen ?

warped trail
#

show us the code 😏

stone osprey
#

Defining the archetype im spawning in

#

Spawning the entity... clone(0) simply calls the "createCharacter" method

#

and the customizer on the created entity

naive parrot
#

whats going with the language syntax..

#

var X : Type ??

#

what is this?

warped trail
#

rider? πŸ˜…

naive parrot
#

whats going on exactly there? rider can alter syntax ?

warped trail
#

createCharacter should create only 1 entityπŸ€”

#

it is just visual thing , not real syntaxπŸ€”

naive parrot
#

why though ? is there advantage to reading/writing code like this? is this mimicking some other language?

naive parrot
#

interesting.

warped trail
#

@stone osprey are you sure createCharacter is called only one time, cause Clone does not sound like you are creating something new, it sounds like you are copying something, that already existsπŸ˜…

stone osprey
#

@naive parrot @warped trail Yep rider... i like it more than vs and it has a great integration with Jetbrains toolbox, especially if you use other jetbrains IDE's... furthermore it comes along with many cool features, auto generation of unity event functions, showing asset usages or asset overrides etc... Back to the code, yep im debugging that since half an hour... its only getting called once, its called clone because it depends on the "prototyper" pattern, but it basically does not clone, it simply calls the referenced "createCharacters" method πŸ™‚

opaque ledge
#

Were you able to find out the reason πŸ˜„

#

I know that when you convert a prefab and instantiate you will have 2 entities, 1 for prefab, 1 for 'clonse' of that prefab, i never did archetype stuff however so i cant know

#

still, doesnt sound like a big issue πŸ‘€

timber rivet
#

So as I understand it, there isn't really an "official" way to implement NavMesh agents with ECS, is there? I only really need a few handfuls of agents running around, so I was thinking I could just implement them in monobehaviour with gameobjects and then interface those with entities in the background, but I've also been having trouble actually interacting with gameobjects in a system

safe lintel
#

well no only using them as regular gameobjects and then just interfacing with them as you would any other monobehaviour

#

there are a few github repos of user solutions, if you search in the dots forum, but then you're at the mercy of the author if the official packages become out of date, personally im just biting the bullet and using the old unity engine stuff as I also still rely on skinned meshes and dont care to use 3rd party stuff while ecs is in preview(which might as well be forever)

timber rivet
#

Yeah, I saw a repo of some guy basically building navmesh from scratch in ECS, but that seems like overkill for my use case and also not futureproof as you say

#

Oh, I guess I've been doing it the wrong way around and I should try to work with entities in a monobehaviour script rather than with gameobjects in a system

coarse turtle
#

I think there was an experimental API for multithreading navmeshes at some point in time

safe lintel
#

i think someone here(im butchering the name, xjvs?) posted a snippet on the forums using it, it worked well but its just for finding the path multithreaded and doesnt really cover any part of the movement agent side of things

coarse turtle
#

ah

#

i havent played with it - but i can imagine you can copy the position back to the LTW matrix right?

safe lintel
mint iron
#

funnily enough i chose that name specifically because its hard to remember

safe lintel
#

i felt bad πŸ€” so much, given that you post so much here and I couldnt remember 4 letters!

timber rivet
#

Belated thanks, I'll have to look at that stuff

#

I might just try to make my horrible monobehaviour frankenstein work somehow first since I probably don't need to multithread my pathfinding too much when I expect to be handling at most like two dozen agents, but who knows

opaque ledge
#

I think there was a forum topic about it

#

and also i think Astar pro project is using jobs/burst in their beta version if you have bought it

gusty comet
#

Hi! I'm trying to integrate HDRP decals into my project, is there any dots way to handle decals or is managing gameobjects the way to go?

scarlet inlet
vagrant surge
#

@scarlet inlet very nice

#

looks like that sub-updates is a persistently mapped cpu buffer

scarlet inlet
#

yeah I wouldn't use it in production though, very subjective to the driver implementation I think. However we use GPUInstancer as it is and the number of objects we can render doesn't stop to amaze me

vagrant surge
#

you can make it safe if you do the triple-buffering yourself

#

but im not fully sure how unity does it

#

1 million instanced cubes is no joke

scarlet inlet
#

Look at this video, it's already a couple of releases old. Everything you see it's continuously processed, physic, logic, graphic. There is no zone culling or portal. There is only the rendering culling based on the frustum that GPUInstancer does https://www.youtube.com/watch?v=IrqMPyD6G-Q

Sequel to long gone but not forgotten Raid 51 level also built in GameCraft, some time ago, while it was still called RobocraftX and the scale of basic block was roughly 3 times as big. The game itself has come a long, long way since then and it's currently being developed mor...

β–Ά Play video
vagrant surge
#

lots of bushes there

scarlet inlet
#

hehe yes πŸ™‚

wide fiber
#

When I open the build of my game it crashes immediately during loading.. How can I find the problem if no error appears?

opaque ledge
#

πŸ˜„

#

do you do any math functions ? such as LookAt or Normalize ?

wide fiber
#

I use math.normalize

opaque ledge
#

If you feed very small vector3 to these functions they will return NaN, and if you are doing any other operation depending on these values behaviour will be undefinied and can crash

wide fiber
#

But it was working before (there was already math.normalize)

#

I am using normalizesafe sorry, not math.normalize

opaque ledge
#

ah okay, well i suggest you should do DisableAutoCreation attribute to your recently updated systems, thats how i find out

wide fiber
#

There is a problem.. how can I dispose a native array in a struct when it's destroyed?

opaque ledge
#

You cant put native array into Component, but if you are talking about plain struct then i guess you simply dispose of it when you know the entity that has that struct is going to die

#

i never tried tho

wide fiber
#

(Because structs don't have OnDestroy)

#

Yeah it's a plain struct

amber flicker
coarse turtle
#

πŸ€” that's a pretty interesting find about the entity debugger

bright sentinel
#

Yeah it's pretty interesting why it's not enabled by default πŸ€”

amber flicker
#

14th - faux gdc, entities 1.0??? πŸ˜…

south falcon
#

Any one knows whether Convert of IConvertGameObjectToEntity called first or Awake called first?

opaque ledge
#

convert first iirc

#

Tho it does sound like there is a better way to do what you are trying to do

south falcon
#

Would Gamobject's position change after I set entity's translation if I select convert and inject game object in Convert To Entity

#

There is a problem. I want to spawn a entity and set its initial position. First I Instantiate a gameobject prefab with Convert To Entity script, then set Translate data in Convert function of IConvertGameObjectToEntity. But the this gameobject still spawned at position(0,0,0).

bright sentinel
#

Is there a reason you're not using SubScenes?

opaque ledge
#

There are 2 components to sync entity/gameobject transform, CopyTransformToGameObject and CopyTransformFromGameObject, they both live under Unity.Transforms namespace, if you are thinking about changing your entity's transform thru ECS then put CopyTransformToGameObject and entity's gameobject will sync, if you want to change your gameobject's transfrom thru MB then put CopyTransformFromGameObject and entity's transform will sync

#

afaik you cant put inject mode in SubScenes

south falcon
#

thx, I will try it

bright sentinel
#

What exactly is inject mode? Can't find anything in the docs

opaque ledge
#

It basically needed for the gameobjects that you want to still exist after its converted to entity, its generally used for the functionality in MB that has no equilevant of it in ECS, such as camera

bright sentinel
#

Will there be any link between the MB and the Entity?

opaque ledge
#

so Unity puts a "CompanionLink" component in your entity and puts your gameobject to there

bright sentinel
#

Well there you go

#

So I can query for CompanionLink to get the MB from there?

#

Because right now I'm doing it in a pretty janky way

#

Like for my UI (very temporary) I have a Canvas that has a UIManager MB. This MB is in charge of setting the UI in MB world.
To get the data from ECS I have another GO that get's converted. This has a converted hybrid component that references the UIManager.

Would it then instead be possible to have all this on the same object with inject instead?

opaque ledge
#

quite possible, tho i suppose its better to do just have GameObject in your query

bright sentinel
#

What do you mean?

opaque ledge
#

All the stuff in your MB will be 'added' to your entity, for example if i have a camera in my entity, this camera component will be added to that entity, so in order to get all the entities that has a camera component in ForEach i can do
ForEach((Camera camera)=>).WithoutBurst().Run()

#

so GameObject itself will be also added to that entity so you can just do ForEach((GameObject gameObject)=>).WithoutBurst().Run()

bright sentinel
#

But I can also get any MBs right?

opaque ledge
#

Yes

bright sentinel
#

Okay, then I guess in that case it would be better to use the UIManager, no?

#

For my example at least

#

(And note I'm not talking about the specifics of doing UI in ECS, more about interacting with MBs)

opaque ledge
#

You can just put a dummy script in your gameobject and do inject, and inspect the entity debugger to see what unity has done

#

yes, if you put UIManager script in your gameobject and do inject

#

then simply do ForEach((UIManager uiManager)=>).WithoutBurst().Run()

bright sentinel
#

Alright, that's good to know. But then I guess it will also get the canvas MB on there, which I don't think is quite optimal

opaque ledge
#

why wouldnt it be

#

i mean your gameobject will simply stay there

bright sentinel
#

Yeah, it makes sense. But it's just not something I'd really want access to in ECS world I guess

#

Or I could just get the UI stuff in the system and do it all there? πŸ€”

opaque ledge
#

if your UIManager is a singleton i would just get the components i need from entity manager in OnUpdate method and set the necessary values, its a dirty way of doing it πŸ˜„

wide fiber
#

Can entities have a layer value? Like with GameObjects

#

Or do I have to implement it myself?

coarse turtle
#

you'd have to implement it yourself

#

unless you're talking about the physics authoring πŸ€”

vagrant surge
#

anything of value on the new unity streams?

#

for someone interested on dots

warped trail
#

@wide fiber or you can wait for v2, there is rendering layer componentπŸ˜…

dull copper
#

@vagrant surge there's not much for DOTS announced yet. on 22 April there's "Meet the Team Behind DOTS Sample" which doesn't really tell much what it's about, doesn't sound very technical session either

#

28 April has "Using Burst Compiler to Optimize for Android" but if you are not into mobiles, I doubt that'll be that interesting either

#

"Description:Join this session to learn how our partnership with ARM helps bring the power of the Burst Compiler to Android, enhancing multicore processor performance and power management. You’ll learn how Burst grants ahead-of-time compilation of critical C# code to native code and the features it enables (e.g., Advanced SIMD)."

bright sentinel
#

I think streaming is still a bit off

dull copper
#

@bright sentinel ?

opaque ledge
#

Advanced SIMD πŸ‘€

#

its quite nice for me as i was going to release my first game to mobile 😈

warped trail
#

i'm still waiting for Mike's gdc talkπŸ˜’

opaque ledge
#

is that actually going to happen ?

warped trail
#

πŸ€·β€β™‚οΈ

last jasper
#

Is this the place for tiny?

amber flicker
#

welcome @last jasper πŸ™‚ - yea for what little there is, probably here

bright sentinel
#

@dull copper I meant that streaming is probably not going to be landing for a while

vivid copper
#

I have a Cube prefab with physics shape an physics body which I convert to a entity: Then instantiate a bunch of this entity prefab and set its nonuniformscale component to random size. But this only changes the renderd mesh and the physics body stays the original size. is there a way to adjust this ?

safe lintel
#
warped trail
#

i don't think this will help himπŸ€”

#

if he instantiating this objects from one prefab, then he basically get copies of BlobAssetReferense<Collider> which are pointing to same blobasset

#

just create new collider for every instantiated object which you want to modifyπŸ€”

safe lintel
#

well you could create an array of sizes and make a collider for each one and then select one at random for a pseudo random effect, but theres not really an alternative and perhaps given how theyve responded to such things there may never be a true alternative πŸ˜’

mint iron
#

i think i saw a checkbox in the physicsShape to force a unique collider

warped trail
#

it is unique, when you create entity via authoring component 😏

#

but i may be wrong, and they figured something out for instantiating caseπŸ€”

vivid copper
#

thanks for the input. I try it, might be that I come back to this ^^

stone osprey
#

Is there a dots api for animations ?

wide fiber
#

Is there an easy way to get the component in a child in a child? Or do I have to use queries to get the right child, than another query to get the component?

opaque ledge
#

You can do GetBufferFromEntity<Child> in OnUpdate and access entity's child buffer using indexer access like buffer[entity]

#

i think there is a dots animation package but its in very early state so not sure if its usable right now

wide fiber
#

Is there a better way?

#

Like GetComponentInChildren?

zenith wyvern
#

HDRP only apparently

amber flicker
#

@wide fiber not really, no - though you can use ComponentDataFromEntity if you have the entity of the child to get the component data

stone osprey
#

Thanks @zenith wyvern ! So its very experimental right now... i guess im gonna stick with monos for the first :9

#

Another question... Is there a way to store "Action<>" or "Func" inside a component ?

#

Would love to have a health component which is able to call events on death/on alive

zenith wyvern
#

There's Burst FunctionPointer which can be stored in a component

stone osprey
#

Burst FunctionPointer... thats interessting πŸ™‚ Is it able to return/accept params ?

zenith wyvern
#

I think events should probably be built around the idea of using Event Components or an actual event system though, building events into your actual components themselves is kinda an OOP way of doing things I think

#

It can accept and return params, yeah

amber flicker
#

just to add if you're thinking actions / callbacks to mb land, it'll all need to main thread - you could also use an ICD class potentially

stone osprey
#

I thought about event components... but i cant really decide between them and the integrated callbacks... both have advantages... @amber flicker So you mean the FunctionPointer<> calls are getting executed on the main thread ?

amber flicker
#

no, sorry if I confused things

zenith wyvern
#

Just to clarify a bit, the reason you might want to avoid callbacks inside your component - any time you need to call that callback, you need to pass in any state it requires. That means that state needs to be passed all down the line of your ECS system to get to your component callback, and it quickly becomes a whole thing

#

Ideally the components themselves will represent the events/state and your systems will respond to them. That tends to fit better in ECS imo at least

amber flicker
#

if you want to e.g. associate an action like () => gameObject.SetActive() with an entity, i.e. you're working in mb/managed land, you could use an ICD class instead. Or just a dictionary (entity, action) etc. Might not be what you're doing at all.

stone osprey
#

Ahhh alright... so you mean the bridge πŸ™‚ Thats right... im currently going with a hybrid approach... ecs for the data structure and gameobjects for the visual part, so i guess theres no real multithreaded approach for this scenario right now...

#

Is there a documentation of "FunctionPointer" ? The Burst-Package does not know that struct

#

Oh wait

#

it selected the wrong version again

wide fiber
#

Ok thanks

formal scaffold
#

Not sure where to ask, if I create a static function it is loaded inside the memory for as long as the programm runs. I assume it's loaded inside RAM. When I use that function it is loaded inside the cache, correct?

warped trail
#

with this ecs, everyone became obsessed with cacheπŸ˜…

opaque ledge
#

all because of Mike Akton πŸ˜’

#

πŸ˜„

formal scaffold
#

Tell me all about Cache πŸ‘€

wide fiber
#

How can I query the components of a disabled entity?

formal scaffold
#

I think it's very helpful to know this in the future, any Idea if there is a documentation on this? Prolly inside C# docs somewhere 🧐

mint iron
#

@wide fiber .WithEntityQueryOptions(EntityQueryOptions.IncludeDisabled)

wide fiber
#

Ah ok thanks

#

If I want to only include disabled ones? Should I also put the .WithAll<Disabled>()?

safe lintel
#

yeah

wide fiber
#

:)

vivid copper
#

I have 2 platforms on the same level and they do not have a gap between but when my ball rolls fast enough over the "joint" it starts hoping. Is there something I can do?

safe lintel
#

this is something that unity physics does(i am not a fan πŸ˜’ ), you either need to modify the simulation and weld the points(samples repo might have an example of this) or use havok which does this automatically

warped trail
#

you have to specify which layers are weldedπŸ˜…

vivid copper
#

can I weld at runtime? because these platforms are generated at runtime

zenith wyvern
#

There's going to be a livestream from the dots sample team right, anyone know when that is?

safe lintel
#

where was the official mention of that?

#

i also saw mentioned a while ago meet the dots team but i only ever saw that on discord

zenith wyvern
#

I don't know, I remember seeing it...somewhere. Now I can't find where

safe lintel
#

artengine πŸ€”

bright sentinel
#

@vivid copper If they're generated at runtime, can't you just "weld" them together before spawning them?

vivid copper
#

well instantiated is the correct term, as soon as I figure out how to weld i'll try but i do not even find a guide for this

bright sentinel
#

@vivid copper It's essentially making one big mesh instead of two small ones, and combining vertices close together

#

You can make a pretty simple algorithm for that yourself

safe lintel
#

kinda wish this stuff was just taken care of for me

bright sentinel
#

I mean stuff like this isn't even in old physics

#

You'd have to do that yourself as well

#

I can imagine it might come at some point

safe lintel
#

I dont recall this behaviour in physx though?

bright sentinel
#

I've had the behavior happen

vivid copper
#

but the mesh and the physic collider are not the same so modifing mesh would not relsult in a other behaviour does it?

safe lintel
#

honestly that whole marble sample project wouldnt really work if the bouncing was near the same magnitude you get in dots physics

bright sentinel
#

It shouldn't

dull copper
#

artengine πŸ€”
@safe lintel you saw the blog post about this right?

safe lintel
#

yeah, im just surprised because its not really available for the public at hand

dull copper
#

roadmap stream gave impression that they are working on exposing it to regular customers

safe lintel
#

hm my impression from that was the unity implementation was going to be available, but its current state it would stay as is(but id like to be wrong)

#

at given the glacial timeframe things move at, im skeptical of what the talk will feature

dull copper
#

it'll probably just talk about the underlying tech

#

at best they could give some roadmap where they are going with it

formal scaffold
#

Btw, any Idea why the Values of our struct components are written with a capital letter? Only because inside structs you usually write with capital letters? Or is there another reason?

coarse turtle
#

most likely just the MSDN C# conventions where public fields start with a capital letter

vivid copper
#

@safe lintel @warped trail
Havok and welding did it many thanks to you!

opaque ledge
#

wow ml-agents is coming ? its pretty hard to work with but seems rewarding

#

i thought only public properties was starting with capital letter and fields were camelCase πŸ€”

coarse turtle
#

oh @opaque ledge probably haha

#

I actually dont really know myself - as long as you keep it consistent

opaque ledge
#

^^

#

Yeah i think its Unity thingie, thats what they do, such as naming their private variables with "m_"

safe lintel
#

anyone know why you would want to check the fraction for a raycast hit?

craggy orbit
#

iirc, fraction gives a value 0-1. useful for interpolation maybe? maybe proximity checking too

warped trail
#

from docsπŸ€” Lower level ray cast routines against primitives have a slightly different input. They do not compute the surface intersection point explicitly for efficiency reasons. Instead, given a ray of origin - O and displacement (combining direction & distance) - D, they return a hit fraction - f, which can be used later to compute the hit position if needed using O + (D * f)

safe lintel
#

thanks, can you link the page?

warped trail
#

and this from Raycast.cs ```Note that the primitives are considered solid.
Any ray originating from within the primitive will return a hit,
however the hit fraction will be zero, and the hit normal
will be the negation of the ray displacement vector.

fallow mason
#

using Tertle's event system. Hasn't been converted to SystemBase AFAIK, so feeling my way through it. I'm getting a 1-frame lag with this code. Any ideas why?: https://hastebin.com/latajuvafu.cs

hollow sorrel
#

@fallow mason haven't read the rest but are your systems updating out of order? can check their order in entity debugger

fallow mason
#

they very well could be

#

I'll check

hollow sorrel
#

might have to add an [UpdateAfter(typeof(EventProducer))] on your EventConsumer

fallow mason
#

heh yep consumer is before producer. silly mistake.

#

hmm still getting lag

#

nvm I think it had something to do with me creating a reader in the EventProducer. I thought I needed to provide a foreachcount for my writes. got rid of the reader stuff and the lag disappeared.

#

now I have to test multiple event producers and readers to make sure everyone is getting the events they need

#

oh yes, that is working nicely

toxic mural
#

A script inside an assembly definition file out to be able to see a script sitting in /Assets right? I shouldn't need to add any reference to the asmdef?

#

ought*

paper mauve
#

This seem like a pretty common thing to do, but for the life of me, I cannot figure this out. I have 1 entity that is the player that is moving around and a bunch of other entities that are spawning and moving towards a point. How do i best get a reference from the player entity to the following entities (without using collision) ?

wary anchor
#

Had a dream last night that I'd started work on the audio for my game and had to have a factory pattern providing minimal audio source gameobjects to an AudioSystem in ECS. Anyone know if/when audio will be integrated in Dots?

opaque ledge
#

lol

#

There is DSPGraph

#

its pretty low level

south falcon
#

Hello, anyone know where is the source code of EndSimulationEntityCommandBufferSystem

opaque ledge
#

are you trying to create your own command buffer system ?

south falcon
#

yes, want to create a similar one but different timing

opaque ledge
#

create a class that inherits from EntityCommandBuffer

south falcon
#

ThxπŸ˜„

wide fiber
#

How can I cast a ColliderCast with UnityPhysics? There is no example in the documentation

wide fiber
#

πŸ‘

#

So do I have to implement them by myself?

warped trail
#

what do you mean?

wide fiber
#

Is there a function called Physics.SphereCast in Unity?

#

Or do I have to copy/paste the code of the example

warped trail
#

you get or create collider and then physicsWorld.CastCollider with itπŸ˜…

wide fiber
#

So there is no function called for example SphereCast, I have to make the collider and cast it manually.. ok

warped trail
#

new tiny packageπŸ₯³

mint iron
wide fiber
#

How can I get the world and use it in a Job with Burst?

#

It gives me an error that says I can't use references, it's only allowed without burst

warped trail
#

why do you need world in a job? πŸ€”

silver dragon
#

Hm, no changelog for Entities 0.9.1...

opaque ledge
#

0.9.1 released ? πŸ‘€

#

you should look for it in packages folder, changelog in manual wont update immediately

wide fiber
#

why do you need world in a job? πŸ€”
@warped trail I don't need it anymore, I have found another solution

#

I make a grid (at runtime, every 2 seconds for example) for my map (AI pathfinding), to check what nodes are walkable I use a SphereCast for each Node and based on what I hit I can say if it's walkable. The problem is that I have 900 nodes, it spends 1 second to make all the casts (in the editor)

Better solution to find which nodes are walkable? (In future I may add penalty costs also)

amber flicker
#

@silver dragon * Fixed NullReferenceException issue with Singleton access methods in SystemBase. is the only change I think

silver dragon
#

Ah, right, there is a changelog in the packages folder πŸ™‚

#

Yep, it's the only change

opaque ledge
#

Hybrid Renderer's update is simply updated dependincies

south falcon
#

Anyone knows how to declare ReadOnly for temp variable of NativeMultiHashMap?

#

Which is used in parallel foreach of entities

mint iron
wide fiber
#

Ok

south falcon
#

Anyone knows how to access ComponentDataFromEntity<T> in parallel Entities.ForEach?

#

always log error "xxx is not declared [ReadOnly] in a IJobParallelFor job"

opaque ledge
#

you have to do .WithDisableParallelRestriction(yourVariable)

wide fiber
#

If I want to create a lot of entities with the same archetype and I want to change the values of some variables in the components what can I do?
Do I have to make a for and create the entities 1 by 1?

opaque ledge
#

most likely, otherwise batch create and iterate over the returned native array

wide fiber
#

Ok thanks

south falcon
#

Still log error 😞

warped trail
#

maybe try WithReadOnly? πŸ€”

wide fiber
#

@warped trail ok now I need a world in the job. How can I sphere cast inside a Job? I need the world to make the sphere cast (it's the first line of the function)

bright sentinel
#

The new Entities package was purely a hotfix

south falcon
#

maybe try WithReadOnly? πŸ€”
@warped trail Yes, it is working πŸ˜„

silver dragon
warped trail
#

work around with struct is ugly πŸ˜…

bright sentinel
#

I tried this with NetCode in the ghost prediction group, but no dice. Any way to get that to work?

warped trail
#

no luck with what?πŸ€”

bright sentinel
#

Physics queries

warped trail
#

just do queries before or after physicsπŸ€”

#

unless you really want to change something in simulation

bright sentinel
#

Right, but it's not working with the ghost prediction group

#

NetCode is doing some things with physics that make it not work

warped trail
#

have you looked at how they do raycasts in LagCompensation sample?

bright sentinel
#

No πŸ€” Is that in the multiplayer repo?

warped trail
#

yes

bright sentinel
#

I'll have a look

wide fiber
#

@silver dragon it doesn't work, I am using SystemBase, maybe there are some differences.. I will send the code in a few minutes

warped trail
#

@wide fiber look at code i linkedπŸ€”

silver dragon
#

Ah yes, need to be changed a bit for Systembase

bright sentinel
#

@warped trail Hmm, that looks promising. It was pretty close to what I was doing, but not exactly. I'll try it out next week when I have time, thanks

wide fiber
#

@warped trail ok

#

@warped trail basically I need to add those lines of code (the variables, the OnCreate function and the dependencies inside OnUpdate) to every system that needs to access physics?

warped trail
#

yeah, you have to deal with those FinalJobHandle things, when you work with physics because physics use native containers alotπŸ˜•

wide fiber
#

:(
Ok thanks

stone osprey
#

Are your prefabs invisible too when you use dots ?

#

Just tried to open a prefab and its invisible, just the scene shows up

#

This is dots related... would be great if someone could check if they have similar problems

mint iron
#

do you have hybrid renderer package?

stone osprey
#

Yep... but im not using it... does this cause it ?

mint iron
#

if you're using entity prefabs, instanitating them in dots, then it uses hybrid renderer; ive started new proejcts before and forgot to add the package and they were all invisible 😦

stone osprey
#

I mean the prefab mode/view is invisible... not the prefab itself ^^

#

So if you double click on a prefab, its inivisble and shows the scene... if i spawn it in, it renders fine

mint iron
#

oh yeah... its invisible for me too, i have no idea why, it makes me angry.

wide fiber
#

@warped trail It gives me an error (all the systems don't work, their functions aren't called):
Invalid [UpdateAfter] Unity.Entities.EndSimulationEntityCommandBufferSystem ... because it's already restricted to be the last

I have deleted the UpdateAfter but now it gives me dependencies error, I will send the code and the errors in a few seconds if you want

stone osprey
#

@mint iron Yep... its impossible to work with... my whole UI is prefab based and i cant edit anything... i found one single forum post... they said they gonna fix it and its dots related... but i really wanna find a short solution for this

mint iron
#

you can't order a system outside unitys ECB systems within default a group, don't know why they enforce that, its super annoying.

warped trail
#

@wide fiber oh, i made a mistake there, you need EndFramePhysicsSystemπŸ˜…

#

[UpdateAfter(typeof(EndFramePhysicsSystem))]

wide fiber
#

Ok I'll try :)

#

Ok now it seems to be working, thanks

warped trail
#

prefab mode/view works fine in my project, or i don't understand somethingπŸ€”

stone osprey
#

@warped trail What unity version ? ^^ And could you probably post your dots related packages here ?

#

Thats the only post i found about this issue

warped trail
#

i use 2020

wide fiber
#

Ok it works, 900 sphere casts in 0.75 milliseconds, Burst compiler and jobs are awesome

mint iron
#

very nice

warped trail
#

you can try point distance query instead of sphere casts πŸ€”

formal scaffold
#

Hey, whats the difference internally between creating a local var of components or using component.Value over and over again inside ForEach Lambda functions?

opaque ledge
#

probably doesnt matter, but i generally do var

safe lintel
#

well one is making a new variable without basing it on something that exists

opaque ledge
#

I think he is asking because he wants to optimize his caches πŸ‘€

eager jungle
#

hey guys, really trying hard on this one, is anyone able to help?

I'm trying to Instantiate an hybrid object (a gameobject, with its linked entity), from a system. I can't figure out the proper way to do it. Best solution i found so far is to do a simple GameObject.Instantiate(prefab), and let the ConvertToEntity to its stuff, but in that case, there is no way for me to find the linked Entity after my instantiate call... any idea?
ideally i'd like to do something like : InstantiateHybridGameObjectFromEntityPrefab(Entity prefab) : Entity
or if there is no way to do that, I'll use a hashmap to map my gameobject prefabs to my entity prefabs, and use something like : InstantiateHybridGameObjectFromEntityPrefab(GameObject prefab) : Entity

opaque ledge
#

do you know how to convert a prefab to an entity in code ? or rather in authoring component ?

eager jungle
#

yes, creating an entity prefab isn't a problem

opaque ledge
#

you want to do that and stash that returned entity to shared static or to a component, then simply instantiate that entity

eager jungle
#

but that wouldn't instantiate a gameobject, is it?

opaque ledge
#

No, you have to stash the entity that was returned from that convert function

zenith wyvern
#

If you're using HybridComponent it should instantiate the GameObject with it

opaque ledge
#

i am in bed and dinner is soon, so i cant show you a code πŸ˜„

zenith wyvern
eager jungle
#

hmm ill have a look at that thanks

#

HybridComponent, what is it exactly?

#

i mean what are you refering to?

zenith wyvern
#

The article explains it in detail, basically it "attaches" a gameobject of your prefab to your entity

#

So the prefab instance lives and dies with your entity, and gets instantiated alongside it.

opaque ledge
#

if you convert a gameobject prefab to an entity you wont need to do that afaik, it will automatically done for you

eager jungle
#

so you mean, if i then instantiate an entity prefab, the gameobject will be instantiated along with it ? i though i tried it earlier and it wasn't working..

zenith wyvern
#

Were you using conversionSystem.AddHybridComponent?

eager jungle
#

no

#

let me show you quickly,

#

im using IDeclareReferencedPrefabs

#

and then conversionSystem.GetPrimaryEntity to save my entity prefab to a component

opaque ledge
#

yes, check from entity debugger if your entity prefab has "Companion Link" component, that is the responsible for instantiating gameobject and attach it to your entity

#

or at least thats what i heard πŸ˜„

zenith wyvern
#

Yeah I think that should basically do what HybridComponent does internally, like Curly said

#

That's the idea at least

eager jungle
#

doing the way i mentionned earlier using GetPrimaryEntity, my prefab entity does not have a companion Link component

safe lintel
#

im not sure if using hybrid components is the way forward, given what topher alluded to

eager jungle
#

what do you mean?

opaque ledge
#

He said something like, hybrid component was never meant to use directly, it was an internal thing

wide fiber
#

you can try point distance query instead of sphere casts πŸ€”
@warped trail mmh..

eager jungle
#

hmm @opaque ledge @zenith wyvern @safe lintel really trying my best, but i can't figure this out...
My code is extremely simple... my GameObject prefab is referenced like this : referencedPrefabs.AddRange(goPrefab);
In the Convert method of my IConvertGameObjectToEntity, i use conversionSystem.GetPrimaryEntity(goPrefab) to store the prefab onto a Component

The prefab gameObject itself has a ConvertToEntity : Convert and Inject

I really can't find a way to instantiate a linked gameobject+entity pair from a system...
Using EntityManager.Instantiate(prefab); does not create a GameObject
Using GameObject.Instantiate(goPrefab); creates both but I cannot get the Entity back (and its created later anyway, bc of the ConvertToEntity script)

opaque ledge
#

Does the entity prefab you convert has "CompanionLink" component on it ?

#

@eager jungle

eager jungle
#

no, i checked answer is no.

#

i can't event find that component. Where is it?

opaque ledge
#

Entity debugger

eager jungle
#

i mean, i checked in the entity debugger, and the prefab entity does not have that component

opaque ledge
#

your entity has to have CompanionLink component on it, Unity should have put one

#

does your gameobject have any disabled scripts or components ?

eager jungle
#

no, its a simple cube, ConvertToEntity enabled, with conversion mode = ConvertAndInjectGameObject

#
  • a simple component
opaque ledge
#

Can you add a dummy script and see if your entity has a CompanionLink on it ?

eager jungle
#

i can't even compile with that. Is is possible that i have set UNITY_DISABLE_MANAGED_COMPONENTS without knowing it (or its by default)?

opaque ledge
#

its definitely not added by default

#

but perhaps check your project settings if its set ?

eager jungle
#

pretty sure its not

opaque ledge
#

it should be in Project Settings->Player

#

well, not being able to compile shows there is something else going on

eager jungle
#

ill double check with a sample code as well, give me a sec

#

there are not disabled, for sure

opaque ledge
#

what does compile error show πŸ‘€

eager jungle
#

testing now

#

EntityManager.GetComponentData<CompanionLink>(prefab)

#

error CS0122: 'CompanionLink' is inaccessible due to its protection level

opaque ledge
#

oh no no no, you dont want to add CompanionLink your own, Unity will add it automatically when you convert your gameobject

eager jungle
#

im not adding it myself

#

you asked me to check from code if it was added, that's what i was trying to do

#

and its not showing in entity debugger

opaque ledge
#

also i believe that i understand the problem, one time i heard that convert and inject mode doesnt work if you are converting it at runtime(meaning thru a authoring component).

#

I actually encountered this problem when i was trying to do the same for my world UI, but couldnt make it work

#

what you can do is manually adding your gameobject to your entity thru systems.

#

For example, you could have "AddSomething" component in your entity, then you simply query(on main thread) for it, do your processing and add managed component through entitymanager.AddComponentObject(entity) and then remove "AddSomething" component

eager jungle
#

just want to add something: having an instance of the prefab directly in the scene, the converted entity does not have a CompanionLink either

opaque ledge
#

well that does sound weird 😦 That happened to me once because some scripts in my gameobject were disabled, but once i enabled them, CompanionLink was added again

eager jungle
#

how what you're mentionning above would help spawning a gameobject with a entity prefab btw?

#

someone must know about this lol i can't believe no one had this problem before

mint iron
#

I'd say very few people if any are using HybridComponents, i dont even know if they intend to support it going forward or if it was something they were just experimenting with. So if its hard to get info, that's probably why.

eager jungle
#

@mint iron nice you mentionned it, i just tried that a minute ago, and indeed the companion link is added, but that doesn't make the gameobject spawn along with the entity anyway ^^

#

I'd say very few people if any are using HybridComponents, i dont even know if they intend to support it going forward or if it was something they were just experimenting with. So if its hard to get info, that's probably why.
How are you guys dealing with animations and unsupported features? or physics if you want anything production ready???

safe lintel
#

my conversation with topher a while ago kinda gave me the impression that hybrid components were really meant for their own use with subscenes like lights and cameras(ie longterm outlook for them is unknown), of course things may change but the samples mentions it shouldnt really be used outside of experimenting. that said I could totally be misinterpreting things but id just caution against doing anything significant with them

eager jungle
#

i mean, my problem seems very simple.... im pretty sure anyone that wants to use some kind of hybrid will have to deal with this

safe lintel
#

for animation im just going with using monobehaviours via AddComponentObject and managing their lifetime my self. mostly not destroying or creating any unityengine thing outside of start/awake

eager jungle
#

but for that you need to Inject Gameobject right?

safe lintel
#

also some other things like particles. yeah need to use that with inject

eager jungle
#

how would you spawn such an object from a system ??? bc basically thats what im trying to do

safe lintel
#

I pool my gameobjects into a list that I need to "spawn" at the start of the game, and then just get them from the list as needed from a system

eager jungle
#

i mean, what if you want to spawn one at a random time?

safe lintel
#

i think you can technically instantiate a gameobject that has IConvertGameObjectToEntity(god I hate typing that out) and the conversion is called while playing but it might cause your game to hitch because conversion should technically take place at the start and conversion systems are not necessarily jobified or bursted in any way

eager jungle
#

that does work for sure, but in my case i need to retrieve the linked entity for later use in my system

#

that's my problem actually

safe lintel
#

conversion should just give you an entity along when you use it via the interface

#

I mean you could just make your gameobject via Instantiate and then use EntityManager.Create to make an entity and then manually link them from a system

#

unless you are talking specifically about LinkedEntityGroup ?

eager jungle
#

i don't think so, there no hierarchy

#

i just need the gameobject to be instantiated at the same time as the entity... and get the entity right away, not next frame => reason why GameObject.Instantiate is impractical

#

Even though Im very surprised there is no simple answer to that (like a utility function), I could do with any manual workaround if you have one.
I'm really really surprised no one needs that. It seems like any networked game for example , instantiating hybrid gameobjects at runtime would need that. Or i really missed something important.

coarse turtle
#

there used to be a utility function but they changed how the conversion pipeline works

#

on the surface it does the same behaviour you'd see as prior - but iirc they removed a few static utility functions which converted gameObjects

safe lintel
#

ok so i see what you mean by a frame lag of regular instantiate

eager jungle
#

im having that in a system for a networked game, i want to spawn something and save the linked entity into a hashmap along with its networked id. But i can't find a way to find the Entity from the GameObject itself either (in case im using GameObject.Instantiate and let the gameobject self register later for example)

coarse turtle
#

well a weird work around is to have a "free list" of entities and gameobjects and when you need one instantiated you simply link the two together - but if you a massive volume of objects - you'd be pushing the load up front and try to predict how much you would need later down the line

eager jungle
#

you mean like a pool

coarse turtle
#

yea pretty much

eager jungle
#

that's a good idea, but still, super weird we can't do that... the basic way

coarse turtle
#

which entity version is this?

#

I might have a workaround - i haven't checked my testing suite with the latest entity version tho

eager jungle
#

0.8.0

gusty comet
#

People keep asking how to reference an individual entity from systems, and the only answer ever provided is, "Don't." Even though numerous API calls require an individual entity reference from a system. So, I'll answer the question.

#

Create a progenitor entity from which others are cloned. When your system starts, it's the. only. one. That's important, because you can filter for it and know you only get one.

#

Cache that progenitor.

#

Then every time you clone it, rename the clone with its hash.

wide fiber
#

Can I hide some entities in the EntityDebugger? I spawn 900 nodes, I can't find other entities easily

gusty comet
#

Look for the script you want on the left pane, and then you'll find a list of component combinations using it on the far right pane. Find the combo that represents the chunk you want, and only it will show in the middle pane when you select it.

wide fiber
#

I could make a world where there are only the nodes, but yeah

opaque ledge
#

there is a filter, press on it white ones will show the entities that has that component, red ones will show the entities without that component

wide fiber
#

Ok thanks

opaque ledge
#

i do red "PreviousParent" component, that disables every child

gusty comet
#

Your nodes are all in the same chunk, right?

wide fiber
#

How can I check the chunks?

obtuse swallow
#

Is there a way to get a ref to the EntityManager singleton from some MonoBehaviour?

wide fiber
#

They have all the same components, but I don't know if they are too big

gusty comet
#

1 sec koward. It's DefaultWorldSomethingOrAnother. I'm spoiled by my IDE's autocomplete

opaque ledge
#

there is no entity manager singleton, every world has an entity manager, you can do DefaultInitializitonWorld.EntityManager

wide fiber
#

Your nodes are all in the same chunk, right?
@gusty comet yes

gusty comet
#

You should be able to select that chunk to only see those entities

wide fiber
#

I am using filters, it works well (I want to hide only the nodes, I can't do that with chunks)

gusty comet
#

"EntityManager singleton" each world has only one EntityManager, so they're all by definition a singleton

#

Within their world anyway

#

EntityManager eMan = World.DefaultGameObjectInjectionWorld.EntityManager;

obtuse swallow
#

Alright, thanks. I might need to read about the concept of worlds to ensure I'm not doing something weird here.

#

Are systems registered somewhere, or placed in a scene perhaps? How does the engine know they exist? Reflection on subclasses of SystemBase?

bright sentinel
#

I think it gathers all the systems that inherits from ComponentSystemBase, maybe through reflection, but not sure. They're then stored with the world, so all worlds doesn't automatically all systems

opaque ledge
#

Yes reflection

#

You can disable auto creating by using DisableAutoCreation, you can also disable creation of defaul world as well

wide fiber
#

If I put the 'in' (read-only) modifier to some parameters in a function will I get a performance improvement? (Called from a job)

opaque ledge
#

yes, Unity will know you are reading it so it will know your job will not create any race condition for that component

bright sentinel
#

Not by itself, but will allow the job system to parallelize more stuff - so the more complex your project is, the more it will utilize multiple cores

obtuse swallow
#

Is SystemGroup (Update, Initialization) set by reflection on what methods you override in your system?

wide fiber
#

Ok thanks

opaque ledge
#

Unity uses reflection to find your systems and generates code from your code in OnUpdate

wide fiber
#

Do I have to put base.OnCreate() in a SystemBase override OnCreate?

opaque ledge
#

i didnt see any change, so i simply dont

wide fiber
#

Ok

mint iron
#

yep the base is an empty method.

obtuse swallow
#

Do you have to start from a converted gameobject at the moment to create an entity for the player's components? If not when&where should that entity be created?

bright sentinel
#

You don't have to, but it's probably the best solution right now, so you can edit variables directly in the editor

opaque escarp
#

it's seems like when I instantiate entities one at a time from a prefab in a ComponentSystem using PostUpdateCommands, they're all put in their own chunks instead of being combined. But when I manually create the things and attach a ConvertToEntity script to them, they're properly put into the same chunks. Is there some gotcha I'm unaware of with chunks, or is that a bug?

#

looks like if I instantiate them in groups of 10 each frame instead of 1, each group of ten is in its own chunk...

warped trail
#

maybe show some code😏

#

and use systembase instead of componentsystemπŸ€”

mint iron
#

if they have exactly the same components they should be being packed into the same archetypes' chunks. Except if the chunks are locked, or if you use a SharedComponentData, then chunks must share the same value of SCD components.

opaque escarp
#

how can you tell if a chunk is locked or not?

mint iron
#

i think right now only a user can lock them by calling EntityManager.LockChunk()

opaque escarp
#

I'll try systembase, though I don't see how that would change how chunks are handled

mint iron
#

yeah, it might just be the way it works right now....

#

i usually use the NativeArray overload which will make full chunks properly.

opaque escarp
#

looks like PostUpdateCommands is not available in SystemBase, do I have to get a command buffer manually?

#

yea I've used nativearrays in the past and never had issues

mint iron
#

i think so yeah

opaque escarp
#

thanks, I'll give it a shot

mint iron
#

for create at least, they have fancy new methods for Get/Set/Has Component.

opaque escarp
#

is SystemBase supposed to replace ComponentSystem?

warped trail
#

yes

#

it will replace ComponentSystem and JobComponentSystem

#

one system to rule them all😏

opaque escarp
#

well interestingly switching from ComponentSystem to SystemBase and using the different command buffer made it go from one entity per chunk to two, in addition to making the chunk archetypes thing in the entity debugger go wild, will post if I make more progress on identifying the issue

#

it looks like instantiating them through the SystemBase somehow adds a LinkedEntityGroup component, could that be the cause?

#

I found the issue. I had a sytem that would go through and remove components after instantiation, and it looks like after the removal of the components it would not put the entity into a like-chunk

#

seems like a bug, but it's using old API stuff. I'll submit a report if after making it use the newer stuff it still happens

zenith wyvern
#

Huh

As many of you rightfully mentioned, you like to work with systems and queries, and we understand. ECS queries will be an essential part of the Unity Editor experience in the future. We've come to assess that they go far beyond the needs of Visual Scripting alone. Once we have finalized an approach that will enable both artists and developers to harness the power of queries throughout the editor at a Unity-wide level, they will be re-introduced to Visual Scripting. ​

From the Visual Scripting thread. What could it mean

#

Not sure how the conversion system fits with that description

warped trail
#

like this? πŸ˜… The ECS workflow is more and more based on authoring gameobjects, not writing jobs by hand and relying on under the hood magic. We're going the same way..

zenith wyvern
#

Like serializable queries you could set from an inspector maybe

hollow sorrel
#

oh man that thread is a dumpster fire

safe lintel
#

i dont understand that at all?

opaque escarp
#

happen to have a link to the revelant thread?

safe lintel
opaque escarp
#

oh lawd

zenith wyvern
#

Ehh don't be too hard on them, based on that last post there's obviously some big changes to the editor itself going on behind the scenes that they can't talk about yet

warped trail
#

from tens of thousands of objects to switch that is opening a door πŸ˜…

gusty comet
#

Say, is there an example somewhere of how to use EntityCommandBuffer to instantiate clones of an existing entity? Or must that always be done on the main thread?

coarse turtle
#

when would be a good time to set the max # of threads for the job system? I imagine when the scene loads or at a world creation standpoint, anyone have any thoughts? πŸ€”

gusty comet
#

Frustration is mounting. A week and a half with DOTS in Unity, and so far exactly nothing has been intuitive.

zenith wyvern
gusty comet
#

Much appreciated, Sark

zenith wyvern
#

Say, is there an example somewhere of how to use EntityCommandBuffer to instantiate clones of an existing entity? Or must that always be done on the main thread?
@gusty comet

And just to be clear EntityCommandBuffers are played back on the main thread, but you can definitely queue CommandBuffer.Instantiate commands inside a job

mint iron
#

when would be a good time to set the max # of threads for the job system? is this new? i thought it was hardcoded at 128?

coarse turtle
#

There's a JobUility.JobWorkerCount property

mint iron
#

if thats an entity should be tested against Entity.Null, and ECB entities returned from create/instantiate will be invalid until playback.

gusty comet
#

I just saw the mistake, so cleared my noise.

mint iron
#

public const int MaxJobThreadCount = 128; πŸ™‚

coarse turtle
mint iron
#

huh...

coarse turtle
#

well that property certainly works - you can limit it down to 1 worker thread πŸ€”

mint iron
#

well you learn something every day don't you.

dull copper
#

yeah, I've used that for a while for quick testing

#

the downside of that setter is that it doesn't actually remove extra workers from profiler

#

for that to happen you have to launch the editor with extra command line parameter that limits the worker amount

coarse turtle
#

o - good to know

dull copper
#

I also don't think you set the worker amount to bigger than your own computers hw threadcount -1

#

so with say 8 hw threads, you can get max 7 workers

#

I can test this quickly but I think it was mentioned somewhere that it's capped by your hw

#

so I can confirm, tried to set 30 workers from commandline and Worker 22 was last one listed on profiler (so 23 workers total since they start from 0) on 24 hw thread machine

#

@mint iron ^

#

128 is just the max capacity

#

basically the computer you run it on will determine the actual worker amount unless you force it to something lesser

#

doesn't work the other way around

#

also, apparently 64 hw threads is actual capacity today

#

at least I do remember someone reporting issues with this stuff with 64core threadripper

#

had to turn off SMT for things to work

mint iron
#

in my case i needed the max when making a fixed threaded container so each thread possible could have a place to write data; but i only knew about the const not the other one.

dull copper
#

if it's only for your own use, then sure

sudden comet
#

hello guy .. Iβ€―have something that looks like a bug but β€―Iβ€―am not sure .. Iβ€―found a workaround but it does not feels right

        {
            Dictionary<ResourceType, int> resourceCounts = new Dictionary<ResourceType, int>();
            
            entities.WithNone<RecipeElementComponent>().ForEach((ref ResourceComponent resourceComponent, ref QuantityComponent quantityComponent) =>
            {
                if (!resourceCounts.ContainsKey(resourceComponent._resourceType))
                {
                    resourceCounts.Add(resourceComponent._resourceType, 0);
                }

                resourceCounts[resourceComponent._resourceType] += quantityComponent._resourceCount;
            });
            
            entities.WithNone</*RecipeElementComponent, */QuantityComponent>().ForEach((ref ResourceComponent resourceComponent) =>
            {
                if (!resourceCounts.ContainsKey(resourceComponent._resourceType))
                {
                    resourceCounts.Add(resourceComponent._resourceType, 0);
                }

                resourceCounts[resourceComponent._resourceType] += 1;
            });
            
            return resourceCounts;
        }```
#

Why if Iβ€―uncomment RecipeElementComponent it says Iβ€―have a duplicate filter in my query ? any mean to reset the QueryBuilder? is it intended?

#

I don’t really like making a query taking what the previous did in account :/

amber flicker
#

Just wondering.. if ebcs are now fully bursted, is there a point at which they become faster to use than e.g. a bunch of SetComponent or AddComponent calls?
My understanding is that after every structural change there's work done re chunks & layout. Does it make better sense to do this work after you've finished modifying the structure of a bunch of entities? Wondering if ebc playback allows for/takes advantage of that?

cosmic sentinel
#

How do I apply multiple adjustments in one iteration of EntityCommandBuffer? Told to use entityInQueryIndex as jobIndex, but if I want to do multiple changes in one iteration of Entities.ForEach (thus using the same entityInQueryIndex) it fails. Do I have to create multiple buffers?

opaque ledge
#

why would it fail ?

#

what do you mean by 'fail' exactly ? does it give you any error @cosmic sentinel

cosmic sentinel
#

I must be going insane. I got errors in the log (before I did a workaround). Tried to go back to my old code but now I can't make it fail again.

#

Code pretty much does:

                    if (health.Value <= 0.0f)
                    {
                        ecb.RemoveComponent<Target>(entityInQueryIndex, entity);
                    }

                    ecb.SetComponent<Health>(entityInQueryIndex, target.Entity, health);
#

obviously affecting two different entities. but the target.Entity's health wouldn't update

#

but for some reason it works now. very confusing

#

my workaround was just to use target.Entity.Index instead of entityInQueryIndex

mystic mountain
#

Try posting full code, and errors : )

cosmic sentinel
#

I'll try to reproduce the error

opaque ledge
#

whole reason to use entityInQueryIndex is being able to use parallel command buffer commands playback in deterministic way, so what you are doing is correct πŸ˜„

vagrant surge
#

the visual studio drop8 thread is pretty fun to watch. Very heated

fallow mason
#

I just cringe any time I get to another manifesto. There are good points being made poorly.

fallow mason
#

Anyone know of any decent UI solutions for DOTS being worked on? I saw one on the forum, but I'm not sure if it's maintained anymore.

stone osprey
#

Quick question... is there a way to call "GetComponent" within a Entities.Foreach() ?

mint iron
#

with SystemBase you can just call GetComponent<T>(Entity), i believe if its bursted the codegen swaps it out with GetComponentDataFromEntity

opaque ledge
#

@fallow mason go hybrid πŸ˜„

fallow mason
#

hah trying to avoid that

#

targetting webgl and eventually I plan on moving development to tiny, so keeping it pure will give me the best chance of porting without issue

mint iron
#

eventually we'll probably see something with UIElements, that'll be nice. I've been meaning to look into if they've exposed any of the native goodies so we could control it from dots. But its on my neverending list of awesome things to do.

fallow mason
#

yeah, I was thinking of getting familiar with that workflow since I've heard that will be the DOTS UI system of choice

warped trail
#

in a year or two πŸ˜…

fallow mason
#

in a year or two we might have a nice shiny new UI system to look forward to 😏

mint iron
#

i really liked all the stuff they showed in Copenhagen last year for UIElements, the editor, the perf demos, i have high hopes.

fallow mason
#

UIElements my comfort zone as an (also) web dev. But honestly, I don't hate UGUI like some. I'm just glad I rarely have to write IMGUI anymore.

amber flicker
#

UI Toolkit's really good but it's the opposite of dod right now.. hard to see it morphing into something but I guess it will eventually

stone osprey
#

Ok, another question... Entities.ForEach(AnimationComponent ac => { ac.Animator = getAnimator(); }); AnimationComponent is shared... getAnimator delivers a Object which is not null... in a ForEach loop after this one here ac.Animator is still null... any idea why ?

opaque ledge
#

I have a system that crashes editor(it gives invalid IL code a few times before crash) even when burst is disabled and yet it works on standalone build

#

now i have to spend days to figure this out πŸ˜’

stone osprey
#

PostUpdateCommands is still a thing ?

opaque ledge
#

no

stone osprey
#

What to use instead ?

opaque ledge
#
        private BeginSimulationEntityCommandBufferSystem endSim;

        protected override void OnCreate()
        {
            endSim = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BeginSimulationEntityCommandBufferSystem>();
        }
#

and in OnUpdate

var commandBuffer = endSim.CreateCommandBuffer().ToConcurrent();
#

then you can use that commandBuffer for your structral changes

#

if you only do Schedule only do endSim.CreateCommandBuffer(), if you do ScheduleParallel you do endSim.CreateCommandBuffer().ToConcurrent(); and in your ForEach you have to do "int entityInQueryIndex" for job index parameter of your command buffer

#

in OnUpdate after your ForEach, you have to do endSim.AddJobHandleForProducer(Dependency);

stone osprey
#

Sooo and how do i do structural changes on entities ? That new buffer looks complicated

warped trail
#

@stone osprey ```cs
using Unity.Entities;
public class YourSystem : SystemBase
{
protected override void OnUpdate()
{
var PostUpdateCommands = new EntityCommandBuffer(Allocator.TempJob);

    Entities.ForEach((Entity e, in YourComponent data) =>
    {
        //PostUpdateCommands.SetComponent();
    }).Run();

    PostUpdateCommands.Playback(EntityManager);
    PostUpdateCommands.Dispose();
}

}```

#

but this will create sync pointπŸ˜…

opaque ledge
#

uuh please dont do that πŸ˜„

dull copper
amber flicker
#

also fyi DOTS Editor update came out yesterday - nothing new but makes it compatible with entities 0.9

wide fiber
#

If I have a query and I execute it multiple times will I get always the components in the same order?

#

In the native array

amber flicker
#

I believe so - unless there are any structural changes between the two. Otherwise it wouldn't be derministic I think. That said, if you're multi-threaded I wouldn't expect it guarantees that the chunks operated on by each worker are the same. (Also happy to be corrected if I'm wrong about any of this)

wide fiber
#

Ok

stone osprey
#

Is .setSharedComponentData(entity, struct) valid for updating shared components ?

#

The first job is used to play a "run" animation... it simply sets that data set... the second job plays the animation... the problem here :

#

The first job does not update the struct correctly...

#

A new value is never getting set

wide fiber
amber flicker
#

math.slerp(from, to, 0->1)

#

is one way

wide fiber
#

Ok ty

#

In an Entities.Foreach() how can I put an "optional" component? If the entity has that component I want to read it, if not I want to do a thing

#

I could use inside the Foreach an entityManager.getComponentData but it won't allow me to use burst (IIRC)

opaque ledge
#

You cant

wide fiber
#

Ok

stone osprey
#

Well i fixed this issue... looks like only one single "SetSharedComponentData" is allowed in each SystemBase... i splitted my AnimatorComponent into two... one for the data set ( i component ) one for the unity reference...

#

Oh... is there an inbuild support for component dependency ? What should we do if one component requires another ?

safe lintel
#

yes you can, use ComponentDataFromEntity @wide fiber

#

might even be able to use HasComponent, havent really experimented with that much and if its burst compatible

amber flicker
#

yup if using SystemBase just HasComponent<>, GetComponent<> & SetComponent<> automatically do CDFE behind the scenes

wide fiber
#

@safe lintel I don't think it's allowed by the burst compiler

opaque ledge
#

it IS burst compatiable, you have to use SystemBase to be able to use it

#

What Timboc said basically

wide fiber
#

Ok

mint iron
#

thought of the day: This SystemBase method should have been replaced by codegen

wide fiber
#

@opaque ledge Some days ago I tested GetBufferFromEntity and it wasn't burst compatible, the other functions are compatible? (Now I don't have a pc)

safe lintel
#

GetBufferFromEntity is burst compatible

opaque ledge
#

you have to do GetBufferFromEntity and GetComponentDataFromEntity inside OnUpdate, and not inside of ForEach

#

@wide fiber

wide fiber
#

Ah ok, I need it in the Foreach (sorry for the "bad explanation")

opaque ledge
#

you have to do that in for each, that will return an 'array', you can use that array to access any entity's components, simply access it by indexing, like bufferFromEntity[myEntity]

#

@wide fiber

mint iron
wide fiber
mint iron
#

what does the error say

wide fiber
#

Entities.Foreach Lambda expression invokes 'GetComponentDataFromEntity' on a ComponentSystemBase which is a reference type. This is only allowed with .WithoutBurst() and .Run()

#

(I am inheriting SystemBase)

opaque ledge
#

you have to do GetComponentDataFromEntity OUTSIDE of ForEach and inside of OnUpdate

var layerDatas = GetComponentDataFromEntity<LayerData>(true);
Entities.ForEach((ref PathNodeData pathNodeData) =>
{
    var layer = layerDatas [entity];
})
.WithReadOnly(layerDatas)
.ScheduleParallel();
wide fiber
#

Ok thanks

opaque ledge
#

Or since you are doing it inside SystemBase you can also do

Entities.ForEach((ref PathNodeData pathNodeData) =>
{
    var layer = GetComponent<LayerData>(entity);
}).ScheduleParallel();
wide fiber
#

πŸ‘ πŸ˜€

opaque ledge
#

Gl^^

safe lintel
#

ah nice one of the latest packages shows what monobehaviours are attached to your entity

wide fiber
#

@safe lintel which package? Entities?

safe lintel
#

i dont know, I just updated entities, and dots editor within the last day or two and one of those things has the slightly improved entity debugger, guessing entities

wide fiber
#

Ok

gusty comet
#

Is there an example anywhere of how to use EntityCommandBuffer.Concurrent to generate parallel processing, now that practically everything in the documentation is marked obsolete?

#

I can't find an example anywhere using just IJobChunk or Entities.ForEach

gusty comet
#

Thank you, and sorry. The official Github examples aren't clearly enough labelled. That's a LOT of code altogether to read and try to find what's actually needed. By the time I find it, I wouldn't remember what I was looking for.

#

What we really need is a community wiki, so we can maintain documentation together.

warped trail
#

default documentation is pretty goodπŸ€·β€β™‚οΈ

warped trail
#

there is View latest versionπŸ˜…

gusty comet
#

I suck

gusty comet
#

I may be getting too old for this. Almost 40, and the people in my life wouldn't let me focus until now

#

Guess they got tired of borderline poverty after a decade and a half of telling them I could do better if they'd let me

gusty comet
#

Thank you, drUiD. Unity has the best developer community I've ever witnessed, and it's immensely appreciated.

gusty comet
#

Still going nuts though. 15FPS with enormous spikes in GPU wait with only 10k vertices (2501 quads) in the scene, 2500 of them with the same rendermesh data, instanced materials using the color property with no texture, and those same 2500 rotated out of view of the camera. Lower the resolution, and FPS picks up, but I don't see how this should even be happening in the first place. People render millions of entities with no problem!

#

I thought maybe it was the way I instantiated them, so that's why I went over that. But with that eliminated, I'm totally out of guesses.

mint iron
#

if you're seeing this in the editor, it may not accurately reflect the real performance; check if it improves with burst on, safety off, job debugger off, leak detection off. Even then, there's a lot of debugging code that still runs in the editor, like live-link stuff for syncing sub-scenes that take a couple of ms even when doing nothing.

#

Also, not sure if you're aware but async compliation of burst means that it may take a while for it to hot-swap out the slow-ass c# functions to the burst ptrs. So you may think its in burst when its actually not. Only way around that is to enable syncronous compliation and then wait for ages when you hit play.

gusty comet
#

Player loop is reading 2.3 ms, so that's about 43fps, with Burst Compile on, all safety stuff turned off, and jobs turned on. Editor loop is shadowing the rendering spikes on the performance graph, so that may be it. Going to go read up to verify synchronous compilation. "Loading, please wait..." is always better than "Damn lag!"

#

That 43 is weird still though. With all but one quad behind the camera, they should be culled completely. And on a 1080ti, it should take way more than that.

mint iron
#

im not versed on it but ive seen comments in this channel before about culling that would make me believe hybridrenderer v1 is not culling at all.

gusty comet
#

I'm using V2. But in HDRP, so that may be the issue.

#

Thing is, even without culling, this isn't right. It's like it isn't batching

#

I'm not sure how to confirm that it is, aside from going over all the instructions

#

Trying to get URP to render now (copied scripts to a new project), to test if it's HDRP

low tangle
#

are you on the latest unity beta as well?

#

it only works on whatever that is

#

Editor loop is shadowing the rendering spikes on the performance graph,

#

ah you mean on those frame spikes the editor loop is the excessively large part?

gusty comet
#

Yeah, but 2.3ms on player loop still comes out to about 43fps on that loop alone

#

I'm using 2020.1.05b

#

On UDP, seeing the same performance loss, without it even rendering the quads visibly

#

Just found the culprit!

#
        if
        (
            camRot != Camera.main.transform.rotation ||
            camPos != Camera.main.transform.position
        )
        {
            FaceCam();

            camRot = Camera.main.transform.rotation;
            camPos = Camera.main.transform.position;
        }
#

Without the camera moving. So, it's calls to check camera position (to keep quads pointed at the camera)

#

Comment that out, and it's back to normal

low tangle
#

oh very nice!

#

always make sure you scan over the entity debugger and profiler to check your job times

#

make sure you didn't spinwait the main for a long ass time and what not

gusty comet
#

I was comparing float3 to Vector3, so the test was always false. Turns out moving 2501 entities every frame isn't performant

#

Or I'm moving them wrong

warped trail
#

just show the code 😏

gusty comet
#

I haven't looked over this since I learned a little more about parallel jobs earlier

    [BurstCompile]
    public struct FaceCamera : IJobChunk
    {
        [NativeDisableParallelForRestriction]
        public ArchetypeChunkComponentType<Translation> translations;

        [NativeDisableParallelForRestriction]
        public ArchetypeChunkComponentType<Rotation> rotations;

        public ArchetypeChunkComponentType<QuadSprite> qSprites;

        public Vector3 camPos;
        public Vector3 camFor;
        public Vector3 camUp;

        public Quaternion camRot;

        public void Execute(ArchetypeChunk chunk, int chunkIndex, int entityIndex)
        {

            NativeArray<Translation> translation
                = chunk.GetNativeArray<Translation>(translations);

            NativeArray<Rotation> rotation
                = chunk.GetNativeArray<Rotation>(rotations);

            NativeArray<QuadSprite> flags
                = chunk.GetNativeArray<QuadSprite>(qSprites);

            for(int i = 0; i < translation.Length; i++)
            {
                rotation[i] = new Rotation()
                {
                    Value = (flags[i].reversed) 
                          ? (camRot * Quaternion.AngleAxis(180.0f,camUp))
                          : (camRot)
                };

                translation[i] = new Translation()
                {
                    Value = new Unity.Mathematics.float3
                    (
                        camPos.x + camFor.x,
                        camPos.y + camFor.y,
                        camPos.z + camFor.z
                    )
                };
            }
        }
    }
#

But that's where the transforms are changed.

warped trail
#

you can use ForEach for thisπŸ˜…

gusty comet
#

Yep. Setting that up now

warped trail
#

and use mathematics instead of Vector and QuaternionπŸ€”

stiff skiff
#

Why are you calculating the same rotation and translation, every time, for every entity in the chunk?

#

Or am I missing something here?

gusty comet
#

Each entity has its own translation and rotation, and they're all being positioned relative to the camera.

#

These will be UI rectangles at some point in the future.

#

And they won't all be in the same chunk. Eventually, they'll have different textures and tags to match, for different UI elements.

gusty comet
#

@stiff skiff Saw what you meant right after I said that, but anyway

#

Just went ahead and fixed it

halcyon bay
#

aye guys, how stable is the implementation of ECS atm?

#

I've had 1 crash when playing around with large numbers of entities but I'm just curious if I can depend on it when I actually bring it into my game

spiral nacelle
#

its still in preview not close to stable

#

@halcyon bay

#

I wouldnt touch it with a 10ft pole myself... the API changes as you're doing stuff does not help dev

#

your code today might not work in the next version

halcyon bay
#

well obviously, but is it not worth using at all

spiral nacelle
#

only if you dont plan on releasing anything

#

Β―_(ツ)_/Β―

halcyon bay
#

yeah I guess that's one way to put it

#

oof

#

I was getting excited about this

spiral nacelle
#

:\

halcyon bay
#

Well does anyone know how close they are to a stable build?

hollow sorrel
#

well obviously, but is it not worth using at all
@halcyon bay
core is pretty stable in terms of crashes/bugs, but wouldn't trust any of the side packages yet such as networking etc
so biggest downside is that you need to reinvent the wheel for a lot of things

halcyon bay
#

ok fair enough

#

I'm trying to make a factory game similar to factorio so I figured I'd use it for the items that go on belts and what not

#

but I came up with a system that won't be too intensive for the belts themselves and machines

cosmic sentinel
#

Is there a way to make a query that excludes components (similar to Entites.WithNone, but for queries)?

bright sentinel
#

@cosmic sentinel You can make a new EntityQueryDesc which supports None

#

Even though it's old, it should still work

cosmic sentinel
#

@bright sentinel thanks

low tangle
#

the core ecs has been stable pretty much since it came out, its just the conversion and high level packages that have been in major flux. theres two networking packages, unity transport and unity networking. transport is just a simple udp library that works inside of jobs / ecs but layered on top of that is networking, which is the high level ghost / replication - fps world state type of server system

#

and that is in active development

#

I shipped my vr networked sandbox game on full ecs and unity transport a few months back and have no issues with the core stuff being stable. other than some lost performance and stuff from job scheduling bugs etc. but that stuff has been fixed over time. it never really was a problem for a real game anyways because of the sync points and mono land shit you have to deal with anyways

#

been working on something you guys might be interested in, but not quite ready to make it public.
@vagrant surge
been working on a ECS framework for a ultra constrained system, that has almost no ram at all. basically benchmarking the framework/pattern

#

did it mainly to write my own ecs framework, but then I had some interesting ideas to apply it to a memory and cpu constrained system to see how well it can speed up a single core machine where I have direct control over the cpu 'cache'

cosmic sentinel
#

Is there a way to convert a query's component to a entity-component NativeHashMap?
Currently I got stuff like:

NativeArray<Translation> positions = query.ToComponentDataArray<Translation>(Allocator.Temp);

But then in the Entities.ForEach I have to do a linear search for every entity:

Entities.ForEach((Entity entity, int entityInQueryIndex, in Target target, in Translation translation) =>
{
    for (int i = 0; i < entities.Length; ++i)
    {
        if (entities[i] == target.Entity)
        {
            // positions[i]...

Do I have to construct my own hash map?

low tangle
#

theres NativeHashMap<V,K>

cosmic sentinel
#

yeah, I know that. but can I get one pre-made or do I have to generate my own?

low tangle
#

and you usually will avoid ToComponentDataArray

#

you have to generate your own, but thats like 3 lines of lambda

#

let me grab a example

cosmic sentinel
#

Thanks

low tangle
#

this is the older style ForEach syntax in a deprecated ComponentSystem

#

I'll see if I can find a systembase one

cosmic sentinel
#

yeah, I use systembase, but I think it will be fairly close πŸ™‚

low tangle
#

bit easier to write

#

constructed at the top, very bottom most line is being used

#

this is a single thread usage, but native hash maps contain a parallel writer

#

better one

#
NativeHashMap<int, Entity> PlayerLookup = new NativeHashMap<int, Entity>(playerQuery.CalculateEntityCount(), Allocator.TempJob);
            var writer = PlayerLookup.AsParallelWriter();
            Entities
                .WithStoreEntityQueryInField(ref playerQuery)
                .WithAll<PlayerEntity, ServerOnly>()
                .ForEach((Entity ent, ref PlayerID id) =>
                {
                    writer.TryAdd(id.Value, ent);
                }).Schedule(inputDeps).Complete();

            var allPlayers = PlayerLookup.GetValueArray(Allocator.TempJob);
#

I use this pattern a lot, and have been thinking about building a way of auto doing it using a bit of reflection to say which field I want to use as the key in the map, and what query

#

something like a filter method

CreateHashmapFromQuery(query, (e, id)->(return (id.Value, ent);));```
roughly
cosmic sentinel
#

is there any point doing a parallel writer if you're not doing parallel scheduling?

#

seems like you'll just introduce locks

low tangle
#

it does internally yeah

#

it did speed up one of my hashes on a system that was actually full jobs

#

I do it out of habit, so that if theres a chance it speeds it up, it will

#

if not its nbd

#

writing it single is the same thing, but you just dont create that writer inbetween

#

same syntax

#

.Run() instead of schedule

cosmic sentinel
#

yeah that's what I mean. in your example you write in the main thread but use locks

low tangle
#

its not main thread, its just waiting till complete

#

that system is being ported to a full job usage

cosmic sentinel
#

still single threaded job

low tangle
#

but the foreach that runs right after has to run on main thread at the moment

#

it isn't a single threaded job if the number of entities is high enough

gusty comet
#

Working on the next issue, I find something weird. With 2500 entities (quads), frame debugger shows two SRP batcher calls: one with 4 vertices and 6 indices (the first quad), and one with 8 vertices and 12 indices (after the first is instantiated 2500 times). That's expected. But then, if I increase the number of instances, around 5000 this shoots up to 20 vertices and 30 indices. At 7000 instances, the game (and editor) crash because Windows resets the GPU. At 6500 instances, it's 24 vertices and 36 indices. There doesn't seem to be an intuitive relationship between the number of instances and the growth of vertices, except that they grow.

I can't find where anyone else has seen this growing vertices issue.

#

Should I submit a bug report for this?

vagrant surge
#

@low tangle neat

#

atm im continuing my experiments with that boids simulation i had

#

after moving the entire simulation to be a threaded taskgraph, im reaching 20 ms for 400.000 entities for sim+render

gusty comet
#

Posting screencaps to show what I mean.

#

That's nowhere near a constant cost per instance (consider the first 2500). And at 7000 instances, the GPU is killed.

low tangle
#

@vagrant surge hell yeah, keep us updated on that stuff.
did you do any more unreal engine stuff?

vagrant surge
#

not atm

#

includes Tracy profiler to check how it runs

#

last thing i did is implement a culling system very similar to what mike acton explains in Megacity

#

where i cull per-chunk, and build a list of visible chunks + bitmasks

#

i understand now why mike acton built it like that. It definitely its a great way to do it, very strong

opaque ledge
#

@gusty comet are you instantiating from a gameobject prefab ? or create your entities from code ? Also GPU instancing on your materials has to be enabled for RenderMesh/Hybrid Renderer v2 to work

gusty comet
#

GPU instancing is enabled (they're being SRP batched), and they're procedurally generated quads.

#

Problem isn't getting them to batch. It's that the batcher is instancing a non-constant number of them, and then crashing the GPU.

#

First 2500 cost one quad (so it's instanced). But then the number of quads goes up

opaque ledge
#

Can you try to instantiate from prefab ? i remember an Unity staff said creating your entities from conversation is much better in DOTS envoirement than generation one on your own especailly when it comes to the entities that has render components

#

i think it was in Hybrid Renderer forum topic

gusty comet
#

I guess I could try in a roundabout way, maybe? I need procedurally generated geometry, so I'd have to generate the mesh, attach it to a gameobject, convert it, and then instantiate it.

#

Cool, he covers it there. Thank you. This must be related to something HDRP specific. That explains why I didn't see it on the built in renderer before migrating.

wide fiber
#

Can I already export to html5 with unity tiny?

mystic mountain
#

When you do HasComponent in Entities.ForEach of SystemBase will it do a GetComponentFromEntity? Follow code it does EntityManager, but I guess there is some magic involved, so does it matter if I use Schedule() or Run()?

gusty comet
#

If you're doing structural changes, use WithoutBurst().Run(). Otherwise, you should be able to use Schedule().

#

When you query for components, it just traverses the archetype's component list.

#

Sorry, WithStructuralChanges().WithoutBurst().Run(). I think.

opaque ledge
#

@mystic mountain yes, HasComponent/Get/Set essentially do GetComponentFromEntity, with less code

#

Run makes the job run on main thread, schedule makes the job run on worker thread

#

You want to do Schedule most of the time

mystic mountain
#

Right so can I avoid needing to add WithReadOnly etc with this?

opaque ledge
#

yep exactly

#

unless you are parallely writing tho

#

you cant do SetComponent with ScheduleParallel

mystic mountain
#

Right, then I still would need to do the disableParalell thingy

opaque ledge
#

you have to explicitly do GetComponentFromEntity and put WithDisableParallel

mystic mountain
#

So is there any threshold on when you should do run vs schedule vs paralell, or is this just something you'll have to test?

opaque ledge
#

yeah its something you should test

low tangle
#

always test

#

only rule of thumb you can work with is entity count, and how packed you think the chunks are

#

if you think the jobs gonna be running over 2 chunks with 50 entities each then yeah, main thread run

#

if your systems gonna run over every single position+delta+dietimer and there might be who knows how many at any time

#

probably a good idea to write it full parallel

#

but always just setup a test case and profile

mystic mountain
#

For all like 100s of systems? x)

#

I guess only optimize when you have to but ok yeah.

low tangle
#

thats why they made lambdas the one way to rule them all

#

there much easier to switch between

amber flicker
#

I actually just posted on the forums related to this.. in my case, numbers of entities that systems run over can vary hugely. Run/Schedule massively better for low numbers, ScheduleParallel significantly better for large numbers (obviously). At the moment it's looking like I'm going to have to do this manually/dynamically but with the lambda syntax, this is a bunch of horrible copy/paste, even once I've extracted the bulk into a struct. Would really love some auto parallel -> run switch when below a certain number of chunks.

opaque ledge
#

@amber flicker I remember Joachim post in the topic that was about IForEach being depraceted, i believe it was about creating a static method that you pass your query's component in it and that static method would do the process
Something like this i think

static void Execute(ref componentA, in componentB){
  //Process
}
void OnUpdate(){
  if(lotsOfEntities){
    Entities.ForEach((ref componentA, in componentB)=> Execute(ref componentA, in componentB)).ScheduleParallel();
  }
  else{
    Entities.ForEach((ref componentA, in componentB)=> Execute(ref componentA, in componentB)).Run();
  }
}
#

but i think he did it thru a struct instead of static method, i dont remember

#

tho i guess this wont see captured variables πŸ€”

amber flicker
#

thanks @opaque ledge yea that's what I meant by extracting the bulk into a struct (you do basically that but new myStruct().Execute) similar to the old ijobforeach. The issue is, in my case I also have a bunch of chaining of jobhandles so even doing this creates a tonne of code. It's looking like the most viable option right now but this feels like it should be an api level feature tbh.

opaque ledge
#

ah okay

#

i dont think there is a workaround for this that lets you not do copy/paste 😦

amber flicker
#

I don't think it's unreasonable that scheduling a parallel job on a cpu with many cores takes considerably longer.. I guess I gotta hope over time other people will start experiencing this pain too πŸ˜…

#

the main frustrating part of this is that I could store ForEachLambdaJobDescription that foreach returns then later call Schedule or ScheduleParallel.. but doing that throws an error that ForEach needs to end in either a Run, Schedule or ScheduleParallel invocation 😬

warped trail
#

copy generated code and use it directly πŸ˜…

amber flicker
#

It's all code-gen anyway - just longer compile times and more to maintain (not to mention all the refactoring to structs)

opaque ledge
#

Unity Phsysics new package πŸ‘€

warped trail
#

I'm curious what Entities 1.0 will bring usπŸ€”

dull copper
#

Or entities 0.10?

opaque ledge
#

πŸ˜„

warped trail
#

πŸ˜”

lusty otter
#

It's going to be a long while for it to be anywhere production ready, I feel πŸ˜”

dull copper
#

missed minor Entities update earlier:

## [Entities 0.9.1] - 2020-04-15

### Fixed

* Fixed NullReferenceException issue with Singleton access methods in SystemBase.
#

Hybrid Renderer got update but it's only for dependencies according to changelog

warped trail
#

if we are getting new subscene functionality in next release , will we finally get some subscene documentation?πŸ€”

dull copper
#
## [Unity Physics 0.3.2-preview] - 2020-04-16

### Upgrade guide

* All `PhysicsShapeAuthoring` components that were newly added after version 0.3.0 were incorrectly initialized to have a bevel radius of 0. It is recommended that you audit recently authored content to assign reasonable non-zero values.

### Changes

* Dependencies
    * Updated Collections from `0.5.2-preview.8` to `0.7.1-preview.3`
    * Updated Entities from `0.6.0-preview.24` to `0.9.0-preview.6`
    * Updated Jobs from `0.2.5-preview.20` to `0.2.8-preview.3`

* Run-Time Behavior
    * In order to test gameplay end to end determinism users should:
        * Navigate to UnityPhysicsEndToEndDeterminismTest.cs (and HavokPhysicsEndToEndDeterminsmTest.cs if using HavokPhysics)
        * Remove #if !UNITY_EDITOR guards around [TestFixture] and [UnityTest] attributes (alternatively, users can run the tests
          in standalone mode without the need to remove #ifs)
        * Add scene that needs to be tested (File -> Build Settings -> Add Open Scenes)
        * Make sure that synchronous burst is enabled
        * Run the test in Test Runner

* Authoring/Conversion Behavior
    * Compound conversion system is now deterministic between runs.

### Fixes

* Volume of dynamic meshes is now being approximated with the volume of the mesh AABB, as opposed to previously being set to 0.
* Fixed regression causing newly added `PhysicsShapeAuthoring` components to initialize with a bevel radius of 0.```
#
## [Havok Physics 0.2.2-preview] - 2020-04-16

### Changed
- `HavokSimulation.StepImmediate()` is now provided and can be wrapped in a single Burst compiled job for lightweight stepping logic; however, it doesn't support callbacks; if callbacks are needed, one should implement the physics step using a set of function calls that represent different phases of the physics engine and add customization logic in between these calls; this should all be wrapped in a Burst compiled job; check `HavokSimulation.StepImmediate()` for the full list of functions that need to be called

### Fixed
- Fixed a crash that would occur when adding a static body, while the AABB of an existing dynamic body contains world origin (0, 0, 0).
warped trail
#

or will it be like we added this, this and this, good luck figure out how to use it in changelog? πŸ˜‚

dull copper
#

wonder if they've finally documented StepImmediate now that it's on both physics pacakges :p

#

check `HavokSimulation.StepImmediate()` for the full list of functions that need to be called
does sound like that's a negative though πŸ˜„

#

there's also a minor bump to Platforms 0.2.2p10 but since it doesn't have changelog update, it must be some dependency update

opaque ledge
#

They have added TriggerEvents and CollisionEvents in previous update, so you could do ForEach on them (i think) but i still couldnt figure out how to use it

warped trail
#

from forum πŸ˜… cs var events = ((HavokSimulation) stepPhysicsWorld.Simulation).TriggerEvents; foreach (var i in events) { }

loud matrix
#

Anyone have any advice on setting up global game databases for use with DOTs? I've never had to implement one but I'm looing at seeing a few different ways, scriptable objects, static classes, external xml files etc. But all the info I can find is old so if there were any issues with ECS they wouldn;t be covering it anyway.

naive parrot
#

how do you get the JobHandle for dependency management thats gets generated/used by ForEach?

#

nvm , Dependency property contains this.

mint iron
#

@loud matrix ill throw in some thoughts;

the easiest option is basic data converted into Singletons, you could do that by having a prefab in a subscene with authoring components, input your data in the GO and it will show up in ECS world, as long as you only have one such object it can be accessed via the EntityManager Singleton methods.

One downside there is that since subscenes compile to a blob of data, it has to be defined at compile time and if its something you need to load dynamically like converted from a web request then its not going to work. Maybe you could get around that by streaming in a complete SubScene or BlobAsset remotely either manually or with addressables, but i haven't seen some good examples.

Sadly runtime conversion doesn't seem like its going to be supported which complicates things.

loud matrix
#

@mint iron Thanks for the reply. It's mostly just game data, items, weapons, ship types etc. The one thing that interested me with scriptable objects was being able to easily grab meshes for use in ECS rendering without having to reference file names or the like.

untold night
#

so I am going to push some updates to that repo sometime in the near(ish) future, but I'll let you know that you can now put regular object IComponentData if you just need to read pre-existing data on the main thread. Use blobs if you need to access everything on jobs.

#

so you could have a component that's just a wrapper for a reference to a scriptableObject or mesh asset as an intermediate solution

fallow mason
#

Hey anyone know if having your enums inherit from byte is worth doing for ICDs? I imagine it would allow more in cache, but might be slower processing because modern architecture is optimized for 32 bit word length, right?

#

Probably would be more beneficial for netcode.

vagrant surge
#

better to have them smaller

#

modern architecture basically treats all ints as 64 bit

#

i think

fallow mason
#

Yeah I can see OOP it not being worth the tradeoff, but got to get that tight DOD packing.

hollow sorrel
#

did some quick tests a while ago with 1mil array of int2 vs 1mil array of byte2 and doing a simple a + b = sum
in regular C# the result was the same, C# always casts to int when doing math on bytes so i guess that makes sense but was surprised to not see a result from being packed tighter in memory

in burst however the byte2 version was 2x faster when sum is int
3x faster when casting result to byte and sum is int (so sum += (byte)(a + b))
5x faster when casting to byte and sum is byte

#

i'm guessing burst actually treats byte math as bytes instead of casting to ints

fallow mason
#

Oh nice! Guess it's confirmed.

hollow sorrel
#

so ya even at worst using bytes has no negative impact which was the main reason i did the test, kept reading stuff about "just use ints because cpus are more optimized for it" and the idea that casting is expensive

fallow mason
#

Right, that was what I was reading. Makes sense that there would be benefit to using smaller datatypes with ECS. Glad to see it's true.

vagrant surge
#

ECS tends to be so stupid fast that is bottlenecked by raw memory bandwdith

fallow mason
#

Pleasantly surprised to hear processing benefit too.

vagrant surge
#

as a general rule of thumb, smaller = faster

hollow sorrel
#

yea

#

and just for reference the actual results with editor attaching disabled and all using NativeArray:
1mil a + b = sum in regular C# = 1.60ms
burst int2 = 0.60ms
burst byte2 = 0.30ms
burst byte2 with casts = 0.20ms
burst byte2 with casts and sum is byte = 0.10ms
burst int2 and sum is byte = 0.50ms

so best case scenario iterating and summing 1mil byte2's is only 0.10ms on my machine which sounds bonkers to me

#

even overhead will prob be more than 0.10ms when using proper systems and whatnot

#

burst is crazy fast

fallow mason
#

Wow. Yeah. Thanks for running those tests. Very cool.

hollow sorrel
#

oh sorry regular C# version was using regular C# arrays cuz nativearray in regular C# was more costly

#

but yea still

mint iron
#

ill give it a whirl

hollow sorrel
#

looks like i forgot to put a [BurstCompile] above the int2job when i uploaded but it is in my tests thonking so ya just add it manually

#

and looks like i didn't add the byte2 struct either which is just

public struct byte2
    {
        public byte x;
        public byte y;
    }
#

since unity.math doesn't have a byte2

#

and remove the using Phased.Tilemap3D oh man
basically i just use one class that i use as a notepad for benchmarking stuff when i need to that's why it's so sloppy when i wanted to copypaste only this part

mint iron
bright sentinel
#

@hollow sorrel I'm wondering, only the bottom one was burstcompiled, wouldn't that make a huge difference?

#

Oh duh

#

That's the job

#

πŸ€¦β€β™‚οΈ

#

Oh wait no, the int2 job isn't bursted πŸ€”

hollow sorrel
#

yea i think i copypasted wrong but it should be there on the TestInt2Job as well

bright sentinel
#

Ah ok

#

Oh you stated that right there

#

Lmao

hollow sorrel
#

@mint iron do you have safety stuff on?

#

and/or jobsdebugger

mint iron
#

no, i just have a laptop from 2008

hollow sorrel
#

ahh makes sense then

#

byte2 still seems to be ~5x faster on your pc

mint iron
#

my notebook probably runs slower than a modern phone haha

hollow sorrel
#

makes for the perfect testing machine then

#

if it runs on there you know it'll run for most ppl

mint iron
#

runs marginally faster in WithCode, could also be due to overheads in the performance testing package though.

#

strangely it looks like the int2 is not being vectorized and the byte definately is

hollow sorrel
#

huh didn't know WithCode was a thing

#

also huh

mint iron
hollow sorrel
#

that's weird because int2 is a unity.math type and byte2 isn't so i was expecting the opposite

mint iron
#

byte has all the fancy things, xmmword the dead giveaway cause its 128 wide.

hollow sorrel
#

ahh

#

i've been meaning to post burst inspector results on forum because burst guy asked but i can't even tell what part is relevant and what isn't so i never did

#

what would cause the int2 to not be vectorized?

warped trail
#

accessing individual values πŸ€”

mint iron
#

i'm just learning it at the moment, becuse i've been trying to improve an octree for the last few days, and making an Aabb4x2 for 256 wide goodness πŸ˜„

warped trail
mint iron
#

what a speedy person

hollow sorrel
warped trail
#

my laptop from 2012 πŸ˜…

hollow sorrel
#

i thought the point of using int2 int4 etc was that it would automatically do these fancy things

mint iron
#

what did you change to make it faster?

warped trail
#

i guess these fancy things will be with float4+float4

#

not when you play with individual values

mint iron
#

oh that was with what drUiD just posted?

hollow sorrel
#

yeah

mint iron
#

you'd have to go back through the output array i guess and sum it to get the same result

warped trail
#

with this, it runs much faster πŸ˜‚ cs c[0]+= (byte)(a[i] + b[i]);

mint iron
#

thats weird, how is adding to a single result different than adding to an array with one item πŸ˜„

fallow mason
#

hah wth. Burst like vectorization that much?

#

brb converting all my scalar operations

mint iron
warped trail
#

but do you get vectorization?πŸ€”

mint iron
#

yep

#

i reduced the input to 250k becuse its doing 4 at a time.

#

wait maybe i messed that up.

#

yeah i only had the first and second indices adding

#

thats a bit faster:

warped trail
#

1 simd operation is slower then 1 regular operation ? πŸ€”

mint iron
#

the byte operation is simd also

warped trail
#

i mean int+int is faster than int4+int4 ?

mint iron
#

no the int + int is 4x slower

warped trail
#

int+int = 1ms and int4+int4 = 1ms ?

mint iron
#

Test3.TestInt is the int+int, the other two are both int4, just diff output method

fallow mason
#

int+int is 1.94ms and int4+int4 is .53-.54ms no?

warped trail
#

i don't know how to explain properly my question πŸ˜…

#

int+int is one operation right?

#

int4+in4 is one operation too, but it is doing 4x work

fallow mason
#

ah I see what you're asking

warped trail
#

1 scalar operation is slower then 1 simd operation?

fallow mason
#

simd quite a bit faster, right? doing 4x the work in 1/4 the time?

mint iron
#

yeah, although there is some additional setup it seems there are many more instructions for the simd version but its faster.

warped trail
#

but you are not doing 4x the work in 1/4 the timeπŸ˜…

#

you are doing 4x work in 1x time

mint iron
#

haha, true, true - or the same work in 1/4 the time

fallow mason
#

how so? isn't the int4 version adding 4 ints in same op, while int version does one? and int4 version does it in about 1/4 the time?

warped trail
#

noπŸ˜…

#

you can't do it faster

mint iron
#

i dont think hes talking about my test results, just in general

warped trail
#

you are doing more work in same amount of time

fallow mason
#

ah ok

warped trail
#

but is it really same amount of timeπŸ˜…

#

simd operation can't be faster then scalar operation

fallow mason
#

it has to be. I just spent the last half hour converting everything 😏

warped trail
#

too bad my English is bad πŸ˜…

fallow mason
#

I think your English is great. I'm just kidding. I did no such conversion, because I don't believe simd faster than scalar either

mint iron
#

i dunno, it could be faster, not all instructions are created equal.

#

but setup time as well, int4 and bool4 masks might be faster, but you have to be storing them in that state all the way through, otherwise you've got added construction time.

warped trail
#

my question is related to this i reduced the input to 250k becuse its doing 4 at a time.

#

like 1 mill simd ADD should be executed in same amount of time as 1 mill scalar ADD ?

mint iron
#

yes but then simd verison would be adding 4x as much stuff in the same time

warped trail
#

but whole point of simd is 4x work for same amount of time, isn't it?

mint iron
#

or same work in 1/4 the time?

fallow mason
#

lol

warped trail
#

but you can't do operation for half HZ