#archived-dots

1 messages Β· Page 128 of 1

dull copper
#

I've just spent so much time alone fighting the dots subscenes that I now just avoid them at all cost (which is at the same time sad because I really love the entity conversion preview using dots editor package that only works on DOTS subscenes)

worldly pulsar
#

I haven't looked into the new hybrid component mechanism, but do I understand correctly that we will be able to just put arbitrary old-style components on GOs in a subscene and have them "Convert-and-Injected" except with all the subscene features?

sour ravine
#

officially

#

no

bright sentinel
#

Not 100%, only if the Entities package has already defined ECS components for the MB component

sour ravine
#

unofficially, yes

#

limits apply, see store for details

bright sentinel
#

But most standard ones do, e.g. transform and renderer

worldly pulsar
#

So you can e.g. use Animators etc and they will just have some hidden gameobject created for them at runtime, correct?

sour ravine
#

very loosely

bright sentinel
#

You'd have to inspect the source for each conversion to get the specifics

sour ravine
#

hybrid stuff can use 'real' components AFAIK, there's just an invisible game object linked to the converted entity

#

I don't believe it's strictly based around creating ECS equivalents

#

transform is synced with some helper systems

worldly pulsar
#

Which as I understand doesn't require any specific conversion code more than "keep this old-style component around"

dull copper
#

Yeah, but invisible go's are like the total opposite what I want

sour ravine
#

right-- and keep in mind a lot of this involves under-specced invisible things that aren't really documented

dull copper
#

I want more data actually exposed in the editor

sour ravine
#

^

bright sentinel
#

Oh yeah, that's useful for something like camera's with hybrid renderer V1, where there is no direct ECS support yet, so you can access it directly from Entities.ForEach

#

(There is now for cameras, but there are still other things living in GO world)

#

Like author tools especially

worldly pulsar
#

I'm looking at this as a temporary solution for the subscene+hybrid setup pain (Ideally I'd like to just put my whole canvas into a subscene and then query for (TMP_Text, HPDisplayTag) in a system).

sour ravine
#

which, unofficially does seem to work

bright sentinel
#

Related question, is that really the best practice for UI? I know that is a big pain point currently, but my understanding here was that a single UI manager was a better solution here

opaque ledge
#

@worldly pulsar dont put monobehaviours into class components that has TMP asset in it, it wont build. You have to do AddComponentObject using EntityManager directly if you want to control the MB from ForEach lambda

#

@bright sentinel i dont know what is the best practice for DOTS UI but you can just simply AddComponentObject to your entity and control your MB from there, however weird thing is.. when you destroy the entity the object you add with AddComponentObject reference will be lost as well, and if you add a Monobehaviour to a class component and add that to your entity(which imo much better solution than AddComponentObject) if your MB has TMP asset in it, it wont build(but its fine if you are in editor).

low tangle
#

You can use a system with a lookup table and a system state component to cleanup gameobjects when the entity is deleted.

opaque ledge
#

Yeah thats what i was doing, or if you want to do in a dirtier way you can also check from MB if entity is alive or not

low tangle
#

Don't do that

#

Won't scale well at all

opaque ledge
#

but like i said since my MB had TMP in it so it didnt build, i had to change to AddComponentObject version

#

yeah i know, some of the Unity's examples is doing it πŸ˜„

low tangle
#

Oof

#

I only do the on destroy event for making a gameobjects delete it's entity

opaque ledge
#

tho i guess its not big deal if you are only using it for screen UI (means there is only 1 script), but in my case it was World UI

low tangle
#

But that's almost never used

#

I've got quite a few linked gameobjects

opaque ledge
#

why is that ? its a game mechanic or ?

#

because from what i can see its only there to destroy whole hiearchy once parent is destroyed

low tangle
#

Made a interface it works on to make it simple to convert. It's like the older gameobjectentity just without the stuff that doesn't scale

#

It's for managing UI and vr controllers which are impossible to do in ecs

opaque ledge
#

btw, since you are much more experienced than me, have you ever tried render culling ? or succesfully using it ? (for 3D)

low tangle
#

Most vr movement and tracking is done though transforms

#

Yeah I have

opaque ledge
#

never tried VR 🀷

#

Can you tell me the approach you took if its not too complicated πŸ‘€

#

i tried with adding frozen scene tag but its not burstable so its taking like 50 ms lol

low tangle
#

Fulstrum culling, you construct 6 planes that define the camera fov and near and far clip planes. Then you select/filter/sort your render set by 6 simple plane dot products

#

Putting your scene into a bvh before intersection is a good idea as well

opaque ledge
#

i am using that to control some other stuff, like disabling/enabling World UI, which was a massive improvement, but render mesh v2 is still rendering all stuff which takes like 30 ms.

#

wait, am i suppose to change rendering layer of the entities somehow ?

low tangle
#

Full occlusion culling probably won't save you in that case

#

I think the new render had a tag for don't render

#

Or disable

#

You should be changing that

opaque ledge
#

ah, i remember that, like disable tag that only prevents rendering

#

yeah i dont think that is in render mesh v2, i guess i have to wait on URP HDPR 9 πŸ˜„

low tangle
#

Use the regular ecs disable then

opaque ledge
#

that disables everything tho

low tangle
#

Got other logic on that entity?

opaque ledge
#

yeah, they are my space ships πŸ˜„

#

so they have AI, movement, shooting etc.

low tangle
#

Detach the rendering on them

#

Then just have a pass after render culling where you cdfe their position from the real one

#

Since it's after culling your only copying the position of ones your going to render anyways

opaque ledge
#

how do i detach it ? i tried to remove local to world and then add again but it doesnt work because children's local to world isnt updating properly i think, i also tried removing world bounds but there is a system that adds it automatically

low tangle
#

Detach at creation

#

Ship entity, render entity

#

Render entity has a component that refs the ship

opaque ledge
#

oh i see, so i copy the position of ship entity to render entity ?

low tangle
#

For making sure the sub entity gets deleted, put a child entity array on the 'head' entity which is the ship. When deleting the ship delete the children in the buffer as well

#

Yes

#

Now you can separate the logic and have less fat archetypes

#

Which will improve your cache performance

opaque ledge
#

I see thanks for the insight, that is indeed doable, tho my ships are modular, meaning there is a gameobject for core, engine, weapons etc which can make things a little bit uglier for this approach, i think i will wait on the new shiny stuff and make use of that disable rendering component

low tangle
#

Oh there not fully entities?

#

Ship parts buffer on the head

opaque ledge
#

They are, i meant to say that when they are converted they will have bunch of child entities which actually has the rendering components

#

wait... what if i just add disable component to children πŸ€”

low tangle
#

Yeah

opaque ledge
#

children doesnt have any logic on them except for rendering and positioning

#

hoooo i will try it now, thanks much πŸ˜„

low tangle
#

Would work

#

Sure

opaque ledge
#

@low tangle it works \o/ πŸ˜„

low tangle
#

hell yeah

opaque ledge
#

πŸ˜„

#

i guess creating world UI for every ship and disabling out of camera ones doesnt exactly work

#

There are "Semaphore.WaitForSignal in profile but i have no idea what they mean, sure i guess they are waiting for a job to finish but which one πŸ€”

low tangle
#

whats the UI for each ship look like?

opaque ledge
#

Basically

#

@low tangle

#

also i managed to run 4k ships under 60fps (without UI) πŸ‘€

#

i am so proud

#

Also about UI, i create 1 for each ships and then disable/enable according if ship is in view.

#

Updating them doesnt take much time 4-5 ms, but other canvas related stuff such as render batch etc.. takes too long

#

i think instead of create 1 for each ship i have to pool it in a way that only ships in view will have those UIs

low tangle
#

yeah okay

#

so its simple UI

#

way overkill for using old unity's UI

#

instead create a gameobject, put a quad inside that, put another gameobject with text mesh pro non ui version

#

resize the background to match the size of the tmp gizmo

#

update the tmp contents and g2g

#

it will render faster than that UI by a lot

#

its what my nameplates are

#

few quads, all with injected entities for each all driven by the entities

opaque ledge
#

how will i able to do the shield/healtbar tho ?

low tangle
#

multiple quads all stacked

#

if you need to start doing animations on them, your gonna need to find a UI framework that actually scales

#

value could also be driven into a material instance

#

drawn in the pixel shader

opaque ledge
#

no i meant, they are image with type of filled, so when they get damage or regenerate i am updating the fill percentage, how will i able to handle that in gameobject approach ?

#

oooh

low tangle
#

you would just adjust the size and position of the filled bar

opaque ledge
#

i never done shader stuff, would shader graph ok ?

low tangle
#

scalling and position

#

yes ofc

opaque ledge
#

ah i see, do you think positioning and scaling is better than doing it with shader graph ?

low tangle
#

if you make a shader for it, you can use masks and make the bar much more intresting looking

opaque ledge
#

i think i will go with shadergraph since i dont neet do calculate any position and stuff πŸ˜„

#

yeah will try, thanks

#

i shall working on it now πŸ˜„

low tangle
#

good luck

opaque ledge
#

it works \o/ πŸ˜„

#

tho it still is taking 8-10 ms for all 4k, even if i dont move the UI gameobject if ship is not visible

#

oh well

low tangle
#

better just do some max number of health bar culling then

#

or one health bar for groups/fleets

bright sentinel
#

Yeah, you also have to think about how much information a player can actually take in

opaque ledge
#

yeah, i think i will take a break from that ui stuff rn πŸ˜„ right now it works pretty well and ui will depend on testing, like what people want to see etc.

#

So i guess i can just use simple gameobjects for world ui rather than actual world ui πŸ€”

low tangle
#

yup

eager oracle
#

Good morning

obtuse swallow
#

Hi guys! I have entities that need to be added unless they already exist (I define "existing" as "there is already an entity with same components and same values"). Is there a better way to do this than keeping an hashset of them in my system? EDIT: What entities need to exist or not exist changes over time.

bright sentinel
#

You could create queries of the archetypes that you check and then check whether the count is bigger than 0

worldly pulsar
#

same components and same values
Can't compare values in a query. If you can't create/destroy the entities when the set of "what shoud exist" changes I'd say a hashset is the simplest thing you can do.

bright sentinel
#

Oh, I missed that, that's true

#

Then I agree

opaque ledge
#

you can impletement IEquatable on a struct and do your custom logic and do array(or list).Exists(value) in your list, if it returns true then it exists, if not then it doesnt

dull copper
#

Unity has been removing their tech demos lately

#

just warning here that if you want to keep access to MegaCity, maybe good idea to backup that zip file

#

they just wiped BOTD, Adam 1, Blacksmith etc assets from asset store

#

I don't think MC will be gone yet but wouldn't trust them to keep it around for long either

wet epoch
#

they deleted standard assets even

dull copper
#

only the old ones

#

the newest package for 2017.3+ is still up

worldly pulsar
#

you can add standard assets via Unity Hub

wet epoch
#

ah ok

dull copper
#

@worldly pulsar isn't that for the "new" standard characters on the github?

#

that project got essentially purged too

worldly pulsar
#

hmm, let me double check

dull copper
#

like, it's still there, they moved the development to some other team but it's been pretty dead since

wet epoch
#

i'm not sure the assets in those demos were free to use anyway?

#

i think they were all restricted?

worldly pulsar
#

they were free

dull copper
#

some assets were restricted, basically everything on Adam tech demos

#

BOTD art assets are all free to use for your own projects

wet epoch
#

ah ok, seems weird for unity to take them down then

dull copper
#

I wonder if it has anything to do with Epic now owning Quixel

#

all of those demos had Megascans in them

wet epoch
#

i guess they didn't want to update the shaders and stuff

dull copper
#

so maybe they couldn't renew some old deal anymore

wet epoch
#

ah ok, maybe

dull copper
#

they haven't updated the tech demos anyway that much

#

they updated BOTD once

#

and they were supposed to update it for 2019.3

#

there's even WIP branch on SRP github for the update

#

but that doesn't look like it's happening now πŸ˜„

wet epoch
#

i guess we can hope it's temporary

#

they might've just got sick of support requests

dull copper
#

I dunno, I first thought they were thinking different redist approach for these

#

but after seeing all the content the removed at the same time, I think these all were intentionally removed

#

would love to hear from Unity about the reasons though

wet epoch
#

i think we can still download them

#

but only if we "bought" them previously

dull copper
#

if you've added them to your account, you can still download them

#

yes

#

well, they completely wiped some older stuff from the store, but that was like Unity 3.5 content πŸ˜„

#

I don't see those assets on my account even on the deprecated side

#

but I also doubt many will miss them

#

there was one nice vehicle sample for Unity 3.5 that I was looking to backup but it's now gone πŸ˜„

#

they had like additinal raycast vehicle sample there that implemented pacejka tire model and had a race track

worldly pulsar
#

re: standard assets via hub - seems like that only works for <=2017.3 (in the "Add Module" window) and it's the asset store version, with Ethan and projector shaders etc

dull copper
#

ah, I'm totally backing all these up now πŸ˜„

#

I don't really have any use for standard assets but many example scenes do require them

opaque ledge
#

perhaps they will add new ones soon πŸ€”

dull copper
#

well, that's what the initiative for new standard characters were for

#

before they got dropped

#

tbh, was in kinda weird position considering dots is ramping up and it was still about the old unity

#

it seems that they want to slowly move new development to happen on dots ecosystem instead

bright sentinel
#

Yeah, I think the problem is that it seems like Unity is split into old Unity and DOTS atm, so each area gets half the resources of a full Unity R&D

#

And so each product is just inferior

opaque ledge
#

i really doubt Unity will stop 'supporting' MB way, there are lots of stuff released for MB and lots of people doing games with it, sure ECS definitely will be popular but imo not popular as MB is, and that is definitely will be like that for at least 5 years

#

I mean you cant even raycast without issues right now πŸ˜„

#

Hope new update will come soon, i am curious πŸ‘€

dull copper
#

it's not about stopping support, but they are moving most new development toward DOTS now

#

things we see now in previews or coming to previews are mostly things they've started working on years ago already

opaque ledge
#

Well i mean they should obviously bring some basics such as UI, animation etc.., not sure if it should count as 'new development'

thorny vault
#

Hello! I'm doing some experiments with ECS, and noticed my systems load in every scene. Are there best practices for filtering which systems load in each scene? I'm thinking of adding an attribute [LoadInScene("scene_name")] and checking it against the current scene name in ICustomBootstrap.Initialize. I'm not sure if Initialize will be re-run between scenes, though.

opaque ledge
#

If anyone is interested in burst code

thorny vault
bright sentinel
#

So what is the reason for safety checks, and why would I ever turn them off?

mint iron
#

its faster without safety checks

bright sentinel
#

Oh, okay. I assume they are turned off automatically in a build?

opaque ledge
#

i think for deadlocks and race conditions

#

yeah they are turned off

bright sentinel
#

So what's the reason for being able to turn them off in the editor?

#

I mean, wouldn't you always want them on? Because if you're measuring performance, you really should do that in a build anyways

opaque ledge
#

yeah you probably want to have it turned on all the time

bright sentinel
#

So what's the reason for being able to turn them off in the editor?

mint iron
#

I've turned them off before to see if the game crashes, and also because my notebook is really slow and things can get bogged down in the Editor.

#

Live link is taking like 5ms every frame while doing nothing

bright sentinel
#

But wouldn't the safety checks report if there are any things that would cause a crash?

mint iron
#

youd hope so!

opaque ledge
#

for thread related probably

mint iron
#

also some of the things i'm writing use the safety checks define, so it helps to make sure things are working as you expect. For example, im using EntityManager.SetName to add helpful debugging information, and don't want that stuff in a real build. I guess thats not really the intent for safety checks, but yeah, i guess if you're writing your own native containers.

bright sentinel
#

Couldn't you just use #ifdef UNITY_EDITOR?

#

Or whatever it's called

mint iron
#

mmm yeah i should do that

opaque ledge
#

yeah same thing over here, you just have to use that ifdef

digital kestrel
#

what are blobassetstores?

opaque ledge
#

no idea πŸ˜„ but they are used for run time conversation for some reason

digital kestrel
#

lol

warped trail
#

from documentation πŸ˜„ Purpose of this class is to provide a consistent cache of BlobAsset object in order to avoid rebuilding them when it is not necessary

fallow mason
#

I'm guessing there isn't an equivalent viewportpointtoray in ecs yet?

#

since camera is not pure ecs

opaque ledge
#

you can make it on OnUpdate and then send it to your job

warped trail
#

math.mul() πŸ˜‰

opaque ledge
#

you can get references to your cameras inside OnStartRunning

fallow mason
#

eh, I don't need the camera reference beyond needing to cast ray from mouse position whenever it's clicked

#

and yeah, @warped trail I've been thinking about fumbling through the math to turn screen space into world space

#

is it really that easy?

warped trail
#

just matrix multiplication

fallow mason
#

fine. I'll do it.

warped trail
#

but you have to get matrix from cameraπŸ€”

opaque ledge
#

πŸ˜„

safe lintel
#

@bright sentinel just for playtesting purposes, much more enjoyable experience without the background overhead of both the editor and safety checks. like the dotssample runs kinda poorly with all safety checks on

fallow mason
#

right

#

and would need to be orthographic

#

to get the right end point

warped trail
#

i guess you need matrix with perspective to transform directionπŸ€”

fallow mason
#

bah. this is getting too complicated to merely queue a movement target.

#

probably going to have to do more on the MB side than I was hoping

mint iron
#

4D space time math

warped trail
#

store this matrix once. and then just recreate it with translation and rotation😏

low tangle
#

start of a systems update, Camera.main.transform.localtoworld

digital kestrel
#

if I wanted to spawn an entity on button press

#

should i instantiate a gameobject with conversion scripts that destroys the game object

bright sentinel
#

@digital kestrel You can't convert a gameobject in the middle of a game, only at the start

digital kestrel
#

what do you mean "start"

#

instantiating my game object prefab converts properly to entities

#

even if I instantiate them post-initialization

#

@bright sentinel

low tangle
#

You can run gameobject conversion at any time. You will need to decide if the thing you're spawning is simple enough to just be a entity. You can also covert a prefab version and instantiate that

digital kestrel
#

Thanks for the info. I've thought about keeping a global dictionary of gameobjects to entity prefabs, but didn't know what the best practice was

#

when my gameobject is done building, i want to spawn the entity to replace it

fallow mason
#

oh I didn't see the new beta

#

anything interesting in b4?

north bay
#

Crashes got fixed and replaced by new ones

opaque ledge
#

lol

#

well i just want urp/hdrp 9 offically supported so i can upgrade πŸ˜„

dull copper
#

most recent HDRP master is incompatible with b4 already

#

this is like 9.0.0-preview.13 atm

opaque ledge
#

Olento, share your infinite wisdom with us and tell us when urp/hdrp 9 will be relased πŸ‘€

warped trail
#

soonπŸ˜†

mint iron
#

will i have to upgrade to 2020 or will they backport to 2019.3?

dull copper
#

2020 only

mint iron
#

sad panda is sad

dull copper
#

this basically means no hybrid renderer v2 on 2019 cycle

warped trail
#

my bet 9.0 is for 20.2 πŸ€”

mint iron
#

i guess we are in 2020 now....

dull copper
#

9.x is supposed to be for 2020.2 but it's still compatible with 2020.1

#

that recent probe change that broke HDRP on 2020.1.0b4 doesn't mean it wouldn't have the change on b5 or b6

#

I'm currently just waiting for 2020.2 alphas to go public

#

they've been on 2020.2 alpha 5 for a good while according to issue tracker

#

couldn't really care much about 2020.1 as it's just stepping stone for the 2020.2 and .3

safe lintel
#

any featurelist for 2020.2?

dull copper
#

they've said they'll fix HDRPs (and hybrid renderer v2's) perf on DX12 on 2020.2

#

they also make hybrid renderer v2 to work better on other platforms on 2020.2:
Hybrid Renderer V2 is experimental in Unity 2020.1. We have validated it on Windows DX11, Vulkan and Mac Metal backends in both Editor and Standalone builds. Our aim is to validate DX12, mobile device and console platform support for 2020.2.

#

can't think of anything else that would have been announced

#

the roadmap stream we got didn't have almost any estimates, it was more like what they are working on

#

so can't really tell what all of it will land on 2020 cycle and what's going to 2021 etc

safe lintel
#

oh more platform support, was thinking it was features related for 2020.2

mint iron
#

god damn unity physics throwing exceptions at me shakes fist

safe lintel
#

is it something to do with the rigidbody index out of range? πŸ™‚

mint iron
#

sounds about right.. is this a known issue?

#

IndexOutOfRangeException: Index 0 is out of range of '0' Length. -ExportDynamicBodiesJob

naive parrot
#

@dull copper any idea ?

dull copper
#

probably what it says

#

it can't write to that destination

naive parrot
#

not very helpful. evey other package installed all correctly

#

entities always has been problem to install properly

dull copper
#

I'd wipe the package from cache

#

try again

naive parrot
#

IDE was locking the path smh

#

thanks anyways!

mint iron
#

figured out the exception - i had switched a system to not use command buffer, and it was instantiating new entities that contained physics components in the middle of the damn simulation group. So Physics tries to do something and the chunk now has more components than its expecting and it throws its toys around the room.

safe lintel
#

sorry was watching ozark, whenever im checking raycast results I seem to always need to ensure its not -1 otherwise I seem to get those errors

#

i think i also check its not 0 maybe out of paranoia πŸ˜„

opaque ledge
#

it returns bool anyway, so you just have to do if statement for raycast check if it hit something

dull copper
#

from the forums: ```If you have problems with objects rendering at the origin when using Hybrid V2, you can try re-importing the shader graph to make sure that the shader graph is using V2 code and not V1 code. Switching between V1 and V2 causes a change in how the shader code is generated for shader graphs, and unfortunately the currently released version doesn't automatically re-import when V2 is enabled. A fix for this is being developed.

There was also another bug that caused specifically the PBR shader graph to work incorrectly with Hybrid V2. That bug has been fixed, and the fix should hopefully be in the next release. ```

#

to me that sounds super hacky πŸ˜„

#

I don't get why they don't just make some variant tag for the SG that would just trigger recompilation, instead of having to play with version numbers

modern flame
#

Hello !
I'm trying to port my WIP bocky voxel terrain generator (minecraft-like, i'm learning unity) to pure ECS and i'm having a lot of trouble understanding how i'm expected to represent my data structure.

i've defined a component public struct ChunkComponentData : IComponentData inside of which i'd like to have a "list" of voxels. That is, an "array" representing the vertices, normals & triangles for the chunk.

I've tried a lot of things but as soon as I try using an array, fixed array, nativeArray, buffer or whatever the code either won't compile or give me a 'not blittable" runtime error.
I've also tried using a IBufferElementData and a buffer directly on the chunk archetype but i couldn't figure out how to read from this buffer ... when i try to use EntityManager.GetBuffer<VoxelBuffer>(entities[i]); I get a "VoxelBuffer is not a valid component"

So my question is: how should I represent a "list" of structs inside of a component that has an arbitrary size (set at runtime).

scarlet inlet
#
 /// <summary>
    /// Burst friendly RingBuffer on steroid:
    /// it can: Enqueue/Dequeue, it wraps if there is enough space after dequeuing
    /// It resizes if there isn't enough space left.
    /// It's a "bag, you can queue and dequeue any T. Just be sure that you dequeue what you queue! No check on type
    /// is done.
    /// You can reserve a position in the queue to update it later.
    /// The datastructure is a struct and it's "copyable" 
    /// </summary>
#

quite powerful, but it may have still some bugs, if you can spot a bug it would be awesome πŸ™‚

stone osprey
#

I wanna start with dots πŸ™‚ What unity version should we use ? Unity 2020 Beta ? Or Unity 2019 Stable ?

fallow mason
#

I use 2020 b4. You shouldn't be using DOTS for production use yet, so why not live on the cutting edge?

low tangle
#

2019.3 also fine

fallow mason
#

The real cutting edge has been trying to get it working on 3.5 😏

stone osprey
#

Thanks everyone πŸ™‚ @fallow mason Why shouldnt dots be used for production yet ? Thats exactly what i wanted to do... im reworking my current client architecture and wanted to choose a data oriented approach for managing entitys ( mobs, players... items )

mint iron
#

There is a big risk that depending on what you want to do, you may hit huge roadblocks. For example building to IOS in some situations with URP can screw up rendering of all your textures on device. You can get around most of these issues if you're willing to do enough work, or are working with the Unity team directly for VIP support. Its not mature, so you can't rely on it working as expected.

opaque ledge
#

There are still things to get stuff into DOTS, like animation, UI, physics(properly working) etc and making it hybrid takes some time/complicates things,.

fallow mason
#

well, parts of it (like the job system I think) may be out of preview, but I know entities, burst, etc is not yet. Anything in preview is not recommended for production use and may change wildly before it is out of preview.

opaque ledge
#

I am however working on a game using DOTS, and i want to release it in a couple of months, so we will see how it goes πŸ˜„

stone osprey
#

Thanks ! I didnt knew that :/ Well actually i want to use entitys for moving my mobs etc... i thought i could use dots spawn and manage my prefabs for monsters... i also thought about "Entitas"

fallow mason
#

sorry, I believe Burst is actually the only part of DOTS not in preview

dull copper
#

job system was first part basically

#

I think new math lib has also been out of preview for a while, wonder if it released same time with burst 1.0

fallow mason
#

Until they paginate math doc, its still in preview for me

dull copper
#

what do you mean by that? @fallow mason

#

math lib's scripting api docs are bit scarce but I doubt that'll ever change

dull copper
#

looks like pretty classic autogenerated api docs

#

I personally hate autogenerated docs

#

but that's what we have now

naive parrot
#

i have been stuck in this package dependency hell for days now. as soon as i install entities package , all the package manifest resets and all the DOTS package get removed. all these exceptions are caused by missing DOTS package ( math/collections/burst/jobs )

fallow mason
#

did you scroll down?

#

just wait a bit

dull copper
#

@fallow mason ah, you mean that πŸ˜„

fallow mason
#

lol

dull copper
#

yeah, it's kinda pita to find the right thing from that list

#

just use browser search :p

fallow mason
#

no, dude. the tab crashes

#

impossible to find what you're looking for if it never gets loaded into the DOM

zenith wyvern
#

Clearly your computer isn't hard core enough to handle these docs

dull copper
#

for me it seems to load everything

#

using the scrollbar is instant

#

@naive parrot I have these on my packages/manifest.json:

    "com.unity.collections": "0.7.0-preview.2",
    "com.unity.dots.editor": "0.4.0-preview",
    "com.unity.entities": "0.8.0-preview.8",
    "com.unity.physics": "0.3.1-preview",
    "com.unity.platforms": "0.2.1-preview.8",
    "com.unity.rendering.hybrid": "0.4.0-preview.8",```
#

they are all compatible with eachothers

#

don't install perf testing package yourself

zenith wyvern
#

I have a pretty beefy PC and even for me it takes ~10 seconds before I can search for anything. Imo it's indefensibly bad but what can you do

dull copper
#

you can omit that platforms too

#

I only have it because I tested the newer one before which isn't compatible

fallow mason
#

I guess I need to load the docs on the 32 core threadripper 64 GB RAM pc I brought home from work πŸ€”

dull copper
#

I only have 12c 😦

#

64GB ram tho

fallow mason
#

honestly, it's probably my home internet speed, but pagination should be implemented regardless

naive parrot
#

@dull copper i already have Maths/Collections/Jobs/Burst in project added individually and they all work fine. but when i add entities package everything breaks. those 4 pacakges disappear from 'In Project' list , probably because they are also part of Entities dependency list , except for Burst.

#

this is clean state of project. with everything in order.

#

as soon as i add entities 0.8 or lower ,all of these dots and other packages that i have manaully installed , including PPV2 disappear

#

not sure whats going on

zenith wyvern
#

Not an ideal solution but you could just add entities to an empty project and it will automatically get whatever else it needs. The package manager is doing a truly horrible job of managing dependencies right now. I guess they are working on it.

naive parrot
#

@zenith wyvern actually did try that and apparently vscode still fails to recognize the entities namespace.

dull copper
#

@naive parrot don't have vscode open when you update

#

you need to reopen the project after adding package

naive parrot
#

@naive parrot don't have vscode open when you update
@dull copper good point. trying that now. adding entities with vscode closed

zenith wyvern
#

I don't use VSCode but usually when visual studio acts up I just delete the visual studio project files and re-open it from Unity editor

naive parrot
#

:/

#

everything is wiped. all packages gone after importing entities

dull copper
#

that's not package error

#

it's literally third party asset throwing those at you

naive parrot
#

oh i know its vegetationstuido , all those are exception due to missing DOTS packages

zenith wyvern
#

I guess Unity's API update decided to reset your packages for whatever reason. Try re-importing Entities now

dull copper
#

well, if that asset has asmdef, it's possible it just doesn't have package refs set right now

solar spire
#

the json dll one is about you having two of the same dlls in the project

naive parrot
#

I guess Unity's API update decided to reset your packages for whatever reason. Try re-importing Entities now
@zenith wyvern re import as in? it already appears in package list as installed but none of the DOTS package seem to be there now

dull copper
#

I'd focus on getting that thing working on new project first before mixing it with tons of asset store code

zenith wyvern
#

If package manager says it's installed then yeah it sounds like an ASMDEF issue like Olento said

naive parrot
#

the json dll one is about you having two of the same dlls in the project
@solar spire this is solved. i deleted old newtonsoft dll

#

these seems to be setup correctly. its in vegetationstudiopro directory

#

am i missing something?

solar spire
#

make sure you don't have any other compilation issues locking up the project

zenith wyvern
#

Not familiar with the asset. What is the very first error you're getting right now?

solar spire
#

things can be quite order dependent

naive parrot
#

make sure you don't have any other compilation issues locking up the project
@solar spire none.

#

it was all clean as i posted above. i import entities and Boom

#

all gone

#

lots of packages are gone including UGUI?!

#

not just dots as i mentioned

zenith wyvern
#

If your project is using asmdefs it's not a matter of packages being gone, you need to make sure your entire project is using proper references

#

In addition to the packages being in UPM

naive parrot
#

i dont have any custom asmdef. and the vegpro package already has asmdef properly define as i posted above.. is it missing something ?

dull copper
#

either:

  • wait for these things to mature and asset stores to catch up
  • solve these conflicts systematically by making sure you first have something that works before you add 3rd party things on it
naive parrot
#

and what about UI packages missing?

coarse turtle
#

I had a similar issue - I had to delete my package cache locally and let the project reimport - is there any error with any of the packages in the package manager?

solar spire
#

You can look in the manifest.json file to see if that's actually the case. Otherwise it'll probably be compilation order issues/assmdef links

zenith wyvern
#

If I remember right if anything in your asset folder uses an ASMDEF then everything else has to as well

naive parrot
#

either:

  • wait for these things to mature and asset stores to catch up
  • solve these conflicts systematically by making sure you first have something that works before you add 3rd party things on it
    @dull copper as i said multiple times with burst/maths/collections/jobs installed from upm all with latest version and with every other asset store package it all works fine. it compiles fine and runes fine
dull copper
#

also, occasionally just wipe your library

#

especially if you've updated unity version

#

or some major packages

naive parrot
#

I had a similar issue - I had to delete my package cache locally and let the project reimport - is there any error with any of the packages in the package manager?
@coarse turtle nope.

#

If I remember right if anything in your asset folder uses an ASMDEF then everything else has to as well
@zenith wyvern how is this not a problem till i dont add entities package ?

solar spire
#

In a project I'm working on I had to use a Collections version that was not latest, otherwise I got similar reference problems. Try 0.6.0?

zenith wyvern
#

I thought it wasn't a problem until you did the API update, which means you imported a 3rd party asset into an existing project, no?

naive parrot
#

API update pops up only after i import Entities package which is weird i know but thats what it is

#

no asset store import

#

using 2019.3.7 btw

#

i moved from 2018.4.16 to 2019.3.7 and all worked fine. compile and build were fine as well. i decide i need entities package and this happens endlessly.

zenith wyvern
#

Then all I can suggest is to start from a fresh project, install entities, then try to import your assets in modules one at a time if possible and see what's actually breaking it

#

Clearly trying to install entities in your existing project is just not helping you find the actual cause

naive parrot
#

i guess. there are 2yrs + worth of stuff in the project as of now. its going to take a while to now go around adding everything from scratch but i guess i dont have any other option

solar spire
#

first try rolling Collections back to 0.6.0, as that fixed issues in my project. (I need these packages for 2D Animation)

naive parrot
#

trying now

amber flicker
#

Is it my imagination or did this used to work?

        public class Test : SystemBase
        {
            protected override void OnUpdate()
            {
                int externalVal = 2;
                Entities
                    .ForEach(... =>
                    {
                        if (externalVal == xxx) //Do stuff
                    }).Run();
                }
            }
        }
``` - it compiles but when it executes I get `InvalidProgramException: Invalid IL code`. I'm 99% sure at some point this worked fine in JCS & SystemBase (currently on 2020b4 and latest packages).
zenith wyvern
#

Try WithoutBurst and see if you get an actual meaningful exception

coarse turtle
#

hmmm not sure if you need withoutburst

amber flicker
#

good suggestion.. trying now

#

still get invalid il code

coarse turtle
#

otherwise you could try stackallocating externalVal and pass in the pointer with WithNativeDisableUnsafePtrRestriction(T capturedValue)

amber flicker
#

trying to avoid unsafe altogether

#

might try rolling back entities version or something

zenith wyvern
#

Try disabling burst too from the menu options

amber flicker
#

yea, burst was disabled from the menu too

naive parrot
#

first try rolling Collections back to 0.6.0, as that fixed issues in my project. (I need these packages for 2D Animation)
@solar spire it worked. all errors are gone moving to 0.6.0!! although vscode cant detect entities namespace still but apparently i have entities imported into my project now without compile errors!

zenith wyvern
#

And you're sure that code is what's causing the error? Like it goes away if you comment it out?

amber flicker
#

yup

zenith wyvern
#

Weird

amber flicker
#

yea.. I feel pretty confident that this was working before.. with burst and everything

zenith wyvern
#

I don't see why it wouldn't, sounds like a bug

naive parrot
opaque ledge
#

perhaps do xxx==externalVal πŸ€”

#

if you just updates burst or some other package, restart editor

naive parrot
coarse turtle
#

@naive parrot might be the visual studio code package issue - try 1.2.0 version or 1.1.3

amber flicker
#

wait.. although I stripped my code right down and observed the difference if I commented in/out that int, it may be caused by existence of a cdfe.. investigating...

naive parrot
#

@naive parrot might be the visual studio code package issue - try 1.2.0 version or 1.1.13
@coarse turtle am on 1.2.0

coarse turtle
#

btw is this from a fresh generation of the csproj files?

naive parrot
#

i see 1.1.3 in list but not 1.1.13

#

@coarse turtle yea

coarse turtle
#

sorry 1.1.3

naive parrot
#

i cleaned all then opened again

coarse turtle
#

hmm I haven't tried with 2019.3 - Im on 2020 beta atm πŸ€”

amber flicker
#

ok I think .. cs // Invalid IL code public class Test : SystemBase { protected override void OnUpdate() { ComponentDataFromEntity<Something> someCDFE = GetComponentDataFromEntity<Something>(); int externalVal = 2; Entities .ForEach(in Entity e, ... => { var a = someCDFE[e]; if ( externalVal == xxx) //Do stuff }).Run(); } } } // Works public class Test : SystemBase { protected override void OnUpdate() { ComponentDataFromEntity<Something> someCDFE = GetComponentDataFromEntity<Something>(); //int externalVal = 2; Entities .ForEach(in Entity e, ... => { var a = someCDFE[e]; //if ( externalVal == xxx) //Do stuff }).Run(); } } } // Works public class Test : SystemBase { protected override void OnUpdate() { int externalVal = 2; Entities .ForEach(in Entity e, ... => { if ( externalVal == xxx) //Do stuff }).Run(); } } }

naive parrot
#

@coarse turtle tried with 1.1.3 , 1.1.4 and 1.2.0 , same. entities csproj files is not generated. rest all are generated all fine

coarse turtle
#

hmm I'm out of ideas πŸ€”

naive parrot
#

no problem

#

am gonna keep digging

zenith wyvern
#

@amber flicker Seems like a bug for sure. Did you try with the new SystemBase HasComponent GetComponent ?

amber flicker
#

yea - GetComponent works fine - sadly I wanted to move a chunk of code out to a static method that accesses those CDFEs so afaik I have to declare it like above?

#

Will try and make a small repro project to submit

zenith wyvern
#

Yeah for a static method you would have to pass in the CDFE

amber flicker
#

Appreciate the affirmation πŸ‘

warped trail
#

why are you using in Entity? πŸ€”

amber flicker
#

that's a good question... didn't notice I was doing it... does it actually resolve to anything different?

opaque ledge
#

perhaps it will πŸ‘€

amber flicker
#

same error sadly

opaque ledge
#

are you using 2020 ?

amber flicker
#

yea b4

#

i.e. 2020.1.0b4

opaque ledge
#

have you tried on 2019.3

low tangle
#

in = [ReadOnly]
ref = [ReadWrite]

opaque ledge
#

i was using 2020.b1 back in few weeks back and it just started to give me a weird error about one of my systems so i had to downgrade to 2019.3 and it works fine

amber flicker
#

does (Entity e) resolve differently to (ref Entity e) is what I actually meant

opaque ledge
#

perhaps you are also getting something similar

low tangle
#

yes you can't ref the entity struct

warped trail
#

without ref or in you will get item by value

low tangle
#

it should always be a copy

fallow mason
#

Curious, can you use out for [WriteOnly] a component?

low tangle
#

yes

fallow mason
#

Any performance benefit?

low tangle
#

I dont know if that made it into systembases but it does work on ComponentType.WriteOnly<T>()

amber flicker
#

given I don't need to write to Entity.. is there actually a benefit to using in rather than taking a copy though? It compiles/works fine I think?

low tangle
#

no performance benefit, it was going to be explored in the safety system for writing out from mt but dont think that ever went anywhere
its useful for annotation though, ex this system only writes to [MyPosition] not read/write

zenith wyvern
#

Using in on Entity wouldn't make a difference, it would just cause a compile error if you tried to write to entity which wouldn't make sense anyways.

fallow mason
#

Sure, yeah that's what I suspected. Thanks @low tangle

wary anchor
#

Need some advice on setting up loading sequences if I can trouble you wonderful peeps
I wish to extend my current set of loading systems to allow me to load a main menu as an alternative to the game scene. I have a couple of thoughts on how to do this initially.

  1. convert all my individual LoadXEvent IComponentData events to SingletonEntities (not necessary just cleaner for passing the data around), and include a bool or other identifier for each so I can specify whether it's loading the main menu, game, or other scene (then later in the sequence I can decide which components of my game to load depending on what the initial data specified)
    or 2) Create a single extra SingletonEntity with the data for loading and have each Loading System get those data in addition to what they do now if they need to do something different based on those data.

I'm leaning towards 2 but would appreciate external wisdom!

amber flicker
#

😦 thanks @mint iron the test I'm putting together in a new project seems to be ok too.. this is going to be painful to narrow down

low tangle
#

I treat all scene loads as requests, and process requests. then I have a totally different system that processes active requests and finalizes them deleting the inprogress when done @wary anchor

#

honestly seeing the querys usually says a lot for me so this is LoadSceneSystem:

#

the loop is roughly,
hash all loaded
hash all in progress
use a ecb to delete all requests, we will always consume all of them.
process requests, checking if they are already loaded or in progress loading. care is taken to make sure requests in progress that are created here are added (keys are all thats needed to signify existance) so we don't create two in progress loads

#

simply loop over all in progress requests, check for completion on the unity AsyncOperation, then delete that entity. emit a entity to signify if desired. and create a loaded entity to signify existence as well.

wary anchor
#

mm I'm more talking about running through a sequence of systems which all run in a specific order to read/prepare data after unity scene load (I'm actually only using 1 scene at the moment but that's not really relevant). The only differences I'll need between loading the data I need for the menu vs the game will be for later systems like creating the player, generating AI actors and calculating spawn positions, so I'm thinking that in those systems specifically I can include a read step for the singletonentity component data... or... hmm actually you made me think I don't need any data in there at all I could just query for an additional component and only run those systems when needed that way

low tangle
#

it would be better to encode the data as entitys with components themselfs directly

#

instead of enums on components

wary anchor
#

yeah I've not currently used any singletonentities at all and I was kinda hoping to avoid having to resort to them πŸ˜„

#

that's a great point and would be much cleaner, thanks @low tangle

low tangle
#

pretty short section though

#

for something similar, I have a postprocess request that runs on scenes after finishing loading

#

its consumed in a system that checks for that scene being loaded or not (hash)

wary anchor
#

I'm using messaging currently to kick things off so I can sync up those pesky remaining monobehaviours (ie cam and when I get there, audio) and start the various loading events when I know the game is ready for them

low tangle
#

then when it is, it does all of the post processing there. I've learned over time that those kinds of transformations should be done in as few steps as possible. when I was first starting out I was thinking of keeping them as separate as possible but that needed up creating a messy chain of coupling that simply is not needed if you do the whole operation up front.

#

trying to apply DRY to systems too hard isn't always the best idea

north bay
#

@low tangle What is the book called?

wary anchor
#

so you end up with a massive loading system, but at least it's not a big chain of interdependent systems right?

low tangle
#

sometimes you need to do a bit more in your system to save yourself from interconnecting too much on one archtype. but then again this might just be a side product of the initial design of that entity / logic as it was very mutation heavy instead of disconnected reference components

#

actually the loading system is done pretty much perfect minus the post processing stage needing just refactored from much earlier entites

#

highly suggest paying for the book if you can, as there isn't much good stuff out there thats dod

north bay
#

Thanks i'm in need of someone telling me what im doing wrong lol

low tangle
#

I keep getting great books recommended only to crack them open and being fed OOP and gang of four

#

it helps shift the mindset, that book

#

almost every single pattern in that book can be translated to unity's ecs framework

#

its very powerful when done and highly worth the investment

warped trail
#

this is the difference between in Entity e and Entity e btwπŸ˜… ```cs
OriginalLambdaBody(runtimes.runtime_e.For(i));// Entity e

this.OriginalLambdaBody(ref runtimes.runtime_e.For(i));//in Entity e```

low tangle
#

this boi is very useful for the new systembase's

#

I had to debug a lot of shit blind because I didn't even think to look for this

#

burst doesn't do ternary statements yet btw

mint iron
#

One thing i tried to allow for levels to have a period of preloading prior to actually being ready, was to throw up an entity tag indicating the level had been loaded; then systems that were responsible for doing things are triggered, and may produce their own response 'Hey im a dependency, wait for me to say im finished". Whatever system is responsible for giving the final say on level being ready just waits for any dependencies to have said they're resolved.

amber flicker
#

For anyone curious about my invalid il code issue.. I can't come to any sensible conclusions.. I can reliably comment in/out different parts to generate the error but every time I think I've found the cause (simultaneous CDFE & external var or most recently, brackets around the foreach), they turn out not to be an issue in a clean system or at playtime. The error I receive is not at compile or play-time, it's when an entitiy in a subscene is converted and the system runs in editor. There's something fragile about the il code gen timings I suspect but I don't think I can easily narrow it down.

low tangle
#

have you messed with this v

amber flicker
#

I've opened it... seen how much code I have and then cried

naive parrot
#

can we have multiple components and systems declared in single script ? or is it restricted to one per file like Monobehaviors ?

low tangle
#

multiple

#

do it

zenith wyvern
#

[GenerateAuthoringComponent] Only works for a single component, other than that there's no limit

naive parrot
#

cool! thanks

#

[GenerateAuthoringComponent] Only works for a single component, other than that there's no limit
@zenith wyvern yea i read that

wary anchor
#

every time I come here with a question, it sparks a 2 week refactor session to deal with all my previous misdemeanours

low tangle
#

very great for prototyping a new bundle of logic. define all your data types up top, comment them
then start commenting out your logic for systems below them, then go ahead and start converting your comments to systems as you go.

#

hah yeah, but that just means your getting better and learning

wary anchor
#

On the one hand, YAY! On the other hand ohhhhhh boy I'm slow at getting this game done πŸ˜„

low tangle
#

yeah eventually you have to cost analysis your time and decide if the amount of time dealing with the shit code will be less than the amount to refactor it into 'better' code. and that all vrs deadlines

#

most of the time I try to stick by 'dont live with broken windows' if your apartment windows were broken, you could live with it for awhile, but you wouldn't like it.

#

broken code and broken windows go hand in hand

wary anchor
#

well that's where I'm bad, because I'm doing this full time for myself, supported by my awesome mrs while I do. So I do need to be a bit more ruthless and really focus on getting it done

low tangle
#

exactly, you said it, get it done

wary anchor
#

to be fair, it's actually working pretty well, I'm just not 100% sure on extending it, but I think adding different components as signals for which systems need to run is as clean a way as I'll get in the current setup

#

and as it's all loading only, even if it's not the most efficient way, it'll still be way faster than I really need

low tangle
#

designing for the future too heavily is very foolish, overbuild it but not too much. there are design requirements you can't know and you will just have to replace it. thankfully refactoring systems and data is very easy

#

premature optimization while on top of a very fast framework (dots) is foolish x2

#

you might end up fast in cpu cycles but you pay for them with human cycles

wary anchor
#

heh, and my game is nowhere near CPU bottleneck because the raymarching is so much more intensive

low tangle
junior fjord
#

I have some nativearrays that I only populate once at the beginning and never touch again. is there a way to make them globally read only, so I can pass them into my Entity lambdas without capturing and specifying them as read only in every single system?

low tangle
#

don't think so but thats a good suggestion though. what you could do is convert them to a blob asset which is immutable and can be passed by blobassetrefs inside of components even (and to get the data)

mint iron
#

You can put a static wrapper around a SharedStatic and then you could just use it without capturing or passing anything into your jobs.

low tangle
#

oh yeah sharedstatic is new

#

can't find a page on it

#

burst maybe?

low tangle
#

oh thank you, I was about two scrolls up from that :P

junior fjord
#

ok thanks, I think that got recommended to me once before here actually and I forgot

#

hmm ok I don't really understand what that shared static is. <T> would be a nativearray in my case?

scarlet inlet
#

I still didn't manage to make SharedStatic work

#

Don't know if you have noticed, but on google if you shared SharedStatic you get 2 or 3 exampels and one is from @mint iron πŸ˜„

#

I got to a point where soon I will need special tools to see if code can be optimized to cache related issues. I am thinking of Vtune

junior fjord
#

your usecase is pretty similar to what I need actually

#

just found your forum monologue πŸ˜„

scarlet inlet
#

@junior fjord thank you for giving me your support. I don't feel stupid at least πŸ˜„

mint iron
#

seb's situation was a little trickier, ill try to put a working test together πŸ˜„

scarlet inlet
#

I cannot think of many other cases where SharedStatic could be relevant

#

@mint iron I will need to make that work eventually. In reality I was wrong, because the hashcode solution may result in collisions, my code potentially may not work

junior fjord
#

another question actually, what is better design: There are multiple things that can change the color of a tile (tile type changes, water is now on tile).
All of these emit event entities, for example TileTypeChangeEvent, CreateWaterEntityCommand
These events are already used by the systems that change the simulation logic (create simulated water etc.)

But I also have a system that will actually recalculate the mesh and set new colors to the vertexes, RecalculateVertexColorsSystem. What is better
(A) The systems that do something that could trigger a tile color change also create a TileColorChange command (either by adding a component to the command entity already existing or a new entity)
(B) RecalculateVertexColors is aware of the events that can change the tile color and also "jumps" onto them (it also checks the CreateWaterEntity command etc.)

#

so all in all, should the simulation logic know about the UI and create events for the UI or should the UI understand the simulation logic and know which event should trigger what?

mint iron
#

could have just stored the pointer... depends if you wanted to use functionality from the UnsafeList.

zenith wyvern
#

I have some nativearrays that I only populate once at the beginning and never touch again. is there a way to make them globally read only, so I can pass them into my Entity lambdas without capturing and specifying them as read only in every single system?
@junior fjord

You can use managed arrays inside jobs/burst as long as they're created as readonly

junior fjord
#

somehow at the moment it even works without defining it as readonly

#

I call a function Globals.GetNeighborOf(TileID id, int nNeighbor) which reads from Globals.neighborTileIDs and unity does not complain

#

somehow I was sure this would get me in trouble since I have to define Globals.neighborTileIDs as readonly somewhere but πŸ€·β€β™‚οΈ

#

and about the SharedStatic, I somehow don't understand how that is relevant here

zenith wyvern
#

If it does work now I would expect it won't in the future. The burst docs specifically say you need to define managed arrays as readonly to use them inside burst

junior fjord
#

I think I don't understand what it does at all πŸ˜„

scarlet inlet
#

Burst doesn't support Volatile.Read apparently, what's the alternative?

mint iron
#

is there a way to make them globally read only, so I can pass them into my Entity lambdas without capturing and specifying them as read only in every single system?
maybe i've missunderstood the question, but with the SharedStatic example i posted, once you've loaded your read only data into it you would be able to access it globally, including within jobs without setting up anything in your systems/jobs.

junior fjord
#

no you are right, thanks. I just think I have a hard time understanding the boilerplate code around it.
SharedStatic<Type> is a basically a static variable of Type T? What does this GetOrCreate<Class1, Class2> do?

#

like what kind of data structure is this?

zenith wyvern
#

If your data isn't changing at runtime you don't need SharedStatic

#

You can just use readonly arrays

junior fjord
#

but I also have NativeArrays that change

#

at the moment I just capture all of them each time and pass them in with WithReadOnly or DisableParallel... if I know that I am only writing to different locations

#

but I don't understand how SharedStatic works now and how it makes it possible to write to data from jobs? what is with two threads trying to write to the same location?

#

or is it basically that I have to check for that not to happen myself and burst just assumes DisableParallelForRestrictions for me?

opaque ledge
#

There is no safety thread check when it comes to shared static

junior fjord
#

so using a sharedstatic array and writing to it would be the same as using a nativearray and DisableParallelForRestrictions, just that I have the boilerplate when creating the sharedstatic and not in every system?

#

Do I understand that right?

opaque ledge
#
public abstract class Shared_FleetMaster
{
  public static readonly SharedStatic<NativeHashMap<int, EncounterShip>> encounterShips = SharedStatic<NativeHashMap<int, EncounterShip>>.GetOrCreate<Shared_FleetMaster, EncounterShipKey>();

  private class EncounterShipKey { }
}
#

This is basically what Shared Static looks like

#

just copy paste and put your own generics, which is NativeHashMap<int, EncounterShip> in my case

junior fjord
#

yeah I am trying to understand what GetOrCreate<Shared_FleetMaster, EncounterShipKey>(); does

#

and thans a lot

#

I will use that template

mint iron
#

normally everything that is used in a job must be passed into it, either exiplicitly with IJobChunk or a captured local for the new Entities.ForEach/Job.WithCode. Aside from static methods, SharedStatic is the only way to use stuff without passing it in.

junior fjord
#

ok thanks

#

I do wonder why it works for me right now for some of the nativearrays but hmm

#

maybe not rely on it

#

ok so in the source code of SharedStatic.GetOrCreate<T1, T2>();, T1 and T2 are hashed and the 128 bit resulting hash is passed to the burst allocator

#

but why? what does the burst allocator need the hash for? And isn't there some easier way to pass in a hash then having me to create two classes? I have 0 understanding what is happening here πŸ˜„

opaque ledge
#

does it really matter ? you just put it into it and it works πŸ˜„

mint iron
#

for whatever reason, they wanted to keep the memory used by burst separated form the rest. In earlier versions you used to be able to do all sorts of cheeky things like using Malloc in a static constructor. But for whatever reason they decided that wasn't a good idea and disallowed it. SharedStatic was the solution to replace it. As for the hash. I'm guessing its indexed so the burst side can find the memory address.

junior fjord
#

@mint iron but at which point does it need to refind the memory address? As I now understand it SharedStatic is basically a read-only pointer which I can use which is nice. And when creating it for allocation I pass in two classes which are hashed to find a memory location? Why does that memory location have to be deterministic? Why not just some normal malloc analogue in C#?

#

I mean the pointer will now be safed in the SharedStatic anyway, I won't need to re-find the same memory location later based on the Class-Hashes or do I?

#

@opaque ledge haha yeah that is a way more productive way of seeing things πŸ˜„

#

I always get caught up in the details but as long as its interesting its ok

#

Ok and the above question basically boils down to why the method is GetOrCreate instead of Create? Why should I call that thing from multiple places

opaque ledge
#

i think it just.. when data first requested behind the scenes Unity checks if that data is actually created in first place, if its created then it simply returns it, if its not created then it allocates/creates and returns it.

#

i also have no idea what i am talking about, but it makes sense if this is the case.

mint iron
#

yeah most of the examples show it being stored as a field, but you can call the whole thing again anywhere after its created to get it again.

junior fjord
#

yes, if the thing was already allocated it will return a pointer to the same space again

#

so it will just get it not create it

#

but when is that necessary? Is there an obvious usecase?

#

I think you could even reinterpret it as a different type

#

since the actual type that you are storing is not hashed

mint iron
#

yeah im not sure, makes sense to just store/wrap it after creation, at least its not a super long thing to type out then.

junior fjord
#

ok good thanks for all the explanations

mint iron
#

np πŸ™‚

junior fjord
#

just odd that they have all the boilerplate to have this getter method

#

it seems that if if the method would be only Create, it would be way simpler πŸ˜„

#

and not these boilerplate classes

loud matrix
#

God this is a weird one, Basic component system for translation when the throttle key has an axis of > or < 0 and then adds or removes 10 * deltatime from its z translation.
But for some reason every 100 units the entity moves, its staggers a teeny bit.

#

Why must the complex part of DOTs seem to work but the simple things do weird stuff like this

#
public class MoverSystem : ComponentSystem
{
    protected override void OnUpdate()
    {
        Entities.ForEach((ref Translation translation) =>
        {
            if (Input.GetAxis("Throttle") > 0)
            {
                translation.Value.z += 10 * Time.DeltaTime;
            }
            else if (Input.GetAxis("Throttle") < 0)
            {
                translation.Value.z -= 10 * Time.DeltaTime;
            }
        });
    }
}

Am I being blind here?

opaque ledge
#

is TΔ°me.DeltaTime from UnityEngine or Unity.Entities ?

amber flicker
#

what happens if you cache delta time outside the foreach?

opaque ledge
#

This is run with Run i think, so shouldnt matter

loud matrix
#

I ... honestly have no idea, I viewed its definition and it loaded the entities definition of time, which makes sense as the abstract component system unity.entities has a Time reference

opaque ledge
#

well i never encountered this issue, but maybe something about float percision

amber flicker
#

yea you're right @opaque ledge - it looks ok - there's nothing going on right? like a moving camera or something?

loud matrix
#

I just tested it and it does seem to be an issue with the time as no matter the speed after 1s ish it staggers, though hard to see, I'm trying to debug the time with a screen record to see what the real values are

#

Nope, literally just 1 cube that's a static reference object on screen. another I'm using ECS to make and move

opaque ledge
#

just do Debug.Log

loud matrix
#

I tried that but it doesn;t log fast enough

amber flicker
#

vsync enabled? if you're frame rate is varying wildly, that might be what you're seeing?

loud matrix
#

Either that or my screen record set to 500 FPS can't capture it fast enough

#

You may be onto something there, i never noticed but the FPs is dropping to half during the stagger

#

Huh, that was it, weird. It never happened with the monobehaviour version of exactly the same thing

opaque ledge
#

use SystemBase instead of ComponentSystem, Component system is old and offers no parallelism, it runs on main thread and it does allocation, perhaps that allocation causes the stagger

loud matrix
#

Not heard of SystemBase before, I'll have a look at the docs.

opaque ledge
#

i mean i just look at the manual and ComponentSystem isnt there anymore, only SystemBase, make sure to look at the latest version which is 0.8

stone osprey
#

Whats the newest "Entities" version ? I only see a 0.0.? version inside my package manager...

wary anchor
#

0.8.0

stone osprey
#

Is there to get that version running in Unity 2019.3 ? Looks like 2019 only has that old version in the package manager

opaque ledge
#

i do πŸ€”

#

i think your package manager might be bugged

#

if it doesnt show 0.8

stone osprey
#

Hmmm... thanks @opaque ledge πŸ™‚ probably a restart helps

obtuse swallow
#

Do jobs cost a lot to create? Is it ok to do a job on entities, and each execution might spawn more jobs?

opaque ledge
#

you cant create jobs inside jobs, and yes it does take a little bit overhead but probably its worth it for most cases

#

if you are sure that there is only 1 entity in your query for such as camera movement or player movement you should do Run, but otherwise do Schedule or ScheduleParallel

obtuse swallow
#

OK, thanks!

amber flicker
#

hmm with SystemBase is there a way to either Run or ScheduleParallel the job based on how many entities it will iterate over? Every Entities.ForEach statement needs to end with a .Schedule(), .ScheduleParallel() or .Run() invocation.

coarse turtle
#

not natively in the lambda

warped trail
#

.WithStoreEntityQueryInField(ref m_Group) ?

amber flicker
#

would that help @warped trail ? Wouldn't it still need to end with run or schedule etc

warped trail
#

you can calculate amount of Entitites in that query

coarse turtle
#

ah - true with CalculateEntityCount()

#

or something like that πŸ€”

warped trail
#

if(count ) run foreach

#

else don't do anything

junior fjord
#

the compiler sees the WithStoreEntityQueryInField and stores it in the field for you before the foreach is run, so you can use it before

amber flicker
#

hmm.. getting the count isn't the problem though.. it's that you have to end a lambda in some kind of run? Unless I'm missing something

warped trail
#
var count = m_Group.CalculateEntityCount();
if(count > 1)
{
  Entities.ForEach().Run()
}```
amber flicker
#

I need var count = m_Group.CalculateEntityCount(); if(count < 1000) { Entities.ForEach().Run() } else { Entities.ForEach().ScheduleParallel() } without duplicating the code ideally

warped trail
#

you can use some struct πŸ˜…

amber flicker
#

hmm yea I suppose that's true

warped trail
#
struct MyData
{
    float DeltaTime;
 
    public void Execute(ref Position position)
    {
        position += new float3(0, DeltaTime, 0);
    }
}
 
// Create data struct, it will be captured by the lambda method automatically
var data = new MyData { DeltaTime = Time.Value };
Entities.ForEach(ref Position pos)
{
    data.Execute(ref pos);  
}.Schedule();```
amber flicker
#

So... I have a lot of systems... most of them have more overhead than they need when they're just a few entities - so I was thinking I should just run instead for low numbers. This must be a common issue - something that ideally Unitys scheduler could automatically detect at some point? Or am I doing silly things.

warped trail
#

Has anybody benchmarked this overhead ?πŸ€”

zenith wyvern
#

I think @mint iron has said he found below 5k entities it was MUCH faster to just .Run if your job is sufficiently simple

#

There's variance there depending on how many chunks you're iterating of course

warped trail
#

but is it really worth it to block main thread and not just schedule()?πŸ€”

dull copper
#

hmmm, I'm getting quite a boost in scene brightness with hybrid renderer v2 on HDRP when I press play on editor

opaque ledge
#

is movement considered simple ?

zenith wyvern
#

A single addition seems pretty simple to me. I have to imagine there are more meaningful optimizations you could do rather than trying to micro manage the scheduler though. Like Druid said you have to consider that you're blocking the main thread too.

vagrant surge
#

not in unity, but i can 100% confirm that if you have entity counts in the hundreds or less, and they are "simple" iterations, like just some basic logic, no raycast/physicsqueries/etc, then it will be faster to not multithread

amber flicker
#

yea I think I need to properly profile the difference under different conditions to see if it's even worth it... a quick test now showed some very variable results (.Run avg 0.03-0.04ms, .ScheduleParallel() 0.03 - 0.13ms) but consider those numbers pretty meaningless - not a proper test

opaque ledge
#

from Schedule or ScheduleParallel perspective, is 1 entity with high calculation is considered same with 1k entity with low calculation ?

vagrant surge
#

no

#

Schedule or ScheduleParallel will both be on 1 core, because there is 1 chunk to calc

#

vs 1000 entities where there might be a few chunks

#

but normal entity counts on the 16k chunks is from 50 to 500

#

on a "normal game" entities

#

so 1000 entities, at 200 or so per chunk, is 5 chunks, and thats more overhead than its worth it

#

personally (on cpp) i was only starting to see gains on counts 10.000 and up

zenith wyvern
#

But again, even if the work takes longer if you schedule it, you may not want it running on the main thread anyways. Scheduling a million different jobs just sounds like bad design, so trying to micromanage the scheduling sounds like premature optimization

#

But I guess it depends on what you're doing and what profiling tells you

vagrant surge
#

yes. its a flaw with the way unity job system works

#

the main flaw is that you have a main thread launching jobs

#

in systems like the one in some AAA engines like the doom one, the jobs can ALSO launch more jobs

#

so the "launching overheads" are a bit more spread over all threads, and its not bottlenecking so much on main

#

doom eternal is an absolute masterpiece at this

zenith wyvern
#

I don't know if it's a flaw, they made it that way to protect people who are new to multithreading

vagrant surge
#

you can see it using almost exactly the same % cpu power on all cores you have

#

@zenith wyvern its just one possible way of doing it. By centralizing it like that, you can simplify a ton of stuff massively

#

and that lets you spend the "complexity budget" on fun things like automated task dependency resolution

zenith wyvern
#

I'm pretty new to it myself but at least from what I read it sounds like being able to schedule jobs from jobs would make it really really easy to shoot yourself in the foot if you don't know what you're doing

vagrant surge
#

yes

#

its indeed a thing

#

jobs from jobs is pretty swee tho. For example one job with multiple parts

#

first part calculates how many of X to do, then the job itself launches multiple jobs to execute the workload

zenith wyvern
#

That does sound pretty sweet

vagrant surge
#

it also lets you run "unrelated" subsystems in parallel

#

for example lets say you have a bunch of physics systems on one side

#

and rendering systems on other

#

by splitting the thread in 2, you reach better parallelism as it bottlenecks a bit less on the main thread

#

they explain that sort of thing in a naughty dog presentation

#

they have like 2 "braids" , game thread and render thread, each of them spams jobs, which spams more jobs

#

they run them overlapped to increase cpu utilization

#

reached like 90%+ use on ps4

opaque ledge
#

Doom eternal doesnt look like a game that needs multi threading πŸ€”

vagrant surge
#

it does. Singlethreaded games cant do shit on consoles

#

console cpus are just that bad

#

doom eternal has to manage all the rendering + all the enemy AI and animation, it does more than what it looks like

#

unreal engine would have trouble running a game like doom eternal

amber flicker
#

frustratingly total for all my systems in sumulation group add up to 0.4ms for 1 entity yet still 0.4ms for hundreds... build attached to editor 😩

mint iron
#

don't look at the new sub-scene, physics or rendering system timings then 🀣

#

my compile times are out of control right now too, my notebook is a little slow, but its almost get up and go and get a coffee level whenever i save in visual studio.

warped trail
#

but system execution time is not the full picture, isn't it?πŸ€”

mint iron
#

im not entirely clear on that point... what exactly does the EntityDebugger timing cover.... i assume it includes any jobs launched from those systems?

warped trail
#

i don't think soπŸ€”

zenith wyvern
#

I don't really pay attention to the system ms, I only look at the jobs in the timeline and the hierarchy

amber flicker
#

Same

#

Total time when you select a job is v useful

safe lintel
#

i think it does(edit debugger system includes spawned job time ms)

#

would be kinda useless without it

opaque ledge
#

hiearchy can be pretty inaccurate tho, because it can show some system is done .n 0.1 ms but in reality its in some other job's WaitForJobID group where its like 6m, thats what happened to me, and for weird reason in entity debugger a job's time is added to next command buffer's time, so system shows 0.06 seconds in entity debugger but the real time is actually added to command buffer's time which shows (lets say) 5 ms

#

so, imo, timeline is the most accurate

zenith wyvern
#

Yes Timeline gives a great overall view of what you should actually be focusing on

mint iron
#

thats a good point, you have to consider ECB time which shoes up in the begin/end group, and if the ECB is high you have no idea which system is causing it

dull copper
zenith wyvern
#

I usually only go to hierarchy when I need to deep profile to drill down to what actual function is the bottleneck

dull copper
#

(banding is from gif compression)

zenith wyvern
#

Too bad that looks kinda cool, hahah

dull copper
#

heh

#

it just looks like total exposure changes when I hit play

warped trail
#

are you using those fancy new material components?

dull copper
#

same happens with all meshes that are converted

#

nah, just using conversion

safe lintel
#

ok so wild theory: is there another light being duplicated and set hidden?

#

cos i have that with a camera due to whatever subscene stuff goes on(ie i have to search all cameras and disable a hidden companion one in the latest entities update)

dull copper
#

I dunno, I tried to convert the light and it ended up double bright after that πŸ˜„

#

wonder if this even works properly outside dots subscene

#

if I convert these, there's just one light on entity debugger

#

none on the GO side

safe lintel
#

but without any specific conversion, it might be that theres something going on behind the scenes

zenith wyvern
#

I know the hybrid renderer is supposed to be able to convert lights into hidden gameobjects using the HybridComponent thing. It was broken last time I tried it

dull copper
#

it seems to work in a way that they do move on entity side

safe lintel
#

yeah, my tinfoil theory is that this is it πŸ™‚

dull copper
#

camera still renders etc

safe lintel
#

just do a finallobjectsoftype with lights and see if theres a tricksy hidden one

zenith wyvern
#

Kinda dumb but you could create a script to change all gamebjects hideflags to reveal them

dull copper
#

hmmmm

#

if I move these to subscene, it doesn't change the brightness anymore after hitting play

#

but it does make the exposure go immediately off the moment I moved these to subscene

zenith wyvern
#

After you close the subscene for editing?

dull copper
#

the moment I move light from regular scene to dots subscene

zenith wyvern
#

Yeah no conversion should happen until you actually close the subscene

#

It's weird that it would change just from that

dull copper
#

I could adjust the exposure to match the new setup but I'd need to retune everything, including the sky exposure

warped trail
#

when you keep subscene open it constantly convert thingsπŸ€”

zenith wyvern
#

Oh right I guess that's what livelink is

dull copper
#

anyway, this feels like a bug they haven't caught for whatever reason

#

I need to lower the light intensity from 10k to 1k to get matching exposure on ground

zenith wyvern
#

I'm sure proper docs and examples for subscene usage are coming....any day now....

dull copper
#

well, I'd really want to... not use subscenes at all

#

they pain me if you remember my rants

safe lintel
#

can you satisfy my curiosity and just add a script that debugs this with the light not in a subscene?

        var lights = FindObjectsOfType<Light>();
        Debug.Log(lights.Length);
zenith wyvern
#

From what Topher said it sounds like they are desperate to get rid of ConvertToEntity entirely and force us to only use Subscenes

opaque ledge
#

We should uprise to their tyranny πŸ‘€

mint iron
#

they really do need to polish it up a bit though; maybe some of the support isn't ported to 2019.3 cause it seems a bit jerry-rigged.

dull copper
#

I wouldn't mind dots subscenes if they just made everything compatible

zenith wyvern
#

Hahah, I wouldn't expect them to force it until subscenes are actually like...usable and you know, actually documented.

dull copper
#

which I'm sure they eventually will

#

I'm totally expecting the default scene to be dots subscene at some point

opaque ledge
#

what exactly is a subscene anyway, like.. dots scene so to speak ?

dull copper
#

@safe lintel outputs 1 when light not in dots subscene

#

outputs 0 when light in dots subscene

safe lintel
#

doh ok πŸ˜„

#

tinfoil theory shattered

dull copper
#

also entity debugger doesn't show any lights unless I specifically convert it there

#

but it could still be some silly HDRP bug for hybrid

#

I wiped all cache too

#

so it's not some left over thing

zenith wyvern
#

From what I understand subscenes are just a way to "preload" conversion so you're not forced to do it at runtime/when you hit play @opaque ledge

opaque ledge
#

πŸ‘

mint iron
#

0lento is the hero we need, all beta testing the git source.

dull copper
#

tbh my current issue could be related to being on too bleeding edge, I'm testing this on githubs hdrp/staging

#

so there could be some new change that caused this issue

#

also tried with and without this: https://github.com/Unity-Technologies/Graphics/pull/10 but it's not really supposed to even affect this because it's only changing shader graphs and my issue happens on regular HD Lit shader

#

(which is supposed to be supported by hybrid renderer v2)

#

there isn't any official 9.0 release yet so can't really pick "right" version even

mint iron
#

hopefully we'll get a package in the next couple weeks!

dull copper
#

should get new dots packages too

#

spotted kinematica preview also now on unity's packages registry

#

I think they said on the roadmap talk that they are developing dots compatible version of it but right now it's for the old system

#

(few weeks old news already)

naive parrot
#

are systems that are set to update in a custom ComponentSystemGroup are auto added to the list of that ComponentSystemGroup and updated or is there an override procedure?

dull copper
#

this isn't that hard to believe as it matches what I've seen (lowering light intensity makes it closer to what I'd expect)

safe lintel
#

There was a new package updatefor animation just a few days ago but without an update to the samples its almost not worth mentioning πŸ˜‰

naive parrot
#

does creating a ComponenSystemGroup auto creates and adds all of its subscribed/child Systems to targget World?

mint iron
#

yes

naive parrot
#

ok thanks

charred elk
#

Guys how can I apply transform to a entity?

opaque ledge
#

do you mean, how can you move an entity ?

charred elk
#

.ForEach((ref Transform transform, ref PhysicsVelocity velocity, ref CharacterControllerData data) => {
I've done this, but i can't use Transform.Translate

opaque ledge
#

Transform is a class so its a managed object, if thats what you intend you have to run it with WithoutBurst().Run(), but entity version of class Transform is seperated to 3 componenets, Translation, Rotation, Scale/UniformScale

warped trail
#

forget about Transform when you working with entities πŸ˜…

opaque ledge
#

So you have to do Translation instead of Transform

charred elk
#

So I have to calculate the new transform values and then apply them to the entity?

warped trail
#

entities don't have transform, they have translation, rotation and scale components

#

if you are working with PhysicsVelocity then you have to change velocity, not positionπŸ€”

junior fjord
#

would you say this is good practive:
Have some global arrays (Water, Humidity) in shared static and have tag Components like WaterAccess, HumidityAccess, that I just pass in as read or write if I am reading or writing to the corresponding arrays?

#

then unity does all the automatic scheduling of the jobs not running in parallel for me and all I have to check is that if I am writing to an array in one system, I don't write to the same location simultaneously

#

is this a good idea or am I overseeing something?

vagrant surge
#

job system can protect the access to those global arrays

#

, no need to have the tag components

junior fjord
#

but this way seems easier to me

#

I have no manual dependency handling at all

opaque ledge
#

why you dont simply create singleton buffer/components for global acess ?

#

i dont think Shared Statics should be used in a way like that, plus there could be a performance issues(not sure)

#

you can do GetSingletenEntity<Water> and send it to GetBufferFromEntity<Water>(entity) in OnUpdate to get the buffer, and then simply do ForEach.WithAll<WaterAccess>..

#

same goes for Humidity

junior fjord
#

in which way should shared statics be used? But yeah the buffer would also make dependency handling automatic, thanks for the idea

#

but on the performance side I think there should be less of an issue with a sharedstatic then always getting the buffer or not?

sour ravine
#

what is going to be slower

junior fjord
#

but I don't need the WithAll<WaterAccess> in your case do I?

opaque ledge
#

Tbh, i am not sure, its quite a handy tool, i mainly use for Random struct and for prefabs. Would make sense to use it for global/singleton stuff as well, but i think its specifically designed for communication between ECS and MB

sour ravine
#

WithAll is mostly for tag components

#

meaning not something you will declare in the lambda parameter list, but optionally need or want to filter chunks with

junior fjord
#

yes, that is how I am using it currently

opaque ledge
#

Well.. yeah if you can make sure the entities you are processing has 'access(as in game mechanic)' to Water singleton buffer

junior fjord
#

to let unity handle that I do not access the same shared static from two systems in parallel

sour ravine
#

statics are in general a bad idea

opaque ledge
#

Unity cant handle that

junior fjord
#

@opaque ledge yeah that is done by them having a TileID component, the WaterAccess was just a tag for accessing the waterarray specifically

opaque ledge
#

i meant to say you should create a singleton buffer instead of shared static

sour ravine
#

singleton entities are a better fit for 'one per world' data which is in almost every case what people really want

#

see subscenes, IConvertXXX

viral kindle
#

@dull copper // I see they are also making something with nodes in their new aniamtion system

junior fjord
#

because of the dependcy handling?

viral kindle
#

I'm actually quite interested in what they will do with ECS and Visual Scripting

sour ravine
#

static read/write data is a leaky abstraction in any OO language

junior fjord
#

i meant to say you should create a singleton buffer instead of shared static
@opaque ledge yes I understand that thanks, it does seem like a better idea

vagrant surge
#

i still dont understand why singleton entities arent native and with special rules

#

they are just so useful for storing system data

junior fjord
#

so what I could do is:

public static class Globals{
    public static Entity data;
}

OnUpdate(){
    var waterArray = GetBufferFromEntity<Water>(Globals.data);
    var humiditiesArray = GetBufferFromEntity<Humidity>(Globals.data);
    Entities.Foreach(){
        //use humidities and water
    }
}

@opaque ledge @sour ravine

#

is that what you are recommending?

sour ravine
#

static read/write entities are a bug

junior fjord
#

yeah I mean you can also do GetSingleToneEntity<GlobalData> if you want

#

but asides from that

sour ravine
#

there is an actual method called GetSingletonEntity<T>()/GetSingleton<T>() on EntityManager ComponentSystem and friends

junior fjord
#

ah really?

opaque ledge
#

Just make a single entity and throw Water and Humidty in it, and thats it

junior fjord
#

ah ok good that changes things, I thought this is just about personal taste πŸ˜„

opaque ledge
#

afaik those methods doesnt exist on EntityManager, they only exist on SystemBase and EntityQuery

sour ravine
#

yeah my b, it's early morning for me

#

fixed

#

anyway-- you can set up that entity when you bootstrap your World

opaque ledge
#

That, or just make a MB that creates the entity and adds stuff

sour ravine
#

also makes authoring a lot easier

#

yep, also valid

junior fjord
#

Ok, so I would make a tag component
struct Globals : IComponentData {}, then create one single entity with that component, add buffers for the different global arrays I want to it and then do GetSingletonEntity<Globals> in my system to get that entity?

sour ravine
#

SetSingleton<T>() can help with that, but you don't need the tag component here if you just want that data

opaque ledge
#

yep basically, then you have to do GetBufferFromEntity<Water>(globalEntity) to get the buffer, you also dont have to use Globals if you are sure there is only 1 Water buffer in the world

junior fjord
#

what do you mean by I don't have to use globals?

#

I thought this is basically my way of having a world-global?

#

but thanks a lot for all the help

sour ravine
#

struct Globals : IComponentData {} by itself isn't going to do much unless you actually are filtering on the presence of a Globals component on an entity archetype

opaque ledge
#

So.. singleton buffer/component means that there is only 1 of that type in the world, so if you put Water buffer to an entity, and only to a single entity, that means Water buffer is a singleton

scarlet inlet
#

Hello, surprise pop up question of the day: how many entities can UECS build before it gets noticeable? is it in the order of hundreds/thousands/hundred of thousands? Is there a way to build 1 Million of entities ? I think the only way is to build them over the frames (streaming)?

sour ravine
#

disregard if you're putting actual data in it

junior fjord
#

is there any reason to do either
(1) One SingleTon<Globals> entity with all the dynamic buffers or
(2) One SingleTon<T> entity for each entity with a buffer similar to T, e.g. Singleton<WaterSingleton> entity for a entity with dynamicbuffer Water?

opaque ledge
#

both is valid, but i prefer to go with 1

sour ravine
#

2 is more idiomatic to DOTS, further complicating πŸ™‚

#

that's what the Singleton<> APIs are built around-- but in theory I think you can actually assign them all the same entity

opaque ledge
#

i think its not about how many entities are there πŸ€” its about how frequently change if you are curious about performance

#

i believe Sark mentioned that in his roguelike project, adding/removing a thousand component every frame starts to make noticable lag

sour ravine
#

more or less. The split component approach offers some more granularity

#

for dependency management, etc.

#

hence comment about it being more idiomatic

junior fjord
#

GetSingleton<T>() has no parameters for isreadonly in the docs

#

how would I now specify that I only want to read that buffer?

sour ravine
#

it copies the data

#

returining the component data

warped trail
#

@junior fjord through EntityQuery

sour ravine
#

you actually would be doing it in the System potentially as well

opaque ledge
#

yeah, i think its read only if you do that

#

if you want to change it i guess you have to do GetSingletonEntity first and get the value from CDFE

sour ravine
#

you can also run an Entities.ForEach() directly as well

#

since it's still a regular entity with a regular component

junior fjord
#

ok I think I need to search for some simple working example where someone uses it for reading and writing to a some world-global array

warped trail
#

@junior fjord and you can have 1 Singlton entity with a lot of components, each component will be considered singlton

sour ravine
#

^

opaque ledge
#
            var singletonEntity = GetSingletonEntity<GlobalEventTag>();
            var masterComparision = GetBufferFromEntity<MarketComparissionBuffer>(true);

This is what i do to update my market comparisions

sour ravine
#

yeah do want to stress in all cases you're still dealing with a regular entity

#

so all the same approaches would apply

#

though

charred elk
#

Guys is there any good document or video to learn how to use dots for a fps controller?

sour ravine
#

would instead suggest something like

var singletonEntity = GetSingletonEntity<MarketComparissionBuffer>();
var masterComparision = GetBufferFromEntity<MarketComparissionBuffer>(true);
junior fjord
#

and then you save marketComparison[singletonEntity] to some variable which you access in the Foreach?

sour ravine
#

then do masterComparison[singletonEntity].lolProperty = 0/0

opaque ledge
#

Yeah thats also valid, since MarketComparissionBuffer is a singleton, but i like to have a tag for it to 'explicitily' say this entity i am accessing is global singleton

junior fjord
#

well hopefully you don't do that if you just specified it as read-only πŸ˜„

sour ravine
#

we are all about the bad ideas here πŸ™‚

#

but considering it's a DynamicBuffer<> it's not even valid code anyway

opaque ledge
#

@junior fjord in my example i am simply reading, let me check how i write it

sour ravine
#

yeah same thing

#

just set the data

opaque ledge
#

yeah

#
            var globalEntity = GetSingletonEntity<MarketComparissionBuffer>();
            
            var buffer = GetBufferFromEntity<MarketComparissionBuffer>();
            var marketComparisionBuffer = buffer[globalEntity];
#

i am also not exactly a pro coder, so dont mind the incosistency πŸ˜„

sour ravine
#

it is valid, you're just less likely to get something back from that index

#

speaking of use cases of WithAll<>

junior fjord
#

ok, and in case I have two buffers on my globalEntity, A and B and three systems, two read from A, one writes to B. Would unity schedule them all in parallel?

#

or would I have to put the buffers on different entities for that?

sour ravine
#

they'd have to end up in different chunks

opaque ledge
#

@charred elk probably not but should be easy to implement, as long as you get the idea of how ECS works its just matter of simply copying the code from standard fps controller, i would suggest you start with CodeMonkey

sour ravine
#

so different entities are more likely to do that in practice

#

well

#

different archetypes

junior fjord
#

ok so the scheduling in unity is not done component-wise but archetype wise?

opaque ledge
#

yeah they would run parallel, there is no problem with reading parallely.

sour ravine
#

neither

#

chunk-wise

junior fjord
#

so if one system writes to a chunk, no other system can use that chunk, even if it is just reading a different component?

sour ravine
#

EQs produce chunk lists which are ForEach'd

#

correct

junior fjord
#

ok, yeah then I should probably put the buffers on different singleton entities

sour ravine
#

that's what's called a data hazard

junior fjord
#

having them all on one would block nearly everything for me then πŸ˜„

sour ravine
#

since another thread could be in the middle of a non-atomic write (think different fields in a struct, etc.) and threads could read different values

#

two entities with different archetypes cannot share a chunk

#

since every chunk has exactly one archetype

#

reads can run with reads, but that's the only safe relationship

junior fjord
#

yeah I understand how chunks and archetypes are related

#

but if I write to component A and read to component B, the threads could not read different values

#

the system reading B has nothing to do with A

sour ravine
#

because of dependency management

junior fjord
#

it is just a coincidence that this archetype shares the two components

vagrant surge
#

im not so sure of that

#

on the per chunk level

sour ravine
#

again, based on how the chunk/archetype relationship works, no

vagrant surge
#

if one system is writing component A and reading B, and other system is reading B and writing C, they run together couse its safe

junior fjord
#

yeah that is my question, how does unity schedule that

vagrant surge
#

unity looks at the read-write dependencies on the component types

junior fjord
#

does it just check the component-wise read/write relations and schedule systems s.t. only one system writes to one component at a time

vagrant surge
#

and allows 2 systems to execute togther if there is no read/write conflict

sour ravine
#

yes

opaque ledge
#

holy shit i am so peasant i have no idea what people are talking about

#

i will just continue code stuff

sour ravine
#

and waits for those EQs to complete before scheduling anything reading again

#

writes suck, don't do 'em πŸ™‚

junior fjord
#

ok good, so no archetype/chunk wise blocking happening here?

#

don't know how far you come without writing πŸ˜„

sour ravine
#

shh, no practice here

#

only theory

junior fjord
#

ok, so to conclude. It is ok to put all my global dynamic buffers on the same singleton entity and unity will be able to schedule jobs in parallel that write to different buffers of that entity?

vagrant surge
#

no

#

they would need to be on different components for that to work

junior fjord
#

yes they are different buffers hence different components

#

or what do you mean?

vagrant surge
#

ok if they are different comps then its fine

junior fjord
#

I have one

struct WaterHeight : IDynamicBuffer {float Value;}

and the analoguous for Humidities

#

ok perfect, that is what I hoped for

#

then I see no reason for different singleton entities actually

#

having one even means that all the pointers to the dynamic buffers would lie right next to each other which marginally reduces the read requests I guess πŸ˜„

#

ah no scrap that

sour ravine
#

IBuffer and friends actually use inline storage

#

one better

#

up to a point, at any rate

#

false sharing lol

vagrant surge
#

false sharing isnt a problem on reads

#

only on writes

junior fjord
#

yeah but my arrays are so big I don't think it will be inline

#

they are basically worldHeight*worldWidth

#

can I set the internalcapacity so high?

#

I thought it is probably capped to something

sour ravine
#

that's a good question-- chunks are set to be 16kb by default iirc

#

I don't know what happens if you break that

#

re: sharing and RO data-- true, but I don't know what kind of reduction(s) are being done on the buffer

vagrant surge
#

@junior fjord if its really that big, you might not want it to be one entity

#

but a bunch of them

#

this way you can parallel-for update the water simulation neatly

opaque ledge
#

if you exceed buffer's capacity, rest will be put into heap

#

if your internal capacity is high enough to make an entity's size go up to 16KB then it will result an error, if you are sure buffer will be get that big, better set initial size to 0

sour ravine
#

yes, we're asking what happens if you make the internal storage buffer large enough that it can't fit into a chunk

junior fjord
#

@vagrant surge right now, I just have one big nativearray and I know my system is designed s.t. it never writes to the same place twice and I do WithoutParallelForRestrictions

#

is there no analogue for a dynamicbuffer?

#

@opaque ledge yeah I also thought that I would set it to 0