#archived-dots
1 messages ยท Page 154 of 1
the video shows it btw.
the debugger shows that my BulletSpawnSystem picks up the 2 spawners.
so why isn't anything spawning?
So they have the correct components, but don't do what they should...
If you do a query to get the count for the entities in the system, does it output correctly (debug write)? What about a print line at the top of the inner block of the foreach/loop/job, does it run once per entity?
I think I've found the source of the bug
SerializeUtility.SerializeWorld(entityManager, writer, out temp);
"out temp" is not providing different referenced objects after passing in entitymanagers with different amounts of entities. It seems like it gets stuck on the first batch of entities sent in. I think that is why my references are getting messed up, thus blobasset problems.
{
Debug.Log("STARTING SERIALIZEWORLD");
var ents = entityManager.GetAllEntities();
Debug.Log("Number of entities in manager: " + ents.Length);
object[] temp;
using (var writer = new StreamBinaryWriter(_savedWorldFilename))
{
SerializeUtility.SerializeWorld(entityManager, writer, out temp);
}
unityMappingTable = temp;
string outObjs = "";
foreach (object o in temp)
{
outObjs += o.ToString() + " ";
}
Debug.Log("Objects in output temp1: " + outObjs);
saveCount++;
} ``` Is this enough proof for a bug report?
If you can make a minimal repro project with it, definitely
hmm cant get urp to work with hybridv2 now
was it new unity alpha, entities package, hybrid package, incorrect setup(of a blank urp example project) i swear debugging these kinds of issues literally drains my lifeforce
ok consistent crashes, definitely reporting now ๐ฉ
@safe lintel Did you get that combo of tech to work? I've tried but had the weirdest rendering bugs
Models seemed to randomly swap, rotations confused, scale changed or reset. But no crashes
I quickly swapped back as it didn't seem worth investigating
no, I did some tests but I use some straight monobehaviour injected things and I think its just too mind bending a problem for me to handle
haha
We must be somewhere on the scale close to BDSM... self inflicting pain ๐ค
yeah animation really needs a support group. not even a dedicated thread on the forums ๐ฉ
@safe lintel have you seen anyone try the latest drop?
Usually that's been me, but I haven't gotten around to it yet
i really want to start doing some graphics stuff, as it looks SOOOO bad but all these issues keep scaring me away
i installed it, made some really sad attempts to make it work but i have no clue, absolutely no clue ๐
i dont think animation works with URP
@ocean tundra it "works" but no gpu instancing, hence all your models will happily animate "in sync"
I just don't understand why they don't just update the fricking samples when they release a new package version
I mean someone must have some code that produces results...
well thats better then i thought
even though graphics/hybridrenderer is buggy, at least you got pretty good dev communication on that end. all the recent releases have been minor or just updating dependencies, something more meaty feels due soon
@spark glade when you say "in sync" you mean they all play the same animation at the exact same frame?
yeah, let me try to find the post...
Can't find the unity forum post.
But yeah, I tried for many many hours all sorts of combinations of URP/HybridV1/V2/...
In the screenshot you can see that all the units in the 50x50 grid animate exactly the same. With HDRP it works just find, aka all animate individually.
And here are some attempts with the 0.4.0-preview-1 release from about 6 weeks ago: https://github.com/Unity-Technologies/Unity.Animation.Samples/issues/14
Haven't tried 0.5.1-preview.1 yet. But will do, probably this weekend.
they changed up the way rootmotion is handled though the existing way still works(just marked as obsolete).
as one of the main changes
Hey Guys
I'm needing to do this around most of my 'message' related systems (networked RTS game)
/////DO JOBS AND FOREACH's
messageContainer.WriteJobHandle = JobHandle.CombineDependencies(messageContainer.WriteJobHandle, Dependency);
Can anyone think of a nicer way to show/write that
Maybe a custom Entities.WithMessageJobHandle... that can do that combine bit
or a using statement 'thing'
Can we even make custom code to interact with the system code gen?
if I query 100 entities in a Entities.ForEach()... and put a debug.log message in it.
would I get 100 debug.log messages?
yea you should
hrmmm
i think in the systems view when you select a system you can see how many entities it will run over
but if they are one offs maybe thats not so useful
also the systems view is useless to me as i use custom worlds, so that could be wrong/out of date info
we're at our wits end here trying to find a reason behind a strange error that endlessly repeats in the console, but only on one machine in our team. the other people with exact same commit don't have it:
LambdaForEachDescriptionConstructionMethods.ThrowCodeGenException[TDescription] () (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/CodeGeneratedJobForEach/LambdaJobDescription.cs:392)
LambdaForEachDescriptionConstructionMethods.ForEach[TDescription,T0] (TDescription description, Unity.Entities.UniversalDelegates.R`1[T0] codeToRun) (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/CodeGeneratedJobForEach/UniversalDelegates.gen.cs:339)
MyNamespace.MyTestSystem.OnUpdate () (at Assets/Content/Code/MyNamespace/MyTestSystem.cs:47)
Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/SystemBase.cs:414)
Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/ComponentSystemGroup.cs:445)
UnityEngine.Debug:LogException(Exception)
Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/Stubs/Unity/Debug.cs:19)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/ComponentSystemGroup.cs:450)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/ComponentSystemGroup.cs:398)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/ComponentSystem.cs:109)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.11.1-preview.4/Unity.Entities/ScriptBehaviourUpdateOrder.cs:192)```
what could be causing it? it completely cripples editor work for one of the members of our team but we can't find any information about it beyond a vague patch note in Unity 2019.3.15 (we're on 2019.4.1, long past that release)
removing ScriptAssemblies helped but it would've been great if this was communicated anywhere else aside from a one off comment in this Discord dating a few months ago that I was lucky to find ๐
maybe the error itself should point out the possibility of removing assemblies folder in the Library
@plush stirrup What sort of script assembly is it? asmdef or external dll?
we don't use any assemblies with Entities systems
maybe the code generator just hit some sort of an error and filled that folder with output that prevented it from running correctly on the next go
i use a TON of asmdefs
no issues so far
but i am on 2020.1
no clue if that is a important difference
we had some problems with WWise audio library today - their Unity integration is horrifyingly unstable and runs right in edit mode, occasionally popping errors on assembly reload
it's not a huge stretch to imagine some error terminating an editor update prematurely, throwing a wrench into what entities codegen was doing
side question, why use wwise for audio? what does that do that unitys normal audio system dosnt do?
ps i know almost nothing about audio in games
This is a bit off topic for this channel but there is little choice beyond relying on WWise or FMOD for projects with complex audio, or at least that's the opinion of audio team we rely on. To compare, the difference between capabilities of built-in audio system vs. dedicated third-party libraries is akin to a difference between legacy Animation component and Mecanim Animator system. It's almost a standalone layer of the game with its own logic fully controlled by an audio engineer, where they can set up crazy procedural music responding to inputs we send over, control the mix with ridiculous level of precision etc. The level of audio complexity and polish we get out of it is very nice.
That said, if I could go back in time, I'd seriously consider going with FMOD instead of WWise because WWise Unity integration is just unacceptably bad at times. We avoid using almost all components they've built and only interact with bare minimum of their bootstrap/bank management stuff and it still manages to break frequently. It's a true enterprise grade solution in a sense that only big projects can afford the time to deal with it's bugs and horrible side effects. Just today we had a WWise upgrade script that copied our whole repository (70gb) to a temporary folder without asking to modify a few prefabs (and corrupted said prefabs in an attempt to helpfully "optimize" them). Later in the day WWise script also consumed all space on the drive of one of our team members due to horrifyingly designed recursive directory copy method that just went into infinite loop of creating new subfolders and copying giant banks (this was only stopped by Windows path length limit triggering a hard exception at some point, otherwise the process would've continued running indefinitely).
Sorry for ranting, I'm just salty about what should've been a simple .dll replacement wasting our whole day today. ๐
Thanks for the overview. Audio is one of the parts of Unity i know least and i never seem to get round to implementing it
maybe ill check out FMod when i want some audio in my game. Also what about that new DSP?? thing unity has in ECS for audio?
I'm very much looking forward to playing with DSPGraph (or what Unity builds on top of it by the time we get there) on our next project
oh they clearly say thats its to replace FMod ๐
hmmm 0 docs and no update since 2019
sadly that's often the story with these things, I'm not hoping for any updates till late 2020 cycle
yea that bit is VERY out of date
it was demoed with Megacity and not much after that, I think?
yea i think so
they probably built it specifically for megacity then have left it since then
oh there was a talk at Unity Copenhagen in Sept 2019, got to track it down
oh well audio is always last on my list ๐ so hopefully in a year or so they will have it ready
@plush stirrup back to your main problem and a side idea to fix it
Could you move most of your WWise stuff out into a side project and have it build into addressables and load those?
it may keep its errors more managable if you dont have a 70gb sound library
Unfortunately not, it's a very rigid native plugin that only works when used "right". 70gb isn't our audio library size, it's total project size (upgrade script just copied it all for some bizarre reason ๐ )
In any case, we fixed it by clearing script folder in Library, so its all good ๐
another idea is to wrap all the WWise stuff in a #if define, then you can have that off 90% of the time and have it switch back on during builds and when you need it for sound stuff
oh sweet so all happy then
70 gb is crazy
WTF i just checked mine and im at 6Gb
no clue how
77k files ๐
are we flexing on project size?
๐ yup
๐ nice
What does GameObjectConversionUtility.ConvertIncremental() do that the other convert methods dont do?
I thought there would be some sort of handle or thing i could wait for or tick to update over many frames
I read this:
This method should have been replaced by codegen
As the magic DOTS codegen failing, which is most definitely a bug (probably in DOTS, possibly in your code doings something very wrong). As for how to fix when different team members with the same unity version may or may not experience it for the same code, there might be some settings in Unity, but I think you need deep, deep help from someone who's familiar with the codegen to even have a chance...
I am still trying to figure out how to represent a grid in the dots world. Right now I have 2 solutions in mind.
- The grid is an entity with a grid component and the GridPosition component has an entity field to link to a grid.
This seems pretty similar to the MonoBehaviour way to me, which might be an indication that its bad for the DOTS world? - Have a SharedComponent referencing a Grid (could be an object) similar to the Material component.
This might have the advantage of grouping objects by grid although it feels weird needing a pointer to an object in the Shared component in order to change any values (e.g. cell size) easily
What's the use case here?
Just having arbitrary entities placed on a grid? Or some kinda grid-based terrain? (think Minecraft/Terraria)
Placing tiles on a grid with a height offset, so kind of in between
We already talked about that a few days ago if you remember @tawdry tree
Oh right, it was that one
But I did not come to a conclusion how to represent the grid specific data like cell size and maybe even translation/rotation of the whole grid
For that, hmm... Probably a singleton entity with grid settings (cell size and such)
now that I think about the translation/rotation bit it might make sense to rebuild the usual gameobject hierarchy with the grid as a parent entity in order to use the translation and rotation systems
You're gonna want a helper to convert between coords anyway, and with that and Translation you don't strictly speaking need anything else. Might want a tag like UsesGridTag
Why would you parent them? Do you intend to move the entire grid?
yes there might be multiple grids with different positions/orientations
i would not move them at runtime though
so I am not sure if this parent relationship would cause any overhead at runtime
That complicates things slightly, but can still work off of Translation+BelongsToGrid(Entity reference to grid entity) and a helper
in gameObject world I just handled it like this:
public Vector3 CellToWorld(Vector2Int cell)
{
return this.transform.TransformPoint(CellToLocal(cell));
}
You'd want a way to generate a matrix for the local directions, which the parenting stuff might help with
Then you could convert between world and local pos and back easily and "cheaply"
so right now I have a CellPosition component and the GridPlacementSystem which just sets the position. If the entity is parented to the grid entity the TRS System? (not sure what it was called) should move and rotate it to the correct world position afterwards right?
Maybe? Haven't touched the parenting system, but it should be quite easy to check, no?
Is there some kind of entity listener we can use to trigger a callback once a certain component was added to the ecs ?
There are methods on the Entities.ForEach structure to check for stuctural (ICD) cahnges
How do i use them ? ^^ Probably i missed that in the documentation... i basically just wanna execute a piece of code once a certain component was attached
Honestly, the simplest way is to just add a bool HasInitialized on the component, or adding another component (tag) to mark it as done.
I forget what the exact methods are called, just that I've noticed them using intellisense on Entities.
@tawdry tree Thanks ! I hope this only gets executed once... i thought theres another way, other ecs frameworks mostly offers listeners getting executed once a component was added or removed which is extremely helpfull
If you want to make 100% sure it's only run once you should add a tag or boolean in the component
I don't know if there are listeners. There might be but I haven't seen any (nor have I looked)
Hodhandr.
If the game is suspended would the systems still run?
what about the plethora of blob assets I made? would they get leaked?
i thought about this... but its too dirty for my usecase... i also use ComponentObjects which makes this harder
There is such a thing as EntityChanges, thouhg. I think it's mainly for internal use, though.
mfragger - suspended how?
DOTS game on android. User pressed the home button. Does other stuff. then returns to the game.
that kind of suspended
Depends on how unity handles that, but I assume the game is effectively paused. if they switch back in time, anyway; in my experience apps need to reload if you wait too long.
Systems will definitely not run.
I know there are events to catch an app being suspended in android, though not sure how accessible they are in unity. I suspect you'll be fine as long as you dispose in the appropriate locations.
Is there a way to make structural changes during a schedule ?
During? No.
You would either need to use Run() and do it with the EntityManager afterwards, or use an EntityCommandBuffer
Alright, thanks ^^
So i tried .WithChanges... didnt worked, printed all entities even if they didnt changed at all :c
because it works on chunks, not on entities
lets say you have 5 chunks, each of them has 10 entities in them, you do a WithChangeFilter on it, if one of the entities's data changes, the chunk that entity belongs to will 'increments' version, so all 10 entities in that chunk will be processed, but not other 40
The "dirty" way is probably the best. It's not even that bad
@opaque ledge Oh... thats why, thanks ! So theres really no way to listen for newly added/removed components in unity ecs ?
are you aware of system components ? they are designed to work with listening to adding/removing components and creating/destroying entities, so great way to run a system when component is added or removed, kinda requires some work tho
i think there should be an example in manual
Thats exactly what i need ๐
gl^^
Im gonna take a look at those, thanks ^^
does shadergraphed materials work with hybrid v2?
why i cannot tryadd on a Nativeashmap inside entities.foreach ? i remove parallel restrictions and i using my own struct as key
i think is about race condition
but i dont know why tryadd is thread safe
or maybe it is about my own struct key ?
What error do you get?
hard crash, huh
Well... this is what the safety systems are for - stopping you from doing whatever crashes unity here.
Disabling the systems ins specifically if you know what you're doing, and know it is safe - TryAdd is clearly not threadsafe, which makes sense because it needs to do a bunch of checks
What are you trying to accomplish? You should probably look for alternative paths to your goal
i will share u the code
wait
could u say me the web where i can share code with u
please
Pastebin, hastebin and such
But if you have enough code that you can't post a snippet here, that indicates you might have something overengineered
Anyone familiar with SystemStateComponents ? I wanna use them to detect the creation/removal of entities... the problem here is that when i destroy a entity, all components excluding the SystemStateComponent getting destroyed... that means if i listen for a destroyed entity by its SystemState i know that it was destroyed... but i dont know which components it had previously... any idea how i could get that destroyed component ?
genar, why do you need the destroyed component? If you just need to know which components were destroyed, you could put that in a SystemStateComponent (I think - a flag enum should do), but if you want the data, capture it before deletion
i run it on schreadule and works, it is about parallel
"works ", i get a bust error but at least didnt crash hard
burst*
Fist impressions: It's HUUUGE! Consider moving the entire switch case to a static method. Second, this is a good spot fora swicth expression, if you're on 2020
i think i am xd
@tawdry tree Hmmm... thanks, im gonna try to store the components somewhere ^^
it is better declare it as removeparallelrestrictions, .parallelwiriter was only a try
genar, this is a good use case for a flag enum, assuming you have a known amount of components you care about
hodhandr the main idea of that code it is only create one entity with the same vertex and occluder
i mean no duplicates
lmml, there are reasons why you have those restrictions; you're threading in unsafe territory here.
@tawdry treeI actually wanna track all added/removed components... kinda like a reactive system, a simply flag is not enough :/
If you're building a mesh, consider building each mesh separately, in a job where each instance of the job has its own array of vertices. Then a second job could do cleanup
genar, that sounds overengineered, bad pattern, and likely to cause maintenance or performance issues
Performance isnt that nessecary at all... im using the ecs for its maintability due to bad oop experiences... nearly every major ecs framework has methods like "manager.onCreated<PlayerComponent>(callback);"... so if unity does not offer this, its probably time to create such a system on my own using those SystemStateComponents :/ thats why i wanna track all of them
lmml, I haven't gotten quite so far yet, but I am working on a voxel terrain mesh generator. The plan is to do it in two steps, one to generate the mesh (duplicate vertices allowed), and a second to clean that up if needed.
i could do the same i guess
Another problem here is... i havent found anyway to receive all components of a entity
genar, Do you really need to listen to all changes? I've come to the philosophy that with ECS, you want to make systems as general as possible, while still being specific to your use case... overgeneralizing is a maintainability issue in itself
I wouldn't share ideas if I didn't want people to be inspired by them, now would I?
thx u hodhandr ๐
It also makes for more single-responsibility jobs, which is nice
And as a bonus, if i later want to generate something that is not terrain, I can use the same mesh cleanup job on that
Well atleast i want to have the possibility to listen to all component changes... actually i just need add/remove listeners for a handfull of components, but im in search for a generic solution
If you only need it for a handful of components... just implement it for those, but in an extendible way (so you can easily slot in other components later)
@tawdry tree Well... that could work too... the main problem is to detect such changes... im searching till ages, that StateComponent isnt that usefull either, because its only good to track the creation/deletion of entities... not of components
Why do you need to detect changes?
Because i wanna react to a newly added component... world.Created<Mob>(() => {Log("Mob spawned"); }) for example... my usecase is a bit more complicated due to the hybrid ecs
So i need a way to detect if a component was newly added without a flag... i wanna have clean, flexible, loose coupled code... i made too many mistakes in the past where i needed to rework my whole game
can you tell us your use case specifically? what you're gonna use it for?
If you're using it for doing first-frame work on newly spawned entities, I'd say just use a tag for that, NewlySpawnedTag or something like that, and have a system running really late remove it the first ECB of the next frame
Yes, it causes a structural change, but it would happen rarely, is simple to make, simple to expand, and very loose coupled.
Due to my hybrid approach i create gameobjects async using the unity adressable system... once that gameobject was created a callback runs which adds it as a "ObjectComponent" to its ecs representation... Once that GameObject was assigned as a ObjectComponent, my animation system should get a callback in order to get the animator and several other stuff from the gameobject... that would be fucking easy... IF theres a way to listen for newly created/destroyed components :/
maybe add a tag to it so you can track it with a system?
then remove the tag once the stuff you need are loaded in
That could actually work... and i think im gonna do that... but damn, i really wanna have a reactive system, even if its not that performant
you mean... you want a way to throw an event if there's a struct change?
and basically "interrupt" current operations?
hrmmm... thinking about it. there isn't a way to do it.
The best you can do is queue it in a CommandBuffer and play it back at one of the pre-built in hooks you can use
I think adding and removing components works fine for now, should get better too. Posted by unity guy
You want some sort of a state machine / event system. Right now you think that changing state via AddComponent / RemoveComponent is too expensive, because it moves archetypes.
We have found a similar problem in Dots shooter. But it really depends on the frequency of the addcomponent / removecomponent calls, is a perf issue or not.
That is why we are currently working on adding Enabled state to all components. This way you can enable / disable components from any job safely without changing the structure. Entities.ForEach will automatically do the filtering for you. It will process only the entities that match essentially a disabled component appears as a component that doesn't exist.
Internally this is done via packed bitfields across multiple entities and SIMD bit mask tricks so it will be quite efficient.
In Dots shooter our plan is then that during conversion you setup all possible components (Enabled or disabled) and at runtime you simply enable / disable components. Our game code team also prefers this approach since it will be clearer to have all possible components already present. So its easier to identify a specific type of object in the world...
That sounds like it should solve your problem...
So the question what do you do for now, until this feature lands.
In DOTS Shooter we are simply pretending the functionality exists and are putting a bool Enabled; in each of the Ability System components. And then we do the filtering manually in Entities.ForEach in the first line of code.
It's not optimal but it gets us to a place where we can structure our game code how we want it to be and once native support for enabled / disabled components lands we can simply remove all of the .Enabled bools and let ecs take care of the filtering for us.
Yes... enable and disable... highly anticipated
tags are great, their very lightweight to remove and add. but it's kinda, for lack of a better term, imo, somewhat disrespectful to the hardware if we move entities all over memory.
Posted by unity guy heh ๐
Had forgotten who, was Joachim https://forum.unity.com/threads/dots-skill-system-repo-available.894007/
Edit - repo available here https://github.com/WAYNGROUP/MGM-Skill
edit - Changed title to better reflect most of the content of the thread.
Hi,
I...
So i looked into those StateComponents and came along with this : https://pastebin.com/Mb6ziDfk
Not sure if it works without any issues... but it could be used as some sort of reactive system
I was wondering why Unity kept hanging when running this one system...
Turns out at some point I refactored away the safety guard on my while loop that should stop it from running forever... oopsie
I'm saying this because it seems like people think I know what I'm doing ๐
most of the time you do though
I suppose
I can almost assure that some of you have worked more with ECS than me
Then again I have a good mind for programming, keep lurking here even when not active, and may or may not start to really grok the whole DOTS thing
I suppose I might be at the far side of the Dunning-Kruger hill...
Does anyone know the difference between math.distance and math.distancesq?
distancesq does not take the square root between 2 vector positions when calculating the magnitude
distance takes the magnitude between 2 vectors and then square roots it
So... both are broken?
?
With "should" it sounds like they don't do what they should. Do you mean "do"?
oh - yes, do not should lol
Oh new unity beta version.
I wonder if there's a package update too
Does anyone know of a way to name entities spawned using ECB.CreateEntity(EntityArcheType)?
dont think you can name entities with ecb right now
yeah you cant, but if you instantiate, newly created entity will have the same name
Spawning from archetype, so that doesn't really help. Oh well, it's not really important, but i figured it might be useful down the line for debugging, since this system quickly makes a couple thousand entities.
During? No.
You would either need to use Run() and do it with the EntityManager afterwards, or use an EntityCommandBuffer
@tawdry tree Yes. ExclusiveEntityTransaction ๐
Hmm, I don't care about it enough to create a sync point like that
But good to know!
So... both are broken?
@tawdry tree both works as expected.
They have edited the message, it was a bit poorly worded at first
Anyone having a idea how we could make a reactive system depending on "SystemStateComponent" more "generic" ? Heres my current attempt... would be great if someone could take a look at it ๐ https://forum.unity.com/threads/reactive-system-generic-way.919997/
Does anyone have a good strategy for making an ECS library and managing the dependencies of systems? I have the following "problem":
My library will provide a bunch of systems with dependencies between each other. The game I'm using has a few system groups set up, let's call them BeforeTheGameStartedSimulationSystemGroup and AfterTheGameStartedSimulationSystemGroup, which I used enable a bunch of systems that are specific to my game. The problem is that the systems from the library obviously don't know about these specialized system groups. So what are my options?
I could disable auto creation of the systems and manually somehow manually add them these custom system groups? Or I make all systems abstract and override them in my game with the respective dependencies?
you can put these groups into your library, but that might be annoying for users to have a bunch of extra groups, and they still wouldn't be able to order them as needed.
i tried at one point to have a system that is essentially a loader for the other library/package systems. It would allow the user to customize where the library stuff should be placed within their project - group/system/before/after etc.
i wish this stuff was just built into ECS already :S
Sounds like a pretty specialized use-case, so I can see why they haven't spent dev-time on it...
My other solution is to have one big monobehavior and manually enable/disable 100 systems instead of just 2 groups :/
i would say leave it as monobehavior
to allow people to customize it relatively easily
i think as this matures we'll see a lot more of the unity marketplace providing ECS systems in packages, where they go in your project setup will matter.
Yeah, but I don't expect this kinda "polish"/QoL until at least v1.0
true!
maybe I'll just copy my library code into the project ๐ I'm my only user anyway, haha
Beware overgeneralization, hm?
Or maybe my library shouldn't be a library but more of sample code one would start off of and modify ๐ค
Any possibility to store a struct/class type inside a burst compiled struct ? Is this allowed ?
https://docs.unity3d.com/Packages/com.unity.entities@0.11/manual/component_data.html#managed-icomponentdata
Managed ICD is meant
to help port existing code over to ECS in a piecemeal fashion, interoperate with managed data not suitable in ISharedComponentData, or to prototype a data layout
But it cannot run scheduled anymore, right ?
Well, something like that - it makes everything a massive pain.
Damn... i hoped thats the way i could solve the generic problem with reactive systems... currently using ISystemStateComponents you are "forced" to write one reactive system for each component you wanna listen too... too much boilerplate code, i hoped i could use a buffer component in order to safe the component type that changed with the information if it was added or removed... this way it wouldnt require a "Health" -> "HealthAdded", "HealthRemoved" component anymore
I wonder how hard it is to automaticly generate those structs... but that would be a huge overkill
You can get an entity's EntityArchetype, which would let you get a NativeArray of the ICD types.
It is itself a struct (probably just an index like Entity), so yo could store the EntityArchetype in an ICD.
That would let you compare the before and after, at least if you make some helpers to compare.
That could work too... damn, why dont they just provide one by theirself xD
Because that's not where their priority should be at the moment?
It sounds like it would be very useful if I needed it, but most people are more concerned with the core APIs and use cases at the moment.
I can't see them not making an official solution to that at some point, but it'll be after 1.0 and likely after the way to turn components on and off mentioned some time ago (4-7 hours?).
so i have a problem that i'm failing to find on google
it's hard to even put into words
i'm learning ecs by doing a minecraft-like game (uninspired i know) and i'm able to generate a flat dirt world but my character is bumped weirdly by the ground when walking
basically it's like i was hitting the edges of the cubes even though the world is flat
and i'm really lost as to how to fix this :(
sorry if this is the wrong channel and thank you for any help you might provide
@mighty whale did you try to use the physics debug component to see if your colliders were good ?
and be careful, that thing needs to be a singleton
<- learned that the hard way
mh i am not aware of the physics debug component ahah, imma try that thanks :D
right channel
@mighty whale this is kind of a by design thing of unity physics
i think its called contact welding which havok has options for, might have to code something for unity physics
might be an example of it in the samples repo, there should also be things on the dots physics subforum if you search it
thank you for this, adding "contact welding" to my search indeed led to relevant posts ! i would have never found it myself lol
okay...
var arch = dstManager.CreateArchetype(typeof(SpawnerEntityData),typeof(SpawnerNumberData;
dstManager.SetArchetype(entity, arch);
this doesn't work now
like... am I going crazy?
How fast is entity GameObjectConversion ๐ค ...
public void Convert(Entity entity, EntityManager entityManager, GameObjectConversionSystem gameObjectConversionSystem) {
var stopwatch = new System.Diagnostics.Stopwatch();
stopwatch.Start();
var prefabRegistrySystem = entityManager.World.GetOrCreateSystem<PrefabRegistrySystem>();
for (var i = 0; i < prefabs.Count; i++) {
var prefab = prefabs[i];
var prefabEntity = gameObjectConversionSystem.GetPrimaryEntity(prefab);
/* Extract the entry authoring from the prefab, so that we can use it for efficient lookup when the prefab is needed in other systems: */
var prefabRegistryIdentifier = prefab.GetComponent<PrefabRegistryEntryAuthoring>().prefabRegistryIdentifier;
prefabRegistrySystem.Add(prefabRegistryIdentifier, prefabEntity);
}
Debug.Log($"PrefabRegistry: {stopwatch.ElapsedMilliseconds}ms");
}
40 reasonably complex prefabs
1ms
Can that be correct?
Sounds fair enough, it's pretty heavy and something you generally want to do with the sub-scene system or otherwise at start only
I'm very happy how fast that is. I had never measured it before and came to a point where I'd be 3x-ing the number of prefabs, or go down a more complicated route...
Seems like I can just go the easy way haha ๐
Another question:
Say I have 2 prefabs. They both reference the same mesh.
- ECS just keeps the reference to the Mesh, but doesn't clone it or whatever, right?
- So memory consumption wise it should only exist once?
- SRPBatcher or whatever batcher is at work should be smart enough to properly batch the mesh drawing, right?
1+2: ECS RenderMesh uses Material and Mesh classes, so they're by reference and shared (unless you load it twice)
Dunno bout 3
I guess the easiest to verify 1+2 would be to see if they end up in the same chunk, right? (bc different ISCD for the mesh would force them to different chunk, wasn't it?)
Or am I remembering that wrong ๐ค
Correct
Why does new ComponentTypes take a managed array of ComponentType where most API's return a NativeArray instead
Not sure what you mean by new ComponentTypes, but several APIs take component types by param, meaning you don't need to actually send in an array, you can just give it however many of the thing you need.
Also, NativeArrays has this method:
public T[] NativeArray<T>.ToArray();
Has anyone successfully used EntityManager.MoveEntitiesFrom to move entities between worlds lately?
can someone check my sanity...
why is it...
math.cos(180) = -0.598f
isn't is supposed to be -1?
am I inputting the wrong unit the mathematics library?
@tawdry tree Sadly the conversion from NativeArray to managed array will allocate here
Usage of params does allocate a managed array under the hood as well
mfragger: Pretty sure th math lib uses radians. Try with that?
well then
math.sin(math.radians(180)) = -8.7
math.sin(180) = -0.08
it's supposed to be 0
Oh but 90 works!
wth
and 270 works!
but not 180!
oh ooooh!
I see.
It's a floating point number accuracy!
the math lib is so accurate that it wont return 0.
@stiff skiff https://github.com/stella3d/SharedArray I came across this recently which allows you to implicitly convert between NativeArray<T> and T[]. Looks like it's achieved by pinning a ptr
ahh hackweek
hackweek makes me sad, they used to do it super in the open, with video or page with all the hackweek projects
now you get 2 o 3 employees telling about their hack week on tweeter
i guess because peoples expectations were high(i mean mine were). like the distributed light baking thing they showed eons ago
I remember one where they enabled c++ scripting, seemed cool at the time
*high that it would get rolled into the editor and not be a one off hey check this out lol forget about it actually
now dots seems way better
I get why they stopped making them super mega public, but unless you go totally dark not letting anyone publish anything, then a forum thread with huge disclaimers would be nice
or maybe its just that it only just ended and they havent had time to write up about it? with everyone working from home its kinda less exciting than making a big show of pictures of everyone collaborating together from a pr stance
@coarse turtle It does this by just always allocating the managed array
ah true
To give some context, im trying an experiment in where I want to merge 2 entities
This requires me to take the archetypes of both source and destination entity, and merge their unique component id's into a new list, which is then used to update the archetype of the destination entity
After which I copy over the data from each component that was present on the source but not the destination
o i see, so the EntityArchetype - when you grab its ComponenTypes, just returns a NativeArray, but when you create the new archetype from the EntityManager, it uses a managed array, and you want to avoid that right?
Something like that
Heyo, I'm having a really weird issue with unity's IJob system. Anyone here know anything about it?
I'm trying to run several jobs in a priority queue, but when the same type of IJob (a new one of the same struct) finishes, it gives me this error when I try to dispose of it's data.
I made a handler to manage multiple job types in one priority queue:
and this is what I call on jobs that finish:
The error occurs in handleFinishedJob when I try to dispose of a nativeArray this job type uses for output
If anyone had any insight I'd greatly appreciate it ๐, debugging offers no real help sadly
Also, this is the IJob being run here, the error only happens for the second IJob of this type to finish and go through the finish job handler. The first job works fine and finishes and disposes
@blissful veldt I cant follow all the custom bits, but theres a overload of Dispose that accepts a JobHandle, maybe try that one
Any reason why @ocean tundra ? And I'm more than happy to try to help explain any custom bits, I'm just not sure what's really happening.
I'm pretty new to the job system.
๐ I'm just tired so brain is struggling to switch on
I'm just not sure what the overload for dispose does, i should go look ๐
Also what is ApetureJobHandle?
Thats the struct thats in the first screenshot. It's a handle I use to hold the job and the job handle and some other data for a few different types of jobs my manager queue uses.
if its a struct make sure your passing it as Ref
I have a manager that handles a priority queue of several different job types.
Oh hmmm
So I'm carrying around job handles for native collections for my stuff, and i ran into issues with structs vs class and copying the handle around instead of keeping its reference
Ah yea that's probably it then, I just need to figure out how the heck to keep the reference
i made a 'container' which is a class
lol dang, i'm trying to avoid classes because of garbage collection
and made it return ref's of its job handels
my things are long lived so that wasnt a issu
i never destory/create new containers they last the lifetime of my game
mine are like, 900 tiny jobs
the job handles inside change a ton tho
hmmm yea that would be tricky
but also is it a pre optmization? gc is annoying but if your mostly in the dots world you should have tones of frame time left for the progressive gc
are you making 900 per frame?
or is it mostly 1 offs
it's mostly one offs, it adds the like 900 chunks around the player to start (voxels) and then as they move it adds walls of chunks
theres differnt jobs for loading the block data, meshing the data, and activating them in unity space
so the job type and distance to player play into priority
Jobs have to finish on the main thread though don't they? So GC would have to happen there?
yea
I've had issues with voxels and objects over structs and garbage collection in the past, so I guess i'm not sure it'd be a problem but, i have a feel
you might be able to get it to work with structs as containers
yea i just need to ref eveything... time to find out out to go through a dictionary by reference ๐ฆ
i just found it annoying but pretty sure my issue was a i am assigning a field the container
and i think that is what 'breaks' the ref to the same item
if you have a single system that contains all the handles/containers and only ever use them from that i think it will be fine
I think what may be breakign it is i'm calling complete in a foreach loop
wait, so i think i just need to make this a ref
because that marks it complete, and then... wait no, if the issue was it wasn't marked complete because it's not a ref that wouldn't matter
I mark it complete right before I dispose without storing it again ๐
yea that should be ref
Wait, I'm a bit confused how the jobHandle needs to be passed by ref
isn't it a struct? or is there weird unity magic that lets it store a reference type?
because as long as the one I send had Complete() called on it, why does it matter that it's a copy of the original handle?
i mean your custom handle thing needs to be a ref
I'm not sure why though
hmm do you need the completed one out of it again?
if i copy it it should copy the completed one right?
This is how I run them and check for completion:
these both run in Update()
getJobFor() returns a new ApertureJobHandle
wait. schedule is where you get the job handle from
but you dont have it
It's a wrapper function
It's scheduling the job, and storing the handler in that AJH, then storing the newly modified AJH struct in a new dictionary... so it should be fine without being passed by ref right? ๐ค
yea i think so
and then I take the value that was put into that dictionary, modify it again by running complete() on the struct's stored jobHandle, and run a function on the modified one
maybe just to be safe print the hash code of the jobhandle on lines 53 and 55
to confirm it gets set
i didn't know you could do that
just debug.log(handle.gethashcode
everything in c# has a hashcode
ive never really messed with reflection and stucts no clue if that has any effects
tho cant you just schedule on the IJob without the generic magic method?
im guessing unity dosnt like that?
they don't ๐ฆ
no i see
cause your passing it as IJob
it loses the 'struct' bit and gets boxed
yea confusing
nice solve tho
yeh, it's weird.
thanks lol, took a bit of searchin
now i just need it to work XD
but that reflection bit wont be nice for performance
you could probably cache the making generic method bit in a static
and i think you can pass null to invoke instead of a new empty array
for the parameters
it's silly there's not just a default lol
yup
i ran into similar issues trying to genericly add IComponents to a entity
very annoying
yea, i'm still trying to think of a better fix than the reflection
the static is a neat idea, but i'd need to make it some kind of array or dictionary with all of the potential job types
yea optmize after it all works
i could make it a static array that expands when it encounters a new job type, would mean only the first job is slowed ๐ค
yee
I'm going to test with passing the handle to Dispose ands check the hash code on the handle while debugging through, I'll let you know what happens
yea it looks like between me setting the handle :
and me calling complete on it
the hash changes ๐ฆ
Guessing unity uses the hash to find the job it's managing
theres some sort of pointer under the hood, but i dont know what sort of magic they do
wait...
but if its changing somehow means your getting a copy made
it changes as soon as i'm out of the function apparently... i'm confused
the reflection i think, one sec
hmmm
(ignore the top watch value)
so the bottom watch value is before I schedule anything, so it's a default handler
job handle gets set
back outside the function, the value didnt' change
is it because i'm using invoke?
honestly dont know
your setting a bool in the invoke method right?
has been scheduled
what value does that have
oh yea... I am, and that seems to set
but it's also a bool so there may be some weird voodoo
I'm going to try this
if that dosnt work maybe see if you can strip it wayy back
remove the container
use a set of nativelists
that the index's all match to 1 job
and use pattern matching on the job schedule
theres also native queues which may be a better fit
it looks like it's working! ๐
well, at least this part is
wait what do you mean "use a set of nativelists
that the index's all match to 1 job" ?
it wont work with a queue
basiicly you could have 5 native lists for each type of data you need, index 0 of all those lists are for the same job
it would be a bit of a pain tho
Hmm, maybe
same hash value on the out side too!
steaaadddy
WOO! That seems to have fixed it
๐ Thanks so much @ocean tundra ! Couldn't have done it without you
@blissful veldt SWEET!!!
Wait, can jobs not output booleans?
Does it HAVE to be in a native array?
I have this job for example, and was hoping to use the boolean at the end when i check the job after completing, but it seems to revert back to true
Or does storing jobs in a dictionary not save a link to them correctly? It looks like the job has a different value when it's running Execute for job.GetHashCode() than when I call schedule() on it.
I think i may be misunderstanding how to store jobs and get output from them
@blissful veldt Jobs can only output data in native collections
make a native array size 1
A Hybrid Renderer V2 batch is using a pass from the shader "Hidden/Internal-Loading", which is not SRP batcher compatible. Only SRP batcher compatible passes are supported with the Hybrid Renderer.```
Might be the better question for this channel, on second thought.
How can I prevent this nuisance?
What rendering-related packages are you using?
Universal RP 9.0.0 preview 14, Hybrid renderer 0.5.2 preview 4
I think yes. The error occurs only when I instantiate an entity that was declares using IDeclarePrefabs, and only when that is the first time. The entity in this case even uses my own shader graph, but any shader that hasn't been loaded yet won't work, because the cyan colored "dynamically loading" shader is the one that doesn't work with the SRP batcher.
so... shader graphed materials aren't fully supported yet?
Not sure, what's not supported is dynamically loading them.
while the shader loads, the renderer barfs.
NEW QUESTION ๐ In Hybrid Renderer V2, on Universal Render Pipeline, how can I add a second directional light (can be a vertex light) without manually writing my own Lit shader?
It works fine for non hybrid renderer objects.
The other loses the blue fill light as soon as it becomes an entity.
@deft stump its supported, check hybrid renderer manual
there are 2 version of hybrid renderer, v1 and v2, its supported in v2, not in v1
hey guys does NativeList still exist? i was trying to use it as i was following a tutorial on dots pathfinding but it seems NativeList doesnt exist
[QUOTE="Tim-C, post: 5875384, member: 15376"]Hi. Universal RP + hybrid currently does not support more than the main directional light. We have to make some new systems to pass the per object light index list through to renderer. This is high on our priorities and being worked on.[/QUOTE]
How do i add multiple components using the command buffer ?
how do you mean ? you just call the commandBuffer.AddComponent multiple times
Thanks ! Thats what i meant... but i thought theres another solution ^^
Hmm... any idea why some of my systems have the tag "not run" in the ecs debugger ?
Does that mean they crashed ? Shouldnt they run always ?
@opaque ledge Are you sure that the command buffer .AddComponent works after another with multiple different components ? Somehow only the first component gets attached https://prnt.sc/t7h0ub
"Added" gets added... while the state component does not get added at all :/
its better to use EntityManager directly then
command buffer is designed to work with jobs
tho i am not sure why your state component isnt being added, can you change the code to StateComponent being added first and "Added" component second ?
I did... then the entity has the "StateComponent" attached... but is missing the "Added" component :p
I actually need those buffers in order to add the "Added" component at the start of the frame and remove it at the end :/
It gets strange... even if i attach the state by entitymanager and the added by the buffer... only the first one gets added to the entity
hmm, any errors ?
Nope :/ Checked all my systems... disabled them... nothing
Damn i hate such issues
Anyone else ever had the problem that a command buffer somehow only adds the first added component to the entity ?
This drives me crazy... i cant find the damn issue
This also doesnt make sense
That throws a exception that its not possible to call .AddComponent because newEntity is not a EntityQuery
But .AddComponent(entity) exists
try .AddComponent(newEntity, typeof(Added));
@amber flicker Thanks ! But it tells me that this method does not exist in the command buffer
how about .AddComponent(newEntity, new Added());?
also that should have worked - is Added not an IComponentData?
thanks ! That worked ๐
hmmm ok
But the previous issue still exists... only the first component in the buffer gets attached
I start to hate dots... instead of using a query... im gonna loop over all entities to add them... i wonder if this works
Dots is fucking me up... this works for some reason
so... I'm not sure how involved I want to get ๐ but just to say.. you should have a large preference for queries where possible, also be careful when using buffers - e.g. the create calls return entities but they don't yet exist in the default world so you shouldn't create references to them.
ok.. one more thing if that change worked
consider that any structural change may affect your query results for the buffer to act upon
e.g. psudeo code myQuery = typeof(Bob); buffer.Remove<Bob>(myQuery); buffer.Add<Something>(myQuery); - that last .Add will do nothing as there are no more bobs ๐
That could be the reason... my "newEntities" query involves entities without State and without Add... once the first AddComponent was fired, it involes State/Add and the second component does not get attached... fucking hell @amber flicker You saved my day, thanks xD
Awesome - may you go forth and spawn many entities
Thanks, thats what im gonna do ๐ this is the way
Does anyone here knows if i can attach ObjectComponents via a command buffer ? Probably not because ObjectComponents run on the main thread right ?
can you add class-based ICDs? I think you can? Possible alternative for component object at any rate.
though I could be wrong - maybe you can't use them with ecbs - never tried and they wouldn't be burstable
how do i pass a entity query via a array ? everytime i try to either pass a query or a nativearray it somehow clears itself and ends up being empty
I basically wrote my own system with 3 queries... those gonna get used inside the onupdate method... a derived system uses them but all queries are empty but only in the derived part... passing query or data doesnt work too because its getting cleared
Anyone ever experienced something similar ?
Im still stuck with that shit... when i try to pass a damn query which is full of entities... its getting cleared during the passing....
var count = entities.CalculateCount(); | Count = 100.... | myMethod(entities) -> Count = 0
I already googled, read the damn documention but i cant find anything about this
Event the cached queries are empty
What are you trying to do here? Pass an array of EntityQuerys? Or just in general pass some recipe for getting a specific (but arbitrary) set of entities?
maybe you want to pass the query.ToNativeArray rather than the query itself? Sharing code and as Hodhandr says, what you're trying to do here would help.
whats new? ๐
been a while since i saw topher's last post
New burst?
Nice
Time to immidiately install
And break development because it might break unity
im trolling joachims forum posts for news ๐
"BlobAssets can not reference other blob assets. It is not supported because it would mean that blob assets are not immutable / memory ready anymore. " - Joachim_Ante
So i cant do blob asset within a blob asset?
apparently not, and he's keeping to the blobAssets are only for immutable data but a lot of people are not using them that way, i guess if you go to the dark side you're on your own.
they have to be at conversion/storage time of course, to be able to get loaded in a subscene.
Hrmmm... I dont understand though.
Since all it would store is the referrence to the other blob asset.
You could totally make a system (non-ECS) where you'd give your blob assets some kinda ID; and you could then have a blob asset store such an ID to refer to other blob assets.
"Looking at the C++ code it looks like JobHandle.CombineDependencies implicitly automatically kicks off jobs that haven't been scheduled yet." - someguy "I agree it shouldn't be doing that and i'll figure out what we can do about it." Joachim_Ante
https://forum.unity.com/threads/so-i-was-using-ecs-the-wrong-way-story.877138/#post-5768368
"When you have small entity/chunk counts, the overhead of scheduling can be higher than just executing the code with .Run(). Do note, that we are doing a lot of work in order to make that not be so...
Specifically we are:
- Adding support for completely bursted struct based systems. So a system itself can be burst compiled.
- Doing a bunch of optimizations in IJobChunk & JobScheduler to reduce overhead." - Joachim_Ante
my game runs faster when i disable all jobs than with jobs enabled ๐
yeah
it also runs faster when i reduce the job count to 1 worker in a build, havent found how to disable jobs in a build
๐คท
oh i mean Use Job Threads being disabled not the debugger
@safe lintel scheduling ECS jobs is like 99% overhead
on simple systems
the core ECS burst execution is stupid fast
but it gets boggled down by huge overhead on a per-system basis, due to checking dependencies with stuff
wonder if it would be worth just writing your own version of systems without any checks
admittedly im not scaling up my entity count too much, still too dependent on monobehaviours for character stuff to be able to do it in a way that yields benefits from dots
i also wonder what perf would look like if I explicitly set the order of all my systems, i lazily let unity figure out the majority of it
also even when you actually get gains from jobs, it's possible your gains diminish the more worker threads you throw at it
unity job system by default schedules work on all worker threads which is your cpu hw thread amount -1 (and main thread)
this is very inefficient on my testing, even for basic built-in DOTS stuff like physics or hybrid renderer both benefit from reduced worker amounts
I've gotten really side tracked lately so haven't gotten any demo for this done yet but I'll try to get it out
that being said, last Unite Now for Unity Physics did mention they are looking at letting Unity Physics run things using x amount of threads and that they allow this for Havok Physics (I don't even know if it has anything to do with Unity jobs on havok as it probably does it's own threading)
they wouldn't even consider this if they didn't know of this bottleneck already
I haven't really seen any practical gains past ~4-5 worker threads
yeah there are a lot of little gotchas currently
vs 23 max it would assign by default on my cpu
yeah i shudder now when i hear people talking about multi-threading their code. I think best case scenario you set things up so you have the option easily down the line if neccessary - which Unity ECS does a great job of allowing. But otherwise ignore it.
I want to make bigger world prototype using DOTS so I'd need to figure this one out
my main issue here is that stock DOTS system suffer with default design currently
it definitely shouldn't be like that with "performance by default"
even if you have older, say 4 core 8 hw thread cpu, maxing the workers probably does give you worse results than just limiting the workers to half of what unity would assign to it
of course the issue will not be as clearly visible but everyone should be able to tell they are not getting more perf and that they are consuming more cpu
from my tests 4 seemed to be the magic number, more or less would be worse once past the threshold of gaining any benefit at all from parallel
How can I check for whether all values in a bool3 are true?
yeah, 4 is a good compromize
math.all
ty
I can't remember if it was unity physics or hybrid renderer but one of these worked best with ~4 workers and other with 0-1 workers
I hope whoever designed these packages with small cases is deeply ashamed
if you mean new math lib, this was thoroughly discussed in miles long forum thread when it arrived
it really split opinions
here we go! hehe
even in javascript they have camel case classes lol
how I read it through the lines, there were one or two staff members (Acton etc?) who really wanted to keep the lowercase thing
it had to be someone with big authority
yeah I agree. Because its so stupid, I dont see any other way for this to actually be authorised
that being said, if you write a lot of math, it's actually faster to use it like it is now as it's tad faster to type
personally im for using the official standards from the people who make the langauge, makes sense you know.
i kinda like the lowercase ๐
imo, I don't particularly care.
ikr looks like shader functions to me ๐
i do feel its helped me feel more comfortable modifying shader stuff
I don't mind either anymore, just find it weird that Unity now has three different conventions
totally subjective
Yeah the math library was kept as close to hlsl as possible I think
i could get behind that too @dull copper if they chose something and stuck to it, but half the unity core APIs and objects still use lower case public members, the other half are to standard.
old stuff used pascalCase, new C# packages use CamelCase which I think comes from .NET standards etc... and then there's the math lib oddity
i also agree that the standards are just all over the place ๐
waiting for snake_case to drop ๐
I can totally understand the shift to move toward more standard way but the math lib then broke the convention again
all old Unity API also uses british english where new stuff uses american
lmao
behaviour, colour etc
is there any AddForce equivalent in dots?
I believe this is because Unity was originally a danish company and we learn british english at schools at EU
I dunno if there's any helper function for that somewhere
there are some for impulses
theres a physics utility class, cant rememnber the exact name
but force is really just impulse * deltatime
im getting started with dots and I noticed setting PhysicsVelocity.Linear gets rid of gravity, like with RIgidbody.Velocity
I still can't get around that libs "PhysicsWorld.ApplyAngularForce()"
angular force...
that's torque
@dull copper hows your game going btw?
been bit slow lately haven't done much unity work in few weeks now
this week has been pain as I'd really need AC here
it's really hard to make any creative work when it's near 30 degrees celsius at the desk
used to have movable AC but it broke down, should totally get another one
whats your game about?
๐
https://youtu.be/RgkDFc6FgPg?t=27
i want to convert this into DOTS, but I think I'll need to write some of the joint system because as far as i've seen DOTS doesnt have an equivalent to ConfigurableJoint (or am I wrong?)
Physics-based character controller with procedural animations
Unity Physics samples have joint scripts in the ECS samples
there aren't all very efficient but you can fix them and do custom joints yourself
yeah I was taking a look at that
it does have configurable joints
there's also conversion from some joint types but I haven't tried it as I prefer to setup these myself and not rely on conversion
i use it for converting gameobject ragdoll character joints to dots joints personally, had to modify some stuff because hierarchy wasnt supported and im still not sure if it is right now with inject
this should list all joint types there: https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/UnityPhysicsSamples/Assets/Demos/4. Joints/Scripts/Creators/Joints
hmmm
talking of dots samples, wonder how long till we get that dungeon generator
i was mentioning that earlier, topher has gone missing
@wary ibex you've seen this? https://www.youtube.com/watch?v=n_5RGdF7Doo
Learn whatโs new with Unity Physics and Havok Physics for Unity. In this video you will get a brief recap of our Unite Copenhagen talk, then a deepdive into a cool example of how you can convert a GameObject-based simulation over to the Data-Oriented Technology Stack (DOTS).
...
it does cover some of the custom joint things briefly
also just checked and its been like 6months since dspgraph was updated
com.unity.ui.runtime has been a while (sitting still) too
I kinda wished that would have gotten more traction
is that elements/toolkit?
it's basically ui elements for runtime
so.. for your game itself
I can't wait to not have to use ugui
anyone tried it for game UIs?
ah yeah, i was fiddling around with the github package but figured its too early to attempt to rely on that
I don't like even the idea of having gui in scene
yeah it's way too early still
there's like no animation even
ugh
animation was on the roadmap but since there hasn't been any actual package update and dev repo is not public, there's no telling where it's going atm
visual scripting integration ๐
I hope they don't wait for that to release first
dots ui stuff is still a question mark
I'd love that pie menu for probuilder
but yeah, that UI stuff was teased years ago already
did you see the dots timeline package?
at least thats kinda there and in development
yes, but haven't tried it
there will be dedicated timeline for dots?
or just dots support in existing timeline
how are you track packages after bintray dropping by unity?
do you mean timeline the unity feature or timeline as in roadmap?
cool
for keeping track i just type in the package name here, not really a good alternative yet
also this package is super early and not mentioned anywhere
i dont even remember how i found it
i imagine
waiting for all dots animation features like compositor and timeline
tried new state machine in compositor recently but with no luck. pretty complicated without documentation
yep kinda painful waiting
i want to progress doing more stuff for my project, but i really dont want to do anything more with mecanim/unityengine stuff, dots is there and working but beyond my understanding, so twiddling my thumbs waiting for updates, examples, dev communication which are all sparse
Hi can we put multiple PhysicsCollider in a single entity ?
it seems like a simple question but im struggling to find the answer on google for some reason
@safe lintel
it does have configurable joints
would you mind saying how you got configurable joints in ECS?
@mighty whale they mentioned that will be possible in the future on the Unity Now talk
I haven't checked if it already works on newest Unity Physics package or not
ah, it's in
It is now possible to create a compound collider by adding multiple PhysicsShapeAuthoring components to a single GameObject.
It is now possible to convert a GameObject with multiple Joint components on it```
(Unity Physics 0.4.0)
ok ty, and is there any other way that we could have 2 discontinued hitbox for one entity ? To be clear I don't need to know which hitbox is hit so it can be 1 hitbox, the thing is that hitbox could be made from cubes that are not touching each other
i hope it's not too confusing...
I don't see why not
@wary ibex i think all joints get turned into ecs "configurable" joints when conversion takes place, the input data determines what their limits etc are. the video explains a bit more but if you take a look at the code you can see how it happens
ie Unity.Physics.Hybrid\Conversion\LegacyJointConversionSystem.cs if you want to use the builtin conversion
hmm the "official" joint authoring components seem to only exist in the samples?
this part in the video covers some stuff https://youtu.be/n_5RGdF7Doo?t=2287
im stepping out now but ill be back in a bit
๐ฆฎ dogs gotta walk ๐
thanks! I forgot about the video ๐
What are these mutable interfaces? Any place I can read about them? Couldn't find anything on google
basically ignore jointdata you create a PhysicsJoint( IComponentData)
I was able to do this
var constraints = hinge.GetConstraints();
var constraint = constraints[0];
float targetRotRad = math.PI / 4;
constraint.Min = targetRotRad - 0.01f;
constraint.Max = targetRotRad + 0.01f;
hinge.SetConstraints(constraints);```
which I think is the intended usage
this is nowhere near the functionality of a ConfigurableJoint though ๐
are you using the physics sample joint authoring components?
I think so? I'm using these
yep thats the stuff
hmm
I think I'll need to write the TargetRotation and all other motorised joint implementations
Is it not possible to edit component values in runtime?
@wary ibex What do you mean by edit values? like in the inspector?
how bad is the cost of scheduling jobs?
I'm trying not to optimize too early but I could rewrite some of my core systems to be a job per player
I would like to support 16 players which would mean 16 jobs per game 'thing' (Position/Health/Rotation ect) to sync over the network
So alot of jobs
it's not free and 1 job per game thing per player doesn't sound worth the trouble
job schedule overhead is around 0.05ms per job last i checked so wouldn't bother scheduling more unless the job takes longer than that to complete
actual number depends on cpu but still
yea thats kinda what i was thinking
also i just remembered chunk based jobs so they might be better if i do need more performance
that and chunk change versions would probably have much better performance
doesn't 16 players * game thing mean you're just updating 16 positions etc or am i misunderstanding
of no, 'thing' is basically a component i want synced over the network
replace thing with component and hopefully it makes more sense
yea but still 16 doesn't sound like even version checking would be worth it
wouldn't most of that fit in one chunk anyway
oh its a RTS
ahh i see
makes sense
@ocean tundra yes in the inspector
hmm, how can I make an entity a parent of a go going through conversion ?
So you have an entity...
And you have a gameobject.
And you want to convert the gameobject, and want it to be a child of the entity when done?
yep
You would need to search for that entity and use a custom converter
just discovered LinkedEntityGroup buffer that allows to link few entities and instantiate/destroy whole group with the owner, so sad that it is not documented, such useful thing
how many things there left to discover...
Would the performance of IJobParalleFor and IJobParallelForBatch be the same whe nBurst is used?
I have this gut feeling that IJobParalleForBatch would be faster, but I have never verified
just did a quick test and IJobParallelForBatch seems indeed much faster
@wary ibex You cant, the inspector dosnt allow editing of entitys and components
Is there any way to customize the entity component inspector yet?
I would like to setup a Guid inspector and a bitmask inscpector
no i dont think so, at least not officailly
maybe in a few updates
well, it will come eventually, tho not sure tomorrow or 2 years later ๐
๐
Anyone knows how to access the GenerateAuthoringComponent from code?
Basically I'm trying to have a script that generates prefabs and I want to add a bunch of components to those prefabs. Some of them being Components with GenerateAuthoringComponent.
If it's my own hand written AuthoringComponent, there is no problem:
var prefabRegistryEntryAuthoring = instance.AddComponent<PrefabRegistryEntryAuthoring>();
prefabRegistryEntryAuthoring.prefabRegistryIdentifier = unitDefinitionLevel.PrefabRegistryIdentifier;
But if It's one with GenerateAuthoringComponent like:
[GenerateAuthoringComponent]
public struct Shadow : IComponentData {
public float scale;
}
Then there doesn't seem to be an authoring component I can reference from my code:
var shadowAuthoring = instance.AddComponent<Shadow>(); // ???
That might just be a limitation of the GenerateAuthoringComponent workflow, but I'm wondering if there is a way that lets me avoid writing a dozen or so "dummy" boilerplate authoring components.
๐ค
@spark glade Could you add them to the converted prefabs?
or must be added to the GameObject version?
yeah i can add them through the editor
Just no idea how to add them through code, because the Shadow : IComponentData doesn't extend MonoBehavior.
there should be a new type
And there doesn't seem to be a ShadowAuthoring that Rider can find
Maybe I could inspect an existing prefab somehow ๐ค
Yea just noticed that
they must make them in some sort of unreference assembly somehwere
Wow, so if I check the prefabs it references a GUID: e1d46917ee1a417e8a7f2a2a9a384210
Debug.Log(AssetDatabase.GUIDToAssetPath("e1d46917ee1a417e8a7f2a2a9a384210"));
yields
Assets/Scripts/Game/Components/Shadow.cs
I have no clue how unity are hiding it from your code
its namespace should be the same as your type, its name is appended with Authoring and it should have the same scope
but it does get a DOTSCompilerGeneratedAttribute put on it
Must be some black magic tricker, sigh
wait
its a post processer...
so it runs after your code has compiled
so the type does exist
but your code cannot see it
I just noticed how they bolded Inspector ๐
you should be able to find your authoring types via reflection
it should be in the same assembly as your type so something like this should work
Shaddow.GetType().Assembly().GetType(nameof(shaddow)+"Authoring")
๐ฑ
if you have namespaces it may be slightly different
Hm... yeah I'm gonna write those myself I think Never a fan of reflection.
It's a ticking time bomb
๐
Is there any way to customize the entity component inspector yet?
I would like to setup a Guid inspector and a bitmask inscpector
@ocean tundra btw: https://odininspector.com/roadmap
Get insight into our future plans for Odin Inspector.
Haven't tried it the 3.0 Beta of Odin yet, but their team is working on making the Entity view less ugly ๐
Hopefully it'll come to Unity without the need of such extensions
Ooo i do like Odin
Best $50 I've spent fo far ๐
@spark glade there is "dots editor" package but it only works for peeking the values when things are placed in dots subscene
or @ocean tundra, whoever that question applied for originally
@mint iron oh that looks great
well, everyone expected it to be on next physics package one version ago already so...
but you can also apply impulses to your joint setup manually just fine
basically you can build motor functionality with them
@dull copper you apply impulses to the body, and not the joint, right?
I believe Iโll also need to write the forward kinematics code which the motor would handle, at least if it has a โtarget rotationโ setting which Iโm also expecting
to the bodies yes
Hi guys, quick question regarding EntityManager.Exists. How is it possible for an entity after its been destroyed with an ECB to still "exist" but already have no component?
For example ISystemStateComponent can prevent full destroying until this ISystemStateComponent will be removed directly, for example you have entity and A, B, C components where C is ISystemStateComponent and until you directly not remove C - entity wouldn't be destroyed fully, but all other component will be removed
hey tanks, i don't use ISystemStateComponents, i knew about that and checked specifically
or maybe a builtin one?
You don't - unity does for some systems ๐
does parenting use that?
Yes
ok, problem solved then... kind of
PreviousParent : ISystemStateComponentData, Child : ISystemStateBufferElementData
im reviewing a peer code, and he's using a routine to destroy all parents, shouldn't the root destroy be also destroying all children?
But ususally it can be only 1 frame and depends when you destroy entity
(it is actually one frame only, yes)
im reviewing a peer code, and he's using a routine to destroy all parents, shouldn't the root destroy be also destroying all children?
@eager jungle if LinkedEntityGroup buffer used for root - yes it will destroy all childs (well not childs technically as you can populate that buffer by yourself, but default prefab conversion populate LinkedEntityGroup with childs for you)
we have a simple mesh hierarchy (depth =4), whith convert and destroy on root, we're calling Destroy on an ECB on the root entity , and the children are not destroyed
Show EntityDebugger and inspector for root entity (after conversion)
I supopose it's just hierarchy object on scene? Not converted prefab?
in scene, correct
Well then I'm sure on 100% your entity haven't LinkedEntityGroup ๐
no LinkedEntityGroup component
Yep
as it's added only for prefabs from DeclareReferencedPrefab
Well you can add it by yourself in Convert for your root
ill do that, but that is kinda weird behaviour ^^
Just simple MB with IConvertGameObjectToEntity and add LinkedEntityGroup in Convert and add all child's AND (important) root itself to that buffer
Or use DeclareLinkedEntityGroup on root GO
how am i supposed to recurse in the entity children from the convert?
GetPrimaryEntity in root Convert, or as I told above - conversionSystem.DeclareLinkedEntityGroup in Convert
im going to use DeclareLinkedEntityGroup , but im curious, about GetPrimaryEntity. Am i supposed to use that by passing the GameObject children? and recurse the go?
oh there is a child component, i missed it sorry
GetPrimaryEntity return you other entity which will be converted, this not necessary child, it can be different entity, different prefab from IDeclareReferencedPrefabs etc.
DeclareLinkedEntityGroup simpliest way to add and populate LinkedEntityGroup from root
yea, seems to be working
not solving the one frame delay after deletion, but makes more sense
And wouldn't as it's by design how ISystemStateComponent works ๐
yea sure, i mean, it make sense now im fine with that
thanks for your help, very appreciated
Np
Did anyone have problem with FallbackAllocation so far?
that's less than 0.005ms, don't think it matters that much >.>
haha
what about now
this fallbackallocation is eating up a lot of time
it's even more than that
wow
@scarlet inlet answered to you on forum about ComponentDataFromEntity, but ask here as it's faster ๐ Why you need ComponentDataFromEntity by ref? ComponentDataFromEntity is a native container which itself only store pointer (and 3 utility fields and 2 of them even readonly) it's already access EntityComponentStore "by reference" through pointer ๐
I meant returning the components from it by ref
By the same reason as any native container works
I don't think there is a valid reason for both scenarios tbh
my guess is that when they designed the native containers, returning by ref was simply not available
ComponentDataFromEntity is not even a native container is it?
It's native container
It works with pointers directly
This is why it's not ref allowed. You accessing pointers and converts it to structs, you not working with structs directly for ref return structs.
what?
I don't see your point
Unsafe.AsRef is there for this reason
to transform a pointer to a ref struct
Ah yes
I use it continuously in svelto
there is a huge cost in this copy
performance by default is less trustworthy when I see this kind of stuff
there is a new havok component that has inside a stack based 128bytes array
I have to change this data every frame, which now means copy it
instead to modify it directly
Well problem here is Burst I suppose
nah it works fine with burst too
again I do this kind of things continuously
this data is native, not managed
isn't it?
actually, now I wonder if it's true, because I do use a lot of native memory nowadays, b ut I am not sure if UECS does the same
I would be surprised otherwise
Yeah it works with burst fine, just checked (never tried it before with burst)
ah you meant the Unsafe.AsRef itself
haha you would be surprised how many things I do inside burst compiled code haha
I wouldn't as I'm tried many s**t in burst just for own interest ๐ I not tell you that it's not possible (It was just guessing of root of the problem), I tell you I just not tried ๐
anyway everything insude Unsafe is safe as it's just a wrapper to existing IL code
hehe
anyway everything insude Unsafe is safe as it's just a wrapper to existing IL codั
It's not even IL wrapper *explicitly * but just plain pointers routine which IL friendly
M_R on the forum raised a valid point
Yep I saw
For a [GenerateAuthoringComponent] IComponentData, is there a way to access the generated monobehaviour from the gameobject prefab? like GameObject.GetComponent<SomeComponentAuthoring>. Primarily interested in editor functionality, not runtime, so performance isn't critical.
(specific use case is generating some textures for cards in a card game, based on the components on the card entity prefab)
And reflection of course
Thanks Eizenhorn - it seems the answer is no for now, you have to write your own authoring component
I've just recently started learning Unity, and today I just found out about DOTS and the fact that you can make a game with no gameobjects at all (and it's apparently much faster that way).
Since I'm just starting out, should I push myself to learn how to do things the DOTS way right from the get-go, or should I make a few complete games without it first? Are there 'bad' things about the gameobject way that you have to unlearn when progressing to DOTS?
I would say make a few prototypes with gameObjects since that workflow is still largely in place with the Editor. The biggest hurdle to overcome with migrating from gameObjects to entities is really the mindset from OOP -> DOD. Once you get the hang of that you can start utilizing entities much more easily.
Okay, thank you! I wasn't sure if the two approaches are so different that learning one would screw me up on learning the other. DOTS seems pretty intimidating. But hopefully it won't once I get better at working with gameobjects
Yea, also the workflow for DOTS is still a WIP - so improvements to come along the way
Ahhh, gotcha
Hello, me again
I have been profiling for days with ECS .10. I had to update to .11
and this appeared
please save my soul, because it's now in despair
what is this, where does it come from and why does it allocate so much?
(there is obviously something wrong)
Is it possible to iterate over ISharedComponentData entities and access its data?
@pulsar jay yes
Unity tells me: "This is only supported when using .WithoutBurst() and .Run()"
please save my soul, because it's now in despair
@scarlet inlet well I haven't fallback allocations in my code (only my manual mallocs)
Unity tells me: "This is only supported when using .WithoutBurst() and .Run()"
@pulsar jay inside job (and burst especially) - no
On main thread - without problems
@pulsar jay I don't use it inside burst
EntityManager.GetAllUniqueSharedComponentData(groups);
mhh. thats sad. why does it prevent me from burst and jobs?
I don't know I use shared components only for one specific reason, grouping entities
so I can do
@storm ravine let me check I am not sure it's a fallback allocation case
I don't even know what UnitySynchronizationContext is, I have never seen it before
I have seen some threads talking about it tho, last year, showing the same problem
Maybe my approach is not good then. I am still trying to represent a grid and thought sharedcomponentdata would be great for that
it's grouping entities inside a cell?
if so I guess it's fine
everything is about grouping can be solved with shared components
but you will need to iterate over the groups separately
@scarlet inlet this UnitySynchronizationContext is part of internal jobs scheduler if I'm not wrong. How many jobs you're scheduling? Is there any for loop where you scheduling many Job's?
I have a grid positioning system that needs the per entity cell position (cellpositioncomponent) and the grid data (grid size etc.)
@storm ravine it wasn't showing until I updated havok and ecs today
I thought it would be great to store the grid data in a sharedcomponent so I can have multiple grids and acces its data in the system
@storm ravine it wasn't showing until I updated havok and ecs today
@scarlet inlet Well I haven't that but I'm not using Unity DOTS\Havoc Physics
sounds like it could be related to the havok change in that case? they talked about changing it from many small jobs to one larger one I think?
