#archived-dots
1 messages Β· Page 144 of 1
I've never seen anything like this
the only issue i did have was Performance, as that ForEach has like 10k generated overloads π but they fixed that pretty quickly
Hey guys.. Ideas on how to do RTS style drag select?
My options I've thought of
- All selectable entities are to have a "screen position" which is Camera.WorldToScreenPoint
- Calculate the camera frustum and figure out a Unity.Physics query somehow
@ocean tundra You can try projecting from screen point to world point and check which positions are in the area that's been selected when doing that click drag
@coarse turtle Screen to world.. Like raycasting?
As thats what im doing for normal select, but I want drag select now
You can do something like that, or just transform the screen point to world point with some matrix math π€
I'm pretty sure you can reproduce the same steps as you'd do it in opengl: https://stackoverflow.com/questions/7692988/opengl-math-projecting-screen-space-to-world-space-coords
π€
that looks way confusing π
but im still unsure how getting a mouse world point helps, i still need to raycast or something
Im thinking i could get the 4 corners of the camera and raycast to the ground, then create a overlapAabb
ah that might be an interesting idea
but yea that idea was just from the top of my head
I might be oversimplifying it π€
A. Convert the "Drag" box from screen to world (which then makes a cube volume from nearclip to farclip), use this to either iterate units and check if they are in said volume or use Physics.CastBox to let physics engine to do it, or B. iterate units, convert position to screen space, and check if position lies within selection box. B is simple and straight forward. not great performance but that may not matter.
Can a AABB be rotated?
nope they are axis aligned
you can do some math to rotate them yourself if you want
but then they are not axis aligned anymore
I generally use AABB for early checks, and if the AABB overlaps I then do a more intensive/accurate check
true
I like the idea of starting with a AABB
and then doing B i guess
i could create a custom mesh collider and then cast that
but that seems expensive
it's basically frustum culling in a way, just with a smaller frustum than the actual camera frustum
yea exactly
Its possiable to create one of those using https://docs.unity3d.com/ScriptReference/GeometryUtility.CalculateFrustumPlanes.html
or even do it myself
yeah could try that
how would i know if something is inside them or not?
π€¦ββοΈ
I have no idea how performant any of this is
yea im not sure if that stuff is Burstable π
probably decent I imagine
yeah probably not
could do the math yourself
but again, just iterating the units, projecting to screenspace, and doing a simple rect check may be all you need for now
unless you plan to have 10000 units or something I guess
haha thanks
i think AABB to find units within the Rough drag area, followed by constructing a Frustum of the mouse box and doing a burst compatible version of TestPlanes
i could also optmize more by filtering out already selected units
what if the new selection box no longer contains them
You could probably re-use the components rendering uses for culling to filter for visible units, and then use the plane tests
https://pixelmatic.github.io/articles/2020/05/13/ecs-and-ai.html an interesting blog abt utility theory/BT ai in dots
Some of those code examples, don't actually work
I love utility AI. I've been thinking about using neural nets to tune them instead of doing it manually though. I wonder how well that'd work in practice.
cause manually tuning them sucks
There is a very good paper/article on GOAP used in F.E.A.R.
I wish aigamedev hadn't died off
wonder if there are any new Game AI Pro book releases out
nope
and yeah that FEAR paper was good
There has to be a backup of aigamedev somewhere, that was a lot of really valuable info to just disappear
Some of those code examples, don't actually work
@stiff skiff o good to know
Also the example given, is NOT goap
Whats the best way to do/have performance tests in the build
I'm thinking using custom command line args which can effect my main game scene in some way (spawn in some stuff)
But how should i go about capturing/exporting things like FPS? I have Graphy in which can give some nice visuals/stats, should i be attaching a profiler?
I typically just attach a profiler
theres a overhead with a profiler isnt there?
the overhead should be small if you attach it to the player
also i want to setup and run my server/clients in these tests to also preformance test my networking
I recommend separating all of these tests out into parts. For example using multiple playmode tests using the new performance test framework package.
If I'm in monobehaviour code running in the editor, how do I get the client world (and entitymanager) of the client who is currently presenting?
is that with NetCode?
if not you can probably just use World.DefaultInjectionsWorld or something like that
theres also World.All
@ocean tundra I'm trying to eventually send an RPC with netcode, yes. World.DefaultInjectionsWorld is giving me DefaultWorld0
not one of the client worlds I probably want, I think?
I could walk the list of worlds, I suppose, but how do I programmatically know which is the right one?
In the editor, I might have multiple clientworlds
im probably going to implement something like that in my net code
there must be a variable somewhere saying which world is active
worst case you can loop over every world and find the one that has presentation group active
"has presentation group active"?
@sand prawn you can do world.GetExistingSystem<PresentationGroup> or something like that
and check to see if it exists and if so if it is Enabled
@sand prawn @ocean tundra You kinda have to loop through all the worlds and check if their systems are active. Here's a snippet taken from the docs: https://docs.unity3d.com/Packages/com.unity.netcode@0.1/manual/getting-started.html
{
// Destroy singleton to prevent system from running again
EntityManager.DestroyEntity(GetSingletonEntity<InitGameComponent>());
foreach (var world in World.AllWorlds)
{
var network = world.GetExistingSystem<NetworkStreamReceiveSystem>();
if (world.GetExistingSystem<ClientSimulationSystemGroup>() != null)
{
// Client worlds automatically connect to localhost
NetworkEndPoint ep = NetworkEndPoint.LoopbackIpv4;
ep.Port = 7979;
network.Connect(ep);
}
#if UNITY_EDITOR
else if (world.GetExistingSystem<ServerSimulationSystemGroup>() != null)
{
// Server world automatically listens for connections from any host
NetworkEndPoint ep = NetworkEndPoint.AnyIpv4;
ep.Port = 7979;
network.Listen(ep);
}
#endif
}
}
I'm trying to create a grid map of my entities' positions
I'm trying to use entities.foreach to grab position data from entities and update a multi hash map like this:
JobHandle spawnJobHandle = Entities
.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) =>
{
int hashMapKey = GetPositionHashMapKey(translation.Value);
sectorsMultiHashMap.Add(hashMapKey, new SectorData
{
entity = entity,
position = translation.Value
});
})
.Schedule(inputDeps);
However my sectorsMultiHashMap is a static variable, because I want to access it in other systems. I know I can't use static variables with Entities.ForEach, so I'm not sure what to do. is there a way to update the static variable? Or should I find another way to share the sectorsMultiHashMap with other systems?
Store map in local variable outside ForEach. Despite that all native containers is a struct and copied by value, they all under hood use pointers to used memory thus every value copy (just pointer and allocator label) will point to the same memory and changing values of that map, stored in a local variable, will change your map in a static field.
wait so how do I access the local variable from other systems then? do I just set the static variable to the local variable afterwards like this?
NativeMultiHashMap<int, SectorData> localMap = sectorsMultiHashMap;
JobHandle spawnJobHandle = Entities
.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) =>
{
int hashMapKey = GetPositionHashMapKey(translation.Value);
localMap.Add(hashMapKey, new SectorData
{
entity = entity,
position = translation.Value
});
})
.Schedule(inputDeps);
This local variable only for current context
in every system you just do the same
where you need pass your static NHM in to ForEach
it doesnt seem very efficient if I have to sort all my positions in every system that needs that info
maybe i'm going about this the wrong way?
I found this guy doing the same thing: https://gist.github.com/mikestonecodes/5ccf0bdb20011b41405e62f2d4f7db0e#file-quadrantsystem-cs
so I edited my code to use "quadrantMultiHashMap.AsParallelWriter();" like his. Which I think is letting me write to the hashmap π₯³
but I get an invalid operation when I try to access the hashmap from another system, which says " You must call JobHandle.Complete() on the job QuadrantSystem, before you can read from the Unity.Collections.NativeMultiHashMap"
I guess its saying I need to wait for the system to finish its jobs. So I put
[UpdateAfter(typeof(QuadrantSystem))]``` in the accessing system but it didnt fix it :/
The accessing system:
```csharp
[UpdateAfter(typeof(QuadrantSystem))]
public class WorldRenderer : ComponentSystem
{
protected override void OnUpdate()
{
Debug.Log(QuadrantSystem.quadrantMultiHashMap.Count());
it doesnt seem very efficient if I have to sort all my positions in every system that needs that info
This error will be expected, you should handle dependencies for your container it's not managed automatically. UpdateAfter only define systems update order, not jobs chain. Dependency chain responsible for jobs waiting
You have systems A which populate that map
and all other systems which will use that map should be in the same dependency chain
it doesnt seem very efficient if I have to sort all my positions in every system that needs that info
@leaden hatch You shouldn't
Read again:
This local variable only for current context in every system you just do the same where you need pass your static NHM in to ForEach
you should do the same local variable approach, not ForEach itself. First system populate map, other systems use map.
I added a local variable like this :
var LquadrantMultiHashMap = quadrantMultiHashMap.AsParallelWriter();
JobHandle hashJobHandle = Entities
.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) =>
{
int hashMapKey = GetPositionHashMapKey(translation.Value);
LquadrantMultiHashMap.Add(hashMapKey, new SectorData
{
entity = entity,
position = translation.Value
});
})
Is this what you mean by a local variable?
I tihnk I'm misunderstanding what you mean
I recommend you start from docs and samples repo and understand basics, understand dependencies and how DOTS manage things, check source code π It will be better for you than just drop inside blindly.
thats fair
I'll take a look, tyvm
What you need to do in your case. Store your static map in local variable in this system (as you already did) pass that local variable in to lambda for processing. Store this system job handle (guess you'll use static field for that if you using static field for map). In every system which should use that map you should combine this job handle with system job handle and use as dependency, return it back etc and use your static NHM. it become a mess very fast with this approach π Better is use some dummy type with ICD class (and use that class as Singleton entity), which store that map, and give unity manage dependencies by that dummy type.
@storm ravine Ty I'll look into this and read up on ecs/dots
@storm ravine I actually got it to work in the end. The error message I posted was actually telling me what to do lol. I needed to use hashJobHandle.Complete();
This ran super slowly with ComponentSystem, but with JobComponent system its ridiculously fast, basically not even a hitch. Unity's ecs is pretty neat. Hopefully I can use this to only render what the camera sees and have all the fps in the universe!
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
EntityQuery entityQuery = GetEntityQuery(typeof(Translation));
quadrantMultiHashMap.Clear();
if (entityQuery.CalculateEntityCount() > quadrantMultiHashMap.Capacity)
{
quadrantMultiHashMap.Capacity = entityQuery.CalculateEntityCount();
}
var LquadrantMultiHashMap = quadrantMultiHashMap.AsParallelWriter();
JobHandle hashJobHandle = Entities
.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) =>
{
int hashMapKey = GetPositionHashMapKey(translation.Value);
LquadrantMultiHashMap.Add(hashMapKey, new SectorData
{
entity = entity,
position = translation.Value
});
})
.WithStoreEntityQueryInField(ref query)
.Schedule(inputDeps);
hashJobHandle.Complete();
return inputDeps;
}
Both deprecated. Use SystemBase instead π
Oh really, haha crap thanks
Ok with SystemBase lol. Thanks again @storm ravine
protected override void OnUpdate()
{
quadrantMultiHashMap.Clear();
if (query.CalculateEntityCount() > quadrantMultiHashMap.Capacity)
{
quadrantMultiHashMap.Capacity = query.CalculateEntityCount();
}
var LquadrantMultiHashMap = quadrantMultiHashMap.AsParallelWriter();
Entities
.ForEach((Entity entity, int entityInQueryIndex, in Translation translation) =>
{
int hashMapKey = GetPositionHashMapKey(translation.Value);
LquadrantMultiHashMap.Add(hashMapKey, new SectorData
{
entity = entity,
position = translation.Value
});
})
.WithStoreEntityQueryInField(ref query)
.ScheduleParallel();
this.CompleteDependency();
}
hello, does anyone know of the fastest way to set all NativeArray elements to 0? Iterating over a for loop seems takes up quite some time.
MemsetNativeArray<T> ?π€
@warped trail thanks, that just improved performance by 10
Im struggling to understand Big data.... my map is saved in pieces... for any XYZ in worldspace, I have a function so I know to get the data I need I must open "Piece A" at array poisition "B"
But how to pass this function to a job
dont want to pass my whole world data π
really the job just needs Read only access to the world
(pieces are entitys)
example, my playercontroller system must see if I am touching the floor. Rather than looping every entity in world, it only needs to loop 1, in the place I am sttod
before I just had a simple function: world.IsBlockSolid(testPOS) but implementing this into a system is bvlowing my mind π
General NativeCollection question. If I'm writing a function that returns an array of float2 I'm wondering if it's better to use NativeArray or just return a float2[] and deal with it, given that the function may or may not be called by DOTS or Jobs code? Is the NativeArray faster than float2[] or is it just the garbage collection?
General NativeCollection question. If I'm writing a function that returns an array of float2 I'm wondering if it's better to use NativeArray or just return a float2[] and deal with it, given that the function may or may not be called by DOTS or Jobs code? Is the NativeArray faster than float2[] or is it just the garbage collection?
@low oasis
NativeArray is only faster than a managed array if it's used in burst. Otherwise it's slower.
oh new animation package too 0.4.0p1 https://packages.unity.com/com.unity.animation
i miss browsing bintray π
@zenith wyvern So, if I'm making a static function it is probably better to return a float2[] and convert it if I'm doing anything with Burst, which I would hope to take advantage of.
Depends on a lot of things. If you aren't going to be keeping that managed array around that's an unnecessary allocation.
@bright sentinel @ocean tundra I rather thought the PresentationGroupSystem was for UI bits? @bright sentinel I know all of these client worlds will be in the "AllWorlds" list because they're all running in editor. Just don't know which one is currently presenting.
@dull copper it works with the latest entities(0.10), i have a small project to test it out with. from the notes theyve upgraded to using systembase for at least some of the systems(cant tell if its all) so its ahead of physics in that regard π
Ah, got it. It's the ClientPresentationSystemGroup that I care about
Anyone found any change logs for Unity.Animation?
@sand prawn Nope Presentation is for all visual things, DOTS has no UI bits yet
whats a dataflow graph??
something animation uses to connect up all the clips with rootmotion and mixers
im guessing the final thing might be visual or at least include a visual part because theres descriptions in the code for the animation nodes like rootmotion
sounds cool
like [NodeDefinition(category:"Animation Core/Root Motion", description:"Extracts root motion values from animation stream so these can be used for different operations (i.e store state values in entity components)")]
do we have to use it for animation? ideally i would like to just Play a animation clip
well you need to use it to make a graph to drive any animation in dots, assuming its the equiv of the playables in regular unity but I really barely understand whats going on π
cant figure out how to add rootmotion to the play clip example in the samples π€·
sometimes i feel like unity does the really big stuff and forgets about small stuff, why not give us the ability to just play a clip and then work on the next level up
i want to have my animations controllable via data, and things like the animator makes it super duper hard to swap animations at runtime
well theres an example to do that in the samples
all the easy side of things will come later, i do wish later was sooner but thats the price of being an early adopter for this stuff
π
yup
i love it tho
the whole ecs coding pattern is awesome
that data flow graph thing, is basicly a state machine??
i dunno? maybe more like a behaviour tree?
@coarse turtle Inside animations, I dont really understand what it is tho, Animator for ecs?
o
oh nice
i havent tried it at all though
something for tweening too, not sure but @tawdry tree might want to see it(i think you were working on a tween package for dots?)
That wasn't me, can't remember anyone working on a package for that
But I do remember discussing it, so someone else might've been working on a package
π Iβm working on a dots tween library. Similar functionality to DOTeeen. Though it will work with monobehaviours and much more. Hopefully thereβs room for both what Iβm making and what Unity comes up with π .
About a year and a half in... wasnβt as easy as I thought π¬
dataflowgraph tween sample
i guess its animation related but maybe something there you could steal π
Any documentation for it? (im guessing no?)
all the docs are the examples
Quick question:
Any good way to use non Blittable type variables with the Job system?
I kinda need to find a way to make an OpenCV method that takes ~300ms run in the background so it won't freeze the UI constantly.
The only problem I'm left with is how to get the Cv2.Mat into my job without referencing the static var from inside the job (which works but yeah no)
I tried converting it in a couple of ways but neither worked so far
Currently thinking about just using the regular multithreading system
How do i add unity animation again?
do i need to manually add it to my package thing?
probably easier to clone the animation samples repo
wip - you'll be able to create an animation as an asset, edit it on a Timeline, target gameobjects or entities independent of hierarchy and use it with entities/conversion workflow or else do something like myEntity.TweenTranslation(..).OnComplete() etc
@amber flicker Oooo how did you get timeline working with ECS???
The UI? It's all custom sadly - couldn't sufficiently repurpose either the Timeline or Animation window - it's still a work in progress - turns out bezier curves are easy... weighted bezier curves not so much
No i mean the actual Timeline Data
I would love to use it to mix animations/sounds/effects for my game
it'll be on the asset store eventually .. I hope π - lots of cool features - keyframes can be relative so you can reuse animations across many different projects - they can be nested so you can make and reuse a 'fade' animation everywhere for example. Event system built-in too that uses scriptable objects. It's a bit early to be sharing probably π
yea but how did you get the data compatable with DOTS?
Convert the timeline at runtime into a blob asset of some sort?
sure - it's conceptually pretty simple - an asset that stores the keyframe data which is then used to create the entity with the kind of component data you would expect (start time, duration, start value, end value kind of stuff) - entities can be created at runtime or as part of the subscene conversion process
in my tests entities with e.g. dynamicbuffers of points is faster than using blob assets due to the linear access
it also makes it much better for inspecting - all the data could be hidden away in native arrays but you really don't lose much perf by just exposing it all
yea they need a better way to inspect data
that's coming apparently.. just nobody knows what it looks like or when
everything is comming π
Working on the code-gen UI today - you use this to mark what components you want tweenable (both in the Timeline and via code). Still some work to do but at least it shows you how many times each property is used and where.
Yea kinda essential for a lot of ecs
im using those TT templates
oh good luck π
hand-rolled inefficient stuff
don't they require visual studio?
Theres a pre process mode that turns the Template into a c# class that you can then call from unity (thats what my Scriotable obejct does) to pass in Unity stuff
um i'm using Rider
pretty sure theres a VS Code extention for them
might investigate for a future project but I'm pretty happy with the current solution tbh - totally in my control and plenty fast enough
no external dependencies beyond unity is pretty appealing
for an asset
yea i get that
I want to have a NativeHashMap with NativeArray values, but that doesn't work, so I tried creating native arrays and having the hashmap store the pointers instead, then reconstruct the native array and dispose later, but Unity complains about a memory leak, presumably because it can't track the native array after it's been converted into pointer form. How can I tell it to chill?
@opaque escarp Have you seen MultiNativeHashMap
yeah, but I'd like to be able to performantly access it by abritrary index
its basilcy <KEY,NATIVELIST<VALUE>>
seems like you can only access them sequentially in multihash
yea i have noticed that
There are also these:
I might check that out. Otherwise I guess I could manually allocate
NativeMultiHashMap is nice but you only have Next, you can't access the NativeLists or whatever holds the multiple values for each key
Actually theres GetValueArray
and getValuesForKey
Does that help?
oh no just noticed its still a Enumerator
Anyone looked at building a custom DynamicBuffer?
I'm just interested if its possible
its probably a terrible idea
what would be the usecase of that ?
mainly to have those native collections attached to entities
like that 2d array
but its all sugar and not needed
maybe was overthinking things too
π
just use a method to cnvert 2d index to 1d index 
yup
that's just what NativeArray2D is under the hood
was definitely over thinking
tho be careful with dynamic buffers
until they're above their limit, they will put themselves in the chunks; if you have too big buffers you might make so that very few entities can fit in that chunk
yea so some of my bufferes are HUGE!!!
so if you plan on having big dynamic buffers, put the threshold size of like 8 so that it goes to the heap imediatly
like 1000s of items can build up in them pertty quickly
yea going to set it at like 4
but im still not sure what to do about those big bufferes
its mostly unneeded data so for clients i was thinking ill trim them down to the last 10 or so items
but for the server i actually want to keep that data (its basically replay data) so was thinking to write out old data to files or something
unless this data creates alot of computation on the client, really don't bother
really??
its not like i loop over it all, i generally only need the last 10 - 20 items max, so i loop backwards till i find what i need
but thought leaving it there would be bad practice
I'm not proficient with ecs by any stretch, but I rly feel like this would be pretty late optimization to implement
yea true
ok different question :P
Fog Of War DATA
Better implemented as?
NativeMultiHashMap, with Key = int2 of position (some math to get it) and Value's being the Entities. this is cleared and rebuilt every frame, could also have a static list which is updated once for things that dont move
OR
Entitis with DynamicBuffers<Entity> and a SharedComponentData(the key/position), much less frequently updated as moving things will remove themselfs and readd as they move around
Actually just reading it again makes me think the 2nd option would be better, but maybe combo it with a hashmap to quickly find the entity again (position, fog of war entity)
is it possible to make a temporary list in a system?
im trying like: NativeList<Vector3Int> rawChunks = new NativeList<Vector3Int>();
Or can I only define it as a component, or make a job and define a nativearray externally first
@graceful mason yea you can do that, but you have a few things wrong
need to set a Allocator, probably temp into the contstructor
and i think you should be using int3 instead of vector3int
finally you need to call .Dispose when done with it
ok thanks so much
all good
lol do you know my material question π
material?
1 sec..
worldManager = GameObject.Find("WorldManager").GetComponent<WorldManager>(); entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = mesh, material = worldManager.material });
Argh it wont let me paste
trying to assign 1 material to 1000s of meshes
is that a good way? π
it works, just no idea if its instanced or there all new instances
pretty sure you can keep the RenderMesh and just pass it into the SetShared....
thats my whole func: https://pastebin.com/GcCjpM1X basically each entity has the geom saved in componeents
that wont work in jobs and stuff
Im going to move it into PostUpdateBuffer soon
and that
or maybe run on main thread as it very fast anyway
but the material, isnt crerating 1000s of different instances?
thats something that keeps hanging me up, i keep trying to optimize early
na pretty sure that dosnt copy material
I use 1 material for all game objects, just wanna make sure im only using 1 as got FPS issues LD
you can test it
hit play and spawn all your suffts
then find your material asset
and change something on it that you should be able to see
if it copied noting will change
all good
Does anyone have experience with raycasts in ECS? I have a bunch of detector entities on the ground of my scene and would love to do a ForEach over those, have each detector entity cast a ray straight up, do math with components of any target entities the ray hits, and write the result to a component of the detector entity
But I haven't touched DOTS physics yet, so I'm not sure if it can be that easy
its a bit more annoying
but not by much
Heres the docs
they have examples of everything at the bottom
Hmm
So suppose I have like five of my target entities floating above a given detector entity and they have flat circle-shaped colliders. I suppose I want to take the ray cast code and have that within my foreach or job, but it sounds like that will only return one of those entities, so I would have to monkey around to actually get it to give me all the applicable entities?
Argh I worked out my problem , I was trying to declare my NativeArray in a system like on this page: NativeArray<float> result = new NativeArray<float>(1, Allocator.TempJob);
but it only works if I dont put in the intial size
@timber rivet Theres a overload that will return everything along the ray
ah
So the big thing I'm looking at is CollisionWorld.CastRay and I need to look into the overloads on that
yea that sounds right
And either way this requires a separate component on the targets I want to hit, right, a collider
yup
if your using the authoring flow you can add PhysicsShape to your thing
if your not it looks super hard to construct the colliders
if your not it looks super hard to construct the colliders
You mean programmatically?
yea
I am going to need to figure this out
So that's not as easy as just assigning a mesh like one would do with rendering meshes, then
na bit more invloved
Is it? It's not just ComponentData?
Got a doc somewhere?
Oh, man. That's an amazing sample though
I wonder if the system will yell at me for messing getting another set of entities in a foreach/job because I've had to jump through hoops to do that before. But I only plan to read from the raycast targets so in principle it should be thread safe
Actually the collider looks easyier then i thought
most of that is for the physics body
yeah, gonna say... that doesn't look that magical
maybe it got better π€·ββοΈ
Okay, I should be able to work with this. Thanks a bunch
@timber rivet na it should be fine, if you need components from those entitys use ComponentDataFromEntity
oh yeah
is burst on by default for a systembase.. They seem active for me in the burst inspector
public class ChunkLoaderRequestListSystem : SystemBase{ protected override void OnUpdate() {
one of my systems
It says in one of the menu items at the top
Jobs maybe?
Jobs > Burst > Enable Compilation
As I understand it, Entities.ForEach uses burst by default
yup it does
Guys I am getting a weird error when I am playing (after a while, not at the start).
It says that "The component of type:... has not been added to the entity", but I add the component using an Authoring script and I never remove it (I can check it with the entity debugger)
I only use that component in the queries (with ref or in based on the system)
{
return math.acos(math.dot(v1, v2) / (math.length(v1) * math.length(v2)));
} ```
I don't remember who gave me this function, but sometimes it returns NaN, why?
This function (I gave it to you) require vector with length (because it obvious for angle between vectors)
So if it returns 0 it means that the angle is 0?
@wide fiber yes, just use same vector for both arguments and it should return 0
Because angle between them will be 0
@wide fiber yes, just use same vector for both arguments and it should return 0
@storm ravine Sorry, it wasn't the right question, I've edited it
I want to add a component on each material of a mesh in conversion, and hopefully also link these to a buffer on one of the parents. Anyone know in what stage the child entities are created in the conversion, or any shortcut to make this happen?
@storm ravine Sorry, it wasn't the right question, I've edited it
@wide fiber No. There is no angle, because one of arguments has zero length.
If one of the vectors is zero-length - it's just (0,0,0) point, and which angle you expect between vector and point - 0? 360? 1080? it hasn't any angle.
is it possible to get a position of trigger event ?
Found that you can use GetEntities of a gameobjct to get the entities at least, not sure if best way. But it's one way at least π
.
dots joke @tribal cobalt ? π
Yeah, sorry lol.
if I got unlimited Data to process without any deadline, got any suggestions? I was thinking, loop entities, populating output buffers, until deltaTime hits a threshold.
I guess I may have issues with it clogging other actual imporotant jobs but I can hit that later π
maybe if deltatime thresh is low enough, im ok
I'm having trouble getting the camera to follow the player...
What I did:
-Camera In subscene
-IConvertGameObjectToEntity
-dstManager.AddComponent(entity,typeof(CopyTransformToGameObject)); / CopyTransformFromGameObject
-In a Job(under entities.foreach): cameraTranslation.Value = playerPos; (float3)
yet, the camera isnt updating.. I should mention that the camera entity does update as desired, but the "gameobject" inside the subscene doesnt change
am I missing a step?
@gusty comet I noticed some weird behaviours with camera depending on how I converted it. So what I experienced is that it seems that the Camera component is converted, but doesn't seem to update correctly in world (or in time?) So what I currently do is spawn it with GameObjectConversionUtility, and use the gameObject camera.
Ah nice. I think i'll do that anyway, cause the conversion system seem to hit the performance quite a bit too
hi, is there a way to check live conversion in edit mode is ON via code
Has anyone ever used particles in Unity DOTS?
Has anyone here tested the performance of NativeMultiHashMaps? I know I've talked about this before but I havn't really solved much of my previous issue (if there even is one, which is why I'm asking this)
Hello, i'm writing a terrain LOD rendering system and making it composed of structs to make use of the job system. I'm finalizing the logic and looking at ways to optimize the algorithm, which needs quite a lot of optimization as right now it's currently taking 1ms per terrain and i expect ~64 terrains to potentially be active at any one time. The system initializes ~90% of the data used in the tree once and then needs to recalculate the rest every frame.
I'm using a quadtree which is made out of nodes where the nodes store data like neighboring node indexes, depth, aabb, etc. At first i found using an array of nodes inside the tree as a convenient way to keep logic related to the tree inside the tree and logic related to the nodes in the node struct. However, after moving to a NativeArray i noticed that in order to override an index of the array you can't just do stuff like "array[0].depth = 0", instead a whole new struct needs to be given to it. The node struct which I've been using is pretty huge, more than 150 bytes in size. The copying of a 150+ byte node has pretty high cost, which is why I've decided to split the parts of the node struct which need updating per frame into different NativeArrays inside the tree. This improved the performance by a lot as now I'm only updating the necessary data without any overhead from the whole struct by doing "depth[0] = 0".
Having said that, now i feel as if i'm bleeding half the logic which should belong to the node into the tree. Is splitting up a struct in this fashion the way to go or am i perhaps missing something?
LocalToWorld.Position is the global position while Translation.Value is the local one?
if your entity has parent than Translation is in parent space
and LocalToWorld is always in world spaceπ€
Is there a way to see what is taking the most time in a Job?
if your entity has parent than Translation is in parent space
@warped trail ok..
I am making a raycast and I am getting some inaccurate results and I can't understand the problem.. I will send the code if I can't solve it
also.. I still have to optimize my noise generation. Since a lot of you say that generating a 200x200 noise map in 0.20ms is slow. Though I don't really know any way to make it faster
Yeah it uses burst, don't know what you mean by seq
I got a weird bug where when I load a new scene with entities that get created with ConvertToEntity, previously destroyed entities' number and version gets reused. I check with EntityManager if an entity still exists and it returns true, and the entity it references is completely different from the one I checked originally. Anybody knows how that can happen?
@odd cipher sequencial, aka you're writing to your array inder after index and not out of order
I am confused what you mean by "inder" and it is a IJobParallelFor
I'm having problem with Burst where it throws error like that for a simple job.
[BurstCompile]
public struct AssignVoxelJob : IJobParallelFor
{
public NativeArray<byte> voxelArray;
public void Execute(int index)
{
if (index > (32*32*32)/2)
voxelArray[index] = 1;
else
voxelArray[index] = 2;
}
}```
I'd wager you're not ever assigning voxelArray
I did assign the array
NativeArray<byte> voxelArray = new NativeArray<byte>(32 * 32 * 32, Allocator.TempJob);
AssignVoxelJob assignVoxelJob = new AssignVoxelJob
{
voxelArray = voxelArray,
};```
do you get the same error when disabling burst?
The error only appears in Burst inspector, the job itself works fine.
Is there a way to store the equivalent of a NativeMultiHashMap on a component? DynamicBuffer is more like an array it seems
I guess I could store the map keys and values in a dynamicbuffer and then construct it back into a NativeMultiHashMap in the systems its required. But that doesnt sound too performant
I've never seen errors in the burst inspector myself, always relied on the console
I think you could get away with storing a pointer to the NativeMultiHashMap maybe
What's the hotness for creating primitive meshes (cube/sphere/etc) in DOTS?
ok different question :P
Fog Of War DATA
Better implemented as?
NativeMultiHashMap, with Key = int2 of position (some math to get it) and Value's being the Entities. this is cleared and rebuilt every frame, could also have a static list which is updated once for things that dont move
OR
Entitis with DynamicBuffers<Entity> and a SharedComponentData(the key/position), much less frequently updated as moving things will remove themselfs and readd as they move around
@ocean tundra I'm currently trying to solve the exact same problem π . If each SharedComponent with unique data is a separate chunk, if your world has a lot of positions wont it add a ridiculous number of chunks? I dont know if that will have an impact on the rest of the system or not
shared components for this are a really bad idea
have a single dynamic buffer where 1 index = 1 grid coordinate and inside the struct you put the state of the fog of war for this tile
and convert a 2d index to a 1d index to access the elements of the buffer
@zinc plinth What would you recommend if you want to store the entities in each tile? Should I just use a nativemultihashmap? or is there some way to store this data in a dynamic buffer or something
you don't "store entities"
if you want to know the coordinates of an entity that is "placed" on the grid, just add a component to it with it's coordinates and size
you can't think of some entity "owning" other entity in ecs
if I want to know the entities close to others doesnt it makes sense to pre sort them into a quadrant/tile system and then just check the current and adjacent tiles?
instead of checking every entity with a position component
in a world of reference types that would make sense
but you can't really do that in ecs, not while keeping each entity a strict task
but I use a lil workaround for that
I have multiple stuff that need a value for every tile of my grid, so I added buffers to my grid entities containing those values
I still have grid element entities, but for values that are more part of a grid state more than a grid element (even if the value is a result of a grid element being there) I put in in a buffer in the grid
but then you have to be careful to update your states properly
with this you still can't just "get the neighbor grid elements", but for my cases it solved my problems
I mean you can by looping over the grid elements of one grid, but ya
but isnt that what theyre doing in the boids example unity provides?
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/Advanced/Boids/Scripts/BoidSystem.cs
// Populates a hash map, where each bucket contains the indices of all Boids whose positions quantize
// to the same value for a given cell radius so that the information can be randomly accessed by
// the `MergeCells` and `Steer` jobs.
// This is useful in terms of the algorithm because it limits the number of comparisons that will
// actually occur between the different boids. Instead of for each boid, searching through all
// boids for those within a certain radius, this limits those by the hash-to-bucket simplification.
var parallelHashMap = hashMap.AsParallelWriter();
var hashPositionsJobHandle = Entities
.WithName("HashPositionsJob")
.WithAll<Boid>()
.ForEach((int entityInQueryIndex, in LocalToWorld localToWorld) =>
{
var hash = (int)math.hash(new int3(math.floor(localToWorld.Position / settings.CellRadius)));
parallelHashMap.Add(hash, entityInQueryIndex);
})
.ScheduleParallel(Dependency);
@leaden hatch from what I understand from it, with this you build a hashmap each time
ofc if you preprocess stuff you can get your multihashmap; but my solution didn't involve preprocessing
Your way actually makes sense too, thanks, I'll have to think about it
I'm having problem with Burst where it throws error like that for a simple job.
@obsidian halo it's not an error in your code. It is cached error message and stack trace in case if this job write check fails and burst will need to throw it, as burst itself doesn't support throwing regular exceptions.
in a world of reference types that would make sense
but you can't really do that in ecs, not while keeping each entity a strict task
@zinc plinth You can. And moreover - you should. Spatial portioning (quad\octrees, simple spatial hash map, BVH tree etc) it's an exact case where you literally should store entities (or any other your type\indexer) for search\checks for performant and fast iterations on a scale. Space portioning absolutely not depend on reference\value types, OOP\DOD, it suitable and recommended for both approaches on performance-sensitive iterations, big scale. Simple example - physics, it's just can't work performant without that, this is why under hood, physics use this (BVH as one part of it). In our game we use spatial portioning for our own physics, for gameplay logic - closes enemy, closest resource, count in range etc. moreover we have more than one level of portioning. And of course, you shouldn't update it in a naive way every frame, you should use state change strategies (like state component, change filter, change order version etc.)
@storm ravine So many good ideas, im just starting combat now and have realised i need to find other units around me π sounds so simple but to support crazy numbers need to get real cleaver
So you find and cache closet enemy?
How do you know when it changes? wont you have to do a distance check every frame?
Except for your other point, you could update only when some other level of positioning changes
How do you know when it changes? wont you have to do a distance check every frame?
@ocean tundra
you should use state change strategies (like state component, change filter, change order version etc.)
@storm ravine how do get around ref triggering the change number thing?
chunk iteration
like i would like to have a condition first so not you update it
change filter
oh i haven't really started with that yet
Change filter, filters chunks by type version in archetype, and wouldn't run your ForEach (not missing with running system itself, because it ignore filtering) if setted as filter component version for archetype for chunk wasn't changed. And If it changed it will process only entities in changed chunks.
Moreover for building spatial maps (any of type) you don't need ref only in and other systems which can change these types should use filtering, early out's, chunk iteration, CDFE with the conditional setter. For the new concept of IJobEntity (and Entities.ForEach) I requested, some code analysis processing for them, for check if you really change ref types in current code path and only in this case bump version, they noted that, and I hope this will be implemented soon.
wait so your saying if eventually, if i dont change the value of the ref parameter it wont change the version?
That's the plan. But when it will (if will) not known yet.
sweet thats awesome
In which update group should I put my system that performs a raycast to check it after the physics update? I think I am making a raycast but in the world that is 1 frame old
@ocean tundra Just wanted to emphasize change checks are per chunk - v useful but important to understand it's not per entity
In which update group should I put my system that performs a raycast to check it after the physics update? I think I am making a raycast but in the world that is 1 frame old
I have put [UpdateAfter(typeof(EndFramePhysicsSystem)] but it still perform the raycast in the 1 frame old world
I put UpdateAfter BuildPhysicsWorld, im not sure if that is right
does anyone know if they are planning to add vfx to the dots stack?
Does anyone know if there're ways to return NativeArray indexes by ref rather than by value?
does anyone know if they are planning to add vfx to the dots stack?
I am also interested in VFX with dots
I'm going to go and assume they mean that with DOTS as it's on dots subforum
Hi my friend and I are doing minecraft with ECS as a learning project, and we wanted to get the new Unity and ECS update yesterday however after the update our blocs became invisible 
here are the components of our blocs
private static readonly EntityArchetype _archetype = _entityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(LocalToWorld),
typeof(PhysicsCollider),
typeof(RenderMesh)
);```
is this perhaps a known issue with the update that we can fix ?
ah turns out the solution was to add the renderbounds component
What is worse, random read or random write? π§
writes are read + write
unless some very specific instructions are used (not the case)
so actually random write is worse
unless the random read has a pipeline dependency (like being decision on a branch, or a pointer to other stuff), where latency is an issue
Can Burst be disabled for builds?
Never mind, found the option to disable it under "Burst AOT settings"
@mighty whale Is your project pure DOTS or hybrid DOTS? Pure as in absolutely no references to UnityEngine and using the DOTS Runtime
If it's hybrid, then you might want to use the authoring workflow instead of making your objects in code. It will make it quite a bit easier to make objects in the future.
A rocket in my game has a Gameobject with a particle system as a child. How can I convert the rocket to an entity without converting the child? (The particle system doesn't work on entities)
A custom IConvertGameObjectToEntity should be able to do it?
As part of Convert(), you most likely need to detach the child or something like that.
.
A custom
IConvertGameObjectToEntityshould be able to do it?
@tawdry tree isn't there a component that already does that? ConvertToEntity...
IConvertGameObjectToEntity lets you cusotmize how it converts the gameobject to an entity. that will let you, you know, customize the conversion
The GameObject (the child, particle system) needs to follow the rocket entity and needs to be destroyed when the rocket is destroyed (I am using a linked entity group), I thought there was an easier way
Not familiar with linked entity groups, and haven't really worked with gameobjects and entities interacting
@tawdry tree isn't there a component that already does that? ConvertToEntity...
Because if I try to use a normal GameObject with a particle system and Convert and Inject it works fine, but if I make it a prefab and I spawn the prefab in a system it doesn't work
Companion workflow exact for that purpose
@mighty whale Is your project pure DOTS or hybrid DOTS? Pure as in absolutely no references to UnityEngine and using the DOTS Runtime
If it's hybrid, then you might want to use the authoring workflow instead of making your objects in code. It will make it quite a bit easier to make objects in the future.
@bright sentinel conversion workflow is pure DOTS. Making entities through conversion doesnβt make it hybrid, itβs authoring, which at runtime - pure. Hybrid is when you using GO as runtime core with convert and inject, or manual syncing parts.
@storm ravine I disagree, I'd say
- Pure DOTS is using the DOTS Runtime (currently only Tiny).
- Hybrid is using mostly DOTS, but still needing to inject gameobjects such as lights, cameras, UI that are still not possible, with the authoring conversion workflow. That's the way most people use DOTS/ECS right now
- Unity GameObjects using jobs/ECS for specific parts. This doesn't have a name for me.
Again. Companion workflow - authoring for things not yet properly implemented. And itsβs pure. Authoring workflow is intended pure. Using some things as helpers GO doesnβt make it hybrid. Build logic on GO/MB and DOTS parts as helpers - hybrid.
Then why do you have to use the hybrid renderer for "pure" DOTS?
(Of course you don't have to, but there's no pure renderer - except for DOTS runtime)
Then why do Tiny use Unity.Tiny.Hybrid and Hybrid input if it pure? π
This is why I started discussion, to show βpoint of view differenceβ π I doesnβt think personally, something here is pure or hybrid. I ended that separation long time ago. I just think about it as DOTS without any separation π
pure dots was probably that one guy that bolted raylib onto tiny
rendering his own render entities directly
0 gameobjects
But I like arguing sometimes for showing that not all that simple and white/blackπ hope I didn't offend you @bright sentinel π What about you @digital scarab, you can wait a bit, you destroyed my shiny plan, I prepared arguments/counter arguments which will show meaning difference in the end, but you destroyed that planπ’hate you (joke)
:blobsmilesweat2: I just wanted to make a joke about Joe being prayed to
@digital scarab and other guys from DOTS with I spoke about thatπ€£ From 2017 Unity become secret cultists praying about truth of pure or hybrid DOTS, even before It started call DOTS

this is true, in fact DOTS was not a name we came up with, but was brought down from a mountain top having been etched in stone to be shared with the common folk
@digital scarab amen
@storm ravine Tiny use Unity.Tiny.Hybrid so it will work in editor?π€
Itβs namespace for HybridInput
Hybrid input won't work in dots runtime cause there is gameobjects in there, so it is kinda editor only thingπ
Yo, I explored DOTS a bit a while back. I remember it being quite feature incomplete ~6 months ago. Have been any "usability breakthroughs" done in that frame period? Or is it still a tool you only bring out when you need MAX POWAH?
Now that the new "platforms" build system is required, does anyone know when the plan is to stabilize the API for that?
can someone explain to me how ISharedComponentData work or how do I get the data between 2 entities to share the same data?
let's say I attached a sharedcomponent with an integer as it's data on 2 entities (let's call it E1 and E2).
On E1, I set the integer to 555.
but when I check at the debugger for E2's integer, it remained at 0.
am I fundamentally misunderstanding something how ISharedComponentData work?
I split a job into 5x different jobs as it takes a while, hoping to run them over 5 frames, anyone got any tips? I was trying to just add a componenent for each stage, so each system know what to process. But I think its running all 5 jobs in 1 frame. How to stop, do I just manually specify a reverse depdndancy chain? (e.g first job, depnds on second, depends on third)?
A shared Component Data isn't "shared" between entities that have it
Its that entities with the same data in the "component" will share 1 instance
So 3 entities with "SharedMeshComponent" where 2 have a mesh A and 1 has a mesh B
results in 2 groups
so shared compnenet data is just all about chunks and performance, nothing functional?
Its about filtering entities on data
Without them, you can query for all entities with "Mesh"
but you cant query for entities where "Mesh == A"
Oh I see, so it actually, splits your data into many more chunks?
Aaaaaaaah.
It's not sharing but more like grouping
Yeah, same archetype, but a group of chunks per variation of the shared component
ahaha I thought it was opposite π
I try to avoid them, because they have an arbitrary limit of 8 per archetype
And I've found they are almost never the right design choice
I see, Ill have to think what I use them for. I thought storing my material in there would help with GPU instancing or something π
It would
Rendering can be batched if you render things with the same "parts" in sequence
Oversimplifying it a bit, but still
every object for me has unique mesh, shared material.
So I think they may get split into unique chunks
and it probably worse?
so its a unique value for everything
entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = unique_mesh, material = worldManager.material })
(I got the 0 batches in stats)
Companion workflow exact for that purpose
@storm ravine are you talking with me?
https://pastebin.com/K6MFLWi0
I've added this component to my GameObject with the particle system but it gives me some errors
So there's no way to use particles in unity ECS?
But the problem is the prefab, because if the GameObject that has the particle system isn't a prefab and I put on it Convert and Inject it works perfectly
@storm ravine are you talking with me?
https://pastebin.com/K6MFLWi0
I've added this component to my GameObject with the particle system but it gives me some errors
@wide fiber exception not about conversion, but about command buffer
Hybrid supports a very specific set of internal components for use by the hybrid renderer. Right now it cannot support generally anything from classic Unity, such as particle systems.
@digital scarab but companion object doesnβt require hybrid renderer at all, it using classic hidden GO
Yep thatβs true, but it works fine as temporary solution
We using that for camera, particles, post processing layers/volumes, audio
(Built-in renderer)
Yes. Same you can see in 5argons blog, Iβll find link for you
Companion Object section, exact sample for particles
And again how it relates to HR if they completely separate. Even your own tests use just any MB.
Under hood it not relates to this at all π it's simply list oh hidden object with indicies for synch (simplified) π
looks like when we did that, we forgot to add the renderer :blobneutral:
@digital scarab seems so π
Afaik Fabrice making all that hybrid thing
Yep I know we speaking with him often, include Hybrid components topic π He is one of Unity guys to which I met in person π
Hahaha yeah
When he came to Russia we often compare how similar French and Russian words
Yep hybrid components still buggy, bud what I heard and tested it's fine for most cases with convert to entity, and most part of bugs from subscenes workflow
have you met Valentin and Anton as well?
@digital scarab yep, of course, we chat with Val every day π And with Elena from time to time π Also I know two Ilya's (one working in Helsinki (he worked in Rovio), last time he brought me nice liqueur π , and the second one always with funny green\pink hair :)forgot his second name, but I'm sure you know whom I mean) With Anton (if you speak about Anton Kruglyakov from DOTS team) we don't met in person but by email when we discussing with Unity about access to our game repo and Unity can look at our code, and how we utilise DOTS π I also know more foreign guys (I mean not Russian) in person from different Unity teams, and whole more by direct chatting or video calls π
Slack?
Including slack channels (like ext-dots, ext-hybrid-renderer)
@wide fiber exception not about conversion, but about command buffer
@storm ravine it gives me the errors only if I add that component to the entity
@storm ravine Not offended at all, just busy with exams π I think the real problem is that there is no official stance on it and the concepts are a bit muddied. I think we're mostly speaking about terms here, and we're both very aware of the differences.
Yep is exact what I meant (and Topher spoilers) - even Unity don't know where edge and what is Hybrid and what is Pure (yet) π
And second special for you @wide fiber π
Well then I know about him a bit π Sometimes I feel ΡΠ½ΡΡΠ΄Π° like I'm working in Unity, especially when spent a couple of hours per days with you guys fixing or reproducing some bugs in DOTS. But it's pretty funny, and helps both sides - Unity fix hidden tricky bugs, us - fix project and continue work without workarounds π
Earth small, you always know someone who know someone
Ty I'll check the videos later :D
How do you check if an entity has a component within a system? It's not the entity that I'm currently iterating over, either.
@digital scarab Np, glad to help, it will help many newcomers and studios who want to try DOTS π this sort of bridge will simplify their life
How do you check if an entity has a component within a system? It's not the entity that I'm currently iterating over, either.
@verbal pewter if it on main thread - EntityManager. If it on main thread - ComponentDataFormEntity. And if you inside SystemBase then you have helpers wrapped around things above - HasComponent, AddComponent, GetComponent
@storm ravine Yeah, it's inside SystemBase. Hmmmm, it seems like I'm able to call HasComponent within the OnUpdate call, but I'm not able to call it from a static method that belongs to the SystemBase class.
Yes
Are we meant to use EntityManager outside of OnUpdate?
Use EM (for main thread) or ComponentDataFromEntity which passed as argument to static method
Are we meant to use
EntityManageroutside ofOnUpdate?
@verbal pewter of course, you can use it anywhere on main thread
Just remember about Synch Points
I'll be honest, I'm not super familiar with them. My understanding is that they represent points where the program has to wait to ensure all threads are caught up to proceed, so that it can guarantee that specific data isn't going to be changed in the middle of being used. Is that right?
yes
So I have implemented a simple raycast in an Entities.ForEach where I do a raycast for each of my detector entities that I am looping over, find the closest target entity, get component data, and write to the detector entity's components. I'd like to have it return all entities the raycast hits, though, not just the closest, and when using the overload for that Unity gives me a lot of errors that look something like this:
InvalidOperationException: The previously scheduled job DetectorSystem:<>c__DisplayClass_OnUpdate_LambdaJob0 writes to the NativeArray <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.collisionWorld.Broadphase.m_StaticTree.Nodes. You must call JobHandle.Complete() on the job DetectorSystem:<>c__DisplayClass_OnUpdate_LambdaJob0, before you can read from the NativeArray safely.
So it sounds like collisionWorld.CastRay(input, ref allHits) is actually writing to something in CollisionWorld and for obvious reasons ECS doesn't like that. Is there any possible workaround to that so I could use that overload in parallel?
how do I approach a grid-based movement in ECS?
I have 2 ideas but I dunno which is best
is it 1.) make every cell it's own entity with it's own coordinates component?
or 2.) do I make a "grid manager" entity with a dynamic buffer component?
Hello, does anyone know how to lay out data of a NativeHashmap to make "NativeHashmap<key, NativeArray<>>" viable as a concept? I'm currently doing "NativeHashmap<Vector3Int, struct>" where the struct has multiple NativeArrays inside it, which makes it unusable in a job due to NativeContainer not allowed in a NativeContainer problem. Once in a job, the structs will need to access the NativeHashmap again to check for neighbouring structs of same type.
question: is indirect lighting still not supported for HDRP in the hybrid renderer?
@storm ravine It still doesn't work, it gives me the same error (I am using prefabs)
https://pastebin.com/E0ZnTvuG
The problem exists only when I try to Instantiate the prefab in a system (with an ECB), not when I use it normally
If I comment one of the 2 lines (10, 11) it doesn't give me any error but it doesn't work...
It like a bug in PatchEntities
When instantiating prefabs. Yeah it form ManagedChangesTracker.PatchEntitiesForPrefab where CommandBuffer fills commands queue where one of them PatchManagedEntitiesForPrefabs
Pointed Fabrice to this
What is the right way to handle 3d object - mouse interactions using dots?
is Collision queries from unity.physics is a way to go?
Whats muse?
mouse
Mouse obviously
wayy to early for me to figure that out :P, I use the Unity.Phyics for my mouse picking, i just do a raycast on mouse click
and for click and drag i create a frustum and test against that
is there any up to date example for raycasts using dots?
thanks
Well I showed simple example for mouse sphere interaction , year or 1.5 years ago, but yeah it's raycasting in general (I showed simple custom raycast, not from physics)
If you using physics already - use raycast, because it has optimised BVH for checks. If you not using physics, well I suggest choose between (again) physics or your own simplified solution. Because we not always require whole physics for such simple thing.
before i had mouse interactions only with 2d grid on the fixed plane, so i've made my own simple reaycast function, but now i need to interact with 3d objects above that plane, so looking for right way to do it, i don't use physics
so looks like now i need physics just for collision queries
yup thats what I use it for
got it working, thanks
hey! could anyone help me understand the difference between Schedule() and Run() for an ECS foreach loop?
i believe in JobComponentSystem, Schedule ran jobs as parallel(as opposed to ScheduleSingle which ran a job on one worker), using systembase now requires you to use ScheduleParallel, and Run is just running the job on the main thread immediately
aha! Ok, thanks
Anyone used Unity.Physics Triggers?
I have created a trigger collider and added it to my main entity all via code and i think im still missing something
I cant get any trigger events to fire
what does your code look like
I probably have a issue with all my entitys being static as i dont want the physics system to move my things
you have static entities trying to (trigger)collide with other static entities?
yea that sounds weird
if you're moving them with code instead of physics should make them kinematic
hmmm
i basicly just want physics for the collision query's
i might just not use triggers
instead just use collider distance checks
whats the way to make a kenimatic physics entity?
should check if kinematic/static actually is the issue, i imagine if it's marked static it might not update its position on physics side at all but not sure
yea was just going to test that
you mean from code not authoring?
yup
just add a PhysicsVelocity?
oh wow i thought physics would completly take over
yea seems to be just velocity
yea
physicsbody conversion seems to be adding a physicsmass and gravity as well with inverses and gravity set to 0
i thought my objects would all fall over
dunno if that's needed
but yea kinematic is basically don't simulate physics on this object but still include it in queries
π
It like a bug in PatchEntities
@storm ravine so it is a bug, for now there is no way to get around it?
Do you guys know how to make a buff system in ECS?
public class BuffSystem : SystemBase
lol
π
But you all know...technically... 
is there anyway to not show strings in the entity debugger?
cant debug my enteties as I polluted them all with strings
Dumb question that probably relates to a fundamental misconception somewhere.... I am doing a "hello world" project with DOTS & Tiny that just has 1 entity that is a spinning sprite on screen. I access that entity via
var logoEntity = GetSingletonEntity<Logo>();
... and hitting play in editor, that works exactly right. It spins. Great. Hello, World! But... if I build to wasm and run in browser, I get this error:
The exception message is: GetSingletonEntity() requires that exactly one exists but there are 0.
So what gives? Why is it even possible that this line runs in Editor but not in the build? What detail am I overlooking? Do I have to explicitly register my singleton and there's a race condition or something?
hey! any resources for dots fast-forward/rewind?
@burnt depot are you sure you don't get that error in the debugger when running in editor, you normally get one warning at beginning when using getsingleton because systems exist before entity's and so there is no entity at the start
i do not get any warning or error in editor (while running)
well anyway I usually use HasSingleton to check first if there is a singleton
@burnt depot How are you building? First off, I have no idea whether web is supported yet for DOTS/Tiny unless doing some custom stuff. It may be that it is though, but I have no idea. Secondly, you probably need to use the build configurations rather than just "build and run"
i am using the build configuration, yes -- used project tiny samples for reference. I have built several of those to wasm and deployed them runnably successfully
Alright, that seems right, just wanted to confirm it. How are you creating the cube?
short circuiting the system with HasSingleton seems to work in editor and in build now. I'm going to squint at that for the moment as something-something-cache-something π
instead of using hassingleton you can use RequireSingletonforupdate as well, depending on your use case
it took me approximately 2 hours to write and deploy a spinning sprite that changes color that runs on my phone (browser). It's like learning how to program all over again. I am enjoying my confusion π
to test the material property stuff I'm trying to link my entities' material properties to the color, but it doesnt seem to be changing
I've got my component set up like
[MaterialProperty("_ColorTest", MaterialPropertyFormat.Float3)]
public struct SPHVelocity : IComponentData
{
public float3 Value;
}
And my shader just takes the normalised float3 value as the color. But ingame its permanently the default color. Not sure why when the velocity is definitely changing
o when did they add a material property attribute?
o it's part of the hybrid renderer
ah that's why i didn't know abt it- haven't used it yet haha
it says in the docs to enable hybrid isntanced on the custom property, but I dont have that option. Not sure why. I'm using URP template
and I'm on 2020.1.0b8 which is past what they require
oh it seems you cant do vector3's only vector4. aww
they allow vector 1 and 4 but not 2/3 D:
Got it working in the end. Cool feature, gonna use it for controlling vertex animations
@storm ravine so it is a bug, for now there is no way to get around it?
@wide fiber Well, Fabrice answered that he is 90% sure that it's fixed internally (not released yet) but he want double-check that. Anyway it's bug and it already fixed (90%) and, possibly, will be in next release
Ok ty
@coarse turtle its pretty recent, you could do it in HR v1 with significant hacks, then they put it in proper for v2 so its like 1 month old-ish.
good to know π
Hello, long time now see. There is something with the profiling that is driving me crazy, who's up for some fun stuff regarding mono CLR and maybe IL2CPP too? It may be DOTS related because it's about iterating an array of 1M elements (without using BURST)
any idea if text is supported in project tiny? ... I see there used to be a Unity.Tiny.Text package/components in much older versions (~0.13) but I do not see these in later versions (~0.22). Did this get dropped perhaps?
and suspiciously see text in the samples as being baked into sprites
Need help with NativeSlice anyone have experience with it and a couple of minutes to explain something
Everyone. What the question?
documentation refrences things like ToArray() and such, but VS2019 doesn't show that as a method etc (and most of the othe things the docs sy)
It converts it to T[] which mean it's not for jobs, but you can use it on main thread
And it's here
DOH
.Value gives you ToArray
I want to copy out the positions from the DPC from arfoundation for my own manipulation
show where you set positions from point cloud list
Its supplied by the event from the ARPointCloudManager
I asked where exact slice set, from where that event was thrown π
Or it's from engine side? Which type of these positions exact? Same nullable slice?
From a Unity3d ARPointCloudManager Unity component (engine)
public event Action<ARPointCloudChangedEventArgs> pointCloudsChanged;
public struct ARPointCloudChangedEventArgs : IEquatable<ARPointCloudChangedEventArgs>
{
public List<ARPointCloud> added {
get;
private set;
}
public List<ARPointCloud> updated {
get;
private set;
}
public List<ARPointCloud> removed {
get;
private set;
}
Which type of these
positionsexact? Same nullable slice?
Hover mouse to positions in VS
hopefully I'm back on track now you pointed the nullable out, can't believe I didn't see it.
So very few examples of this code in the wild to verify against!
Well in this case you should use slice?.ToArray(); which will return null if slice null or T[] if not null
Anyone else witnessing TONS of draw-calls for shadows using the Hybrid Renderer?
Am I doing something obviously wrong?
Can you even do NativeSlice<Vector3>?
(this is if I draw 10000 cubes, btw)
Shouldn't you use float3?
protected override void OnCreate()
{
ecbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
GameObject go = Resources.Load<GameObject>("3DObjects/RedCube");
if (!go)
{
UnityEngine.Debug.LogError("Couldn't load RedCube prefab, bailing!");
return;
}
redCube = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, GameObjectConversionSettings.FromWorld(World, assetStore));
}
protected override void OnUpdate()
{
var ecb = ecbSystem.CreateCommandBuffer();
Entities.ForEach((Entity entity, ref PWCmdRpcCommand command) =>
{
Console.WriteLine($"Server got PWCmd: {command.command}");
float3 position = new float3(1.0f, 1.0f, 1.0f);
using (NativeArray<Entity> entities = new NativeArray<Entity>(10000, Allocator.Persistent))
{
EntityManager.Instantiate(redCube, entities);
for (int i = 0; i < 100; i++)
{
position.x += 2.0f;
for (int j = 0; j < 10; j++)
{
for (int k = 0; k < 10; k++)
{
Translation pos = new Translation();
pos.Value.x = position.x + i * 2.0f;
pos.Value.y = position.y + j * 2.0f;
pos.Value.z = position.z + k * 2.0f;
var ent = entities[(i * 100) + (j * 10) + k];
ecb.SetComponent(ent, pos);
}
}
}
}
PostUpdateCommands.DestroyEntity(entity);
});
}
Oooh, sorry for the spam
Thought it would end up in a smaller window
Set GPU Instancing on material.
So I'm moving some common code to a static class so i have a bit of reuse. Is there any point to marking the input parameters as 'in'? and should I worry about using a return or have a 'ref' parameter?
Finally is that AggressiveInlining attribute worth it?
How do people do profiling of netcode? Bytes/sec that sort of thing?
@bright sentinel Thanks!
@bright sentinel I can make my network suck there, don't see a way to measure?
suck?
@bright sentinel Okay... I'm now able to see bytes serialized on a frame by frame basis... but I'm not seeing in/out bytes sent after delta compression
So here is a question as I've not used it before
If I use the "Conver to Entity" script on a prefab that has no scripts but is just a bunch of gameobjects put together to look like a model
And then choose "Convert and Inject" rather than "Destroy"
How do I reference the resulting entity that is injected?
@tardy locust Tag it with a unique component so you can find it in queries?
Alright. I don't know how they expect you to work with it so if that's how to do it I can do that
I could DEFINITELY be wrong
but based on how everything seems to work
that seems to be the expectation
Okay
@tardy locust Even down to like, state-machine style behavior where you remove one tag comp. and add another to indicate a state transition
Oh
What about Instantiating prefabs?
Lets say I wanted to make 50,000 of those Bees
I can do that fairly easy by spawning a bunch of mesh renderers with Entities
But they don't look like my lil' bee
I just want to check, an IJob can run indendantly of the game loop, potnetailly for 5-10 seconds?
@tardy locust Like, the meshes are distorted or something?
@tardy locust There's a routine for converting the heirarchy
How do?
GameObject go = Resources.Load<GameObject>("3DObjects/RedCube");
if (!go)
{
UnityEngine.Debug.LogError("Couldn't load RedCube prefab, bailing!");
return;
}
redCube = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, GameObjectConversionSettings.FromWorld(World, assetStore));
I'm doing that
Where assetStore is a BlobAssetStore I'm allocating and then Disposing in OnDestroy()
Now redCube is an entity that I can instantiate
So RedCube is a prefab?
Yeah, "3DObjects/RedCube" is a regular prefab, basically
(I have a ghostauthoringcomponent on it for multiplayer)
(note that it has to be in a Resources directory for the Resources.Load to work)
I'm just making a little sandbox thing. I'm not doing MP right now
Yeah, you don't need that component then
@tardy locust If you want more code than that, I pasted a bigger hunk further back
I wonder if the routine fuses the meshes or ?
cuz if not that seems to be really ineficient vs creating a single mesh with everything in it
I don't think it changes meshes at all? Are you talking about the ConvertGameObjectHeirarchy I posted above?
ya
I don't think so. Just makes components out of the bits of data that have Convert() overrides, I assume
(ie., they implement that IConvertableToEntity thing or whatever)
yea..
There's a way to merge meshes, though, I think? Could be done here at load-time fairly cheaply, I would think?
Well given that it's supposed to happen before the game starts
The time is something you can ignore, mostly.
I'm loading my objects dynamically here
You can probably do better than this if you anticipate being able to bake merged meshes at build time or something
Any reason you wouldn't load at least the prefabs ahead of time to make archetypes of them?
What does the Conversion return to you?
And I needed my objects loaded dynamically anyway
An entity
Entity
(with all of its sub-entities converted, too, if they can be, presumably)
(And components converted from old-style to ECS friendly, for those that support it)
So all the components you get from the conversion and the entity
Could be put in an archetype
right?
Sure, but as you add components, your stuff is likely being moved anyway
You end up w/ archetype chunking whether you want it or not, afaict
But you talked about loading prefabs dynamically, not about switching out components right?
The code I gave you loads a GameObject prefab and converts it to entities. GameObjects have non-ECS components that need conversion
right?
I suppose so, yes. But are they not converted at the same time?
PS i recommend using Addressables instead of resources π
@ocean tundra I do wanna learn about those
@ocean tundra Also: really hard to find ECS-friendly examples of Addressables in use
i use them, dont really have any good examples tho
@ocean tundra For example, all the Addressables stuff is async, right? How do I load that stuff in OnCreate?
i just do addressables.load and then pass the result into the gameobject convertion utility
Can my OnCreate be an IEnumable ?
oh yea it is, i have all my load stuff in a normal monobehaviour
Ah, ok
as i dont use the autocreated worlds
Autocreated worlds?
I assumed DefaultWorld was just legacy Unity (GameObject) style data anyway?
and i dont have them updating automaticly, i call world.Update on them
yea
So no SystemGroups?
its cause i wanted my server world to update in fixed update
Aren't you losing out on some free coordination?
i still have those
i still create and setup the world the same, but its not auto updating
hum
Wish I could look at your code; having a hard time wrapping my head around that
What's the purpose of that structure?
Hm, ok... and you're using ENet-CSharp, right, not NetCode?
i also wanted full control of the loop, so i can break out bits, for example i have a bit of server code that runs in the update AFTER fixed update π
yea all enet
i may use netcode
but theres like only a small part of it i would want
Which part is that?
Jobs + reliable messages
any of the replication/prediction stuff will get in the way of my stuff
Wait, does ENet not have an unreliable layer, then?
Right....
NetCode's replication tech seems pretty tidy, but the prediction is, so far, not my favorite. I probably haven't wrapped my head around the whole thing yet
so for some world creation code:
var world = new World("Server");
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, false);
that will create a world that match the default ones, (all systems and groups and stuff)
sorry with this bit too
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, filteredSystems.ToArray());
between those i do some of my own stuff, like netcode does with the UpdateInWorld attribute
ok....
then to update the world just call world.Update
the biggest issue is the DOTS inspector, it wont show me the systems for the world π¦
but I've reported it, and its on the to fix list
to make it worse i plan to have many server worlds, (maybe many client worlds too??) so parts of my game can be completely separate
PM me if you want any more details
is an entity version updated only in ECBS, or as soon as you get the command in the ECB ?
I would guess there would be concurrency issues if it's in the ECB, but I'd prefer to be sure ^^'
?? More details?
The entity version never changes, unless you destory then recreate
context: filling a dynamic buffer with entities, and making sure that those entities don't sudenly refer to nothing
and isn't it the version that changes when you make structural changes (add/remove components) ?
but I'll make my question more broad: does an entity change(id or version) outside of ECBS
so I don't have to keep track of components getting added/removed when storing Entity structs ? :O
well that will be wayyyy easier than I thought then 
GameObject go = Resources.Load<GameObject>("3DObjects/RedCube"); if (!go) { UnityEngine.Debug.LogError("Couldn't load RedCube prefab, bailing!"); return; } redCube = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, GameObjectConversionSettings.FromWorld(World, assetStore));
@sand prawn bad practice. In this case you create and destroy conversion world for every call, very ineffective π
instead of having a network id im currently using the server Entity
@storm ravine is the bad part creating a new GameObjectConversionSettings?
@storm ravine That code only happens in one OnCreate()
But what world am I creating/destroying?
context: filling a dynamic buffer with entities, and making sure that those entities don't sudenly refer to nothing
and isn't it the version that changes when you make structural changes (add/remove components) ?
but I'll make my question more broad: does an entity change(id or version) outside of ECBS
@zinc plinth structural changes affect types versions in chunks (or order version if you create/destroy entities). Entities version persistent until you destroy and create, thus index will be reused with different version.
so as long as I track create/destroy of entities I'm good ?
yea i guess so, when one of your entities is destoryed you probably want to remove from that list
use ISystemStateComponents for that
@storm ravine is the bad part creating a new GameObjectConversionSettings?
@ocean tundra > @storm ravine That code only happens in one OnCreate()
@sand prawn call ConvertGameObjectHierarchy for every prefab - bad practice. If you have 1-2, thats not so important, but if you have more... This method on call create new conversion world, converts GO, return converted entities to destination world and destroy conversion world. Iβm going to sleep now, maybe Iβll show you tomorrow why itβs bad if donβt forget.
@storm ravine Sweet, looking forward to it, I def do that per prefab, but I do that all during load so not super worried yet
use ISystemStateComponents for that
@ocean tundra or GetCreatedAndDestroyedEntitiesAsync
OOOOOoooo Never seen that, To the Docs!!!
@storm ravine What's the superior approach, then?
@sand prawn At a guess i would say that GetCreatedAndDestroyedEntitiesAsync but im unsure how to use it
If you can make something happen async
Then it seems to be the way to go in general
agreed
but i dont know where you get the State input list for that method
but also, i would start with whats easiest to get going
then when you start profiling refactor bits
What's the best way to do a timer now?
Example is a attack timer (can only attack every 5 seconds)
Currently I add a attack component with a timer value set to 5 seconds then inside OnUpdate i ForEach over them and subtract delta time until it equals 0
Can you give me some tips on using UI with Unity DOTS?
Should I convert to entity the canvas... Or should I keep them GameObjects?
Can I access components in entities from a MB?
hi guys, can anyone point me to the proper way of creating a custom begin/end ECB system for a custom group? I looked at DefaultWorld.cs, but the code is using some internal member. Cheers
Edit: I'm using var m_systemsToUpdate = this.Systems as List<ComponentSystemBase>; to do the re-ordering, which is a bit dirty imo knowing this.System is a readonly IEnumerable, but it works... Any better / official way of doing it is very welcome.
@sand prawn @ocean tundra Ok I'm here. Now I'm explain why ConvertGameObjectHierarchy bad on scale. If you look at source code and how it works it become obvious. Inside ConvertGameObjectHierarchy you'll see this. And if you look in to it you'll see that it creates new World (see second image) for conversion, add bunch of conversions systems with their initialization (from settings or from default systems), converts just one your game object, move to destination world and destroy conversion world. And this happens every time when you call that method, if you will convert 30 prefabs - you'll create new world, populate it by systems, destroy that world 30 times. Even in start\oncreate it become expensive.
In opposite, if you look how ConvertToEntity works - it also create new conversion world and populate systems, BUT (big but) it doing that once for batch of objects. And when if things in OnCreate\Awake\Start they all converted with World created once
Because ConvertToEntity in Awake populate list of all ConvertToEntity mono behaviours.
And performance difference very valuable, no one want stuck game at loading for 30 seconds instead of 5
About addressables and how we using them with DOTS
SubScenes doesn't have good support, currently, for them, and we using ConvertToEntity here. We loading all required AssetReference's through LoadAssetAsync, which not freeze main thread and we can do any thing (in our case it's game intro\credits\etc at application start), when all required assets loaded we create one hidden go with convert to entity and pass all loaded GO to this hidden GO (with specific mono behaviour - PrefabsConverter) which populate IDeclareReferencePrefab, and in Convert fill our dictionary of entity prefabs (we have own unique ID system where every object has it's own unique persistent ID). And thus converts all prefabs at once.
In our authorings we have some custom inspectors for these unique ID's which allow us to has "reference" to prefab even without that prefab and before conversion
Because that ID is persistent (important) unique int which mean it will be the same in build and in editor
There is couple of custom editors, scriptable objects etc which helps other people in team (like artist, gamedesigner etc.) easily setup things, for example they just create prefab, fill it by required authorings and press one button and all this converts to required for loading representation, with required labels, utility components and SO, addresable references and groups etc.
Which allow you do every thing you need with that prefabs in editor before conversion. Like create initial buildings presets with all params like this when you can easily select required prefab and add to initial building set with parameters drag it through map, literaly "draw" them on map. and see where it will be in game for selected generation preset.
And approach of converting this things through that hidden GO with ConvertToEntity much faster than ConvertGameObjectHierarchy (which obvious)
Sorry to other for that little lecture for these guys π they asked I answered
OOOOOoooo Never seen that, To the Docs!!!
@ocean tundra It's new from 0.10 (I knew about that before from Simon because I requested exact same thing, and luckily they implemented that at the same time), it allow you to have lists of created\destroyed entities between calls which also very useful for processing chunks with destroyed entities (because change filter doesn't handle entity destroying per chunk, and order version does)
Hey, I've got a NativeArray<MyType> that I am passing around through managed code functions, and each time it obviously creates a copy of the wrapper that holds the pointer to the native array, and throws errors about memory leaks, although I dispose the allocated memory later on. Do I have some kind of a misunderstanding about this (is the NativeArray not a wrapper, is there an actual leak everytime its cleared from stack?) or the errors are just stupid?
What do the stack traces for the leak say?
Just points out where the memory was allocated (created)
A Native Collection has not been disposed, resulting in a memory leak. Allocated from:
are you passing by ref?
Shouldn't need to right?
The DisposeSentinel works by its finalizer, and if you pass by value both instances of the NativeArray will reference the same sentinel
I tried, no luck
Short answer: I don't know. This could be a bug with the safety system I guess.
currently withhout ref
Don't suppose you can tell if you actually do have a leak?
Do you have a snippet to share?
its all over the classes, but I can share something later, I havea noob quesiton first π
what does schedule expects for arguments?
If you can reproduce it with a small snippet, sounds like it would be worth posting on the forums.
@wispy walrus Which version of entities are you on?
I dont have entities package but I think I have burst
yes entities is not installed
you have burst, its installed through entities as a dependency
You're on 0.8.0, that page just shows latest (0.10.0)
I was trying to show the install button implying that I dont have it installed
What kind of Job is JobExample? (Which interface)
struct JobExample : Unity.Jobs.IJob {
public void Execute() {
}
}```
Ah.. I mixed collections and entities, wow, SORRY
Just normal Schedule() should do
I don't know what's the problem, but the VSCode Editor 1.1.4 package has a lot of problems, downgrade to 1.1.3
Do you have using Unity.Jobs; at the top?
nope
is thaht extension method?
@stiff skiff THHANK YOU! that works π
noob slight )
Its a super easy mistake to make
The extension methods show up due to one of the using's you have, but the basic method didnt
yeah didnt find the problem in docs for schedule
Its because a lot of things are now extension methods for some odd reason
No idea why
@wispy walrus There is no need pass native container by ref. How long your container should live? And when you although I dispose the allocated memory later on I guess you doing that not in same (or close) frame, and later? If so, just show me where you allocate that container, or tell which allocator type you using. I guess you using TempJob allocator?
@wide fiber there's vscode 1.2.0 which solves the problems in 1.1.4
@storm ravine no, I am crreating a persistent container and it lives pretty much as long as the application life.
Well we need to see code. Because it's definitely work as we have many persistent containers which walking through outr systems until application close
I also have native array pool (just a List) where I push and pop arrays. Each push and pop throws leak warnings because the value type is destroyed from stack but there are no leaks since the memory is 'shared'
did you use Allocator.Permanent ?
@zinc plinth Persistent not Permanent and yes he using it as he mentioned. This is why we need to see his code. Because I'm sure is user error :)
@wispy walrus I am crreating a persistent container
Can be, I will try to simplify and reproduce it than share the code if its still there
hah, calling Dispose in OnDestroy did it....
I had IDisposable implemented for everything that works with native collections, so that its responsible to release the memory later. But I did not call it thinking the class finalizer will trigger it anyway, but leak detection worked before the finalizer did.
thats my theory anyway
explicitly calling dispose fixed the problem
Yep, depends on how and where class instances lives finalizer can run much later than you exit play mode, especially when domain reload disabled. In simple case your destructor called not on exit from play mode, but right after pressing play and creating new instance for field where your previous instance lives. Personally I didn't like destructors pattern and prefer handle disposing things myself (not only in Unity context)
agreed, I like to know where my memory is and how its handeled.
On hindsight that explains why the errors were so inconsistent and random.
I got rusty at Dots, can anyone remind me why this piece of code crashes my editor as soon as I hit play?
Oh wait, now I think I get it.
check the editor log for the error
It probably crashes because I divide 0 by 0
that is certainly problematic
Yeah, but if it is the cause, then it's just stupid
yes it is
.....yeah. That was the issue.
I was wondering what the hell is happening for hours, and as soon as I posted my question I realized the problem.
for future crashes, I do recommend checking the editor log though, vs just trying to figure it out
usually there will be a stack trace of some kind in there
Well, Dots errors are often pretty unhelpful. At least in my experience. And yes, I also kinda forgot that logs are stored as a separate file.
also turning on all the safety checks and stuff
I have also another issue
Can I not change a value in a buffer without rebuilding it?
When doing:
activeBuffer[playerIndex.index].value = 1;
I get
Cannot modify the return value of 'DynamicBuffer<ActiveGrid_Buffer>.this[int]' because it is not a variable

