#archived-dots
1 messages Β· Page 128 of 1
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?
Not 100%, only if the Entities package has already defined ECS components for the MB component
But most standard ones do, e.g. transform and renderer
So you can e.g. use Animators etc and they will just have some hidden gameobject created for them at runtime, correct?
very loosely
You'd have to inspect the source for each conversion to get the specifics
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
To be clear, I'm talking about this thing:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/StressTests/HybridComponent/README.md
Which as I understand doesn't require any specific conversion code more than "keep this old-style component around"
Yeah, but invisible go's are like the total opposite what I want
right-- and keep in mind a lot of this involves under-specced invisible things that aren't really documented
I want more data actually exposed in the editor
^
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
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).
which, unofficially does seem to work
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
@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).
You can use a system with a lookup table and a system state component to cleanup gameobjects when the entity is deleted.
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
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 π
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
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
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
btw, since you are much more experienced than me, have you ever tried render culling ? or succesfully using it ? (for 3D)
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
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
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 ?
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
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 π
Use the regular ecs disable then
that disables everything tho
Got other logic on that entity?
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
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
Detach at creation
Ship entity, render entity
Render entity has a component that refs the ship
oh i see, so i copy the position of ship entity to render entity ?
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
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
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 π€
Yeah
children doesnt have any logic on them except for rendering and positioning
hoooo i will try it now, thanks much π
@low tangle it works \o/ π
hell yeah
π
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 π€
whats the UI for each ship look like?
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
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
how will i able to do the shield/healtbar tho ?
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
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
you would just adjust the size and position of the filled bar
i never done shader stuff, would shader graph ok ?
ah i see, do you think positioning and scaling is better than doing it with shader graph ?
if you make a shader for it, you can use masks and make the bar much more intresting looking
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 π
good luck
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
better just do some max number of health bar culling then
or one health bar for groups/fleets
Yeah, you also have to think about how much information a player can actually take in
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 π€
yup
Good morning
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.
You could create queries of the archetypes that you check and then check whether the count is bigger than 0
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.
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
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
they deleted standard assets even
you can add standard assets via Unity Hub
ah ok
@worldly pulsar isn't that for the "new" standard characters on the github?
that project got essentially purged too
hmm, let me double check
like, it's still there, they moved the development to some other team but it's been pretty dead since
i'm not sure the assets in those demos were free to use anyway?
i think they were all restricted?
they were free
some assets were restricted, basically everything on Adam tech demos
BOTD art assets are all free to use for your own projects
ah ok, seems weird for unity to take them down then
I wonder if it has anything to do with Epic now owning Quixel
all of those demos had Megascans in them
i guess they didn't want to update the shaders and stuff
so maybe they couldn't renew some old deal anymore
ah ok, maybe
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 π
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
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
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
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
perhaps they will add new ones soon π€
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
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
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 π
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
Well i mean they should obviously bring some basics such as UI, animation etc.., not sure if it should count as 'new development'
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.
I just read this article https://gametorrahod.com/world-system-groups-update-order-and-the-player-loop/ by the same person. It was really helpful.
So what is the reason for safety checks, and why would I ever turn them off?
its faster without safety checks
Oh, okay. I assume they are turned off automatically in a build?
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
yeah you probably want to have it turned on all the time
So what's the reason for being able to turn them off in the editor?
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
But wouldn't the safety checks report if there are any things that would cause a crash?
youd hope so!
for thread related probably
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.
mmm yeah i should do that
yeah same thing over here, you just have to use that ifdef
what are blobassetstores?
no idea π but they are used for run time conversation for some reason
lol
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
I'm guessing there isn't an equivalent viewportpointtoray in ecs yet?
since camera is not pure ecs
you can make it on OnUpdate and then send it to your job
math.mul() π
you can get references to your cameras inside OnStartRunning
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?
just matrix multiplication
fine. I'll do it.
but you have to get matrix from cameraπ€
π
@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
i guess you need matrix with perspective to transform directionπ€
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
4D space time math
store this matrix once. and then just recreate it with translation and rotationπ
start of a systems update, Camera.main.transform.localtoworld
if I wanted to spawn an entity on button press
should i instantiate a gameobject with conversion scripts that destroys the game object
@digital kestrel You can't convert a gameobject in the middle of a game, only at the start
what do you mean "start"
instantiating my game object prefab converts properly to entities
even if I instantiate them post-initialization
@bright sentinel
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
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
Crashes got fixed and replaced by new ones
most recent HDRP master is incompatible with b4 already
this is like 9.0.0-preview.13 atm
Olento, share your infinite wisdom with us and tell us when urp/hdrp 9 will be relased π
soonπ
will i have to upgrade to 2020 or will they backport to 2019.3?
2020 only
sad panda is sad
this basically means no hybrid renderer v2 on 2019 cycle
my bet 9.0 is for 20.2 π€
i guess we are in 2020 now....
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
any featurelist for 2020.2?
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
oh more platform support, was thinking it was features related for 2020.2
god damn unity physics throwing exceptions at me shakes fist
is it something to do with the rigidbody index out of range? π
sounds about right.. is this a known issue?
IndexOutOfRangeException: Index 0 is out of range of '0' Length. -ExportDynamicBodiesJob
getting this error trying to install latest entities package in 2019.3.7 ?!
@dull copper any idea ?
this is the latest i could find on forum https://forum.unity.com/threads/ebusy-resource-busy-or-locked.845497/
not very helpful. evey other package installed all correctly
entities always has been problem to install properly
this did the trick : https://forum.unity.com/threads/resource-blocked-when-installing-post-processing-package.827199/
IDE was locking the path smh
thanks anyways!
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.
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 π
it returns bool anyway, so you just have to do if statement for raycast check if it hit something
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
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).
Hello, I'd like to share this new datastructure for you to review: https://github.com/sebas77/Svelto.MiniExamples/blob/master/Example1-DoofusesMustEat/Iteration3-Jobs/Assets/Svelto/Svelto.ECS/DataStructures/NativeRingBuffer.cs
/// <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>
I use it to have burstifiable/jobifiable atomic queues. I use it together with https://github.com/sebas77/Svelto.MiniExamples/blob/master/Example1-DoofusesMustEat/Iteration3-Jobs/Assets/Svelto/Svelto.ECS/DataStructures/AtomicRingBuffers.cs to have a queue for each thread
quite powerful, but it may have still some bugs, if you can spot a bug it would be awesome π
I wanna start with dots π What unity version should we use ? Unity 2020 Beta ? Or Unity 2019 Stable ?
I use 2020 b4. You shouldn't be using DOTS for production use yet, so why not live on the cutting edge?
2019.3 also fine
The real cutting edge has been trying to get it working on 3.5 π
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 )
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.
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,.
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.
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 π
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"
sorry, I believe Burst is actually the only part of DOTS not in preview
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
Until they paginate math doc, its still in preview for me
what do you mean by that? @fallow mason
math lib's scripting api docs are bit scarce but I doubt that'll ever change
looks like pretty classic autogenerated api docs
I personally hate autogenerated docs
but that's what we have now
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 ah, you mean that π
lol
yeah, it's kinda pita to find the right thing from that list
just use browser search :p
no, dude. the tab crashes
impossible to find what you're looking for if it never gets loaded into the DOM
Clearly your computer isn't hard core enough to handle these docs
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
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
you can omit that platforms too
I only have it because I tested the newer one before which isn't compatible
I guess I need to load the docs on the 32 core threadripper 64 GB RAM pc I brought home from work π€
honestly, it's probably my home internet speed, but pagination should be implemented regardless
@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
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.
@zenith wyvern actually did try that and apparently vscode still fails to recognize the entities namespace.
@naive parrot don't have vscode open when you update
you need to reopen the project after adding package
@naive parrot don't have vscode open when you update
@dull copper good point. trying that now. adding entities with vscode closed
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
as soon as entities got done importing , these popped up. any clue ?
so now its asking to update APIs
aannd back to square one after API update :
:/
everything is wiped. all packages gone after importing entities
oh i know its vegetationstuido , all those are exception due to missing DOTS packages
I guess Unity's API update decided to reset your packages for whatever reason. Try re-importing Entities now
well, if that asset has asmdef, it's possible it just doesn't have package refs set right now
the json dll one is about you having two of the same dlls in the project
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
I'd focus on getting that thing working on new project first before mixing it with tons of asset store code
If package manager says it's installed then yeah it sounds like an ASMDEF issue like Olento said
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?
make sure you don't have any other compilation issues locking up the project
Not familiar with the asset. What is the very first error you're getting right now?
things can be quite order dependent
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
btw
lots of packages are gone including UGUI?!
not just dots as i mentioned
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
i dont have any custom asmdef. and the vegpro package already has asmdef properly define as i posted above.. is it missing something ?
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
and what about UI packages missing?
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?
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
If I remember right if anything in your asset folder uses an ASMDEF then everything else has to as well
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
also, occasionally just wipe your library
especially if you've updated unity version
or some major packages
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 ?
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?
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?
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.
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
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
first try rolling Collections back to 0.6.0, as that fixed issues in my project. (I need these packages for 2D Animation)
trying now
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).
Try WithoutBurst and see if you get an actual meaningful exception
hmmm not sure if you need withoutburst
otherwise you could try stackallocating externalVal and pass in the pointer with WithNativeDisableUnsafePtrRestriction(T capturedValue)
trying to avoid unsafe altogether
might try rolling back entities version or something
Try disabling burst too from the menu options
yea, burst was disabled from the menu too
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!
And you're sure that code is what's causing the error? Like it goes away if you comment it out?
yup
Weird
yea.. I feel pretty confident that this was working before.. with burst and everything
I don't see why it wouldn't, sounds like a bug
can't get entities csproj to generate smh
perhaps do xxx==externalVal π€
if you just updates burst or some other package, restart editor
its imported but doenst generate csproj files. π€
@naive parrot might be the visual studio code package issue - try 1.2.0 version or 1.1.3
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 might be the visual studio code package issue - try 1.2.0 version or 1.1.13
@coarse turtle am on 1.2.0
btw is this from a fresh generation of the csproj files?
sorry 1.1.3
i cleaned all then opened again
hmm I haven't tried with 2019.3 - Im on 2020 beta atm π€
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(); } } }
@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
hmm I'm out of ideas π€
@amber flicker Seems like a bug for sure. Did you try with the new SystemBase HasComponent GetComponent ?
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
Yeah for a static method you would have to pass in the CDFE
Appreciate the affirmation π
why are you using in Entity? π€
that's a good question... didn't notice I was doing it... does it actually resolve to anything different?
perhaps it will π
same error sadly
are you using 2020 ?
have you tried on 2019.3
in = [ReadOnly]
ref = [ReadWrite]
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
does (Entity e) resolve differently to (ref Entity e) is what I actually meant
perhaps you are also getting something similar
yes you can't ref the entity struct
without ref or in you will get item by value
it should always be a copy
Curious, can you use out for [WriteOnly] a component?
yes
Any performance benefit?
I dont know if that made it into systembases but it does work on ComponentType.WriteOnly<T>()
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?
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
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.
Sure, yeah that's what I suspected. Thanks @low tangle
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.
- 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 your code seems to compile for me. https://gist.githubusercontent.com/jeffvella/98d35b4ecaab5ba93bbc4ba20e14d923/raw/b6723d9224dcd7b660c6d455670d13299747270b/gistfile1.txt
π¦ 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
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
finalizing is very simple
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.
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
it would be better to encode the data as entitys with components themselfs directly
instead of enums on components
in the dod book theres a section on this
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
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)
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
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
@low tangle What is the book called?
so you end up with a massive loading system, but at least it's not a big chain of interdependent systems right?
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
Data-Oriented Design
highly suggest paying for the book if you can, as there isn't much good stuff out there thats dod
Thanks i'm in need of someone telling me what im doing wrong lol
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
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```
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
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.
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.
I've opened it... seen how much code I have and then cried
can we have multiple components and systems declared in single script ? or is it restricted to one per file like Monobehaviors ?
[GenerateAuthoringComponent] Only works for a single component, other than that there's no limit
cool! thanks
[GenerateAuthoringComponent]Only works for a single component, other than that there's no limit
@zenith wyvern yea i read that
every time I come here with a question, it sparks a 2 week refactor session to deal with all my previous misdemeanours
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
On the one hand, YAY! On the other hand ohhhhhh boy I'm slow at getting this game done π
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
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
exactly, you said it, get it done
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
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
heh, and my game is nowhere near CPU bottleneck because the raymarching is so much more intensive

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?
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)
You can put a static wrapper around a SharedStatic and then you could just use it without capturing or passing anything into your jobs.
oh thank you, I was about two scrolls up from that :P
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?
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
your usecase is pretty similar to what I need actually
just found your forum monologue π
@junior fjord thank you for giving me your support. I don't feel stupid at least π
seb's situation was a little trickier, ill try to put a working test together π
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
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?
alright, so this works, https://gist.github.com/jeffvella/b90ca308fdd47f7566687d9efc0da17a
could have just stored the pointer... depends if you wanted to use functionality from the UnsafeList.
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
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
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
I think I don't understand what it does at all π
Burst doesn't support Volatile.Read apparently, what's the alternative?
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.
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?
If your data isn't changing at runtime you don't need SharedStatic
You can just use readonly arrays
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?
There is no safety thread check when it comes to shared static
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?
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
yeah I am trying to understand what GetOrCreate<Shared_FleetMaster, EncounterShipKey>(); does
and thans a lot
I will use that template
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.
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 π
does it really matter ? you just put it into it and it works π
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.
@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
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.
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.
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
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.
ok good thanks for all the explanations
np π
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
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?
is TΔ°me.DeltaTime from UnityEngine or Unity.Entities ?
what happens if you cache delta time outside the foreach?
This is run with Run i think, so shouldnt matter
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
well i never encountered this issue, but maybe something about float percision
yea you're right @opaque ledge - it looks ok - there's nothing going on right? like a moving camera or something?
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
just do Debug.Log
I tried that but it doesn;t log fast enough
vsync enabled? if you're frame rate is varying wildly, that might be what you're seeing?
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
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
Not heard of SystemBase before, I'll have a look at the docs.
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
Whats the newest "Entities" version ? I only see a 0.0.? version inside my package manager...
0.8.0
Is there to get that version running in Unity 2019.3 ? Looks like 2019 only has that old version in the package manager
Hmmm... thanks @opaque ledge π probably a restart helps
Do jobs cost a lot to create? Is it ok to do a job on entities, and each execution might spawn more jobs?
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
OK, thanks!
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.
not natively in the lambda
.WithStoreEntityQueryInField(ref m_Group) ?
would that help @warped trail ? Wouldn't it still need to end with run or schedule etc
you can calculate amount of Entitites in that query
the compiler sees the WithStoreEntityQueryInField and stores it in the field for you before the foreach is run, so you can use it before
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
var count = m_Group.CalculateEntityCount();
if(count > 1)
{
Entities.ForEach().Run()
}```
I need var count = m_Group.CalculateEntityCount(); if(count < 1000) { Entities.ForEach().Run() } else { Entities.ForEach().ScheduleParallel() } without duplicating the code ideally
you can use some struct π
hmm yea I suppose that's true
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();```
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.
Has anybody benchmarked this overhead ?π€
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
but is it really worth it to block main thread and not just schedule()?π€
hmmm, I'm getting quite a boost in scene brightness with hybrid renderer v2 on HDRP when I press play on editor
is movement considered simple ?
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.
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
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
from Schedule or ScheduleParallel perspective, is 1 entity with high calculation is considered same with 1k entity with low calculation ?
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
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
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
I don't know if it's a flaw, they made it that way to protect people who are new to multithreading
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
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
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
That does sound pretty sweet
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
Doom eternal doesnt look like a game that needs multi threading π€
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
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 π©
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.
but system execution time is not the full picture, isn't it?π€
im not entirely clear on that point... what exactly does the EntityDebugger timing cover.... i assume it includes any jobs launched from those systems?
i don't think soπ€
I don't really pay attention to the system ms, I only look at the jobs in the timeline and the hierarchy
i think it does(edit debugger system includes spawned job time ms)
would be kinda useless without it
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
Yes Timeline gives a great overall view of what you should actually be focusing on
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
any ideas on this? hybrid rendering v2 + HDRP 9
I usually only go to hierarchy when I need to deep profile to drill down to what actual function is the bottleneck
(banding is from gif compression)
Too bad that looks kinda cool, hahah
are you using those fancy new material components?
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)
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
but without any specific conversion, it might be that theres something going on behind the scenes
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
it seems to work in a way that they do move on entity side
yeah, my tinfoil theory is that this is it π
camera still renders etc
just do a finallobjectsoftype with lights and see if theres a tricksy hidden one
Kinda dumb but you could create a script to change all gamebjects hideflags to reveal them
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
After you close the subscene for editing?
the moment I move light from regular scene to dots subscene
Yeah no conversion should happen until you actually close the subscene
It's weird that it would change just from that
I could adjust the exposure to match the new setup but I'd need to retune everything, including the sky exposure
when you keep subscene open it constantly convert thingsπ€
Oh right I guess that's what livelink is
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
I'm sure proper docs and examples for subscene usage are coming....any day now....
well, I'd really want to... not use subscenes at all
they pain me if you remember my rants
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);
From what Topher said it sounds like they are desperate to get rid of ConvertToEntity entirely and force us to only use Subscenes
We should uprise to their tyranny π
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.
I wouldn't mind dots subscenes if they just made everything compatible
Hahah, I wouldn't expect them to force it until subscenes are actually like...usable and you know, actually documented.
which I'm sure they eventually will
I'm totally expecting the default scene to be dots subscene at some point
what exactly is a subscene anyway, like.. dots scene so to speak ?
@safe lintel outputs 1 when light not in dots subscene
outputs 0 when light in dots subscene
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
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
π
0lento is the hero we need, all beta testing the git source.
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
hopefully we'll get a package in the next couple weeks!
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)
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?
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)
There was a new package updatefor animation just a few days ago but without an update to the samples its almost not worth mentioning π
does creating a ComponenSystemGroup auto creates and adds all of its subscribed/child Systems to targget World?
yes
ok thanks
Guys how can I apply transform to a entity?
do you mean, how can you move an entity ?
.ForEach((ref Transform transform, ref PhysicsVelocity velocity, ref CharacterControllerData data) => {
I've done this, but i can't use Transform.Translate
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
forget about Transform when you working with entities π
So you have to do Translation instead of Transform
So I have to calculate the new transform values and then apply them to the entity?
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π€
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?
job system can protect the access to those global arrays
, no need to have the tag components
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
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?
what is going to be slower
but I don't need the WithAll<WaterAccess> in your case do I?
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
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
yes, that is how I am using it currently
Well.. yeah if you can make sure the entities you are processing has 'access(as in game mechanic)' to Water singleton buffer
to let unity handle that I do not access the same shared static from two systems in parallel
statics are in general a bad idea
Unity cant handle that
@opaque ledge yeah that is done by them having a TileID component, the WaterAccess was just a tag for accessing the waterarray specifically
i meant to say you should create a singleton buffer instead of shared static
singleton entities are a better fit for 'one per world' data which is in almost every case what people really want
see subscenes, IConvertXXX
@dull copper // I see they are also making something with nodes in their new aniamtion system
because of the dependcy handling?
I'm actually quite interested in what they will do with ECS and Visual Scripting
static read/write data is a leaky abstraction in any OO language
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
i still dont understand why singleton entities arent native and with special rules
they are just so useful for storing system data
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?
static read/write entities are a bug
yeah I mean you can also do GetSingleToneEntity<GlobalData> if you want
but asides from that
there is an actual method called GetSingletonEntity<T>()/GetSingleton<T>() on EntityManagerComponentSystem and friends
ah really?
Just make a single entity and throw Water and Humidty in it, and thats it
ah ok good that changes things, I thought this is just about personal taste π
afaik those methods doesnt exist on EntityManager, they only exist on SystemBase and EntityQuery
yeah my b, it's early morning for me
fixed
anyway-- you can set up that entity when you bootstrap your World
That, or just make a MB that creates the entity and adds stuff
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?
SetSingleton<T>() can help with that, but you don't need the tag component here if you just want that data
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
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
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
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
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)?
disregard if you're putting actual data in it
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?
both is valid, but i prefer to go with 1
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
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
more or less. The split component approach offers some more granularity
for dependency management, etc.
hence comment about it being more idiomatic
GetSingleton<T>() has no parameters for isreadonly in the docs
how would I now specify that I only want to read that buffer?
@junior fjord through EntityQuery
you actually would be doing it in the System potentially as well
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
you can also run an Entities.ForEach() directly as well
since it's still a regular entity with a regular component
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
@junior fjord and you can have 1 Singlton entity with a lot of components, each component will be considered singlton
^
var singletonEntity = GetSingletonEntity<GlobalEventTag>();
var masterComparision = GetBufferFromEntity<MarketComparissionBuffer>(true);
This is what i do to update my market comparisions
yeah do want to stress in all cases you're still dealing with a regular entity
so all the same approaches would apply
though
Guys is there any good document or video to learn how to use dots for a fps controller?
would instead suggest something like
var singletonEntity = GetSingletonEntity<MarketComparissionBuffer>();
var masterComparision = GetBufferFromEntity<MarketComparissionBuffer>(true);
and then you save marketComparison[singletonEntity] to some variable which you access in the Foreach?
then do masterComparison[singletonEntity].lolProperty = 0/0
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
well hopefully you don't do that if you just specified it as read-only π
we are all about the bad ideas here π
but considering it's a DynamicBuffer<> it's not even valid code anyway
@junior fjord in my example i am simply reading, let me check how i write it
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 π
it is valid, you're just less likely to get something back from that index
speaking of use cases of WithAll<>
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?
they'd have to end up in different chunks
@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
so different entities are more likely to do that in practice
well
different archetypes
ok so the scheduling in unity is not done component-wise but archetype wise?
yeah they would run parallel, there is no problem with reading parallely.
so if one system writes to a chunk, no other system can use that chunk, even if it is just reading a different component?
ok, yeah then I should probably put the buffers on different singleton entities
that's what's called a data hazard
having them all on one would block nearly everything for me then π
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
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
because of dependency management
it is just a coincidence that this archetype shares the two components
again, based on how the chunk/archetype relationship works, no
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
yeah that is my question, how does unity schedule that
unity looks at the read-write dependencies on the component types
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
and allows 2 systems to execute togther if there is no read/write conflict
yes
holy shit i am so peasant i have no idea what people are talking about
i will just continue code stuff
and waits for those EQs to complete before scheduling anything reading again
writes suck, don't do 'em π
ok good, so no archetype/chunk wise blocking happening here?
don't know how far you come without writing π
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?
ok if they are different comps then its fine
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
IBuffer and friends actually use inline storage
one better
up to a point, at any rate
false sharing lol
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
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
@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
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
yes, we're asking what happens if you make the internal storage buffer large enough that it can't fit into a chunk