#archived-dots

1 messages Β· Page 111 of 1

opaque ledge
#

but yeah its not production ready thats for sure πŸ˜„

#

then again whole DOTS is not production ready

zenith wyvern
#

Technically it is but to be honest right now it doesnt seem like it's in a state where it can practically be used by anyone other than the person who wrote it

remote coyote
#

I'm kind of not liking the Ghost / Generation model that DOTS Netcode use right now. Having to generate code from an Inpsector interface to generate them is a bit meh.

#

I really like how RPCs are set up with code-only and no code generation

odd ridge
#

is it possible to destroy entities from within a threaded job?

#

or to generate an EntityCommandBuffer from within a threaded job?

flat talon
#

Entities 0.6 just released

odd ridge
#

no documentation for it yet?

flat talon
#

in the package, not online yet

odd ridge
#

oh okay

#

what's new

remote coyote
#

just got to wait another two months for the next Netcode update then

flat talon
#

[0.6.0] - 2020-02-17

Added

  • The [GenerateAuthoringComponent] attribute is now allowed on structs implementing IBufferElementData. An authoring component is automatically generated to support adding a DynamicBuffer of the type implementing IBufferElementData to an entity.
  • Added new SystemBase base class for component systems. This new way of defining component systems manages dependencies for the user (manual dependency management is still possible by accessing the SystemBase.Dependency field directly).
  • New ScheduleParallel methods in IJobChunk and Entities.ForEach (in SystemBase) to make parallel scheduling of jobs explicit. ScheduleSingle in IJobChunk indicates scheduling work to be done in a non-parallel manner.
  • New editor workflow to quickly and easily build LiveLink player using the BuildConfiguration API.
  • Adds Live Link support for GameObject scenes.
  • The SceneSystem API now also loads GameObject scenes via LoadSceneAsync API.
  • Added new build component for LiveLink settings in Unity.Scenes.Editor to control how initial scenes are handled (LiveLink all, embed all, embed first).
  • Users can now inspect post-procssed IL code inside Unity Editor: DOTS -> DOTS Compiler -> Open Inspector
#

Changed

  • The package com.unity.build has been merged into the package com.unity.platforms. As such, removed the dependency on com.unity.build@0.1.0-preview and replaced it with com.unity.platforms@0.2.1-preview.1. Please read the changelog of com.unity.platforms for more details.
  • Managed components are now stored in a way that will generate less GC allocations when entities change archetype.
  • Moved Unity.Entities.ICustomBootstrap from Unity.Entities.Hybrid to Unity.Entities.
  • World.Dispose() now completes all reader/writer jobs on the World's EntityManager before releasing any resources, to avoid use-after-free errors.
  • Fix AssemblyResolveException when loading a project with dependent packages that are using Burst in static initializers or InitializeOnLoad.
  • .sceneWithBuildSettings files that are stored in Assets/SceneDependencyCache are no longer rebuilt constantly. Because they are required for SubScene behaviour to work in the editor, if these are deleted they are recreated by OnValidate of the SubScene in the edited Scene. They should also be recreated on domain reload (restarting unity, entering/exiting playmode, etc).
  • EntityQuery.cs: Overloads of CreateArchetypeChunkArray, ToComponentDataArray, ToEntityArray, and CopyFromComponentDataArray that return a JobHandle (allowing the work to be done asynchronously) have been renamed to add Async to the title (i.e. ToComponentDataArrayAsync). The old overloads have been deprecated and an API Updater clause has been added.
  • Entities.WithName now only accepts names that use letters, digits, and underscores (not starting with a digit, no two consecutive underscores)
  • Updated package com.unity.properties to version 0.10.4-preview.
odd ridge
#

@flat talon where did you find this change log?

flat talon
#
  • Updated package com.unity.serialization to version 0.6.4-preview.
  • The entity debugger now remembers whether chunk info panel is visible
  • The entity debugger now displays the full name for nested types in the system list
  • The entity debugger now sorts previously used filter components to the top of the filter GUI
  • Bumped burst version to include the new features and fixes including:
  • Fix an issue with function pointers being corrupted after a domain reload that could lead to hard crashes.
  • Fix potential deadlock between Burst and the AssetDatabase if burst is being used when building the database.
#

-- SNIP-- Find the rest when you download the package under Library\PackageCache\com.unity.entities@0.6.0-preview.24

stable fog
#

please stop spamming...

flat talon
#

@odd ridge Library\PackageCache\com.unity.entities@0.6.0-preview.24

odd ridge
#

thanks @flat talon

remote coyote
#

ty Siggi

odd ridge
#

one thing I need to ask, when you edit a script in unity 2019.3, does it take a while for the editor to refresh or it's almost instant?

#

cause mine has been taking a while, like 5-10 seconds freeze on any script change and it's so annoying

crystal helm
#

it takes longer than before (asset pipeline2)

#

at me

odd ridge
#

for this reason I've been staying with 2019.2, but I'm missing on all the juicy DOTS updates...

remote coyote
#

World.Dispose() now completes all reader/writer jobs on the World's EntityManager before releasing any resources, to avoid use-after-free errors.

#

yey

warped trail
#

sweet 500ms iteration times😭

crystal helm
#

trust me, they are not juicy, if i wouldnt need it, i would wait a year longer to implement it

flat talon
#

tons of fixes in this release, including perf fix for subscene loading

odd ridge
#

@warped trail but 2019.2 does give me sweet 500ms iteration time! 😒 , but .3 is iteration time hell.. I can't stand it

#

@crystal helm I mean juicy compared to using Entities version 0.1

#

I can't even use the [GenerationAuthoringComponent]

#

in 0.1

crystal helm
#

you have to die one death 🀣

odd ridge
#

lol

flat talon
#

@odd ridge did you try the new faster play options in 2019.3 (domain/scene reload toggle)? Im getting very fast startup time on my DOTS project with that. Or you mean just your script compilation?

odd ridge
#

@flat talon I'm not sure what it is, but it's when I edit a script and click back into the Unity Editor. the editor freezes for 5-10 seconds

crystal helm
#

he means the recompiling

flat talon
#

Try moving your code files to an SSD, if not already?

odd ridge
#

sadly it's already on SSD. I mean I'm confused because 2019.2 recompile is almost instant, why is .3 so slow

flat talon
#

"Why is .3 so slow" is something a LOT of people are asking πŸ™‚ even the editor viewport is slower

odd ridge
#

it is! I've been avoiding it because of that

warped trail
#

there is huge posts about this "Why is .3 so slow" on forums πŸ˜…

odd ridge
#

I guess I'm stuck on Entities 0.1 until they fix that

flat talon
#

I've found at least one cause is the new UI. Moving an object in the scene view is slower when the inspector is open and updating the coords. Tabbing into another window (hiding inspector) makes moving objects faster

odd ridge
#

yeah I like the look of the new UI but if it what slows everything down, I wish we could choose

crystal helm
#

anyone knows how i get the jobindex inside a ICollisionEventsJob? 😦

#

found it, inside the job: [Unity.Collections.LowLevel.Unsafe.NativeSetThreadIndex] public int jobIndex;

remote coyote
#

Just reading through Netcode a bit to enhance my understanding of its inner tickings. In CommandReceiveSystem we have this little snippet:

int age = (int) (serverTick - tick);
age *= 256;
snapshotAck.ServerCommandAge = (snapshotAck.ServerCommandAge * 7 + age) / 8;

#

Any idea what these magic numbers are doing?

#

I'm following the first line

#

but why these magic numbers?

opaque ledge
#

soooo... we inherit from SystemBase instead of JobComponentSystem now ?

mint iron
#

i assume it lets you avoid the performance penalty of all the safety checks and events they're using in the normal ...ComponentSystem classes

opaque ledge
#

so no safety checks in SystemBase ? that doesnt sound useful

mystic mountain
#

@remote coyote Looks like some bit shifting

opaque ledge
#

hmm.. in new SystemBase, you can just Schedule().

zenith wyvern
#

Looks like the online docs have been updated. Not seeing any manual references to SystemBase aside from the API and changelog

#
Added new SystemBase base class for component systems. This new way of defining component systems manages dependencies for the user (manual dependency management is still possible by accessing the SystemBase.Dependency field directly).
#

Not really sure what they mean by this

#

Haven't they always managed dependencies for the user? Or am I missing something?

mint iron
#

seems like a typo to me; it says it managed dependencies, then explains how you can still manage dependencies manually, why would you need that if its already managed.

#

also dependencies seem jacked, getting 7 exceptions after upgrading.

#

it required collections 0.5.2 but collections doesnt seem to be on the dependencies list for entities at all. strange.

zenith wyvern
#

Oh I see, no more jobhandles...hmm

formal scaffold
#

Has anyone done Animations with DOTS and can point me to a good tutorial?

opaque ledge
#

yeah i think so as well Sark, so i guess we also dont need to worry about Run() πŸ€”

zenith wyvern
#

We do, Run will still force it to run on the main thread. As far as I can see it's just saving us from having to constantly pass "inputDeps" around when scheduling jobs

gritty grail
#

So an EntityCommandBuffer seems to not have any way to change component data

zenith wyvern
#

So if you call Schedule it would automatically assign it back to inputDeps and pass inputDeps in as a dependency under the hood

#

But it would still be scheduling a threaded job

opaque ledge
#

Yeah but idk, feels like Run lambdas should be also automatically dependency handled

#

i am however not really using Run much so i cannot confirm

mint iron
#

Had a look through SystemBase, looks like the new "ComponentSystem" is that being depreciated maybe?

OnUpdate() doesn't pass/return job handles.
Supports Entities.ForEach & Job.WithCode
Doesn't use [AlwaysSyncronizeSystem]
Doesn't lookup handles from dependencyManager by default
Still completes previous frame's job handle if "Dependency" field is set.
gritty grail
#

Wait

#

So does SetComponent do the same thing as SetComponentData?

zenith wyvern
#

Yes

opaque ledge
#

pretty much

gritty grail
#

oh my bad

#

nvm

zenith wyvern
#

Doesn't lookup handles from dependencyManager by default wat

opaque ledge
#

yeah thats what ComponentSystem did πŸ˜„

#

but ComponentSystem is succeded by JobComponentSystem, no ?

mint iron
#

@zenith wyvern just some extra work its not doing.

opaque ledge
#

I mean ComponentSystem and JobComponentSystem arent different things

#

so i feel like SystemBase is created to succeed JobComponentSystem

#

idk πŸ˜„

zenith wyvern
#

Since 0.5 JCS should be able to do anything ComponentSystem could do but faster

#

And with no allocations

#

Okay I see, so SystemBase does some extra checks to see if it can avoid doing dependency lookups if you're only using .Run() in it

#

So it should be a replacement for both ComponentSystem and JobComponentSystem

opaque ledge
#

oooh how do you know that πŸ‘€

zenith wyvern
#

The source file in the package

#

It's pretty small

opaque ledge
#

ah thats cooll, i generally dont go in there, its a minefield for me

#

but yeah i guess no need for AlwaysSync now

haughty flare
#

if you generate all csproj files, it is very helpful to jump into packages sourcecode ... gives better up-to-date information than docs

zenith wyvern
#

You should. There's usually helpful comments in there that you don't get from "GoToSource":

            // If outputJob says no relevant jobs were scheduled,
            // then no need to batch them up or register them.
            // This is a big optimization if we only Run methods on main thread...
#

Even if you don't deep dive on the code itself the comments are usually super helpful

opaque ledge
#

πŸ‘

#

good to know, maybe i will check that later

#

i should convert my code to SystemBase now

zenith wyvern
#

Well you might want to wait considering it's not even properly documented yet

#

Who knows how they might change it

haughty flare
#

comments like these are always helpful πŸ™‚ because it might be hard to spot differences in docs text... but in code, it is obvious

opaque ledge
#

Hmm idk, doesnt seem like its something that can be change drastically

#

but yeah i should wait i suppose

#

actually i will not

#

i am wild like that

#

@digital scarab and write better documentation for people like CurlyOne πŸ€”

#

So i have a question, about design, so i am making space ships, and these ships will have shield, armor and hull, when they are hit by a bullet(or laser rather) depending on what ship has it will deduct from that, so lets say ship only has shield and hull, shield will get hit first and then hull, if ship has armor and hull, armor will get hit first and hull, so do you guys think that i should make them seperate components or one big component ?
Seperate component means i have to check if ship has shield, armor or hull component and get hit properly, big component means i have to have bools inside that component and write their values, but that means there will be ships that will have wasted memory if they dont have all shield/armor/hull.

haughty flare
#

will they ever "lose" their shield/armor after creation? or is it just at 0 if depleted?
do you have shield regeneration? armor regeneration? hull regeneration?

#

don't think about objects if you are using ecs πŸ™‚ only think about pure data, how/when it changes and what is actually needed for one part of your logic to read/write to that data. it depends entirely on your specific usecase in most scenarios

crystal helm
#

@opaque ledge it depends strongly on how you want to implement all that, for example, is the shield just a number that "protects" the HP? or is it a collider that catches the impact before the hull does?

iam personally for flexibility, so i did seperate components for Reactor/Shields/Engines etc.etc. and Systems run multiple Jobs to process all the possibilitys.

opaque ledge
#

yeah for the time being it protects HP basically, and Armor is reducing the damage taken by hull.

slow epoch
#

One solution could be that the dmg are entities and the Health, Shield and Hull Systems are executed in order, modifying those Entities for that dmg to be applied?

opaque ledge
#

I think i will go with big component first, then we will see how things go.

#

So how do we register a jobhandle for command buffer ?

#

i mean in SystemBase

warped trail
#

look at ecs samples

#

they are updated

amber flicker
#

@opaque ledge Just in case there's any "why didn't anyone say" element - I'm generally pro smaller components. There aren't many downsides - whilst initially you may have a monolithic system that requires all the components, eventually I tend to find I mostly end up with more systems acting on single components. Especially as behaviour gets more complex. The upside I believe is that it's slightly faster to iterate only on the components you need. But like you say, quite easy to change later. I also tend to have a lot of bools rather than add/remove tags. You probably don't need every smaller component to have a bool though.

crystal helm
#

oh sry, i ripped out the part where you register the command buffer for producer;

endSimBuffer.AddJobHandleForProducer(projHandle);

opaque ledge
#

πŸ‘

#

got it thanks

zenith wyvern
#

Looks like the samples have been updated to use SystemBase as well

#

Huh, I didn't realize there was a sample for subscenes

formal scaffold
#

Hey, how would you follow an Entity with your camera? How can I get the Translation position in my system? One approach I found in the AngryDOTS demo is a singleton "Settings" class that holds the position of the player. But this isn't a pure DOTS approach.

gritty grail
#

So, how do I do GetComponentData with a CommandBuffer?

zenith wyvern
#

The answer to both your questions is that the only way to get component data is via EntityManager.GetComponentData or through a query

#

Or via GetComponentDataFromEntity

gritty grail
#

okay

#

thanks

dull copper
#

oh, neato, was wondering when the next entities drop would be

crystal helm
#

after updating the hybrid renderer my android build does not work like the editor X.x

opaque ledge
#

did you update the platform ?

#

Unity Platforms i mean

dull copper
#

I wonder if we'll get that entity preview ever for nonDOTS subscenes

crystal helm
#

unity platforms?

dull copper
#

I kinda gave up on the DOTS subscenes already as it's just too much additional pain if you don't use hybrid rendering

#

@crystal helm ```md

  • The package com.unity.build has been merged into the package com.unity.platforms. As such, removed the dependency on com.unity.build@0.1.0-preview and replaced it with com.unity.platforms@0.2.1-preview.1. Please read the changelog of com.unity.platforms for more details.```
opaque ledge
#

Unity Platforms in package manager

crystal helm
#

ahhhh, ty πŸ˜„ didnt catch that, ill try

magic frigate
#

No need to return jobhandles from job onupdate anymore it seems

gritty grail
#

How to I delay the creation of a system?

dull copper
#

btw, wondered about that that dots subscene thing because of this: ```md

  • Adds Live Link support for GameObject scenes.```
magic frigate
#

[DisableAutoCreation]?

dull copper
#

if they can do live link in GO scenes, they have some serialization support for it

gritty grail
#

ok cool

dull copper
#

No need to return jobhandles from job onupdate anymore it seems
@magic frigate what do you mean by this?

#

surely you have to return something since the OnUpdate still requires a return type

zenith wyvern
#

SystemBase handles the jobhandle internally so you can ignore it unless you need it, like for command buffers or explicitly scheduling parallel jobs

#

OnUpdate returns void with SystemBase

dull copper
#

ah

#

well, I'm all for less boilerplate code πŸ™‚

magic frigate
dull copper
#

I do like the ScheduleParallel and ScheduleSingle

#

makes way more sense than Schedule and Run

magic frigate
#

Is ScheduleSingle a replacement fo- ah

#

I was about to ask if it was different than Run(), lol

dull copper
#

hmm

#

they still have Run

#

the ScheduleSingle is apparently only for IJobChunk?

#

I was hoping it would have been for all

crystal helm
#

hm, getting the android platform package didnt fix the problem

dull copper
#

so, nevermind me

#

@crystal helm you only need android platform package if you build against dots runtime afaik

mint iron
#

i though the difference was that ScheduleSingle() gets scheduled and potentially on a different thread, but Run() just gets main thread inlined if possible.

dull copper
#

but if you need DOTS subscenes to work in build, you still need Unity Platforms package

#

oh right, good point @mint iron

#

so what's the diff with ScheduleParallel and Schedule now?

#

"ScheduleParallel` methods in `IJobChunk` and `Entities.ForEach` (in `SystemBase`) to make parallel scheduling of jobs explicit.

crystal helm
#

i got both... but i updated from LRP to URP today, some materials seem to be a bit off too....
ill fix the materials and render pipeline stuff first, maybe the hybrid renderer just chokes and dies from something left over

dull copper
#

I admit I read the changelogs too quickly, I really thought they changed the wording to make the diff between schedule and run more clear but I guess not πŸ™‚

magic frigate
#

Do any of the old ones give deprecation warnings or something?

dull copper
#

Schedule at least doesn't for me (with SystemBase)

#

but in general I like this, it's awesome that we get closer to not having to write a ton of extra code with DOTS (unless we need finer control over things)

indigo delta
#

Any tips or best practice on state machines and DOTS? Broad question I know, but curious what approaches have worked well. My naive inclination is to make entities representing states (since they're just data) but not sure what that looks like when it comes to the animation state machine and whether any logic should live on the animation nodes, etc

#

Looks like condition tables might be the way

crystal helm
#

state machines are this animation pseudo visual scripting, right?

indigo delta
#

Well, technically a FSM (Finite State Machine) is just a concept that exists in all kinds of programming and systems. The animation node graph is one, yes.

#

But really they're all over the place, just maybe not formally considered as such

#

Any finite set of states with defined ways to transition between them is a FSM

#

If jumpButton -> isJumping=true; is a state transition, for example

vagrant surge
#

adding a component is basically a state machine switch

#

on ecs

indigo delta
#

What I'm asking about is a more formal, structured approach for organizing an FSM in an ECS/DOTS architecture, to use to drive logic like combat/locomotion/animation

vagrant surge
#

because you can use that to switch what systems run on an entity

indigo delta
#

The current default unity non-DOTS approach seems to be "define a state machine in the anim graph and tie logic to the nodes there"

#

Which is messy and hard to maintain

vagrant surge
#

just be careful with it, as its a memory switch, and can be expensive if you do it on the "tens of thousands per frame"

karmic pilot
#

as always, look at your specific usecase... you probably don't want to implement a generic "one rules them all" FSM with ecs, as this would run counter the dod principle

#

how often do you switch states, are there far more transitions than states? can you add new states/transitions via config files, etc etc

indigo delta
#

Of course. Just that it looks like a blind spot as far as docs/examples to go from "setup combat/locomotion in the anim graph" to "process your entities in DOTS with systems", without a clear bridge to achieve the same FSM-style behavior graph

vagrant surge
#

yup. Ive seen people trying to do a generic FSM on ecs and it allways fail

#

its just better to have it special-case

indigo delta
#

That's why I was curious if there was a Bestℒ️ way to think about it

vagrant surge
#

@indigo delta as a rule of thumb, component = state is the easiset to think about

#

the easiest of cases is the "Dead" component

#

if entity has the Dead component, then its dead

#

and on your general gameplay systems, they dont run on entities with Dead component

karmic pilot
#

or you could use shared component values with an enum for all your statesπŸ€·β€β™‚οΈ

vagrant surge
#

nope, thats worse

#

much worse

karmic pilot
#

aye it is, but it is possible πŸ™‚

vagrant surge
#

you are doing the whole "archetype switch" anyway

#

might as well have it as component

#

better filtering and you can put data on it

indigo delta
#

So view components as behaviors, systems operate on entities with matching components, change components on events that should change behaviors, to transition "states". I get where you're going

vagrant surge
#

yup

#

thats great, but it has downsides of causing memory switch when you need to transition state

#

and causes fragmentation

#

so generally only use it in the cases where you wont constantly switch

indigo delta
#

What alternative architecture would you be using if you want a graph of contingent behaviors?

vagrant surge
#

maybe "child" entity

indigo delta
#

To be more ECS friendly

vagrant surge
#

an state is done by a separate entity which points at parent

#

downside is reduced performance when calculating things, as accessing component data from an entity ID is slow-ish on unity ECS

indigo delta
#

I see

vagrant surge
#

this is kind of why trying to create a general state machine is not a good idea

#

there are multiple ways with pros-cons, and they are all really trivial code, so the general state machine is unnecesary

indigo delta
#

Well that's kind of what I was getting at moreso than just how to FSM, but rather how to approach gameplay systems that are often graphs with contingent nodes while respecting/gaining ECS benefits

#

Then how in Unity one ties that intelligently to an animation graph, for instance

#

The naive approach (and every video/doc on it) has you just drag in anim nodes and attach scripts to transition on variable conditions

#

Which feels antithetical to DOD thinking

zenith wyvern
#

@dull copper Schedule is equivalent to ScheduleSingle with an IJobForEach, it forces it into one thread but it still schedules a job on another thread. Run forces it to run on the main thread

opaque ledge
#

πŸ‘€

#

So we should go for ScheduleParallel then

#

i thought Schedule would default to ScheduleParallel

coarse turtle
#

ah cool they made entityQuery.ToComponentDataArray async πŸ™‚

#

and explicit

zenith wyvern
#

Yeah it's a bit unintuitive, with job structs the default is parallel and you have to explicitly call ScheduleSingle for a single threaded job, in SystemBase they reversed it for some reason

dull copper
#

it's weird, yeah

#

but I just tried this and profiler does show this as well

#

for simple systems .Run will still be way faster, and .Schedule will be tad faster than .ScheduleParallel

#

it all boils down to job system overhead there

crystal helm
#

oke, ive tried everything now, checked all used materials and meshes.. got the new platform packages (btw you cant install unity platform android without unity platform) and checked the debug console on the build;

nothing helped. it seems like the hybrid renderer cant calculate the position of the objects, all of them sit at 0,0,0 but the entity logic is running without problems and no debug error fires :/ all since the update today

zenith wyvern
#

Are we still supposed to use [AlwaysSynchronizeSystem] if we're only calling .Run?

opaque ledge
#

Most likely i think

crystal helm
#

you fixed the projectiles xD

opaque ledge
#

πŸ˜‚ yeah

crystal helm
#

did you manage the fx with go's?

#

or did you use the tiny.particles?

opaque ledge
#

nah with GO/Monobehaviour

#

didnt know you could do particle stuff with DOTS yet

crystal helm
#

havnt looked into that, but i know i need a lot of particle systems... i was planning to use simply shapes with shaders that looks like a effect... which should be much lighter than the base particle system

coarse turtle
#

ah is tiny particle only on the 'tiny' platform effectively?

crystal helm
#

dont know, didnt try. but found the docu and was curious.

zenith wyvern
coarse turtle
#

ah and @zenith wyvern dang haha

crystal helm
#

oke, for everyone who runs in this problem too:

the hybrid renderer cant hande the SRP Batching. Thats why all renderobjects get placed in 0,0,0 and the logic works just fine.
the update turned it on and i didnt catch it.

works again πŸ‘Ύ
the problem occured just in build, not in the editor

zenith wyvern
#

That happens from trying to use a member variable in ForEach, in the previous entities version it would give a nice error about need to assign to a local variable first

#

Is that with URP @crystal helm ?

crystal helm
#

jep

zenith wyvern
#

I wonder if it wouldn't do that in HDRP

opaque ledge
#

@zenith wyvern i got that as well on previous version i reported it then said they fixed it on 0.6, but i guess not πŸ˜„

formal scaffold
#

I'm sorry for asking again but I can't get it to work. I have a Player Entity with just a Translation Component. I want to access the Translation Value inside a System to chase the Player Entity with another Entity. How can I achieve this? I tried storing the player entity in a GameManager singleton but all I can access is its Index.

opaque ledge
#

do you only have 1 player entity ?

formal scaffold
#

yes

opaque ledge
#

then you can do:

  var playerEntity = GetSingleton<PlayerTag>();
  var translations = GetComponentDataFromEntity<Translation>(true);
night cargo
#

Anyone got a duplicated Unity.Build package error with Entities 0.6 ?

opaque ledge
#

then inside your job you can do

  var playerPosition = translations[playerEntity];
#

you should put a PlayerTag on your player entity so you can retrieve it using like that.

#

so complete example would be:

  OnUpdate(){
    var playerEntity = GetSingleton<PlayerTag>();
    var translations = GetComponentDataFromEntity<Translation>(true);
    var deltaTime = Time.DeltaTime;
    Entities.WithAll<Enemy>().ForEach((ref Translation enemyPosition)=>{
      var playerPosition = translations[playerEntity];
      enemyPosition += normalize(playerPosition - enemyPosition) * deltaTime;
    })
    .WithReadOnly(translations)
    .Schedule()
  }
formal scaffold
#

Ahh great now I understand how GetComponentDataFromEntity works. Thank you πŸ™‚

crystal helm
#

or you give a component to the playerentity that just tags it as such and going for Entitys.ForEach -> this keeps the option open to add more playerEntitys

opaque ledge
#

πŸ‘

#

Actually wait, that example wont work since you are getting Translation in OnUpdate, and also getting Translation of the entity. But thats the general idea

#

So for future reference i am fixing it:

  OnUpdate(){
    var playerEntity = GetSingleton<PlayerTag>();
    var translations = GetComponentDataFromEntity<Translation>();
    var deltaTime = Time.DeltaTime;
    Entities.WithAll<Enemy>().ForEach((Entity enemyEntity)=>{
      var playerPosition = translations[playerEntity];
      var enemyPosition = translations[enemyEntity];
      enemyPosition += normalize(playerPosition - enemyPosition) * deltaTime;
      translations[enemyEntity] = enemyPosition;
    })
    .Schedule()
  }
#

Something you have to watch out that, you cant use a component data in ForEach if you get it from GetComponentDataFromEntity, otherwise it will give you alias error

warped trail
#

copy positions of all targets in different job to native array and than pass to your job πŸ‘

#

then you can iterate over targets and choose which one you want🧐

formal scaffold
#

I think I can do it like this to manage some sort of "Aggro" in a battle . I will play around with this thanks alot πŸ‘

safe lintel
#

is Unity.Build like an internal namespace now? cant seem to access it

opaque ledge
#

i think it got merged to platforms

safe lintel
#

i mean its still there in the new platforms package, my ide just doesnt see it now tho and neither will it compile in unity if I try to use it

mint iron
crystal helm
#

I can't get over his facial expression xD

formal scaffold
#

Did anyone experience Entities falling through the floor when converting a GameObject with a RigidBody and Gravity turned on to an Entity? If I don't convert my GameObject it doesn't fall. πŸ€” Nevermind I didn't turn my ground into an Entity πŸ˜…

crystal helm
#

theres no other way ^^ the physics system of gameobjects and entitys dont interact with each other

#

how can it be that EntityCommandBuffer.DestroyEntity(index,entity) does not destroy its children? O.O

safe lintel
#

you need to add any child entities or entities you want to destroy together to a LinkedEntityGroup

crystal helm
#

hm :{
then i load the object to a prefab and instantiate it, less work and it needs to be done anyways

#

instantiated prefabs from referenced prefabs are linked automatically, right?

safe lintel
#

i dont think LinkedEntityGroup is added automatically to many things at all but whatever youre doing just check in the entity debugger if it has it or not, should be easy to tell

odd ridge
#

I have a problem, I have this Ball object prefab which I put a ConvertAndDestroy script on it

#

when I put it in the hirarchy, the ball converts to an entity and works properly

#

but I'm trying to spawn it from code, so I reference the prefab through the inspector, convert it to an entity prefab, and create an instance of it with the entity manager

#

problem is, when I instantiate the entity from code, the physics doesn't work

safe lintel
#

are you using the physics authoring components(shape and body)?

#

should "just work" but I would double check the entity debugger that everything on the instntiated as a prefab is the same as non prefab test

hollow sorrel
#

i realize i've been doing this for a while without thinking about this but, how does using ecs get/setcomponentdata from non-ecs code work? jobsystem manages dependencies inside ecs, but what about outside? is it possible to setdata from monobehaviour while it's at the same time being set in a job in ecs?

#

i mean the latter seems to be possible, but is it safe?

crystal helm
#

Referenced Prefabs automatically add a LinkedEntityGroup with the complete child hierarchy.

uff, tomorrow ill write the spawn system, iam not doing that today >.< sitting since 12 hours on this, its gaming time now :}

zenith wyvern
#

@hollow sorrel As far as I know ECS uses entity queries in combination with the JCS job handles to manage dependencies.

You can technically access the entity manager from a MonoBehaviour via World.GetDefaultGameObjectInjectionWorld.EntityManager. With the entity manager you could set component data on any entities your MonoBheaviour has a reference to, but I think you would have to force a sync point first with EntityManager.CompleteAllJobs(). And I don't think there's a way to create an entity query outside a system so getting access to an entity in the first place is going to be a little hacky.

hollow sorrel
#

hmmm

#

ah yea it creating a sync point when doing setcomponentdata makes sense

#

ty

odd ridge
#

okay, I found the problem..

crystal helm
#

tell us :>

plush portal
#

@mint iron Haven't analyzed all the code, but wow thanks!
Although I kind of have a hard time understanding everything in detail, since I am not very experienced with C# events(I have only used events with Action). It's a good opportunity for me to learn more about that though.

#

Also I didn't put it in an editor yet, so that might make it easier for me to read.

odd ridge
#

@crystal helm well... it's something to do with the transform. even though the prefab was identical (same transform value), it wasn't handled the same way, and the values were only valid for the manually instantiated balls. so I adjusted the values for my ECS spawned balls and they work

#

now breaking the manually instantiated ones, but I don't need the manually instantiated ones anymore

#

how do you count the number of entities in a ForEach job?

safe lintel
#

if you know the query you can use query.CalculateEntityCount

halcyon plume
#

QQ everyone. What is the DOTS? is this kind of ECS? or what is it all about?

solar spire
warped trail
#

@odd ridge cs var count = myEntityquery.CalculateEntityCount(); Entities .WithStoreEntityQueryInField(ref myEntityQuery)//field in your system .ForEach(()=> { });

opaque ledge
#

Hmm πŸ€” So.. i put a 6 targets on scene to shoot at (you can see that in my previous video) but what i have noticed that is.. Target's child objects are attached as "Child" Component not LinkedEntity Component, therefore when i destroy Target, the actual mesh(which is Target's only child) is still around and it actually 'spawns' at 0,0,0 since Translation value, compare to parent, is 0,0,0.

#

When i instantiate an entity from EntityManager.Instantiate, children are linked entities, but when i put them to editor and add convert to entity, children are "Child"

dull copper
#

anyone got Unity Physics raycasts working with the new Entities.ForEach setup?

opaque ledge
#

try to disable JobsDebugger

dull copper
#

huh, that works

#

why? πŸ˜„

opaque ledge
#

no idea πŸ˜„

dull copper
#

well, it's clearly bypassing the safety checks now

opaque ledge
#

thats what happened to me as well so

dull copper
#

which should tell if things are doing things they shouldn't

#

which isn't all that great solution

opaque ledge
#

i am not sure, it says debugger not safety checker

#

nvm you are right πŸ˜„

#

but idk, everything works fine for me so

#

also maybe use new SystemBase, it handles every dependency i believe

dull copper
#

I'm actually using it already

#

trying to slim everything down

#

I'd still love to set the collision world to read only for this as it's what's causing this to happen in the first place

opaque ledge
#

Yeah, tried stuff but couldnt make it work.

#

I will just disable job debugger when i am sure my other systems are working properly

#

kinda annoying really

dull copper
#

it's not related to the system mentioned here

#

this happens even without it, it seems to be some stock physics authoring component triggering it

#

well, it's convexhull thing

#

I'm feeding the shape component a mesh to use as basis for convex hull generation, and it does generate it nicely from it but I suspect this is what makes this happen

#

I got other meshes in the hierarchy which I don't want to be used in convex hull generation at all, hence manually feeding the mesh there

silver dragon
#

@dull copper I have a solution for this raycast issue! It was posted here in discord, i forgot to update the forum thread. Give me a few minutes...

dull copper
#

ah, nice, I tried to seach this channel but I guess I failed πŸ˜„

silver dragon
#

Ha, found it:

public struct CollisionWorldRo
{
    [ReadOnly] public CollisionWorld collisionWorld;
}

and pass it to Entities.ForEach:

var collisionWorldRo = new CollisionWorldRo{collisionWorld = _buildPhysicsWorld.PhysicsWorld.CollisionWorld};
#

Thats it!

dull copper
#

lol

#

that's so hacky

silver dragon
#

yep

dull copper
#

but I'll take it

#

I hope they fix this in future entities/physics package

silver dragon
#

This and all the other things πŸ˜›

dull copper
#

anyway, thanks for the info, much appreciated πŸ™‚

silver dragon
#

Thanks for the hint, i just updated the post!

dull copper
#

I'm still getting this
InvalidOperationException: The previously scheduled job BoundingVolumeHierarchy:BuildFirstNLevelsJob writes to the NativeArray<Range> BuildFirstNLevelsJob.Ranges. You are trying to schedule a new job TestSystem:<>c__DisplayClass_OnUpdate_LambdaJob0, which reads from the same NativeArray<Range> (via <>c__DisplayClass_OnUpdate_LambdaJob0.Data.collisionWorldReadOnly.collisionWorld.Broadphase.m_StaticTree.Ranges). To guarantee safety, you must include BoundingVolumeHierarchy:BuildFirstNLevelsJob as a dependency of the newly schedu

#

the message clips there πŸ˜„

#

but it's basically the same error that the original poster had on that thread

opaque ledge
#

I believe Unity doesnt properly handle dependincies if you include physic world, because for me, its working fine if i only have 1 system that does raycast, but starts to fail if i have 2 systems doing it

#

Try UpdateAfter(typeof(EndFramePhysicSystem)), that actually helped me when i was working on it just now.

#

but it said i was 'modifiying' bodies, in first system, so 2nd system should depend on it, but i am not modifying it, so i think Unity cant see that.

#

If i try to make Physic World read only then it will give an error and wont compile.

#

So in the end, its like what you said Olento, there is no way to do read only

#

but then again even if i am modifying it Unity Job Scheduler should see that and schedule correctly.

#

but maybe i am wrong idk, i am not smart

dull copper
#

that just breaks it totally for me πŸ˜„

silver dragon
#

Ah, i have: [UpdateAfter(typeof(BuildPhysicsWorld))]

dull copper
#
  • I really need to do this before physics stepping or I get one physics step delay for no good reason
#

yes, that's what I had too

silver dragon
#

hm, i have two systems doing raycasts and no error anymore

#

But let me double check πŸ˜›

opaque ledge
#

does both system access bodies ?

dull copper
#

weird, I even tried reverting to the JobComponentSystem (from new SystemBase setup) but it still spams the same thing

silver dragon
#

only one of my systems doing raycasts access bodies

dull copper
#

I'm on newest entities 0.6 too

opaque ledge
#

try to access to bodies on your 2nd job, thats when you will get the error

#

same Olento

silver dragon
#

uh, i'm still on 0.5.1

opaque ledge
#

doesnt matter probably

dull copper
#

I am on 2020.1.0a23 as well so that could also change things

opaque ledge
#

its still same package tho

silver dragon
#

Ok, i added access to bodies in my 2nd job and i got no errors.

opaque ledge
#

but maybe you are right

silver dragon
#

2019.3.0f6

dull copper
#

this thing crashes the editor for me like on every 3rd run πŸ˜„

opaque ledge
#

well i get error if i do that

silver dragon
#

strange enough...

low tangle
#

theres 3.1f1 now as well

silver dragon
#

Both are Entities.Foreach with CollisionWorldRo and [UpdateAfter(typeof(BuildPhysicsWorld))]

#

Oh, there is more: .Schedule(JobHandle.CombineDependencies(inputDeps, _buildPhysicsWorld.FinalJobHandle));

low tangle
#

seems like it came out really quick after 0f6

opaque ledge
#

yay an update πŸ˜„

silver dragon
#

Everything should be in there πŸ˜›

dull copper
#

3.1f2 is getting out this week

silver dragon
#

Yep, new week, new update!

dull copper
#

f2 is going to fix DX12 breaking with HDRP, people testing DXR are anxious in getting that

opaque ledge
#

ah nvm, i am already at 2019.3.1f

dull copper
#

@silver dragon ah, I didn't have that input dep as BaseSystem setup doesn't allow it

#

I'll try it on the JobComponentSystem

silver dragon
#

Hm, the SystemBase is for ComponentSystem only? I thought this goes away somewhen?

#

You can use SystemBase.Dependency

dull copper
#

ah, true

#

I actually saw that just a moment ago, but derp πŸ˜„

opaque ledge
#

no SystemBase is the 'new' System now

dull copper
#

anyway, inserting that dep did fix the error for me

#

I'll try again with BaseSystem now

silver dragon
#

πŸ™‚

dull copper
#

thanks again πŸ™‚

silver dragon
#

"New" system? For what?

#

Is there more explanation somewhere?

opaque ledge
#

for.. stuff πŸ˜„ it succeeds both JobComponentSystem and ComponentSystem

dull copper
#

old setup:

public class TestSystem : JobComponentSystem
{
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var jobHandle = Entities.ForEach((ref TestComponent testComponent) =>
        {
            // whatever here
        }).Schedule(inputDependencies);
        return jobHandle;
    }
}```
#

new setup: cs public class TestSystem : SystemBase { protected override void OnUpdate() { Entities.ForEach((ref TestComponent testComponent) => { // whatever here }).ScheduleParallel(); } }

opaque ledge
#

i believe whole ECS Sample updated for that

dull copper
#

basically it's just reducing the boilerplate if you don't need the dependencies

opaque ledge
#

it came with 0.6 btw

#

also it improved your jobs if your system only has Run jobs

#

or so i heard

silver dragon
#

0.6 manual doesn't mention that

#

only changelog

opaque ledge
#

its a secret πŸ‘€

silver dragon
#

A partial secret!

#

Maybe 0.85f

opaque ledge
#

But yeah, in their manual it still shows JobComponentSystem and ComponentSystem

#

but like i said ECS Samples are updated to SystemBase

dull copper
#

ok, this works with SystemBase: cs Dependency = JobHandle.CombineDependencies(Dependency, buildPhysicsWorld.FinalJobHandle);

silver dragon
#

Maybe i should update the samples, i have a really old version... haven't used them for some time.

dull copper
#

no more errors, yay

silver dragon
#

πŸ‘

opaque ledge
#

Hmm i tried that but didnt work 😭

#

i will check it out later, gotta update some stuff

dull copper
#

did you combine them?

opaque ledge
#

yeah

dull copper
#

and you did that before Entities.Foreach?

opaque ledge
#

are you guys doing any UpdateAfter ?

#

no after ForEach

dull copper
#

you still need the struct hack

opaque ledge
#

ahh nvm, you guys doing it with struct hack ?

#

i will just wait until its properly handled πŸ˜„

silver dragon
#

You need all those funny things πŸ˜›

opaque ledge
#

yeah πŸ˜„

#

btw a question, so one of my system is checking interaction distance between my interaction target and my player, if its in distance it interacts, this is the code:

    protected override void OnUpdate()
    {
        RequireSingletonForUpdate<PlayerInteractionTargetTag>();

        var playerEntity = GetSingletonEntity<PlayerTag>();

        var targetEntity = GetSingletonEntity<PlayerInteractionTargetTag>();

        var translations = GetComponentDataFromEntity<Translation>(true);
        var playerPos = translations[playerEntity].Value;
        var targetPos = translations[targetEntity].Value;

        if (distance(playerPos, targetPos) <= 0.3f) MasterInteractionMono.instance.TestInteraction(targetEntity);
    }
dull copper
#

yeah, I just tried it without the ReadOnly hack and it still fails without

#

so you need all that

opaque ledge
#

so there is no job in it at all, should i make a IJob or this is okay?

#

its working so far but not sure

silver dragon
#

Add ProfilerMarker and check times with(out) job

opaque ledge
#

so should i add physics dependency before ForEach or after ?

dull copper
#

before

#

btw, got rid of the convex hull errors simply by adding physics material to the thing πŸ˜„

#

I thought it would always just use some default 0.5 values if there's none assigned

#

that's how things work like... in every other physics implementation out there

low tangle
#

Oh boy another syntax change

remote coyote
#

hooopefully won't be too long until they update Netcode to these latest Entities changes

#

anybody tried to run Netcode with latest updates? I wasn't able to get it running on 0.5.1

silver dragon
#

Yep, i don't like having packages as dev version...

#

I have it running with 0.5.1

low tangle
#

Transport layer seemed fine on mine

#

I don't touch the high level stuff

silver dragon
#

Let me check the fix for it...

remote coyote
#

Yeah June, been tempted to just run with Transport myself.

low tangle
#

It's much more sane

#

It all works in jobs, you can just construct whatever packets you need to whatever meaning

remote coyote
#

Yes, Transport seems to be where the archwizards applied code... or perhaps its just that Netcode is more opinionated

low tangle
#

It feels like the old network

#

Where they tried really hard to make it do everything

remote coyote
#

yeah, I'm used to Raknet, so would be cosy

#

and I really don't like to have to generate code via editor inspector

low tangle
#

If you know how to build up from a simple udp packet lib I highly suggest it

dull copper
#

as a side note, having Debug.DrawLine working now on jobs (with 2020.1) helps a lot on these raycasts, no need to do workarounds to get these drawn

remote coyote
#

yeah, lets you shape it to exactly what you need, rather than hope to mold Netcode into what you need

low tangle
#

A seriously fun pro tip is that you can use a unsafe pointer and memcpy to the nativesteamwrter

#

From your entity components

#

Which are fixed sizes

remote coyote
#

do you still write to dynamic buffer like Netcode does?

low tangle
#

It's a fixed stream

#

Fixed in size but you can do it thread (job) local memory

silver dragon
#

@remote coyote If i remember correctly you have to move netcode to packages folder (make a dev package) and make this change in ClientServerWorld:

protected internal static void GenerateSystemLists(List<Type> systems)

to

protected internal static void GenerateSystemLists(IReadOnlyList<Type> systems)

Should be enough to get it working with 0.5.x

remote coyote
#

yeah, I did that fixx daschatten, but was some other error that I was not able to resolve. Must have been something else (I don't recall off the top of my head)

silver dragon
#

Hm, it was the only fix for my project. Maybe some feature i don't use...

#

You never know what bugs are hidden πŸ˜›

remote coyote
#

yes, I have set up just enough unit tests / integration tests for my code that it catches a few of those

silver dragon
#

I avoided tests for netcode, so there are no bugs for me partyparrot

remote coyote
#

I'll have to play around with that a bit June. Thanks for the tip. Was looking seriously at Steam Network Socket yesterday, but might as well stick with Transport and stay in DOTS-land with it.

opaque ledge
#

how can i send a persistent native array to ForEach ? if i capture it locally in OnUpdate, it wont be the same array.

warped trail
#

isn't native array just a pointer to some memory?πŸ€”

#

or what do you mean by not the same?

opaque ledge
#

i have to capture it like, var newArray = persistanceArray;

#

to be able to use it inside ForEach

warped trail
#

but it is the same NativeArray

#

copy of a pointer points to the same memory of the original, or am i wrongπŸ€”

opaque ledge
#

Yep seems so, my bad, there was a mistake in my logic

#

@silver dragon btw, instead of After BuildPhysicSystem i did it after EndFramePhysicsSystem, that way i didnt need to combine dependincies

#

not sure if i get lucky or smth tho πŸ˜„ can you try it on your side as well when you have the time

silver dragon
#

I suppose you're lucky. It depends on when a system is scheduled and when the jobs are running. Once i added one more system and suddenly got some dependency errors from other systems. Since then i like explicit dependencies.

#

(and keep read/write attribs clean)

worldly vector
#

Hi, everyone. So I've invested some time on learning Entitas. Is it going to be hard to switch to DOTS?

crystal helm
#

to learn/work with it? not particually, migrating a project to it? hell yes.
if you want to outsource just one seperate system to it (it needs to be mostly independent to the rest) its manageable

worldly vector
#

Oh, thank you for this answer. I want to learn it. I'm in love with the concept. And I'm ready to start a new project to understand all the caveats of DOTS.

#

Where should I start from?

crystal helm
#

in this channel, on the top right it a pin, if you click on it it shows you a collection of useful links, also i can recommend the "codemonkey" youtube videos on ecs, some have outdated syntax but the principles are the same and easy to fix.
oh and stay away from ComponentSystems, get directly used to Jobsystems πŸ™‚

silver dragon
#

F***, a FixedListByte4096 has only space for 4094 bytes... i need 4096 for my 16x16x16 cluster...

crystal helm
#

🀣 lies everywhere

silver dragon
worldly vector
#

in this channel, on the top right it a pin, if you click on it it shows you a collection of useful links, also i can recommend the "codemonkey" youtube videos on ecs, some have outdated syntax but the principles are the same and easy to fix.
oh and stay away from ComponentSystems, get directly used to Jobsystems πŸ™‚
@crystal helm, thank you!

crystal helm
#

thats why we are here πŸ˜„ besides complaining about outdated documentation ofc 😭

fallow mason
#

So use JobComponentSystem even if the work you're doing cannot be multithreaded? Run instead of Schedule? ComponentSystem going to be deprecated then?

crystal helm
#

icant find the link right now but i saw a unity technologies post in the forums that said componentsystems will get more changes than the jobsystem in the near future.

fallow mason
#

Makes sense as the job system is more mature, though I literally never used it before ECS

crystal helm
#

and yea, you can just .Run() a job to mainthread it

#

there is that statement that some things cant get jobified, but i personally never encountered a limit :\ someone else maybe

gusty comet
#

.

#

.

#

.

#

.

silver dragon
#

We need more DOTS!

fallow mason
#

Doesn't a lot of Unity's API have to run on the main thread? Sure, you can make a copy of any piece of data, do multithreaded transforms on it, and sync it back up to the main thread. But sometimes it just makes sense (and is faster) to keep it on the main thread, right?

zenith wyvern
#

Yes, for simple tasks it's faster to run on the main thread. You can still get the benefits of burst on the main thread as well using .Run instead of .Schedule

odd ridge
#

how do I use burst when using a Entities.ForEach statement?

odd ridge
#

if I understand, job structs require the attribute [BurstCompile], but ForEach is bursted by default?

zenith wyvern
#

Correct

odd ridge
#

is there any reason to use a job struct over a ForEach lambda or vice versa?

coarse turtle
#

Chunk iteration - I typically tend to use IJobChunk

#

until there's a way to do ForEach lambda with chunk iteration soon - I'd probably be jumping to that πŸ™ƒ

mint iron
#

i thought ForEach lambda does a chunk iteration under the hood; IJobForEach<T> did as well.

coarse turtle
#

They do

#

can you actually grab the chunk in Entities.ForEach? πŸ‘€

mint iron
#

i see what you mean, i can't see a lamda match anywhere for the chunk

coarse turtle
#

ah I guess I misread this: When you define the lambda function to use with Entities.ForEach, you can declare parameters that the JobComponentSystem uses to pass information about the current entity (or chunk) when it executes the function. (A Job.WithCode lambda function does not take any parameters.)

odd ridge
#

sometimes people use 'return default;' in a system's OnUpdate function. what is the meaning of the default here? I never saw the default keyword used outside of a switch block. is this new to ECS? is this specific to Unity or is this a c# feature?

opaque ledge
#

its c# feature

mint iron
#
var translations = GetArchetypeChunkComponentType<Translation>();
Entities.ForEach((ArchetypeChunk chunk) =>
{
    var stuff = chunk.GetNativeArray(translations);

}).Run();

this doesn't compile 😦

opaque ledge
#

default is generally used with AlwaysSync attribute, AlwaysSync attribute makes jobs finish before system starts, since all jobs are finished you dont need to return inputDeps, you simply return default

zenith wyvern
#

I don't think we need to use AlwaysSynchronizeSystem with the new SystemBase now as well, so the pattern of using alwayssynchronizesystem and returning default is obsolete with SystemBase

mint iron
zenith wyvern
#

From the docs Note: Currently, you cannot pass chunk components to the Entities.ForEach lambda function.

odd ridge
#

right now there's two ways to create a system, either with the .ForEach lamda or a IJobForEach struct. is there any reason to use one over the other?

opaque ledge
#

no, they are basically the same

#

but for ForEach, you gotta capture variables locally, you cannot use class variables just like that, so it has kinda 'weird' workflow

odd ridge
#

what's the recommended way to react to input? I tried using Input.GetKey() in a IJobForEach but that wouldn't work

#

why does Input.GetKey() work for a ForEach lambda but doesn't work for IJobForEach

opaque ledge
#

are you using input system or manager ?

#

new one or old one

odd ridge
#

I'm not sure actually

zenith wyvern
#

You read input on the main thread and pass it into your jobs

atomic schooner
#

The old is default, so if you didn't specifically opt-in to the new one you're on Manager

zenith wyvern
#
        protected override void OnUpdate()
        {
            var moveInput = _moveAction.triggered ? (float2)_moveAction.ReadValue<Vector2>() : float2.zero;
            
            if (moveInput.x == _previousMove.x && moveInput.y == _previousMove.y)
                return;
            _previousMove = moveInput;

            Entities
                .WithAll<Player>()
                .ForEach((ref Movement move) =>
                {
                    move = (int2)moveInput;
                }).Run();
opaque ledge
#

i am using new one, so i simply register class fields on performed, started, canceled etc. then capture them locally

odd ridge
#

is there a DOTS audio solution already?

zenith wyvern
#

There's audio in the project tiny racing demo, you'll have to see what they're using

odd ridge
#

if not for project tiny, I have to communicate sound events between ecs and regular audio?

zenith wyvern
#

Project Tiny uses ECS by design, so whatever they're doing for audio, that is how we'll have to do it

#

Or come up with your own solution using hybrid

mystic mountain
#

wwise will be supporting ECS within this year as well.

odd ridge
#

what's the frequence of a JobComponentSystem OnUpdate function? like, does it run as fast as it can or is it a fixed 60hz?

warped trail
#

just like the regular Update of monobehaviour

odd ridge
#

so I need to write my own fixed time step solution to have my jobs run at 60hz?

#

I suppose there's a way to disable the OnUpdate per frame call so that I can call it manually from my own Job manager?

dull copper
#

@mystic mountain where is the info about that?

#

First time I hear about it :)

indigo delta
#

@odd ridge Or you can use deltaTime to scale your rates to compensate for changing frame rates?

odd ridge
#

@indigo delta it's really performance that I'm concerned about, leaving game logic to run as fast as it can seems ... non sensical

indigo delta
#

Modern CPUs with multiple cores (reason for DOTS and Jobs in the first place) and the Burst compiler make per-frame updates pretty darn fast.

#

If you don't need to update something very fast, just... don't update it every frame. But the basic OnUpdate logic is pretty universal as a main place to handle things

opaque ledge
#

you shouldnt really concern about performance when you are using ECS πŸ˜„

zenith wyvern
#

Performance seems to be unity's first concern, it's the whole reason they made ECS. And some people are making games for mobile devices, where better control over the update rate can mean the difference between a dead phone or not

#

I don't have a link but I seem to remember someone from Unity saying they are working on giving us better control over the update rate

indigo delta
#

Sure, hence the don't update a thing every frame if you don't need to, but that doesn't necessarily mean writing your own JobComponentSystem function

#

You can do lots of things. Limit frame rate to 60, for one. Use timers. Run jobs in response to some trigger.

#

Keep a counter and only run your logic every nth frame

odd ridge
#

what I had in mind is to have a per job system update rate. like I could tell my audio sound system to run at 10hz, and some manager super class handles calling it only once every 100 milliseconds

#

just wondering what's the proper way to do this in unity

coarse turtle
#

you could manually update systems yourself

#

instead of the default injected world you would create your own with your own authored systems to handle different tick rates

odd ridge
#

yeah! that's what I'm looking for, how do I take control of my systems?

#

hmm

zenith wyvern
#

You add [DisableAutoCreation] and add your systems to ComponentSystemGroups with World.GetOrCreateSystem<SystemGroup>().AddSystemToUpdateList

#

Then when you call update on the group it updates all that group's systems

coarse turtle
#

that's also another way πŸ™‚

odd ridge
#

so if I want each system to have its own tick rate, I will have 1 system group per system?

#

or could I skip the group system if I'm to call systems 1 by 1

zenith wyvern
#

There's probably about 1000 different ways you could do it

coarse turtle
#

pretty sure you can just ignore the system groups

zenith wyvern
#

We gave you at least 2

coarse turtle
#

and update the system manually if you have a reference to them

odd ridge
#

trying to figure out what's the most 'proper' way

#

I see

coarse turtle
#

Hmm I wouldn't worry too much about formalities/proper if you're exploring πŸ˜‰

odd ridge
#

well, exploring for the long run yeah hehe

zenith wyvern
#

I like using AddSystemToUpdate list since it lets you avoid touching the default initialization and also obeys the UpdateBefore/UpdateAfter attributes

#

Although if you go down this route you're losing the ability to see your system in the entity debugger

coarse turtle
#

interesting - that's good to know

odd ridge
#

and I suppose I don't want to lose the entity debugger right?

crystal helm
#

anybody has experience with the profiler and ECS? my framerate breaks after i Destroy a Entity for the second time, profiler tells me:

edit: seems like a editor bug, not ecs related

#

102k calls seems like a error xD

mystic mountain
#

@dull copper I sent them a message and asked πŸ˜›

crystal helm
odd ridge
#

did you just time travelled 63 ms in the past

crystal helm
#

i try to figue it out :\ iam not convinced about a time anomaly within my cpu...

#

it isnt a Threadripper 3990x 🀣

crystal helm
#

could it be that i manipulate a static variable (yea i know i should not) but it didnt throw a error of any sort so i thought it is fine 😦

#

within a IJobForEachWithEntity

odd ridge
#

if I use EntityManager.AddComponentData to add a component that already exists, is it gonna be duplicated or replaced?

zenith wyvern
#

It's going to throw an exception because an entity can only have one of any component type

odd ridge
#

if I get such exception I should use SetComponentData instead?

#

also, what does [Inject] does? is this specific to dots?

zenith wyvern
#

If you get an exception it means you're doing something you shouldn't be doing

dull copper
#

inject has been removed a long time ago from dots afaik

#

you'll see that a lot if you find some older tutorials/dots code

zenith wyvern
#

Meaning if you're trying to add a component when it already exists there's a flaw in your logic. You should either already know the component exists or you should be checking for it's existence.

odd ridge
#

my question about AddComponentData was because of the latest unity ECS tutorial by Mike Geig

#

he has a Ball prefab which has PhysicsShape and PhysicsBody components, but to change the velocity value, he adds a PhysicsVelocity component

#

which should already be added by the Physics scripts

#

because PhysicVelocity exists if I don't add it in the first place

#

from here, he adds PhysicsVelocity to the ball even though it should already have that component, no? https://youtu.be/a9AUXNFBWt4?t=3212

In this workshop style video we walk through an example project created by Unity Evangelist Mike Geig on how to script a Pong style game using Unity's Data Oriented Tech Stack (DOTS) including the Entity Component System (ECS). This video covers the latest syntax in Unity 2019...

β–Ά Play video
zenith wyvern
#

Yeah I have no idea, I don't really use the physics package right now and I haven't seen that video for a while, but it's easy enough to test. If you call AddComponent twice in a row on the same entity with the same type you will get an exception. Meaning you must be misunderstanding something in the video

odd ridge
#

I suppose the distinction is between AddComponent and AddComponentData, I guess the data only overwrites the data of the existing component

zenith wyvern
#

Okay I was wrong. AddComponent doesn't throw an exception, I was sure it used ot

#

It does return a bool, I'm assuming that's to let you know if it was a duplicate

#

AddComponentData is just if you want to set the value while adding it at the same time

#

But yeah, I would still say if you're adding when it already exists that's not right

odd ridge
#

ooh

low tangle
#

hm

#

wonder when that was changed

dull copper
#
false if the entity already had the component. (The component's data is set either way.)```
#

that doesn't sound like like there's anything wrong with adding it again

odd ridge
#

oh, I got my answer from the doc

zenith wyvern
#

Okay I was wrong. AddComponent doesn't throw an exception, I was sure it used ot

dull copper
#

isn't that in the doc? πŸ˜„

odd ridge
#

"Returns true if the component was added, false if the entity already had the component. (The component's data is set either way.)"

#

well it won't add it again if it's already there

low tangle
#

hm

odd ridge
#

lmao the server is having a heart attack

dull copper
#

yes, I just quoted that πŸ˜„

zenith wyvern
#

Discord is haunted

odd ridge
#

"Returns true if the component was added, false if the entity already had the component. (The component's data is set either way.)"

dull copper
#

yup

zenith wyvern
#

that doesn't sound like like there's anything wrong with adding it again
@dull copper

Just because it doesn't stop you from doing it doesn't mean it's not wrong. Not a big deal or anything but I think it does represent a flaw in logic imo

dull copper
#

I mean, I feel it's better this way (that you can just override the data if it exists already)

#

yup

odd ridge
#

yeah

dull copper
#

wtf discord πŸ˜„

crystal helm
#

btw, my performance died because of the static access :x

#

dont do that ^^

dull copper
#

there can be cases where you just want to add and set the data, if you don't do it a lot, being able to override the existing component data saves you from writing the checks yourself

#

also... I'll just wait until discord doesn't freak out like this πŸ˜„

dull copper
magic frigate
#

I tried building and running the Boids example from the latest sample but I just get a blue void. Any ideas as to why nothing is spawning?

dull copper
#

if it uses dots subscene, you have to build it with the new build tools

magic frigate
#

Ahh, I forgot about those

dull copper
#

dots subscenes will not build using the old setup

#

also pretty sure that was the exact sample where I first found out about this πŸ˜„

zenith wyvern
#

New build tools?

dull copper
#

it's part of the platform package now, used to be Build package before recent DOTS packages

zenith wyvern
#

I've never seen this thing in my dang life. Seems nicer than the "Build Settings" window

dull copper
#

you haven't used dots subscenes in build?

#

they would totally get ommitted by the old build setup

zenith wyvern
#

Nope

#

There's no proper documentation for them so I haven't used them

dull copper
#

I think this happened only during 2019.3 stage of DOTS

#

yeah, understandable

#

you need dots subscenes for dots livelink + dots editor's entity preview tool to work

#

they did add gameobject scene livelink on recent version tho, so I dunno if that's changing the livelink situation on DOTS without subscenes too

#

entity conversion preview thing is still dots subscene only

#

it was the main reason I even tried to use dots subscenes myself as I really dig it

safe lintel
#

@dull copper dont suppose youve tried to access the Unity.Build namespace at all?

#

latest update made it internal or something? its there, but I just cant access it since the latest package update that consolidated it

dull copper
#

@safe lintel if you mean past the attempt to build using these tools when we last spoke about it, then no

#

ah

#

they moved the build things to platform package

#

so it's probably just under different namespace now?

#

or did they move them to internal there too?

safe lintel
#

same namespace in the new package, i dont actually know what to look for if its actually internal, just that I cant use it 😦

zenith wyvern
#

I don't use the conversion system hardly at all since I do most of my work via procedural generation, subscenes should be useful on that front though so I should really start using them

dull copper
#

I wonder where I even put that old build script now

#

I should really organize random experiments better

safe lintel
#

anyway just saying as I had a nice little editor tool that consolidated annoying clicks in the editor, one of which was to build button off of one of those build assets so I didnt need to constantly hunt it down

dull copper
#

ah found it

safe lintel
#

its also getting confusing in the forums finding out which package has a subforum etc, took me a day to find the one for the python package which is just a thread

dull copper
#

ah, should do stuff like that myself too, it's just, only done small protos on DOTS so far to understand where it's at better, but if moving it into production side, then stuff like that would be really handy

#

atm, I don't even need the new build setup as I already ditched the dots subscenes

#

my main painpoint on those is that you really have to use hybrid rendering if you go there or do some hacky workarounds

#

main benefit of the dots subscene for me would have been that dots editors entity conversion preview, as it also shows live data easier than entity debugger does

#

but since there's no support on cross scene references, authoring rendering on other scene and syncing it to dots subscene was pain

#

you can do it but it's quickly more pain than what it's worth

safe lintel
#

i think i can use subscenes for enviro stuff, hybrid is adequate for my needs for now

dull copper
#

it'll get better soon for sure

safe lintel
#

hoping they announce and release v3 of hybrid at gdc though

dull copper
#

but I don't think the more experimental things will work in DOTS any time soon, like raytracing on hdrp

safe lintel
#

I downgraded to universal as I can just about stumble blindly through the shader code for it

#

id probably switch back if raytracing worked with dots though πŸ˜„

#

always chasing the new shiny thing

dull copper
#

and that DXR barely works right now πŸ™‚

magic frigate
#

Shamelessly copying the build pipeline asset from the FPSsample seems to have done the trick

dull copper
#

ecs samples already have it

dull copper
#

oh you meant the whole editor tooling they did there

magic frigate
#

Oh, they are there

#

Strange that these didn't show up when I searched for a pipeline

dull copper
#

if that's what you even mean, not really sure πŸ˜„

magic frigate
#

Those and the build pipeline they need to target

dull copper
#

proper Unity Physics joint support is still pretty far off

#

Steve from Havok wrote this few weeks ago: Conversion from Legacy Joint components will be in the next release due in the next few weeks.

#

so that will likely release soon (or at GDC)

#

but when it comes to joint motors (which these DOTS packages don't support atm), the response was: This upcoming release of the conversion code will not include motor support, however Joint motors are a priority for the subsequent release.

#

considering there's been ~3mo delay between physics packages, it's looking like we could expect that motor support around this summer (unless they speed things up)

safe lintel
#

yeah i was really hoping the cadence for updates for physics would be higher

dull copper
#

trying to setup those joints atm here

#

could try to do some naive motor to these I suppose

#

but man even the setup for limited hinge joint... πŸ˜„ nobody would setup these like this

#

should be at least some editor gizmo to tell where the positions and ranges are in reality

#

it's been ages since I've setup joints in unity in general, maybe I'm just spoiled by ue4's physics asset editor

#

oh wait there is a gizmo (I initially took only the joint scripts from dots repo, should have taken the editor tooling for them as well)

#

nevermind me πŸ˜„

safe lintel
#

i dont think ive ever used the motor part for joints, personally im looking forward to being able to ignore self raycasts

dull copper
#

I still wonder why there has to be perpendicular axis on this joint

#

one would think the position and axis + angles would be enough, why you need the perpendicular axis too?

safe lintel
#

I wouldnt know πŸ™‚

dull copper
#

just tested prismatic joints and they seem to have huge tolerance for the angle, things just twitch back and forth πŸ˜„

#

prismatic joint is supposed to be piston like joint, only moving on one axis

#

but due to the low stability, it lets the attached objects rotate back and forth

#

oh wow, it freaks out because I had scaled the other object

dull copper
#

it's still not fully stable but at least it's more in the ballpark what I expected from it

#

and switching to Havok totally explodes my test setup.. somehow Havok still plays nicely on the sample repos joint parade level

warped trail
#

maybe fixed time steps would help?πŸ˜…

dull copper
#

I'm actually running your mod here

#

wonder if that's why havok explodes πŸ˜„

warped trail
#

πŸ˜‘

dull copper
#

nope, still explody without

#

this is super simple setup, but I'm guessing I'm still doing it wrong here

warped trail
#

i've only tried limit DOF joints and they worked fine

dull copper
#

yeah, all joints do work fine on the samples repo too, with havok or unity physics

warped trail
#

i used it in my test project

#

oh and used soft joints too, but i created them from script. like they do in testsπŸ€”

dull copper
#

I'm just reusing the same scripts from that samples thing

#

of course this will not work properly without the motors

#

it wobbles less if I halve the physics step interval

#

I wonder if it's the huge mass ratio difference between the wheels RB's and vehicle RB that makes that happen

#

it's not self collision as collisions between joints and body have been removed

warped trail
#

and they want money for thisπŸ™„

dull copper
#

or well, I guess it could be if the authoring scripts failed there

#

it's clearly nowhere near finished (but I agree it's still quite raw to charge money for)

#

but I don't expect stable joints on Unity Physics at all

#

I'm pretty sure I could hide most of the wobbling even with Unity Physics if the rest of the things were implemented, mainly missing those motors from physics engine side

#

I normally do just basic raycast suspension, it's easy to get stable but requires all kinds of workaround and hacks for corner cases. Would love to do joint based suspension and handle wheel contacts on own code (as Unity Physics would let me do this), this would let me get best of both worlds but those joints would need to work better for it

vale nymph
#

Trying to get the Child buffer from an entity when creating it, however it gives back an error saying that the child component has not been added to it. Is there a different way to get the children of an Entity or am I missing a step? I know the object has multiple child objects on it

opaque ledge
#

if you are creating from command buffer, those doesnt add components to an entity immeidately, for simplicity you can think they are added next frame, the reason that is for performance reason.

vale nymph
#

Ah thanks you're right. If I just wait a small bit they are added!

dull copper
#

looking at unity physics internals for the linear limit jacobian and saw this comment: However, if the limits are nonzero, then the region is not a point, line or plane. It is a spherical shell, cylindrical shell, or the space between two parallel planes. In that case, it is not projecting A to a point on the constraint region. This will not prevent solving the constraint, but the solution may not look correct. For now I am leaving it because it is not important to get the most common constraint situations working. If you use a ball and socket, or a prismatic constraint with a static master body, or a stiff spring, then there's no problem. However, I think it should eventually be fixed.

opaque ledge
#

Does anyone know how to read Chunk Utilization in Entity Debugger

#

This is my ship chunk, what should i understand from that orange rectangle for example

#

or number of "44"

hollow sorrel
#

i think the ui for it is completely bonkers as for readability

#

have to look up what everything means every single time

opaque ledge
#

Thank you so much

warped trail
remote coyote
#

Ah useful Scorr! Somehow that forum thread had skipped my eye

vale nymph
#

Thanks @warped trail! I'll check it out!

dull copper
#

I'm also struggling to convert child physics bodies when the parent has it's own dynamic physics body

#

in past it was enough to just have another convert to entity script on child RB's

#

but somehow it doesn't convert anything anymore

#

if I separate the childs to not have converted parent, it works

#

even the script says it will be unparented when it will not actually convert anything

dull copper
#

hmmm, I might have used convert and destroy earlier when it worked

#

I honestly can't wait to have proper ECS editor in year 2025 :p

mystic mountain
#

@dull copper Not sure what your wanted result is?

remote coyote
#

hm, anybody has experience running conversion via unit tests?

#

in particular I need the GhostPrefabCollectionComponent to exist as singleton, which is handled through GhostCollectionAuthoringComponent's conversion pipeline. I have this component added to a gameobject in a scene that I load with UnityEditor.SceneManagement.EditorSceneManager.OpenScene

#

Since a unit test is not in "playmode", perhaps it prevents this from working

#

Ah, might just be that ConvertGameObjectToEntitySystem is not added... (its a private class in Unity.Entities.Conversion)

#

GameObjectConversionSystem is abstract, so can't add that system manually

#

hm

dull copper
#

@mystic mountain just want to have different physics bodies in parent and child without having to flatten the hierarchy

#

this works with convert and destroy on physics samples

#

but I'd prefer convert and inject gameobject as I can't use hybrid renderer and would still want to sync the mesh renderer logically

#

I could set the remaining GO's in different hierarchy tree and it would solve this (would still need to write custom conversion scripts for everything) but seems like every thing you do with conversion workflow nowadays is jumping through different hoops

#

or well, this probably would work even with this hierarchy if I did my own conversion again

#

it's just annoying that can't use almost any "stock" setups as they don't work in expected ways

#

if you use hybrid renderer, you are getting so much nicer experience with these conversion hacks

#

I think most of my recent painpoints with DOTS have boiled down to the built-in conversion stuff. Earlier, as soon as I dropped the editor tooling for most part and wrote my own, things started to work in more predictable ways

#

but at the same time Unity strongly recommends using the built-in authoring components which I feel they only work on some really simple use cases

gusty saffron
#

I've started using [GenerateAuthoringComponent] instead of writing proxies for my components. So instead of using the old "Game Object Entity" monobehaviour I use "Convert to entity". Previously, the changes made to entities showed in inspector (selected gameobject). How do I show current entity component values, in the inspector, with this workflow?

dull copper
#

what you mean by changes in case?

#

that generate tag should expose the component data properties which are compatible to the editor

#

you of course have to add those to the gameobject for it to happen

gusty saffron
#

Yes, I can see the properties in the inspector, but they dont change in runtime

dull copper
#

they've never changed runtime on DOTS on that view

#

but if you can use DOTS subscenes and hybrid rendering, you can get live conversion preview per DOTS subscene gameobject that does work even at runtime

#

I guess I don't fully understand what you mean by changes to the entities

#

any change you make to componentdata struct shouldl get updated on inspector too

#

and live data has never showed there in past

#

hmmmm, I thought that was a new video, but it has a comment from 2 weeks ago πŸ˜„

#

I guess they just updated the entry

warped trail
#

too bad my potato pc can't handle HDRP at all, and DOTS Sample on lowest is kinda broken on my machineπŸ˜‘

opaque ledge
#

does anyone made a script to check if an object can be seen in a camera ?
I made this:

            var difference = normalize(localToWorld.Position - cameraLocalToWorld.Value.Position);
            var forward = cameraLocalToWorld.Value.Forward;

            var dotResult = dot(difference, forward);
            var result = dotResult > cos(PI / 3);
#

it 'kinda' works and it actually is enough for my use, but was wondering if anyone has a 'proper' check

#

I know Camera class has WorldToViewPoint, but i need to use it on my job so i can optimize some stuff so i dont want to use reference type

zenith wyvern
#

I don't know much about culling but it seems like you can see how Unity does it in the hybrid renderer in Packages/Hybrid Renderer/Unity.Rendering.Hybrid/InstancedRenderMeshBatchGroup.cs. It seems like they pass in the camera planes to a job and do the checks against the entity's WorldRenderBounds components

#

They do some more broad checks like checking against the entire chunk bounds to avoid having to check any entities in that chunk too. Works well for megacity since large static chunks are separated spatially

velvet oxide
opaque ledge
#

Yeah something like this, thank you

mystic mountain
#

Is it even possible to get more than 15 fps with DOTS in the editor x(

opaque ledge
#

So i shouldnt use Physics Velocity yet right, since Physics isnt working properly ?

velvet oxide
#

Is there a way to modularly add IComponentData to Entities through the inspector? I got so close but I get some incompatibility errors

#

I made a attribute drawer that searches all of an interface and adds it to the serialized reference value

#
    [SerializeReference] public IComponentData data;```
#

I get this error ArgumentException: Unknown Type:`Unity.Entities.IComponentData` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType]. Unity.Entities.TypeManager.GetTypeIndex[T] ()

toxic mural
#

Is the [GenerateAuthoringComponent] messing things up?

velvet oxide
#

I have to make a concrete type...but when I do that I can no longer use [SerializeReference]

#

I have to make somehting like [assembly: RegisterGenericComponentType(typeof(GenericComponent<int>))] in my scripts but then I cant use serializereference. so close... :/

toxic mural
#

Are you supposed to be able get a reference to a struct?

#

I thought they're value types

velvet oxide
#

...oh shit yeah I guess I overlooked that

#

just saw that you can serializereference interfaces and thought this would work...didnt think about that though

#

Would be nice if we could add components this way so we could do "event" type actions

toxic mural
#

What are you trying to do? Some editor tool that adds components?

velvet oxide
#

yeah so for example I can have a list of components I want to add before destroying an object the next frame.

#

or for a trigger event...a list of components are added

#

like I could add an "OpenTag" component, a "SpawnObject" component

zenith wyvern
#

You could use authoring components to generate an entity with a list of components. But iterating over the components in a generic way is a lot more tricky

velvet oxide
#

yeah the only way I cna think of doing this is having a massive event system that each object carries all the time

mystic mountain
#

Anyone got any more ideas than turning off JobDebuger and Leak Detection, and enabling burst compilation to speed up editor? :S :/

zenith wyvern
#

@mystic mountain Subscenes

safe lintel
#

2020 might give you a boost

#

over 19.3

grim plinth
#

hmm wondering if I should convert t dots now or wait still it's near final because I want to switch to dots soon as it's fully ready

mystic mountain
#

What difference does subscenes make more than for load? However I'm already using it as much as I can...

zenith wyvern
#

You can unload subscenes when they're not in use, and any entities in the subscenewill not be processed by systems

toxic mural
#

Is anyone using .ScheduleParallel() inside a SystemBase? I need to chain job dependencies but I can't figure out how to get the first one

hollow sorrel
#

disabling editor attaching in preferences should make editor running faster too

#

altho then you can't debug and it's a pain to switch back cuz then you gotta restart editor

zenith wyvern
#

@toxic mural If you need to manually manage the job handles you just use Dependency like JCS used inputDeps

toxic mural
#

@zenith wyvern Hey I recognize you from the forum thread. I'd like to use automatic dependency management but I don't know how to trigger that. My issue is I'm using Entities.ForEach().ScheeduleParallel(), so to get a JobHandle back from the first job, I had to pass in a jobhandle, but I get errors thrown if I use this.Dependency or a new JobHandle()

zenith wyvern
#

If you're only scheduling lambda jobs you don't need to worry about the jobhandle. It will automatically chain them off eachother internally

#

Otherwise if you need the job handle you can do something like

var deps = Dependency;
deps = Entities.ForEach().Schedule(deps);
deps = new SomeParallelForJob().Schedule(deps);
Dependency = deps;
#

Assigning the job handle back to Dependency is basically like returning inputDeps from JobComponentSystem

toxic mural
#

fml it really was that easy. For two .ScheduleParallel() lambda jobs, second depending on first... well thanks!

zenith wyvern
#

Again, if you're doing Entities.ScheduleParallel only, you don't need Dependency. Just call them without passing in a job handle and it should work

#

Doing

Entities.ForEach().ScheduleParallel();
Entities.ForEach().ScheduleParallel();
#

Will do what I did above internally

toxic mural
#

I've only been into Jobs for a day or so, everyone kept talking about jobhandle dependencies so I figured I had to shove one somewhere, hah

#

Thanks very much for your help

zenith wyvern
#

Yeah the new way of doing it only came about a couple days ago

coarse turtle
#

ah that's cool that they're chained via the compiler extensions

zenith wyvern
#

Yeah it makes it a lot cleaner

coarse turtle
#

time to migate some jobs of mine to use this lol

zenith wyvern
#

Maybe more confusing if you're not familiar with how it works and you suddenly need to worry about managing job handles

indigo delta
#

Starting to look like LINQ chains :D

mint iron
velvet oxide
#

Very nice in a reorderable list too

#

@mint iron how did you get around the registering components?

#

or is it converting a string value to a type?

mint iron
#

Then stashing all the data on conversion with a TypeManager lookup >> ComponentType

velvet oxide
#

@mint iron Beauty thanks! I am loving this factory. Will poke around to get more ideas. I still need to be able to carry values with the components as well so I need to find out how to show that as well.

toxic mural
#

Does EntityManager.GetEntityQueryMask() need to be regenerated each update?

woven axle
safe lintel
#

is there a reason you are using rigidbodies over the physics authoring components? i did see this thread and wanted to give it a go on a small test scene but didnt get around to it

shadow jacinth
#

Ok quick stupid question. I have everything setup to test but I'm not seeing anything in game. But when I look at the debugger i see them moving... why?

zenith wyvern
#

Do you have the hybrid renderer package installed?

shadow jacinth
#

No. Thank you.

ocean tundra
#

Has anyone experimented with the new NetCode for a RTS?

remote coyote
#

Netcode is specifically being designed for a real-time shooter right now. Overwatch seem to be an inspiration. So real-time arena shooter. It wouldn't be an optimal solution for an RTS with a ton of units moving about.

#

They will tackle the RTS genre among others later though. Maybe we will hear some updates on those things come GDC

mystic mountain
#

I want to iterate over entities A with inner loop that are on the same spatial plane as entities B. The entities spatial planes rarely or never change, so my first idea was to subscribe both with a state component to a dynamic list which I can iterate over. Somewhat messy. Could sharedComponent solve this? I need to iterate A inner loop B, with matching sharedComponents then, anyone know if possible on first glance?

remote coyote
#

yes, with sharedcomponent you should get every entity with matching sharedcomponent state into a separate archetype. Does that work with ComponentsFromEntities? I'm not sure. Idk how else you'd do the inner loop?

#

I have not worked enough with the archetype/chunk specific stuff yet to know if it has an equivalent that would get you said list

#

well, array

mystic mountain
#

Hmm, I thought I could do IChunk with NativeArray of the other loop, but seems I can't access SharedComponent of the chunk...

remote coyote
#

So one tag per spatial plane might be the solution then, unless they're arbitrary

mystic mountain
#

They are sort of.

opaque ledge
#

So, i am making a system that makes space ships to raycast forward and store the results to a DynamicBuffer, so my question is this, my Dynamic Buffer has 10 buffers, so lets say my raycast system stores 3 of them to this Dynamic Buffer, i will be processing this results later on, on a different system but how that system will know that there is only 3 'usable' results in that Dynamic Buffer, will bad things happen if i process more than 3 results ? I know that i could just clear dynamic buffer and store raycast result, but i was wondering if i can do it without it

#

i mean i could check if element is null if it was a class but its not, its a struct.

mystic mountain
#

Why don't you want to clear it?

opaque ledge
#

well i am clearing it right now πŸ˜„ assuming clearing takes a little bit time i was wondering if i could do it without clearing

mystic mountain
#
        public void Clear()
        {
            CheckWriteAccessAndInvalidateArrayAliases();

            m_Buffer->Length = 0;
        }
remote coyote
#

yeah, that's about as cheap as a clear can be πŸ˜„

opaque ledge
#

πŸ˜„

mystic mountain
#

@remote coyote This is most likely how I will solve it this time if this works in practice, I basically have a duplicate of the shared component as normal one to check for index 0 of all chunks
https://pastebin.com/4Ri9j0VY

#

ofc with the typo of character chunks x)

remote coyote
#

thanks for sharing Jaws

remote coyote
#

right, so it just becomes a double for loop over the same chunk array?

#

well, in practice

#

ah

#

I see the comments where you set up the entity queries now Jaws

#

they're not actually meant to be identical, just wip

mystic mountain
#

Yeah, just some fast mockup, also 39 should be "var characterSpatialChunk = characterChunks[k].GetNativeArray(spatialDataChunkType);"

formal scaffold
#

Hey I'm currently working on rotating my character when moving the mouse. So far in my System I change the rotation like so:

        // Get the player position and direction, and change his rotation
        Entities.ForEach((ref Translation translation, ref Rotation rotation, ref LocalToWorld localToWorld, ref PlayerTag playerTag) => {
            
            rotationY += mouseInputX * mouseSensitivity;
            var targetRotation = quaternion.RotateY(rotationY);

            rotation.Value = targetRotation;
            
        });

And this rotates my character. I also have a CameraSystem that rotates the camera to the LocalToWorld.Forward of the player and sets the camera behind my target.

    protected override void OnUpdate() {
        Entities.ForEach((ref Translation translation, ref Rotation rotation, ref LocalToWorld localToWorld, ref PlayerTag playerTag) => {

            var targetPosition = translation.Value + new float3(0f, 1.75f, 0f) + localToWorld.Forward * -5.5f;
            cameraTransform.position = math.lerp(targetPosition, cameraTransform.position, Time.DeltaTime);
            cameraTransform.rotation = rotation.Value;
        });
    }

I let my CameraSystem update after the RotationSystem. But I see alot of stuttering when I rotate around. Any idea on how to prevent that?

opaque ledge
#

Update it before TransformSystemGroup, thats where CopyTransformToGameObject works

#

hope that helps.

#

also for tag components you can use Entites.WithAll<PlayerTag>().ForEach, its pretty useful when you wont be reading/writing to that component but want to have it on entity.

formal scaffold
#

Oh it is faster then I guess? Thanks I will change my Systems then. But updating my systems before the TransformSystemGroup doesn't change the stuttering.

It's wierd because I explicitly run the rotation of the character first and then change the camera. Also both Systems run on the main thread so the rotation should be set first before I position the camera and rotate it. Or mabye the camera is stuttering because I rotate and position it πŸ€”

opaque ledge
#

Well i have basically the same systems, let me check. Also another thing, if you are only reading from a component and wont be writing to it you can use "in" instead of "ref", that way Unity Job Scheduler can schedule your job better since parallely reading doesnt cause trouble while parelly writing to something needs to be in sequence

#

but that might be the case, its better to position first then rotate

#

Ah also, if you are going to use "in", there is a rule in sequence, without ref or in is written first, then ref, then in

#

So i just checked my systems, my camera system is updating after player movement, both on main thread, and before transform system group, i set position first then rotation. I only had your problem because of the issue i mentioned, but it was gone after i solved that. Not sure what else can.

formal scaffold
#

I am currently changing my systems to JobComponentSystems and make sure I use in and ref accordingly. Maybe it is something with the ComponentSystem. Ah one thing I'm interested in is, do you have a hybrid camera or a normal GameObject camera?

opaque ledge
#

its a hybrid camera i guess, i do Convert and Inject, and yeah changing to JobComponentSystem is good, tho newest one is SystemBase.

#

Also, generally speaking usage of ComponentSystem is not advised, in their manual it says it should be only used for deugging and such.

#

Also, if you are running main thread on JobComponentSystem, please use AlwaysSync attribute, otherwise it wont handle dependency properly, and return default.

#

you dont need to do that on SystemBase

formal scaffold
#

So if I use a private float rotationY outside OnUpdate() I cannot use .Schedule() or must use a local variable that is initialized. I gues it's .Run() then

opaque ledge
#

Can you upload your whole system in perhaps a hastebin or so ?

formal scaffold
#

Sure I'll try, have never used it

opaque ledge
#

looks good to me πŸ€”

mystic mountain
#

Anyone got any tips to solve unity editor crashing when enabling burst?
The output closest to crash in log;


Streamed scene with 1167ms latency from VirtualArtifacts/Extra/3f/3f1b1f1066f812fbeaf6b316faabde75.0.entities
Streamed scene with 1428ms latency from VirtualArtifacts/Extra/2c/2c7bf465ff5de0f0a21e3849bab2353a.0.entities
Refreshing native plugins compatible for Editor in 3.81 ms, found 3 plugins.
Streamed scene with 301ms latency from VirtualArtifacts/Extra/15/15894e1cc5f38121db59e5bae2b3b34b.0.entities
Streamed scene with 585ms latency from VirtualArtifacts/Extra/d1/d13fd0061ae04b252dcc1c416d44d1f8.0.entities
A crash has been intercepted by the crash handler. For call stack and other details, see the latest crash report generated in:
 * C:/Users/chris/AppData/Local/Temp/Unity/Editor/Crashes
Crash!!!```
opaque ledge
#

did you just update your burst package ?

formal scaffold
#

Same but maybe it's because of my camera being a pure GameObject. Thanks for your help πŸ™‚ πŸ‘ it's good to see that my Idea seems to be right just gotta play around a bit more then

mystic mountain
#

Not sure, haven't had it enabled for a while...

opaque ledge
#

Well burst manual says that if you upgrade your burst you should close your editor, delete library folder and open your project

mystic mountain
#

And C:/Users/chris/AppData/Local/Temp/Unity/Editor/Crashes is empty..

#

Might be that then

opaque ledge
#

"f you update to a newer version of Burst via the Package Manager in your project which has loaded already Burst, you need to close the editor, remove your library folder and restart the editor"

formal scaffold
#

Thats so strange πŸ€” removing this fixed my problem.

UpdateAfter(typeof(CameraFollowTargetSystem))
opaque ledge
#

can you check entity debugger and what order they update ?

formal scaffold
#

I know I have to fix the names of my systems πŸ˜…

#

MovementSystem > CameraRotateSystem(Rotates and positions Camera behind player) > PlayerRotateSystem (Rotates Player along Y-Axis)

coarse turtle
#

Hmm, I thought I could do IChunk with NativeArray of the other loop, but seems I can't access SharedComponent of the chunk...
@mystic mountain You can grab the index of the ISCD and use it for later look ups

mystic mountain
#

@opaque ledge So I removed and recloned project, and this time I actually got crash report, still can't decrypt what is casuing it...

Stack Trace of Crashed Thread 28740:
0x00007FF981421EB0 (cf9b3d8952302bff45629d8fc2c95cc) FB3CA9C5D08E944A
0x00007FF981421703 (cf9b3d8952302bff45629d8fc2c95cc) FB3CA9C5D08E944A
0x00007FF98142136D (cf9b3d8952302bff45629d8fc2c95cc) FB3CA9C5D08E944A
0x00007FF98142117A (cf9b3d8952302bff45629d8fc2c95cc) FB3CA9C5D08E944A
0x00007FF981421030 (cf9b3d8952302bff45629d8fc2c95cc) FB3CA9C5D08E944A
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C7065E)
0x00007FF644C7065E (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C708BC)
0x00007FF644C708BC (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C71742)
0x00007FF644C71742 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C5F7ED)
0x00007FF644C5F7ED (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C5FF4D)
0x00007FF644C5FF4D (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C61AA3)
0x00007FF644C61AA3 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF644C66E36)
0x00007FF644C66E36 (Unity) (function-name not available)
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FF6451B1123)
0x00007FF6451B1123 (Unity) (function-name not available)
0x00007FF99A7E7BD4 (KERNEL32) BaseThreadInitThunk
0x00007FF99AA4CED1 (ntdll) RtlUserThreadStart
opaque ledge
#

hmm, it says function-name not available, perhaps something with function pointer ?

mint iron
#

mmm... if you can find the .dmp, then open that in visual studio sometimes you can get a more useful trace of the callstack. But if its coming from deep in unitys native land you might just have to comment things until it works again.

mystic mountain
#

weird thing is it doesn't crash when built.

trail burrow
#

@mystic mountain you tried to de-reference an invalid pointer

formal scaffold
#

Is it possible to lock the Rotation of the DOTS Physics Body? Angular Damping helps a bit but it doesn't remove it. I apply force to move my character and moving back and forth along the Z-Axis. This causes my Physics Body or Physics Shape to rotate along the X-Axis. Which makes sense but I don't want rotation on either Z or X Axis. With a normal RigidBody you could freeze Rotations along Axes can I do the same with the DOTS script?

warped trail
#

look at physics samples there is limit DOF joint

formal scaffold
#

Thanks I found it πŸ‘

velvet oxide
#

This may seem like a stupid question but is there a way to remove a dynamic buffer?

#

from an entity

opaque ledge
#

doesnt RemoveComponent work ?

#

dont write DynamicBuffer when you are removing tho, so if you have MyBuffer : IBufferElementData, then do RemoveComponent<MyBuffer>()

stiff urchin
#

I've loved using DOTS so far, but man is it ever unstable on macos. 😦

bright sentinel
#

@stiff urchin How exactly have you experienced it being unstable?

stiff urchin
#

Typically on play any entities I have get rendered as transparent in the editor or weirdly like a plane if you're too close..

#

Editor crashes on play about 30% of the time.

bright sentinel
#

What version of Unity and Burst are you using?

stiff urchin
#

2019.3.1f1 and 1.2.3

bright sentinel
#

Do you also have the experimental "Enter play mode options" enabled? That's supposed to cause a lot of crashes

#

As for the other things, sounds like it's a problem with the renderer

stiff urchin
#

yeah it's weird I can set it to ogl and its better in some ways and worse in others.

#

I'm looking at my play settings now

#

yeah the play mode options are all turned off

#

I think the number of packages I have installed also makes it hard for vscode and vs to compile.

#

resulting in me not having intellisense in either code editor

bright sentinel
#

Yeah I think IntelliSense is still an ongoing thing with DOTS generally

#

I'm at least having some major lag issues with Rider

stiff urchin
#

yeah vscode/omnisharp just flat out fails to load and visual studio lags and shows incorrect information. 😦

bright sentinel
#

Yeah, but that's kind of to be expected with preview packages

#

Not really the main concern there

#

Have you also tested your project on Windows to make sure they are actually Mac problems?

stiff urchin
#

yeah I generally have way fewer issues on windows

#

only I'm never at my windows machine.

#

lol

#

I have been using unity with parsec(game streaming) and it works pretty good for the most part.

#

just an inconvenience.

bright sentinel
#

Hm alright. My teammember hasn't complained about any Mac crashes tho, so πŸ€·β€β™‚οΈ

pliant pike
#

are you only allowed one Entities.foreach in a jobcomponentsystem or something?

opaque ledge
#

no

pliant pike
#

I don't understand why it isn't running then, debug.logs work in jobs don't they as long as you have .withoutburst()

opaque ledge
#

are your jobs depend on each other or independent from each other ?

bright sentinel
#

Either way, you should probably use the debugger of your IDE instead. It's going to be a lot easier to debug with that

pliant pike
#

they are independent the first job is just running on the main thread so I can't pass handle's from one to the other

#

I hate using the ide debugger its to slow

bright sentinel
#

Which IDE are you using?

pliant pike
#

Rider

bright sentinel
#

I haven't had any problems with it

pliant pike
#

well I mean you have to set a break point and if you want to see all variables through a length of time you have to click through constantly

opaque ledge
#

So your first job do Run() and your 2nd job do Schedule() ? Well it should work then, can you check entity debugger to see if both ForEach has a valid query ?

pliant pike
#

no second is run as well withoutburst

opaque ledge
#

WithoutBurst or WithBurst doesnt really affect whatever ForEach runs or not, if burst fails it falls back to withoutburst i think, but it sounds like your 2nd job doesnt have any entity to run on, maybe thats why you are not getting log output πŸ€”

pliant pike
#

neh mind stupid me I had the thing unclicked in the console 😳

#

sorry