#archived-dots

1 messages ยท Page 115 of 1

round summit
#

I only needed dots physics
Companion entity does physics and syncs transform to its gameobject

bright sentinel
#

Okay, but you still haven't answered my question of why you can't just convert the gameobject as you enter the game

#

I mean, just a prefab reference

round summit
#

hm

#

that might work actually if i cant force the convert

warped trail
#

i think converting something during gameplay is against conversion workflow๐Ÿค”

bright sentinel
#

Yeah, that's what I've been saying

round summit
#

Hm, okay
I'll see about converting prefabs only once

#

Any examples on this?

warped trail
#

you can convert everything you need at "build" time to subscenes

bright sentinel
#

Look at the samples with the rotating cube, they have some conversion examples

warped trail
bright sentinel
#

I think you linked to the wrong time ๐Ÿ˜›

warped trail
#

just start from beginning๐Ÿ˜‹

#

and codemonkey made good video about subscenes i think๐Ÿค”

junior fjord
#

do I understand it right that the system run after system just makes the systems run after each other but not the scheduled jobs?

junior fjord
#

and is this the right way if I want the job of System B to run after System A?

System A
inputDeps = Dependency
systemADeps= Entities....Schedule(inputDeps)
//somehow pass systemADepsto systemB
System B
inputDeps = Dependency
deps = JobHandle.CombineDependencies(inputDeps, systemADeps);
outDeps = Entities...Schedule(deps)
Dependency = outDeps
warped trail
#

//somehow pass systemADepsto systemB this thing is automatic

#

Dependency thing is passed between systems

#

and there is default sync points like Begin-End SimulationEntityCommandBuffer

bright sentinel
#

Unity's ECS system will basically make one long chain of dependencies that they handle, and are passed between all your systems. This way, it can handle how the jobs will be scheduled automatically, and that the jobs that use the same components will be run in the same order the systems are run in. So essentially there are 2 timelines, one with your systems and one with your jobs. In simple cases, the jobs will have a 1:1 timeline to the systems, but in more complex cases, some jobs are not dependent on each other, so they can be run in whatever order. But if they depend on each other, then as long as your systems schedule them in the right order, the job system will take care that the jobs are scheduled in the same order. Now, they can run whenever they can, but it will be guaranteed to be in the same order

#

System1 produces job1 etc

#

As you can see, Job2 and Job3 will run at any point after Job1 have run, in any order, as they do not depend on each other

#

But Job4 depends on both, as they writes to the same components

junior fjord
#

ok thanks very much

#

and thanks for the nice graphic

#

not that I currently need it but in case they would not access the same components, how would I make the jobs run in the right order?

bright sentinel
#

Well if they don't access the same component, then there's no need for them to run in the same order, that's the beauty of it. It will run when there's resources available

junior fjord
#

haha sorry didn't want to react with a knife

bright sentinel
#

๐Ÿ˜‚

junior fjord
#

yeah but say they would access some other ressource like nativearray

#

and I would want it to happen in the right order allthough they access different components

zenith wyvern
#

In that case it's not just a matter of ordering. You need to explicitly include the first systems job handle with JobHandle.CombineDependency

#

Unity only handles component dependencies for you

#

Otherwise you need to handle dependencies yourself or the safety system will throw exceptions

bright sentinel
#

Exactly, that's where you gotta handle them yourself, by at least chaining the dependencies or combining them, since NativeArrays are 100% managed by you as a developer

#

(except the safety system)

junior fjord
#

@zenith wyvern did I do it right in my above example? wait I'll quote it again

bright sentinel
#

But if you just set up the dependencies correctly, then the job system will take care to run them in the order, and they will be dependent on each other

junior fjord
#

and is this the right way if I want the job of System B to run after System A?

System A
inputDeps = Dependency
systemADeps= Entities....Schedule(inputDeps)
//somehow pass systemADepsto systemB
System B
inputDeps = Dependency
deps = JobHandle.CombineDependencies(inputDeps, systemADeps);
outDeps = Entities...Schedule(deps)
Dependency = outDeps

@junior fjord

#

like this?

warped trail
#

JobHandle.CombineDependencies(inputDeps, systemADeps); this is unnecessary ๐Ÿค”

bright sentinel
#

Since you're already passing the inputDeps to the .Schedule() function, then they're already combined

zenith wyvern
#

That's the right way to handle the dependency in the case that System A and System B are both accessing the same native container

bright sentinel
#

And those will also be passed automatically by JobComponentSystem between your systems

junior fjord
#

but how does it know then that I want SystemB to wait on SystemA?

What I am doing is this: I want to create a texture every frame. Since I cannot use Color or Texture2D in the scheduleparallel, I do everything with nativearrays in SystemA
SystemB should run afterwards on the main thread and basically convert stuff from the nativearray things into Texture2D etc

bright sentinel
#

Then you need to add the [UpdateAfter] attribute on SystemB

junior fjord
#

but SystemB actually only needs the nativearrays, it doesn't even need any entities hmm

warped trail
#
SystemA
inputDeps = Dependency
//your work here
Dependency = inputDeps
SystemB
inputDeps = Dependency
//your work here
Dependency = inputDeps```
junior fjord
#

but isn't that the same as just doing nothing?

bright sentinel
#

WIth the code as is, yes

junior fjord
#

How does SystemB now know to wait on SystemA if they don't access the same components (or SystemB does not access any components at all actually)

zenith wyvern
#

You can use Color in a job. If you wanted Unity to handle the dependencies for you you could convert your texture to an array of color, push that into a dynamic buffer and work with that inside a job. In another job you can query the buffer, get your color data and do what you want with it, including pushing it back into a texture

warped trail
#

Dependency from systemA is passed to systemB

bright sentinel
#

That'

#

That's what the JobHandles are for

warped trail
#

this SystemBase stuff is confusing ๐Ÿ˜…

zenith wyvern
#

It's no different than JobComponentSystem

#

All the same rules apply

junior fjord
#

@zenith wyvern but how would I do it if I don't want unity to handle the dependencies, somehow I just don't get it

#

how do I explicitely tell systemB to wait on the main thread until the job of systemA is done, even if they don't access the same components

zenith wyvern
#

You would do it with the code you posted above. Include the final job handle of SystemA in the SystemB. Unity will run SystemA jobs. When those jobs are complete, Unity will run SystemB jobs

junior fjord
#

ah ok, so the combineHandle thing I did was not unnecessary?

#

ok great if it is like that then I think I kind of got it

zenith wyvern
#

If both systems are accessing data that is not being handles by Unity, then yes CombineHandle is necessary

junior fjord
#

ok perfect, thank you

#

and the other ones helping

bright sentinel
#

Isn't that what's happening when you pass in the JobHandle to the .Schedule() parameter?

#

That was at least my understanding

#

That the new JobHandle you get out of it is the chained dependency

junior fjord
#

is it a good way to pass systemA deps to SystemB by just setting the JobHandle as a static variable of SystemA?

warped trail
#

why do you need to manually pass dependency?

zenith wyvern
#

It doesn't need to be static, you could just make it a public variable and access it with World.GetOrCreateSystem<SystemA>.FinalJobHandle

junior fjord
#

because both access the same nativearray but not the same components

#

ok perfect thats even better right

#

thanks

warped trail
#

scheduler handles native array thing

opaque ledge
#

Your way of doing this seems overy complicated

warped trail
#
inputDeps = Dependency;
NativeArray b;
jhA = new JobA{Acces a}.Schedule(inputDeps);
jhB = new JobB{Acces a}.Schedule(jhA)
Dependency = jhB ```
opaque ledge
#

SarkToday at 16:42
You can use Color in a job. If you wanted Unity to handle the dependencies for you you could convert your texture to an array of color, push that into a dynamic buffer and work with that inside a job. In another job you can query the buffer, get your color data and do what you want with it, including pushing it back into a texture

zenith wyvern
#

@warped trail We're talking about separate systems

SystemA
  Write to Global NativeArray
SystemB
  Read from Global NativeArray

That code results in a safety system exception unless you manually handle the job handle like we're talking about.

warped trail
#

no

#

scheduler knows about nattive arrays

junior fjord
#

I also just read that I can access a textures Color array as nativearray, which makes my problem even easier I think

#

now all I need to do is execute a tiny amount of code (texture.apply()) after SystemA is done, do I still need to setup a SystemB for that?

warped trail
#
SystemA
NativeArray b;
inputDeps = Dependency;
jhA = new JobA{write to a}.Schedule(inputDeps);
jhB = new JobB{write to a}.Schedule(jhA)
Dependency = jhB 

SystemB
inputDeps = Dependency;
jhA = new JobA{read from a}.Schedule(inputDeps);
jhB = new JobB{read from a}.Schedule(jhA)
Dependency = jhB```
opaque ledge
#

You know, you could probably chain job them in a single system, 1st job would run with scheduleParallel and 2nd job with Run ๐Ÿค”

#

trying to handle dependency through systems doesnt sound like a common approach

junior fjord
#

I don't create any unwanted sideeffect with everything waiting for that system then?

#

it seems as if that would mean that as soon that the system is executed, the job has to be executed too and unity could not actually manage parallel running?

#

but maybe I should just get going and worry later ๐Ÿ˜„

warped trail
#

you are just scheduling job

#

on main thread

junior fjord
#

not with Run, that means run it immeadiatly

#

I am talking about @opaque ledge idea

opaque ledge
#

i mean.. if you are writing to a native array in Job A, and want to read it in Job B, for a correct behaviour Job B needs to wait for Job A to finish first, otherwise there will be race condition

#

so that means Job B has to depend on Job A, which is what job chaining means, which can be easily done in a system

warped trail
#

you are doing that by passing jobhandle from JobA to JobB

opaque ledge
#

yes

bright sentinel
#

The parallelism doesn't come in this sort of system, as you will always have dependencies. It really begins once you have more than 1 "task" to do, and you have multiple systems that each handle different things.

#

So talking about it in a simple case like this doesn't make much sense

zenith wyvern
#

Dependency error.

opaque ledge
#

this discussion made me wonder about something tho, what if we use a global native array for System A and System B, will Unity be able to recongize them schedule it properly ๐Ÿค”

bright sentinel
#

@opaque ledge The answer was just posted before you asked your question ๐Ÿ˜‚

opaque ledge
#

oh ๐Ÿ˜„

bright sentinel
#

@zenith wyvern What if you pass in Dependencies in SystemB's .Schedule()?

opaque ledge
#

so this code gives an error ?

bright sentinel
#

@zenith wyvern And say Dependencies is equal to that

zenith wyvern
#

You mean the Dependency property?

bright sentinel
#

Yes

zenith wyvern
#

Unity is literally already doing that automatically. It's the whole point of hiding the job handle

bright sentinel
#

Hm okay, so the way to fix this would be to have SystemA's jobhandle be accessible, and then get that in SystemB?

zenith wyvern
#

In SystemBase Job.WithCode(()=>{}).Schedule is functionally equivalent to Dependency = Job.WithCode(()=>{}).Schedule(Dependency)

#

Yes exactly

bright sentinel
#

Hm, okay. But I guess that's just one of the limitations of working with global arrays then

#

Or at least multi-system arrays

zenith wyvern
#

Yes, and it can quickly get out of control. Much more preferable to write your data into components or buffers and read it by querying for that instead

#

That way Unity handles the dependencies for you

bright sentinel
#

Yeah, that was my thought as well. Then you also have the automatic dependency handling

#

๐Ÿ˜„

opaque ledge
#

What happens if you write that array to a shared static instead ๐Ÿค”

zenith wyvern
#

Hmm, I'm not sure. I've never used SharedStatic before

bright sentinel
#

Shared Static to access static mutable data from both C# and HPC#

junior fjord
#

@zenith wyvern if all I want to do is to execute some small code on the main thread after SystemA is done, is it still the best way to do two different Systems and work as above? (either with explicity dependence management or by using some component for example a dynamicbuffer to let unity do it)

warped trail
#

so i am wrong๐Ÿ˜•

#

sorry

zenith wyvern
#

@junior fjord I think so yes. It's kind of annoying but it's your only option other than manually forcing the job to complete

#

If you want to do it on the main thread though I think you would actually have to manually force it to complete first

junior fjord
#

no actually does not have to be main thread, I just have to be able to use a Texture2D and do tex.apply()

#

after I changed the texture2D.GetRawData in SystemA I need to do tex.apply() somewhere, I don't think it has to be main thread (or does it since it uploads to GPU?)

opaque ledge
#

go with Schedule, if tex.apply gives you an error go with Run ๐Ÿ˜‚

zenith wyvern
#

It probably does need to be main thread. I think if you want to force something to run on the main thread after a job you have to change your strategy a bit. You can't "Schedule" main thread to run after a job, you need to do

if( jobHandle.IsComplete )
{
  jobHandle.Complete(); // Must be called manually when the job is done
  // Do the work meant to happen after the job is complete
}
#

You can do that wherever you want, but yeah

#

That's what I do in my rendering system when I need to upload my mesh data. You basically need to think about where your sync point needs to happen and force it yourself

junior fjord
#

I could just use one of the existing sync points I guess

#

all my systems run in the simulationGroup and the texture thing just needs to happen afterwards

zenith wyvern
#

Could do, you can schedule your job early in the frame and force the sync point just before rendering.

junior fjord
#

ok thanks I'll try to get it working

#

thanks for the extensive help

warped trail
#

This thing is confusing to me. So if you schedule this jobs inside one system everything ok, but not ok if this job are scheduled in different systems๐Ÿ˜‘

#

so dependencies are passed between system with some magic?

#

or is it because nativearray is not inside system?

zenith wyvern
#

Basically Unity tracks how systems are accessing components/entities and figures out dependencies for you. It doesn't track when systems are accessing anything else, so you need to account for those cases yourself

#

If you forget about systems for a second and think about the code I posted but replace the systems with manually running two jobs in sequence, it would have the same result (dependency system exception) unless you completed the first job first, or included it as a dependency of the second job.

warped trail
zenith wyvern
#

Because you're including the dependency in the read job

#

If you do the same code but don't include the dependency in the second job (which is basically what my code was doing but via systems) then you get the dependency error

warped trail
#

but shouldn't all dependencies from previous system be in Dependencies?

zenith wyvern
#

No, from Unity's perspective the two systems are not connected in any way

#

If SystemA was writing to a component and SystemB was reading from that component type, then Unity understands there's a connection and automatically sets the dependencies accordingly

warped trail
#

i thought that Dependency from one system is passed to another๐Ÿ˜•

zenith wyvern
#

Only if they're writing to components/entities and then reading components/entities via queries

junior fjord
#

how does unity actually know which components are written/read before executing the systems?

zenith wyvern
#

You'd have to dig in to the source to figure that out

warped trail
#

so in the end this Dependency is not long continuous chain of scheduled jobs๐Ÿ˜•

zenith wyvern
#

No, otherwise there would be no concurrency

#

The safety system needs to know what's being accessed where so it can schedule jobs in parallel accordingly

junior fjord
#

@zenith wyvern going down that road is always the best way to waste time I should spend on programming my game ๐Ÿ˜„

#

where do you guys dispose the nativearrays on application quit? I tried doing it in a monobehaviour in OnApplicationQuit but that gives me warnings since it disposes before some jobs are completed

warped trail
#

you can .Dispose(JobHandle)

junior fjord
#

how do I get a JobHandle that contains all currently running jobs? I just want to dispose everything when I quit the application

opaque ledge
#

you can do that by overriding OnDestroy in your system's class

zenith wyvern
#

I don't know if there is such a thing. What drUiD posted is normally how you do it, you pass in the final job handle that uses the container to Dispose

#

So in the last system to use it you can just do Dispose(Dependency) in OnDestroy

junior fjord
#

ah ok now I understand how it is meant, thanks

warped trail
#

at least now i understand why it is not so convenient to work with physics stuff ๐Ÿ˜…

junior fjord
#

why? ๐Ÿ˜„

#

I have the luck that my game is actually 2d only with 3d models (top down), so I hope to circumvent having to read through physics

warped trail
#

They use native array a lot๐Ÿ˜…

#

now i wonder if physics and future systems will ever be easy to use or there will be a couple small windows between a lot of closed systems where you would be able to do your regular ECS stuff ๐Ÿ˜…

zenith wyvern
#

Yeah I'm really curious how they end up handling physics. The FinalJobHandle and passing around systems stuff feels so awkward, but maybe that's just how you have to do it

junior fjord
#

I marked it as readonly and only write to the entity I am currently using

warped trail
#

i think public ComponentDataFromEntity<GroundHumidity> GroundHumidityFromEntity; this is unnecessary ๐Ÿค”

junior fjord
#

oh yeah it is, it is just something that I tried before and did not work

#

thanks

#

but I think it is unrelated to the error

zenith wyvern
#

Regarding the error you need to pass read only containers to a Foreach with WithReadOnly(container)

junior fjord
#

ah yeah ๐Ÿ˜„ I actually already did that in other systems

#

thanks

warm panther
#

Ok the performance ceiling is ridiculously high. I need to increase my scope by a magnitude of 10. Scope creep? Scope avalanche!

bright sentinel
#

@warm panther Pretty insane, and that's not even with HRv2

warped trail
#

i wonder what changes will v2 bring?๐Ÿค”

#

wait, but technically its v3๐Ÿง

sour ravine
#

speaking of hybrid ECS-- is the relationship between GO Update() timing and the job system(s) documented anywhere? I want to park things in a chunk archetype buffer and read them in a GO's Update() but need to ensure write visibility

#

(for VFX pooling)

warm panther
#

@warm panther Pretty insane, and that's not even with HRv2
@bright sentinel Yeah I am pretty happy. (and yes shared component data makes soooo much sense to me now ^^) Also, Dots physics is a beast.

bright sentinel
#

@sour ravine All it says in the docs are

SimulationSystemGroup (updated at the end of the Update phase of the player loop)

warped trail
#

if only stacking was a thing ๐Ÿ˜…

bright sentinel
#

You can always go check the source

warm panther
#

I'm making a space game, most areas are extremely sparse. But... this is my current performance sandbox, that's 3 models, 400 vessels total, being pulled into a singularity at the origin. Even when they start forming a very compact ball, it stays at 30 fps in the editor.

vagrant surge
#

because thats absolute perfect use case for the current ECS renderer

sour ravine
#

I can't believe it's not Homeworld 3 4

vagrant surge
#

rendering many of the same meshes is where it excels at

warm panther
#

^^

vagrant surge
#

it was made for megacity, which is like 10-20 assets multiplied by 10000

zenith wyvern
#

Isn't the "Saved by batching" there referring to the SRP batcher?

vagrant surge
#

the srp batcher is really cool

warm panther
#

Well it's SRP with hybrid renderer, so it lays out the data correctly for the SRP batcher to do its thing.

#

I'm pretty happy with where things are going.,

zenith wyvern
#

I'll be happy when we get per instance data in URP

warped trail
#

on my potato pc with havok at 48hz i can run at 60+ fps 5-6k colliders@warm panther ๐Ÿ˜

sour ravine
#

@bright sentinel most of the documentation seems to be referencing JCS OnUpdate() and not the MonoBehaviour ๐Ÿ˜

bright sentinel
#

No I'm pretty sure they mean the PlayerUpdateLoop

warped trail
#

you can look at full playerloop in EntityDebugger

bright sentinel
#

I think they are more interested in where that loop is called in the grander picture of Unity

warped trail
#

i think there is everything๐Ÿค”

bright sentinel
#

No, because it doesn't tell you where in the Unity main loop the ECS systems are called from

warm panther
#

Does Fixed Timestep have any impact on Unity Physics?

bright sentinel
#

No unfortunately Physics are currently frame dependent

warped trail
#

i may be wrong, but i think this is exactly what ShowFullPlayerLoop do๐Ÿค”

bright sentinel
#

I'll have to check that out

warped trail
#

@warm panther you have to force Physics to update in fixed timesteps yourself๐Ÿ˜…

warm panther
#

I actually prefer variable timesteps at this time.

#

Though I wonder how I would simulate multiple physics worlds.

#

That kinda works well with Scenes, but I am porting my stuff over to ECS

bright sentinel
#

Omg the full player loop is really damn useful, thanks. Never saw that before

#

That should be more accessible in standard Unity ๐Ÿ˜‚

warm panther
#

And then the main problem I'll see is moving entities between words, and tying entities with RenderMeshes to entities with Translations in other Worlds.

bright sentinel
#

I'm a bit confused though, if physics are tied to framerate, how are you supposed to do anything useful with it?

warm panther
#

Easy answer, FIXED FRAMERATE like it's the Playstation 4 all overagain.

#

๐Ÿ˜›

bright sentinel
#

Haha oh dear

warped trail
#

you have to set fixedDeltaTime to target fps

warm panther
#

(I'm a bit of a frame rate snob, tbh)

bright sentinel
#

@warped trail Isn't it supposed to be the other way around?

warped trail
#
#if !UNITY_DOTSPLAYER
            float timeStep = UnityEngine.Time.fixedDeltaTime;
#else
            float timeStep = Time.DeltaTime;
#endif
``` this is from stepPhysicsWorld
warm panther
#

shriek

warped trail
#

so if you plan to run your game at 60fps then make fixedDT 1/60

#

144 then 1/144

warm panther
#

what's UNITY_DOTSPLAYER supposed to mean

bright sentinel
#

UNITY_DOTSPLAYER: Standalone DOTS (vs hybrid DOTS) - for example, if you use UnityEngine, you want #if !UNITY_DOTSPLAYER

#

I think the only support for that currently is Tiny

warped trail
#

it is DOTS.Runtime

warm panther
#

Hmm

#

Ok

warped trail
#

i think it is basically another engine๐Ÿ˜…

warm panther
#

The only thing I really miss with ECS right now is being able to properly select and inspect/modify objects in scene view in play mode. I hope there's some kind of API to select the entity automatically in the entity debugger at least.

#

I'm looking into the mouse picker from the samples

bright sentinel
#

@warm panther You can still change the original gameobject when you have LiveLink set to editing mode

#

That will then propagate to the entity

#

Via livelink

warm panther
#

hmmm ok

#

I got enough screens to make that a viable option if push comes to shove

formal scaffold
#

Hey is what I'm saying correct?
An archetype is a set of components, archetypes are stored in the same chunk.
A chunk is a continious line of Data in memory
Removing one element(one instance of an archetype) leaves behind an empty field in the chunk

bright sentinel
#

@warm panther Well it should already be there, since you just need the scene view/inspector and game view

warm panther
#

So does livelink work with prefab stages?

#

those contain the most things I'd like to tweak

bright sentinel
#

@formal scaffold Not quite, but close. An archetype is a set of component. Each chunk can only have 1 archetype, but there can be multiple chunks with the same archetype. This is because chunks is a block of memory of max 16kb, so archetypes can be spread over multiple chunks.
Not exactly sure what happens when you remove it though

#

@warm panther What do you mean "prefab stages"?

formal scaffold
#

Thanks for the input ๐Ÿ‘

formal scaffold
#

Who decided to make a chunk 16kb? Is there some sort of rule? Is it CPU dependend because of cache lines? If I only have entities with the Translation component this should mean my implicit archetype is only Translation. Looking up floats, they seems to be using 4bytes, so Translation uses 12bytes.

12bytes for a 16kb chunk seems like a huge waste. Or do I understand this wrong?

warm panther
#

@bright sentinel I mean when I edit stuff in Prefab mode, and have livelink on, does that transfer, especially when these prefabs aren't in any of the scenes or subscenes directly, but used through IDeclareReferencedPrefabs

#

That would massively rock.

bright sentinel
#

Ah, then no, unfortunately not right now

warm panther
#

Ok.

#

I'll try out livelink in my next session, I'll research how to roll my own PhysicsWorlds now.

bright sentinel
#

@formal scaffold If your archetype is 12 bytes, then your chunk would contain 16k/12=1365 components

warped trail
#

@formal scaffold chunk i like a pool of objects, creating an entity is basically just setting the values in one of chunk's field

#

not a pool, more like array i think๐Ÿค”

formal scaffold
#

Starting to understand this ๐Ÿง good good

opaque ledge
#

Maybe its because of size of L1 cache ? they have low amount of memory, like 16kb, 32kb etc

#

so if Unity is able to put whole chunk in L1 Cache...

bright sentinel
#

Definitely something to do with cache size

sour ravine
#

yeah I do not believe the 16kb size is magic in of itself

#

most caches/page sizes tend to be integer multiples of that, so every invalidation can (in theory) get your money's worth

#

pardon the bad pun

vagrant surge
#

l1 caches tend to be 32k, i think 16k on phones

#

memory pages are 4k at minimum/default size

#

its kinda arbitrary, really

#

they said they wanted to eventually have a smaller chunk size, for when you only have like a couple of entities

warm panther
#

Question - is it generally acceptable to add or remove systems at runtime?

#

(occasionally - e.g. once every couple of seconds)

sour ravine
#

likely no, if only because EQ's are usually a better tool for that kind of thing

warm panther
#

Hmm.

#

I may need a data-based EQ though.

sour ravine
#

EQs are innately data-based

warm panther
#

as in, looking INTO a component's fields, not just at the presence thereof

sour ravine
#

What Are You Doing, Really

#

chunk data might also be more appropriate

#

change tagging, too

warped trail
#

if you want to separate entities to different chunks based on value of component, thenSharedComponentData may help you

warm panther
#

I'm trying to figure out a way to run multiple Unity Physics simulations in parallel, and to "move" entities between them. I don't think creating a whole new World makes a lot of sense, but seeing how the unity physics systems are built, these should be customizable enough - if I figure out an efficient way to query for those entities.

The number of potential physics worlds is unfortunately unknown, probably will cap it at < 100. The worlds are generally very sparse (space game) but I'd like to simulate as many as feasible at the same time.

#

sharedcomponentdata!!!

#

Thanks.

#

That's the solution.

#

(or a start ^^)

sour ravine
#

if you're trying to do a bunch of independent physics sims it almost sounds like you want to skip the shared collision element entirely

warm panther
#

what do you mean?

sour ravine
#

I'm not sure, that's what I'm asking about.

#

if you want everything to not interact with other things, why not skip all the maintenance associated with creating bounding hierarchies, etc. and just use 'dumb' custom physics components

#

maybe recycling some of the Unity Physics spring integrators or whatnot

warm panther
#

I want everything to interact with things in its own frame of reference. (I'm building a floating origin system around this, so think of it like an "arena" you can pop into and have a physical manifestation in). My initial approach with collision groups (in DOTS) and layers (in classic Unity) didn't work well enough, because I have 3 or 4 types of interactions/layers. What did work was using normal Scenes with their own worlds in standard Unity, but ECS lends itself very much to my game idea, and also it is a learning and passion project ๐Ÿ™‚

#
using Unity.Entities;

namespace Jovian.Components
{
    public struct Instance : ISharedComponentData
    {
        public int Value;
    }
}```
#

I guess it'll be something like this.

#

And my own version of BuildPhysicsWorld : JobComponentSystem etc.

sour ravine
#

transforms fundamentally already do this

bright sentinel
#

I'd say that seems like a case for worlds, but I haven't really worked with them

warm panther
#

How?

sour ravine
#

unless you want to do something at double precision

#

basic matrix algebra?

warm panther
#

I mean how do transforms prevent two objects in the same location from colliding ๐Ÿ˜„

sour ravine
#

they don't, just depending on your needs you already have 'local' coordinate systems

#

and unless you write double-precision variants I'm not sure what re-implementing the Unity system accomplishes for composition

warm panther
#

Not for physics, and I know what you mean but I want a pretty large world (real life scale Jupiter system), meaning I built a floating origin system that I'm trying to bring over and scale to work with ECS.

#

I only need double precision for bookkeeping, I am totally fine with confining everything to a 100x100x100 units cube for actual gameplay.

#

I wonder whether changing sharedcomponentdata doesn't thrash a lot of the chunks.

sour ravine
#

it will, it's a full entity copy on change

warm panther
#

it changes RARELY; but not that rarely.

sour ravine
#

see notes about changing archetype

#

when swapping shared component data

warm panther
#

But archetype changes all the tim.e

#

Well, I guess not if you count tags.

sour ravine
#

not necessarily, no

warm panther
#

I'm used to coding with the Entitas ECS, there you express a lot of logic by adding and removing components.

sour ravine
#

adding and removing arbitrary component types (this is not the same as setting component data) is not considered a 'happy path' in Unity

warm panther
#

Hmm

sour ravine
#

it's a structural change

warm panther
#

Good to know.

sour ravine
#

you change the chunk the entity lives in, which you implement by copying the component data

warm panther
#

So I guess I need to express a "null" state in components like targeting data, waypoint data, etc.

sour ravine
#

if they're light components then no sweat

warm panther
#

or anything that changes somewhat frequently.

#

I try to keep components very light.

sour ravine
#

it might be viable

warm panther
#

it's what I am prototyping.

#

and trying to find out here ^^

sour ravine
#

this is just the Mike Acton thinking about data

warm panther
#

I'd say the sharedcomponentdata for which "instance" an entity is physically in changes maybe once every few minutes, per primary entity. But there are probably around 500 of those. Still, I don't think the computer should even break a sweat.

sour ravine
#

I agree it makes sense in the Unity ECS for physics to work in the chunk level, which you can do via shared components

warm panther
#

I think I need to have them on a lot of secondary entities though, because I would use the same system to cull renderers when there is no observer in the respective instance. (by disabling the RenderMesh-holding entities entirely)

#

The nice part is...

#

(or I should probably write my own rendering system but I'd hate to do that at this stage - going the easier way and I still have a lot to figure out about how I translate my physics solution into DOTS)

#

I wish there was a good way to disable RenderMeshes. Maybe copy them into a holding component. But that's potentially hundreds of SharedComponentData changes at once then.

sour ravine
#

the rendering part seems like a good fit for BatchRendererGroup but that's intended for MonoBehaviour usage

warm panther
#

Interesting!

#

Well.

junior fjord
#

can I set components like this
compA.propertyX = 4?
I vaguely remember something like you should make a copy and then reasign the whole component, i.e.
compA = new compA {propertyX = 4}

warm panther
#

I'll look into splitting my entities with a sharedcomponentdata for now, and sort out the queries for that.

junior fjord
#

but that was a long time ago and I am not sure if I remember right

sour ravine
#

@junior fjord no, you must reassign the whole thing (this makes more sense when you understand EntityCommandBuffer and archetype changes)

junior fjord
#

ok so like I did in the second line?

sour ravine
#

ref stuff excepted in specific jobs

bright sentinel
#

No you can assign it directly if it's by ref

sour ravine
#

^^ (so, to be fair, It Depends)

bright sentinel
#

Well if you're going to be changing the value, why wouldn't you do it by ref anyways?

sour ravine
#

ComponentDataByEntity<> is by value iirc

bright sentinel
#

Ah that's fair

sour ravine
#

buffer stuff is also pretty much always by value too

junior fjord
#

ah ok I am working with by ref

#

so ref just means pointer in C#?

bright sentinel
#

Basically yes

junior fjord
#

and ComponentDataByEntity makes a copy?

sour ravine
#

yep

junior fjord
#

ok thanks

sour ravine
#

pointers actually do exist in C# but that's a topic

#

ref is not exactly a pointer in the same way an object reference is not exactly a pointer but it gets the idea across

opaque ledge
#

ah no, its by ref, you can modify them

junior fjord
#

yeah I think I understand how a ref works

#

basically a pointer with the everything hidden away and you cannot reassing the pointer variable itself?

opaque ledge
#

in Unsafe context you can i think, but i never needed to

#

plus its scary ๐Ÿ˜„

junior fjord
#

can I somehow step through my game frame by frame?

warped trail
#

press pause and step?

bright sentinel
#

@junior fjord You can use a debugger with a breakpoint, which you know will only run once per frame (e.g. start of any system OnUpdate). You can then just continue playing it every frame

#

Or you can do that

#

The button next to the pause button is a frame step ๐Ÿ˜›

junior fjord
#

@warped trail thanks man never used that button ๐Ÿ˜„

#

thats perfect

#

@bright sentinel yeah but somehow if I use the Rider debugger unity always freezes

bright sentinel
#

I've never used it either, for 8 years of Unity use ๐Ÿ˜‚

#

Ah yeah, that's a limitation of the debugger unfortunately, because it's the same loop that the editor uses

#

So you can't really use it if it's frozen by the debugger ๐Ÿ˜›

warped trail
#

but be carefull it may step with Maximum Allowed Timestep

junior fjord
#

yeah I cannot see the mesh drawn which is what I want to see

#

when using rider

#

@warped trail good to know but I actually need to step frame by frame since the water flow simulation I do does not use a timestep

#

I want the water to instantly equilibriate so I did not multiply with dt

bright sentinel
#

@junior fjord You could try to manually use Debug.Break() at the end of the frame instead, maybe using some hotkey or something

#

And then everytime you wanted to continue, you just unpause, and your code should then pause again at the right moment

#

If you place this in a System that updates at the very end of the presentationgroup, it should work

#

Or maybe even somewhere later

#

Not sure if that will solve it though

junior fjord
#

I think the stepper button is perfect for now

#

does anyone have an idea why this:

        var random = new Random(seed);
        Debug.Log("Using seed " + seed);
        Debug.Log("First random int is " + random.NextInt(100));

gives me different seeds but always First random int is 0?

warped trail
#

you need to give it BIG seed ๐Ÿ˜…

bright sentinel
#

I'd just use the current UNIX time

#

That way you will 99.99999% guarantee it's a new seed for everyone

#

And 100% if it's the same user

#

Unless he somehow plays a game and restarts all within 1 second

#

And plays long enough to notice that it will be the same.. ๐Ÿ˜‚

junior fjord
#

no this should not depend on the size of the seed

#

I want to keep the seed fixed while developing that is not the problem, but the first random integer should not always be 100

bright sentinel
#

Well try giving it a big static seed then

#

335895875

#

There you go

warped trail
#

you can iterate over seed and see yourself

#

at least with Mathematics Random

opaque ledge
#

You can give current time as seed

#

or call UnityEngine.Random when you are constructing Mathematics.Random

warped trail
junior fjord
#

@warped trail you are right, a big random seed gives different result

#

this is not how I remember that random number generators should work ๐Ÿ˜„

#

thanks

slim nebula
#

hello. I was wondering if someone might help explain something to me. I'm getting this error in my project but it's also in the DOTSSample:

#

is there a different/better/proper way to do the "convert to client server entity" script for a subscene?

#

or does it indeed do nothing even in this case here and maybe the DOTSSample isn't updated?

#

or what's going on here?

#

sorry I'm very new to this and I"m just trying to wrap my head around the basics here

bright sentinel
#

It's a good question I'd also like to know the answer to. SubScenes seem to be the way forward for conversion, but I'm not sure how that will be handled with NetCode, as they have their own conversion flow.

#

But since you're in the DOTSSample, is that how they do it? Or is that something you tried to do yourself?
Because if that's how they do it, then I guess that's the way to do it..

slim nebula
#

kk

#

I havn not quite put it togeather

#

I guess I"m trying to put it togeather myself now

#

not seeing any issue so far but, was maybe trying to skip some self science

#

the client to server script seems to only convert if on either server or client as selected

#

I dunno

bright sentinel
#

I was just asking whether that is how you downloaded the project, or if you added the ConvertToClientServerEntity component yourself?

slim nebula
#

I guess I can run the sample and see if it creates entities on the server

#

nah that was in there

#

I changed nothing

#

should be vanilla DOTSSample from like a week or two ago tho :S

#

oof it wont run ๐Ÿ˜ฆ

#

I guess the unity upgrade broke it

bright sentinel
#

Ah yeah, you gotta stick to what they say to use ๐Ÿ˜›

slim nebula
#

oh those are systems not entites

bright sentinel
#

Huh?

slim nebula
#

im tryin to figure out if it's creating entities on the server

#

I guess it shouldn't because it's set to client

#

I dunno like... gamemode exists as an entity in both the server and the client world

#

maybe there's a different gamemode elsewhere in this scene that goes on the server

#

I'm going to try it with a simple project instead of trying to figure this out. too many moving parts in DOTSSample

#

thanks though

slim nebula
#

ok I mean you're right Bmandk. The way the DOTSSample has it works. I mimic the same thing with a cube. When I set to server, I get that error up top but it does make it not get created on the client so yeah

#

seems like a display but but it's not breaking the script. it does indeed run the one on the gameobject

#

I wonder, is there some way to change the "convert to entity" script used on a specific subscene or something?

#

lol ok removing the convert to entity script from DOTSSample results in everything working just fine XD

#

it seems the server-only entities are created programatically so this script isn't used for any server-only stuff in this sample

bright sentinel
#

Hm, interesting

#

Seems like a bug

slim nebula
#

I get the top error if I try to put the ghost collection into a subscene, and I get the bottom warning if I try to put the ghost authoring prefab into a subscene. The DOTSSample doesn't have this issue but I can't figure out why. I'm curious why this is?

#

moving everything into the main scene works fine

bright sentinel
#

tbh it doesn't seem like NetCode is quite ready for SubScenes yet

#

Which would kinda suck

#

I was actually planning to do all this testing tomorrow, but nice to know what to look out for ๐Ÿ˜„

slim nebula
#

aight well im just starting out so I can just make my stuff inside my main scene for now until things are ironed out hehe

opaque ledge
#

how do i create my own barrier system ๐Ÿค”

#

is it depracted, every link i found is dead links

#

should i just create normal command buffer and just run on the entity manager after job finish ๐Ÿค”

opaque ledge
#

Got it, gotta inherit from EntityCommandBufferSystem, idk why but system didnt initialize so i had to do GetOrCreateSystem in order to retrieve it

scarlet inlet
#

@opaque ledge on the forum people are saying that the field Dependency won't carry external dependencies over the next system, which was my understanding as well initially. I will need to do some serious test for this

opaque ledge
#

yeah, i saw your post

#

gl^^

warped trail
#

@scarlet inlet Note, the JobHandle only includes dependences for component data, not native containers. If you have a system or job that reads data in a native container populated by another system or job, you must manage the dependency manually. this is from ecs documentation๐Ÿ˜•

scarlet inlet
#

link please?

scarlet inlet
#

and what manage dependency manually actually mean? Like passing myself the jobhandle between systems?

warped trail
#

yes

scarlet inlet
#

also I don't think that sentence in the documentation is correct

#

they didn't mean JobHandle, they meant the actual Dependency field, right?

#

the JobHandle can carry other dependencies

warped trail
#

Dependency field is just job handle

#

we discussed this topic yesterday

scarlet inlet
#

I know but reading it like that it looks like I can't ever using whatever JobHandle to carry other dependencies

#

Note, the JobHandle Dependency field only includes dependences for component data, not native containers. If you have a system or job that reads data in a native container populated by another system or job, you must manage the dependency manually.

#

they should have phrased like that right?

#

Anyway I am glad I have the final answer

warped trail
#

thats why physics systems have this FinalJobHandles

scarlet inlet
#

that was my understanding as well

south falcon
#

Hello, I have a question that if I add dynamicBuffer to an entity which already has a dynamicBuffer, what would happen? Would it just override the data of the exists one?

opaque ledge
#

yeah

#

if they are same type ofc

south falcon
#

Is this meaning that I don't need to worry about that an entity whether has this type of dynamic buffer before I add? What about the API SetBuffer? what is the difference between AddBuffer?

opaque ledge
#

SetBuffer is explicity for overriding, it will give you an error if that component doesnt exist, AddBuffer simply adds the component if it doesnt exist, if it exist then overrides it

south falcon
#

Thank you a lot ๐Ÿ˜„

#

I have another question about NativeArray.

opaque ledge
#

shoot^^

south falcon
#

If I new a NativeArray ArrayA and use a temp NativeArray ArrayB to equal ArrayA . Then I dispose ArrayB. Will the data of ArrayA still exists?

opaque ledge
#

no, they will point the same native array, if you dispose one, you dispose the other

south falcon
#

I see. So I don't need to dispose the tempArray if I want original array still exists. Is that right?

opaque ledge
#

Yeah

south falcon
#

Ok, Thank you.๐Ÿ˜„

amber flicker
#

Although, you do probably want to dispose of it somewhere ๐Ÿ˜. Usually in OnDestroy.

warped trail
#

So, Dependency thing is not carrying info about nativearrays does that mean that i can't use physics query outside of BuildPhysicsWorld-EndFramePhysicsSystem window?๐Ÿค”

south falcon
#

Although, you do probably want to dispose of it somewhere ๐Ÿ˜. Usually in OnDestroy.
@amber flicker Yeah, done already ๐Ÿ‘

opaque ledge
#

probably Druid

warped trail
#

everything is alright you can use them outside that window๐Ÿ˜…

south falcon
#

ParallelFor jobs can be only scheduled on Main Thread?

#

aren't they?

#

Can I schedule a parallelFor job to create multiple IJob?

#

Another question is whether is Entities.ForEach a parallelFor job?

zenith wyvern
#

IJobParallelFor jobs don't run on the main thread unless you call them with .Run

south falcon
#

IJobParallelFor jobs don't run on the main thread unless you call them with .Run
@zenith wyvern Thank you. Is parallelFor job only created on main thread?

zenith wyvern
#

Read the links

south falcon
#

ok, thank you

round summit
#
public class BadTests : MonoBehaviour
{
    public GameObject prefabGO;
    // Start is called before the first frame update

    GameObjectConversionSettings settings;
    Entity prefabEntity;
    EntityManager entityManager;

    void Start()
    {

        // Create entity prefab from the game object hierarchy once
        settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore()); // error here if i use null instead of new BlobAssetStore, i don't know why?
        prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(prefabGO, settings);
        entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        int CountX = 100;
        int CountY = 100;

        for (var x = 0; x < CountX; x++)
        {
            for (var y = 0; y < CountY; y++)
            {
                // Efficiently instantiate a bunch of entities from the already converted entity prefab
                var instance = entityManager.Instantiate(prefabEntity);

                Debug.Log(x + ", " + y);
                // Place the instantiated entity in a grid with some noise
                var position = (new float3(x * 1.3F, y * 1.3F, 0.0F)); 
                entityManager.SetComponentData(instance, new Translation { Value = position }); // positions are not set
            }
        }
    }
}```
"Prefab" only has mesh renderer + filter
This code is almost the same as the example entity instantiation code

My instantiated entities always end up having same pos in my screen at 0,0,0
But in entity debugger, i see their transforms having different values?

What is going on you think?
warped trail
#

translation is changing but LocalToWorld is not?

round summit
#

give me a sec, i broke something

warped trail
#

translation is applied to LocalToWorld in TRSToLocalToWorldSystem which updated in SimulationSystemGroup

#

try setting LocalToWorld in your script

round summit
#

yeah, that works
interesting

#

what's the purpose of Translation and rotation component then?

#

Are they supposed to be their parent's transform info?

#

Translation is just for translating in local space?

#

Like a tag* component?

warped trail
#

it is more convenient and performant to work with float3 and quaternion than with 3 float4x4 matrices ๐Ÿ˜…

round summit
#

hmm

#

i would expect a 4x4 transform matrix and some extension methods to access it as quaternion rot, translate vec and scale vec

#

so this is just duplicate info

warped trail
#

i think you can do this if you want๐Ÿคทโ€โ™‚๏ธ

round summit
#

yeah thats what i'll do

warped trail
#

oh, but physics use translation and rotation components, not LocalToWorld๐Ÿ˜ฌ

amber flicker
#

I'd recommend working with Translation, Rotation & Scale when possible and understand the sequencing/timing of when they're resolved to LTW - otherwise at some point you may find your LTW just gets overridden by something else

south falcon
#

Does that AddComponent override the data in the entity which already has the same type of componentData?

opaque ledge
#

Yes

#

For me setting Translation directly works, i never had to work with LocalToWorld for spawning position ๐Ÿค”

warped trail
#

and you never experienced instantiated object at world origin for 1 frame?๐Ÿ˜

opaque ledge
#

i used to, but i am using BeginSim command buffer for that now, i think problem is gone after that ๐Ÿค”

mint iron
#

you just have to make sure your systems run before unitys group that updates the transforms. [UpdateBefore(typeof(TransformSystemGroup))]

#

it would be nice if unitys group sorting took this into account automatically, cause right now pretty much everyone hits the issue at some point

opaque ledge
#

@mint iron i watched the video you sent the other day, and i wanted to conduct an experiment for false sharing

#

i wrote this test code:

#
public struct TestIncrementStruct : IBufferElementData
{
    public int Value;
}

        if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.D)) useOptimized = !useOptimized;

        if (useOptimized)
        {
            Entities.ForEach((ref DynamicBuffer<TestIncrementStruct> test) => {
                var array1 = test.ToNativeArray(Allocator.Temp);
                var intArray1 = array1.Reinterpret<int>();

                for (int i = 0; i < intArray1.Length; i++)
                {
                    intArray1[i]++;
                }
                test.Clear();
                test.AddRange(array1);
            }).WithoutBurst().Schedule();
        }
        else
        {
            Entities.ForEach((ref DynamicBuffer<TestIncrementStruct> test) => {
                var intArray1 = test.Reinterpret<int>();
                for (int i = 0; i < intArray1.Length; i++)
                {
                    intArray1[i]++;
                }
            }).WithoutBurst().Schedule();
        }```
low oasis
#

Why is the VS Code 1.1.4 plugin still an option when it doesn't work generate projects correctly? No namespaces for any of the new DOTS plugins.

opaque ledge
#

when optimized its like 15 ms(on 500k array size) when its not its taking 130 ms ๐Ÿ˜„

#

ofc this probably wont apply to any real life situation but it is nice knowing this

#

tho i guess Burst already takes cares of the stuff for us but still, kinda amazing to see

#

Even in Burst it affects, for 10m size, in unoptimized its 2-3 ms, in optimized its 0.04 ๐Ÿ˜„

scarlet inlet
#

Hello again, I want to throw an exception if a JobHandle is default(JobHandle) or equal to another JobHandle

#

is the only way to do so checking if two jobhandles have the same bits?

#

because == doesn't work

coarse turtle
#

Hmm I'm wondering if they an implementation of .Equals(JobHandle other)

opaque ledge
#

i never tried but perhaps you can wrap it to a struct and give each struct a unique id

#

not according to here

scarlet inlet
#

Equals is the automatic generated one

#

which boxes because converts to object

coarse turtle
#

Yeah that's no good ๐Ÿค”

scarlet inlet
#

Need to leave, I'll try to find a solution tomorrow

round summit
#

Can i debug and detect some "probably infinite loop" in my ecs stuff?

#

I think there is an infinite loop occuring in my simulation system group

#

(i have some other systems added to that group as well)

#

Could i have created a deadlock in dependencies?
I barely touched the system group:(

worldly pulsar
#

The system dependencies will error if you have a cycle

round summit
#

Oh god , my stack tracer is tracing some serious stack

#

I'm glad this isn't such a thing then

worldly pulsar
#

and it's afaik impossible to create a cycle of jobs given the current API

opaque ledge
#

Yeah, as long as your JobDebugger is enabled

#

but not sure what happens if you have an infinite loop in inside of your job

worldly pulsar
#

it will wait forever on Complete()

round summit
#

I found out that i was forcing the SimulationSystemGroup to update 3k times

#

by luck

#

but hm

#

I breakpoint the loop that's causing it but it doesn't stop at the breakpoint

opaque ledge
#

you can do Debug.Log in all of your jobs and just observe before crash, its a poor man's way tho ๐Ÿ˜„

#

but i guess you manually update your systems yes ? maybe there is a problem in your logic

round summit
#

I'll just randomly breakpoint simulation system group stuff i guess

#

yeah i do manually update my simualtion system group + a couple systems in that group

#

I can stop the debugger and switch between threads
But i can't see stack trace in any of them

#

Hmm, i can actually see some
I need to see the main thread though (only that one will make sense to me)

mint iron
#

I breakpoint the loop that's causing it but it doesn't stop at the breakpoint
made sure burst is turned off and job debugger is on?

naive parrot
#

how do i use a NativeMultiHashMap exactly?

#

doin something like this throws this error : ```ArgumentException: Unity.Collections.NativeArray1[System.Int32] used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer Unity.Collections.CollectionHelper.CheckIsUnmanaged[T] () (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/CollectionHelper.cs:124) Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData.IsBlittableAndThrow[TKey,TValue] () (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:72) Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData.AllocateHashMap[TKey,TValue] (System.Int32 length, System.Int32 bucketLength, Unity.Collections.Allocator label, Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData*& outBuf) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:80) Unity.Collections.LowLevel.Unsafe.UnsafeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:1097)
Unity.Collections.NativeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/NativeHashMap.cs:499) Unity.Collections.NativeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/NativeHashMap.cs:493)
Sense.MotionEngine.MotionEngine..ctor (Sense.MotionEngine.MotionEngine+Configuration configuration) (at Assets/Sense/Motion Engine/Common/MotionEngine.cs:64)
MotionEngineManager.Awake () (at Assets/Sense/Motion Engine/Common/MotionEngineManager.cs:30)

worldly pulsar
#

can't put NativeArray into a NativeHashmap

#

all the Native* collections are not blittable

round summit
#

Burst is off but it's still creating worker threads
Maybe there's a way to have ecs work on a single thread for debug purposes.
I'll have to look at it tomorrow
@xzjv#1282

warped trail
#

maybe you can set them to 1๐Ÿค”

naive parrot
#

i got it off here , no clue still how is NativeMultiHaspMap is supposed to work

#

how do i add multiple values to a single key?

#

referred to this , still don't see any method that specifically adds new values to an existing key

#

all i want is an array of array sort of native container

#

after some research , i was lead to NativeMultihashmap

bright sentinel
#

@naive parrot I haven't worked with NativeMultiHashMap, but considering that there is nothing named NativeHashMap, I'm assuming the NativeMultiHashMap is just like a normal hashmap

#

Oh wait

#

The search is just broken

#

Oops

worldly pulsar
#

there is a NativeHashMap

bright sentinel
#

yayaya

warped trail
#

you can look at boid sample

#

they use NativeMultiHashMap there

naive parrot
#

will take a look

worldly pulsar
#

in NativeMultiHashMap you can do:
hashmap.Add(1, 1);
hashmap.Add(1, 2);
and there will be 2 records in it for the key 1. Normal hashmaps are 1 key - 1 value. Haven't used it since forever tho so don't remember the API.

zenith wyvern
#

Keep in mind NMHM is slow as hell if you abuse it. Check the boids sample to see a good example of how to use it with jobs

bright sentinel
#

Ah, so it's basically a way to store lists in a hashmap

worldly pulsar
#

I'm not sure if the order is guaranteed

naive parrot
#

"Add an element with the specified key and value into the container. If the key already exist an ArgumentException will be thrown."

#

If the key already exist an ArgumentException will be thrown.???

worldly pulsar
#

Uh, was there another method for adding more values at the same key? Again, haven't used it for ages.

zenith wyvern
#

Square bracket operator

warped trail
naive parrot
#

thanks , checking

#

i was wondering if there jobs friendly animationcurve or something that can be evaluated inside jobs

#

have checked this thread but nothing concrete

#

additionally am not working with ECS , only Jobs, so the BlobArray being mentioned there is probably not applicable either

warped trail
worldly pulsar
warped trail
#

i'm testing this code right now, and i'm not getting this results๐Ÿ˜•

worldly pulsar
#

I'm testing with Burst and Run()

warped trail
#

maybe because im doing it with testrunner๐Ÿค”

worldly pulsar
#

class TestSystem2 : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((DynamicBuffer<TestIncrementStruct> test) =>
        {
            var intArray1 = test.AsNativeArray().Reinterpret<int>();
            int len = intArray1.Length;
            for (int i = 0; i < len; i++)
            {
                intArray1[i] = intArray1[i] + 1;
            }
        }).Run();
    }
}


class TestSystem3 : SystemBase
{
    protected override void OnUpdate()
    {
        Entities.ForEach((DynamicBuffer<TestIncrementStruct> test) =>
        {
            var intArray1 = test.Reinterpret<int>();
            int len = intArray1.Length;
            for (int i = 0; i < len; i++)
            {
                intArray1[i] = intArray1[i] + 1;
            }
        }).Run();
    }
}

Test3 runs in 22ms, Test2 in <5ms

opaque ledge
#

its better to do AsNativeArray then ? @worldly pulsar when working on dynamic buffer ?

#

@zenith wyvern in what way NMHM is slow exactly ?

zenith wyvern
#

It's anecdotal but it was my experience that NMHM operations just didn't scale well. I can't explain why because I didn't perform extensive profiling but I've heard similar from other people who use it. As far as I know NativeStream is much faster, but a bit more complicated to use

opaque ledge
#

Hmm i see

zenith wyvern
#

Heh, I just spent 20min figuring out why in the piece of code @opaque ledge posted here:
https://discordapp.com/channels/489222168727519232/497874303463850004/684092062445862912
it is 3x faster to alloc a new array, memcpy the buffer into it, work on the copy, and then memcpy back into the buffer...
Answer - because writing to a dynamic buffer is way slower than writing to a NativeArray due to the "are we in chunk" check.
@worldly pulsar

Can you do buffer.AsNativeArray() to get by the check?

worldly pulsar
#

There is a test if the "out of chunk" ptr is not null, and Burst compiles it to a cmov instruction which kills performance when the inner loop is heavy on DynamicBuffer writes. So yeah, I'd say pretty much always use .AsNativeArray() for DynamicBuffers

zenith wyvern
#

Good to know

warped trail
#

are you using a lot of elements in this buffer?๐Ÿค”

worldly pulsar
#

yeah, 100 buffers of 100k ints each

#

for a lot of very small DynBuffers the difference will probably be overshadowed by the entity iteration overhead (in this very trivial example)

#

yep, 10 element buffers are pretty much the same speed, but at 100 ints/buffer there is already a 3x difference

mint iron
#

thats super interesting guys, i wouldn't have thought dynamic buffers so much slower.

coarse turtle
#

hmm what if you use a readonly ptr ๐Ÿค”

#

I wonder how much of an impact it would have ๐Ÿค”

worldly pulsar
#

the loop generated for native array is about as fast as it can get:

.LBB1_12:                 
        inc        dword ptr [rax]
        add        rax, 4
        dec        rcx
        jne        .LBB1_12
#

(without integer simd which Burst doesn't do right now)

mint iron
#

what about if you stackalloc instead of temp nativearray

worldly pulsar
#

but why would you alloc anything? AsNativeArray doesn't alloc, it just turns a DynamicBuffer into a NativeArray (essentially a pointer wrapper)

zenith wyvern
#

AsNativeArray isn't causing any overhead

#

There's no reason not to do it since native arrays are super fast

warped trail
#
var tempArr = test.AsNativeArray();
var len = tempArr.Length;
var A = new int4(0);
for (int i = 0; i < len; i += 4)
{
  A = tempArr.ReinterpretLoad<int4>(i);
  A++;
  tempArr.ReinterpretStore<int4>(i, A);
}``` is this a valid code?๐Ÿ˜…
mint iron
#

ahh, i was looking at the ToNativeArray one

formal scaffold
#

Hey I'm trying to understand how archetypes are formed. And I understand the basics of it. But reading through this article
https://blogs.unity3d.com/2019/11/27/creating-a-third-person-zombie-shooter-with-dots/
the following line implies that you can create an archetype and add more components to it.

"The project uses prefabs for defining archetypes since there are more components needed for the enemies and some of them need references to GameObjects"

But won't adding components to an Entity change the archetype of that entity? Also the thing about defining archetypes with prefabs. A prefab uses a set of components and therefore defines an archetype. Or do they mean that during instantiation the EntityManager implicitly creates an archetype for them and therefore the prefab defines the archetype ๐Ÿค”

Unity Technologies Blog

Weโ€™re rebuilding the core of Unity with our Data-Oriented Tech Stack, and many game studios are already seeing massive performance wins when using the Enti...

zenith wyvern
#

An archetype is just a set of component types. If you create two separate archetypes but both have the same set of component types, they are equal

#

So yeah, if you add a component to an entity it changes it's archetype, period

mint iron
#

in you case of adding a component to an entity. they find/create an archetype with the new set of components, and copy the entity, and every component it has >> to the new archetype.

warped trail
#

if you create archetype, does it automatically preallocate chunk, or chunks are allocated the moment you create entity of this archetype?

formal scaffold
#

Mhm so in this case they use a prefab so they can store references better thats all they are saying with that line. And that the prefab they created defines the archetype for them. Meaning they don't explicitly create the archetype in code, they just instantiate their prefab.

zenith wyvern
#

Only when you create the entity as far as I know

formal scaffold
#

Sorry language is not my strong point. I struggle all the time with what seems basic understanding of sentences

warped trail
#

by creating first entity you basically create whole chunk?๐Ÿค”

zenith wyvern
#

You got it right Swift, they're basically just describing what the conversion system is now with [GenerateAuthoringComponent]. The conversion system wasn't around when that was written

#

Or if it was they should have been using it because it's exactly what they're describing

#

@warped trail Yes as far as I know that's how it works

formal scaffold
#

Okay nice good point to go to sleep thanks ๐Ÿ˜…

warped trail
#

this things doesn't have overhead too ReinterpretLoad<T>() ReinterpretStore<T>()?๐Ÿค”

mint iron
#

@warped trail yes, if an entity exists a chunk has to exist to contain it ๐Ÿ˜„ they keep around empty chunks that were previously allocated so if you had no entities they would re-use an inactive/empty chunk first rather than allocating a new one.

#

thats quite a difference

worldly pulsar
#

What are you comparing?

mint iron
#

test system2 and testsystem3 are the ones u posted

worldly pulsar
#

hmm, how many buffers/elements per buffer?

mint iron
#

mmm, maybe my test is bad.

class TestSystem1 : SystemBase
{
    protected override void OnCreate()
    {
        var arc = EntityManager.CreateArchetype(ComponentType.ReadWrite<TestIncrementStruct>());
        var entities = new NativeArray<Entity>(1000, Allocator.Persistent);
        EntityManager.CreateEntity(arc, entities);
    }
    protected override void OnUpdate() { }
}```
worldly pulsar
#

So your buffers are empty?

mint iron
#

yeah

warped trail
worldly pulsar
#

For 100k 1 elem buffers I get ~20% overhead from the .AsNativeArray() version, compared to ~300% overhead of writing to DynBuffer for 100 element/buffer.
Both of these would probably be small compared to whatever work the job was actually doing in a real world case.

fallow mason
#

Can anyone tell me why the name of a gameobject is retained and applied to its entity counterpart when I use ConvertToEntity, but not when I use subscenes?

#

Even when I try to force it with this component: ```using UnityEngine;
using Unity.Entities;

public class NameAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{

public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
    dstManager.SetName(entity, gameObject.name);
}

}```

round summit
#

Can i call .Compete() on simation system groups update()?
I am the one who calls the update

#

I mean, can i wait for it to finish in monobehaviour?

opaque ledge
#

You are trying so many exotic things Bargos ๐Ÿ˜„

#

or i am doing simple stuff ๐Ÿค”

gusty comet
#

Hello, quick question, why the scale struct has only float value param? How do you manage to scale X and Y differently (with an AddComponentData) ?

solar spire
#

There is a NonUniformScale component

gusty comet
#

@solar spire that's perfect, thanks

dull copper
#
## [Burst 1.3.0-preview.4] - 2020-03-02

### Added
- Debug information for types
- Debug information for local variables
- Debug information for function parameters
- Support for `fixed` statements. These are useful when interacting with `fixed` buffers in structs, to get at the pointer data underneath.
- A fast-math optimization for comparisons that benefits the [BurstBenchmarks](https://github.com/nxrighthere/BurstBenchmarks) that [nxrightthere](https://forum.unity.com/members/nxrighthere.568489/) has put together.
- DOTS Runtime Jobs will now generate both `MarshalToBurst` and `MarshalFromBurst` functions when job structs in .Net builds are not blittable.
- DOTS Runtime Job Marshalling generation is now controllable via the commandline switch `--generate-job-marshalling-methods`.

### Removed

### Changed
- Made it clear that the Burst aliasing intrinsics are tied to optimizations being enabled for a compilation.
- Restore unwind information for all builds
- Print a info message if compiling a function pointer with missing MonoPInvokeCallback attribute (this can lead to runtime issues on IL2CPP with Burst disabled). The message will be converted to a warning in future releases
#
### Fixed
- Fixed an issue where DOTS Runtime generated job marshalling functiosn may throw a `FieldAccessException` when scheduling private and internal job structs.
- Fix a bug that prevented entry point method names (and their declaring type names) from having a leading underscore
- vector/array/pointer debug data now utilizes the correct size information
- DOTS Runtime will now only generate job marshaling functions on Windows, as all other platforms rely on Mono which does not require job marshalling.
- `ldobj` / `stobj` of large structs being copied to stack-allocated variables could cause compile-time explosions that appeared to the user like the compiler had hung. Worked around these by turning them into memcpy's underneath in LLVM.
- Don't always use latest tool chain on certain platforms.
- Fix a crash when compiling job or function pointer that was previously cached, then unloaded, then reloaded
- Fixed compiler error in array element access when index type is not `Int32`
- Fix `set1_xxx` style x86 intrinsics generated compile time errors

### Known Issues
- Native debugger feature is only available on windows host platform at the moment.```
#

heh, that last change for printing info messages about mono invoke now spams console full with latest entities package

worldly pulsar
#

DOTS Runtime Jobs will now generate both 'MarshalToBurst' and 'MarshalFromBurst' functions when job structs in .Net builds are not blittable
Any info on what those are?

dull copper
#
## [Entities 0.7.0] - 2020-03-03

### Added

* Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class.  These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
* `SubScene` support for hybrid components, allowing Editor LiveLink (Player LiveLink is not supported yet).

### Changed

* Fixed an issue where shared component filtering could be broken until the shared component data is manually set/added when using a deserialized world.
* Users can control the update behaviour of a `ComponentSystemGroup` via an update callback.  See the documentation for `ComponentSystemGroup.UpdateCallback`, as well as examples in `FixedRateUtils`.
* `IDisposable` and `ICloneable` are now supported on managed components.
* `World` now exposes a `Flags` field allowing the editor to improve how it filters world to show in various tooling windows.
* `World.Systems` is now a read only collection that does not allocate managed memory while being iterated over.
* Updated package `com.unity.platforms` to version `0.2.1-preview.4`.

### Deprecated

* Property `World.AllWorlds` is now replaced by `World.All` which now returns a read only collection that does not allocate managed memory while being iterated over.
#
### Removed

* Removed expired API `implicit operator GameObjectConversionSettings(World)`
* Removed expired API `implicit operator GameObjectConversionSettings(Hash128)`
* Removed expired API `implicit operator GameObjectConversionSettings(UnityEditor.GUID)`
* Removed expired API `TimeData.deltaTime`
* Removed expired API `TimeData.time`
* Removed expired API `TimeData.timeSinceLevelLoad`
* Removed expired API `TimeData.captureFramerate`
* Removed expired API `TimeData.fixedTime`
* Removed expired API `TimeData.frameCount`
* Removed expired API `TimeData.timeScale`
* Removed expired API `TimeData.unscaledTime`
* Removed expired API `TimeData.captureDeltaTime`
* Removed expired API `TimeData.fixedUnscaledTime`
* Removed expired API `TimeData.maximumDeltaTime`
* Removed expired API `TimeData.realtimeSinceStartup`
* Removed expired API `TimeData.renderedFrameCount`
* Removed expired API `TimeData.smoothDeltaTime`
* Removed expired API `TimeData.unscaledDeltaTime`
* Removed expired API `TimeData.fixedUnscaledDeltaTime`
* Removed expired API `TimeData.maximumParticleDeltaTime`
* Removed expired API `TimeData.inFixedTimeStep`
* Removed expired API `ComponentSystemBase.OnCreateManager()`
* Removed expired API `ComponentSystemBase.OnDestroyManager()`
* Removed expired API `ConverterVersionAttribute(int)`
#
### Fixed

* Non-moving children in transform hierarchies no longer trigger transform system updates.
* Fixed a bug where dynamic buffer components would sometimes leak during live link.
* Fixed crash that would occur if only method in a module was generated from a `[GenerateAuthoringComponent]` type.
* `Entities.ForEach` now throws a correct error message when it is used with a delegate stored in a variable, field or returned from a method.
* Fix IL2CPP compilation error with `Entities.ForEach` that uses a tag component and `WithStructuralChanges`.
* `Entities.ForEach` now marshals lambda parameters for DOTS Runtime when the lambda is burst compiled and has collection checks enabled. Previously using `EntityCommandBuffer` or other types with a `DisposeSentinel` field as part of your lambda function (when using DOTS Runtime) may have resulted in memory access violation.
* Throw correct error message if accessing `ToComponentDataArrayAsync` `CopyFromComponentDataArray` or `CopyFromComponentDataArrayAsync` from an unrelated query.
#

hybrid update is just dependency upgrade

#
## [Collections 0.6.0] - 2020-03-03

### Added

 * Added ability to dispose `UnsafeAppendBuffer` from a `DisposeJob`.

### Changed

 * `UnsafeAppendBuffer` field `Size` renamed to `Length`.
 * Removed `[BurstDiscard]` from all validation check functions. Validation will
   be present in code compiled with Burst.

### Removed

* Removed expired overloads for `NativeStream.ScheduleConstruct` without explicit allocators.

### Fixed

 * Fixed `UnsafeBitArray` out-of-bounds access.
coarse turtle
#

ah cool - thanks for posting this @dull copper

dull copper
#
## [Jobs 0.2.6] - 2020-03-03

### Changed

* Updated dependencies of this package.
* Maintain JobsDebugger menu item value between sessions.
opaque ledge
#

Olento at it again ๐Ÿ‘€

#

and yeah, thanks^^

dull copper
#

np

formal scaffold
#

So much stuff I still don't understand ๐Ÿง gotta keep learning

zenith wyvern
#
Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class.  These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
#

Interesting

opaque ledge
#

yeah was about to say

zenith wyvern
#

I love these save-us-from-the-boilerplate changes

#

I hope we get something like that for command buffers too

formal scaffold
#

Anyone knows what the TRS in float4x4.TRS(..) stands for?

#

Transform?

coarse turtle
#

translation

#

rotation, scale

dull copper
#

getting bunch of these now even with the latest drop:
The method `Void RunWithoutJobSystem(Unity.Entities.ArchetypeChunkIterator*, Void*)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!

#

it's from the burst change

opaque ledge
#

yep

#

i wonder if accessing same component type from GetComponent and ForEach still gives an alias error ๐Ÿค”

vagrant surge
#
* Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class.  These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
* `SubScene` support for hybrid components, allowing Editor LiveLink (Player LiveLink is not supported yet).
#

first one is absolutely huge

#

second one what exactly is it about?

#

like you can edit entities in the editor at last?

formal scaffold
#

Is this type of query still being used ```cs
var query = new EntityQueryDesc
{
All = new[]{
typeof(Transform),
ComponentType.ReadOnly<Velocity>()
},
};

Or did Entities.ForEach replace it? Or am I missunderstanding how Job's work?
zenith wyvern
#

ForEach generates it's own query, but there are still plenty of reasons you might need to create your own query manually

formal scaffold
#

Such as? If I need it twice maybe?

zenith wyvern
#

Like if you have a system that you only want to run when a certain component exists. You create a query for that component and pass it to RequireForUpdate in OnCreate

#

Or if you need to access any component or entity that's not a part of the entities you're querying in your ForEach

#

Or a million other reasons I'm sure

formal scaffold
#

Is OnCreate being called every frame if the System is not yet running? I know It's called once upon creation and after that OnUpdate() every frame

opaque ledge
#

Hmm, probably not, it only called once when its created, and perhaps multiple time for each creating for a world

formal scaffold
#

Oh really? Just a few hours ago it was still at 0.1 was it not? I was reading through it during break at work

zenith wyvern
#

No, 0.1 was like last year. It's been updates almost monthly. Unfortunately google always points to the old version.

warped trail
#

i can update systemgroups in fixed steps without editing package code๐Ÿฅณ

formal scaffold
#

Gosh really ๐Ÿ˜… at least I still learned alot, been reading 0.1

zenith wyvern
warped trail
#

now i wonder when we will see new entity debugger?๐Ÿค”

zenith wyvern
dull copper
#

@formal scaffold these are also in the pinned message on this channel

formal scaffold
#

Is it possible to rotate an entity without a Rotation component? Trying to understand the zombie shooter with DOTS video on youtube. They use a single float for the rotation of their Zombies plus two floats for the position. But how does Unity know how to rotate the Zombie with just this one float? Don't you need a Rotation component for that?

warped trail
#

maybe they use custom transform system?

opaque ledge
#

maybe they are rotating only 1 axis ?

warped trail
#
[WriteGroup(typeof(LocalToWorld))]
struct PositionAndRotation: IComponentData
{
  public float2 Position;
  public float Rotation;
}``` this and some simple system is everything you need basically ๐Ÿค”
formal scaffold
#

Yes they do since they program a 2D game so one float is only being changed. But so far I have been rotating my Rotation component all the time

opaque ledge
#

thats what they are doing as well probably

formal scaffold
#

In order to rotate I need a LTW on my Entity?

warped trail
#

LTW is for rendering system

opaque ledge
#

i think you still need LTW ๐Ÿค”

#

Anyone got these errors after upgrading to Entities 0.7 ?

warped trail
#

TRSSystem in simple case is doing this cs localToWorld = new LocalToWorld { Value = float4x4.TRS(translation.Value, rotation.Value, scale.Value) }

#

you can overwrite TRSSystem if you don't need float3 for position and quaternion for rotation

formal scaffold
#

Let's say I do that won't I have to change the rendering system aswell? What you said earlier seems to imply that the rendering system relies on LTW

warped trail
#

if you don't need scale you basically need translation and rotation matrix, i think๐Ÿค”

#

yes Hybrid Renderer relies on LTW

#

it does not matter how you will get this LTW๐Ÿ˜…

#

LTW is 4x4 matrix

formal scaffold
#

I get it now.

  • Use custom position + rotation and use Systems to work with those
  • Overwrite TRSToLocalToWorldSystem to use my custom position + rotation to create a LTW
warped trail
#

not create, but write to LTW

#

in simple naive approach you just create translation and rotation matricies, multiply them and write result to LTW

#

cos, sin and one 4x4 matrix multiplication๐Ÿ˜…

formal scaffold
#

LTW fields are ReadOnly tho.
Can't I just set the values? I have them already. Something like LTW.Rotation = quaternion(...)

warped trail
#

no๐Ÿ˜…

#

just use float4x4.TRS then for simplicity

fallow mason
#

Can anyone tell me why the name of a gameobject is retained and applied to its entity counterpart when I use ConvertToEntity, but not when I use subscenes?

warm panther
#

Re: Entity Conversions, I have an entity that changes materials based on a sharedcomponentdata (basically which faction they belong to); where do I start setting this up in IConvertGameObjectToEntity (or elsewhere) for a prefab Archetype that can then be used by spawners?

warm panther
#

The materials are set on renderers in various child objects, so it's probably not trivial to set it again easily after conversion.

warped trail
#
var renderMesh= EntityManager.GetSharedComponentData<RenderMesh>(entity);
renderMesh.material = material;
EntityManager.SetSharedComponent<RenderMesh>(entity,renderMesh);```
#

you have to do this on main thread

warm panther
#

Yeahhh that's what I'm doing right now. But...

warped trail
#

i think there is something with MaterialPropertyBlock in HDRP, but im not using HDRP๐Ÿคทโ€โ™‚๏ธ

warm panther
#

This is what my prefab is actually shaped like. Meaning all those renderers need their materials changed.

#

(admittedly this is one of the larger ships but it's not uncommon to have ~20 turrets etc)

#

I'm thinking giving each of these an allegiance field as well, meaning their renderers will just figure it out at runtime. It would also help with simplifying damage attribution.

#

The thing isn't per se setting these in Convert(), the thing is setting these in or after

                (Entity entity, ref Spawner spawner, ref Translation translation, ref Rotation rotation) =>
                {
                    while (spawner.timer <= 0)
                    {
                        spawner.count--;
                        spawner.timer += spawner.seconds;

                        var e = buf.Instantiate(spawner.prefab);
                        buf.SetComponent(e, new Translation {Value = translation.Value + (float3) Random.insideUnitSphere * spawner.radius});

                        if (spawner.count <= 0)
                        {
                            buf.DestroyEntity(entity);
                            return;
                        }
                    }

                    spawner.timer -= dt;
                });
#

Because I basically never place any of these by hand, anywhere. ๐Ÿ™‚

#

(spawner.prefab is type Entity)

#

Problem is, that entity is the representation of what the Battleship prefab was. IDeclareReferencedPrefabs

#

It doesn't "know" much about its ability to change colors or materials, and even if it did, it would have to agree on at least one right there.

#

(out of ~5 to 8 material variants, spread across 2 materials per vessel)

#

I'll look into what ConversionSystem has to offer me.

#

Problem is, conversion happens once for each spawner. Since they refer the same prefab, that gets frozen in whatever state it was converted into.

warped trail
#

Has anyone tried FixedRateUtils?

round summit
#

Can i not have rotations constraints in inspector with dots?
In physics bodies

warped trail
#

i'm afraid you have to use joints for that๐Ÿ˜•

round summit
#

hmm

#

Didn't understand what was going on until i put some some renderers on my characters' physics capsules lmao

opaque ledge
#

๐Ÿ˜„

#

nice

#

Also, new Get/Has/Set doesnt have Buffer versions ๐Ÿ˜’

warm panther
#

Huh.

#

/// Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
/// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.

#

So how would rendermesh work then? OR anything, really.

#

I smell pointers.

#

Those are blittable ๐Ÿ˜„

#

void pointers, preferrably. always void pointers.

opaque ledge
#

perhaps they will make ECS version of material ?

naive parrot
#
Unity.Jobs.LowLevel.Unsafe.JobsUtility.CreateJobReflectionData (System.Type type, Unity.Jobs.LowLevel.Unsafe.JobType jobType, System.Object managedJobFunction0, System.Object managedJobFunction1, System.Object managedJobFunction2) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Initialize () (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Jobs.IJobParallelForExtensions.Run[T] (T jobData, System.Int32 arrayLength) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Sense.MotionEngine.MotionEngine.Update () (at Assets/Sense/Motion Engine/Common/MotionEngine.cs:175)
MotionEngineManager.Update () (at Assets/Sense/Motion Engine/Common/MotionEngineManager.cs:58)```
#

getting this trying to write to a [WriteOnly] NativeList in IJobParallelFor

#

was checking how to do concurrent write with NativeQueue , NativeHashMap to no resolve

#

not sure how to use .Concurrent variants or the ParallelWriter

#

any hints?

zenith wyvern
#

/// Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
/// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
@warm panther

Where did you see this? Considering the hybrid renderer uses SCD with Meshes and Materials I'm not sure how that would work

coarse turtle
#

maybe a comment in the source code?

zenith wyvern
#

@naive parrot Pass the list to the job as a NativeArray

warm panther
#

Bull.

#

I forgot where I copied this from, but it was from Entities 0.6.0

#

As in, clicking into the decompiled source

#

literally the generated doc for ISharedComponentData

zenith wyvern
#

Huh. I'm trying to think of what the implications of that are. I guess pointers like you say, with some kind of safety wrapper

warm panther
#

IComponentData.cs

#
 // [TODO: Document shared components with Jobs...]
    /// <summary>
    /// An interface for a component type whose value is shared by all entities in the same chunk.
    /// </summary>
    /// <remarks>ISharedComponentData implementations are subject to the same constraints as
    /// <see cref="IComponentData"/>.
    ///
    /// ISharedComponent implementations must implement <see cref="IEquatable{T}"/> and <see cref="Object.GetHashCode"/>.
    ///
    /// *Note:* Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
    /// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
    ///
    /// When you add a shared component to an <see cref="EntityArchetype"/>, ECS stores entities assigned the same
    /// values of that shared component in the same chunks. Thus, shared components further categorize entities within
    /// the same archetype. Use shared components when many entities share the same data values and it is more efficient
    /// to process all the entities of a given value together. For example, the `RenderMesh` shared component (in the
    /// Hybrid.Rendering package) defines a set of fields whose values can be shared by many 3D objects. Since all the
    /// entities with the same values for the RenderMesh fields are stored in the same chunks, the renderer can
    /// efficiently batch the draw calls for those entities based on the shared values.
#
    /// You must set the value of a shared component on the main thread using either the <see cref="EntityManager"/>
    /// or an <see cref="EntityCommandBuffer"/>. When you change a shared component value, the affected entity is
    /// moved to a different chunk. If a chunk already exists with the same values, and has enough room, the entity is moved
    /// to that chunk. Otherwise, a new chunk is allocated. Changing a shared component value is a structural change that
    /// potentially creates a sync-point in your application.
    ///
    /// You can find entities with a particular type of shared component using either <see cref="EntityQuery"/> or
    /// <see cref="EntityQueryBuilder"/> in the same way you select entities with specific types of <see cref="IComponentData"/>.
    /// You can also filter an entity query to select only entities with a specific shared component value using
    /// <see cref="EntityQuery.SetSharedComponentFilter{SharedComponent1}"/>. You can filter based on two different shared components.
    /// (EntityQueryBuilder does not support filtering queries by shared component value.)
    ///
    /// Avoid too many shared components and values on the same archetype. Since each combination of values, whether in the
    /// same component type or in different shared components, is stored in different chunks, too many combinations can
    /// lead to poor chunk utilization. Use the Entity Debugger window in the Unity Editor
    /// (menu: *Window* > *Analysis* > *Entity Debugger*) to monitor chunk utilization.
    ///
    /// See [Shared Component Data](xref:ecs-shared-component-data) for additional information.
    /// </remarks>
    public interface ISharedComponentData
    {
    }
#

Of course that might be out of date.

zenith wyvern
#

It would sure be nice if we got those comments through the IDE

warm panther
#

Yeh

zenith wyvern
#

The 0.7 docs say the same thing

warm panther
#

there's a 0.7 ๐Ÿ˜ฎ

#

me want.

warm panther
#

Aww yis.

warped trail
#

i guess there is bug in FixedRateUtils or i'm using it in the wrong way ๐Ÿ˜•

coarse turtle
#

hmm if they change ISCD to blittable types only

#

is a difference between ISCD and chunk component datas ๐Ÿค”

#

I suppose ISCD allows you to do filtering that you may not have in chunk component datas

warm panther
#

hmmm the new burst / entities package doesn't like Unity Physics that much.

(0,0): Burst error BC1040: Loading from a non-readonly static field `Unity.Collections.LowLevel.Unsafe.UnsafeUtility.IsUnmanagedCache`1<int>.value` is not supported
#

Actually the package isn't updating properly

#

I'll investigate

#

Certainly doesn't crash less ^^

opaque ledge
#

for me, it says its from JobParallelDefer from jobs package

#

it doesnt do anything harmful tho it as far as i can tell

warped trail
#

everything fine in my project๐Ÿค”

naive parrot
#

@zenith wyvern thanx , that worked!

hollow sorrel
#

@round summit nice feature
they're all in their own canoe

#

all you need now is add some waterfalls

warm panther
#

Trying burst 1.2.3 instead of 1.3.0 preview now...

#

Same

#

Omg the 2020.1 UI scaling feature โค๏ธ

#

I can finally read shit in the entity debugger

#

But my 3440x1440 screen isn't big enough.

opaque ledge
#

now you can have properly scaled crash screen ๐Ÿ‘€

#

jokes aside, there are some cases that simply crashes me some random some not

fallow mason
#

I'm not doing anything complicated, but seems to be stable for me

#

had one system that started erroring about the way I was using an ecb

#

InvalidOperationException: TurnJob.Data.cmdBuffer is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.

amber flicker
#

@warm panther I can easily crash the editor with too many debug logs in a job, even with burst disabled and independent of project/machine - donโ€™t know if anyone else has experienced the same?

alpine abyss
#

Is this the channel to ask questions about C# Jobs?

solar spire
#

Yes

slim nebula
#

I know this is super vague, but I'm trying to use NetCode with owner prediction on a cube and my cube is twitching. I'm modifying the physics velocity on it based on user input. Looking at the translation in ServerWorld shows the Translation is constant, but on the client the translation twitches a bit. changing from prediction to interpolation removes the twitching but obviously introduces latency. The twitching also occurs when there is no user input. What could be the culprit here? Where can I start looking?

#

maybe there's something else I should be modifying instead of PhysicsVelocity?

#

seems to be twitching forward in the direction of movement. increasing the send/recv delay amplifies the distance that it twitches

radiant sentinel
#

is Ecs support bones?

#

ECS HybridRendering

round summit
#
EntityManager.AddComponent<Constraint>(rb.entity); // no errors here?
Constraint constraint = new Constraint();
constraint.ConstrainedAxes = new bool3(x, y, z);
constraint.Type = ConstraintType.Angular;
EntityManager.SetComponentData(rb.entity, constraint); // error this line

Doesn't let me set constraint because Constraint is not IComponentData
How can i constraint the rigidbody?

warped trail
#

better look at UnityPhysicsSamples๐Ÿค”

opaque ledge
#

So i have this system that does 32 byte allocation every frame, but i couldnt find the reason why

warped trail
#

.WithName()?๐Ÿค”

opaque ledge
#

nah, i just added that 2 mins ago ๐Ÿ˜„

#

im going to try commenting out my code i think

warped trail
#

have you profiled it in standalone build?

opaque ledge
#

no, i have a potat pc that would take too much time ๐Ÿ˜„

warped trail
#

i have no idea than๐Ÿ˜…

zenith wyvern
#

If you enable deep profiling you can drill down to the actual allocating function

#

If you're in the editor it's probably disposesentinel

opaque ledge
#

Yep it was from dispose sentinel, thank you

dull copper
#

new tiny packages now too

remote coyote
slim nebula
#

is there some kind of debugger or trace logging that I can enable specifically for debugging NetCode prediction?

sick talon
#

is there any reference about ai in dots?. or anyone already tried ai planner with dots?

dull copper
#

isn't ai planner done in ecs?

#

like the actual core of it?

#

I haven't really looked more into it

#

I know ml agents is going to get dots support later on but it's not in their short term (3mo) roadmap

opaque ledge
#

i think you have to go hybrid

#

i wanted to try but yeah, so i am doing my own AI right now

stable fog
#

AI Planner isn't dots yet

#

"Currently, we don't support a pure DOTS solution, though it is on our pre-GDC roadmap. First, we need to move the game state data to ECS, then we'll need to build component systems to manage plan and action execution. It's going to be quite an undertaking, but we have a concrete idea of how this will look. We're just going to need the time to build it. "

dull copper
#

I didn't suggest it was, I just remembered it's core was done in ECS ๐Ÿ™‚ pretty much all the interfacing is still done through MB's

#

it currently depends on Entities 0.4

#

stuff like this will give you a dependency hell as you always have to upgrade packages yourself which Unity doesn't keep up-to-date

#

and you can't like mix older entities for one package and newer for some other ๐Ÿ˜„

slim nebula
#

what does "MB" mean in this context?

safe lintel
#

monobehaviour

slim nebula
#

my noob is showing

north bay
#

lol

round summit
#

So, i want to have ecs rigidbodies in my world (not parented to anything)
I want to be able to set their velocities, positions, rotations
From which conponent data i should modify these?
I changed transform related stuff in: LocalToWorld component data
I changed velocity here: PhysicsVelocity component data
And this is what i got

#

So it's completely broken

opaque ledge
#

imo, to change rotation and position change Rotation and Translation components, dont deal with LTW

warped trail
#

physics is using translation and rotation, ltw is basically for rendering๐Ÿค”

round summit
#

I see

warped trail
#

physics writes to translation ant rotation components in ExportPhysicsWorld

round summit
warped trail
#

TRSSystem takes translation and rotation and applies them to 4x4 matrix

round summit
#

I shoot arrow downwards, arrows hits and applies some force to capsule

#

Capsule gains some velocity

#

But that velocity seems to be in local space

#

Because my character drifts backwards relative to it's own space

#

Why do you think that's happening?

#

Could it be my fault?

fallow mason
#

no, don't say things like that. you're perfect.

warped trail
#

are your capsules rigid bodies?

opaque ledge
#

What is it you are expecting exactly ?

round summit
#

yes

#

I am costantly lerping velocity to zero with this interface:

public Vector3 Velocity { 
        get
        {
            return entityManager.GetComponentData<PhysicsVelocity>(entity).Linear;
        }
        set
        {
            PhysicsVelocity setVelocity = GetOrAddEntityComponent<PhysicsVelocity>();
            setVelocity.Linear = value;
            entityManager.SetComponentData(entity, setVelocity);
        }
    }
warped trail
#

unity physics does not support stacking, in my projects rigid bodies are always drifting ๐Ÿ˜…

fallow mason
#

creating arrows too close to capsule, colliders fighting?

round summit
#

Arrow should not have effect anymore after collision is ended i belive, no?

fallow mason
#

Can't tell by gif if the arrow collision is having a continued effect ๐Ÿคทโ€โ™‚๏ธ

#

is there continued velocity long after firing one arrow?

round summit
#

No, it's just a collision, arrow has no logic at all

#

It's not supposed to affect any longer after collision is done with

fallow mason
#

right, but that collision imparts an initial velocity to the player, no? if you don't want, you'd need to make sure the position you spawn the arrow didn't cause the colliders of both objects to intersect

opaque ledge
#

maybe its about mass and Friction ?

round summit
#

Behaviour is like this:
If a collision applies force on my character,
My character seem to have that force saved and added back every frame from now on

#

And the force is cleared after it has moved the character

#

to be added back again the next frame

#

(It's not force though it's just PhysicsVelocity.Linear set)

#

Does that make sense?

opaque ledge
#

well collision doesnt happen in 1 frame i think, so your collision job might be called multiple times

fallow mason
#

so it IS having a continued effect? I was asking because the gif seems to show it not

#

yeah, I'd say there is either another system writing to velocity or what curly said

round summit
#

There seems to be a constant velocity on character's local backwards axis yes
After the arrow has touched

#

Situation is the same after i collide with a different character too

#

both character sway in collision normal continiously (with constant speed) after
even though their velocities are lerped to 0 every frame

fallow mason
#

perhaps the lerping of the velocity to 0 is never letting the job reach its goal and finish?

#

hard to say for sure without the system code

round summit
#

My code is all in mono, i tried to port ecs physics into mono

#

It's basicly like this:

loop:
MyMonoStuffUpdate()
SystemSimulationGroup.Update()

warped trail
round summit
#

Hmm.
It gains speed for one frame, get's to apply it, then you set its velocity to zero and the cycle repeats
Probably this is happening?

#

I think thats normal?

warped trail
#

probably yes, before simulation velocity is zero, simulations advances and cube gains little velocity

opaque ledge
#

imo ? just put a Debug.Log for every possible situation, after that just check logs, thats how i find most of my errors

fallow mason
#

might need to [UpdateAfter]/[UpdateBefore] some system to make sure you apply velocity at right time?

#

before velocity is applied to LTW

round summit
#
I apply velocity in mono
SystemGroupUpdate
I apply velocity in mono
SystemGroupUpdate
I apply velocity in mono
.
.

Goes like this

warped trail
#

velocity is applied to translation

round summit
#

its "SimulationSystemGroup"

warped trail
#
I apply velocity in mono
SystemGroupUpdate
GetVelocity, translation - velocity
```๐Ÿ˜…
fallow mason
#

heh

warped trail
#

you have to revert any undesired change in translation after simulation๐Ÿ˜

round summit
#
MonoUpdate():
   I read velocity
   I lerp velocity to zero
   I set velocity back

SimulationSystemGroup.Update()

repeat

This is what i do

fallow mason
#

lerp happens over many frames though?

warped trail
#

your body gets velocity in simulation and translation+Velocity

round summit
#

one frame of mono = one frame of ecs physics

public void UpdateScene()
    {
        SimpleECSPhysics simpleECSPhysics = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<SimpleECSPhysics>();
        simpleECSPhysics.Simulate();

        for(int i = 0; i < syncedObjects.Length; i++)
        {
            SyncedObject syncedObject = syncedObjects[i];
            if (syncedObject != null)
            {
                syncedObject.SyncedUpdate(sceneTime);
            }
        }

        sceneTime += 1;
    }
#

simpleECSPhysics calls the simulation system group's update

#

it Simulate()

warped trail
#

it is not enough to set Velocity to zero before simulation๐Ÿง

round summit
#

It's before the build physics world?

#

Or after export physics world

#

Depends of how you look at it

warped trail
#

you have body with zero velocity and there is gravitational force, what will happen with this body after 0.02 seconds?

#

it will move

round summit
#

hmm, but whats at the place of gravitational force in my case?

warped trail
#

anything

#

Unity physics sort of sucks๐Ÿค”

round summit
#

I don't think that arrow still applies collision force?

warped trail
#

objects never stay in place

#

like never ever

#

they always drift๐Ÿ˜…

round summit
#

Let me check what PhyscisVelocity says in entity debugger

#

After the arrow and befroe

#

and by just moving around

#

All right i found it

#

ECS physics is perfectly fine and not weird at all

#

Problem was just my incompetence

fallow mason
#

blink twice if a Unity Evangelist is making you say these things

round summit
#

Did i mention i was setting the rotation of my character every frame?

#

Well, i was doing that and not setting the angular velocity to zero as well

#

So it's always in rotating state in buildphysics world

#

and its reset every frame

#

This was my character pretty much

#

Except the paddle is my character's capsule you know

#

And it starts rotating after hit by something (to be never stopped )

#

I might've wasted your time, sorry

opaque ledge
#

sounds like a quite an adventure ๐Ÿ˜„ gl out there

remote coyote
#

Seeing a lot of these after upgrading to Burst 1.3, even though I'm not building for IL2CPP:
The method `Int32 BeginSendMessage(Unity.Networking.Transport.NetworkInterfaceSendHandle ByRef, IntPtr)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!

bright sentinel
#

@remote coyote I think Networking is deprecated, so not sure it's compatible with Burst

remote coyote
#

This is Netcode, which is only Entities 0.6 compatible. I "could" wait for them on their next update, but took like 3 months last time ๐Ÿ˜„

#

my tests are still passing after updating the DOTS packages though

safe lintel
#

theres a post about that on the forums

bright sentinel
#

Oh, got confused, my bad

safe lintel
#

its a temp workaround by the burst team

remote coyote
#

np bmandk

#

ah alright, good to know

#

thanks thelebaron

#

good enough for me

safe lintel
bright sentinel
#

1.4.0?

#

Is the title just a typo?

safe lintel
#

guessing so

onyx mist
#

i took a 3 month hiatus from coding, were there any big updates to DOTS that i should research?

safe lintel
#

just read the changelog for any package you update, in all honesty I dont think too much has changed but it also depends if you were current 3 months ago. SystemBase does replace ComponentSystem and JobComponentSystem and has a slightly different way of handling dependencies but the samples repo has examples

onyx mist
#

alright thank you!

slim nebula
#

I'm very confused. Is it possible for physics to be predicted with NetCode? or is NetCode prediction only meant for ComponentSystems I make myself (using GhostPredictionSystemGroup/PredictedGhostComponent)?

slim nebula
#

like for each prediction tick, the input Translation is the same. Then it gets new data from the server, the first prediction tick is moved compared to the server data, then it continues predicting ticks until the target and they are all the same Translation as the first predicted tick

#

How can I get the physics simulation to happen for every predicted tick? And if I do that, how would I prevent the physics simulation for the !GhostPredictionSystemGroup.ShouldPredict scenario?

#

or is the whole system just not meant for this?

#

๐Ÿ˜ฉ

#

is there a better place I can ask these questions?

safe lintel
#

well it might be late for some of the people who know better ๐Ÿ™‚

#

but forums probably even better place to ask, many experts there

slim nebula
#

ok thanks

remote coyote
#

You're right Simoyd, no physics prediction yet.

bright sentinel
#

"Added integration with UnityPhysics, including the lag compensation from DotsSample. To use it you must have the UnityPhysics added to your project." That's the only info in the logs, doesn't say anything about the rest though