#archived-dots
1 messages · Page 176 of 1
what's the issue
All I can figure out is that my pathfinding isn't working
Somehow the algorithm never reaches the end node
And in general it's become so messy and I've barely gotten started
It's becoming annoying to deal with my own code
relatable
Really? I find it squeaky clean and love the architecture
but then again... I am a total killer.
@solid flume in this CodeMonkey blobasset tutorial he does a pathfinding thingy, might be helpful.
Also @solid flume if you're using a SystemBase you can do Entities.WithAny().ForEach lambda, which helps keep the amount of code down.
I definitely won't argue in OOP land I find I'm writing about half the lines of code for the same functionality as in ECS, but I find the ECS logic easier to follow at scale
I think one of the biggest unsung advantages of ECS is mentally you're doing way less "context" switching in your brain. Most of the Systems follow similar patterns, etc.
is there a point to write something using dots if there is only a single instance of it, like the player
well, alternative is to use MB, i rather use a system, you should run it on main thread
@molten plover imo you get better code clarity and modularity with dots over object orientated programming. though in its current form you lack so many benefits from stock unity that i wouldnt recommend it unless you are very adventurous and a good self learner
reposting from general-code :
trying to adapt my job to use meshdata but man it's confusing
like bro the job is just supposed to change the y coordinates of all the vertices in a mesh and I still don't get how I can just get a copy of the mesh in the job, modify that and then get it out of the job and apply it to the mesh
current version of the mess I'm writing for anyone that might have an idea
https://hatebin.com/odatypymvq
https://hatebin.com/gpkvoomaiq
the same code in its previous, working version without meshdata to better understand what I'm trying to do
https://hatebin.com/hkfywucubo
https://hatebin.com/qpqcouwulr
I want to attach an Sprite to an Entity, it's for my UI to show an Icon, no burst or systems will ever touch it.
Should I put it through ComponentObject or through SharedComponentData?
Or there is a new way of doing it?
why Shared ? ComponentObject seems fine i think
well, ComponentObject needs to be an Component, which have tons of useless fields. but ISharedComponentData always puts entities in different chunks if they have different values.
wow installed latest beta and got a dark theme in free version... omg finally! 🎉
component object. if you have to ask about using ISharedComponentData, its probably not for you
I am not asking about using it, I am asking about which is the least bad to store managed data
I know how to use when it is to be actually used as a ISharedComponentData rather than just a data storage method
slightly related to my problem :
if I repeat a job every frame am I better off keeping its nativearray(s) permanent or disposing of them and creating new ones every frame
i think if you can safely reuse the array as a persistent one its fastest but if not it shouldnt be a problem to dispose and make a new one every frame.
Btw, is anyone running successfully on 2020.1 and can run their game on a Android device?
kk
the day I figure out meshdata this thing is gonna be optimized as shit
like, the majority of this function's time is just this
@spark glade not me 😦 i was working on a project for 8 months and turns out it doesnt work well for android builds
i am working on a hyper casual game now with MBs
2020.1 doesn't like android?
i think hybrid renderer v2 doesnt like android
Ah
slightly related to my problem :
if I repeat a job every frame am I better off keeping its nativearray(s) permanent or disposing of them and creating new ones every frame
@runic crystal keep and resize on demand, been working just fine for me doing that. Remember to dispose of it though.
yeah I just changed it to that and it's even more performant
literally the majority of the cpu time for my function is now the lines I posted above
AFAIK ToArray() might be the issue, since that does allocate a new array and then copies data.
I tried copyto and it ended up being worse iirc
also there's a spike from GC collection every few frames but at this point idk what it is
why are you editing meshes every frame, that's like the worst idea possible
use shaders for this
cause it's to animate the water and I want to be able to sample the height of the water at any given point in code
for like, boats & shit
then use shaders
you can't pull vertex position out of shaders iirc
that .ToArray() is gonna be hugely slow and allocate GC every frame because it's allocating a new array
why would you pull vertex data out of shaders
your shaders are here to tell how your mesh should look, not to get data from it
cause I'm calculating waves on water
and I need to know the height of said water not just to render the water but also for stuff that interact it it
like, floating objects
your water mesh should be a plane, and you put your animations on shaders
I just explained why I can't do that
you won't ever get good performance by editing shaders each frame, be it with ecs/burst or not
just get the same function you use to calculate the water height/waves in the shader and reuse it in the objects's shaders you place on the water
right so if I ever change literally anything to the function I need to change it in the shader too
you only have to change it in the shader because you'll write it in hlsl
mesh.setvertices should let you pass in the nativearray directly which should be better
i agree with torsina tho, shaders sound like a much better solution for this
would be 1000x faster
You might have forgotten a couple zeroes there
so like
if I write the function in a shader
can I directly call the function in c# somehow or I need to do something like blitting
Until the point where you use them to to marching cubes
Although considering the operations and the magnitude it's still very fast
Write a shader. Create a material with that shader. Put it on the water mesh
You can set properties of a material through code
also yes SetVertices is hella faster
you'll never call that function from c#, this is for shaders to know where to place stuff, your transforms will never change
another option is to use DrawMeshProcedural, construct the GraphicsBuffer/ComputeBuffer to generate the water waves
ok but I want my boats etc to be affected by physics
as in, properly float in the water (and at the right height of the water depending on where they are) but also just sit in place on hard surfaces like an island
so I can't really just deform everything that floats in their shader
Does your game really need very good water physics and simulation?
then rewrite the func in c# aswell and just rotate your bots accordingly, you can't use physics for this water physics
I don't need the waves etc to be super realistic but I do want floating objects to be realistic to some degree
physics colliders in Unity.Physics have static shapes once baked
I know
@runic crystal might want to look at how this guy did bouyancy https://www.youtube.com/watch?v=eL_zHQEju8s
thanks
it is not done in dots, but you might be able to translate it to it
I'm not working in dots, just using jobs and was advised to post here as well
huh, that 4 point under water trick is neat
yeah in that tutorial the dude is not only moving the vertices from the cpu, he's also not using jobs at all to do it
all main thread
so huh
oof
the way he does buoyancy is cool
the way he's taking care of the waves is not
why ?
nvm he switches to a shader at the end
I'm dumb
but yeah
having to just write the same formula in the shader and in c# code seems wrong but I guess there isn't really any other solutions that doesn't require a massive brain
Transferring data from CPU to GPU is also expensive.
This isn't DOTS related but I'll post it here anyway since this channel is home to the elite programming strike force - the best of the best.
Just writing an editor script to replace a bunch of prefabs with new prefabs that have identical names (a bunch of prefabs I've converted from having textures to only having vertex colours).
The way I've seen this done before is to grab every GO in the scene and point them to the new prefabs (copying rotation, scale, etc) but writing that seems tedious in comparison to how simple it would be if I could just overwrite the original prefab assets directly.
The reason why I want to overwrite them and keep the references is because the scenes of everything that was built with the prefabs would stay intact.
Seems like there should be a way to do this that doesn't involve the scene at all.
MeshBaker has something like that in it. You can chose new prefabs or bake in place
Context: I am going through all ingredients currently being cooked in my utensil to check for how long until the first one burns and how long until all of them are cooked.
To do this, I am using the ISharedComponentData for the cooked item result (which is present in the utensil and all ingredients).
Question: Is there any difference between [iterating over all ingredient chunks and taking data from each ingredient through the chunk] vs [Getting all the ingredient entities and get the data through the entity]?
Also, how do I use a ArchetypeChunkIterator? I assume it's a better way to iterate through chunks than using CreateArchetypeChunkArray
for anyone that was here yesterday :
maybe I don't have to write the function to simulate waves both in shaders and in code
maybe if I use a compute shader to write the height of the water to a texture once per frame, and then use that texture in the shader & sample it in c# when needed for non graphics stuff, I have the function all in one place instead of in 2
oooooh boi, ya going in a danger territory messing with compute shaders
you better off doing it twice, especially with the whole memory latency of getting GPU processed data
you will be dealing with the C# part using 2 frame old data
@runic crystal just write that damn function 2 times --'
kk
ho come on! why do they have to reset Parent to Entity.Null when you copy entities between worlds ><
I guess all references to entity indexes that don't exist in the new world are deleted --'
```Burst error BC1001: Unable to access the managed method object.Equals(object) from type Game.Scripts.ECS.Components.MeshBaking.BakedMeshHash
why is it thinking this is not blittable --'
public struct BakedMeshHash : ISharedComponentData
{
public uint3 Hash;
}```
object.Equals(object) - it's likely the default Equals implementation which casts object -> BakedMeshHash
// Default implementation
public bool Equals(object other) {
return Equals((BakedMeshHash)other);
}
ye but why is burst annoying me with this ? I'm just trying to add/set shared component from ecb
ahhhh ok Afaik, SetSharedComponent is not supported by Burst. This underlying method EntityCommandBuffer.AddEntitySharedComponentCommand takes an object as a parameter which is definitely not possible in burst. https://forum.unity.com/threads/burst-new-release-1-2-0-preview-10-we-need-your-feedback.789473/
I tried to burst that job and so yea burst's angry >.>
tbf it's a bit annoying that they don't handle blittable and non blittable shared components diferently
there could be some rly good performance boost to it :x
there should be an burst-able function to let you set the SharedComponentData index, you can get it, but you can't set it afaik
huhh ?
https://i.imgur.com/Gjj2oQb.png @harsh owl
there is a function to get which SharedComponentData index the chunk is referencing or something
index, as a int value
what it actually internally uses
but there is no function to set that value in burst code
well there's no such api for command buffers sadly
it kinda sucks there's entitymanager, ecb and exclusivetransaction which all use roughly the same api but they get updated seperately
ecb eventually got most the api changes entitymanager got but exclusivetransaction is still stuck in 0.0 land
what's the purpose of exclusive transaction ?
lets you do structural changes from non-main thread, like from jobs (but it won't let main thread touch entitymanager during this time so it's not a replacement for ecb)
used for procedural gen / loading worlds and then moving entities from loading world into main world
oh also i'm temporarily using it as replacement for ecb, i'm adding components on world A from world B but if they are more than 4 frames apart ecb starts crying because it uses jobtempalloc
exclusivetransaction doesn't have that issue, but that's also how i noticed it was missing a lot of api, like it doesn't have batch add/remove for example
Hi guys, I have a problem which could just take common sense to fix but I can't seriously figure out what to do
I have a problem with the DOTS physics as every time I convert to an entity it destroys and I don't know why, I know I have it on convert and destroy but after watching tutorials and some other videos on it, for me. It just doesn't work
can someone help me fix this
Do most people rely on parent-child relationships to break down bloat of Archetypes? As in instead of having all components that Offensive might have attached to a primary entity (along with movement/defensive/etc) it is on a separate entity and is linked via parent?
yeah i think splitting and linking entities is fine if they get too big, but referencing the linked entity's components is random access so would only recommend if they're seperated enough that they don't have to look up data from the linked entity much
I would imagine the biggest thing would be translation data for calculation of range and collisions and what not
That would be based on the parent and all the others would need to look up that data?
yeah you got two options in this i think
- every time you need translation, look it up from the parent
- have a system copy that translation onto the other entity, might be faster if you're accessing that seperate translation a lot from different systems because then you could get more cache hits when iterating
1 is fine if you only need it for one system
Yeah, my approach was already going to 2, if I decided to offload the components to children entities
But that would mean every cycle for entities moving it would be writing to a multitude of other components across other entities. Still on the fence
yea
right now i do that with seperated sim entities and render entities
render entities need sim entity's position
so it's copying every frame
Its not too heavy? I would be in the same boat, but for probably 4-5 different entities/components this way
i think it's fine
without the copy it'd be a lot more lookups per frame so would be worse
i think only downside is that copied components take up a bit of space in your seperated entity's chunk
if you wanna optimize it you could use a change filter to only copy when translation has changed if it doesn't happen every frame for you
also it's a bit of boilerplate to write the copying part for each component but meh
i'd be interested to know if there's a more efficient way of doing this tho, i just haven't figured it out so far
Right, almost feels like SharedComponentData
ooo glad you bring that up maybe that's a decent approach too
so afaik sharedcomponentdata is entitymanager has a list<object> and scd has an index into that list, right?
could maybe build up a seperate nativearray<translation> lookuptable that you copy the primary entity's translation into
and just an index into that table on the secondary
and it should be faster than a component lookup because component lookup is actually like 3+ lookups
hmm dunno, might be worth looking into if performance becomes issue there
so far i feel copying data into the other entity is very simple so if that works then eh
Yeah, I am just trying to find what unity would say is the correct approach but having a hard time looking for an example they may have done where they manage a problem like this. I think copying feels simpler so that is likely what I will do
ooof, so seems like copying entities between worlds is really not good for performance
https://i.imgur.com/zrVXqqF.png
3.7s for 20K entities with basic transform and renderer
feel like I would be better off recreating the entities in the new world instead by hand
which is quite stupid to think about
and not like I can put this on an other thread cuz CopyEntitiesFrom is only from EntityManager..
I was just looking into doing something like that, but instead I am trying the <Prefab> approach
I could just delete them and recreate them in the world if need be, but god this bring so much complication
prefabs?
these entities are childs of prefabs and they only contain renderers not logic
so I'd have to piece back together the prefab
and I'm splitting hair just by thinking about it
this whole thing is already complicated enough
urg
I see what you mean
If both were prefabs, and you had a system only looking for prefab tags I assume it would be easier
I could "replace" the renderer component with my own component containing the same data, and when I need the source renderer back I re-replace it with RenderMesh
if only DisableRendering worked 
Yeah, currently doing my own rendering, we should be seeing new animation tools for ecs though in the next few weeks right?
heh ?
I thought I read a post about it, let me see if I can find it
if only DisableRendering worked
DisableRendering works for me
hdrp will shit at you if you use it
it will still cull and eat your cpu time for breakfast
i'm using URP
I agree that renderer is prevented, but then why tf is it culling that --'
I can't find the post, but I am 90% sure I didn't dream it 😮
was wondering why the performance test of my job had 72 GC allocations when it should have 0. Found out that if you go to Jobs -> Leak Detection -> Full Stack Traces (Expensive) was the culprit, and Jobs -> Leak Detection -> Off gave me 0 GC allocations in my performance tests. Friendly reminder to turn that off if you're trying to perf test your jobs.
always exciting when we see new faces in the channel, welcome!
new blood for dots to consume
@zinc plinth wow 4 seconds is crazy, is it making copies of mesh + material as well or something?
crazy as in serializing the entire world + deserializing it into a new one would even be faster i think
maybe something funky going on
I'm guessting it's somehow not internally using shared component indexes and instead manually copy the new value each time
I'll try to do my "replacing component" approach and keep the entities in the same world when I get not too annoyed at ecs
it would be even better if I could use these damn indexes
but it's an internal method 🙃
huh it's moving the chunks
omfg I can't even do my replacement method in jobs because I can't get the RenderMesh inside it cuz it's not blittable --'
isn't there some fucky way with GCHandles to get a managed type into a (non burst) job ?
like I'm that desperate about it ;-;
What are my options for rendering in DOTS? Just Hybrid Renderer?
possibly but it depends on if you own it or unity does, because unity is gonna ignore .net GC handles and do what it wants. Like how they forcibly remove native Go/Mb and .net is like whaaaat, null, regardless of if it still has references.
huh, that's an error I didn't see before https://i.imgur.com/XnhTMvg.png
need to check if I'm not just getting null from my gchandle in job
well handle.Target isn't null 
so that's a first step
am I too stupid to see where the problem is here ?
https://i.imgur.com/PFkDnOl.png
RenderMeshSave is a copy/paste of the code from RenderMesh (with IEquatable changed to right type ofc)
in debugger the command type is 40235
huuuhhh why >.>
hoooooo
I forgot I'm using this ecb concurrently >.>
o.0 it worked
holy shit it worked
how let's see how much this takes
so now this takes 531ms including 515ms of ecb playback, yikes
and that's only for 20K entities on a 100 by 100 grid
job on 4 worker thread https://i.imgur.com/da1sEhz.png
that's with a Debug.log in them tho
hmm is there some way I could speed up that playback time ?
I have 6.3 seconds of playback on the frame the mesh baking system group does work 
I wonder how much faster are entity queries for ecb commands rather than doing stuff per entity
and if the cost of adding and removing a tag specifically for this will not outweigh the benefits
HOLY SHIT
fast this thing is
3.75 seconds with ecb -> 53 ms with entity queries
feels like a good progression lol
https://i.imgur.com/6t32gKV.png
https://i.imgur.com/5m0t8es.png
https://i.imgur.com/eUU83Qa.png
https://i.imgur.com/Dukn94x.png
8.4s -> 1.7s
and I can still do alot more I think
now that I know entity queries are so damn worth
so out of 1s for the GetMeshBakingGroupRendererSystem, I have 370ms of buffer retrieval o.0 (80K instances)
@zinc plinth Do you get the same performance improvement if you do this with collection safety checks off?
these improvements were only from refactoring my code
have you tried measuring with safetys off thou
can try 
It could be they are the same speed. But since the query version doesnt create that INSANE amount of allocations for the safety sentinels
(Never profile things with the collection safety on)
ehh not that much of a change https://i.imgur.com/xdRb9kA.png
I'm scared to ask, why are there still so many allocations ?
100ms less
have to manipulate lots of managed types cuz RenderMesh, https://i.imgur.com/tuTX4zJ.png
So at the top of your profiler, there is a button to enable the stack traces for allocations
clear the profiler after hitting it and record some more
and you can see what is causing the allocations
365685 allocations is kind of nuts
I know what are causing them, I use managed collections in these jobs
this frame is not what the game runs at, it's the mesh combining step
only runs on the grid on 1 frame
nah, will maybe make it a boilerplate for grid based games in ecs if I'm happy by the features and perf and put it paid on the asset store, otherwise I'll just use it for my game
👍
for now mostly angry at hdrp and unity physics for performance
Is it possible to do a Entities.ForEach() with an optional component?
Or maybe there's an easier way to do what I want 🤔
When created some of my entities have a DisableRendering component
Based on some conditions, some of the entities will need to start getting rendered, so I'll need to remove the DisableRendering component
cant remember if the lambda has options for that, but as a workaround you could just use HasComponent<DisableRendering>() and if it does remove it
Hm, how do I get the source entity from the Entites.ForEach @safe lintel ?
🤔 can I add the Entity itself as a param
Entities.ForEach((Entity entity, int entityInQueryIndex, ref MyComponent myComponent)=>{
if(HasComponent<DisableRendering>(entity)){
//do stuff
}
})
Dope, thanks! That's exactly what I was looking for
Hmm, anybody know what I'm doing wrong if this shows up?
Entities.ForEach Lambda expression makes a structural change. Use an EntityCommandBuffer to make structural changes or add a .WithStructuralChanges invocation to the Entities.ForEach to allow for structural changes.
If I understand the docs correctly enabling with structural changes remove the multithreaded capabilities of the foreach, how would I get around this?
you dont, consider that removing or adding components requires sync points, so you can defer it with entitycommandbuffers or do it immediately withstructuralchanges. the entities docs has more info on this
If I want to use the Hybrid Renderer, do I have to match one of these three component sets?
yeah, if you convert an entity witih a mesh filter and mesh renderer Unity will automatically calculate stuff and put thosse components for you
I'm creating them manually
looks like I just needed RenderBounds which gets transformed into the other bounds
@zinc plinth What do you exactly mean by changing from the use of ECB to entity queries?
In ECS is it generally better to use tags or a dirty flag on a component to signal something needing updating?
depends on a lot of things, changing chunk (adding component) is expensive but it's cheaper to query an archetype than it is to check a dirty flag per component
so if you are adding/removing tag on the same entities every frame, better to use isdirty, if not then component tag is usually fine
also current plan is to add a disabled flag to each component so in the future that could be a thing to consider too, adding the tag beforehand and enabling/disabling this flag when you want to setdirty
as in plan from unity side
should be better than a dirty flag in a component itself
What is currently considered best practice for runtime changeable configuration data which is NOT set in the editor? Use a central ConfigurationSystem which is keeping state and being queried by other systems or make individual components and use e.g. GetSingleton<T>() on those components in systems that need the configuration? This would currently lead to a lot of individual components which would each use up a single chunk due to the archetype being unique.
Oops, misread your post at first. Configuration data that's mutable. Possibly shared statics? If you're worried about wasted memory then you could also combine a lot of components on one 'Settings' singleton entity? Rather than one component per entity?
yes mutable, like one more specific example:
we receive addressables catalog paths at runtime (can be changed multiple times during the lifetime of a session), remove old catalogs, load new one, transform urls for CDN and then set the resource locations. while this is in progress, there should be no other system (like the ones downloading or instantiating individual addressable assets) doing any work on addressables, as the cache might be completely out of sync until the whole refresh is done
@twin raven I was adding and removing a shared component per entity on more than 80K entities, results in almost 4 second of ecb playback. In the other hand if I create a entity query for the system with a special tag that I add and remove right before and after my changes, I can get these 80k entités in an entity query instead, and the speed difference is 100x if not more because EntityManager has a version of it's api for entity queries as the subject of the change
@zinc plinth Apologies if you already know this (maybe someone else will find it useful) - if you imagine every entity has an archetype and it indexes into an array of archetypes to know what components it has - when you do what (at least I call) a 'batch' operation with an entityquery, it's effectively changing a single entry in that array - so it's blindingly fast - no moving entities or chunks around
oh wow i thought an update mentioned they added those batch entityquery methods to ecb seperately but seems like they forgot sharedcomponents
I know now? I looked at the code for this yesterday @amber flicker
it's almost free to change the archetype of every entity of a certain archetype, no matter the number - so cool 👍
if I'm adding a system to a world manually, do I have to put it in the right update group myself?
it seems I need to call group.AddSystemToUpdateList(system) as well
@calm edge yep there's no automatic method for it
you gotta read out the attribute yourself if you want to auto add it to group
here's the method i use
assumes that that group already exists in world tho
if you're adding a bunch of systems from scratch all in one go, you want to add them to the world first and then add them to update lists
because otherwise you'll be trying to add to system groups that don't exist yet
ran into that issue before
that's a sweet hatebin 
why is there no api to add the same component(not shared component) to a query/native array of entities...
I just want to add Parent to all my grid tiles (._. )
you mean adding a component with a specific value? Add + Set at the same time?
yea
I think my only option is to either to one call per entity, or make that component a nativearray of component containing the same value for all of them
which is pretty stupid if you ask me
well I agree a convenience method like that would be cool. I guess how it would work under the hood is to bulk add component then have a job iterate over it and set it though - which is something you could do? So long as you don't change the archetype one by one
It doesn't sound quite like your use-case but just fyi the entityManager instantiate method can instantiate hierarchies of entities and modify parent/child relationships as expected.
yea but the transform system group fucks me over by ripping off my parent component cuz I do n't set it in the frame they're spawned in
(it's complicated)
huh, wonder how I could make this faster than per-entity(second method) ```
private static void SetupGridTileDatas(NativeArray<Entity> gridTiles, NativeArray<GridTileData> gridTileDatas, EntityManager em)
{
}
private static void SetupGridTileData(Entity entity, EntityCommandBuffer ecb, GridTileData gridTileData)
{
if (gridTileData.Usable)
{
ecb.AddComponent<GridTileUsableTag>(entity);
}
}```
wonder if it will run better if I filter in a bursted method to get the entity array indexes for each type I want to add
i dont have the a reference handy but is there a method to set archetype / add component with a native array of entities?
then it will probably be batched within the same chunk and faster than ECB/per entity; would mean making two arrays of GridTileData.
you mean one per GridTileData field ?
i was thinking split NativeArray<GridTileData> gridTileDatas into two, a list of .Usable ones and non-usable.
then add the component to the entire array of entities that are usable
well if non usable you just don't do anything no ?
yeah, true that
Usable might rly not be the only field in this too
and prolly not all of them will be tags but have some data inside (ore counts, stuff like that)
the problem with EntityQuery is that it can only filter on existence of component, so at some point you have to do the per entity branch
ye queries aren't rly an option here
AddComponent on native arrays get batched yes https://i.imgur.com/sqtE18M.png
this is pretty obvious but you want your job to tag whichever subset is expected to be smaller of the entities you're processing - it's easy/cheap to bulk flip tags later
you might be able to force them into different chunks manually without changing the archetype and then you could iterate them seperately even though they're the same archetype. The benefit there is you can do even faster batching by changing the archetype on an entire chunk at a time because you know it only contains the right entities, they wouldnt be mixed.
to do anything with the subsets I need to create them first, they don't exist before this method
jobs or just bursted code for filtering on each field of GridTileData ?
I guess a IJobParrallelFor would fit nicely here 
since this is handling >40k entities
so would look like this ```
public struct CreateGridTileDataFilteredEntityArraysJob : IJobParallelFor
{
[ReadOnly]public NativeArray<Entity> GridTiles;
[ReadOnly]public NativeArray<GridTileData> GridTileDatas;
[WriteOnly]public NativeQueue<Entity>.ParallelWriter UsableEntities;
public void Execute(int index)
{
Entity gridTile = GridTiles[index];
GridTileData gridTileData = GridTileDatas[index];
if (gridTileData.Usable)
{
UsableEntities.Enqueue(gridTile);
}
}
}```
guess 256 would be a good batch, there's rly not alot going on in here
there is actually a filter job specifically for this kind of thing I think... doesn't really matter - doubt it'd be any faster
huh, what's the interface name ?
maybe IJobParallelForFilter? just seeing if I could check
yup that's it
how is it different tho
; it's the same Execute
thx unity, rly nice docs https://docs.unity3d.com/Packages/com.unity.jobs@0.5/api/Unity.Jobs.IJobParallelForFilter.html
been a long time since I looked at it... might be that it saved boilerplate in the pre-lambda days but is pointless now?
it has a specific "job producer type", no idea what that does
/// <summary>
/// <para>All job interface types must be marked with the JobProducerType. This is used to compile the Execute method by the Burst ASM inspector.</para>
/// </summary>
[AttributeUsage(AttributeTargets.Interface)]
public sealed class JobProducerTypeAttribute : Attribute
{```
so does it gets compiled diferently ? 
maybe some more loop optimization ?
will try both and see
hmm yea, revisiting this I'm sceptical it's still relevant - looks like you used ScheduleAppend? Is that a thing? 😄
well there's a bunch of shit in that producer type
looks like it's main thread only... no idea if it's been updated in the past couple years...
Execute, ExecuteAppend, ExecuteFilter, ScheduleAppend, ScheduleFilter
and there's some comment in there https://i.imgur.com/mrXkgXs.png
I'l just use parallelFor lol
yea, worth checking but it doesn't look relevant anymore
I want multiple outputs anyway, not just one set
k all done, now to record baseline for the per-entity way and compare 😁
for per entity way I have this https://i.imgur.com/Ul9P1dn.png
that's a really curious pattern
why did one of my message get deleted 
https://i.imgur.com/aM3YpSh.png hello ?
the stripes are 16 tiles long
the physics colliders are in the right place tho 
aand I crashed my unity by enabling gizmos 
what's your per-frame physics time
with those billion colliders
tho i guess wouldn't matter much if nothing is moving or casting
they're still rebuilding each frame, and on 4 worker threads(forced) at 5ghz I'm at around 1ms of physics
I want to do my own thing for this since I literally only want raycasting, but didn't get good ressources on how to do that yet
and I have alot on my plate already
but yea, super confused about this glitch
are there not supposed to be stripes
no it's supposed to be a rectangle of tiles lmao
not sure but looks as if you have some jobs touching the same data instead of only their own
seems like they somehow end up all the way over there https://i.imgur.com/YUT2kLs.png
lol
I don't have jobs touching the translations
hooooo
maybe it's from the query 
cuz it's not ordered the same way as my arrays
could it be crossing multiple frames? the non-system jobs are not forcibly finished each frame
nah I complete all my jobs
I think it's cuz I'm using the query to set index specific data from my arrays
and it's not working well cuz not the same ordering
thank god AddComponentData isn't batched so I don't lose much perf I think AddComponentData<T>(EntityQuery entityQuery, NativeArray<T> componentArray) https://i.imgur.com/J11svOA.png
so I can swap to the NativeArray variant (pls tell me it exists ;-;)
IT DOES'NT WTF
urggggg
more loops I come then --'
ayyy fixed
grumble grumble grumble https://i.imgur.com/LHGzdqH.png
97 -> 146 >.>
but hey still better than 1s
I can't find my filter job in profiler 
the tag is applied tho 
ha found it https://i.imgur.com/oUXamdh.png
2ms for 256 batch size seems awfully high tho
there's no burst error but this seems so weirdd
wait, there would be way more than 5 instances if it was 256 entity per call
so it's doing multiple batches per thread in the same call ok
@hollow sorrel on 80k colliders https://i.imgur.com/vq7wlJg.png
time to go after the 300MB of memory I'm leaking each start now lol
1ms not bad for 80k
they're planes soo
but that's still an awfully unnecessary 1ms
cuz I just want raycasting :/
ye true
once I'm done with leaking I'll prolly go for this since I'm done with my mesh source saving now 
the replacing RenderMesh method works wonders
ho I already tracked them all lol
neat
without safety checks or memory leak detection I'm at 4.5ms, 3 of which are from hdrp...
(if you couldn't tell by now I don't like hdrp much)
except it has vfx graphs which I rly want ;-;
ok so, need to check how raycasting works in Unity.Physics
that's uhhhh, complicated
ugh doing some non dots coding my code is turning into such spaghetti! mb updating static class which refers to non static class and classes within classes to not make some monolithic mess, i hate it already
guess I'm implementing this lmao http://allenchou.net/2014/02/game-physics-broadphase-dynamic-aabb-tree/
wait is it just me or does recompile during play now recreate the default world? when did this change happen 🥳
I always stop playmode when I recompile
also, feels bad jacksondunstan doesn't have a NativeTree in his collections
i was using stop for a long time because the anything entities related would error like crazy but it seems with the latest packages its actually recreating the default world now?
dots hotreload is kinda a dream scenario for my own uses
recreating as in like restarting?
that doesn't sound that useful, same as stopping and playing
Is there a way to get entities based on the ComponentType?
use an entityquery @finite breach ?
@hollow sorrel one less button to press goes a long way when you chalk them up over time. its why i hate unity's habit of nesting every damn menu item under more menus, just make the editor ui customizable like maya or something ffs
that's true
what i'd like to see tho is serializing the current world before compilation and restoring the gamestate after
oh for sure reloading proper state would be best. i know they plan on it given theyve said they want to support hotreloading like current unity, just no idea when its gonna come. but this is a welcome first step towards that
hey all! I'm currently getting "InvalidOperationException: Attempted to access BufferTypeHandle<SpellCombatEffect> which has been invalidated by a structural change." because i update the buffer in for loop with new values. any workaround?
i've updated buffer data before so it's weird. it seems i can only add/remove
Seems like you do {Add|Remove}ComponentData between getting the buffer and writing to it
i did indeed. thanks! 🙂
@safe lintel Thanks! My brain melted after 8 hours of google "researching" DOTS again to the point where you miss the obvious 😐
if you havent read it already, the entities docs are a good reference point 🙂
Hi all, sorry if this seems obvious, but im trying to add Entities to my project, and with it being removed from Package Manager, im not sure how to go about that ... Do i set up a github package link?
@viral sonnet if you're doing structural changes while you look your buffer use ToArray and not AsArray
Don't forget to dispose it afterwards tho
Also, marijnz's native octree seems exactly what I need for my custom rayczsting, except it doesn't have an api for rayczsting as is and it's in the TODO for 5 months now ;-;
So I have to find a compatible raycasting query for octree and implement it in c#..
But after that I just need to throw the AABBs of my grid tiles with their entity as element and boom it's done
Im on a weird mission, but maybe one of you has an idea. I basically want to make an entity that replicates the movements of another entity but on a delay
so I guess the naive way would be to fill up a buffer of positions and have the other entity consume those positions?
also hello, long time no see
@tight blade yea, buffer would do it. Just be careful to only push as much as you pop I guess. Or you could e.g. set the target pos every 10 frames, lerp between and set position to last point when you overwrite it. Depends why you're doing it, how accurate you need to be, what your perf requirements are etc.
Anyone here have any experience with the CopyTransformToGameobject tag?
Currently having a weird scenario of entities swapping which gameobject transforms https://forum.unity.com/threads/converttransformtogameobject-not-sending-data.962040/
@safe lintel Oh I have! It's is not my first run at DOTS but you know how well hidden the "not so standard things" are. 🥺
@amber flicker hmm, yeah actually thank you for the lerp idea. I totally forgot about that option. I think that will be necessary to use in some degree
I'm on the road to dynamic waves
How do we actually chain several ecs mechanics together ? Lets say we have implemented the following systems, each firing events once they done : Collision, Task, Drops... And we want to achieve the following, once a player collides with a tree ( e.g. ), a task gets started that takes 10 seconds and once its finished we wait till the drops are generated in order to insert them into the players inventory... how do we achieve this inside a ecs ? Any good tipps ?
Each of those system fire events to inform other systems... like "CollisionEnter", "TaskFinished" or "DropsGenerated"
You'd need some sort of pending/conditional task entity and a system to manage them, once the conditions are met/time elapsed it could perform the delayed action. I did a super simple version of this for staggered delayed destruction so items looked like they were exploding in a pattern.
@mint iron Thanks ! Could you describe this a bit further ? ^^ How would it look like ?
i create entities for each event, so like lets say you raycast and hit a tree, create entity with a component that has a timer(could also stuff an entity prefab id to it), after that timer is finished do a lookup to the player inventory and add whatever item(ie the entity prefab that was stored in the timer event entity)
yeah pretty much that; i originally tried to make it too generic and as i added conditions that only applied in certain circumstances the struct got too heavy, so if i tackled it again in the future i think id make multiple structs for each specific purpose where possible and a system or ForEach within a system manage each one separately to keep things clean. You can abstract pretty much anything in that way, e.g. queue stuff up to be spawned rather than doing it at the origin and have a system dedicated to performing that action.
So... the only two things that have been mentioned at all re dots timelines... (.enabled states coming 3weeks - 3months - as of mid-May) and new animation samples 'sometime next month' i.e. August).... I just want to check I'm being impatient. Or should I start to be concerned that there's been zero communication about either those things or that epic ~100 thread post?
i was gonna say that i wish that thread prompted official responses
Thanks ! Im also using event entities... and thats what makes things pretty difficult... in my case i want to keep things flexible ^^ So you would simply attach more components to those events/entities in order to execute custom logic ? For example : OnCollisionEventEntity -> Attach "SpawnProgress" -> System iterating over OnCollisionEventEntity + Spawnprogress in order to spawn those progresses ?
also that i wish it was still going, imo it kinda got hijacked a little bit from unity could communicate better and heres why to here are the problems with unity dots and i want these changes 😆 (kinda guilty of participating in steering it offtopic but thought it might spur some official response)
I can totally understand staff steering completely clear of that post.. but I hoped we might get a 'blog post coming at the end of the month thread' or something
the silence is pretty deafening rn
Or what do you guys mean by queueing them up ? ^^
@stone osprey tertle on the forums made some event system that a lot of people seemed to like, could be generic? but for my own uses its too complex 🤪
Nah i mean queing them as actions ^^ Like -> OnCollision -> Spawn progress -> On finished -> .... e.g.
well the queue would be determined by the systems processing them and their lifetime, like
OnCollisionSystem [makes event entity with CollisionOccuredEvent]
SpawnCollisionEventSystem [processes entities with CollisionOccuredEvent, if a timer hasnt reached a certain point, just wait, if it has spawn item? or spawn more event entities that get processed by more systems down the line]
@amber flicker i dunno, kinda thought it could warrant a reply. at least the majority of people in the dots subforums are mature and a frank discussion could be had.
a blog post that doesnt actually give people something substantive just invites all the riff raff 😉
kinda painted themselves into a corner with how they have approached this, big marketing stuff mixed with later on hiding packages, but the all the marketing pages are still up guiding users to a void... 😅
I have several theories atm. 1) Everybody's been told they can't publicly say anything about direction or timescales - specifically just the DOTS team though, 2) Everyone's on holiday.. told to spend time with families or such, 3) There are lots of passionate discussions ongoing still about whether to abandon DOTS, make everything DOTS or make two editors and they still haven't decided. Or all 3.
abandon DOTS ? madness
abandon DOTS 😕 have you actually seen any unity people allude to this??
nope - and I obviously hope not
seems quite a few games industry folk expect them to roll it back - I don't but who knows what's going on internally
I dont think they'll abandon it.
it'll be in the backburner for sure though. Like really really far back into the back burner
my take: i think its just poor communication tbh, everyone is continuing to work away. for us using it though its like waiting for paint to be mixed before you can even watch it dry.
Even when there's an outcry of "you're not communicating... please communicate"? ¯_(ツ)_/¯
their communication to the community sucks.
too formal, too stiff, too enterprisey when their users are pointing out facts at them.
they need someone like laurent is doing for the visual scripting team, to kinda liason info with the community(that poor guy is like the punching bag for unity's own missteps)
maybe they are making very juicy updates 🥺
yea a lot of the teams have so much better communication (UI Toolkit too for example) - it makes the difference more stark
my take is, they got burned pretty hard in a few threads like the visual dots topic, and some of the staff seemed to be getting quite agitated and perhaps not responding in a manner that would help their case. They might be revising their communication strategy...
yeah that guy is too... excited about voicing his opinion
I think there's very likely a very human component to this. That said, at some point "our engine team" really has to report in. Even officially.
oh that one guy i wish would post succinctly
Any net code crackheads here that manage to make the getting started cube move? My server seems to not be receiving the input command data? Anyone has encountered that problem? More info and code here: https://forum.unity.com/threads/netcode-getting-started-server-does-not-enter-foreach-of-the-ghost-movement-system.962253/#post-6267171
It sounds like you need to create a CommandSendSystem and a CommandReceiveSystem
public class SendInputCommandDataSystem : CommandSendSystem<InputCommandData>{}
public class ReceiveInputCommandDataSystem : CommandReceiveSystem<InputCommandData>{}
I do have those, I didn't put it in the forum because it's boilerplate code but it is there in my list of systems 🙂
Is there anyway to verify on the client side what is sent to the server by this system?
Thank you tho!
Hmm okay, I haven't had a problem with it so I haven't had to debug what's being sent, not sure where you'd hook that in
Are you setting the CommandTargetComponent server side?
public class GoInGameServerSystem : SystemBase
{
protected override void OnUpdate()
{
Entities.WithNone<SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
{
EntityManager.AddComponent<NetworkStreamInGame>(reqSrc.SourceConnection);
UnityEngine.Debug.Log($"Server setting connection {EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value} to in game");
var ghostCollection = GetSingleton<GhostPrefabCollectionComponent>();
var serverPrefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection.serverPrefabs);
var prefab = Entity.Null;
for (int i = 0; i < serverPrefabs.Length; i++)
{
var ent = serverPrefabs[i].Value;
if (EntityManager.HasComponent<PlayerComponent>(ent)) prefab = ent;
}
var player = EntityManager.Instantiate(prefab);
EntityManager.SetComponentData(player, new GhostOwnerComponent { NetworkId = EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value });
EntityManager.AddBuffer<InputCommandData>(player);
EntityManager.SetComponentData(reqSrc.SourceConnection, new CommandTargetComponent { targetEntity = prefab });
EntityManager.DestroyEntity(reqEnt);
}).WithoutBurst().Run();
}
}```
OMG !!!
I'M SETTING THE COMMANDTARGETCOMPONENT ON THE PREFAB
Haha, yep that'll be it I'm guessing
new CommandTargetComponent { targetEntity = player }
@fair flame Thank you so much after 12 hours of headbashing my capsule is now moving on the server haha
While I'm here, is there anyway with the Physics body to restrain movement in certains axis like on the RigidBody?
I think someone here managed that but had to blow a few fuses to get it working lol
I think you can freeze rotations by setting the relevant inertia tensor axis to float.MaxValue. For translations you might be able to use joints but there's no easy setting like with PhysX rigidbodies
The project comes with sources, right? It should not be complicated to add that to the solver.
I know that because we implement these restrictions in our physics engine, and it's not complicated (only a few places will move the entities: velocity integration, position correction, constraints solvers normally)
We'll, if you know a bit or two about physics engines...;)
@stone osprey interestingly what you're talking about is precisely the kind of use case the VS tool is designed to address
@tight blade VS tool ? ^^
they seem like kind of a mess though. Early on they had a concept that the DOTS users were really happy about. then they gave the tool to some big game companies who knew nothing about DOTS and they hated it, so they redesigned the whole thing to be more monobehavior like. Then, it seems, Unity decided they lost their patience with the dots vs and decided to in house Bolt
now it seems like bolt will be the primary visual scripting tool and the VS stuff will become a sad extension of bolt that delivers some satellite performance benefits to mostly monobehavior style authoring
I just saw this, and there's almost no mention of ecs/dots at all in the 2021 roadmap lmao https://blogs.unity3d.com/2020/08/13/the-road-to-2021/
We are excited to share our plans for 2021. We’ve listened to your feedback and established our plan based on what we’ve heard. Our 2021 product commitment is simple. It’s about giving you production-ready features, workflows, and components based on what you have told us you ...
how does it feel to work on dead tech 😀
bolt probably has worse performance than the vs stuff, bolt 1 performance is abysmal
visual scripting is stupid
bolt 2 would've had amazing performance because it codegens all your visual graphs to actual C# code
but they canceled it 🙂
focus on the engine, stop these stupid acquisitions
First, this means expanding the focus beyond the Data-Oriented Technology Stack (DOTS) netcode space to solve for current-Unity GameObjects
yeah i lol'd when i read the netcode part
they haven't been able to make a stable netcode in the entire existence of the engine
meanwhile you're walking in a wasteland while doing dots netcode lmao
now they are tackling 2 versions at the same time
seems like for a public company they almost have a fiduciary responsibility to axe dots
i wouldn't go that far, investing in the future it legit or you'll be left behind
meanwhile I still can't use latest entities/hybrid renderer because I use addressables :)))
yea i was gonna say, if they have more money due to IPO that's more reason to spend on DOTS since it's basically R&D
right, because IPO's are known for stirring companies to forgo short term growth in order to secure long term viability.
in pretty much all sales the key people stick around for a year or two then leave a dirty husk. Usually burning everything in order to meet their bonus targets. Not that i'm cynical 😄
@zinc plinth why not
because it crashes on compile lol
rip
good compatibility™️
and prevew addressables versions don't even work half the time
another dead package
it sucks that you can't just load/unload specific assets normally
just use Ressources 
don't you love having to throw everything into a name sensitive folder to be able to get your stuff ?
lol
Hello, trying to get material properties working in dots. I have a shader graph with properties set up like so as well as a material property component & system (https://paste.ee/p/XQCCK). 'UpdateMaterialPropertiesTag' is being added to the entity properly but 'UpdateMaterialPropertiesSystem' isn't listed in the Entity Debugger's list of systems & so it's not updating the material property. Using hybrid renderer v1
my understanding is that v2 isn't compatible with Unity 2019
I don't think that's true 
Latest entities versions do require 2020 tho
I'll see if I can install v2
You don't "install" it tho, they're both in the same package. Unless you're on a very early hybrid renderer package
V2's minimum version of Unity is 2020.1 according to the docs. if I can't find a solution I suppose I'll try to recreate the project in 2020
well that's true 🙂
and material properties don't work in v1
Reasons to upgrade then 👏
Is NetCode unoptimized, did I code it wrong, or is my PC shitty? (NetCode 0.3 - 1 player controlled capsule with physics body/shape)
thanks for the help. seems I'm upgrading lol
Not seeing what actually makes your graph go like that won't make us be able to help you @fluid kiln
How can I tell? 😮
Yeah but which section
Just expand main thread and jobs and show us
Said expand main thread please
could also check timeline view
so you don't have to scroll zoom 1000x
i mean hierarchy*
How much entities do you have in your world, and do you have burst turned on without expensive memory leak check
Ha I like hierarchy better, ty.
On my server there's 10 entities, 18 on client. Where is that checkbox?
Jobs > Burst > Enable compilation
Yes it will, it's written it's expensive.....
makes sense 😉 thank you sorry for not knowing my shit haha
And do you have burst turned on
yes I do
Good
Well the first two checks in the Burst menu
What are your frame times now
33ms, much better thank you 🙂
yikes
Still high?
I never used dots net code, but that sounds a full
Is it thzt un optimized? @hollow sorrel
Redhow the profiler please @fluid kiln
Even on server/client? Well actually now that I closed some windows I'm more around 20ms
Re show
what's taking up most of the time in hierarchy?
Script by far
yea ok but if you expand the hierarchy tree
11ms for server
huh
how du you get a 11ms server with 10 entities
Good question 😂
doesn't it normally show the system names under there too
what entities version are you on?
This?
Hey I just followed the getting started guide haha
As for the version let me check
0.14
Does netcode have an example project?
There's the FPS sample and the Getting Started code
It's my TickServerSimulationSystem and TickClientServerSimulationSystem that add up to 13 ms
are you on a laptop by any chance
No no I have a pretty "good" rig
that's weird then
i heard it's not very optimized yet but 11ms for server that doesn't do much yet seems really bad
well now I'm worried lol
could you check window > analysis > entity debugger
should show per-system timings
sure thing
might have to use dropdown to pick server world
yea but serversimulationgroup should have different systems
It's the physics system
Do you have JobsDebugger enabled?
Yes
Oh wow
Do you have mesh colliders with 60k vertices inside each other?
whaaat
Burst is enabled?
Jobs -> Burst -> Enable Compilation?
Ye
Show the server system group timing
My GhostSendSystem takes 0.16 ms with one client and 47 synced entities
Mine averages 0.5
Also, wouldn't the server system group run in it's own executable without any rendering?
Idk how the server gets it's standalone in netcode
I'll run server only
But yea, if you have bad performance, stop all the debugging first 
...............
hahahah
Are you kidding me
I kinda forgot it existed because I like to debug my code in VS, I rarely touch it
The f are you thinking by complaining about performance with literally every piece of debugging tool enabled in your editor..
Well now you know
5ms with a basically empty world?
5ms spikes, more like 2.5
He has hdrp, so -2ms already @north bay
You're getting 1.3ms of cou on urp?
Cpu *
Turn gpu instancing on if you didn't already on your materials
It's in the advanced settings
what cpu?
Would guess à 16 thread by the amount of job workers
Yup
trying to check the effect of jobsdebugger on my project but it's throwing all sorts of errors 😆
passing temp allocator instead of tempjob to jobs and making structural changes while looping entities
weird that it's fine to do that even in build unless you turn jobsdebugger on (would think leak detection or burst safety checks is the one that catches those but nope)
Ehehe
AMD Ryzen 7 1700 8 cores 3.10ghz
What advanced settings are you talking about @zinc plinth ?
@hollow sorrel I feel you, from time to time i turn it on and fix them lol. DOTS Physics has been a hassle with that
yeah now i'm like wait i've been doing things wrong all this time??
I'm praying Native Octree get'e raycasting queries so I can skip on a whole ms of unity physics lol
Bah can't do that in the end, too much of a pain
i feel u
And prolly mostly impossible anyway
I just want a good Native Octree 
Cuz I don't have the knowledge at all to do that pr lol
I was about to say check the Dots Physics implementation out, but my brain starts melting when reading through the code
I switched to urp and now getting 2.5ms instead of close to 5, without fucking physics I'll get 1.5 ms with 80% being transform system group on like 120k child entities
Yea same @north bay
anyone using unity transport on mobile devices? I am having problems with android devices, can't bind socket, not sure where to ask, asked in forum but nothing
Hemm is unity transport part of the dots stack? Never heard of that package ^^'
Kinda, that's a transport layer they made after the FPS Sample
Ha
it's basically the LLAPI of netcode
but I suppose here is the only place to ask
where netcode is HLAPI
in unet terms
yea it's right place (don't have the answer tho)
I think there was some burst compilation errors on Android, maybe thzt's part of the problem?
ok, thanks
I have runtime issues, build starts withour problems but fails with socket error
Did you check logcat out or whatever the android logging is called?
I ahve android internet permissions
@tardy spoke maybe you have some experience with transport?
I feel like I am the only one using unity transport, probably nobody is so crazy as I am
Haven't tried it on mobile yet
it never worked for me, i ended up replacing it
Netcode sure, transport by itself tho :(
@dire crown what are you using now?
ended up switching to steam networking since that was the platform we were on
ok, thanks, yeah, not my case
The new Steam Socket thing?
this was a few years ago, i don't think its new. they have added more support to it right?
but yes steam sockets
pretty sure this was the interface we used https://partner.steamgames.com/doc/api/ISteamNetworking
it was the older api
Does DOTS Physics Body use the gravity in Project Settings or is it set elsewhere? My body is falling verryyy slowly
pretty sure its part of a script you add to the scene
"PhysicsStep" thank you!
Is there any way to use terrain in DOTS yet? I can't seem to make it work with entities
Its me again... this time a question about converting logic from oop into ecs... Where do we move the logic of methods to during the convertion ? A little example :
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Lets say we had a class in the past which represents a inventory... it has add/remove/get methods, but those methods dont only put the stuff into the list... they also check if the item can get merged ( Minecraft like stack mechanic )... where do we move this logic inside a ecs ?
The stuff creating the entity is in Convert
The continuous logic is in systems
The problem here... the "add" method from the inventory is not continuous
So should we define a "AddToInventory" component and its own entity as some sort of command for adding stuff to the inventory ? Or how do we convert this `?
Create a Public method in your inventory system, and fetch your system from other system when you need it
That or create a buffer of items to add to inventory (more sane approach, would still be nice to have the method doing this in the inventory system still)
I would do something like this:
make a lookup entity.
make a DynamicBuffer component attach it to the lookup entity.
make a system and wrap your add method in a bool within OnUpdate.
and have another system flag that bool whenever it wants
Thanks a lot, both of you ! What about this approach ? We define a entity that is used as some sort of command to add stuff into the inventory ? ^^ For example : Entity{..., AddToInventory } -> AddToInventorySystem processes them and adds the content to the inventory ?
Oh i see, i killed the whole chat
I would probably use an entity like you said, it gives you more control. Let's say you can have an add to inventory entity. WIth a addtoinventory component that has a target, an item, etc...
Then you have a system that looks for AddToInventory components, and produces the command, then deleting the entity
@stone osprey
Unless there's a downside to this method that I can't see
@fluid kiln Thanks for your feedback ! Im still struggling here... couldnt really decide what way to choose. But your answer gave me confirmation. I love flexibility and this is clearly a variant which is not hardcoded at all 🙂 Probably its also better for multithreading, due to the asynchronous processing of those command entities. The only downside here is the boilerplate code ^^ instead of "inventorySystem.add()" you always need to create a entity and attach the right component, but well... theres always a downside
Yeah, and that also means for every "command" your game has, you'll have to create a component and a system. I'm fairly confident ECS will get more and more user friendly with updates, meaning less boilerplate code in the systems. But considering we're in ECS, it makes sense to me to create an entity for that. That's where it's really different from OOP, you wouldn't create a class just for one operation.
Don't take my word for it tho, I'm fairly new to this
i think it makes sense, and what i like about it, is that its helpful for debugging because you can pause the game and go check the entity inspector and see the current state, see that x y z commands were produced properly, and step through to see if they're handled properly. It also decouples your producers from consumers/handlers.
I totally agree with that, thanks @fluid kiln @mint iron 🙂 Im also pretty new to the ecs, theres also not that many articles about ecs architectures/patterns... that makes it even harder to come along a decent solution
@tardy spoke maybe you have some experience with transport?
@zinc plinth unfortunately I do not. 😦
Alright I upgraded and I'm running 2020 with the latest packages but still having issues with material properties. Each property is set up like so in shader graph. The script has a simple class that I created following the hybrid renderer v2 docs. The system doesn't show up in the Entity Debugger at all https://paste.ee/p/5uoXd
you have to create your own struct and add it to the entity that has the material
Unity wont create an unique struct for your material property
I really appreciate the help
we are the only discord channel here that actually answers questions 😄
and we're proud about it 😄
I'm having such a blast with ECS and NetCode, it's awesome
nice! i havent tried it yet, its working well for you?
Yeah it's surprisingly intuitive once you get your assimilated OOP concepts out of your head, for the netcode it's another beast, I spent 24 hours trying to make a capsule move
But now I've unblocked and having quite an easy time with it
I'm gonna make a tutorial to cover the shitty Getting Started doc
nice! there's some folks around making a wiki on github of stuff, could be a good addition
i'll check it out!
So as of 2020, what is the best solution to manages strings in ECS?
I can't use monos because they need to be sent over via NetCode
send it as a byte array and reconstruct it as a string?
I see FixedStringXX in Unity.Collections, might be an easier to use than converting to bytes
FixedStrings work too
Are they slow?
well internally they just store bytes
so it basically does the conversion for you? that's good
yeah
@fluid kiln mind if I add your knowledge nugget to the library of wisdom?
oh you havent made it yet!
It's you who manages the library of wisdom? I'll let you know once I do :p
i am but one of its humble servants
i think it was @tardy spoke and @violet cosmos talking about it recently? https://discordapp.com/channels/489222168727519232/497874303463850004/743305277649977374
its a simple operation once you're ready -- https://github.com/DOTS-Discord/Unity-DOTS-Discord/wiki
FYI, I'm stepping away from DOTS for a bit
I might try it again, for pure Jobs in a few months, when I get into optimizing the proc gen systems, but that's mostly to not tie up the main thread...
thank you for your contributions! We'll be here when you get back!
Yeah, it's a bunch of half baked things not thought out for how developers need... But to make some shiney demos. Count me out
I'm building a thing, not a demo
or, if you dont need to come back, then best of luck in your endeavors and thanks for dealing with the struggle with us!
Glad I could contribute in some way, but I do kind of want those three weeks of my life back 🤣
instead of comparing those 3 weeks with not using dots, compare with continuing to use dots and suddenly you have 3 years of extra life 🙂
hahaha yeah true dat
Good luck out there @violet cosmos
instead of comparing those 3 weeks with not using dots, compare with continuing to use dots and suddenly you have 3 years of extra life 🙂
@hollow sorrel I couldn't imagine how that would work 🙃
The way I see it, you won't start from scratch once DOTS is more mature
Yeah. Honestly as a single gamedev with a full time engineering job, my game wont be ready to ship next year (although that is my resolution), I'm okay with playing the long game.
Oh, dont get me wrong though, @violet cosmos, thats not a contradiction to what you're saying or your conclusion, or your general strategy
Not me. It doesn't work for me, and any affordance they make for what I need would be a significant change
Also, I view it as a technical debt. It will have to change, the API is very likely to go through other huge revisions, especially if you're using hybrid
You're not ahead if you've filled your garage with piles of shit you need to shovel out
You're absolutely not wrong.
I used to follow the Arcadia dream. a lisp based repl driven code interface to unity.
they're incredible devs, and theyve been working their asses off, but its always going to be 2 steps behind
because Unity can't finish a damn package to save their lives 😂
It's fine if you want to nibble at that technical debt release by release, I get it. For certain things, ECS and Hybrid could work
Jobs will work in the niche use cases too
But I'm not going to build anything around ECS until Unity cleans house on the API
Also, I don't trust Unity
And again, you've been generously offering your contributions to knowledge while you've been waylaid here
so, like, you've put in your time, you gave it a fair shot
I think you've a right to say "fuck this"
Look at URP. It's core selling points are: Shader Graph and mobile performance
It's now on version 8.2.0 and guess forgot to add a core mobile material type to Shader Graph? 🤣
technically on 10.x is the latest
Still, doesn't have Simple Lit as a base material afaik
Two years going, people asked for that
The only way to get it is to buy a $30 asset, or make it yourself
I only trust Unity in general, not in implementation details hehe
well source is there, drop the shackles of shadergraph
phil-lira has some excellent shader examples on his github
Oh, I know how to write shaders. I have a whole custom thing for built in and shaders I'm porting to URP as we speak
But, it sure would be nice to say "Hey, I wonder what this looks like with some X and Y" and bang out a graph
Others are not so fortunate to know hlsl obscura too
i get it, current stuff kinda is ass in some places, thats the price of being an early adopter 😉
The point wasn't on my capability, the point was how sometimes Unity often forgets what the day to day developer needs to be productive
It eventually gets there
Anyways, I'm still heavily invested into Unity and will continue so for awhile to come
I honestly do like URP. Was just commenting today in fact that it's refreshing to actually be able to read through and deconstruct core shaders. Built in was a hot mess
does anyone know what the entityInQueryIndex in this refers to? and why its necessary in the setComponent call? https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/f1c9ca936ae506c6dbe2497be4094ecc9c806028/ECSSamples/Assets/HelloCube/5. SpawnFromEntity/SpawnerSystem_FromEntity.cs#L43
I think because you're usually building a command buffer, and if you need to update an enity it gives you the ability to update the same one
Lets say, two systems and four queries could update one entity
entityInQueryIndex refers to the index of the entity being operated on by the Entities.ForEach loop (relative to the set of all entities returned by the loops query). It's necessary in the setComponent call (and the instantiate) to sort a deterministic playback order for the concurrent command buffer
you guys have an example on raycasting ?
physics docs do
also https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/UnityPhysicsSamples should use it on bunch of examples
Hi all. Quick sanity check question:
I have a modular objectives system set up and am implementing 2 different game modes. The different modes require different behaviour from existing systems (eg enemy behaviour, camera-follow/movement code etc).
The two main ways I see to do this are:
- multiple sets of systems, each gated by different game-mode-specific singleton components
or - Single set of systems, game mode data stored in the singleton component that's required for the systems and a check within update for which game mode logic to use.
I was leaning towards 2) until I started writing this. Is it better to have multiple systems that don't run because there's no component fulfilling the RequireSingletonForUpdate(), or to have a conditional being checked in each of the systems every time they run? Both feel a little bit of a compromise!
I was wondering if anyone knows of a way to retrieve the material hit with the Unity.Physics raycast. Specifically on entities.
What is dots can someone explain the benefits and what it’s for?
performance \o/ but its not ready for production, only go for it if you want to play with it
so basically, its new way of coding to get advantage of multithreading and burst (which is Unity's super performance code compiler.. and stuff)
So burst it like il2cpp but faster
DOTS is the umbrella term for a suite of preview/experimental new engine features that is aimed for performance.
So burst it like il2cpp but faster
yes
Ooo
It's also a lot about working with linearly laid out memory for cpu cache efficiency. The ECS part of DOTS is more about working with structs, avoiding as much traditional MonoBehaviours and managed data as possible - which aren't thread-safe - (ideally just syncing at e.g. start & end of frame) to allow you to easily go wide across threads.
I'm back with two small videos of what we are building with DOTS , This is our firework like show system https://www.youtube.com/watch?v=oUo_j4nYr00&feature=youtu.be
and this is quick but about what the game is all about until now on. https://www.youtube.com/watch?v=sRDeffqQPQg&t=3s
We are 7 weeks into pre-production with one semi-junior dev coding and me guiding it as senior technical guy and we have 2 game designers on the project too.
Shoot me questions if any regarding inventory, quest, ... any general systems. character and vehicle movement is not started yet so don't ask regarding those 😄 We're going to start using unity's physics samples
P.S We had a bit of prior experience with DOTS on a canceled project (cancelation wasn't related to dots) and heavily read code and watched unity videos and read their docs
Shows happen in stadiums and you make beautiful moments, visual amazements to behold and complete tasks to earn tablets to sell and get better gear, awesome vehicles and see the world.
You go to other stadiums, create roads and tunnels and rule the world of show business and m...
In this video we show the core loop of the game and the driving mechanic
I'll make development videos or posts with questions
does anyone know a workaround in using EntityCommandBuffers and the problem that CreateEntity or Instantiate return -1 as entity?
afaik that should be a temp index that gets remapped to the proper id after the ecb system runs
or do you mean always just -1?
wtf. remember my question about this line? well apparently the name of that parameter is fixed. if you give it a different name, even if its in the same position with the same type declaration it wont compile 😂
"yup, passed my unit test, we're good here. Dev Complete" - that dev
it is documented in the docs
Okay y'all, with the new NetCode I want to send a RPC that references a ghost other than the client ("NPC" spawned by the server). How can I reference the ghost in the RPC so that the client can find it? The only value I can find matching the entities on the client and server is the ghostId
ghuuuuuhh.... Man, just an FYI to everyone, the https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/HelloCube/5.SpawnFromEntity stuff doesnt work. another dead damn example
I wonder if anyone on our wiki has an example of spawning entities from entities
Hmm isn't that just an EntityManager.Instantiate(Entity)?
^
yeah, I guess I'll end up doing it that way. The idea was to do it in a job in parallel
might be what you're looking for if you're doing it on a large scale and bringing it over from the set up world to the default world
then I have to learn about alternate worlds
lol, I guess that will be tomorrow's labor
is anyone able to spot in this code why there are native containers not being properly disposed?
its curious that I get that error 3 times
ahh, I bet its that blobassetstore
welp. no idea how to fix that.
dark mode is free now btw :p
@tight blade dispose BAS on frame + 1
also
use a single call to CGOH if possible, it is extremely costly and create a full blown conversion world each time
put them under an empty root go, add some tag to each of them to identify then and get their entity back that way through (either child if you wait frame + 1, or filter through the LinkedEntityGroup)
yeah, this whole spawner is a wash perf wise. I started the night trying to get everything running in a job with an entity command buffer, now I'm just trying to get anything to run without errors
good tip though, regarding hierarchy.
also if this is exec multiple time store prefabs of each of these LEG and just reinstantiate the entities
if a prefab entity has a LEG the EntityManager will instantiate all the entities in that LEG
whats that acronym stand for?
LEG = LinkedEntityGroup
nice. thats awesome, thanks
Thank you for the links! I couldn't seem to come up with a good enough google search myself
@tight blade you have to dispose BlobAssetStore as well
Guys, I need some help to understand the new Unity mathematics package.
Currently I'm doing a jobfied version of the code shown below (its based upon the third person tutorial of Brackeys)
When I tried to do a Job corresponding to this method I've tried
However my character is moving at wrong angles now (not sure where the calculation is wrong).
@rough crown the mathematics package uses radians instead of degrees. instead of converting to degrees you can just leave the angle as-is
@craggy orbit thanks, solved my issue, is there a method to convert the camera euler angle y to radians?
yeah there's a math.radians() that you can use to convert degrees to radians
Thanks a lot for the help!
I dont suppose anyone knows why I'm getting this error Library\PackageCache\com.unity.jobs@0.5.0-preview.14\Unity.Jobs\IJobParallelForBatch.cs(63,30): error CS0117: 'ScheduleMode' does not contain a definition for 'Parallel'
what package or version am I missing
try going into preferences and rebuild the project/solution
yeah i think so
let me check my jobs package version
hmm yeah mine is 0.5 as well but i dont get an error like that, using 2020.2.0b
are you using Turtle's event system ?
I'm loading a package from someone else so maybe its fixed to that version of theirs
yeah
👍 thanks, that worked
nice 👍
@fluid kiln https://forum.unity.com/threads/dots-netcode-0-3-0-released.955890/page-2#post-6256991 and https://forum.unity.com/threads/dots-netcode-0-3-0-released.955890/page-2#post-6266304
@viral sonnet I'm not sure if I see the final solution. Are you still using your ghostlookupsystem or is there a more direct approach using GhostField?
The GhostLookUpSystem works really good tho thank you!
@fluid kiln Currently I don't know a better version. RPCs sadly don't use any funtionality of the GhostField. You could add them to the ghost as [GhostField] but then you need a ghostClientId and ghostServerId, so not that great also as it's confusing to have runtime data in sync. I've extended the lookup system with a Entity to ghostId hashmap so both ways of looking up exists. Never needed it before but at one point I needed the ghostId and I only had the entity, no ghostcomponent, so instead of GetComponent I just made another lookup. Should be more performant I think.
So in your TargetComponent (I assume you're making some sort of RPG), do you hold a reference to the entity or the ghost hash? That means that every time I want to access the entity of the target I need to use the system? So if I have 5 systems that uses the TargetComponent, that's 5 lookups per frame per entity.
99% of the time I use the entity itself. Only in sending/receiving RPC calls I lookup the ghostHash
So just so I'm understanding correctly, you set the TargetComponent locally with the target's entity. Then you send an RPC with the ghost's hash, and then on the server they use the lookup to convert it to the entity?
correct
Perfect, thank you!
you're welcome
oh, and don't forget to put a [GhostField] on the Entity in your target comp. Otherwise it's not getting synced to all the others
See I did that, but I don't understand how all the other clients can reference that entity?
If it's synchronized by the framework, why isn't it done in the RPC component too?
ghostfield does the server<->client entity referencing automatically
But not in the RPCs yet?
yeah, i asked the same question 🙂
Yeah I saw, I just makes sense to me, but I guess it'l lbe added in the future :p
at first I thought I could just change the target entity on the client but then it didn't work and I was ohhh authorative server, right. Client has zero control over ghosts
it can only predict and if that fails -> rollback
one time i forgot i added a cooldown comp and didn't predict it. constant rollbacks and lags. haha
Yup! Which makes sense. I'm wondering tho, if my "Player" entity has a target component on the server and on the client, when I set the target locally and then send the RPC, will the few frames in between the reception of the RPC set the client's target to null?
no as it's predicted and ghostfields get saved in the prediction history. if you get a rollback the correct target entity will be there
Okay okay, I'm slowly starting to grasp all of this
thanks!
The netcode is pretty cool to use so far, I'm enjoying itr
np, yeah, without a good grasp it's hard making good designs. i'm still learning too. i think netcode 0.3 is pretty good so far
i want new packages 😦
what helps is that i've worked with the FPSSample back in the day and re-built it from scratch. That was painful but I know what's going on that way
I bashed my head against the Cube example for a good 24 hours, but after that it kindof clicked
hehe, like everything in programming, once it clicks it's pretty great
and writing multiplayer code is easier then ever. i used all versions of their netcode and now it's at a point where the experience is mostly, wow, it works. cool
Yeah I'm really excited, I haven't done much netcode before but I'm surprised at how simpler it is than it looks. Being new to it, it's excited just to see a remote client moving around from another 😂
i started serious network coding in 2015 and I quickly found my limits ^^ i could get stuff to work but it was either heavy on cpu, bandwidth or both. stuff like snapshot compression, i can't do that shit ... lol
Do you think the new NetCode will help in these aspects?
yeah, it already does
what helps is that i've worked with the FPSSample back in the day and re-built it from scratch. That was painful but I know what's going on that way
@viral sonnet Did the same, when netcode came out i transitioned to that
Only problem i have with NetCode and ecs in it's current state is the job overhead. I cannot schedule any of my systems which are inside the prediction group since that instantly adds way to much overhead.
yeah i'm waiting for a new ecs version. scheduling and acquiring data is so slow. I use mostly Run. I don't expect more than 1 core on serves anyway.
I did some heavy testing in a timelapse feature, where I wanted to simulate several hours as fast as possible and Schedule drained the whole flow
basically, when acquiring the data is slower than the actual system code then Run is better
have they acknowledged that scheduling is slow and can be improved?
Joachim acknowledged the schedule problem but i haven't seen any update in it since then
So is it normal that so far in my ecs project, in a lot of my systems I had to use WithoutBurst and Run instead of Schedule
at this current state it's normal
as long as you don't use WithStructuralChanges you're mostly good
EntityCommandBuffers are also slow
I don't think i use a single WithoutBurst inside my Simulation group
You have to use WithStructuralChanges every time you add a component?
i think they are still not bursted, don't quote me on that
Cause that's most of my systems lol
not with an EntityCommandBuffer
I think most of functionality of EntityCommandBuffers is bursted by now
Haa, so I should use the buffer instead of straight up the entitymanager?
SetComponent >>> EntityCommandBuffer.SetComponent
Looks like I got a bit of refactoring to do
so writing back to GetComponentDataFromEntity is faster
i just don't understand why really
guess there's much overhead, i've never debugged what's going on the Playback of ECBs
for anyone using netcode right now. use this barrier: ``
[UpdateAfter(typeof(GhostSimulationSystemGroup))]
[UpdateInWorld(UpdateInWorld.TargetWorld.ClientAndServer)]
public class EndGhostSimulationBarrier : EntityCommandBufferSystem
{
}
if you write to the barrier in prediction systems you can have current data in systems running after the prediction while using ECBs. otherwise it's 1 frame behind
i nearly went crazy getting the sequence right with a mix of data i needed in this frame but only had available in the next
Would that fix the very faint jitter when I move my capsule?
i don't think it does anything for movement unless you have systems running after the prediction which change movement
if you have jitter you either have a problem with frame timings or slight drifts in prediction
I'm not sure if it's even jitter
Problem right now is I have this component
public struct TargetComponent : IComponentData
{
[GhostField]
public Entity target;
}```
When i set target on the server, it becomes null on the client
is the target a ghost?
test it out manually to see if the syncing works. if it does the problem is in the rpc
yeah, set the target on the server to something you know will work.
could even target itself
i'll set it on instantiation
Yeah it works when I set it
Mmhh
Do you see a problem on my RPC systems? Don't worry if I'm asking to much I'll find it eventually 😂
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Because when I send the RPC' the server receives it and sets the target, but it's not updated on the client
maybe try [UpdateAfter(typeof(GhostLookupSystem))]
for ChangeTargetServerSystem
also for any other system that uses the lookup
To send the RPC, I create an entity and attach the IRpcCommand component to it to be picked up by the system. Is that right?
yeah
Because I see that the RPC entity isn't deleted on the client side when I delete it on the server
🤔
hm, so you need to find out if the rpcs are sent/received
Well I log the console when it's sent to the server and when it's received
The server receives it and even sets the target, it's weird
ughh!!! I wasn't deleting the SendRPC entity, just the ReveiveRPC one
I didn't realize they were different!
hm, i don't delete my send rpcs on client
You probably don't instantiate them the same way I do
sure, i do the same thing. create an entity and put the rpc comp + sendcomp on it
i just don't do it in a system. working in the same frame as adding networkstreamingame is dangerour i think
Yes this one is deleting, but I create an entity so that I can initiate the RPC from elsewhere
