#archived-dots
1 messages Β· Page 219 of 1
Yes you .AddComponentData, not Set because no values in the struct, it's just a tag
ty
You do it from Entity Manager, or ECB,...
GameBoardModel.entityManager.AddComponentData<DisableRendering>(GameBoardModel.playerEntity, new Unity.Rendering.DisableRendering());
This probably will work, just gotta find the right place to put it. I think UNITY is picky due to order of operations and such, yet I don't want it in an update wasting a loop if only boolean checked to run once.
Thanks muchly.
Actually forget this sentence, that's misleading :p
Ok, I think I set it disabled, but it still shows. I'm in the entity debugger. Is there anyway to see tags applied?
It said disabled... hmmm
@remote crater should be AddComponent() because it's a tag, sorry
oooh cool
quick example
if you get the entity's in a nativearray you can just do EntityManager.AddComponent(nativearry<Entity>()) outside a job
that's probably the most efficient way
Yeah many ways to add components
Okay well I got the same Time getting deleted error in 2020.3.7f1 now as I was in the 2021 versions I was using before, not sure what's throwing this but it's definitely happening when I open my pause menu, but only sporadically.
and I can't use the entity debugger after the exception is thrown because that throws a load more (UI related) presumably because of the missing TimeSingleton component
how are you pausing things?
with this TimeSystem: https://gdl.space/upicacexoh.cs
There's an InGameMenuController that calls SetGamePaused
interesting so its not an internal unity thing
It happens only very infrequently
I'm sure I'm at fault, I just can't work out where!
looks pretty much like how I would do it I'm guessing its using a Singleton with requireforupdate in the running sytems?
yes
Trying to reproduce the bug and I can't, I wish I could nail down exactly when it happens
I have a log of when it happened in a build, but that's not helpful either. I'll check the editor logs for this current session
sounds like something is using something a singleton in a way it shouldn't
lol 85 mb editor log full of NREs related to this
my guess is it's something to do with get_TimeSingleton
Mmm so one other time it happened in this session and it wasn't the TimeSingleton - it seems to have failed on get_ one of mine (which then had knockon effects, looks like the entire Player was not present, weirdly
Well, I just got it after disabling burst as well so let's see what the logs say now π
which one i need for converting a prefab thats in memory/variable? https://i.imgur.com/FhipBj2.png
oh thats not an enum
can i just make new class instance and not change anything? in these settings
I'm at a loss with this, with full strack traces on, it still gives me no idea where to look to root out the problem. I'll have to search for every single instance of DestroyEntity and work out if I've done something silly perhaps when changing the order of system execution.
Is this warning from burst helpful to tracking down the problem? I've not seen it before but it doesn't appear to point me to anywhere in my code π¦ https://gdl.space/qahaqoreli.sql
I'd report that as a bug to be honest @wary anchor , even if it's not necessarily a bug, the fact it isn't reporting to you clearly where the bug means it is a bug
Yeah I probably should - I'm in the process of tracking down the exact commit where the errors start in the hope of finding the issue that way. Once I have it found it'll be easier to put together something useful - and I have to find the error and fix it or my entire project is fubar!
after 3 days, i recreated the math for a 2D Blend Tree in dots.....send help
hoping the next release of dots also includes the next animation package, that has statemachines. because it feels like a waste of time trying to implement that stuff in either node graphs or mainthread unbursted systems
entityManager.AddComponent<DisableRendering>(playerEntity); //did not seem to make it not render...
that's what i'm working on right now. i recreated the 2DBlendTree and am currently working on changing states and clips using ECS
yeah made my own blend trees with bool overrides for clip interrupting as well but just felt like a complete waste of time given statemachines should theoretically be right around the corner. if you look at their code they have a framework for it in place already, just no examples, and the visual scripting ui is in the process of being merged with their compositor package.
is there a way to use List.Insert with IJobParallelFor for NativeList ? All i can see is Add(...)
@hollow jolt Native list dosnt even have insert
oh i see
how to add_item_at_index >
what is index? is it actually a key that maps to something else?
you could try a NativeHashMap
with hash map ?
oh no sorry the move index idea is still with a native list
so i add ( push ) then i sort ?
the issue with these collections is they are all aiming to support parallel code
aah some mesh stuff
yea i would break that up, so instead of 4 lists, 1 list of struct (Vertex, Uv,Normal,Triangle, Index)
then a job that runs after to sort then break up into the 4 mesh lists
was hoping to solve it in 1 , but ill try multiple jobs
you could probably do it all in 1 big job
i just like smaller jobs for maintainability
small jobs are sometimes more efficient also... depending on what they are doing
Is it possible to have a system call destroysystem on it self
is there a way to instantiate entities inside of the IConvertGameObjectToEntity conversion method? i'm trying to generate some more entities but i only want to do it once
i've tried instantiating to a native array with the entity from conversionSystem.GetPrimaryEntity but it doesn't seem to work. is there a specific allocator i should be using other than Temp?
i keep getting this error
DuplicateEntityGuidException: Found 1 EntityGuid components that are shared by more than one Entity
guid = 28788:ffffdad4:00000000, count = 153, obj = ENV_Vector Field Anchor (UnityEngine.GameObject)
conversionSystem.CreateAdditionalEntity() generates a new entity for you when converted
im not getting the error anymore, but it's still not working. any ideas? this is how im trying to create the extra entities
NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
conversionSystem.CreateAdditionalEntity(anchorPrefab, anchors);
so basically:
void Insert<T>( NativeList<T> list, int index, T value ) where T : struct
{
list.Add( default( T ) );
for( var i = list.Length - 1; i > index; -- i )
list[ i ] = list[ i - 1 ];
list[ index ] = value;
}
that
hmmm i see
not tested yet , but i gonna try to run this parallel jobs
nooo
y ?
Parallel for each
if they have their own list each it should be ok
IJobParallelFor -> Execute(int i)
NativeList should work with it , isn't that the case ?
No idea what you mean, what's not working exactly?
it's not creating more entities
pretty sure the safty system will throw up at you, execute(i) should only access the index of i
eh ? so we can't add to NativeList per Execute i ?
Okay and what's your setup? Are you converting the gameObject on runtime? Are you using a subscene?
you would use the parallel version to add to the same list from many concurrent jobs
i'm converting a gameobject within a subscene. the objects im trying to instantiate are prefabs referenced inside the IConvertGameObjectToEntity
[NativeDisableParallelForRestriction] ?
@hollow jolt no that will turn off the safty checks, and what happens in this example:
2 jobs both with 10 items each both running at the same time
job 1 adds 1, 2, 3, 4,
Job 2 adds 1 ,2, 5,6
sorry add should be inserts at
but you can use add normally can't u ?
how do i use parallel writer ?
this is Schedule vs ScheduleParallel
on entities.foreach (if youve used that)
just call asParallelWriter on your list
and use the result to add too
list.AsParalleWriter.Add ( ? )
But you cant read or insert at pos
var listWriter = list.ASParallelWriter()
inside job
listWriter.Add....
unless you can make 100% sure each index is always unique
its writing like 0,1,2 , 0,1,2 , 0,1,2 ... ( inserts in pairs of 3 )
as in each job i maps to a single index in your lists/arrays
regarding my earlier issue with creating a bunch of entities on conversion: all of the instantiated entities have a Prefab tag on them, which afaik treats them as not really existing in the scene. i've tried removing the component but it's not working. it also doesn't convert the prefab entity before instantiating more, so i have to add the components myself, which im pretty sure im not supposed to do.
here's the instantiation code
NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
conversionSystem.CreateAdditionalEntity(anchorPrefab, anchors);
dstManager.RemoveComponent<Prefab>(anchors);
```and the full script <https://pastebin.com/xJXZ2C5e>
@craggy orbit is the main IConvert a prefab?
ok so
CreateAdditionEntity just creates a empty entity linked to the target you give it
the VectorFieldAnchorAuthoring is a prefab
so CreateAdditionalEntity doesn't instantiate from a prefab like i'd hoped?
Creates an additional entity in the destination world. The entity is associated with the given object. New entities should be created using this method since it ensures that the resulting entities have all data required for conversion correctly set up.
no
that association is for things like livelink i belive
so normally i would pass 'this' into the createadd... method
then setup the new entity
so to confirm your problem, you have a prefab and want to create X of them during conversion?
yes. i've got a base object VectorFieldColliderAnchorAuthoring with a prefab field VectorFieldAnchorAuthoring and i'd like to create X prefabs converted to entities
hmmm
so
the ability do simply do what you want does seem to be lacking
but i think i know a way π
first you cant use IConvert
need to write a custom conversion system
maybe 2
First system, loops over all your VectorFieldColliderAnchorAuthoring GO entities, and creates more entities in the INPUT world
those entities will have your instance data (eg X Y Z) and a link to your prefab
that system has to update in 'GameObjectDeclareReferencedObjectsGroup'
(sorry had the wrong group)
and i THINK that may work, destionation entitys are created after that group runs
wait you need to be creating your source prefab sorry, not adding a link
hm ok... it sucks that the functionality doesn't already exist, but thanks for pointing me in the right direction!
i hope its the right direction π
all the info
hmm they say to treat the input world as read only
what if you do DstEntityManager.Init... with GetPrimaryEntity(Prefab)
it wont be setup for livelink and things
i took a little break before switching to a conversion system, but it took only a few minutes! i was able to practically copy and paste from my old authoring component to the conversion system. the only "big" change i made was the entity creation
NativeArray<Entity> anchors = new NativeArray<Entity>(intSize.x * intSize.y, Allocator.Temp);
DstEntityManager.Instantiate(GetPrimaryEntity(input.anchorPrefab), anchors);
Entity newEntity = entityManager.Instantiate(entityThatYouAlreadyHave);
You have to do this on Main Thread
which means
- on Monobehaviour
or - on System in OnUpdate in ForEach.Run()
and.. I guess even all components are included, the each value of components should be set after that
Is there way to use GameobjectConversionUtility and set the entities to disabled at start/during the process?
there is Disabled Component but i dont know
how to add it
during conversion utility
I am sorry.. π
I didn't know
I am testing it now
That's better π
I recently changed some systems to Schedule that were Run. They're writing work to the EndSimulationGroupCommandBufferSystem and now I've realised a problem I'm not sure how best to get around: at the end of the game I am resetting some public NativeArrays but they were being used by the scheduled job so of course I now get a
The previously scheduled job UpAxisSystem:OnUpdate_LambdaJob0 reads from the --NativeArray--. You must call JobHandle.Complete() on the job before you can deallocate the NativeArray safely.
I can't just move the main menu systems to a later systemgroup as they use many of the same systems as the main game (it's all in one scene). How would you handle this situation?
Well, it sounds like this is just something that happens at the end of the game, right? Meaning it happens once in that frame, and very rarely. So you could just complete the dependency manually here?
Okay, how do you complete the dependencies of other jobs? Or would I have to add that into each one?
I was thinking about delaying the loading process until the start of the next frame / end of this one to get around it that way
You have to save them somewhere. For example ECBSystems has the AddJobHandleForProducer function that adds the jobhandles that must be completed, which it then completes before. You could have a similar pattern here.
The ECBSystem then just saves them to a list
I'm sorry, I'm being really slow on this, I don't follow
just trying to understand how it worked before I changed from run to schedule so I can see where in the loop it would be okay to overwrite the native array
but brain still in shader mode!
I think... if I make sure the system that calls the end of game and kicks off that set of loading systems makes sure it runs before any of the Scheduled systems, that should resolve it?
let your system that resets native array have some public list of jobhandles
and every system that touches that native array just add their jobs to that public list
k then just JobHandle.CombineDependencies then complete before resetting it yeh
why do you need to complete if you can just schedule a job that dependant on this jobhandle?
because I'm recalculating the values for the array and setting it on the main thread
in that case you can complete
look at physics system they use this strategy to handle external dependency to nativearraysπ€
k Cheers will do
Okay, so that seems to be working, but I'm adding the dependency every frame which must be wrong, Sorry I'm being ridiculously thick about this
I suppose i can just Clear it before scheduling the job and add it after, seems like a janky hack tho
Oh man okay no that hasn't fixed it at all, now it goes for the first cycle then there aren't any atoms. I genuinely don't understand why this problem is occurring now. It's all really complicated and of course worked before I switched a system to Schedule - but now I've got all the loading and nativearray stuff happening before the UpAxisSystem, so it should have all the updated values in place before it schedules
ahh unless... yeah there are some of the loading systems in a previous group, so they would be waiting until the next frame before they receive their commands.. the lading is complicated and it's several systems chained together with events driving them
so I could put a blocking component in after the load is requested and delete it when the load is finished, and just not schedule any of the systems that use the array if that component is present
cough or use my existing AllowSystemsToRunComponent cough fail roo
Well, I have no idea why it stopped working but I can reload levels fine so I'll just have to rewrite my menu code. I've been through all the diffs for the last few commits so either I didn't notice this in testing because I've been reloading levels all the time & doing shader work, or unity's decided to order the systems differently and that's somehow caused it. It's no bad thing, the menu needed refactoring anyway.
entityManager.AddComponent<DisableRendering>(playerEntity); //did not seem to work. It is supposed to disable rendering.
Works for me. Do you convert your player from a gameobject ?
Do you have a "complex" hierarchy ? I think the component should be on the same level as the RenderMesh. You can double-check with the Entity debugguer. Not sure it disables all hierarchy
Mr.K, yes I converted my player from a game object. Yes, I beleiev I have a complex hierarchy.
It is a game object with many scripts and a child.
If the mesh is on the child and you convert the parent, maybe that's why
didnt test that case
Going to aunt's 70th, she's awesome. Be back in a few hours. God bless all of yinz.
Is it possible to add an ECB to run after a scheduled job has executed?
@jaunty herald Then you need to create your own ecb system for it that will run after the job is scheduled. An ECB is always a sync point, so you can't depend on it being completed, but you can complete it before the ECB runs.
public class BaseMenu : SystemBase
{
protected override void OnUpdate()
{
if (!isActive)
return;
var query = EntityManager.CreateEntityQuery(
ComponentType.ReadOnly<Translation>(),
ComponentType.ReadOnly<PlayerRotationData>(),
ComponentType.ReadOnly<PlayerTag>());
var origin = query.GetSingleton<Translation>().Value;
var pivot = query.GetSingleton<PlayerRotationData>().rotation;
query.Dispose();
foreach (var element in elements)
{
var config = EntityManager.GetComponentData<UserConfigData>(element);
var position = origin + math.mul(quaternion.RotateY(pivot.y), config.offset);
var turned = quaternion.RotateY(pivot.y + config.orientation.y);
var pitched = math.mul(turned, quaternion.RotateX(config.orientation.x));
var rotated = math.mul(pitched, quaternion.RotateZ(config.orientation.z));
if (EntityManager.HasComponent<UserRenderData>(element))
EntityManager.GetComponentObject<UserRenderData>(element).textMeshPro.transform.SetPositionAndRotation(position, rotated);
EntityManager.SetComponentData(element, new Translation { Value = position });
EntityManager.SetComponentData(element, new Rotation { Value = rotated });
}
}
protected override void OnDestroy()
{
foreach (var element in elements)
if (EntityManager.HasComponent<UserRenderData>(element))
{
TextMeshPro textMeshPro;
if ((textMeshPro = EntityManager.GetComponentObject<UserRenderData>(element).textMeshPro) != null)
GameObject.Destroy(textMeshPro.gameObject);
}
EntityManager.DestroyEntity(elements);
elements.Dispose();
}
}
[DisableAutoCreation]
public class MainMenu : BaseMenu
{
protected override void OnCreate()
{
var buttonMesh = ResourceLoader.active.LoadMesh("Mesh/Button");
var buttonMaterial = ResourceLoader.active.LoadMaterial("Material/Button");
var meshData = new MeshData
{
render = buttonMesh,
material = buttonMaterial,
collider = ResourceLoader.active.GetCollider(buttonMesh)
};
elements = new NativeList<Entity>(3, Allocator.Persistent);
elements.Add(AddButton(
EntityManager,
new float3(-1.1f, -1f, 2f), 0f,
meshData, ToStartMenu,
2.5f, "Start"));
elements.Add(AddButton(
EntityManager,
new float3(0f, -1f, 2f), 0f,
meshData, ToSettingMenu,
2.5f, "Settings"));
elements.Add(AddButton(
EntityManager,
new float3(1.1f, -1f, 2f), 0f,
meshData, ToExit,
2.5f, "Exit"));
Show();
}
}
[UpdateAfter(typeof(PlayerSystem))]
public class UserSystem : SystemBase
{
private BaseMenu current;
protected override void OnCreate()
{
current = World.CreateSystem<MainMenu>();
}
}
my problem is
after i called CreateSystem in UserSystem
the OnCreate function in MainMenu gets called
but the OnUpdate function does not get called
and MainMenu does not show up as a system in the EntityDebugger
could anyone shed me some light on this problem i have?
I could directly call function in MainMenu, which means the class instance does exist
Update: not solved but CreateSystem<BaseMenu>() does work properly
p.s. ping me
thx in advance
I am newbie but
Can you try
current.Enabled = true;
after Created MainMenu?
Hmmm, let me fire up unity
sorry report that its the same as before
Update: not solved but CreateSystem<BaseMenu>() does work properly
What is isActive in the OnUpdate?
it does not do stuff to the system, it just disable a group of entities (to show or hide the menu)
my theory is ecs does not work with subclass
but the compiler does not know it
before return π
just for check
Debug.Log("Code stopped");
on which code snippet
at BaseMenu
OnUpdate
after
if (!isActive)
so just to make sure
the ecs can't run Update
yeah, i did Debug.Log("hi")
nothing showed up
let me test this with CreateSystem<BaseMenu>()
Update: OnUpdate does work with BaseMenu
just not with subclass MainMenu
Remarks: problem not solved (for any helper out there)
Thx for your effort, as always
use
private MainMenu current;
and make OnUpdate, there
and call base.OnUpdate
so make
current = create MainMenu
let me try
OnUpdate doesnt work, but MainMenu showed up as BaseMenu in EntityDebugger
@opal lynx
what version of unity
2020.3.6f1
ah
let me get that version
i heard they started to have compatibility issue with 2021Unity
and advised people to switch to 2020LTS
im gonna report back as soon as 2020LTS is installed
What version were you using?
2021.1.6f1
fingercross my code works with 2020
oh... then some people was right π
I heard the other people still can use ecs in 2021 even Unity said not working
i guess i was lucky before
Oops... I was wrong
It doesn't work
?
oh wow
it works
I can't tell you because it will seems like an advertiser here LOL
is there any way to set position of entity
GameObjectConversionSettings conversionSettings = new GameObjectConversionSettings();
conversionSettings.DestinationWorld = World.DefaultGameObjectInjectionWorld;
conversionSettings.
for (int i = 0; i < 3; i++)
God.galaxyMonos[g].galaxyPopulation[i] = entityManager.Instantiate(
GameObjectConversionUtility.ConvertGameObjectHierarchy(populationHandle.Result.prefabs[i], conversionSettings));
}
i know i can SetComponentData
as last resort
but i thought there would be some parameter
for that
I don't think there's an overload in Instantiate, but if there was it would only call SetComponent anyway.
i see
what even is AmbientProbeTag ? its being added automaticaly with gameobjectconversionutility & instantiate
It's in the Hybrid Renderer namespace, probably for lighting calculations
dunno if probe lights are useful in URP, but i guess they sure are for HDRP
I'm not a lighting guru :p
I guess its heavy ?
so youre saying that ambientprobetag == converting mesh renderer that had probes not turned off?
or you mean that theres a light probe component
before conversion
I'm not asserting anything :p not my field
oh ok
do you know why objects with render mesh are in same group? they have different mesh
maybe they just did it to not clunk the UI idk
theres also this weird tag as well as some other:
https://i.imgur.com/22zdNYX.png
You mean why the RenderMesh is a SharedComponent ?
Yeah I'll let more knowledgeable people on this field answer. But basically the Hybrid Renderer will add anything needed for your entities to be rendered by the Unity rendering pipeline yo uchose
You're trying to get rid of unnecessry things ?
good news - timjohansson just wrote on netcode forum : "Yes, you can only have ghostfields in 128 different component types right now. The code is changing in netcode 0.8" - so although next version of the netcode is 0.7 they are planning ahead - so we do not have to worry about dots - netcode future π
yeah nothing ever goes wrong with unity planning 
im trying to remove unneccessary tags/components
that create during gameobject conversin systems
in order to decraese amount of chunks
Well I would let the Hybrid Renderer do its thing, and focus optimization elsewhere
COpyTransformFromPrimaryEntityTag is surely used by the conversion system to set the transform of the entity in the destination world (?) If I would guess from the name (and you can search in Library/PackageCache to really see what happens)
I would be afraid to see things failing if I remove smthg I don't fully grasp
@gusty comet @karmic basin The reason why RenderMeshes have different chunks for each mesh is because it's a shared component. Shared components group entities that have the same value. So that means all entities of the same archetype with the same mesh are in chunks together. This is to optimize rendering multiple of the same object. The reason that it's designed like this is because ECS was always designed for having many of the same archetype.
It was great to see a huge interest in the DOTS workshop last week. With the support of Unity team, it was nice to see the current state of production-ready and experimental features. Furthermore, it was interesting to see DOTS in action highlighting another part of this technology stack to bring more and more performance.
The recording and repo of this workshop is recently released, you can check here:
https://zt0b1t1jhdi.typeform.com/to/gJCRHuTa
this looks really cool
Unity.Physics first and foremost tries to be an out-of-the-box solution and then slowly is working on exposing flexibility.
In constrast, Psyshock tries to be a βBuild your own solutionβ framework and is being designed inside-out. Over time, it will eventually achieve an out-of-the-box status, but that is not the focus. The focus is flexibility with the luxury of drop-in optimized and accurate algorithms and authoring tools.```
this is how I want a physics engine to be
can anyone tell me why there are two archetypes? all entities that are inside them are made in the same manner and had same components
https://i.imgur.com/gM55iuc.png
I used this
GameObjectConversionUtility.ConvertGameObjectHierarchy(populationHandle.Result.prefabs[i], conversionSettings);
i have some ideas why this could happen but generally a person would think there would be just one archetype.
unique components/tags i spotted:
- copyTransformFromPrimaryEntityTag
- nonuniformscale
- translation
Super interesting! I'm personally not going to use it because it is barebones, but I really appreciate the points he raises. Especially having immutable colliders and the performance issues.
ye looks super young but I Like the nature of it
it really is impossible to have an out of the box physics solution. every game has it's own requirements
This is a long shot and it's something I only learned about recently, but could it be because of shared components? I have no idea how that would show up in that UI.
and I like how it's more ECS oriented as far as the interface (or so he says, tho I didn't look to deep into it myself)
ie queries instead of the hit collectors
Yes! Unity Physics always feels so weird to use in ECS
@gusty cometyou have nonuniformscale because your gameobject is scaled
why you dont't want to use subscene exactly, instead of converting at runtime?π€
you mean cus its not 1,1,1, ?
yes
you can process entities before loading them to main world(offsetting them for example), and there is subsections in subscene, so you can load or unload different parts of subscene(you can load different part based on distance from player)π€
as far as i understood it this is the place to ask burst related questions too, if it isnt though please tell me :b
im not quite sure i understand JobHandle.Complete();
im following this article (https://www.raywenderlich.com/7880445-unity-job-system-and-burst-compiler-getting-started#toc-anchor-001) to get into using burst and im not quite sure what happens when calling that method. does the job get forced to complete or does it force a return early if the job isnt completed ?
furthermore if i schedule a job once in create that i dont need to run constantly (only once) wouldnt it be unnecessary overhead to check if it completed every update ? or does the compiler just ignore it after i dispose of it ?
i know but why theres copyTransformFromPrimaryEntityTag tag?
and in second archetype its not there
@sour atlas it does force complete the jobs associated with that jobhandle. i assume they call it in lateupdate or something after starting the job in update
yeah, they do. is there a disadvantage to forcing a job to complete ? as far as i understand it the main thread creates the worker threads and schedules the jobs appropriately so forcing them to complete kind of seems like defeating the point to me ?
tbh im not sure about jobs from monobehaviour but generally you dont want to make a job in an update and immediate complete it in the same update because you can have hiccups if there are other jobs that might get force completed
oh does it force all jobs to complete ?
id have imagined it forces all jobs the handler scheduled to complete
well as I said im not sure about use from monobehaviours
ah, no worries.
but its easy enough to profile and see the effect of jobhandle.Complete(), worth actually doing it the "wrong" way to see the effect in action. I could potentially see it being useful in certain cases if you know you have a lot of data to process and could potentially do it faster with a parallel job with complete than doing it mainthread only
yeah well thats actually kind of what im doing id assume
for all practical purposes i need a gradient but as a float array so i thought parralellizing that would make a lot of sense lol
@gusty cometI guess it has something to do with sub meshesπ€
this component is added in ConvertToMultipleEntities(...) in RenderMeshConversionContext.cs
you have more than 1 material on your GO
thats why copyTransformFromPrimaryEntityTag is added
that makes no sense
i see no reference to material in the name "copyTransformFromPrimaryEntityTag "
yeah theres 1-4 mats
do entities help with rendering or gpu usage anyhow?
or anything beside hybrid renderer
im also wondering if hybrid renderer v1 is improving anything or just letting GOs and entities to be rendered at same time but without improving anything
@gusty comet So for some reason, Hybrid Renderer creates a copy of your entity for each material. That may be what you're seeing.
i think entities are not optimized for deactivation/deinstantiation, as doing that will trigger structural change/syncpoint
deactivation is a matter of adding/removing Disabled component = that changes archetype = moves entities to different chunks = syncpoint
according to this logic whether i deactivate or deinstantiate i will have syncpoints in every second, if i want to have some dynamic mechanism for eg stopping unseen entities from rendering
It's not, hopefully with enabled bits that will change. But no idea when that will come
are you referring to some not-yet-released feature
oh well, i am in bad situation then, cause unity's camera wont disable rendering of unseen entities
OR maybe it does actually..
How did you find that? Can you show me screenshot for that?
You most likely have a syncpoint at the start and end of every frame anyway. If not now, then you probably will. These are good places for carrying out batch operations like e.g. disable rendering of a bunch of meshes.
could you elaborate? how to reach what youre saying? π eg how to know if i have syncpoint there, and how to force my code to cause syncpoint in that moment
if you look in direction where there are no entities the gpu usage will be smaller in Stats, which is good
that's gpu culling - not rendering triangles in the frustum. Hybrid Renderer also already does camera culling based on mesh bounds. I assumed you're wanting to do some other bespoke culling on top of those?
yeah i toggle lot of meshes basing on distance
It's not very easy to see your sync points until you have a lot of work but the Timeline view in the profiler with Show Flow Events enabled is very useful. I believe rendering anything has a sync point - as all the transforms need to be up to date before uploading to gpu. But it's possible I'm wrong about that.
Are you familiar with the entity command buffers? These are buffers you use that are designed to run at dedicated sync points.
i heard about them but didnt use
That's how you e.g. destroy/instantiate/add/remove components at dedicated sync points.
The hard part for you will be how you store or evaluate which entities you want to change, without e.g. adding a tag.
One way is to use an ICD with a bool flag that you set and then check at a sync point. Another way is to simply queue an entity command buffer (which can be done in parallel + burst) that then executes at a sync point.
oh ok thanks will look into it
how to read and modify physics* colliders ?
thanks , any idea if its possible to read raw convex hull collider data ?
what's the underlying code for transform.translate?
I want to put it in a job
i think i got it
unsafe
{
var phy_collider = manager.GetComponentData<PhysicsCollider>( hit.Entity );
//collider.ColliderPtr->GetLeaf( hit.ColliderKey , out ChildCollider leaf );
ConvexCollider* collider = (ConvexCollider*) phy_collider.ColliderPtr;
BlobArray.Accessor<float3> verts = collider->ConvexHull.Vertices;
var l = verts.Length;
var v = verts[ 0 ];
}
had to expose ConvexHull so i changed it to public
but be aware that entities share same colliders
for example if you instantiate 1k entities and change collider like in this code, you basically changing all colliders
interesting didn't notice this before , im looking for the vert data so i can slice them up and spawn 2 new colliders
im not sure, but if you create collider yourself you will have to manage it's memory yourselfπ€
seems like convex collider makes them for us
ConvexCollider.Create(ConvexHullBuilder builder ...
that whole unsafe scope , arrow syntax which i assume are pointers and UnsafeUtility makes me wonder when my editor will start crashing
didn't take long to show me some obscure errors
Logically it's just position += direction;
I like how simple it is
Well yeah, it's just adding two vectors, there really isn't much to a translation
@bright sentinel doesn't seem to work I think.
my objects are going south
not where I'm pointing
code
[BurstCompile]
public struct RegularMoverJobTransform : IJobParallelForTransform
{
[ReadOnly]
public NativeArray<float2> Directions;
[ReadOnly]
public float Speed;
[ReadOnly]
public float DeltaTime;
public void Execute(int index, TransformAccess transform)
{
transform.position = Translate(transform.position, Directions[index] * Speed * DeltaTime);
}
private float3 Translate(float3 current, float2 direction)
{
return current + new float3(direction, 0);
}
}
Well could be that your directions are wrong
var component_types = entity_manager.GetComponentTypes( entity );
foreach ( var comp_type in component_types )
{
System.Type type = comp_type.GetManagedType();
//...
Why is type.BaseType is System.ValueType and not IComponentData ? ? ? ? It result in an error when I'm trying to make a generic method like so :
//...
var methodInfo = entity_manager.GetType().GetMethod("GetComponentData");
var genericMethodInfo = methodInfo.MakeGenericMethod( type );
That's the error I'm seeing
ArgumentException: Invalid generic arguments
Parameter name: typeArguments
System.Reflection.MonoMethod.MakeGenericMethod (System.Type[] methodInstantiation)
Because IComponentData is an interface. You can't make inheritance in structs (which are value types)
actually it was working until the look reach the Child component which isn't a IComponentData
( Child : ISystemStateBufferElementData, IBufferElementData )
how would you use impostors with dots?
oh well, i guess i have to somehow convert amplify imposts to be dots compatible, or depending how it works, i may have to store impostors mesh and then just load it with dots
but from what ive seen its changing the mesh all the time π
Never heard of impostors, what are they even?
impostors are fake 3d models that are '2d only' with proper rotation scale and position they look as if they were real models
https://assetstorev1-prd-cdn.unity3d.com/package-screenshot/ce9d59c0-6239-4151-b3ba-82efa6b0db87.webp
theres few impostor assets/engines
i especially need it for objects that are a bit further (if not for all) from player, i hope its easily convertable π, will soon attempt it
if i wont be able to convert it, however, it would be ironic cus id be getting more gains from it than from DOTS.. π
Oh, so billboard sprites. Well ECS doesn't really have 2D support, so I don't think you can do that
theyre still rendered with meshfilter
yeah but it's only 2 triangles
or you could hack your way through the vfx system but dunno how much more efficient it would be
I would start with a LOD system, then quad billboards if further needed
im fine with rendermesh component
the asset is nice and works unnoticeable at big distance but each model data is minimum 5mb lol i wonder how much memory will it eat with 500 models..
does it pregenerate the images for impostering?
yeah
how to access child parent relation in ecs ? i see there is the Child and Parent
but only the Parent is inherited from the IComponentData
and looking at one of the entities i got - it contains the child component in it
i guess it allows to limit the number of angles it generates and maybe their quality. that should reduce the memory footprint
i wonder if it does the correct angle texture selection in the shader
hv u tried this one ? https://assetstore.unity.com/packages/tools/utilities/impostors-runtime-optimization-188562
Utilizes max performance using Jobs and Burst
how to access entity child ?
it doesn't like var item = entity_manager.GetComponentData<Child>( my_entity );
since child doesn't inherits IComponentData but does IBufferElementData instead ? __ ?
ah nvm i got it
var childBuffer = entity_manager.GetBuffer<Child>( hit.Entity );
foreach( var well_buffed_child in childBuffer )
{
Entity child_entity = well_buffed_child.Value;
}
just need to use a buffer
Hello guys, I m actually starting using dots, I m using Unity 2020.3.8 with every package needed. I tried to create a system who manipulate a transform, but that 's doesn't work as expected lol.
I create a struct : private struct Group : IComponentData with a Transform, then in the OnUpdate I get every Entity (or GameObject) with :
Entities.WithAll<Group>().ForEach(
(ref Group Group)=>
{
var position = Group.Transform.position;
position += (Group.Speed.Value * DirectionHelper.GetDirectionalValue(Group.PlayerInput.DirectionValue)) * DeltaTime;
Group.Transform.position = position;
}
);```
But it seems that I can't get a Transform on the OnUpdate anymore, it says that transform is not primitive nor blittable.
Any idea how I can go through this difficulty ? π
For information, I m looking for a ECS Hybrid implementation.
Does EntityManager.CreateArchetype() require something specific for DynamicBuffers?
It tells me the buffer doesn't exist on the entity, even though it is in the list of components...
hey so i have a 1d array that i need to turn into a 2d array
ideally id like to parallelise this and as far as i understand i can use a job to do that however the 2d float array is not thread safe as far as i understand and that means changing it in a job doesnt actually overwrite the actual array, is that correct ?
Why not just remap indices @sour atlas ?
@dusty shuttleyou can't put managed types in IComponentData
Actually you can, as long as it's a class, not a struct. But it probably shouldn't be used
i need to pass the array to a terrain object and that only accepts 2d arrays
Alright, so what the good way do without the struct IComponentData to you guys? Thank you for your help
Seems like the Entity package works really differently than before ahah
heightmap = new float[size, size];
for (int i = 0; i < size * size; i++) {
int x = i % size;
int z = (int)(i / size);
heightmap[x, z] = heightmapBuffer[i];
}
heightmapBuffer.Dispose();
terrainData.SetHeights(0, 0, heightmap);
since the Parallel for job only takes an index i should be able to use this except as a job, but i cant override the original heightmap array from the job as far as i understand it
or is it possible to pass the reference to my array ?
Do jobs support arrays now? I thought they didn't
NativeArrays only i think ? im really new to jobs so i dont have much of an idea π
Yeah, I don't think they support any kind of managed array
Your best bet is probably using a direct memory copy
You'll need to make sure your array is properly aligned though
Something along these lines: https://stackoverflow.com/questions/55527580/how-to-convert-2-d-array-to-1-d-array-fast-in-c/55527679
i need 1d to 2d though
The reverse is also possible :)
oh, alright ill look into that, thanks!
Ideally whatever is processing the array in your terrain code should use a 1d array, as it's simply faster
oh right now its being read from a render texture
@dusty shuttle I would look at the ECS docs, they have a good introduction
which is written to by a shader
I think I may have found a bug, unless this is intended behaviour: https://pastebin.com/ZPmM32De
It feels like that shouldn't be happening...
@jaunty heraldi don't get this errorπ€
Very strange, it seems you aren't allowed to statically define archetype component arrays, even as a property.
Basically, something like this doesn't work:
public static ComponentType[] WorldCellArchetype => new ComponentType[]
{
typeof(SerializeEntity),
typeof(WorldCellData),
typeof(WorldCellNeighbour),
typeof(WorldCellEdge),
typeof(NetworkIdentity)
};
Changing it to a field will even throw an error on compile-time
Never read anything about this before...
I guess typeof() is somehow being overwritten and only works during runtime?
Still not sure why a property wouldn't work then however, since that is also during runtime...
Not even a method works 
But inplace it works for some reason, very strange...
@jaunty herald https://pastebin.com/dzVfAfsB this works just fine or i'm doing something wrong?
Try it as a field, it throws an error for me on compilation
i declared ComponentType[] as a field, assigned it in Start method and it works fineπ
Very strange, your example works in a standalone project.
Very odd, @warped trail . Maybe I'm just missing something simple π€·
If I put the array in the class itself, it works. So I assume this is some kind of static initialization / caching issue
oh, maybe it has to do with this fancy fast enter playmode?
No, I don't have that on.
i remember it has some problem with statics
It still seems like a bug. I feel like EntityManager.GetComponentTypes() shouldn't be returning types that aren't actually accessible at that time?
Any idea how to use native array instead of native list
Exactly like an array @fallen pilot
I am using an A* algorithm for Pathfinding and instead of native list I want to use native arrays
Then you need to find an upper bound for the amount of nodes in your queue / path, which is probably the reason why it uses a list in the first place.
Ideally, just use a list and initialize it with a high value, or replace the lists with arrays and check if the array is big enough before accessing indices. It's probably not worth it and very error prone however...
Since you will need to memcpy anyways if the array is too small
alright checked up on it and it seems thats not possible using the NativeArray class unless i am missing something. Itd be possible if i convert the native array to a managed array first and then use block copy but that seems like its going to be unnecessary overhead, any ideas ?
Why wouldn't it work? Nativearrays even have a copy from / to method for managed arrays
he has multidimensional array
Yeah, convert the multidimensional array to 1d, then copy
well it does work but converting to a managed array seems unnecessary given that ill be doing 3 copies that way, likely going to be faster to just iterate at that point ?
I doubt it, but you can just try
memory copy is very fast
Obviously depends on the sizes you are dealing with :)
There is no conversion, it's copying memory
its relatively large at 4097x4097
i mean internal native to managed
I feel like it should somehow be possible to create a nativearray from memory somehow, but that would probably be unsafe. Never tried it π€·
never really managed to find out how unsafe works in unity π
Maybe something along these lines could work, but it seems a lot of hassle. I would make sure you really need the optimization: https://docs.unity3d.com/ScriptReference/Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray.html
also surely it should be possible to pass a job the reference to an array and then work with that ...
Not sure what you mean by reference to an array. Jobs cannot use managed arrays at all iirc
as far as i understood it they can but itll never overwrite the original array and instead use an internal copy or something ? but i might have misunderstood
Hmm, haven't heard that before. But I haven't been looking either, I always just use the native collections for everything π€·
hrm. ill just go ask a friend, they use burst a lot so im hoping they know
Good luck! :) And let me know if you find out about managed arrays in jobs, that sounds interesting
Burst documentation says "Managed arrays are not supported by Burst" and "Burst supports reading from readonly managed arrays loaded only from static readonly fields"
read it here :
Restrictions of the Native Container
You cannot pass references to a job because that would break the jobβs thread safety. That means you canβt send in an array with the data you want as a reference. If you pass an array, the job will copy each element from the array to a new array within the job. This is a waste of memory and performance.
also where do i go to get help with unity hard crashing ?
ive been told its possible but messy and not useful at all in my case
How come when I'm using
var component_types = my_entity_manager.GetComponentTypes( my_entity_target );
It contains the ChunkWorldRenderBounds type , but when I'm trying to read it with GetComponentData it throws me the following error ?
ArgumentException: A component with type:ChunkWorldRenderBounds has not been added to the entity.
and in the same time
entity_manager.HasComponent( my_entity_target, comp_type );
is true o_O
Is ChunkWorldRenderBounds a shared component or managed component? I dont think the latter would be any different but former will require different syntax
what's a managed component ?
An IComponentData that is declared as a Class. You can place managed properties in it like strings or regular arrays. Downside is: you can not use them in a regular burst or multithreaded job.
ChunkWorldRenderBounds is a struct
If you dont use them, dont worry about it. Just check if it's a shared component.
Alright, so regular IComponentData. Then hrm, HasComponent() returns true but immediately after it says not added to entity? With the same entity?
wait what's the difference between shared and managed ?
i do checks for shared components
yes
interesting
The name ChunkWorldRenderBounds implies either a shared component or a chunk component. Probably the latter. Try using EntityManager.GetChunkComponentData() for that component.
is there a way how to check if it is a chunk component or not ?
don't seem like its possible
ill try HasChunk ...
Typically you know what component it is since you create the archetype. But if it's coming from HybridRenderer, no clue.
yes
hasChunk worked , i don't get any more errors and can finally parse the entity
There ya go. If you need to use ChunkComponents inside a bursted job, you'll need to dive into the "exciting" world of struct based job declarations. https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_chunk_component.html#iterating-over-chunks-to-set-chunk-components
thanks but approach doesn't use jobs much
not sure how cursed it is but it seem to do the trick
Hrm, are you sure about that? The entire reason to use DOTS is for the Job system and burst. Otherwise, it's a very inefficient way to create a bunch of arrays.
well i just need to modify the physics colliders
already found a way to read vertex data from the Collider Ptr with some unsafe code
now im trying to clone an entity
Oh alright, good luck then. Why not use EntityManager.Instantate?
will it copy all the component data as well ?
Yea
Hrm, no clue. DOTS emphasizes flattening your hierarchy so I've never tried to see if Instantate copies children. Probably not.
this example has 1 child that contains the renderer
in my case i would need to modify both the phyiscs collider and the mesh vertex data which exists on 2 different entities
Children is just a DynamicBuffer of Entities so 99% no, Instantate will probably not create a child entity.
well it does save me a lot of efford tho
i can just loop them kids and glue the parent value
- if using EntityManager.Instantate
Yes it does clone children entities so long as it's using a LinkedEntityGroup dynamic buffer of entities.
LinkedEntityGroup that;s a new one as well for me
Seems like you're very new to DOTS. Yea, the documentation isnt the best but all of this stuff is buried in there. LinkedEntityGroup is just the GameObject hierarchy translated to DynamicBuffer<Entity> via the Entity converter.
Honestly DOTS is an absolute mess. I dont recommend on using it unless you want to spend months doing the wrong thing until you stumble upon the correct way to code then throw the previous months work out the window.
I've been working with dots for a few years now. Do you need something specific? This channel is good enough. It's very quiet and more public information on DOTS is good.
~~doesn't seem to be happy when im trying to clone its children ~~
ArgumentException: A component with type:Child [B] has not been added to the entity.
~~at the second line : ~~
foreach( var child in entity_manager.GetBuffer<Child>( entity ) )
var copy_child = Instantiate( entity_manager, child.Value );
nvm that i had some recursion issues
Make sure to use EntityManager.Instantate, not the built in GameObject Instantate.
that's what i ended up with and seems to work so far
just need to figure out why the physics constants ( joints ) are not being cloned
Times like this makes me regret knowing DOTS so well. I am paralyzed with decisions. I have a Company entity that issues 100 shares. These shares are distributed among People entities. Do I throw efficient chunk layout out the window and create a DynamicBuffer of Entities (Entity struct is 8 bytes wide) resulting in an 0.8 kB memory utilization. This doesnt include the numerous other Components and Buffers also attached to the entity. Already, that's a max chunk size of 20 entities or less.
Another option is instead store an Entity reference on the People entities themselves. That brings into question whether a Top-Down iteration process is more efficient than a Bottom-Up connection. I've done far too many tests and it's still a toss-up on that.
Furthermore, I am struggling with the decision to use shared components to fragment my entity chunks and use chunk components. It'll simplify a lot of the value aggregation systems for various calculations but I'm concerned with all those warnings about over-use of shared components leading to inefficient chunk utilization.
I feel the same.
it's like eating the forbidden fruit of knowledge that is DOTS.
and now God(Unity) has thrown us out of the Garden of MonoB.
Yea, doesnt help that DOTS itself is fairly undocumented and truly efficient processes have to be found using brute force trial and error.
I have a 1000 line system where I test out various Entity hierarchy structures and data summation/aggregation systems to test performance. Very simple sum the value of 5000 entities grouped by a identifier property. I still have not attempted deliberate chunk fragmentation via shared components because I'm terrified of the warnings from Unity.
God(Unity) has forsaken us
if u r looking for optimal performance why not use something like gadot ?
Gadot?
Gadot? or Godot?
2nd one
also no, godot isn't as performant as you think.
If it's Godot, Godot is not performance friendly. Burst and the Job system outstrips anything out there by orders of magnitude. I'm talking about microsecond improvements via rearranging Entity component structure.
compared to dots
Anyways, I'll just post the various results I got from testing in this channel. Time values obtained from the Profiler and eyeballing the times so they're not the most accurate of values
what about something like this https://www.youtube.com/watch?v=tInaI3pU19Y
Comparison between one of Unity's sample ECS/DOTS projects, and a "from scratch" cloned implementation using C++ and OpenGL. Bringing some data to the game engine discussions. Custom game engine vs Unity DOTS!
Unity sample project repo: https://github.com/UnityTechnologies/AngryBots_ECS
C++ clone source: https://github.com/ntcaston/AngryGL
Yo...
That's a super unfair comparison that doesn't really have much real-world impact
but it does reach optimal performance for an edge case
Hrm, Im not using hybrid renderer. Personally, I think HybridRenderer was a mistake.
why is that ?
If you need anything done graphically that needs entities, just do it in ComputeShaders
true it would be faster
And roll your own solution with a bunch of arrays.
Just write it in assembly and then you get all the benefits
Anyways, the entity relationship is as follows:
Entity People
Component int Quantity
Component Entity Province
Entity Province
Component int Survey
Component Entity Country
Entity Country
Component int Census```
Provinces sum the `Quantity` of People entities that contains the corresponding Province entity component into `Survey`. Countries do the same with Province `Survey`s into `Census`.
This exact structure changes between tests which I'll describe per result.
The comparisons between different things like this do not make sense practically, that video is comparing an old entry-level ECS implementation without any acceleration from burst or jobs. It's a surface level clickbait comparison of two things with completely different capabilities, one's an ecosystem enabling fast and varied code, and the other is a specific implementation authored to do one exact thing.
The first attempt was Bottom-Up iteration structure.
Each Person Entity used their Province entity component to query and set the Survey component using GetComponent() and SetComponent() in a singlethreaded Schedule(). The same with the Province -> Country.
Result: ~ 0.11 ms to 0.13 ms. Occasional spikes to 0.3 ms+.
well yes but somebody who knows how to openGL with cpp might not need 90% of what a game engine has to offer and could potentially make a simple game / app using this approach
Sure, but that's not what 90% of the people watching the video are there for
it's just a great avenue for complaining
Second attempt was another Top-Down iteration structure.
There was an external NativeMultiHashMap where a first stage per Person entity ForEach would populate the native container using Province Entity. A second stage using Provinces and Countries (with a dynamic buffer of all related Province components) scheduled with ScheduleParallel() and in parallel with each other using manual dependency handling.
Result: ~ 0.1 ms to 0.5 ms depending on cache miss. Using external native containers such as NativeMultiHashMap seems to massacre performance. What I learned is to be very hesitant on using them.
It could be something I was doing wrong with the NMHM but the random read write parallel performance was not good.
Third attempt was the extreme version of Bottom Up iteration.
It denormalized the entity relationship to which the People entity would contain references to both the province and country it resided in and used a singlethreaded add to both the Survey and Census quantity of both Province and Country entities.
Result: ~ 0.13 ms to 0.5 ms in a single job thread. Definitely not good.
quick question , when inspecting chunks in the EntityDebugger does it mean those are unique entities ?
The fourth was a Top-Down iteration.
Each Province and Country would contain a DynamicBuffer<Entity> of the related children entities. Using a rotating buffer of Read-Write access, it queried the childs' int quantity component and summed it.
Result: ~ 0.08 ms. The best result yet. Why? I am still trying to find out.
Unique entities?
Those are unique archetypes.
can an entity exist inside multiple archetypes ?
No. An entity is characterized by a set of Components. The collection of which is an Archetype. Multiple entities can have the same set of components types (doesnt need to be the same value).
It's like a Class of entity.
An object can only have 1 class. Multiple objects can have that same class but an object can only be of one class.
Unlike a object, you can add or subtract different properties to that class at runtime, resulting in a different class or completely new class. Replace all class with Archetype and that's DOTS.
so a chunk is a list of similar archetypes ?
A chunk is a list of Entities with exactly the same Archetypes
It's like an array of objects. That array can only be of one class (ignoring interfaces). If you add a new component to that Entity, it must move to a different array or create a new one.
if you add a new component type that is ?
It's like adding a new property to a class. A new float value or something else.
Good luck. DOTS physics API is very raw. I'm personally holding off until the next release of DOTS packages (probably in a year or two, thanks Unity) before experimenting with it.
Good luck. I couldn't understand a single line of the source. If I ever get to the point where I need my own physics engine, I'll throw myself at the research papers of GPU side physics rather than languish in CPU hell.
oh man that's like the dream
I mean, how hard can it be. The GPU already has vertex data due to needing to render it. Simply do physics as well. Yea.
there are few attempts on the web so far ( unity )
nothing that is stable / easily usable
mainly been looking at water simulations
but those aren't bidirectional ( it only reacts to the normal physics )
Yea, mainly abandoned projects or proof of concepts. I mean, I technically roll my own screen based raycasting system onto a sphere but that's simple mathematics.
there is a Gpu based raycaster repo
not sure if its the same as u did
https://github.com/staggartcreations/Graphics-Raycast
Probably not. I display the UV of a sphere as the texture of the ball. Then sample it both to display texture in post processing and calculate clicked location.
if u decide to do something like this give me a ping , im interested in making something similar to teardown
is there a way to use Entities.ForEach outside of SystemBase and in IJob ?
i think i found it but its obsolete .. ?
It tells you what to use
reading IJobChunk now
not sure if im doing it right , but the amount of code it takes to do a simple search is ridiculous
public struct JointBodyPair
{
public PhysicsJoint joint;
public PhysicsConstrainedBodyPair bodyPair;
}
JointBodyPair[] FindTargetJointFor( Entity target )
{
NativeList<JointBodyPair> result = new NativeList<JointBodyPair>( Allocator.TempJob );
EntityManager entity_manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var job = new CloneJointsJob()
{
Handle_Joint = entity_manager.GetComponentTypeHandle<PhysicsJoint>( false ),
Handle_Pair = entity_manager.GetComponentTypeHandle<PhysicsConstrainedBodyPair> ( false ),
target = target,
output = result
};
var query = entity_manager.CreateEntityQuery(new EntityQueryDesc()
{
All = new ComponentType[]
{
ComponentType.ReadOnly<PhysicsJoint>(),
ComponentType.ChunkComponent<PhysicsConstrainedBodyPair>()
}
} );
job.Schedule(query).Complete();
//job.ScheduleParallel( query ).Complete();
var data = result.ToArray();
result.Dispose();
return data;
}
public struct CloneJointsJob : IJobChunk
{
[ReadOnly]
public ComponentTypeHandle<PhysicsJoint> Handle_Joint;
public ComponentTypeHandle<PhysicsConstrainedBodyPair> Handle_Pair;
[NativeDisableParallelForRestriction] public NativeList<JointBodyPair> output;
public Entity target;
public void Execute( ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var value_joint = chunk.GetChunkComponentData( Handle_Joint );
var value_pair = chunk.GetChunkComponentData( Handle_Pair );
var data = new JointBodyPair
{
bodyPair = value_pair,
joint = value_joint
};
if (value_pair.EntityA == target || value_pair.EntityB == target )
output.Add( data );
}
}
Do you have to use an IJobChunk? If you do, yea that's about normal.
as u suggested
what i need is a way to iterate all chunks of PhysicsJoint & PhysicsConstrainedBodyPair
if this would be an option it would be ideal
whenever i do dots i have an odd feeling that somebody wanted to over engineer the framework for some reason
Hrm.... yeaaaa. Such is life. I'm doing something similar because I'm trying to do some summations into a chunk component and thus have to use miles of boilerplate IJobChunk structs. Fun.
Welcome to DOTS. Where everything is simultaneously overly complicated and also half baked.
its like giving us a half baked abstraction layer for multi threading without the actual access to the low level stuff ...
On the flip side, if you use IJobChunks everywhere, you can use ISystemBase and go all in on the structs and BurstCompile everything.
bursting all sounds promising
funny i just realized the code above runs without errors but also returns zero results ...
Kinda, the catch is that the only nativecontainer you can use is NativeArray and Entities.
I want to use a native multi hash map but it's so fucking hard. Why Unity...
doing grids ?
Nah, just parallel summation.
when i need code examples i do the following : https://github.com/search?p=2&q=NativeMultiHashMap+grid&type=Code
Nah, I know my way around unity collections by now. It's just trying to get it to dispose while burst compiled is the problem.
Burst is amazing, but also very dumb.
lol
SystemState is something in dots ?
Yea, it's the various functions available in SystemBase. Since structs can not extend anything, it's all storied in SystemState
also i think i see why it didn't look for all the elements, but now i wonder if those arrays would be aligned or not ... π€
Oh yea. Since you're not using a lambda function, you'll need to guarantee component alignment manually.
in the debug dialog those look like they are already aligned
It is, Unity does it somehow. The Entities.ForEach() lambda function is translated to a simple IJobChunk at compile time.
Anything you can do with a ForEach you can do in a IJobChunk, just with a lot more code.
Yep, that's what we all are doing. And what i'm trying to do with this.... and Unity crashed. Fun.
Fyi (earlier post I saw), Instantiate can also take an array of entities - in case you donβt have a linkedEntityGroup and it correctly replaces inter-entity references- pretty useful
Alright, this does work. Do not remove the ref anywhere. Burst will cause Unity to crash if removed.
Can you make that nmhm persistent instead?
Nope, you cant store managed components in the property field of a bursted system. It basically becomes a IComponentData.
I think as long as you use a ref itβs fine?
Ref where? The interface between [BurstCompile]'ed code and [BurstDiscard] managed requires the ref but storing it as a property of the system itself doesnt work.
Does anyone know how to schedule a NativeList.Sort after a job that uses the list? It appears to me like using the dependency JobHandle from the prev job does nothing as the unsafe pointer is accessed when Sort is called
Does this not work?
var job = Entities.ForEach().Schedule(Dependency);
job = NativeList.Sort(job);
Dependency = job;```
Or are you using struct based jobs?
I am not using Entities
I do something very similar with an UnsafeHashMap - it's possible there's a safety issue when trying to do the same with a NMHM but it's worth a go. Psuedo-code:
{
public NativeMultiHashMap myHashMap;
OnCreate -> myHashMap = new Native.... blah
OnUpdate
{
ref var hashMapRef = ref myHashMap;
}
}```
Alright, show me your scheduling chain.
How is that possible? Burst complained that NMHM was not possible as the property of the struct. Are you bursting everything?
The problem is that the Sort utility expects a pointer to the data but the List could reallocate the buffer anytime you add a element to it. Your best bet is to write your own job to which you pass the NativeList and then call Sort yourself. I think someone at Unity just missed that...
Seems pretty silly to have a dependency-based system you can't usefully use
It may be you need to use an UnsafeHashMap then. Got a bunch of them in fully bursted ISBs:
that would make sense as it's the dispose sentinel I think that is the managed part of the default collections
Hrm yea, as Script said, if you add or subtract anything to that list, it invalidates the list reference. Consider instead using IJobParallelForDefer and then rolling your own sorting algo.
{
public NativeList<int> ListToSort;
public void Execute( )
{
ListToSort.Sort( );
}
}```
That should work fine. Dunno why the collection package doesn't do that internally
I'll give it a shot, thanks π
Or that. Makes it simplier.
hrm, that makes sense. Yea....... hrm.
Yea, it's a pain. Wouldn't it be nice if the dispose sentinel was unmanaged in the next update. Wondering how that doesn't break everything though.. guess they'll have to introduce a new collection of collections? π€
Might not be worth switching to unsafe but if you're measuring times of 0.08ms, I'm guessing creating the hashmap is a note-worthy part of that.
Yea, I'm attempting to remove the need for the NMHM entirely.
Hrm, odd. Even with UnsafeMultiHashMap, burst still can not schedule a dispose job
do you need to dispose anymore? Other than in onDestroy obviously.
This however seems internal and not something I can fix.
Occasionally, the capacity of the MHM must increase. It's based on the chunk count of another entity archetype.
I could add a check and then do a burst-discard to recreate the NMHM if the capacities are different.
From 0.08ms to 0.07ms. A 12.5% improvement
The offset job scheduling takes as long as the job itself. I haven't found a way to reduce that other than using read-write buffers and attempting to merge the scheduling, which doesnt work with a MHM being passed between the two.
Yea, job scheduling and dependency chaining is a killer right now unless you're scheduling a tonne of data.
The dependency chaining is esp frustrating when nothing else changes. I Know it's cool to be stateless but there feels like so much of the same work done every frame when nothing changes.
Well, there is chunk.DidChange() or the change filter. It's very sensitive since I'm fairly certain even looking at it (using readonly getcomponent via entity reference) causes a change in chunk.
That's unrelated to e.g. dependency = blah
Yea, the scheduling is questionable at times. I had a long writeup where I experiemented with entity component structures and manual dependency scheduling to get minimal job sync points. The main problem I found was the enforced "sync" point between system boundries. Jobs from one system must be finished before the next system jobs can run even if the various read-write dependencies dont clash. So turning of JobsDebugger and manually scheduling across systems was required.
I can understand why Unity did that. The order of systems are not guaranteed at runtime if there is no [UpdateBefore/After] tags but it would be nice if the automatic dependency handler would recognized when two jobs scheduled one after another can be run in parallel without having to manually use JobHandler.CombineDependencies().
I mean, if you read the documentation, it makes it seem like the automatic dependency handler is magic:
But if you check the profiler in practice, it's absolute shit.
I kind of agree with that (though in the context of a 'full' game or app I can see how that becomes less relevant). The part I'm talking about is the work done to a) distribute work to workers and b) evaluate those inter-job dependencies. It's the same every frame, despite often nothing changing. I understand knowing when to invalidate cache then adds a lot of complexity and it's probably smart not to have that complicate things while trying to build the core libraries.. but I hope it isn't the case forever.
Yea, Dependency can be a lot smarter. I mean, Unity already caches EntityQueries for job scheduling, why not go the next step and cache the result. People already throw around 16 GB of ram on their mobile phone, surely some of that space can be used to store scheduling data.
I also like nice solid green bars of job thread utilization. Makes me feel nice and warm inside looking at a profiler with full job utilization.
All the system boundaries have giant and obvious gray gaps. Makes me feel sad.
As e.g. whether a job is running can change every frame, I think their preferred approach is currently to get burst working for everything - then if that work still happens fresh every frame it's no big deal. That probably is a better solution if it ever gets there/fast enough.
Oh fuck, look at the time. It's almost morning. Time to sleep.
does DataFlowGraph with ECS allow doing stuff like multithreaded recursion with thread internal state?
Hey! whats "dots"
It's more atomic, so yeah easier to read and reuse π
agree
But yeah for a new in the team who doesnt know yet all the systems....
there's def more boilerplate but... we just skim that
they still advertise that dotssample there tho
which I'm pretty sure doesn't run even with the specific version they say because their package store sends junk instead of the correct package versions when you try to load it
Yeah thats probably my problem.
hey guys, if I have entities with collision filter in their physics shape that states "Belongs To: 24", how do I make the same collision filter in script?
new CollisionFilter
{
BelongsTo: 24
}
doesn't work for some reason?
Try BelongsTo: (uint) 1 << 24
or maybe (uint) (1 << 24) just to be sure
yeah, for some reason this doesn't work.. i'm trying to filter my raycasts. some examples online state this refers to the bodies LayerMask and not CollisonFilter?
my understanding here is lacking, if I want the raycast to only hit certain objects, do I specify here their layer or their collision filter?
so let's say I have a layermask, my collision filter should look like:
new CollisionFilter
{
CollidesWith = (uint)HostileMask.value
}
``` ?
(this doesn't work either, btw π¦ )
Well hard to debug on discord, do a test in a simple scene with an easy setup ?
are there any docs with examples regarding collision filters? I can't find any
thanks, but they are always using 0 so there's no actual filtering going on
yup
All examples I've seen use Default and I didnt try filtering yet. Or maybe I did in the past but I dont remember sorry
it would make sense if collision filters referred to other entities collision filters when filtering, rather than their LayerMask
it does smthg like that with the CollisionFilter.GroupIndex
I fixed it
!
var collisionFilter = new CollisionFilter()
{
BelongsTo = ~0u,
CollidesWith = 1 << 24,
GroupIndex = 0
};
If they are equal and > 0 they collide, if negative they never collide
had nothing to do with LayerMasks
Nice
just needed to specify the other parameters.. pff
Isn't it what I told you ? more or less :p
yes, thank you π
Oh I see they are not facultative :p
IIRC same thing if you generate collider shape from code, need at least to pass quaternion.identity if you dont need some specific rotation. Or smthg along these lines, it was a long time ago not sure I remember well
Is dots stable? If not, when will it be
guaranteed by 17th August just not sure which year yet
no
Reevaluating what data is actually being used and reorganizing the entity component structure results in over 50% job run time reduction
Solid green, it's beautiful.
that is beautiful
Right, verified that all the values are changing as expected. Here's how I achieved that performance: Rotating read-write buffers and manual dependency handling.
A lot of my entities depend on the components changing in other entities. Normally, this would require GetComponent<>() and a series dependency chain. But do entities really need to know what the component value is this frame? Introducing: Read-Write buffers. Parent entities would write into a WriteOnly HashMap<Entity, Component> and Child entities would read from a ReadOnly similar hash map.
private UnsafeMultiHashMap<Entity, int> _censusRead, _censusWrite;
private UnsafeHashMap<Entity, float> _budgetRead, _budgetWrite;```
At the end of the frame, the variables are swapped and the write buffer is cleared. That results in a delay of 1 frame before the child entity reads and recognizes changes to the parent entity component but that I believe is acceptable since now everything can be scheduled into a single "block".
And strangely enough, ParallelWriter has better singlethreaded WriteOnly performance than the base NativeContainer.
It also somehow signals to the job scheduler to merge the GetChunksAndOffset job to run in parallel with the other jobs. Otherwise, it would schedule like this:
No clue why, nothing changed other than the removal of AsParallelWriter() for a singlethreaded job
how to debug inside a job ?
Turn off burst in top menu
@gusty comet @hollow jolt There's no memes or other off-topic media
i disabled burst compilation but still can't catch breakpoints
Not sure then. Maybe someone else knows
Is 0.15.0-preview.21 a recent version of Unity.Collections?
I'm trying to foreach a NativeArray (not in a job, it's part of my saved game system) and getting this:
Unity.Collections.NativeList`1[T].System.Collections.Generic.IEnumerable<T>.GetEnumerator () (at Library/PackageCache/com.unity.collections@0.15.0-preview.21/Unity.Collections/NativeList.cs:661)
SadnessMonday.DiscIndustries.Data.World.SystemData.PopulateFluidBuffers (System.Collections.Generic.IEnumerable`1[T] fluidBuffers) (at Assets/Scripts/Data/World/SystemData.cs:46)```
There's no mention of this not being supported in the docs as far as I can tell π€
https://docs.unity3d.com/Packages/com.unity.collections@0.15/api/Unity.Collections.NativeList-1.html#Unity_Collections_NativeList_1_GetEnumerator
i suspect the is no data for the job to iterate thru
is there a way to find out how much data does a query holds ?
that's what i tried so far
it should be possible to loop it normally with a for loop
It is - I'm just wondering why they bothered implementing IEnumerable if it's not implemented
As it is - it makes my code a bit awkward, and leaves me exposing the NativeArray directly in places I'd rather not expose it.
I guess some parts of Dots is still WIP
fair enough - it is a preview package after all.
how do i get existing archetypes ?
so i tried Entities.ForEach , then* i tied IJobChunk via EntityQueryDesc but still was receiving 0 results
in the end i just used entity_manager.GetAllEntities(); inside mono and scanned them manually
which seems to do the trick
query.CalculateEntityCount() ?
Never tried that one don't know if it works
When setting component data "Parent" it takes the child buffer some time before it auto regenerates, is there any way to know exactly when does this would happened ? rn im waiting for next frame to continue the operation ( yield return null inside a coroutine )
@hollow jolti believe it happens in endframeparentsystemπ€
So... for all you guys who want premade DOTS/ECS with a hybrid reference to the player so you can move it via monobehavior scripts and keep proper design patterns, this is da bomb! http://crystalfighter.com/bin/wumbla.zip
I just did it for a guy who came on my stream, only took 3 hrs.
Its a basic project DOTS/ECS, but also the ability to touch DOTS/ECS via Monobehaviors and singletons
So... for all you guys who want premade DOTS/ECS with a hybrid reference to the player so you can move it via monobehavior scripts and keep proper design patterns, this is da bomb! http://crystalfighter.com/bin/wumbla.zip
I just did it for a guy who came on my stream, only took 3 hrs.
Its a basic project DOTS/ECS, but also the ability to touch DOTS/ECS via Monobehaviors and singletons.
Its totally missing documentation:
Basically the magic is in:
Movement Data Authoring Script for Data
Identifier == 1 is the only one linked.
Identifier takes the entity and shoves it in a Singleton to reference. This is because Unity Engineers in their grand wisdom can't simply link indexes to Entities so you can drag and drop GameObjects to be converted into Entities directly into Entities.
DOTS_ID_LINKER.cs is where you manually link the number to a public static Entity in GameBoardModel(singleton)
DOTS_MATRIX.CS processes the job on the Movementdata.
ProperHyrbid/playerControls.cs shows the proper data pattern for taking a player controller on an already working game, and controlling an ECS player!!!! Just do if statements for the gametype running. This is proper design pattern, instead of many functions, write one, instead of many player controllers, write one, and branch if statements based on game mode, gameObject or Entities! This is amazing!
Of course all your enemies and other things should not be in monobehaviors, but the ECS jobs... But some things reaaaaaly need Monobehavior still, like aiming your camera, etc etc, and this shows you how to do this too.
I think this is the CORE starting place for many game devs who wanted to get into DOTS but couldn't get anything to work... This has all the packages and stuff already linked which is no trivial task.
disclosure: I'm heavily skeptical about this being useful or a good idea and I'm not about to download a random zip file - that said, can't simply link indexes to Entities so you can drag and drop GameObjects to be converted into Entities directly into Entities - just checking you know that if you reference a GameObject with the GenerateAuthoringComponent, it will automatically be converted to a referenced Entity. The idea being e.g within a subscene you can have references between GameObjects like normal (drag & drop). Might not be related to whatever this is but sounded like some overlap.
yeah I was going to say surely its better to use an open github or some other similar for something like this, random zips are highly risky
Does anybody know what DotsRuntimeBuildProfile is good for as it does not seem to be used at all. The ECSSamples build configs just use the ClassicBuildProfile (or in case of BaseBuildConfig none at all)
That could be possible as I wouldnt even be able to make it work as the target dropdown does not work but it requires a target
Where do you begin trying to debug this warning? I looked at the docs but they don't help me track down the cause of the warning π¦
at Unity.Entities.SystemBaseRegistry.CallForwardingFunction(Unity.Entities.SystemState* systemState, int functionIndex) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:307)
at Unity.Entities.SystemBaseRegistry.CallOnUpdate(Unity.Entities.SystemState* systemState) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:346)
at Unity.Entities.SystemBase.UnmanagedUpdate$BurstManaged(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBase.cs:464)
at Unity.Entities.SystemBase.Unity.Entities.UnmanagedUpdate_00000F27$BurstDirectCall.Invoke(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails)
at Unity.Entities.SystemBase.UnmanagedUpdate(System.IntPtr pSystemState, ref Unity.Entities.SystemDependencySafetyUtility.SafetyErrorDetails errorDetails) (at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBase.cs:445)
While compiling job: System.Boolean Unity.Entities.SystemBase::UnmanagedUpdate(System.IntPtr,Unity.Entities.SystemDependencySafetyUtility/SafetyErrorDetails&)
at [dir]\com.unity.entities@0.17.0-preview.41\Unity.Entities\SystemBaseRegistry.cs:line 307
Oof wall of error lol
One time I've seen a similar error is I think trying to use ISystemBase with a non IJobChunk (e.g. IJobEntityBatch)
Yeah as I said in my post, I already read that but it offers no help as to working out where the issue is
It's all just SystemBase, no separated jobs outside of Entities π¦
If only it gave even just a system to look within it would help :(
Hrm, a burst warning. Does it still occur after a restart of the editor?
Yes, it only appears on build though
Using any generics?
@amber flicker nope π¦
Right, I just built my project that uses multiple unmanaged ISystemBase systems for the first time and didn't experience this error. Have you narrowed it down to something specific?
Wait hrm, I build using Debug release because I use virtual texturing and HDRP does not properly compile virtual textures in release or master builds so no clue. Have you tried building in Debug mono/il2cpp versions? Attempt Mono first as that does not strip code.
Unity Plz: Reinterpret method for NativeArrays.
GetDynamicComponentDataArrayReinterpret The fuck is this? No documentation at all but it may be what I want.
The method's code looks fairly complex but I trust unity to have optimized it to hell and back for Burst.
Yea, it's what I expected it to be. Probably what is used in the generation of the Entities.ForEach code. But my god my eyes bleed looking at the giant method name.
In fact, chunk.GetDynamicComponentDataArrayReinterpret() has the exact same backing code as chunk.GetNativeArray(), just the type is obtained from different places.
And thus by the power bestowed upon me by Bill Gates himself, I say Fuck You Unity and rewrite the method name:
public static NativeArray<T> GetArrayReinterpret<T>(this ArchetypeChunk chunk,
DynamicComponentTypeHandle handle) where T : struct
{
return chunk.GetDynamicComponentDataArrayReinterpret<T>(handle, UnsafeUtility.SizeOf<T>());
}```
There is a Reinterpret<T> method for native arrays. No need to jump thru hoops:
var previousData = batchInChunk.GetNativeArray(PreviousCharacterCollisionDataHandle).Reinterpret<CharacterCollisionData>();
Normal ComponentTypeHandle<T> and everything
Wait what.
Arg, making me get out of bed and squint at the bright computer monitor just to see if that is true...
I am blind. Fuck. Thanks.
it's also on DynamicBuffer<T> too. For the exact same reasons
Does anybody have experience with creating custom build pipelines. At first it seems to be extensible as you could derive from ClassicNonIncrementalPipelineBase and build your own pipeline from a list of build steps. But then there is no way for it to be 'selected' easily as they just use an instance of the first found class derived from ClassicNonIncrementalPipelineBase
It looks to me like the only way to use a custom pipeline is to also create a custom build profile (IBuildPipelineComponent) and a custom BuildPipelineSelector which would be mostly copy/paste
It seems to be even more annoying as all the existing build steps are private. So I cannot even use them in a custom pipeline π£
The post was made on the 23 April that's quite a big jump from the time of setting the forum public lol
practically realtime on dots timescales
can you use unity dots jobs with the build in renderer or is that only available to urp / hdrp ?
u can
Hrm. I can't say if half a year to annual release schedule is "landing all the time" but whatever you say Unity.
landing all the time but only gets released with the main entities package it appears
It's actually a blessing in disguise. I've really gotten to learn the various quirks and syntax of fairly obscure parts of the ecosystem. I would imagine some would get thrown out the window next decade when the next release finally gets shipped to the public but I'm actually getting shit done rather than wondering through and getting sidetracked with the newest feature.
id rather have frequent updates π€·ββοΈ
I would settle for even less. Someone from Unity to finally recognize DOTS existence again.
Also note: DynamicBuffers have terrible performance. I'm half convinced it's just a thin wrapper around a component with an UnsafeArray property.
well you got your wish, updates are really slowing down from once every other week, to once a month and now its looking to be once or twice a year
im glad cuz i despice urps limitations and hdrp is unfinished / overkill
@robust scaffold terrible performance compared to what?
Basic blittable components. Just getting an empty size 0 Buffer on a component takes as long as iterating through a set of float components with random read-write with another entity.
Which is why I'm convinced that DynamicBuffers are just a fancy version of a regular component with a UnsafeList pointer property. Best practice is to avoid using UnsafeX as properties in components because they wreck the cache alignment since they're pointers to distant places in the memory and not nearby in the various CPU level cache.
it depends what you set as capacity
InternalBufferCapacity(0) and a TrimExcess() on creation. Nothing in the buffer.
so you're not fetching any elements? just fetching the dynamicbuffer itself is slow?
The job just checks if the buffer IsEmpty. No elements. IsEmpty is a property on the DB.
oh that's weird
Well, it doesnt even branch, if or if not it IsEmpty, it returns.
wonder why that'd be slower than a regular component
btw checking if an UnsafeList on a component is empty should be just as fast as a regular component too
you wouldn't need to go outside the chunk for that
it's not an unsafe list internally per-se, but it's not far off.
It'll use the internal capacity buffer list on the component itself, and then when exceeded will swap to a dynamically allocated buffer.
setting the capacity to 0 forces it to be dynamically allocated ALL THE TIME
yea but the length should still be a struct field so if you're just checking isempty should be the same
also, if you're measuring in the editor, make sure the leak detection setting is either on or off, not full.
You may also be getting overhead from the container safety checks
Nah, it's just plain on but this is a bursted system. Leak detection is automatically off.
leak detection is not automatically off in a burst system in the editor
you have to manually disable it as a global setting
and DynamicBuffer is treated like NativeArray and has safety checks
Doesnt seem to have changed anything with it off.
Still averaging ~0.03 per thread for doing nothing but accessing.
Hrm, that may just be overhead
they have said there's some job and data access overhead they're working on optimizing out now that burst is fairly stable.
Also the safety system currently uses managed objects at various points, I know they said somewhere they wanted to make it purely unmanaged.
That overhead should dissappear outside the editor
as the safety checks and additional editor overhead doesn't exist in a built player
Anyone knows if DOTS Netcode already supports ghost ownership transfers?
Yea, it's the buffer access. Hm. Well, I really cant do anything about it. I need a dynamic resizable list and I would imagine Unity at least attempted to optimize DynamicBuffer rather than just porting over UnsafeList.
Well, technically I could go around malloc myself a fixed sized struct to use as a "list". I know FixedList<> is one of them.
I mean, if it's really bothering you, you could put this stuff in an ISystemStateComponent that contains an UnsafeList<T>, alloc when the ISystemStateComponent is added, dealloc when ISystemStateComponent goes out of scope.
I've played with this before and it seems to work ok. You just HAVE to make sure you clean everything up properly.
FixedList would work but it could bloat your component size and cause fragmentation
depends on capcity size
True, although I may be going counter to best practices. I actually want boated size as I need my chunks to fragment. I'm currently using a chunk component as a "regional" bank and already fragmented my entities using a shared component so the chunk utilization is already awful.
Still, the performance is amazing. Memory usage, not so much.
Still the memory usage pales in comparison to the four 16k x 8k textures I have plastered on the screen at all times.
What I have to ask is: Why Unity does the FixedLists go from 128 to 512. I need more than 15 elements but not 63 of them. What's wrong with 256?
And oh yea, I'm doing that already with the references to BlobAssets. I really dont want to create unique disposal system for every singleton containing a BlobAssetReference so I just use a sharedsystemstatecomponent with a List<IDisposable>.
You mean on connection lost ? Never saw anything about that, think you have to implement yourself. Maybe it's too soon.
In my case a stationary weapon that can be entered by a player who should then start predicting it.
My current approach for this has been to create a separate predicted entity that gets instantiated once a player enters it and despawns when he leaves it.
I was just wondering if Unity already allows for changes to the GhostOwnerComponent after spawn. I know that wasn't possible a year ago and I haven't checked it since.
Nothing in the changelogs to indicate the situation has changed within the last year
Yea.. It's probably still determined when initially spawning the ghost
Not good. Although I need to compare to a DynamicBuffer with size 16.
that's a lotta dividends
Just slightly worse.
It's about 12k entities, each with a dynamic buffer of size 16.
Can you handle it as any other weapon ? But everyone has one, kinda hidden, and you auto switch to it when a player enters the turret π€·ββοΈ
I'll stick with my current approach of having the standard interpolated entity and a client predicted one that is dynamically spawned.
It worked fine so far I was just hoping that they simplified the process by now.
Thanks for the suggestion tho π
I swear I read this somewhere but a dynamic buffer containing an entity reference (entity property) will have that element destroyed when the entity it references is destroyed. All I can find is HasEntityReference on the ComponentType but nothing uses it.
That would be a crazy design choice and break a lot of stuff I'm doing in my code base
It's only the LinkedEntityGroup that destroys it members when being destroyed
Hrm, guess not then. Huh.
@robust scaffoldthere is chunk.GetUntypedBufferAccessorπ
and this accessor has GetBufferLength() methodπ€
at this point, updates would prolly be once every 2 years by 2022
Why is ISystemBaseStartStop Internal?
I suddenly realized the existance of unmanaged OnStartRunning and OnStopRunning yet Unity made it internal. Why?
I should start practicing my dots again.
I haven't touched my dots project in so long
I wonder about that too - but considering the limits of ISystemBase not generally surprised it's not* publicly available
I actually copied over the Entities package and made ISystemBaseStartStop public. OnStartRunning and OnStopRunning dont actually get called. They aren't hooked up somewhere to the event system.
Ah...that's a shame
ISystemBase is apparently going to be ready for use in the next release
whenever that happens to be
Exactly, whenever that happens
Also, damn. My bigbrain shared component filter job scheduling is not so big brain.
just like enable/disable right?
thats what im fearing
honestly, I feel enable/disable is probably farther out than ISystemBase
ISystemBase implementation gets immediate gains to scheduling performance and System overhead.
They've already done a lot of the lead work by converting more of the EntityManager and EntityQuery stuff to structs instead of value types.
enable/disable is more of a "nice-to-have" that happens to have the bonus of being familiar to most existing Unity users, and it's main perf benefit is fewer structural changes & being able to skip disabled entities for processing.
the current rate of updates makes it hard for me to judge how things are shaping up now tbh
also the original estimation was 3weeks to 3months last year at this time(welp), im not upset that its taking longer, just that everything seems to be slowing down (from my perspective)
Oh man same. They clearly have messed something up cadence/compatibility wise. Makes you wonder how many years it will be until we get past experimental and preview on the core, let alone the surrounding features like animation/audio/particles/vfx
I always wondered if it wouldn't be simpler to make a DOTS branch of Unity to begin way.
That way compatibility issues would be instantly visible when merging new engine features and the DOTS packages could be shipped in lockstep with a version they know works.
The release cycles have slowed down like crazy since the last year which is pretty frustrating when Unity staff tells you they fixed something but you still have to wait 4 months before you can try the fix out..
agreed Script, this has been the biggest problem from my experience, matching editor versions with package versions. There is no way to know which editor you need for a specific version of the packages or dependency packages. Which works fine if you're always on the cutting edge latest version, but that's not always practical.
imagine reading changelog after next release
This doesn't help ? https://docs.unity3d.com/Manual/pack-safe.html
Does Entities.ForEach().ScheduleParallel will parallel by Chunk ?
Yes I think it still just compiles down to an IJobChunk basically.
is there some weird rule with EntityManager.AddComponent() that if the entity already has that component then it just picks another entity to add the component to, by incrementing or decrementing
Highly unlikely. If the component exists already it just does nothing afaik.
yeah I don't then I must have some weird case where entityquery arrays arent aligning, I guess I'll stick to a boolean then, thanks
don't forget that if you make any structural changes (e.g. add component), queries won't return the same entities in the same order
that's probably why then
another basic question but are you only able to change components with setcomponent now
GridSpaceOccupied temprgid = new GridSpaceOccupied();
temprgid = tempGridocced[tompvool];
temprgid.boolValue = false;
tempGridocced[tompvool] = temprgid;```
you can't do something like that to set a component π
well nevermind setcomponentdata doesn't work at all either
can you show more?π
dots really is annoying sometimes, the simplest things I cannot get to work sometimes
have to go to work now, will have to try and figure it out later, thanks for the offer though
Make sure you are not overwriting the value somewhere else
Some good tips from Unity themselves in this thread. Even if you're not using Hybrid Renderer but still would like to profile Entities like me.
Hello, does anyone know what causes this EditorOnly DisposeSentinel thingy and how I can disable it? I'm scheduling a job in Update (MonoBehaviour + Burst (no ECS)). In that Update I'm also creating 2 native array which are most probably the performance hit
It seems like this thing only happens in the editor, hence why it's called like that lol