#archived-dots
1 messages Β· Page 256 of 1
nice, not sure how I can access that journaling menu and export it to a csv π€
they have full playlist for gdc videos on their channel
doesn't seem like I have it as an option
well.. you can see the playlist on the side there too π
that's not hidden on the main channel either
The editor running in the video is 2022.2.0a4
Now I can totally make baseless timeframes and get disappointed when they don't match reality!
authoring workflow looks good, much better than I thought it would be.
Debugging tools look great.
I wish they'd show more about "aspects" though.
yeah save during playmode is finally here
Everyone keeps saying "aspects" and I am too scared to ask
my uneducated take is they seem to be a way of simplifying complex sets of data, theres a very small blurb on the dots roadmap
Entities 0.50 runs fine on 2022 with only a very few minor changes
Hybrid renderer busted though due to major graphic api changes
what is the practical impact of not being able to use the hybrid renderer?
better performance? π€
(it depends what you do with it)
practical impact is that you can't do as much purely on ECS side without hybrid rendering since you have to constantly sync the GOs to them for rendering
i c.
DOTS feature compatibility
Hybrid Renderer does not support multiple DOTS Worlds. Limited support for multiple Worlds is intended in a later version. The current plan is to add support for creating multiple rendering systems, one per renderable World, but then only have one World active for rendering at once.
for our project this may be a limiter as well
hybrid renderer has bunch of limitations
I'm guessing it's quite featured nowadays but still lacks some more niche features like raytracing etc
guessing since haven't used it for few years
oh wow, they still lack reflection probe support on URP
and point + spot lights π
urp with only a directional light is just brutal
Hey, I'm getting 16 error messages after trying to install the Entities package and the Hybrid Renderer package. Some say The type or namespace name 'Editor' does not exist in the namespace 'Unity.Profiling' (are you missing an assembly reference?)
and others are The type or namespace name 'ProfilerModuleViewController' could not be found (are you missing a using directive or an assembly reference?)
and no suitable method found to override. Did I miss a dependency?.
Does DOTS normally take this much unnecessary work to install?
What version of Unity are running on?
2020.3.29f1
Upgrade it to a minimum of 2020.3.30
Will do
Hey All. What is the equivalent of OnTrigger events in DOTS 0.5?
Everything I've found online so far is out of date with the latest release. I would also be interested on what would be the equivalent of a OverlapSphere cast, which could also be used for my needs.
I have similar question : how to use unity.physics just to detect collision events? I have my own physics and need only collision detection from dots physics
@solar anvil physics samples repo has examples of ontrigger stuff, its not yet officially part of the package though so(for now) you would have to update it to 0.50 yourself
also instead of a specific overlap cast, you just use a collider cast and specify the type of collider to cast with
similarly the samples also covers collision events
could you link to the repo?
see pinned message for github
@solar anvil also check this, PR for the physics samples update to 0.50 https://github.com/Unity-Technologies/EntityComponentSystemSamples/pull/207
Thanks. That helped
Hey guys, I need to iterate over chunks manually with IJobChunk and am wondering if It's possible to access the next chunk within the job. What I need is essentially random access into the entities of a series of chunks
aspects is basically component families from project tiny (if someone remembers that)
are you only reading not writing to these chunks?
if so just use a IJobFor instead of IJobChunk
and do manual iteration
you'll have the collection of all your chunks in a NativeArray that you can read
I need to write
well you you can't safely write to something you're reading from in parallel
i have errors with unity 2022 and Entities 0.50. Any ideas?
Library\PackageCache\com.unity.entities@0.50.0-preview.24\Unity.Entities.Editor\Unity.InternalAPIEditorBridge.002\ProfilerModules\StructuralChangesProfilerModuleBridge.cs(92,32): error CS0507: 'StructuralChangesProfilerModuleBridge.defaultOrderIndex': cannot change access modifiers when overriding 'private protected' inherited member 'ProfilerModule.defaultOrderIndex'
entities 0.50 is not supported in 2022
Finally got around to watching that authoring gdc talk
An ambitious plan to be able to design and build your game while never leaving play mode
is it public?
yeah the stuff looks really cool, I especially like the entities journal thats really useful to me
This video covers the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It also addresses a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with...
what's the "correct" way to create an entity prefab that needs a game object attached to it in 0.50?
Damn, I really dig the foreach syntax in ISystem from this video
Same
I feel like all the UI stuff is kind of huge for debugging
yeah its all really welcome changes. the persistent playmode stuff is huge
your really missing out and making your job harder if you just use gameobjects
the way you can adjust things live turn systems on and off, see exactly what data has what relationship and where and when exactly its changing
yeah just enable/disable systems is super handy
I can't imagine how well this will work in more complex/real scenarios
if some entity has a component with fields that get read at instantiation and then some other fields that are used continuously
if you change both fields in the authoring gameobject, one won't have any effect, the other will
when you are playing
I'm not sure how that would much of problem, but there's always edge cases and issues
but it would save a ton of time being able to design and adjust levels in real time without ever having to go into edit mode
I wonder if theres some high level wizardry for standalone save/load stuff in the works down the road, maybe post 1.0? seems like this example of save/load would open the way for it.
has anyone done this?
I found some outdated stuff about Companion components that doesn't seem to exist anymore
@worthy rampart I'm using convert and inject game object plus the copy transform to game object authoring for something and it still seems to work on 0.50.
yea but does that work for a prefab
that you can instantiate at runtime
I was hoping to be able to instantiate the entity prefab
yes, Im using it in a prefab
are you instantiating the prefab via an entity manager
or is it already in the scene in editor
I've got a prefab that has convert and inject set
ah I just remembered I wrote a special system for that case, because I couldn't use it this way even with the previous version. It's instantiating with Object.Instantiate and then converting it at runtime.
I guess. I remember trying a few things back then and couldn't get it to work otherwise.
Is anyone else seeing some kind of NativeArray leak with Entities 0.50? I just upgraded a project from 0.17 and noticed that a server build quickly ran out of memory that previously had a stable memory consumption. Upon further inspection in the editor I saw that when I take samples with the memory profiler, the NativeArray entry is consistently growing really fast. I disabled all systems, which stopped it growing, and enabled them one by one until it started growing again. My finding was that it happens when a system is executed that has a ForEach with Run, but does not even match and work on any entities. Just running the ForEach already begins to grow the NativeArray entry in the profiler. I also tried using the memory profiler package, but unfortunately that gave me no more insight into what this culprit NativeArray might be and who is allocating it, except that it seems to be a single one that grows over 1GB within a few minutes while the other native arrays donβt change much. It just seems to happen on any system that uses Run. When I change it to Schedule it stops growing, but I canβt do that everywhere. Since there are so many systems Iβm not sure if itβs somehow related to my project setup and I havenβt tested an isolated case in a simple project yet, which I guess Iβm gonna try next. Does anyone know if and how I could find out more about the NativeArray allocations in the memory profiler?
Hey, I keep getting a red line under using Unity.Entities; even after updating VS Code per reccomendation.
"The type or namespace 'Entities' does not exist in the namespace 'Unity'
Hi @half jay, did you be able to make a compilation on iOS?
Actually my problems is on running, give me a error with EXC_BAD_ACCESS in Unity.Entities.SystemBase.Unity.Entities.UnmanagedUpdate_00000C82$BurstDirectCall.Invoke(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails) -> bool_f7c830754110dc9aeb9050443cd2a04b ()
I think this a issue for Entities 0.50 with Xcode 13.3
anyone have problems with Xcode 13.2.1?
What's the best way to use CollisionWorld.CastCollider with a filter? I assume I need to write a custom IQueryResult, but I have no idea how to get the collision filter from that
I was going to pass the Bodies list and use the RigidBodyIndex to get the body, and then the collider, and then the filter, but there might be a better way?
I find a thread with this: https://forum.unity.com/threads/ios-dots-buid-crash-on-startup-with-il2cpp.1259388/#post-8013296
Hello, need help(
I have a problem with running my game for iOS with DOTS package(pretty sure it is same for other platforms as well).
It builds...
Do you have a custom bootstrap where you manually add systems?
Yes, I do.
Unity has a new per frame allocator that everything within entities uses
Which is reset by a system
If you don't add this system to your loop you'll leak all internal entity operations
Ah interesting. Yeah I'm setting up multiple worlds with different systems. Can I add this system myself?
I'll check all the default systems if I find one with a name that sounds related. Thanks for the pointer already.
It's an ISystem
WorldUpdateAllocatorResetSystem?
That's the one
Nice thanks, saved me a lot of time and worries. Just disabled it in a test project and it' showing the same leak. Will now fix the real one.
Bump. I can't find any tips online on how to solve this. I'm not getting any errors in the Unity editor, but VSCode isn't recognizing the namespace Entities even though I have the package installed
Edit -> Preferences -> External Tools -> Regenerate project files
Also make sure visual studio code editor package is up to date
That said we don't support vscode for our developers so limited experience troubleshooting it
Nice. That worked. Btw, I meant Microsoft Visual Studio, I thought they were the same thing. I've used it for years with very minimal problems
VS studio and code are very different!
Thank you! Gonna go make an N-Body gravity simulation now. :)))
This is my code, I followed a tutorial almost word for word, but I can't get anything to render. In the console there's a message (not a warning or error) saying "No SRP present, no compute shader support, or running with -nographics. Hybrid Renderer disabled"
The mesh and material are set, ofc;
what render pipeline are you using?
If that's tutorial code I need to have a word with them...
i mean that's how most tutorials look like
even unity's own samples has a really high reliance on monobehaviour centric examples π
@coarse turtle mind if I pm about nimgui?
yea go for it
Currently, the default render pipeline, I haven't installed one
Should I use the URP?
What's wrong with it? I'm just getting started with DOTS, or is it something more fundamental?
Is there a good way to create entities without any reliance on the GameObject system?
Best life advice I can give is make a copy of the entities package, change permission of CreateEntity from public to internal and try to never touch it again
I guess I don't know enough about DOTS to understand
You should not be creating entities at runtime
Ah
You should be authoring your entities
All the tech Unity is showing off in 1.0+ etc does not work if you create entities at runtime
It requires and they expect you to use the authoring workflow
I guess I'll have to figure that out as well. Btw, I installed the URP and the entity still won't render.
I'm pretty sure you're missing a bunch of components
There's some helper function I can never remember the name of (because I never use it since I author all my entities) that will add all required components for you
I'm sure someone here knows the name though
oh actually you also never assigned RenderBounds
so you're bounds are 0 and will always be culled
also your rotation is 0,0,0,0 and not identity
Wow, lots of stuff the tutorial didn't cover at all, lol
how old is this tutorial?
Too old apparently, it looks like this version of DOTS is too new to have the info base fleshed out for even getting it running
It looks like someone had the same issue as me and posted about it today
i actually decided to start writing a new save system for my own project yesterday (since I obviously can't use the one I wrote for work)
i have a pretty good idea how i want this to work now and if I can bebothered since I know this is such a common pain i might look at releasing it in some form
basically be my 3rd crack at this
Did anyone manage to figure out scene switching with Entities 0.50? It used to work fine for me on 0.17 when just before loading another scene I just cleared entities with entityManager.DestroyEntity(entityManager.UniversalQuery); But now something's changed with entity physics and I get the following error. Physics entities just stop moving around after this happens. If I just start from the same scene without loading it form another scene everything works fine.
InvalidOperationException: GetSingleton<Unity.Physics.Systems.PhysicsSystemRuntimeData>() requires that exactly one Unity.Physics.Systems.PhysicsSystemRuntimeData exist that match this query, but there are 0.
Unity.Entities.EntityQueryImpl.GetSingleton[T] () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/Iterators/EntityQuery.cs:1073)
Unity.Entities.EntityQuery.GetSingleton[T] () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/Iterators/EntityQuery.cs:1843)
Unity.Entities.SystemState.GetSingleton[T] () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/SystemState.cs:913)
Unity.Entities.ComponentSystemBase.GetSingleton[T] () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/ComponentSystemBase.cs:487)
Unity.Physics.Systems.PhysicsRuntimeExtensions.RegisterPhysicsRuntimeSystemReadOnly (Unity.Entities.SystemBase system) (at Library/PackageCache/com.unity.physics@0.50.0-preview.24/Unity.Physics/ECS/Base/Systems/PhysicsInteractionSystems.cs:18)
Arc.Weapons.Laser.ShotLaserBeamSystem.OnStartRunning () (at Assets/Scripts/Arc/Weapons/Laser/ShotLaserBeamSystem.cs:30)
Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/SystemBase.cs:390)
Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/ComponentSystemGroup.cs:583)
i don't believe in scene switching for entities projects, that said your issue is you can't do this entityManager.DestroyEntity(entityManager.UniversalQuery) as it destroys the safety singleton physics uses
if you want to do this you'll need to get internal access to the physics library and either recreate this entity after you destroy it or put it in the exclude query for your destroy
personally i'd advise against this, just because it works now who knows maybe unity adds 100 internal components in a future version that are required to exist. creating utility or state entities in OnCreate is a reasonably common pattern and what you're doing breaks this.
better off just never switching scene and use subscenes (my recommendation) or destroying the world and re-creating it on scene switches
That is really disappointing. Entities have so much flexibility if you know what you are doing. The authoring stuff I've seen in 0.17 was really rough
Dots authoring is getting a lot better https://youtu.be/p4ct4vHWYt0
This video covers the improved Editor tooling in the upcoming Data-Oriented Tech Stack (DOTS) 0.50 release, including the Hierarchy, Inspectors, Profiler modules, Systems window, and entities journaling. It also addresses a new Editor workflow, coming in Entities 1.0, which allows artists, gameplay programmers, and level designers to author with...
watch like 17:30 onwards for 1.0 and the future
2022.2a7 was released, but not entities 1.0 π¦
We need that 2022.a6.dotse build the dev in the video has π
That's optimism
Did they promise 1.0 in 2022?
1.0 will only be compatible with 2022
nah, in the video ^^ they said it'd be close to 2022 lts. so still over a year
still pog
but i gotta say unity is kinda inconsistent. in the forum posts they said it'd be: 0.50, 0.51, then 1.0 in the video ^^ they said they'd go back to normal experimental releases now
Hmmm, makes sense. PhysicsSystemRuntimeData is internal and switching to a single scene would be too much work for now so I guess my only option is re-creating worlds. I tried to look for some info on this but I couldn't find and. Should I just disable automatic bootrastrap and copy and modify what's inside Unity.Entities.DefaultWorldInitialization ?
Or is there a simplier way to do this?
Nvm, I found a guide: https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/world.html
@rotund token Thank you for your help π
Hello @rotund token , if I'm not mistaken you recommended in discord to use log4net over the basic unity debugger. Have you managed to use log4net from a burst job ?
anyone know if there are any examples anywhere for simulating multiple physics worlds using the PhysicsWorldIndex component
Complete opposite, I was advocating for using unity debugger and hooking in on the other side
You can hook in whatever you want in other side by overriding ilogger
Can anyone point me to an up-to-date tutorial on how to render entities with the hybrid renderer V2 and ECS 0.50?
I'm having trouble finding ones that are updated or still relevant
Someone said that the conversion workflow is the best way to do it, so I guess I'll quit trying to use pure ECS rendering.
conversion doesn't mean it's not pure ecs
it just means you edit game objects in the editor
add a cube to scene, hit convert to entity checkbox
Does ECB.Instantiate still return a negative-indexed entity which should not be stored in other components?
Thank youuu
Oh, ok thanks I'll look into it.
don't do that! use subscenes
Hi I am creating Transformaccessarrays with the constructor new Transformaccessarray( [TransformArray] ) .
I want the transformaccessarray to persist permanent but dispose it when I end the game with the pause button.
How do I dispose it?
curiously why are you manually creating transform access array
You know ECS 0.50, does that still support GenerateAuthoringComponent?
cause I get a lot of errors about "Runtime" missing in the generated code files...
[GenerateAuthoringComponent] still works perfectly fine
Huh
Wonder whats up with my project then :/
Seems I have multiple code gen issues... "Duplicated parameter name" also π¦
show your package manager
hm, seems ok. try going to preferences and regenerate project files
Fix first one in order
try regenerating the project files
"Regenerate Project Files" makes no difference, Maybe a reimport assets will do the trick, kinda doubt it though
well you can manually delete Temp folder if you wanna be sure :p
what unity version are you on? and what ide are you using?
20.3.32
and ide?
and deleting Temp/GeneratedCode neither ?
Don't really get how a fully namespaced usage can be missing, esspecially in the system space
what rider version?
21.3.2
are there other errors except those from the temp/...?
very curious
reopen the project?
Unless asdef files found a way to break the reference somehow
Had to close before I could delete the entire temp folder
So that's not it π¦
doubtful
Oh
There is one unique error
but it's just as bad
"The parameter name 'shared' is a duplicate"
in a generated file
try removing all partial keywords from your system classes
Did WithSharedComponentFilter change?
i don't think so
cause these is the generated method arguments:
and this is the setup for that:
why would one be ref and the other not?
do they need to get passed in now?
looks fine
Hmm, then why is shared declared twice?
oh. uhhh, i have no idea. but i doubt that that's the issue
well it's the only thing not complaining about missing system namespace....
and the only one that looks like an actual compile error
can you remove all the partial keywords? so it doesn't generate anything, then put them back one by one to find which one actually causes an issue?
I can try
So if I remove the partials it works?!?
Well it has runtime errors cause of missing references but it compiles
if you remove the partials, it will not generate any system for you
do you have multiple entities.foreach for the same system in different files?
I think I need to restart the editor again
do you have nested Entities.Foreach()?
I don't think so
be easier if you just posted the full system
It's everything
every system has this issue
everything with GenerateAuthoringComponent has it too
It's like unity dosen't import the System package into the solution
(i just want to note here that compared to source generators written by microsoft (and therefore also the generated files), unity's source generators (and therefore the generated files) are ....gross. but i hope / am optimistic that they might improve them)
I doubt it
it works fine
there's likely 1 file that is breaking everything
and stopping it all linkiing
+1
I think this is the issue
and i have a post with like 5 different things that break the code gen
and unless you post some code we can't see which cause it is
and i doubt that the code that you posted actually breaks anything
ahh but it does
we can clearly see the result is broken
I mean not my code but the generated code
wouldn't that stop the compiler too and possibly break linking?
yes but your code is what triggers the generated code
and there are currently a bunch of things that you can write that are legal c# that will break code gen
ah man, i'm slow right now....yeah that should break something..
yeah, best post the whole system pls
OK if was to guess, is what is breaking your code gen
WithShardedComponentFiltering likely passes in a copy of the shared component itself, but you are also capturing the same variable
i pretty much never use scd in jobs but i have an idea, give me a sec need to test
what i can contribute is that....uhhh.....putting entities.foreach into a foreach loop does not feel right.
yeah ok
just pass hte shared component in the ForEach
ForEach((Entity entity, SpriteSheetMaterial ssm, ref BufferHook) => {}
can confirm it's the capturing of the shared component that does it
good to know
Well that error went away but the rest of them are still there π¦
if you clear, what's the first
Temp\GeneratedCode\Code\PathfindingSystem__System_2109874506.g.cs(16,13): error CS0234: The type or namespace name 'Runtime' does not exist in the namespace 'Code.Pathfinding.System' (are you missing an assembly reference?)
yes
But Runtime is System.Runtime
Unless you need to link to System now which would be a bit crazy?
are you using .net standard 2.0 or .net 4.x
2 I think, let me check
Yeah 2
(wish they would update to 6 but but 2 will do for now)
well latest net standard is 2.1 so 6 would be a leap π
they will. but it'll still take about 2 years before that happens
Latest is .Net Standard 6
they are on track for that....if you don't know
there is no .net standard 6. or .net core 6. there is only .net 6
you can use c# 9
partial was added in .net 3.5? I think
so 2021 was c#8, 2022 c#9? (partial support)
he meant partial c# support, not the partial keyword
yeah
only used 2022 for half a day but i really want the new namespace
anyway show us a system crener
you mean file scoped namespaces?
yep
hmm i'm pretty sure that worked in 2022
told ya
C# 10 is .net 6 Right?
c# version and .net is not necessarily connected
Cause I know it got added in .net 6
even worse when it comes to unity
.net 5 and 6 have shipped with new versions though
def
and MS are trying to stay on a yearly schedule with releases now
yes, but the version is not fixed to a .net version
....for the most part at least
Not in the framework series but from standard onwards that was the goal
the release of a new version is, yes....but not the usability of the new version. that's what i meant
Hmm, why would they release an unusable version?
.....what? i think we're not understanding each other currently
hmm i'm totally wrong, file scoped namespaces don't work in 2022. Swear i used them for a little while.
told ya
i wasn't doubting your c#10 statement
but i explicitly recall downgrading my project and having to remove a bunch of file scoped namespaces π
2022 can create a .net 6 project with is C# 10
no
i can only seem to make it generate a 4.7.1
well that's not the feature i'm talking about
you just made a console app
don't do that. use .net standard 2.1 has more api's than 4.7.1
of course
i was just testing the .net framework
that it was generating because he mentioned it
yeah but this isn't a unity app?
No
we are talking about unity 2022, not vs 2022 / rider
too many platforms to support
I figured with .net standard being more of a thing they would drop Mono
More speed and better support
not for too long anymore, max 2 years. then they'll be in lockstep with .net releases, probably shifted by 6 months or so
i think it just feels long atm because we're stuck on 2020
yeah......it even feels long when you're at 2022
Didn't 2.1 come out in 2018 though :/
c#10 was only released 5? months ago
yeah nov 2021
(they aren't going to support it in preview as much as you'd like)
yes
Yeah and it will be out of date in 7 π
not really. .net 6 is lts supported for 3 years
yeah but .net 7 will be out in Novemer if they can keep up with the yearly schedule
anyway unity will make the .net core transition with .net 7 or 8
Really?
that's at least what they officially said
Huh
Time will tell
they don't have the best track record
I mean I hope they do it but I have low confidence
there's a thread on this if you are interested: https://forum.unity.com/threads/unity-future-net-development-status.1092205/page-16
josh peterson pretty decent with communication
yeah π
but it did hurt when i asked: 'when?' and the response was: '.net 7 or 8' π’ π
since i've been following this from before .net core 3.0 release
Yeah
What? but wouldn't the generated code have todo Mycode.whatever.System.X not System.X? You can't just have a random namespace expect to carry on from your current location?
OMG thats so dumb
optimally, yes. but the way unity has written the source generators is......well, not optimal in the slightest
If I rename to "Systems" the errrors start going away
that doesn't work
since when is that a thing
which source generators should prepend to literally anything
.....mostly
π€·ββοΈ
but pls don't put usings inside a namespace
i had an light discussion with someone on the internet a few months ago why using System as a namespace was bad
well who's laughing now
yeah nah
?
Uuuuh such a stupid issue to have π¦
i follow stylecop guidelines in my libraries which mandate usings inside namespace
Well at least Rider lets me bulk fix namspaces super easily
i follow microsoft c# guidelines and roslyn guidelines which mandates usings outside namespaces
also there are legit benefits of usings inside namespace
https://stackoverflow.com/a/151560
only if you have multiple namespaces in 1 file, which is horrendous and it breaks file scoped namespaces
well yeah that is a terrible idea
but that has nothing to do with that link i posted?
But then you get conflicts if you have clashing class names inside different imported classes
example?
and the standard project templates also put usings outside the namespace @rotund token
namespace a { public class same{} }
namespace b { public class same{} }
namespace ab { using a; using b; public class example{ public same instance; } }
I don't think I've ever heard of using inside a namespace
i've seen it, and i hate it
Then you have todo a.same and then it just gets really messy
i tested this example, i see no difference with the using inside and outside
it's funny, i've used it so long I hate it outside
and until file scoped namespaces it's staying that way
it's a compile error
it's a compile error with the using outside
is there an easy way for me to prevent the physics systems from being added to the default world
without going full custom bootstrap
why would it not be a compile error?
that's the whole point of a bootstrap
also: having them outside get's rid of horizontal waste
which is always good
don't I lose the autodiscovery of things if I implement bootstrap
yes but you get the same error if they're outside
why would it change in this example
it's still ambiguous
I'm starting to get fed up with DOTS in Unity 2020. Tutorials just don't work and I can't seem to get anything done. Should I just wait until the package is out of preview?
depends if you want to wait a year+
if you just want to smash out some games and not spend 6months learning it, then probably best to avoid
dots is for 'experienced programmers' even with 1.0. it won't just get 'easy'
Oh I figured inside the namespace would transfer to other classes in the same namespace but it doesn't. So what's the point of even allowing that?
allowing what?
using inside a namespace
for the reason i linked above?
microsoft created stylecop from their internal standard of using c#
oh I'm an idiot I didn't realize that IBootstrap took a list and you can just filter that... ty
then you can using other things in the other namespaces without including all before.....
i'm following most of the .editorconfig standards that are kept more closely an eye on. they default to using outside namespace
I don't expect it to be easy, I just expect code to work as intended and not spend hours just staring at the code trying to figure out why it doesn't work. Maybe I'll try going to 2019 to see if tutorials actually work.
if you really want to know you can read the justification here: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md
- Eliminating Type Confusion
Ignore 2.
code does work as intended.
*doubt*
if anything I find DOTS to be significantly less magical than Monobehaviours
what's calling my Update and Start methods π§ (/s)
frankly, i don't care. type confusion is bad style and just for removing horizontal waste it's worth putting them outside the namespace
Makes it harder to to parse the class cause you can't assume that the first X lines can be skipped. Probably just getting used to the whole thing though. Won't use it regardless cause it's pretty non-standard way of doing things....
doubt double
is 4 spaces on a few lines at the top of file really that big a deal
if you have 25 usings, absolutely
if you have 4, yes
i mean, they're auto closed by default for me so it's not like it's hard to skip
I work on stuff where I commonly have 30-40 worst case has been ~70....
closing code is a temp thing only. if you want to focus on something specifically for a bit. the next time you open the file all should be expanded again. else you suffer the same critical issues as when using #regions
i literally can not think of a time in the past maybe 4 years
i've ever looked at my namespaces
so i'm quite happy keeping them perm closed
i can be 99.9998% certain that you can do a lot of refactoring with that code then
how are you ever going to see if you're still using all of your included namespaces???? it is standard and errors if you have unused namespaces around
i dont
It's not a unity project. and There are a lot of pretty well organised sub systems that get used in the classes that are needed. For Unity I get to around 7 for the larger bit of code.
terrible
unused namespaces are a warning in my project
and i dont allow warnings
i literally turn warnings as errors on every few weeks
and fix them all
warnaserror only
i do doubt that 1 class uses 70 namespaces
and if there's more than 1 class, that should be extracted into a seperate file
I can't really show you cause it's not on my personal machine but yes. It happens when you work on large code bases.
i mean i won't argue on that, but i can only imagine a monolithic class that uses that many
has vs too
im sure there is (probably that hotkey since i use VS hotkeys)
It was 4k lines and then got split so that the base logic could be reused in a version that managed data differently. I think the base class is still importing maybe 50 things... It all depends how the rest of the codebase is organised really
idk, still just doesn't feel right
Give it a while when you get into a really big codebase π
what isn't working? we're here to help afterall
i've been, and i've never had to deal with that
There will be a class somewhere that has to integrate 5-6 different systems into one to do something very specific
I guess ECS helps keep the usings down if you only work with that
though here is 200 lines of pathfinding using 12 so π€·ββοΈ
yeah that's normal
I've sorta given up on DOTS for the meantime as tutorial code doesn't work and no google search has offered enough info to even get close to finding the problem. I can't even render an object. I'm gonna delete the current project and make a new one, and if that doesn't work I'll try downgrading to 2019, but if neither of those are fruitful I'm gonna put learning DOTS on the back shelf for another year or two.
just download the samples
they have rendering cubes in that for you
it's a much better source than most of these tutorials
Fair enough, I'll try it
moonboy just stick the object in a subscene or add the convert to entity mono to it
1 - you cannot use the built in render pipeline
2 - you have to enable gpu instancing on the material
3 - use the conversion workflow, don't make up archetypes yourself
it should "just work"
Once you get the basics of the api, then read unitys own guide on dots best practices to try get your head around some principles
https://learn.unity.com/course/dots-best-practices
'dots best practices' - updated february 2021
also.....oof there's not much
Monobehaviours "just work", there must be a reason you want to use ecs specifically? (curiosity is perfectly valid)
I wish that ECS worlds were separate though, from a threading perspective π’
nooo
yessss
nooo
1000 short ticks on world 1, 2 long ticks on world 2
but you can't exceed 4 frames before it doesn't like world 2 which sucks
well you can now
exactly
with the new world allocator
since 0.5?
though even though the changelog said they updated ecbs, they didn't
oh yeah i was meant to follow that up with unity
to see if it's going to make 0.50.x or 0.51 or delayed to 1.0...
So I can now have world 2 take 2 seconds to update and have world 1 run at 60fps?
I'm trying to create an n-body simulation, so I don't really understand how 'Convert to entity' would help when I need to generate 5,000+ entities on runtime. I really just feel like I can't learn without robust docs, it's how I taught myself Unity, I don't know how else I'm supposed to learn it sufficiently. I think that's the main reason I might just need to wait.
i was replying to this
but you can't exceed 4 frames before it doesn't like world 2 which sucks
Figure out how to render a cube, then move the move a cube, than go from there
you generate 1 prefab entity, then instantiate 5,000+ from it
Well when i was playing with it in 0.17 it didn't like it even when I had my own time system
just like you have a prefab gameobject and make copies if it regular GO world
you do the same thing for entities
The main issue was that it would get stuck waiting for jobs in world 2 to finish in order to complete rendering world 1. So world 1 got the penalty of long jobs in world 2.
so yeah if you want long running jobs, don't
use Run() and execute it in a separate thread
Like managed thread?
yep
use burst
and just let it run until it's done
if you want long running multi threaded jobs, think about your problem again π
Yeah....
because it doesn't make sense
I wanted like 20 of my threads to work on world 2 and 4 to remain on world 1
if you use all your cores up on a long running job, your game can't run
that's good, what if a player only has 4
World 1 = Max(2, threads * 0.25)
World 2 = threads - World1
π
If they have less than 4 just close
or 3, you can probably get away with 3
1 for burst threading, one render thread and one for the second world
(and I know the render thread does a little of the burst work when it's idle)
But I can't have that π¦
Tried that in 2020 and it didn't work and I found no indicators why, so I'm gonna try 2019 and see if it actually works. If it doesn't I'm just gonna shelf n-body sim for a while.
have a look at some of the Code Monkey tutorials for the release version of ECS and you should be able to get it rendering. If all else fails just grab the finished tutorials from GitHub and use that as a starting point where you know that rendering is actually setup correctly
Aight
Just pretty down and discouraged about the knowlege base rn
the docs are actually pretty good. but you have to do digging yourself
Yeah it's not the best atm. if you want to get really good docs and community tutorials you probably want to wait till 1.0
Well if you have not got a good base to work with there is a lot of conflicting information from ECS from the very first demo and then the 0.17 which was there for a year and a half and this version. Though at least there is a base that doesn't seem to change at this point π
why are you trying 2019? only 2020.3.30+ is supported
or were you wanting to use an old version of entities
he said he wanted 2019 cause it should match the old tutorials
Ye, this
PhysicsWorldIndex seems like a really weird addition
considering how much work you have to do to enable useage of non zero values
isn't there a field on authoring?
yea you can add entities to other worlds
but only world 0 gets simulated
I was expecting something like, they loop over the unique values of that shared component
and run all the worlds
but they do not
it's like, RegisterSimulation or something isn't it
oh wait no
that just adds to each index
hmm not sure haven't looked enough
i had some ideas for some uses of this though
but i haven't looked how hard to set it up
if it was easy to setup, nice to have a world with no actual colliding objects and is just used for spatial queries
I build and maintain a bvh
yeah so do i
i have a modified version of unities bvh
ah gotcha
though i have a much faster nearest neighbour search
well its about the same lookup speed
but i can build it magnitudes faster
just using a hashmap with a custom AddRange method
actually speaking of, i should release this method
what build speed do you get?
using 16 cores it takes like 1ms to add 100,000 entities
i can add 100,000 on a single thread using AddRange in 0.1ms
wut
oh i think i missed a total thing here
AddRange method for NativeMultiHashMap
but yeah it's ridiculous
before
after
this isn't a bvh
this is just a quantized hashmap
it performs about 4x faster than unitys bvh though for nearest neighbours lookups (about all it's good for)
let me load up my simulation i haven't looked at this recently
but the demo has 200k entities finding their 10 nearest neighbours in a few ms i think
the lookup is really 'dumb'
I think I would be able to calc the nearest neighbor in an array lookup or two though
it's just hashmap.TryGetValue(quantize(point), out values);
iterate all values doing distance checks
pretty much
makes sense
it performs 10% slower than fastest quadtree i could find
4x faster than unitys bvh
but it builds like 10x faster than the quadtree
yea optimized trees are expensive to build
my rust code always runs the same speed π€£
I might have to investigate some cheaper but less accurate build strategies
oops this was only 100k
but that's the cost
that first 2 tiny sections is the building the map (done every frame)
no no no
I haven't played around that at all yet
yeah here i'll post the code
i can memcpy the keys and values into the hashmap
then all i have to do is iterate the keys and generate hashcodes
and the whole thing is built
it's fucking beautiful
but yeah super happy with how much i've optimized this simulation over time
been like a little side optimization project i just keep coming back to when i have a new idea
ahh
they are following paths
and not colliding
it's a burst implementation of ORCA (rvo2)
200k!
yeah 200k elements added to a hashmap, 0.56ms only using a single worker
nice
how does your bvh compare to unity's? much faster for what you need?
I built it for use in gameobject land without the use of unities ecs packages
ah
funny enough that's what i was using the unity bvh for
figuring out what static gameobjects to stream in
i just store the bounds and index to the gameobject
gotcha
I think unities should build faster
but mine probably has better query time
I'll have to bench to check
mine is binary
I've benched it against another quad bvh
it's not as fast as i would like, but i think it's because it does a lot
yeah the thing the unity one i use in the work project never needs to rebuild
it builds once and it's good
it's not used enough for me to warrant looking at improving query time
but i'm always interested in things out there for future problems
code is here
I generate C# bindings for it
query perf is mostly about build strategy
hm
I wonder how fast I could do nearest neighbor search in my bvh with partial updates
proof of concept works! Serializing is much faster than deserializing (by design) as you often want to save while a game is running but loading can happen during a load screen. Only type, rotation and translation saved in this example (the rest is generated from the prefab.)
to register a component for serialization all you need to do is create tiny class
{
public override int Key => -1;
// Burst generic job support
protected override SerializeJob CreateSerializeJob => default;
protected override DeserializeJob CreateDeserializeJob => default;
}```
these map 1:1 to components so at some point in future i'll codegen them from an attribute on the class
this is a big difference to the system that we wrote at work where save systems map 1:1 to 'archetype' which might save an arbitrary amount of components
migration, while not implemented yet, will be done via a collection of small class just like this (so you can migrate multiple versions at a time if loading a really old save).
entity references are also supported
this looks clean as hell π
that's what i'm hoping for, migration api is currently leaning towards
public class TestMigration1 : ComponentMigration<TestMigration1.Test, Test>
{
protected override void Migrate(in Test oldComponent, ref ComponentSaving.Test newComponent) => newComponent.Value = oldComponent.Value;
public struct Test { public byte Value; }
}
public class TestMigration2 : ComponentRawMigration<Test>
{
protected override unsafe void Migrate(in void* buffer, ref ComponentSaving.Test newComponent) => newComponent.Value = UnsafeUtility.AsRef<byte>(buffer);
}```
depending on use comfort on unsafe code
we wrote 2 different save systems at work, the original with serializeworld which while very convenient for saving is absolutely useful for migrating data and making changings to your prefabs
while the second system, which i actually wrote, saves on a per archetype. it's been working well but it has a few quirks that i'm trying to iron out in this version in my own library
so i'm kind of merging them together to get best of both worlds
yep
what's the interface for SerializeJob?
protected unsafe struct SerializeJob : IJob
it's just a job
you don't need to implement anything
{
var idx = this.Data.AllocateNoResize<Header>();
int entityCount = 0;
foreach (var chunk in this.Chunks)
{
var entities = chunk.GetNativeArray(this.Entity);
var components = chunk.GetNativeArray(this.Component);
entityCount += entities.Length;
this.Data.AddNoResize(entities.Length);
this.Data.AddBufferNoResize(entities);
this.Data.AddBufferNoResize(components);
}
var header = this.Data.GetAllocation<Header>(idx);
header->Key = this.Key;
header->EntityCount = entityCount;
header->LengthInBytes = (this.Chunks.Length * UnsafeUtility.SizeOf<int>()) +
(entityCount * (UnsafeUtility.SizeOf<Entity>() + UnsafeUtility.SizeOf<T>()));
}```
the job currently
the file sizing is not ideal as it has to save entity for every component
but this is the cost of doing per component rather than per archetype
i could just save the index though for the key, i actually wrote a stride/slice method already for this to do that but just for the proof of concept easier to just use the whole thing
but yeah, serialization isn't really the hard part. lots of ways you can do this
You still can't generate a subscene from a list of gameobjects right
what do you mean by generate subscene?
there's nothing stopping you opening scene using editor scene manager, creating the gameobjects and saving the scene
bam subscene created - though i suspect this is not what you are looking for?
Yeah I meant from c#
yeah, so do i
a subscene is just a regular scene attached to a subscene component
what part can't you do in code for setting one up?
wait can u save an entire scene using DOTS?
File -> Save Scene (Ctrl+S)
How did you get the entity within a job again?
Need to get the entity the job is currently performing work on
By that I mean the entity which owns the components currently accessed in the execute method
void Execute( Entity ent , ref Delta delta, in Position position, in Neighbors neighbors, in Capsule bounds) is how I remember it being done before
That's for a job declared with a Foreach lambda
not from the execute method of a job struct
which job declaration are you using ?
Oh I misunderstood, it was late at night. Iβll have to look at that, I wanted to see if maybe I could make and save subscenes as part of a level editor build system
IJobEntity
Can you Dequeue a nativequeue in a job?
I don't use it yet (not migrated to 0.50) but manual says it will autogen an IJobEntityBatch. So you'll get a chunk matching the Query
So you could loop over the entities in the chunk like IJEB I assume
Does that help ? :p
or do you need details ?
long story short you need an EntityTypeHandle, and retrieve a nativearray from this handle, then you can loop your entity array like you'd expect
I mean from the chunk with the help of the handle :p
project is not open on my computer rn but feel free to ask if need an example
Anyone here ever experienced a dots related crash ? Im actually using entities in production and i have some users reporting that their app crashes.
Those crashes appear randomly, no pattern. I couldnt reproduce it on my devices. But i make heavy use of dots, so its either dots or android related. Unfortunately no one could send me their crash log yet, so im still stuck.
Anyone ever experienced a dots crash ? What was the reason for you ?
Hehe, that's why you don't use it in prod π
I know i know... but i didnt want to use entitas or any other ecs lib ^^ Its actually more like a alpha testphase but still pretty annoying... especially because i cant reproduce it.
Damn :/ Well i just saw theres a "backtrace" plugin which automaticly tracks crashes and errors and uploads them to a cool dashboard... gonna try this, hopefully it tells me why my clients are crashing
Sentry is pretty good as well π
Do I have to dispose ECB manually?
Getting thousands of memory leaks
Of course I have to
Where's the facepalm emoji?
_commandBufferSystem.AddJobHandleForProducer(Dependency);
We use backtrace, haven't used it on mobile but it should get you a dump and log which is a good place to start
I have Unit which spawns these prefab Entities: a single Officer, a single Formation, and many Soldiers. Officers, Formations, and Soldiers need to reference each other in their components. However, this can quickly become extremely complicated since instantiated Entities have negative indices right after creation, and should not be stored in components until the ECB has played back and converted the negative indices to positive ones. Are there any good patterns for creating and linking these spawned entities?
since instantiated Entities have negative indices right after creation, and should not be stored in components until the ECB has played back and converted the negative indices to positive ones.
ECB can update these indices for you
EntityCommandBuffer ecb;
var entity1 = ecb.Instantiate(prefab1);
var entity2 = ecb.Instantiate(prefab2);
ecb.AppendBuffer(owner, new CreatedEntities {Value = entity1});
ecb.AppendBuffer(owner, new CreatedEntities {Value = entity2});
ecb.SetComponent(entity2, new MyParent {Value = entity2});```
these entities will be remapped to the new created entities on playback
Thank you. The
ecb.SetComponent(entity2, new MyParent {Value = entity2});
I know gets remapped. However, regarding your two lines above that, would something like
var soldierEntity = ecb.Instantiate(soldierPrefab);
ecb.AddComponent(officerEntity, new SubordinateComponent { entity = soldierEntity });
not cause any issues? Where officerEntity already exists. Your example of
ecb.AppendBuffer(owner, new CreatedEntities {Value = entity1});
ecb.AppendBuffer(owner, new CreatedEntities {Value = entity2});
seems to imply that only certain ECB methods like AppendBuffer work
Also out of curiosity, how does ECB even detect if an IComponentData or IBufferElementData its manipulating has an Entity field, and thus knows when to remap newly instantiated entitues? Wouldn't this require reflection on the fields?
Are the DOTS talks from GDC going to be available?
they are already available but unlisted
any ECB method will remap
I kinda didn't get it, ECS related to Hybrid renderer v2 or this is separated projects?
@rotund token how do you actually handle blobs? also could you just codegen it to grab every ICD? Dont see modifying builtin packages to add an attributes everywhere being desirable
are you talking about saving?
yeah
i dont need to save blobs they're immutable
they will already exist on the prefab when i create it
there were some finer grain details regarding entity prefabs I was going to ask but its late and my mind is frazzled
the type of entity is saved then how i deserialize is, instantiate entity from prefab with all the default values then apply save data to this entity
this means you can update the prefab, add components, remove components etc
this is another flaw with using serializeworld it just gives you back what you serialized exactly you cant make changes to your game in the future
you can save entity references on components really easily, thanks to unity
private void RemapEntityFields(ref T data, TypeManager.EntityOffsetInfo* offsets, int offsetCount)
{
var ptr = (byte*)UnsafeUtility.AddressOf(ref data);
for (var i = 0; i < offsetCount; i++)
{
var entity = (Entity*)(ptr + offsets[i].Offset);
*entity = this.Remap.TryGetValue(*entity, out var newEntity) ? newEntity : Entity.Null;
}
}```
oh yeah came to me, uh how do you treat entities that exist in the scene that dont necessarily have a prefab equivalent floating about?
so existing entities (from subscenes) is something i'll tackle next weekend
thats one aspect from the one entity -prefab remap workflow(i think eizenhorn talked about) that kinda eluded me at least for some scenarios that I believed apply to my project
well i'll probably enforce all savable stuff in subscenes to be prefabs in my project
i could just use the actual asset in the subscene as the prefab
haven't seen what eizenhorn wrote about this
think it involved storing a hash of the blob asset during serialization and then remapping to the prefab when deserializing
anyway Im probably not seeing the big picture but the idea of creating a prefab for every single asset that might be in a scene kinda makes me wince
i'm surprised your assets aren't prefabs already
but anyway this basically follows the same rule as ghosts from netcode
Anybody has an idea how it is possible for a hybrid component (vfx) to be only visible in game view but not in scene view?
It is a vfx effect on a converted prefab
vfx isn't an approved hybrid component
{
typeof(Light),
typeof(LightProbeProxyVolume),
typeof(ReflectionProbe),
typeof(TextMesh),
typeof(MeshRenderer),
typeof(SpriteRenderer),
typeof(VisualEffect),
#if PARTICLE_SYSTEM_MODULE
typeof(ParticleSystem),
typeof(ParticleSystemRenderer),
#endif
#if SRP_7_0_0_OR_NEWER
typeof(Volume),
typeof(SphereCollider),
typeof(BoxCollider),
typeof(CapsuleCollider),
typeof(MeshCollider),
#endif
#if HDRP_7_0_0_OR_NEWER
typeof(HDAdditionalLightData),
typeof(HDAdditionalReflectionData),
typeof(DecalProjector),
typeof(PlanarReflectionProbe),
typeof(DensityVolume),
#if PROBEVOLUME_CONVERSION
typeof(ProbeVolume),
#endif
#endif
#if URP_7_0_0_OR_NEWER
typeof(UniversalAdditionalLightData),
#endif
#if HYBRID_ENTITIES_CAMERA_CONVERSION
typeof(Camera),
#if HDRP_7_0_0_OR_NEWER
typeof(HDAdditionalCameraData),
#endif
#if URP_7_0_0_OR_NEWER
typeof(UniversalAdditionalCameraData),
#endif
#endif```
these are the only valid hybrid components that work
I can see the rest of the prefab (mesh etc.) in both but the vfx is only visible in game view
if it's not on this list, it will be excluded from hybrid conversion
oh didnt know there was an approved list. all I know is it worked before.
It still works half way as it is visible in game view
unity locked down hybridcomponents in 0.50, no longer allow public use of the api and have a hard coded list of components they support
In which file did you find that list
CompanionComponentSupportedTypes
com.unity.entities@0.50.0-preview.24\Unity.Entities.Hybrid.HybridComponents\CompanionComponentSupportedTypes.cs
Hello! I am working on a racing game in **DOTS ** and right now I am tinkering with the concept of speed UP and **speed Down **zones.
I know how to make a TRIGGER collider but since in dots there's no Trigger ENTER and EXIT, I can't figure out how to approach stacking the speed modifiers on the objects that stay in there.
I was thinking of having a dynamic buffer with the **floats ** and adding them in a system before I math out my velocity, but it will keep being re-added into my buffer nonstop because I can't tell when it JUST entered the zone and staying in there.
there's a trigger enter and exit in the physic samples
So it should just not be converted at all? Because it works perfectly fine when putting it in a subscene
that's interesting, i'm not sure why it works
actually yeah you say it works in game view but not scene view is extremely interesting
You probably just have vfx disabled in scene view
to me it looks like they already implemented some part of this authoring/runtime view they showed at GDC
No. The vfx in subscenes work in both
Only the runtime converted prefabs work only in game view
as far as i'm aware no hybrid components should work that aren't on that list so i don't know why it's working
also the entity prefabs now pollute the active scene with disabled game objects π
what script is it called again
The new runtime changeability things look great, but I still think switching between play / edit mode will be common. Afterall you can't add code even with the new editing stuff
i think it's more for game designers tbh
Its called VisualEffect
Definitely. And really nice. Unfortunately not something huge for the programmers
Visual Effect is in the list. So thats why it works
But doesnt explain why it stopped working correctly when converting a prefab π¬
was going to look at some vfx in a few weeks
till now it worked well with just converting the prefabs. I have the suspicion that it must have to do anything with the conversion flags. But they are not documented anywhere
let me just re-read what you wrote originally
yeah so only runtime converted prefabs dont work
but subscene do?
yes
doesn't surprise me
but if the subscene is open while entering playmode the behaviour is still kind of wierd
yeah open subscenes break a lot of things atm
it still works but the companion objects start showing up in the hierarchy
if you look at netcode they specifically stop you entering the game like that
i do the same thing in my library
i don't expect this to work properly until 1.0 tbh
sad thing is there is still no solution for prefabs other than converting them at runtime. Would be nice to just be able to store converted prefab entities as assets. But till then I dont see any other option to populate my tilemap
i just store them all in a subscene
i use a similar system to the dots shooter sample with weak asset references
so i can reference across subscenes
Hmm. Do you know if its possible to put subscenes in addressables?
I am trying to keep the game extensible. Thats why I currently load and convert the prefabs from addressables. I dont really like the idea of using subscenes as containers for everything but if that works that might be the way to go
don't believe so
subscenes are kind of built like addressables already
but not sure how extendable they are
they actually load via streaming assets though
Argh. Just found this statement by Joachim:
"SubScenes and Addressables don't work together. They package their data independently if the same resources are used, they will be duplicated. We are planning to bring a lot of concepts from Addressables into DOTS as builtin functionality SubScenes is the first step. Next is addressable prefabs & deduplication of shared assets etc. "
Would love to have those addressable prefabs π¬
Hey all, does anyone know how I can automatically destroy particle effect entities when they have completed
the entities are hanging around despite looping set to false
I usually handle this by adding an expiration time component to the entity and having a system destroy or better pool it if Time > expiration time
yeah I have that system already, was hoping there was an automated way with particles. All good, it works fine with explicit destroy control
If there is I dont know it. With VFX effects I define a property in the graph thats called "Lifetime" so the system can read from it (if it exists) when adding the ExpirationTime component
@rotund token Do you know if its possible to reference and load a subscene? Or does it have to be embedded in a scene at edit time?
yes
2 primary ways to load subscenes
SceneSystem.LoadSceneAsync()
or the better way you can do it from jobs
add a RequestSceneLoaded component to the ResolvedSectionEntity.SectionEntity
you can unload
SceneSystem.UnloadScene
or the better way you can do it from jobs
remove the RequestSceneLoaded component
Great thanks for the info. I will see if I can use it to load my tileset
they have a backdoor to add more companion types to the list
not sure if they are calling it internally somewhere
AddTypeToCompanionWhiteList on GameObjectConversionSystem
all I know is that I also see all the non-convertable monobehaviors on gameobjects I'm converting attached to the entity as well
yea I'm not relying on it in anyway
(but that future is quite far away)
I may have found the root of my problem:
// Code never hit currently so outcommented:
// When live linking game view, we still want custom renderers to be pickable.
// Otherwise they will not even be visible in scene view at all.
//else if (!hasGameObjectBasedRenderingRepresentation && liveLinkGameView)
//{
// m_DstManager.AddSharedComponentData(entity, new EditorRenderData
// {
// PickableObject = pickableObject,
// SceneCullingMask = EditorRenderData.LiveLinkEditGameViewMask | EditorRenderData.LiveLinkEditSceneViewMask
// });
//}
Turns out instancing entities from a subscene has the same visibility problem. The VFX loaded in the subscene shows in Scene and Game view but its copy is only visible in Game view despite having the exact same components
Quick question, anyone know if there's a count of how many commands are in an ECB?
Or at least a way to know if it will playback
You could use IsEmpty
Is that set to true once Playback() is called?
Depends if the ecb gets cleared on playback. I am not sure but I dont think it is. I guess it will usally just be disposed after playing
As far as I can see it does not get cleared automatically so it will still be false
The ECB even has an m_RecordedChainCount and m_DidPlayback but sadly its internal and not exposed in any other way than IsEmpty
I've been wondering, what's a good way to plug in a (separate) networking system to ECS ?
I receive network messages with an ID that is associated to my Entity. I want to call something that will let me queue up these messages into either an entity (probably via buffers?) or into a system.
What is the advantage of using subscenes?
Say I had a level editor for an open world game, where different groups of objects are loaded and unloaded as the player walks around.
If I put GameObjects into the group in the level editor, exported the subscenes in an assetbundle , and then loaded those in my game, those GameObjects would be there presumably.
Am I able to add and delete GameObjects from a sub scene?
That was very convoluted
My question is: what is the advantage/point of using subscenes
subscenes are fast, gameobjects are slow
But subscenes contain gameObjects?
gameobjects get converted into subscene entities
To add to this, here's what I want to do from outside of any existing System
public void Move(int id, float x, float y, float z)
{
var entity = _characterEntities[id];
var buffer = EntityManager.GetBuffer<MovementCommandBufferElement>(entity);
buffer.Add(new MovementCommandBufferElement()
{
TargetX = x,
TargetY = y,
TargetZ = z
});
}
I'm sure there's a much better way. "Move" is called by my networking code when it receives a "Move" packet
more GDC content:
Explore the lessons learned from early adopters of DOTS, then addresses how Unity plans to transition this promising technology from experimental development to a released set of fully supported tools for the production of your games.
Speakers:
Laurent Gibert (Senior Manager, Product Management, Unity)
Lauren Frazier (CTO & Co-founder, Ramen VR...
-> jobified my whole catmullrom spline calcualtions in one go
-> activates every leak detection and debugger.
-> no errors and it just works π€ Something I have never experienced before
enabling support for simulating physics for all values of PhysicsWorldIndex turned out to not be that bad
Do tell
Then how do monobehaviours work on them?
monobehaviours get converted to components, outside of that they don't work
(except for a small set of hybrid components)
it was basically just, disable existing physics build, step, export, and final physics systems. Copy them into my codebase and adjust each system to do exactly what it was doing before except in a loop over all the unique values of PhysicsWorldIndex currently in the world
they must, it seems like they added this support for a reason
i am curious what prompted them to do it though
I was pumped when I saw the new component
but really confused
when I realized it wasn't really used yet
How did my own script work then? Was it transcoded?
i would have to see what you're doing, but in general they should be stripped
Hmm. I feel like Iβm close to understanding how all of this works, but Iβm not quite there yet.
I tried something almost exactly the same in my code except with Instantiate with a prefab entity rather than CreateEntity. I confirmed that that part of the code was being hit, but after playback, the entity still doesn't show up in the inspector. It doesn't seem to have played back. Here's what it looks like:
var spawnOfficerECB = new EntityCommandBuffer(Allocator.TempJob);
var random = Math.NewRandom();
Entities
.WithName("Unit_Spawn_Officer")
.ForEach((Entity unitEntity, in DynamicBuffer<UnitOfficerTemplateElement> potentialOfficers) =>
{
// Instantiate is confirmed to have been called inside here
})
.WithBurst()
.Schedule();
Dependency.Complete();
spawnOfficerECB.Playback(EntityManager);
spawnOfficerECB.Dispose();
there's no reason that wouldn't work if what you say is true
I'll show the actual Instantiate call
var chosenOfficerEntity = potentialOfficersFast[i].entity;
var newOfficerEntity = spawnOfficerECB.Instantiate(chosenOfficerEntity);
spawnOfficerECB.SetComponent(newOfficerEntity, new UnitMembershipUnitComponent
{
entity = unitEntity
});
potentialOfficersFast is a DynamicBuffer with prefab entities stored in the entity field
So I'm trying to set up a project with DOTS to learn how to use it. I found out that Burst had a new version available (1.6.5 from 1.6.4) and I had a bunch of errors, so I installed the new version, which got rid of all the old errors and replaced them with one new one about some 1.6.4 features being missing
oh hey I found 1.7.0 as well
okay so I found 1.4.11 which is the verified version, maybe I should downgrade to that one to improve the likelihood that everything's compatible?
Have you confirmed that ChosenOfficerEntity exists?
It's actually another oversight by me. The system that my example runs in actually runs from a Monobehavior's Start() callback. Basically, I have a coroutine that updates all systems inheriting from StartSystem, then disables those, then enables all normal SimulationSystems. I made the ECB work by introducing a one-frame delay in the coroutine so that all StartSystems run one frame after the Start() callback
shrug I guess that works. I've largely given up being a purist on DOTS system update order management so you do you.
Yeah itβs frustrating and full of gotchas
So I'm trying to install necessary packages to set up a DOTS project but I have a file missing.
error CS0006: Metadata file 'C:/Users/Marcus/Documents/GitHub/Unity_DOTS_Learning/Library/PackageCache/com.unity.collections@1.2.3-pre.1/Unity.Collections.LowLevel.ILSupport/Unity.Collections.LowLevel.ILSupport.dll' could not be found
I checked the Collections package and there isn't any other version I need to install. I tried regenerating the project files but that didn't work either
what version of unity
2020.3.21f1
that might be causing it, I made the project in a newer version, although I didn't get the 'you're opening this with the wrong version' message
entities 0.50 requires 2020.3.30+ (but doesn't support 2021 yet)
well I tried changing to a different version, it caused an error and when I tried changing back the error still occurred
I might need to make a new empty project in that editor version (which I've now installed) and try reinstalling all the packages
Thanks though @rotund token
Just confirmed that companion objects of runtime instanced entities do not render in scene view. No matter if converted at runtime or copied from a subscene:
Just made a system that copies all the entities of the subscene and offsets their position on the y axis
Hey all,
Am I understanding this right? - ECBs will always execute on the main thread, never in parallel (even with .AsParallelWriter())?.
Essentially, add/remove entities & components must always be done on the main thread?
in the end ECB will .Playback(EntityManager), so yes, it will go on main thread
@frosty siren Cool, thanks
How do I get entities from the main thread?
Would like to fetch entities within a chunk with a certain component
Doing this gets invalidated on structural changes
public void Update()
{
var handle = e_manager.GetEntityTypeHandle();
var chunks = e_manager.GetAllChunks(Allocator.Temp);
foreach (var chunk in chunks)
{
if (chunk.Has(e_manager.GetComponentTypeHandle<Node>(true)))
{
var ents = chunk.GetNativeArray(handle);
foreach (var entity in ents)
e_manager.SetComponentData(entity, new Capsule());
}
}
chunks.Dispose();
}
@gentle harness why you getting entities in a way like this?
The Capsule component's end points need to be set to the position of two gameObjects
Removed the data for brevity
I mean why iterating entities like this? Why not just use EntityQuery with component you need and then just use EntityQuery.ToEntityArray(Allocator) ?
Okay just thought of a way to do it within a jobified system
But this is not how I will be doing it in the end anyways, but I'd like to know how to fetch entities within the main thread
all systems are on the "mainthread"
in onupdate
you only go off mainthread when you dispatch to a job
Yes, but how can you get the entities of a chunk from the main thread?
well you can always do job
and run it on mainthread
via run()
instead of schedule
that's probably how I would write it
@gentle harness
private EntityQuery _nodeQuery;
override void OnCreate()
{
_nodeQuery = GetEntityQuery(ComponentType.ReadOnly<Node>())
}
override void OnUpdate()
{
var entities = _nodeQuery.ToEntityArray(Allocator.Temp);
for(int i = 0; i < entities.Length; i++)
EntityManager.SetComponentData(entities[i], new Capsule())
}
Oh, awesome. Thanks.
But remember to be a good boy and dispose your NativeArray π
The benefit to getting the entities on the main thread like Tony does here is that you can write quick test code without having to pass variables to a job
it will do dispose by itself if it allocated with Temp allocator type
in 0.50 there is job interface which let us write ECS system logic without passing ComponentTypeHandle, instead pass EntityQuery during schedule. Maybe i'm wrong but it may be a way to generate less boilerplate code and prototype faster. https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/ecs_ijobentity.html
I couldn't use IJobEntity for some reason, NullReferenceExceptions for just scheduling it
Has anyone gotten this error before?
Assets\2. RockStar\Spawner.cs(1,1): error SGICE004: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.InvalidOperationException: Sequence contains no elements
I can't get rid of the message. I tried deleting the script that it complained about, then it just complained about another script that was working fine all along.
Long time ago I had this. It was related to using a non-captured variable inside of a Lambda job. I.E I forgot to do a var time = Time.deltaTime
I was writing some gametick logic when it happened, but it was on a separate monobehaviour. I tried commenting out anything related to Time but didn't help.
Hmm found the source. Seemed to be something related to a component of IBufferElementData with a [GenerateAuthoringComponent]. If I switched to IComponentData or removed the attribute, the bug would go away.
GenerateAuthoringComponent is allowed for dynamic buffers too though
With some restrictions like 1 component per file with this tag and no MB
in the file
but you can put it close to a related system if you want, that works
Was it your case ?
I'm not sure what you mean, I just started learning DOTS. It's probably a compiler bug. Maybe it was because I had two components with the same name in different namespaces.
The stuff about Baking in the talk by uDamien, thats for later right? We're still supposed to use authoring components? or?
Yeah, sounds like they reworked conversion for 1.0 and are calling it baking. Not in 0.50.
I was confused because he showed that way in the beginning during the "refresher" rather than during the "coming in 1.0" part
i think its just a terminology change given baking is a more prevalent industry term
EntityStaticOptimization seems to remove Translation and Rotation, leaving only LocalToWorld, but does there exist a way to remove LocalToWorld as well for entities that have no notion of position at all? LocalToWorld takes up a huge number of bytes yet is unused for my entities that govern AI behavior
A way other than manually removing LocalToWorld during Authoring conversion
How does Unity ECS compare to Entitas as of the latest update?
write your own conversion system and remove it based off your own component
Ha u typed faster than me
Thanks. I was wondering if there was a "recommended" way of doing that like a special Authoring. You never know with DOTS
No there's nothing built in
Is the authoring better? I don't want Translation or Rotation automatically added to Authored GameObjects
Just make a conversion system called StripTranslation or something
And put it on all the GOs you don't want to have the positional components
That seems like such a pain in the butt for something that should be customizable.
have you ever been able to remove transform from a gameobject
it's nice to simply have this option
Well I'd argue that most things have position
So it makes sense to default to keeping it
LocalToWorld is already on the obejct
This is like 2 clicks to get rid of it after you set up
if you want localtoworld then just use EntityStaticOptimization
it does what you want already
remove transform/rotation
and just keeps localtoworld
if you don't want localtoworld then you need to write your own system to strip it which is what Abbrew was asking for
Except it wouldn't be a static object, so that may introduce other stuff
The transform system supports just using LocalToWorld and LocalToParent. I was having major update issues between setting Translation and Rotation. Which is why I opted to just modify the LocalToWorld
if you want to manually move the ltw around it will still work
which as far as I can see is the core thing that tells everything where something is
Whereas Translation and Rotation can be modified during a scene but then the end of the frame is when things are updated to LocalToWorld
StaticOptimizeEntity*
Plus I don't want to create an Entity, and then immediately have to move all it's data to another archetype just because of Unity's decision of how their transforms will work