#archived-dots

1 messages Β· Page 101 of 1

scarlet inlet
#

thank you anyway, at least I know I am not crazy

#

I have no clue why Run() for a IJobForEach job should return a handle either for example

#

what is it trying to tell me, that the job may not be completed?

worldly pulsar
#

That's what I'm saying, I never noticed it accepted/returned job handles

scarlet inlet
#

it's only for IJobForEach

thin tiger
#

My entire Unity Editor crashes when I do a blobAssetStore.Dispose();
No messages, no errors, no debugs. Entire process goes down. Any clue?

toxic walrus
#

Youβ€˜re not allowed to dispose the asset store

trail burrow
#

@toxic walrus A man can dream πŸ˜„

ashen flame
#

Hello everyone! I started looking into DOTS very recently and I'm having trouble figure out what is the write way to code with this method. I've looked at many tutorials and they all seems to have their own way of doing things.

zenith wyvern
#

This tutorial was recently released, it's up to date and should give you a good idea of how to get started

tawdry tree
#

One tip you might want to keep in mind is that you don't need to use all of DOTS at once...
You could start with simple, non-job ECS first, then jobify some code, and then maybe optimize code for burst later.
It's also a useful way to prototype - just make something that vaguely does what you want it to in just ECS, and jobify once you know what you're going for.

ashen flame
#

Ok! Yeah from what I've seen it is not that hard to refactor the code to use jobs.

gusty comet
#

"I always like my code to be strongly typed, so I use a very loud keyboard." that guy lol

ashen flame
#

I don't understand why but as soon as I add some Data struct to my game object, it simply crash when I hit play.

#

Even though my game object is converted to an entity.

#

I tried disabling the Burst compilation but it did not change anything. I didn't even added a component system yet lol.

#

[2019-12-25T22:27:27.071Z][ERROR] [Unity Package Manager (Upm)]

#

Symbol file LoadedFromMemory doesn't match image C:\Dev\Unity Projects\Test 2019-03\Library\PackageCache\com.unity.ext.nunit@1.0.0\net35\unity-custom\nunit.framework.dll Native extension for WindowsStandalone target not found

#

* Assertion at ..\mono\metadata\metadata.c:1117, condition ``idx < t->rows' not met

gusty comet
#

is it worth having systems for task like input / camera? since is only one player controler

onyx mist
#

and thats what shows up in the debugger

#

i suck at trig so sorry if im missing something obvious here

craggy orbit
#

@onyx mist it might* be because DOTS uses radians instead of degrees
(*there's a high probability but it could be something else)

onyx mist
#

ohh

#

ok thanks yall

gusty comet
#

I really love the new tag for generating an authoring component

pseudo epoch
#

Hi i'm using jobComponentsystem to fill and retrieve data to a compute shader and i like to find a way to know when all jobs of a system ended (an event, or anything) i've found OnStopRunning but i'm not sure this correspond to the end of all jobs of this system

remote coyote
#

You can at least force it with Complete() on the job handle. I don't recall whether it holds status info as well, but that's where I would expect to find it if it exist Aclard

rancid sigil
#

guys, how to directly set object position via Jobs and ECS?

silver dragon
#

You can set position in Translation component.

zenith wyvern
#

Can you do ScheduleSingle with the new JobComponentSystem Entities.Foreach lambdas?

#

Or some equivalent I mean

gusty comet
#

Had some time to investigate into the prediction code of the dots netcode today and have some concerns:

The code which is used for prediction on the client (ghostpredictionsystemgroup) is executed from the last received snapshot tick to the calculated server tick on the client.
For example if we have received snapshot tick 50 and have a calculated server tick of 55 then the code is executed 4 times (51,52,53,54,55)

So now to me concerns:

  1. If the receive/delay between server/client gets higher than also the number of executions gets higher
    At the netcube example the prediction code gets executed 30 times at 200ms recv/send delay (for EACH Frame)
    So if i want to predict the complete player movement + abiltities this seems like a lot of overhead.

  2. Usually the snapshot received shouldn't be different from my prediction, right? This should only differ in case of unpredictable interactions (like stuns etc)
    -> in the most cases there isn't a full rollback of states necessary. This seems to be not implemented by unity (there is always a full prediction from the last received snapshot)

  3. The ServerTick on the client is adjusted by the latency and therefore can change for each frame => also the amount of predicted executions changes => movement can jumps back and forth

Did anyone else also notice these things?

I am now trying to avoid client side prediction (don't need full authoritive server yet) and send the translation/rotation and other properties of the player with the commandtargetcomponent. (instead of sending the inputs)

Do you think this is a good idea?

trail burrow
#

@gusty comet

  1. the overhead is completely fine
  2. its common to always do the full rollback
  3. this seems like an implementation issue, it shouldn't do this
gusty comet
#

@trail burrow
I've no experience with client side prediction but nice to here that 1) and 2) are common implementations

Maybe i give the prediction a try. Do you have experience with the new prediction system (dots netcode) and would you recommend it?

trail burrow
#

@gusty comet the current dots netcode is many many months away from being production ready

gusty comet
#

months... is an optimistic timeframe

#

I'd say a few years, at least

trail burrow
#

@gusty comet well, a few years is included in many many months, maybe i was thinking on the order of 70-80 months? πŸ˜„

#

but sure yeah

gusty comet
#

well when someone say many many months, I usually think of it as less than a year timeframe

#

technically we could use many many many weeks and it would also be accurate?

#

πŸ˜„

trail burrow
#

sure, whatever... it's not even close to done is what i was trying to convey

dull copper
worldly pulsar
#

Seems completely broken πŸ˜›

#

Starting the menu scene in editor takes like a minute, then pressing start shows a magenta quad and 999+ errors in the console

trail burrow
#

quality stuff they are putting out

#

@worldly pulsar crashed editor for me when i tried to play it

#

on mbp 13" with osx catalina

hollow sorrel
#

pressing start gives me a bunch of ArgumentException: All entities passed to EntityManager must exist. One of the entities has already been destroyed or was never created. then nothing happens

trail burrow
#

Β―_(ツ)_/Β―

hollow sorrel
#

also this isn't what breaks it but they updated to entities 0.4.0 while using wrong burst package corgothonk

trail burrow
#

all these samples are starting to become 'well it works on our computers' level of stability

hollow sorrel
#

to be fair i don't think this one has been announced publically, just seems to be a public repo they're working in

#

but the other ones yea pretty much

trail burrow
#

@hollow sorrel well if they put it on their public github as a public repo...

#

it's like

hollow sorrel
#

tru

trail burrow
#

@hollow sorrel unity needs to (tm) the phrase Not Ready πŸ˜„

gray flicker
#

Hey guys, quick question: Which components do you need to render a mesh using the RenderMeshSystemV2? Right now I have a Translation, Rotation, NonUniformScale and RenderMesh on my component but it doesn't render.

#

It's though finding this stuff on the internet

hollow sorrel
#

needs a LTW too if i remember right

gray flicker
#

Oh, yeah it also has LTW

#

Forgot that one

trail burrow
#

RenderMesh + LTW + Translation + Rotation

#

is whats needed

#

afaik

gray flicker
#

Okay, then I'm probably not setting my mesh correctly

hollow sorrel
#

is there a better way to deal with managed data in entities? for example a spawner that needs a reference to a Mesh to spawn
so far i've been dealing with these things by keeping an id int in a component and then looking it up in a dict when it needs to be used
but that means that for each iteration there's a dict lookup, whereas in OOP it'd just be a normal pointer ref

#

array would be nice but doesn't work when id doesn't start at 0

trail burrow
#

@hollow sorrel We've solved this in quantum neatly

#

we have the 'same' problem

#

i.e. a lot of native mem game state

#

but assets that are C# ref types

hollow sorrel
#

oo

#

how'd you solve it

vagrant surge
#

@hollow sorrel they added "class" components

#

that are normal C# managed types

#

but i havent tried them, just saw them on the patchnotes

hollow sorrel
#

yea but they fuck up your chunks

#

and i don't really trust it

vagrant surge
#

that i dont know how they are implemented

#

and if they fuck chunks or not

#

i know that you cant do jobs on them

hollow sorrel
#

also no idea how they play with serialization

#

in the case of an int id it'll stay the same even if you save/load

worldly pulsar
#

I have references to Materials and ScriptableObjects in class components in subscenes, no problems so far

hollow sorrel
#

what happens when they get serialized

#

does it make a seperate copy for each ref

worldly pulsar
#

separate copy of the component? I'd assume so, I have different data in each component. Also they play nice with chunks, all my text entities are in the same chunk

#

Oh, just realized I completely misread your question. No idea if it duplicates the scriptables, will check in a sec

#

In build ReferenceEquals(component1.scriptable, component2.scriptable returns true (this is within the same subscene).

#

Which is the best idea I had to check if they are not duplicated

hollow sorrel
#

ah yea i thought they were like sharedcomponents with chunking but seems they act like regular

#

good to know it doesn't copy

#

i heard subscenes use same refs for same subscene but if you have 100 subscenes with each 10 refs to the same thing you'll still have 100 copies of that ref
but not sure if it does that in this case too

worldly pulsar
#

Don't have an easy way to check that right now :/

gray flicker
#

Oh shit, I'm actually rendering something using RenderMesh! Thanks for the help!

tawdry tree
#

It's... it's... it's something!

#

Seriously though, unless you use simple conversion, rendermesh can be a major hassle.

hollow sorrel
#

@worldly pulsar scriptableobject as component seems to work pretty well so far, ty
but how do you get rid of the "scriptableobject must be created using createinstance instead of new" warning that ecs typemanager keeps throwing?

worldly pulsar
#

oh, I have a component with a reference to a scriptable in it

hollow sorrel
#

oic

worldly pulsar
#

(to be exact, it has a string, ScriptableObject and Material, all set in the authoring)

spiral cairn
#

I have a PlayerAccount component I would like to save to disk (as a simple save progression system), is it possible in an easy way or should I rely on a dedicated class to handle serialization (that wouldn't be part of DOTS at all)? Thanks

spiral cairn
#

forget my previous question... digging into the Entities dependencies, I found Unity.Serialization which does exactly what I'm looking for πŸ˜‰

gray flicker
#

I have some problems with culling. When I rotate the camera down the voxel chunks begin appearing. Could this be the culling system in RenderMeshSystemV2?

I'm getting decent fps though! I only change the mesh when loading the voxel data in.

#

I see some stuff about RenderBounds, could that have something to do with it?

gray flicker
#

Interesting thing: The scene camera has the same kind of culling, but they are separate from each other. So when something in the game view is culled/invisible, it's still in the scene view, unless it's near the edge of the scene view cam

gray flicker
#

Yeah I had to set RenderBounds to something that's not only 1x1x1 of space in the corner of my entities

shrewd cobalt
#

so on this whole dots stuff

#

Is unity eventually going to like stop supporting their current unity-type design and building on DOTS?

#

Also is the Data-Oriented Paradigm becoming a big thing that will replace OOP altogether?

#

I want to dive deep on dots xD

#

Okay I've answered some of my questions hmm

#

I jus tneed to find a big youtube talk on dots

#

Okay got all my questions answered, carry on c:

stable fog
#

Are the (Ray/Sphere/Box)castCommand jobs accelerated by burst?

coarse turtle
dull copper
#

@stable fog no

#

but underlying physx does do it's own simd optimizations

indigo orchid
#

Does anyone know how you install project tiny now? It isn't in the package manager as suggested by the docs

#

I found the link to the new version apparently with "TinyRacing". Apparently there is no 2D support anymore? Wasn't that one of the main things with Tiny?

solar spire
#

What’s next?
Starting in 2020, will be delivering frequent incremental updates with features and bug fixes. Support for Unity.Physics and 2D are planned in January. During Q1 2020, we will lay out a more precise roadmap as well.

fair vine
#

I'm really confused... I just downloaded the latest Jobs package via the package manager (preview.6 - 0.2.2, December 17 2019). According to the documentation there should be a number of different interfaces to implement different job types (IJob, IJobParallelFor, etc) - however I can only access UnityEngine.Jobs.IJobParallelForTransform in my project. I can't find any information about why everything else is missing so I'm not really sure what to do. Is this package version broken or something?

#

Wait! They live in Unity.Jobs.IJob? Ohhh

#

that's still pretty confusing but at least I found them lol

compact hound
#

how to get euler from quaternion?

dull copper
#

hmmm

#

I'm actually baffled by Joachims response

#

that's just so naive

#

"you shouldn't need this"

silver dragon
#

Does anyone know how to solve this one?

Something went wrong while Post Processing the assembly (Assembly-CSharp.dll) : 
 Failed to resolve System.Collections.Generic.Queue`1 
hollow sorrel
#

@trail burrow still curious about your neat solution to managed refs btw

dull copper
#

what you use it with?

#

oops

#

not that kind of postprocessing πŸ˜„

silver dragon
#

πŸ˜›

dull copper
#

my excuse is that I just woke up :p

#

there isn't any errors prior to that?

silver dragon
#

Maybe it's related to

Unexpected exception Burst.Options.OptionException: Unexpected arguments: `--is-for-function-pointer --managed-function-pointer=0x000001B1BD06A410`
  at Burst.Compiler.IL.Jit.JitCompilerService.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x0012a] in <3179d4839c86430ca331f2949f40ede5>:0 

While compiling job: Unity.Entities.StructuralChange, Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null::AddComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*, Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|Unity.Collections.LowLevel.Unsafe.UnsafeList*, Unity.Collections, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null|System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089)
#

Got some strange errors after upgrade 😦

dull copper
#

you can see all kinds of funky stuff like that if you use nonmatching package versions

#

automated dependencies for packages don't always work

#

so you may need to install jobs, collections etc manually to latest versions

#

there was recently some mismatch on some of those (can't remember which) so had to manually force some package to newer version myself

silver dragon
#

Yep, already installed burst 1.2.0 p11 as suggested in forums. Will check the others. I just noticed the upgrade symbol is not always shown...

dull copper
#

there's also tiny refresh icon on package manager

#

but the versions update with small delay there

#

it shouldn't be that many seconds tho

#

also in past, if you kept package manager always open, it didn't really update properly at all

#

so to avoid that, I usually just close package manager after use and open it again only when I need to

#

it's not the most reliable component in Unity editor :p

silver dragon
#

That's life when using experimental stuff πŸ™‚

#

Packages seems to be the latest ones...

worldly pulsar
#

You did the usual close Unity -> delete Library -> restart Unity?

silver dragon
#

yep, did that today morning while having breakfast

#

Seems burst doesn't like a line from the netcode docs:

var world = new World(defaultWorldName);

Error:

InvalidOperationException: Burst failed to compile the function pointer `Void AddComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*, Unity.Collections.LowLevel.Unsafe.UnsafeList*, Int32)`
dull copper
#

@silver dragon which dots packages and what Unity version are you using?

silver dragon
#

2019.3.0f4, entities 0.4.0 p10, burst 1.2.0 p11, collections 0.4.0 p6, netcode 0.4.0 p0, physics 0.2.5 p1

dull copper
#

these are the ones I put to manifest myself (but I don't have netcode or transport here):

    "com.unity.burst": "1.2.0-preview.11",
    "com.unity.collections": "0.4.0-preview.6",
    "com.unity.dots.editor": "0.1.0-preview.2",
    "com.unity.entities": "0.4.0-preview.10",
    "com.unity.physics": "0.2.5-preview.1",
    "com.unity.rendering.hybrid": "0.3.1-preview.10",```
#

well, those do match

silver dragon
#

This is the full stack from the last error:

InvalidOperationException: Burst failed to compile the function pointer `Void AddComponentEntitiesBatchExecute(Unity.Entities.EntityComponentStore*, Unity.Collections.LowLevel.Unsafe.UnsafeList*, Int32)`
Unity.Burst.BurstCompiler.Compile[T] (T delegateObj, System.Boolean isFunctionPointer) (at Library/PackageCache/com.unity.burst@1.2.0-preview.11/Runtime/BurstCompiler.cs:160)
Unity.Burst.BurstCompiler.CompileFunctionPointer[T] (T delegateMethod) (at Library/PackageCache/com.unity.burst@1.2.0-preview.11/Runtime/BurstCompiler.cs:78)
Unity.Entities.StructuralChange.Initialize () (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/EntityManagerChangeArchetype.cs:58)
Unity.Entities.EntityManager..ctor (Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/EntityManager.cs:163)
Unity.Entities.World..ctor (System.String name) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/World.cs:115)
Local.Core.SlClientServerBootstrap.Initialize (System.String defaultWorldName) (at Assets/Game/Scripts/Core/SlClientServerBootstrap.cs:20)
Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:123)
Unity.Entities.AutomaticWorldBootstrap.Initialize () (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities.Hybrid/Injection/AutomaticWorldBootstrap.cs:15)
#

I hope some Unity guys will check the forums, those errors are too strange for me πŸ™‚

worldly pulsar
#

btw, is this on compile, or on entering playmode?

dull copper
#

I assumed it happened when @silver dragon just opened the project after updating packages?

silver dragon
#

Entering playmode

worldly pulsar
#

try disabling the fast enter playmode

#

options

silver dragon
#

Did that, have to wait a bit because of another strange uissue ...

#
Something went wrong while Post Processing the assembly (Assembly-CSharp.dll) :
Failed to resolve System.Collections.Generic.Queue`1
#

Recompile takes some time...

#

Ok, seems disabling fast enter playmode changed something... i have more errors now, including the erros above πŸ™„

worldly pulsar
#

Β―_(ツ)_/Β―

silver dragon
#

Will pass some errors to their asset owners in the meantime πŸ™‚

trail burrow
#

after getting access to intrinsics in .net core 3.1...

#

i don't want to go back

#

lol

gray flicker
#

Is it possible to write to a DynamicBuffer (defined with IBufferElementData) in an IJobForeachWithEntity_EBC?

#

I see you can use SetBuffer, but in most cases I want to change a value in the buffer, not set a new one

worldly pulsar
#

you get the buffer as an argument in the Execute method

#

so you can read/write to it

gray flicker
#

Yes, but it complains about being not being readonly

#

wait, i'll paste the message

worldly pulsar
#

How do you schedule the job?

gray flicker
#

With job.Schedule

worldly pulsar
#

Schedule(query) or Schedule(system)

#

and if Schedule(query) do you ask for ReadWrite in the query

gray flicker
#

job.Schedule(this, inputDeps) inside the OnUpdate(JobHandle inputDeps)

#

That's the system apparently?

worldly pulsar
#

try specifying the query and ask for ReadWrite on the buffer explicitly (I never use the Schedule(this) version so can't help you on this one)

#

(also: you probably want to use the new jobified ForEach)

#

Entities.WithAll<CompA>().ForEach((Entity e, DynamicBuffer<BuffElem> buffer) => {DoStuff(buffer);});

gray flicker
#

I actually use Entities.With now, but it still brings my fps to almost zero

#

Does Entities.With.Foreach run parallel?

worldly pulsar
#

it generates an IJobChunk (which is what IJobForEachWithEntity uses internally)

#

so yes, in general it runs in parallel

solar ridge
#

"Entities.ForEach β€” the job executes the lambda function on parallel background, job threads. Each job iterates over the entities in the chunks selected by the ForEach query. (A job instance processes the entities in a single chunk at minimum.)"

#

Note, you can combine with and foreach

gray flicker
#

Yeah, I got Entities.With.Foreach working, but it still clogs the game, as if it was running on the main thread

solar ridge
#
Entities.WithNone<Tagged>().ForEach((int entityInQueryIndex, Entity e, in Component component) => {...}).WithBurst().WithName("TagMe").Schedule(inputDeps);
gray flicker
#

maybe because all my entities are in the same chunk?

solar ridge
#

Depending on what you are doing?

worldly pulsar
#

@solar ridge you can skip WithBurst(), it's implicit

gray flicker
#

I'm generating a lot of voxels

#

at least, I want to generate a lot of voxels

worldly pulsar
#

it's there if you want to provide burst options

solar ridge
#

Right, but I do it so I know verbosely that I am using burst

worldly pulsar
#

"In parallel" doesn't mean "over multiple frames"

solar ridge
#

as there are multiple parts where I can't IE string usage

#

πŸ™‚

worldly pulsar
#

if your job takes more than 16ms you'll have frame drops

gray flicker
#

That explains it I guess

solar ridge
#

Now... you "can" schedule a job that can be over multiple frames

#

but... you need to be more careful when doing so

#

as that is not how this system is designed primarily

#

so most of the easy methods to cascade the data together don't exist per se in that route. In example: ForEach assumes a single frame

#

Most of the Entities methods I think are built for 1 frame runtime

gray flicker
#

Oh, by the way, I think most of the work is in creating the mesh of every voxel chunk (an entity with 16x16x128 voxels)

solar ridge
#

Yes.... creating 256x128 meshes... would be a bog down in a frame

#

Unsure if you could do that in a single frame

worldly pulsar
#

Use the profiler, it'll tell you for sure what is slow

solar ridge
#

^

gray flicker
#

Yeah, that's a great plan!

worldly pulsar
#

(and yeah, you won't generate a minecraft world in 1 frame)

gray flicker
#

Thanks for the info! It's though starting with DOTS, but it sure as hell seems nice to work in, as soon as you get the hang of it.

#

No, generation should occur in a loading screen, but still I don't want the game to freeze while in the loading screen...

#

And i'm only taking my first steps into DOTS so loading screens are still far away.

solar ridge
#

So you'll want to split the workload over frames. likely one batch of 16^2 per frame

#

If even that

#

One day. I will get the final 2 pieces of my missing system: TCP Websockets in DOTS, and Burstable comparisons on BlobStrings

gray flicker
#

So if you use Foreach, can you use the EntityManager instead of the EntityCommandBuffer?

solar ridge
#

Why ... exactly would you want to use the EManager?

#

over ECB?

gray flicker
#

Adding and removing tag components

solar ridge
#

And why would you not want that in the ECB?

worldly pulsar
#

not if you want Burst/Multithreaded

solar ridge
#

Well..

#

It goes on further than that

#

If you modify by adding and removing, you create a sync point as well

gray flicker
#

Well, I don't really know how all this works, so πŸ˜„

solar ridge
#

structural changes mid frame are bad

#

So the ECB runs at the start of the frame

#

All 6(?) of them

#

These serve as one massive sync point

#

instead of splitting across the frame

#

This allows for data to be accessed without worry of the list mutating part way through

#

So in adding and removing you can use the ECB to add a component or remove a component anywhere in the frame, and the next frame it will do all the changes in a playback

#

If you were to do it with say the Emanager, you'd wind up stutter stopping due to entities being shifted around

#

It wouldnt be too noticeable with a handful of things, but as time goes on it would be a rather large problem

#

Since they made the ECB burstable, it is MUCH faster now. Now we merely need to wait a little bit for the ECB playback to be bursted

#

An alternative is also utilizing the ExclusiveEntityTransaction... but that is a little more of a learning curve

#

And the performance is very dependent on what is going on

worldly pulsar
#

Using EntityManager in a ForEach has the advantage of being super simple πŸ˜› And you get the changes applied instantly which usually makes the code much simpler

solar ridge
#

Un sure how the ECB is any less simple πŸ˜›

#

You have maybe 3-4 more lines soarynSip

#

And creating sync points is again, something to completely avoid unless you absolutely need them

worldly pulsar
#

The main issue is the "changes applied instantly" part. In gameplay code I have a ton of systems that do

  1. Attach SystemState component to entities matching a query that don't have them
  2. Update all entities with SystemState
#

and separating them into 2 systems before/after a sync point is a major pain

#

But then the way I use ECS is probably not what Unity intended πŸ™‚

solar ridge
#

The best thing I have read for game development: The more pain you alleviate for yourself in development time, the more you put it on the user.

Obviously this doesn't correlate to everything (Example: Editor extensions, etc), but the idea was rather interesting.

#

And makes the OOP vs DDD paradigms more understandable

#

OOP was very much, this is MUCH easier to code

#

but completely forgetting a user audience soarynLOL

#

DDD is THIS IS SO MUCH MORE WORK... but my users shall be happy!

worldly pulsar
#

I'd argue with the "OOP is easier" tbh. I'm using ECS because I think it's easier than OOP for the game I'm making

#

(emphasis on the "I think" part, whether it actually is remains an open issue πŸ˜› )

#

And strong disagree that making your life easier has to impact users

solar ridge
#

It is more the way OOP tries to make your life easier

gray flicker
#

I think I might like this ECS way of programming way more than what I'm used to. It separates concerns nicely.

#

I've used a lot of MVC like frameworks in the past, this feels like taking it a step further

solar ridge
#

Out of curiosity, why do you need to wait a full frame before modifying your system state component?

#

Data related to other system states? Or is it independent?

worldly pulsar
#

I don't, that's the point

solar ridge
#

Why would you need two systems?

worldly pulsar
#

oh, sorry, the 1. 2. was in the same system

gray flicker
#

But why would you need to change something in the exact same frame? Wouldn't it be okay for most entities to change after the frame ends?

worldly pulsar
#

the point being I need the changes in 1. to be done by the time 2. executes

gray flicker
#

So, when you want to change an entity and run some more code, you can just wait a frame right?

worldly pulsar
#

and with ecb I'd need to Playback() it between 1. and 2. (which is a sync point)

gray flicker
#

using another system maybe

solar ridge
#

Unless you need data from another systemstate you don't need to wait

#

You can just do
AddComponent
SetComponent

#

All in the same job

#

But that is dependent on if you need something say like the full entity count (which you technically already have) or something else from one of the other system states (example a different entity ID per se)

#

You can even just AddComponent(e, new MyComponent(){});

#

I actually do that now:

var entity = buffer.CreateEntity(index);
buffer.AddComponent(index, entity, new Component() {BlobReference = BuildBlob(JsonUtility.FromJson<Event>(json))});
#

You also don't manually playback (assuming I'm reading incorrectly what you mentioned before)

worldly pulsar
#

ok, a more concrete case because I see my previous example was bad :)

        Entities
            .WithStructuralChanges()
            .WithAll<AiMoveOptionSelection>()
            .WithNone<HighlightDisplay>()
            .ForEach((Entity e) =>
            {
                highlight = Instantiate(highlightDisplayPrefab);
                Add(e, new HighlightDisplay
                {
                      Entity = highlight            
                });
            }).Run();
        Entities
            .WithStructuralChanges()
            .WithNone<AiMoveOptionSelection>()
            .ForEach((Entity e, HighlightDisplay display) =>
            {
                DestroyEntity(display.Entity);
                Remove<HighlightDisplay>(e);
            }).Run();
        Entities
            .WithoutBurst()
            .ForEach((AiMoveOptionSelection aiSelector, HighlightDisplay display) =>
            {
                /// code that positions display.Entity based on data in aiSelector
            }).Run();
#

note that the first 2 ForEach run rarely, mostly for new entities, and the 3rd runs every frame and has to have the first 2 applied by the time it runs (otherwise you get the newly created highlight entity rendered at some random position for 1 frame)

#

oh, and Instantiate(), Add() and DestroyEntity() are helpers that just call the corresponding EntityManager methods

#

so to avoid creating a sync point here would be a pain

gray flicker
#

wtf

#

I have a weird problem

#

I have no changes

#

all of a sudden when I try to look at one of my entities in the inspector I get:

InvalidCastException: Specified cast is not valid

#

I stashed my changes and it is still there

#

I'm so confused now

solar ridge
#

I beleive

#

that is the UI

#

Potentially

gray flicker
#

Yeah googling it I get UI stuff too

solar ridge
#

UIElements has ... some interesting issues

zenith wyvern
#

I seem to remember that happening when I was trying to store invalid references to entities (IE: the results of a command buffer.CreateEntity)

gray flicker
#

but I never changed anything of that

solar ridge
#

You have the debugger open?

zenith wyvern
#

It would give lots of bad erros when I tried to use the entity debugger on invalid entity references

gray flicker
#

The Entity Debugger? Yes.

solar ridge
#

It USED to be all the time on entity 0 which was hilarious

gray flicker
#

The entity only shows a physicscollider now

solar ridge
#

May need to restart the editor.

gray flicker
#

That's weird because it wouldn't show up before haha

#

I did

solar ridge
#

Off an On again solution

#

Aaah

#

well rip

gray flicker
#

Maybe also close rider

#

brb

solar ridge
#

Mmmm I'm not going to say "don't do that" but that shouldn't fix the problem

#

BUT if it does soarynGood

gray flicker
#

I know, but I can try πŸ™‚

solar ridge
#

Also @worldly pulsar none of that code is parallelized and it is making me sad

gray flicker
#

I'm using a prefab to instantiate my entities. Maybe the prefab is broken?

solar ridge
#

Prefab as long as it is an entity is fine

#

if it is a Gameobject then no

#

not fine

worldly pulsar
#

I'd love to see a parallelized version of this that is not 3x in size πŸ˜›

#

(it's Entity)

#

also: this operates on like 6 entities total

solar ridge
#

Re: Scuba

worldly pulsar
#

so making it parallel would most likely be slower anyway (b/c job scheduling overhead)

solar ridge
#

Oddly while scheduling does take time, it may still benefit as you are full on blocking main thread from continuing until finished

gray flicker
#

Even going back a commit doesn't change anything

#

Rebuilding the entity cache doesn't do anything

solar ridge
#

Especialy since you can then burst the addComponents and positional data

worldly pulsar
#

I know. My whole point is that this version is super simple to write, debug and maintain, and doing this with command buffers would be 10x more complex

solar ridge
#

In a snapshot of the entites, if something is rendered and shouldn't be there is a problem with the logic. BUT, what ever you are happy with. If it works and doesnt degrade the performance, so be it

gray flicker
#

It's weird, I was trying to add a PhysicsShape to my entities yesterday and I couldn't get it to work. Now all of a sudden it adds the PhysicsShape and it breaks everything

worldly pulsar
#

In a snapshot of the entites, if something is rendered and shouldn't be there is a problem with the logic.
Not sure I understand that

solar ridge
#

In terms of a frame

#

The frame being a snapshot, you have entities that have components

worldly pulsar
#

Also to be clear: I'd love to do this without creating a sync point. But there is no easy way to do that (by easy I mean + ~5-10 lines of code)

#

the 3rd runs every frame and has to have the first 2 applied by the time it runs (otherwise you get the newly created highlight entity rendered at some random position for 1 frame)
referring to this?

zenith wyvern
#

You could just remove LocalToWorld while you prepare the entities. Then add it in the third run. It won't render without LocalToWorld

#

Assuming you're using rendermesh

solar ridge
#

Your first job... why not just set the position then?

#

As you could have the display and the selector

worldly pulsar
#

@zenith wyvern the prefab is 3 entities in a hierarchy, the children have meshes so that won't work (and again, complexity for little gain)

#

@solar ridge because what I pasted is a super simplified version and the real 3rd job is actually 2 jobs dependant on one another that take 2 more components and some additional data

gray flicker
#

@worldly pulsar you said earlier that using Entities.Foreach would parallelize jobs. I'm looking in the profiler and I see my systems running on the main thread taking 4000+ ms. Shouldn't I see the work on another thread than main?

worldly pulsar
#

do you Schedule() or Run() your ForEach?

#

Run() runs on the main thread

gray flicker
#

wait. I think I'm missing something here.

#

I just do Entities.With(_query).Foreach in the Update of a ComponentSystem now

worldly pulsar
#

oh

gray flicker
#

nothing with either Run or Schedule

worldly pulsar
#

use JobComponentSystem

gray flicker
#

Okay, I think that is the problem then

worldly pulsar
#

the ComponentSystem Entities.ForEach is a completely different thing under the hood

gray flicker
#

But JobComponentSystem doesn't have Entities?

worldly pulsar
#

are you on Entities v0.3 or later?

hollow sorrel
#

yea ComponentSystem is main thread only

gray flicker
#

I installed it like a week ago, let me check

#

Looks like it's 0.1.1

#

but it says its up to date

worldly pulsar
#

are you on Unity 2019.3.0f1 or later? πŸ˜›

#

(I swear half this channel is just comparing version numbers xD )

gray flicker
#

j2019.2.17 right now

worldly pulsar
#

yea, the new ForEach requires 2019.3

gray flicker
#

is 2019.3 a preview?

worldly pulsar
#

yup

#

Beta/Release Candidate status

gray flicker
#

To the Unity Hub!

gusty comet
#

hey, is it worth having an ecs system for player control or could be used as monobehaviour since its a single gameobject?

worldly pulsar
#

Define "worth it". If your player is a gameObject there is little difference, if it's an entity it's probably easier to use a system

#

also: anyone hit this one before?
(EDIT: and has a solution? πŸ˜„ )

ArgumentException: The entity does not exist
Unity.Entities.EntityComponentStore.AssertCanAddComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/EntityComponentStoreDebug.cs:270)
Unity.Entities.EntityManager.AddComponent (Unity.Collections.NativeArray`1[T] entities, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/EntityManagerChangeArchetype.cs:306)
Unity.Transforms.ParentSystem.UpdateChangeParents () (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Transforms/ParentSystem.cs:295)
Unity.Transforms.ParentSystem.OnUpdate (Unity.Jobs.JobHandle inputDeps) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Transforms/ParentSystem.cs:377)
gusty comet
#

yeah but having a system that only affects a single entity?

worldly pulsar
#

Why not? I have a ton of systems that affect nothing most of the time

gusty comet
#

maybe as a single thread systems not multithread

#

that might be fine

#

also i hit that error

#

in a demo

gray flicker
#

I like the new styles in 2019.3! I was wondering in tutorials if that was a OS specific thing

#

Looks like Entities 0.4 preview is also here

gusty comet
#

in this demo

worldly pulsar
#

@gusty comet as of Entities 0.4 there are very few cases where you should use ComponentSystem over JobComponentSystem (if that's what you mean by "single thread systems not multithread")

gusty comet
#

i mean using Run instead of Scheduling

gray flicker
#

@gusty comet having a system for one entity would separate your concerns nicely right?

gusty comet
#

i find it wierd to have a whole system just to listen for player inputs nor update camera

zenith wyvern
#

I think the expectation is that you could have hundreds and hundreds of systems running and it should be fine. That is Unity's stated goal at least

gusty comet
#

also @worldly pulsar that error usually happens in jobs running burst.

zenith wyvern
#

Right now there's overhead for systems that shouldn't be doing anything, but they are working on it

gusty comet
#

guess ill just go for it since everyone is doing it kek

worldly pulsar
#

Disabling burst is on my list of things to do before asking on discord πŸ™‚

gray flicker
#

But that's the thing: you "could" have hundreds of systems running for hundreds and hundreds of entities, but it can also only be one entity. I don't see why not.

zenith wyvern
#

So if it makes sense to have a system just for the purpose of separating concerns and making your code easier to understand and work with, do it

gusty comet
#

@worldly pulsar there is that option in burst to enable that actually shows the line the error came from

#

i can't remember the name

worldly pulsar
#

I know where the error came from. I don't know why the Parent system thinks a destroyed entity needs a child πŸ™‚

solar ridge
#

LOL

#

Im usually in the boat of if I need to make a GO then either Im thinking about the problem wrong, or I must be patient

gusty comet
#

@worldly pulsar same happens in that demo, when you kill an entity that can attack you

#

i think is trying to call it right after it got destroyed but is too fast

#

and didn't acknowledged that it got destroyed

worldly pulsar
#

I get this on enter playmode πŸ˜›

gusty comet
#

welp, sorry, wish i knew more to help but dots its still pretty new

#

@worldly pulsar i'm a good rubber duck tho πŸ˜‚

gray flicker
#

Just updated to 2019.3 and updated my packages

#

maybe restart for a sec πŸ™‚

worldly pulsar
#

yup, there is now a [ConverterVersion("username", 5)] you can apply to your IConvertGameObjectToEntity

#

and you bump the version number to let the caching system know it has to re-convert the entities

#

it reimports at a subscene granularity?

gray flicker
#

But you need the converterversion for authoring classes?

worldly pulsar
#

@gray flicker you don't need it, but it's a convenient way to 'wiggle something' πŸ™‚

#

i.e. you change the way the authoring works, bump the version number, everything that uses that authoring gets reconverted

gray flicker
#

And does it work when you change the authoring and only then add the version? I've had a problem with state management in Angular where the versioning system didn't work if you didn't version from the start

worldly pulsar
#

Jeez, reading the transform system is so depressing. FindMissingChildJob, parentsMissingChild, FixupChangedChildren

#

@gray flicker I usually add it the first time I change something, seems to work fine

gray flicker
#

Does the ENtities of a JobCOmponentSystem have something simular like the one in ComponentSystem, where you can add an entity query like: Entities.With(_query)?

#

With doesn't exist anymore

worldly pulsar
#

nope

gray flicker
#

Then how do you specify between Read and ReadWrite etc?

worldly pulsar
#

also can't do Entities.WithAll<X>().WithNone<Y>().ToEntityQuery();

#

if your lambda argument takes a component by ref, it's read/write, by in is read-only

zenith wyvern
#

You can capture the entity query that's generated by the foreach with WithStoreEntityQueryInField

worldly pulsar
#

I think dynamic buffers are always read/write but not sure about that

zenith wyvern
#

And it does it at compile time so you can use the query before you run the foreach

worldly pulsar
#

@zenith wyvern I know, the thing is I don't want to foreach that query, I want to .ToComponentDataArray() it

gray flicker
#

What if you want a DynamicBuffer in your WithAll?

worldly pulsar
#

just specify the element type

zenith wyvern
#

Anything in the foreach fields is implicitly in the query

worldly pulsar
#

also: any arguments in your lambda are implicitly WithAll

#

and you must not add them to WithAll (it complains otherwise)

gray flicker
#

Aaah

#

that must be why it was complaining

#

πŸ™‚

#

I had my buffer in the lambda

gray flicker
#

Can you only use static methods inside a ForEach?

#

Unity is complaining: Lambda expression invokes ... on ... which is a reference type

#

With static methods it also doesn't work

coarse turtle
#

you can use static methods in a ForEach

#

If you need to use a reference type

#

especially in a JobComponentSystem - you will need to use

#

Entities.WithoutBurst().ForEach((...)).Run();

worldly pulsar
#

Lol, 1.5h later, turns out if I add a child to one of the ConvertToEntity objects (and only that specific one) it causes the ParentSystem to crash. Completely no idea why.

gray flicker
#

It complained that I was calling UpdateChunk, which is a static method. I'll look into it more in a few hours

#

Playing Overwatch now πŸ™‚

solar ridge
#

You can use FunctionPointers for static methods

#

If it can be burst compiled, then use BurstCompiler.CompileFunctionPointer()

#

If it can't be then just get the marshalled pointer

worldly pulsar
#

Unity is complaining: Lambda expression invokes ... on ... which is a reference type
the "which is a reference type" is the problem here

#

can't have reference types if you .Schedule()

#

must be .WithoutBurst() and .Run()

coarse turtle
#

yup πŸ‘

solar ridge
#

Uh

#

Not sure about the scheduled part as I am using reference types with my job using FunctionPointers now

#

Unless a string has miraculously become a blittable type

#

Without burst sure, ...

#

It really depends on what the method does with said reference type

coarse turtle
#

ah - I guess that's worth looking into, i havent passed function pointers into a job yet

solar ridge
#

It is rather handy

#
public static void BuildABlob(int index, ref EntityCommandBuffer.Concurrent buffer, string json) 
#

That is a method I am turning into a function pointer and passing along to a job

#

en masse

worldly pulsar
#

how do you pass that string into the job? scheduling
struct Test : IJob { public string test; void Execute() {} }
yells at me as it always had

solar ridge
#

byte array or NativeString or using a blob

#

NativeString is nice; however, I am passing in an unknown sized amount of text

#

and allocating an array of 4096Bytes per element seems like a bad idea

worldly pulsar
#

Oh, yea, you can create managed types while executing the job (it's just running mono on a thread, you can do basically anything).
Calling a system method like @gray flicker probably does captures this which is a big no-no

solar ridge
#

To be fair I only read "Can you only use static methods inside a ForEach?"

#

Making food so slightly distracted πŸ˜‰

inland root
#

deliciousness oriented design @solar ridge

compact hound
#

Hi, is there someone for fast question?
I have loaded GameObject prefab in runtime. How to instantiate it as Entity? EntityManager.Instantiate creates empty entity.

#

Should I use Object.Instantiate?

inland root
#

@compact hound i mean... all entities are empty i thought that was the point.. no data encapsulation :D

#

@compact hound maybe some sort of gameobject -> ecs conversion workflow can help you though

worldly pulsar
#

(would cut down the irrelevant parts but I've spent too much time on discord today anyway πŸ™‚ )

compact hound
#

@worldly pulsar yes but you have the prefab during conversion. Im loading my at runtime

worldly pulsar
#

Then instantiate as usual, then GameObjectConversionUtility.ConvertGameObjectHierarchy (I belive it's not deprecated? )

#

(btw. what do you mean by "loading a prefab at runtime"? From an asset bundle?)

compact hound
#

from addresables

#

system starts, loads player settings and load prefabs from settings

inland root
#

I'm really looking forward to a full DOTS mode for projects in the Editor, though. Throws all this hybrid / conversion nonsense out the window.

#

Hybrid has its practical use cases of course. but for a greenfield project that you know is better suited for DOTS it's just a bunch of wasted time dealing with redundant abstractions and boilerplate to scaffold into the age old gameobject based Editor

worldly pulsar
#

I'm pretty sure the conversion workflow is here to stay for the foreseeable future

#

as in no plans for full dots mode

inland root
#

project Tiny already proved a DOTS editor mode

#

they have plans for it long term

worldly pulsar
#

the Tiny editor was scrapped, they use conversion now

inland root
#

especially with Visual Scripting Graph being DOTS only

#

yeah it (project tiny) was a proof of concept only ofc

worldly pulsar
#

also hybrid and conversion workflow are completely different things

inland root
#

hybrid is rendering yes but it deals with light conversion

#

they are related

worldly pulsar
#

hybrid is using MonoBehaviours/GameObjects at runtime

#

like how you can query for MonoBehaviours in EntityQueries

#

conversion is all about having an editor-friendly authoring data representation (using MonoBehaviours because they happen to have a ton of tooling around them already), and turning them into runtime-friendly entity representation

inland root
#

ah, got it.

compact hound
#

true

inland root
#

My thought is presumably an Editor or per project Editor mode (more likely) built for DOTS 100% from the ground up be able to avoid using conversion and the hybrid renderer, yeah?

coarse turtle
#

hmm - question about hierarchies - if you delete a Child entity - does the DynamicBuffer<Child> on the parent entity get updated? πŸ€”

compact hound
#

@coarse turtle should be

#

@worldly pulsar what paramters should have GameObjectConversionUtility.ConvertGameObjectHierarchy

coarse turtle
#

ah wonderful - guess that's a case I don't need to worry about if it's handled already thnx

worldly pulsar
#

@compact hound don't remember, haven't used it since the conversion came out

#

@inland root I really doubt they'll invest a ton of effort into building and maintaining a separate editor for DOTS when conversion handles basically everything

#

re: dropping the hybrid renderer for a pure dots one - I hope that's on the roadmap, but haven't heard anything about it so far

inland root
#

@worldly pulsar If they want DOTS to be widely adopted they will eventually or at least make conversion 90%+ transparent. Of course the projects that need it will jump over whatever hurdles to use it anyway.

and yeah a replacement for hybrid renderer would be very welcome. joachim mentioned in a bug report they are at least planning to refactor the hybrid renderer in a significant way soon before addressing the issues i brought up with light conversion. which is expected being at 0.1.x stage in development Β―_(ツ)_/Β―

worldly pulsar
#

Now I do agree that ECS needs a ton of tooling of its own (the EntityDebugger letting you edit the values being near the top)

#

To be honest once they allow more than 1 [GenerateAuthoringComponent] per file I'm not really sure what else I want from the conversion pipeline

soft nova
#

Is there anyway to query entities with a proxy? (Hybrid) I'm trying to do the following:

Entities.WithAll<MyProxy, MyData>().ForEach((MyProxy myProxy, ref MyData myData) =>
{
    //Do something
});

It unfortunately doesn't run if I'm trying to use the proxy, if I change the proxy to any other attached MonoBehaviour it works without problems.

balmy garnet
#

Is there a reason for why "Game Object Entity" is no longer available in the component menu? The docs don't list it as being deprecated...

radiant sentinel
#

@balmy garnet game object not exist at ECS. you have entities and entities can be spawn from your code. you can convert your game objects to entity at runtime by ConvertToEntity components

balmy garnet
#

but isn't that what the GameObjectEntity script was doing? and also left a reference to its GameObject? Does that mean there is no more hybrid proxy system?

radiant sentinel
#

@soft nova if its an object, i think it is possible, move MyProxy after MyData. i have not tested

#

@balmy garnet yes GameObjectEntity converting too. you can connect that to game object but it is not reference to that

soft nova
#

@radiant sentinel Tried that already, but it didn't work

radiant sentinel
#

@soft nova compile error or runtime error?

soft nova
#

No, no error, the system just doesn't run on the entity

radiant sentinel
#

@balmy garnet what is your package version? at my version, named "ConverToEntity"

balmy garnet
#

@radiant sentinel I have the latest 0.4, but it's not about ConvertToEntity. It's about GameObjectEntity missing from the component menu and it not being documented in the docs/changelog

radiant sentinel
#

@soft nova why you are using WithAll? and MyProxy Gameobject is available?

#

@soft nova are you sure, your system is running?

soft nova
#

@radiant sentinel I need it to run with entities that have a Monobehaviour and a componentdata (MyProxy, MyData) if I use a normal MonoBehaviour the system runs perfectly, but for convenience I changed it to a proxy and realize that it doesn't run when using a proxy.
Well it is not running since it doesn't find any entity, but with another MonoBehaviour instead of the proxy it works

radiant sentinel
#

@balmy garnet ok Use ConvertToEntity, its same.

balmy garnet
#

it is not though, with just ConvertToEntity i have to work fully in the ECS world, is that not the case? With GameObjectEntity I was able to "sync changes" back to the GameObject world and thus have the best of both worlds

#

I want to slowly move towards ECS; without having to rewrite everything as jobs/systems at once

zenith wyvern
#

If you change to converttoentity to "Inject" rather than destroy it leaves your GO and all components intact and you can query for your non ecs components inside a system

#

It's up to you to sync the two representations of your object though

balmy garnet
#

so it being left out of the documentation was just an oversight?

radiant sentinel
soft nova
#

@radiant sentinel Yeah with a normal Mono it works, if you change that to be a proxy of TestData then it won't run

safe lintel
#

@balmy garnet i think its somewhat safe to say they dont want people using the old proxy/gameobjectentity workflow any more

radiant sentinel
#

yes it is, but there is an question. why foreach on proxy? you have data at entity. @soft nova

balmy garnet
#

yeah I just realized that the data is no longer synchronising on get. Which is fine, if they would have communicated that

radiant sentinel
#

each day is different. its preview package. @soft nova if proxy is old, the only way is change your workflow. you can pass your data from ECS world to GO world only by systems. if anyone know other ways, i want know. i need it too.

soft nova
#

@radiant sentinel for the same reason @balmy garnet has been asking, I'm trying to move everything slowly and the more convenient way to start is with proxies

radiant sentinel
#

you can create static hashtable of objects, then pass data from ComponentData to Objetcs. you can add new gobjects to static hashtable.

soft nova
#

@radiant sentinel Hmmm I must be missing something, I did your exact same test right now and it's not running. Is there anything else the GO needs now that GameObjectEntity is not to be used?

soft nova
#

I figured why my system wouldn't run, now I'm using IConvertGameObjectToEntity, but this unfortunately breaks the CharacterController since it won't move. This worked fine with proxies, anyone have any idea how to allow it to move the transform without GameObjectEntity?

radiant sentinel
#

@soft nova yes i have not used proxy or GameObjectEntity at my current project. you should change your game architecture to PureECS and a little hybrid ECS. i know its so hard and expensive. at your project, you can use IConvertGameObjectToEntity as an "author" for Controller ComponentData and controlling your character by system without any character controller. at GO side, for example you have animation on character, i have used my own pattern that named "Attachments" to sync character entity data with mechanim.

#

at attachment mechanism, i am create an ComponentData and authoringMonoBehaviourComponent like figure 1 and 2. and a monobehaviour to do attachments.

#

so, how dose this systems work? you can attach mechanim to your GO for example, and AttachGameobjectToEntity to mechanim gameobject. like this figures

#

now when you are Instantiate your Entity, just call SpawnFor at childs. its spawning attachment at GO world for Instantiated Entity. now you have injected GO, at hybrid systems and sync points you can get Attach Gameobject only by component data and sync your data.

#

it is my idea that used at my project, but you can not use that for many objects, because its processing at main thread

#

and sry for my english

#

if you want know more i can send you example

gray flicker
#

Is it possible to write to an IBufferElementData buffer inside an IJobForeach?

zenith wyvern
#

If the buffer is a part of the query for that job then yes

#

You shouldn't really need to write an IJobForEach in most cases, the new lambdas are simpler to use and do the same thing

gray flicker
#

with new lambda I can't figure out how to use methods and stuff

zenith wyvern
#

What are you trying to do?

gray flicker
#

I'm creating mesh data from voxel data, I'm trying to set a buffer with triangles and a buffer with vertices so I can build a mesh in another system

#

Creating the mesh data is quite intensive, so I don't want to run it on the main thread, but it is also quite complicated, so I need a class or struct to do the job

#

Can you instantiate object inside the lambda? As in, move everything to a seperate class and such?

zenith wyvern
#

I just did exactly this last week. I mean I was building it from a heightmap but yeah, same thing

#

You shouldn't need a class at all

gray flicker
#

If I don't use methods or a class, i'm gonna have a 300 line lambda

#

I wrote my own interpretation of the greedy meshing system, and if I don't separate my code I will lose my mind πŸ™‚

zenith wyvern
#

Well the answer is no, you can't use any kind of class or managed object inside jobs or burst

gray flicker
#

Is a static class managed?

zenith wyvern
#

They did add a FunctionPointer thing to burst recently but I haven't messed with it

gray flicker
#

I should really know this stuff πŸ™‚

zenith wyvern
#

No, you can call static functions as long as they never touch any static data that isn't constant

gray flicker
#

So no changing fields?

zenith wyvern
#

Yes, basically the job needs to know absolutely everything about what's going into it and it can only touch that, unless it's in a nativecontainer

gray flicker
#

That makes sens

#

since it should run in a job

solar ridge
#

Well the answer is no, you can't use any kind of class or managed object inside jobs or burst
Welllll.... half true

#

If the job is not bursted and not scheduled you can use managed πŸ™‚

#

To an extent

#

I would highly advise against it, but in some areas it is unavoidable

gray flicker
#

So using run, and that is on the main thread?

solar ridge
#

Correct

zenith wyvern
#

If you have your mesh triangle and vert data in buffers then you should be able to do all your work on those using jobs and ECS. You can create as many separate static functions to pass in and modify your data as you need, as long as those functions aren't messing with mutatable static fields

solar ridge
#

But you keep the Entity foreach collection

zenith wyvern
#

I mean if the job is not bursted and isn't scheduled then it's by definition not a job and not using burst

solar ridge
#

By what definition?

zenith wyvern
#

Meaning it's just...running on the main thread

solar ridge
#

An Ijob can be run on main thread

#

doesnt make it not a job

#

The performance gain is MUCH lower on main thread

#

but doesn't mean you strip it of its title for doing a poor job πŸ˜‰

#

I think you might be meaning running as a job

zenith wyvern
#

True, but in this context we're talking about how we can use jobs to process vert and mesh data faster. If we just run it on a main thread and it isn't bursted it doesn't gain any benefit from being a job. In fact it may as well not be a job at all and could be a function

solar ridge
#

vs being a job

#

Note, I am allllll for non main thread bursted code

#

My particular use case unfortunately can't be bursted in many areas :\

#

but I love using burst where I can

#

Websocket server -> byte[] data -> json -> data blob with string information

zenith wyvern
#

Hahah, I noticed you seem to be living in string hell

solar ridge
#

Yeaaaa

gray flicker
#

What would be the downside of using an IJobForeach instead of an Entities.Foreach?

solar ridge
#

Mmm not sure there is a downside

#

just more verbose

gray flicker
#

Since they both become jobs

zenith wyvern
#

Just having to write more boilerplate

solar ridge
#

Ijob has existed longer

gray flicker
#

Yeah, IJobForeach is more verbose?

solar ridge
#

Correct, as it was their first implementation

#

well 2nd

zenith wyvern
#

The lambdas are much more expressive and easier to read and change

gray flicker
#

I don't mind writing the boilerplate if I can get it to work

zenith wyvern
#

imo

solar ridge
#

Used to be IJobProcessComponent<> or something similar

#

The lambdas are nice, but it is hard to see some magic in some cases

#

IE: a variable being captured in local context

#

vs IJob{ THIS VARIABLE EXISTS}

zenith wyvern
#

Yeah I usually just explicitly write out all the capture variables immediatley before the ForEach to keep it clear what's going on

solar ridge
#

Code that compiles fine in IDE, but doesnt sit well with the editor is at times annoying

gray flicker
#

Like an EntityQuery @zenith wyvern

solar ridge
#

Well, EntityQuery can exist on either

#

you create the query in create

#

not in update

gray flicker
#

You can't use EQ in the JobComponentSystem right?

zenith wyvern
#

Yeah you can capture the query from the Foreach, but it is very weird and magicky

solar ridge
#

You do Scuba

gray flicker
#

Hmm

solar ridge
#

The ComponentSystem class I have banned myself from using πŸ˜‰

zenith wyvern
#

It feels like ComponentSystem will be deprecated at some point now

solar ridge
#

Well the query is assigned in both in similar ways

#

the Ijobforeach you assign when you go to schedule iirc

#

The EntitiesForeach, you use a method

gray flicker
#

I mean you can't do this:

Entities.With(_query)

solar ridge
#

WithStoreEntityQueryInField

gray flicker
#

Missed that one

zenith wyvern
#

The query is implicitly created by the combination of .WithAll, .WithNone, and whatever fields are in the lambda expression

solar ridge
#

^

gray flicker
#

Why not just call it With?

#

πŸ™‚

zenith wyvern
#

And you can capture that implicit query with what Soaryn just wrote

#

the capture happens at compile time so you're free to use it before the foreach even runs

solar ridge
#

You know what would be fancy dancy magic: If they made a switch case for BlobStrings that is burstable

#

as they are already looking into Burstable string literals

#

So allocation of the BlobString would still be nonbursted

zenith wyvern
#

It can't be called 'With' because you're not passing in a query. You're getting a query from the foreach

solar ridge
#

but comparison would be faaast

zenith wyvern
#

Oh you mean the WithAll

gray flicker
#

Don't exactly know what BlobStrings are yet πŸ™‚ I worked on a product that stored sheet data in a blob, but never worked on that part myself.

solar ridge
#

BlobStrings can only exist in Blobs

zenith wyvern
#

I guess they want to be explicit and separate it from "WithAny" and "WithNone"

solar ridge
#

but Blobs being immutable data is nice

#

as you just pass around a pointer to the data reference

#

This way, I can go from a json data object -> BlobStruct

#

Keep what I want and make it read only persistent data

zenith wyvern
#

I'm still not sure how to use blobs properly right now. I guess they're a way to pass around managed types inside components?

#

I haven't really read up on them too much

solar ridge
#

Not managed types

#

They are immutable data structures

#

so

gray flicker
#

So I'm getting this error message:

InvalidOperationException: GreedyChunkMeshingJob.Data.Buffer is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
On an IJobForeach_EBBBCC where I call Add on the buffer. I thought I could write to a buffer in a JobComponentSystem. Isn't that correct?

solar ridge
#

If I have lots of systems that need said data, I have the understanding that data will never mutate

#

so it is pure read only

#

If I want to "replace the data" then the pointer is reassigned

gray flicker
#

Immutable is awesome, I worked with NGXS a lot, an immutable data store for Angular

zenith wyvern
#

@gray flicker If you want to write to buffers in parallel you need to add [NativeDisableParallelForContainerRestriction] on the container, but make sure you know 100% that you are never writing/reading from an index at the same time

gray flicker
#

I'm only calling Add on the buffer

#

So I won't be doing that I guess

solar ridge
#

"BlobAssets are made for zero cost deserialization for large amounts of data. AnimationClip, CollisionMesh, CurveData is a good example of what we think belongs into a BlobAsset." - Joachim

#

In my case, I can store an int, multiple blobstrings, and an enum for the data I need

gray flicker
#

It can't find [NativeDisableParallelFor]

#

what the hell

zenith wyvern
#

Yeah I wrote it wrong, I fixed it in the edit...I think. It's something like that

solar ridge
#

NativeDisableParallelForRestriction

gray flicker
#

NativeDisableParallelForRestriction

zenith wyvern
#

It's very long and awkward

gray flicker
#

Yeah got it! πŸ™‚

zenith wyvern
#

I see so it lets you pass around some huge data structs without copying them on the stack all the time I guess

gray flicker
#

that didn't solve it. Weird

zenith wyvern
#

Yeah that would let you write to the buffers in parallel, I'm not sure about doing adds in parallel

#

I know you can for sure do a Resize inside a job

#

So you could resize the buffers and do parallel writes

gray flicker
#

Aaah wait

#

I'm adding my buffers incorrectly I think

#

Man, these buffers... I can't get it right

#

Could I use a nativearray in an IComponentData instead?

#

At least I know how to set a new component

zenith wyvern
#

There is some way but it requires unsafe code so I've never messed with it

gray flicker
#

So if I know for sure it's just gonna be set in one system, and read and removed in the other, it's fine?

#

If I use NativeDisabledContainerSafetyRestriction then

zenith wyvern
#

I think so. Based on the description on that page it sounds like that attribute might have some unexpected side effects that persist outside the job though so I couldn't say for sure

gray flicker
#

Ooooh

#

I'm using Vector3 in a buffer. Might that be it?

zenith wyvern
#

Seems like you can add to a buffer in foreach:

        inputDeps = Entities
            .ForEach((ref DynamicBuffer<IntBuffer> b) =>
            {
                if (b.Length < 10)
                    b.Add(5);
            }).Schedule(inputDeps);
#

Works fine

#

I think it should be fine to use Vector3, but you should definitely be using float3

#

It's much more convenient when working with the math library

gray flicker
#

Somehow I'm not allowed to post a bunch of code

zenith wyvern
#

If it's too much you can use some pastebin thing

gray flicker
#

This does not work

#

Keep getting the not declared [ReadOnly]

zenith wyvern
#

I see a few problems

#

You can't assign the results of a command buffer back to anything and expect it to survive outside the immediate loop

#

Anything returned from a command buffer is temporary, if you need to work with the results of it you should query for it in another job

#

If possible your buffers should all be on the same entity. This makes it really easy to work with them since they can all be in the foreach fields and the safety system will not complain about trying to do parallel operations between separate buffers

gray flicker
#

Okay, so I should add the buffer in the system that adds my tag to run this job?

#

And then add my buffers to that query?

#

The buffers are on the same entity, so that's a start πŸ™‚

zenith wyvern
#

If they are on the same entity what are you passing in to the job? Why aren't they just in the foreach parameters?

#
private bool[,] traversed;
gray flicker
#

The voxels buffer is where I store my voxels

zenith wyvern
#

Managed array inside a job

gray flicker
#

Ah damn

#

I thought I could add them to the entity when I actually need to add them, but guess I should add them beforehand

zenith wyvern
#

So your voxels array is just one big buffer of voxels, and you're intending to build your mesh data from that?

gray flicker
#

I have an IBufferElementData called Voxel, with three fields

#

So I guess you are correct?

#

I'm not really familiar with parallel programming, learned about threading in uni, but that's about it

#

Would it be better to store my voxel data in a native array?

zenith wyvern
#

So the voxels, tris, and verts buffers are all on the same entity right?

gray flicker
#

yes

#

So I tried instead of using these buffers to set a shared component data, but that's not possible right?

safe lintel
#

You need to use BufferFromEntity if you are trying to access another entities buffer, only just woke up but I believe its what you want

gray flicker
#

Good morning

zenith wyvern
#

He shouldn't need to if they're all on the same entity

gray flicker
#

No, I just need the data from the same entity luckily

#

Off topic: this discord is awesome. Lot of really cool people that want to help!

zenith wyvern
#
        inputDeps = Entities
            .ForEach((in DynamicBuffer<Voxel> voxels, ref DynamicBuffer<Vert> verts, ref DynamicBuffer<Tri> tris)=>)
            {
                for( int i = 0; i < voxels.Length; ++i )
                {
                    tris.Add(MakeTris(voxels[i]));
                    verts.Add(MakeVerts(voxels[i]));
                }
            }.Schedule(inputDeps)
#

I guess somehting like this is what you're looking for?

#

With how you have it set up?

#

That's not really...parallel I guess

safe lintel
#

If its the same as voxel chunk and chunkupdatedtag why not add it into the job's component reqs?

gray flicker
#

@zenith wyvern it's way more complicated than just looping over the voxels once, but essentially yes that is what I am doing

zenith wyvern
#

That's pseudocode but maybe gives you an idea of what it should kinda look like

safe lintel
#

Did you hit a limit with trying ebbbbcc?

gray flicker
#

One b less

#

Not yet

#

EBBBCC

#

Also, I just removed the two c's, don't actually need that data so I'm using [RequireComponentTag(typeof(Chunk), typeof(ChunkUpdatedTag))] now

safe lintel
#

Ah I'm confusing commandbuffer with dynamicbuffer, yeah need more coffee

gray flicker
#

Haha

#

I'm drinking beer already

#

@zenith wyvern if my managed array wasn't a field, but a variable in methods, would that be ok?

zenith wyvern
#

Depends what the methods are accessing

#

It seems like you would want to store whatever the managed array was trying to do on the entity, or just pass it in as a nativearray

#

You can do NativeArray<bool2>

gray flicker
#

bool2?

zenith wyvern
#

Or I guess it's more likely you'd want a 1d array representing a 2d array of bools

gray flicker
#

Yeah I just converted it to a 1d array

zenith wyvern
#
            [NativeDisableParallelForRestriction] public DynamicBuffer<Vertex> _vertices;
            [NativeDisableParallelForRestriction] public DynamicBuffer<Triangle> _triangles;
            [NativeDisableParallelForRestriction] public DynamicBuffer<Voxel> _voxels;
            [NativeDisableParallelForRestriction] private NativeArray<bool> traversed;

I'm not sure what these are supposed to be doing

#

They're public fields but you're not assigning anything to them when you create the job and you're trying to assign to them isnide the job which would do nothing

gray flicker
#

But I can't assign them from outside the job right? Because I would need an entity to find the buffer?

zenith wyvern
#

That's what the parameters in the foreach are doing, they are referencing the buffers on your entity. If you want to read or write to your buffers you do it through the parameters in the foreach

#

And you can add [ReadOnly] to the readonly parameters to let the safety system know you're not writing to that buffer

#

Which is really awkward which is why I vastly prefer the lambdas

#
            private void UpdateChunk(Entity entity)
            {
                // Loop through the dimensions
                for (int currentAxis = 0; currentAxis < 6; currentAxis++)
                {
                    /**
                     * Loop through the layers of this dimension
                     */
                    Axis axis = (Axis) currentAxis;
                    Vector3Int layerDimensions = GetAxisLayerDimensions(axis);

                    for (int currentLayer = 0; currentLayer < layerDimensions.z; currentLayer++)
                    {
                        RenderMask(layerDimensions, axis, currentLayer);
                    }
                }
            }
#

You're passing in an entity here and doing nothing with it? I guess this is just temporary while you figure out how to stop the first errors?

gray flicker
#

Yes

#

I still need to refactor some stuff

#

Just trying to get rid of the error, entity is gonna go

zenith wyvern
#

It seems like your job struct is insanely large

gray flicker
#

yes

#

I am thinking of ways to cut the work up

zenith wyvern
#

I would get rid of everything in there and put it into helper classes or something. It's just dirtying everything up and I can't even tell what the job is trying to do

#

Which is fine since it's not my code but if you want to help you, yeah

#

I need ot be able to understand what I'm reading

gray flicker
#

Well, it's my own interpretation of an algorithm I found that was even more complex, but all rammed in one method with variables that only have one letter

#

But what it does is not really the problem. The buffers are

#

I just commented everything, only added vertices.Add(new Vertex { Value = Vector3.down})

#

still get the readonly error

#

That's with the buffers in the IJobForeach

#

so in the parameters of the Execute method

zenith wyvern
#
        [RequireComponentTag(typeof(Chunk), typeof(ChunkUpdatedTag))]
        struct GreedyChunkMeshingJob : IJobForEachWithEntity_EBBB<Voxel, Vertex, Triangle>
        {
            public EntityCommandBuffer Buffer;

            public void Execute(Entity entity, int index, [ReadOnly] DynamicBuffer<Voxel> voxels, DynamicBuffer<Vertex> vertices, DynamicBuffer<Triangle> triangles)
            {
                 
            }
    }
#

That's what your barebones job should look like

#

From there you can process your voxels as needed and push them to the vert and triangle buffers

#

Does that make sense?

gray flicker
#

That does make sense

zenith wyvern
#

That should compile

gray flicker
#

It doesn't have compile errors

#

only runtime

#

That readonly error is runtime

zenith wyvern
#

You get readonly errors from just that?

#

The empty job I mean

gray flicker
#

At the moment

#

I removed the traversed and only call vertices.Add in the execute

#

I get a null reference somewhere

#

Let me check it out

#

It's in generating the IJobForeach

#

no

#

It's in ExecuteChunk

#

NullReferenceException: Object reference not set to an instance of an object
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <7d22f8e71133418c87c7b26ea181f3e3>:0)
Unity.Entities.BufferAccessor1[T].get_Item (System.Int32 index) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/Iterators/ArchetypeChunkArray.cs:712) Unity.Entities.JobForEachExtensions+JobStruct_Process_EBBB4[T,T0,T1,T2].ExecuteChunk (Unity.Entities.JobForEachExtensions+JobStruct_Process_EBBB4[T,T0,T1,T2]& jobData, System.IntPtr bufferRangePatchData, System.Int32 begin, System.Int32 end, Unity.Entities.ArchetypeChunk* chunks, System.Int32* entityIndices) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/IJobForEach.gen.cs:3446) Unity.Entities.JobForEachExtensions+JobStruct_Process_EBBB4[T,T0,T1,T2].Execute (Unity.Entities.JobForEachExtensions+JobStruct_Process_EBBB`4[T,T0,T1,T2]& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.4.0-preview.10/Unity.Entities/IJobForEach.gen.cs:3402)

#

That even happens without the vertices.add

zenith wyvern
#

No idea on that one

#

Just reduce your job more and more until it goes away, then figure out exactly what your'e adding that's causing it

gray flicker
#

I think it might actually be a bug

#

I Changed IJobForEachWithEntity_EBBB to IJobForEachWithEntity_EBBBC and it works

#

I had the bare bone minimum

zenith wyvern
#

Well now that you got rid of your errors you should be able to process your buffers at least

gray flicker
#

I also get the readonly error back when I add the EntityCommandBuffer back to the job

#

I can't paste 3 lines of code 😦

zenith wyvern
#

Oh, hahah. You need to use a concurrent command buffer because it's Foreach

gray flicker
#

Ooooh

zenith wyvern
#

I thought you were getting the readonly error from your buffers, but it was the command buffer

gray flicker
#

THat makes sense

#

That works!

zenith wyvern
#

To paste code do:
```cs
Code here

gray flicker
#

Hahaha

#

I crashed unity

#

πŸ™‚

#

added back my code

#

I'm gettting other error messages now, but I'm gonna call it a day

#

Time for some Overwatch

#

Thank you for your help @zenith wyvern!

zenith wyvern
#

No worries dude, good luck

worldly pulsar
#

Looking for an idea for a case like this:
Imagine you are making FTL, you have your overworld map and your encounter screen. Each encounter should probably be a subscene (at least in my case it is), and any entities you spawn during the encounter you want destroyed when it ends. You still want things like the state of the ship etc around during the encounter. Like what in GameObjectLand you would do with SetActiveScene - you spawn all the new gameObjects into the encounter scene and unload it when you are done.

Current ideas:

  1. Tag all the encounter related entities and just Destroy(encounterRelatedQuery) at the end. This is annoying and error prone because you have to remember to do add the tag every single time you spawn an entity.
  2. Inject the encounter subscene into a new World (no idea how to do that actually), and destroy that world when done. Probably a better idea but still annoying b/c now I'd have to juggle some shared state (like the UI, mouseover state etc), and move the persistent state back and forth (like e.g. nr. of missiles in FTL)

Anyone has something better? Or knows how to load a subscene into another world?

worldly pulsar
#

That has the same problem as 1. - forget to do that in one place and you have a stray cannonball/spawner/vfx handle on the overworld map or next time you start an encounter
(my actual problem may be the mess I've made in the encounter code, I probably spawn entities in more places than necessary)

#

I still like the elegance of the old-style SetActiveScene solution - unload the scene and don't worry about anything else.

tawdry tree
#

Use tags component - EncounterEntity, and a simple query to nuke all of them should be enough

#

Though, switching scenes seems more 'correct' to what you're trying to achieve

dull copper
#

you use and abuse the tools you're given

tawdry tree
#

If you go through with that, you probably use the gameobject style of switching scenes, and rebuild the encounter each time. Which sounds a bit cumbersome and error prone, but less so than having to remember to remove everything.

dull copper
#

Unity has traditionally let users come up with the framework so since there's been nothing enforced, it's been more of "whatever works"

hollow sorrel
#

what's wrong with using a seperate scene for encounters

tawdry tree
#

IMO there is nothing wrong with it. It's more of a preferred design thing

#

A singleton (IsInEncounter?) and tags (EncounterEntity) should be sufficient to disable any overworld logic while in an encounter, and also clean up after yourself afterwards.
For UI you prolly use gameobjects anyway, so do it the normal way, and other than that you can just have the overworld stuff be physically away from where the camera is during an encounter to hide it.

#

Scene change is probably the easier way to manage, since it's a full context switch, but I'll admit I dunno how ECS works with multiple loaded scenes, of which not all are active.

worldly pulsar
#

@tawdry tree rebuilding the encounter is not an issue (it's literally just a subscene load). My issue is that I know I will forget to tag stuff with EncounterEntity (or add to a collection as Topher suggested) and I'm looking to recreate the old style solution πŸ˜›

tawdry tree
#

If you do it with subscenes, then can't you just nuke the subscene, which will be reloaded the next time? Assuming the scene load isn't particularly heavy

worldly pulsar
#

I'm talking about spawned entities

#

like in FTL you'd have rockets flying around

#

that are not associated with the subscene

tawdry tree
#

Oh yeah

#

Archetypes, maybe?

#

My mind says something can be done with those. Using a base archetype which has EncounterEntity, and other stuff like projectiles and such having more specialized archetypes?

worldly pulsar
#

Keep in mind this is gameplay code, heavily iterative, changes 50 times a day. Any solution that involves "remember to do X every time you spawn an entity" will be error prone

tawdry tree
#

Honestly, I don't think you should worry about missing one here or there - It can cause bugs, yes, but assuming you do other logic well (no simulating those while not in an encounter), they should be fairly easy to debug

#

^

#

You seem to want to track them, but are worried that you forget some

#

Yeah, it's prolly gonna happen, but then you fix it. woop woop

worldly pulsar
#

I'm actually thinking about going with separate world for the encounter entities (still looking for a way to load a subscene into a newly created world)

#

Hmm, having wrappers around Instantiate/CreateEntity might actually be the way to go (and now I feel dumb for not thinking about it earlier πŸ˜› )

haughty bloom
#

Hey everyone! Quick question: I'm trying to download the 0.4.0 preview of the Entities package, but the package manager is only showing 0.1.1 . Is 0.4.0 not available for the Free version of Unity?

zenith wyvern
#

Yes it's available, maybe you need to update your version of Unity

#

I think the latest entities is only supported in 2019.3.1+

haughty bloom
#

hmm for some reason the only version I'm seeing available to download is Unity 2019.2

#

I'll have a look and see what's going on. Thank you!

zenith wyvern
#

It's pre-release so it's in the beta versions

coarse turtle
#

Well I guess I recently got anchoring/scaling - though it needs work on canvases with large hierarchy depths 😐

solar ridge
#

As a note, DOTS as a whole is free to use. It would be silly if they restricted access to features again, when just coming away from that paradigm

#

The ONLY thing I can really think of with feature limitation is the dark theme now, and eventhen... you can technically make your own

autumn sleet
#

I wouldn't pay a cent for DOTS features since none of them is stable or actually usable.

radiant sentinel
#

@coarse turtle ask at ui-ux

#

@autumn sleet ? really, just don't upgrade packages if you has not bugs.

#

i got cup of my university parallel programing cup, only for ECS and Jobs Burst Presentation πŸ˜‚

fringe sinew
#

I have some trouble understanding the whole gimmick of scene conversion

#

As a concept, it is great. We prepare a batch of entities beforehand and basically just dynamically instantiate them. It's neat (though an actual editor for DOTS would've been better)

#

What I don't get is how it's realized.

#

Specifically, three questions:
-Why do we need to use StreamingAssets for such a thing?
-Why can't we ourselves manage the binary files and load them however we want?
-Why is such a thing subscene exclusive? I also want to have such a thing for normal prefabs.ffff

#

And also one thing about the blob assets. UT specifically says that they are designed for storing serialized data that you create or assign from the editor. But how in the world can that be a reasonable solution when data cannot be shared across different scenes and entity components (think an AnimationClip duped over 200 scenes)? This is just too baffling.

fringe sinew
#

Alright that API link really opened my eyes on some of the stuff. Thanks

dull copper
#

@solar ridge I dunno to what that note was for but you've probably seen earlier DOTS presentations where Joachim has told DOTS sources will be available for pro subscribers

#

that makes zero sense IMO

#

and it's only ever been communicated by Joachim on his presentations, none of the official docs/forum posts have indicated this in any way so it's always been weird notion

#

not having source access has always been one of the biggest disadvantages when using Unity and now they at least give package sources which is still better than nothing

#

would hate to see that going behind paywall again (altho I'm actually on Unity Plus myself)

#

I completely forgot about that, should have asked Joachim at Unite what was that deal about πŸ˜„

#

because it's close to impossible to get him answer that on the forums

#

that being said, I'd be totally fine if Unity gave pro users access to their internal dev repos to get earlier access to things, as long as it wouldn't mean they'd delay the official packages further because of that

#

it would give more value to pro subscribers and still wouldn't take anything out from others

#

please do πŸ˜„

#

because that was super confusing on earlier DOTS presentation, lead to a lot of speculation among community

#

yeah, that's what I assumed

#

was just throwing that out as a possiblity if Unity wants to give more value to pro subs etc

solar ridge
#

From copenhagen it was indicated that all dots sources were in and you can see them. Dots is viewable, Unity sources are locked iirc

#

If you want to see the black box code I believe you need Pro, but that has been true for a while

#

As for Dots, you can already see the sources in the packages no?

autumn sleet
#

@radiant sentinel okay

dull copper
#

@solar ridge if we talk about how things are today, you get full c# source code for most unity packages, excluding burst and any native c++ code these things depend on. You can license Unity's full source if you are on pro sub but it doesn't include it, it's very big $$$ fee on top to get that, you just have to be on pro to be able to license it.

#

the thing I was referring was two older DOTS presentations where Joachim advertised DOTS to ship with full source code for pro subscribers

#

the videos I'm referring to are (with timestamps):
https://youtu.be/7ons0eVjhDY?t=1650
https://youtu.be/aFFLEiDr3T0?t=841

Joachim Ante opens the ECS track by presenting what he and his team have been working on for the last 6 months.
More info: https://on.unity.com/2Q5KxR1
Joachim Ante (Unity Technologies)

β–Ά Play video

March 23, 9:00 am (San Francisco) - Unity's CTO and Co-Founder, Joachim Ante shares the principles behind evolving Unity from a GameObject engine to be Entity Component System (ECS), and the benefits it will bring to developers.

Speakers:
Joachim Ante, CTO and Co-Founder a...

β–Ά Play video
#

the GDC 2018 one was even more unclear as it was more like "what if", but Joachim was more specific of DOTS packages being pro licensed on Unite LA later on 2018

#

also we had c# package source access when those talks were held

#

so there's few possible reasons for all this:

  • He assumed the c# source code wasn't available to all and wasn't kept up-to-date about it
  • The grand plan was to expose c# source code to pro licensees only
  • ?
trail burrow
#

@dull copper cant we already see all C# source of all entity/dots packages?

dull copper
#

yes

trail burrow
#

or we talking about the native parts of dots?

dull copper
#

and we did get them when those talks were held

#

we are talking about c# package source code, as mentioned by Joachim on those talks

#

well, the GDC talk didn't talk about packages but more of referred to it

#

but Unite LA talk is super clear that he means c# packages

ashen flame
#

In ECS, if I need to have an entity look at an other entity, do I need to do a copy of its location or can I reference a specific entity in my data?

coarse turtle
#

You can reference to the other entity

public struct OtherEntity : IComponentData
{
  public Entity Other; // <- Store the other entity there for lookups on its data
}
ashen flame
#

Ah nice! Thank you. I didn't know if this was a good practice or not.

coarse turtle
#

Unity does this to keep hierarchy views so an entity knows its parent πŸ™‚

dull copper
#

@dark egret shouldn't be, considering Burst uses SSE4 which has been supported by AMD after ancient Phenoms and there's also SSE2 fallback that's supported by 100% of current PC CPUs

#

so I'm guessing if one is worried about those old AMDs the only worry is if the fallback setup works right

#

I think there were some issues with it at first but I'd assume those issues have been long fixed by now

gusty comet
#

Sorry to be a bother, but what data type should I use to represent color data in ECS?

#

Translation uses float3.

rocky basin
#

float4 from the mathematics library?

#

That would be RGBA. If you only need RGB, then float3

hollow sorrel
#

i think UnityEngine.Color should actually be fine since it already is a struct

gusty comet
#

oh? nice! huge thanks to you both, I have enough to work with now.

rocky basin
#

I would imagine float4 is more Burst compatible, if it's recommended to use float3 over Vector3, which is also a struct.

#

I don't know if that's recommended though.

hollow sorrel
#

UnityEngine.Color uses 4 floats, wouldn't Burst be able to optimize that as a float4 if that's faster?

gusty comet
#

I can profile both and report back

hollow sorrel
#

oh float4 is also just a struct with 4 floats

#

dunno if Burst has like special consideration for that but if not i'd just use Color since rgba is more descriptive than xyzw

gusty comet
#

i try to use a dynamicbuffer for the first time, but it always throws a nativearray has been deallocated exception. Is it not allowed to add an element to a buffer and then read/index it in the same frame?

gusty comet
#

Ok found the solution. I was iterating through the bufferelements and created an entity with the entitymanager causing the buffer to be invalid.

#

Is there any way to remove a dynamicbuffer from an entity? There seems to be no method available in EntityCommandBuffer and EntityManager

trail burrow
#

@hollow sorrel I know this is from yday, but yes burst has special considerations for the built in new math types

dull copper
#

^

opaque hemlock
#

Hey guys, is it possible to use WheelColliders with dots and the new physics stuff?

dull copper
#

wheelcollider is from physx

#

so to use it with dots, you need to go with hybrid

opaque hemlock
#

Hmm okay. Thank you

dull copper
#

also none of the physx stuff works with Unity Physics package

#

as they are two completely different physics engines

#

you can implement your own wheel system with Unity Physics tho

#

and there's less than ideal example on Unity Physics samples on DOTS sample repo about it

opaque hemlock
#

okay cool I will look into that. Thank you

pseudo epoch
#

Hi all, i'm getting this error so i'd like to know if any job inside a jobcomponentsystem using commandbuffer must be scheduled or is there a way to add command to commandbuffer without scheduling the job, i'd love to schedule it but i need access for the moment to the entitymanager

worldly pulsar
#

Use EntityCommandBuffer instead of EntityCommandBuffer.Concurrent?

pseudo epoch
#

Testing

#

@worldly pulsar Working ! noice ! so what toConcurrent does ? i must admit i've used unity spawner scripts from samples ^^'

worldly pulsar
#

If you want to write to the buffer from multiple threads (like from IJobForEach) you need the concurrent version

pseudo epoch
#

ha yey got it thx a lot !!

worldly pulsar
#

@hollow sorrel here's a really good talk about Unity.Mathematics and simd that touches on the differences between explicit simd (which is what you get when using float4 and friends - they are hardcoded to generate simd instructions) vs autovectorization (the "try and make it fast" system used for any kind of 4 floats in a struct/array of floats etc situations).
It's also a nice intro to simd programming in general:
https://www.youtube.com/watch?v=BpwvXkoFcp8

This session addresses how we are expanding the scope of the Burst Compiler to enable even the most demanding, hand-coded engine and gameplay problems to be expressed in HPC# via direct CPU intrinsics. Andreas shares the reasoning and use cases; as well as discussing implemen...

β–Ά Play video
#

@dull copper My trust for the article you linked dropped a bit when it said "Burst is generating SIMD instructions for both" under an asm listing with 1 simd instruction in it πŸ˜› (the Vec3 case is not simd at all)

pseudo epoch
#

I've removed an hybrid component from entities and i still find his behaviors in my profiler while my job using this script don't run anymore (logic since i've removed the component from the entities) so why is each instance of the script is still running ? Does remove don't destroy the component ?

dull copper
#

@worldly pulsar how so?

#

he even gave the generated asm: ```
; Vector3
movss xmm0, dword ptr [rdx + rdi - 8]
movss xmm1, dword ptr [rdx + rdi - 4]
movss xmm2, dword ptr [rdx + rdi]
addss xmm0, dword ptr [rcx + rdi - 8]
addss xmm1, dword ptr [rcx + rdi - 4]
addss xmm2, dword ptr [rcx + rdi]
movss dword ptr [rsi + rdi - 8], xmm0
movss dword ptr [rsi + rdi - 4], xmm1
movss dword ptr [rsi + rdi], xmm2

; float3
movsd xmm0, qword ptr [rcx + rdi]
insertps xmm0, dword ptr [rcx + rdi + 8], 32
movsd xmm1, qword ptr [rdx + rdi]
insertps xmm1, dword ptr [rdx + rdi + 8], 32
addps xmm1, xmm0
movss dword ptr [rsi + rdi], xmm1
extractps dword ptr [rsi + rdi + 4], xmm1, 1
extractps dword ptr [rsi + rdi + 8], xmm1, 2```

tiny ore
#

The first set doesn't have any SIMD

#

Just regular load,add,store

#

addps is the SIMD instruction

dull copper
#

ah right, only float3 is going wide

tiny ore
#

yes, so the blog post is not technically accurate (in other aspects as well)

#

It's a bit naive

dull copper
#

I'm surprised the perf dif isn't bigger in that case

tiny ore
#

That's a bit obvious actually

dull copper
#

maybe the amount of operations didn't show it yet

tiny ore
#

The bottleneck here is memory transfer, not CPU

#

And the transfer is the same amount...

#

So, analysis is naive, contains wrong information, and example is not particularly good (to say the least)

dull copper
#

anyway, the main point still stands that you should use new math lib with Burst πŸ™‚

tiny ore
#

You should test

#

There are several examples in which Burst even makes code slower... FHolm posted a good article on the topic here before the holidays.

dull copper
#

well, you do pay for interop overhead

tiny ore
#

Even for CPU intensive code in which your intuition says it should speedup things

dull copper
#

so if you only do few things it's obviously going to struggle

#

there's similar thing going on with the job system

#

Unity recently added some workaround to run jobs in main thread I think to overcome that for simpler systems

vagrant surge
#

@dull copper simd x4 wide code isnt faster than normal floats all the time

#

most of the time, having to pack those 4 floats into a vector register has overhead

#

on simple tests like doing very simple math on an array, its 100% memory bound

#

simd only really shows a proper xN speedup when its actual heavy calculation code

#

many times ive tried to manually vectorize a simple loop and it ended up same speed

worldly pulsar
#

a good practice for the kind of arr1[i] = f(arr2[i]); benchmarks is have memcpy as a baseline

dull copper
#

yeah, I can imagine

gusty comet
#

Anyone knows what a blobAssetStore is? It is needed when using the GameObjectConversionUtility.ConvertGameObjectHierarchy(gameObject, GameObjectConversionSettings.FromWorld(world, _blobAssetStore));
Works when creating a new BlobAssetStore and disposing it at OnDestroy. But what is the usecase?

verbal pewter
#

I'm trying to understand on a conceptual level how useful DOTS would be for procedural generation where everything needs to be processed one step after another (compared to Perlin noise where you can calculate each chunk individually). Specifically I'm working on a procedural city generator that grows from a single point. The fact that I can't calculate things in parallel makes me think that the usefulness I'd get from DOTS is fairly limited. Is that a fair assumption?

vagrant surge
#

dots is still faster @verbal pewter

#

also, are you sure that your procgen cant be parallelized?

#

using jobs for a producer-consumer pipeline could work

verbal pewter
#

@vagrant surge Alright, will give it a shot at some point then.

As for the possibility of being parallelized, I don't think so. If I take road generation as an example, the road that gets generated next is determined by a weighted list of possible road growth nodes. When a road gets added, a new growth node gets created. The roads need to be created in the same order every time so that the growth nodes are in the same order depending on the seed used. From my perspective it's important that each road be calculated one after another to ensure consistency. Maybe I'm just not aware of how it would be done?

#

There are some things like block subdivision and what not that could be parallelized, though.

hollow sorrel
#

@verbal pewter dunno about parallelization but there's a couple ways DOTS can help

#

if you're using gameobjects+monobehaviours replacing those with ecs will already be faster

#

not because ecs is so fast but because gameobjects+monos are just really slow

#

even replacing them with regular C# classes would be faster

#

then there's jobs you can use to even sequentially generate everything on different threads which will keep your main thread free

#

then you can apply burst on your jobs which is like telling compiler make it faster plz

verbal pewter
#

Hmmm, I wasn't aware of the possibility of sequential calculation. Though I'm not sure it would apply in my case. If step 2 of generation depends on the result of step 1, it wouldn't be able to start processing step 2 until step 1 completes. Right?

#

But I understand what you're saying about the benefit vs Monobehaviours. In my case the generation is using C# classes and then creating objects based on the results of that.

hollow sorrel
#

you can chain jobs together, if you pass in a jobhandle when scheduling it'll wait for that job to finish before starting the next one

#

so sequential is fine if that's what you want

verbal pewter
#

Oooooh, that's interesting. That's definitely something to look into.

#

The next thing I'm working on for it is a traffic simulation to upgrade roads, which right now I don't think needs to be sequential. Based on the paper I'm working off of that's the most processor heavy part of the whole process, so it seems like a good candidate for DOTS.

#

Thanks for your help, more to think about!

dull copper
#

HDRP is still the slowest part of the enter play mode thing, but now it takes something like 50ms instead 1200 which is more reasonable.