#archived-dots

1 messages Β· Page 231 of 1

robust scaffold
#

I have a theory: Change the contour2D from NativeList to NativeArray and add NativeArrayOptions.UninitializedMemory to the constructor.

#

If the float values do not change, that means that the UnsafeLists are aliasing unintentionally due to the new array's default pointers.

#

And if you want to just skip all these confusing type and memory issues, just malloc your own 2d array

unkempt abyss
#

Had to disable the rest of the function to test that since there's a few bits that rely on it being a list, but doesn't matter since it still seemed to be reproducable with the follow up disabled - using NativeArray with UninitializedMemory, the values in the existing array don't change - NativeArray with ClearMemory and the first two floats are becoming 0f instead of whatever garbage was there before

#

My theory was that my UnsafeLists were getting disposed somehow, so the temp allocator was returning the same memory to put the new NativeList/NativeArray in, but could you explain more what you mean about the default pointers aliasing if this lines up with what you'd expect?

robust scaffold
tribal pollen
#

So I'm Destroying Enemy entities when they die, but then I have some of leftover references to that that entity in a buffer of targetdata.
Anyone know a clean/nice way of removing these items from the buffer? if not I feel like i'd be iterating over every buffer of this datatype to find the ones I have to remove

unkempt abyss
#

(although I'm not doing anything with the array after yet, just throwing out of the function)

robust scaffold
robust scaffold
tribal pollen
#

k. I think ill just add the extra overhead when I destroy the entities, instead of a system that polls for it

robust scaffold
robust scaffold
#

To prevent "aliasing", or when two or more pointers point to the same chunk, or same part of a chunk, or memory.

#

When you create a NativeList<float>, float's a value type so it gets allocated a memory chunk that can be read and write to directly. No worries about aliasing. However, when you create a NativeList<UnsafeList>, that UnsafeList is another pointer. The first pointer to the "chunk" of memory is not aliased, checked by the creation of the NativeList, but that second set of pointers, the UnsafeLists, are not checked.

#

And when an UnsafeList is created, even if it's not new UnsafeList, it's a struct type so it needs to be initialized to default values.

#

That means a lot of null, 0, or whatever default needs to be written there

#

So when you create a NativeList<UnsafeList> without UninitializedMemory, it overwrites anything previously there. And doesnt notify any other pointer currently pointing to that chunk of memory because how could it know. It doesnt check.

#

Of course, that doesnt "fix" the problem of aliasing UnsafeLists. If you were to create and then allocate the UnsafeLists in the NativeLists, then there's a possibility it may re-alias and you get the corruption again... probably not though.

unkempt abyss
#

Slightly confused still sorry, hope you don't mind if I get you to clarify where my thought process is going wrong here

robust scaffold
#

it's a bit of a rabbit hole, dont fault ya for not understanding what's going on in there

unkempt abyss
#

I create a NativeList with a capacity of say 10 using the temp allocator - the list asks the temp allocator for enough memory to store an array of 10 pointers to the UnsafeLists - but these lists don't actually get created yet. (they should just be unitialized pointers / pointers to garbage?) The temp allocator shouldn't allocate memory it's already given out to something else, so there shouldn't be any possibility for corruption here unless I've already told the temp allocator somewhere that memory is safe to give back out?

#

where is my understanding going wrong there? 😁

#

(thanks btw)

tribal pollen
#

What's the best way to remove an item from a Dynamic Buffer? I only see Clear() or RemoveAt(). I'd like to use RemoveAt but on a command buffer....

robust scaffold
# unkempt abyss I create a NativeList with a capacity of say 10 using the temp allocator - the l...

You are correct in that creating a list of 10 UnsafeLists creates 10 pointers to "uninitialized" UnsafeLists. But remember, UnsafeList isnt just a malloc buffer, it has a lot of other "status" variables like length, another pointer to it's buffer (which is the malloc buffer), and more. I think it's a size 16 struct.

Now if UnsafeList was a class, your assumption would be correct. The NativeList would be filled with null pointers that wont conflict with any other current memory allocations and you wouldn't have a problem. But UnsafeList is a struct. That means it's a value type that must, by default, first clear out a space in the memory for it to use. Even if it's not initialized to any value.

The UnsafeLists' buffer pointer will be null, it's size would be 0, and so on. But that still requires space in the memory to store that data.

unkempt abyss
#

Following with you there, thanks - but why is that data ending up where my other data is? 😁

robust scaffold
#

Now NativeList checks if it's pointer and buffer does not conflict with other data in the stack (Allocators is just one giant unmanaged memory chunk). It does not check if the UnsafeLists' pointers do not conflict with another data's pointers. Now this is where my knowledge gets a little fuzzy.

#

Give me a sec to look at the source code

robust scaffold
unkempt abyss
#

TempJob - allocated from before the job is fired off & passed into the job on construction

robust scaffold
#

TempJob and Persistent use the same memory chunk. Temp uses a different chunk. Temp is extremely compacted which may mean aliased buffers but TempJob and Temp should not be close to each other.

unkempt abyss
#

but the lists within it are Temp

robust scaffold
#

Ah, there ya go.

unkempt abyss
#

(which are the ones getting overriden)

robust scaffold
#

This is not documented anywhere by Unity but tests by another programmer characterizing the Allocation memory buffers shows that Temp is extremely volatile and packed together. A lot speed and you dont need to dispose of arrays allocated in Temp because it is very easily overwritten

#

Let me see if I can find the article

robust scaffold
#

Now this is what I think is happening, I have no proof because this is all engine code.

#

When you create a native container with same stride / alignment and size (like contour and contour2D), the Temp memory buffer thinks "oh, look at these already pre-aligned and allocated memory the same size and stride as the new one the programmer wants" and overwrites it with default junk data

coarse turtle
#

Yea im pretty sure their extern malloc also has some additional logic to handle the different allocation strategies (I want to believe that it's a simple bump allocator - but no proof from my end 🀷)

robust scaffold
#

This "eager" buffer allocator allows for "internal" array allocation that do not need to be disposed of within the job since it just "reuses" same stride arrays from previous jobs assuming it is no longer needed

#

The UnsafeLists allocated in Temp outside the job are simply being reused without your permission and without notifying the original arrays, resulting in the pointers now pointing to junk.

#

Simply change the UnsafeLists of the external Contours to be TempJob and it should work without UninitalizedMemory

unkempt abyss
#

See, I'm agreed with you up to there - I can't see why the lists would be getting reused if I haven't disposed of them yet

robust scaffold
#

It's a "feature" of Allocator.Temp arrays. They do not need to be disposed.

#

They're invalidated automatically by the engine based on who knows what parameters, never documented and it's in C++ binary, so it may be doing so too eagerly

unkempt abyss
#

Since they're only valid for within a frame, you can technically not dispose them, but they shouldn't get reused within a frame? πŸ€” This is all happening during one frame

robust scaffold
#

Yep

#

Thats how temp allocated nativeX work in jobs. They're being created before the first job is run based on the number of threads available then reused by all jobs within a single frame

#

Theoretically, using UninitializedMemory, you might be able to pass information between two jobs within a single thread but the order and whatever else Unity is doing to it behind the scenes may invalidate it or throw an error.

tribal pollen
#

how do you guys normally remove items from a dynamic buffer?

robust scaffold
tribal pollen
#

don't care about order right now

unkempt abyss
#

But if Temp stuff allocated within a frame could just be randomly sharing the same memory as something else allocated with temp... surely the temp allocator would be entirely useless? πŸ™ƒ

coarse turtle
unkempt abyss
#

not seeing how it being initalized or not would make a difference here either, that would just change when it gets corrupted from when I declare it to when I start writing into it? πŸ€”

robust scaffold
# tribal pollen don't care about order right now

If you dont care about order, swap last index with the removed index then reduce the size of the buffer by 1. Extremely fast and no need for reorganization. I believe it's already implemented by unity with.... let me find it. Yea, remove at swapback

robust scaffold
tribal pollen
#

so this can't be done with boost?

robust scaffold
tribal pollen
#

Burst*

#

like that action would require .WithoutBurst.Run

robust scaffold
tribal pollen
#

I have an ECB but I don't see a way of using it to do the action

robust scaffold
robust scaffold
coarse turtle
#

The only operation I can see you use in your case, if you have an ECB is SetBuffer

unkempt abyss
#

that might be it

robust scaffold
#
/// <summary>
/// Removes the element at the specified index and swaps the last element into its place. This is more efficient
/// than moving all elements following the removed element, but does change the order of elements in the buffer.
/// </summary>
/// <param name="index">The index of the element to remove.</param>
public void RemoveAtSwapBack(int index)
{
    CheckWriteAccess();
    CheckBounds(index);
    ref var l = ref m_Buffer->Length;
    l -= 1;
    int newLength = l;
    if (index != newLength)
    {
        byte* basePtr = BufferHeader.GetElementPointer(m_Buffer);
        UnsafeUtility.WriteArrayElement(basePtr, index, UnsafeUtility.ReadArrayElement<T>(basePtr, newLength));
    }
}```
#

Nothing there requires invalidating the buffer array provided by DynamicBuffer. So it's burstable. Now Parallel maybe not, depending on how you're structuring the parallel access

#

If you're doing the removal per entity and each entity does not access the buffer of another entity (aka not using GetBufferFromEntity), you can use RemoveAtSwapBack in parallel with burst.

woven cradle
#

hey, when y'all have a chance I have a weird beginner question:
so in OOP, let's say i'd make a script with a public void TakeDamage(float f) function, which would subtract from the object's hit points and perform some other simple tasks/functions like running a private void Die() method if the object was reduced to zero hit points.
as far as I can tell, it's redundant to do something like slap this function on a component, because components are only meant to contain data. how would this be accomplished in DOTS?

robust scaffold
#
Entities
    .ForEach((ref DynamicBuffer<Element> buffer) =>
    {
        buffer.RemoveAtSwapBack(14);
    }).ScheduleParallel();```
robust scaffold
coarse turtle
tribal pollen
#

Ok thanks, I must be fetching it in a bad way. lol

robust scaffold
#

how would this be accomplished in DOTS?
Now in DOTS, you would have another entity attach a component onto its target like a "flag" stating that it has taken damage and how much. Then in a system scanning for these "flags", it then picks it up, combines the flag's damage with the target's hit points, and then remove the flag.

#

That is if you can not directly apply the damage to the target's hit point

woven cradle
#

because the point of this question isn't necessarily to deal damage and have an object die, it's to perform other logic on damage taken (say, spawning particles, factoring resistances, the like)

robust scaffold
unkempt abyss
woven cradle
unkempt abyss
#

which matches up with the documentation:
Each frame, the main thread creates a Temp allocator which is deallocated in its entirety at the end of the frame. Each job also creates one Temp allocator per thread, and these are deallocated in their entireties at the end of the job. Because a Temp allocator gets discarded as a whole, you actually don't need to manually deallocate your Temp allocations (in fact, doing so is a no-op).

robust scaffold
unkempt abyss
#

but I can't allocate TempJob from within the job πŸ˜†

#

or can I? πŸ€”

robust scaffold
robust scaffold
robust scaffold
# woven cradle interesting, that's a lot more intuitive than I initially thought. in regards to...

So you have a system scanning entities with the two components Attacked and HitPoints. Maybe even Armor.
If Attacked.Damage <= 0, early return, skip that entity since no damage has been done since the last time it was checked.
If Attacked.Damage > 0, check Attacked.Type for the type of damage then multiply Damage with Armor, if it has any.
Then apply Damage to Hitpoint component and reset Damage = 0. All on the same Entity.
You can then parallel and, if you're feeling brave), loop vectorize it for lightning speed performance over 2 million entities.

coarse turtle
# unkempt abyss or can I? πŸ€”

probably best to allocate ahead of time with the size you need. Allocate something that's too small - you'll resize & do a memcpy (where the new size is old Capacity + 1).

woven cradle
unkempt abyss
#

this is one of those fun cases where there's a very awkwardly unknown upper bound 😦

#

dumb solution is two just merge my two jobs into one very long job

robust scaffold
woven cradle
#

i see

unkempt abyss
#

since I can only create temp memory within the job, and I can't pass that out of the job (wait, why can I resize a tempjob list within the job then...? πŸ€”)

robust scaffold
#

As long as you never need to read the list in the main thread, you can pass along deferred arrays throughout your job chain.

unkempt abyss
#

hmm, I'll think about it, thanks 😁

robust scaffold
#

Of course, this wouldnt work with Entities. You'll need to use IJobParallelForDeferred and such

unkempt abyss
#

luckily no entities here πŸ˜…

valid haven
#

I have avoided TempAllocators so far, but most of my collections are very large so the cost to allocate even in a job can be problematic for performance πŸ™‚

robust scaffold
robust scaffold
# unkempt abyss luckily no entities here πŸ˜…

I think memory chunks resulting from malloc can pass between the boundary but I know performance is going to be destroyed using that. Otherwise, I dont believe there is any other way to dynamically allocate memory size and pass from a job back to the main thread to be read. You need to know the size of the arrays or memory before the job is even scheduled.

valid haven
#

if the issue is it changes size, just have an array[1] that stores the current index size that frame and pass that in to those jobs as well.

#

i.e. something like that

robust scaffold
unkempt abyss
#

basically I've got one job that produces a jagged array (nativelist of unsafelists of vector3s), and another job that consumes them, where the jagged-ness is of unknown and almost unbounded size 😬

valid haven
#

and this job is spread over multiple threads and you need to avoid inter-thread locking?

unkempt abyss
#

there's multiple instances of it running over multiple threads but there shouldn't be any data shared between threads (other than explictly from job A into job B where b is scheduled after a)

#

(no data is shared between the instances, I'm just running it on a bunch of different data at once)

valid haven
#

you say they are unbounded in size, but in practice how big can they get?

unkempt abyss
#

I think 4194240 float3's in total, spread across the axis is any way

valid haven
#

and u are generating this how often?

unkempt abyss
#

most cases it's gonna be nowhere near that big, just the theoretical max is huge

#

might happen up to hundreds of time a frame when it does happen, but that frame wouldn't happen often

#

πŸ™ƒ

#

if this sounds cursed... it is

#

I think i can get away with job combining the producing & consuming jobs though

half jay
#

Does burstable main thread need ecs 0.17 and ISystemBase?

valid haven
#

understood, I am trying to understand how expensive your memory allocations will be overtime if u keep allocating and disposing, even if in a job this can be expensive. If it happens often and at sizes anywhere near that, I would be concerned. In such cases I would likely just create a pool of paired permanent nativearrays, one of sufficient size to contain my objects and the other of size 1 to contain the current index count. Then just hand them out to jobs as needed.

cerulean pulsar
#

Hey, how do you guys decide when to put two pieces of data in one IComponentData, and when to put each in their own IComponentData? Feels arbitrary right now, except that the default delegate for Entities.ForEach limits you to nine parameters

robust scaffold
robust scaffold
green ledge
#

i agree with you when you said that patching DOTS into an alreasy existing game leads to more suffering, but if DOTS was intended to deal with large number of GameObjects, it's not a bad idea to implement it to a simple game since it gives you better performance by default . let's say a game that uses oop and gameobjects is running fine, maybe 125fps (I don't know, I am just throwing numbers), but with dots it would run even better, maybe 200fps+ (again just throwing numbers) but maybe it took more time to create the game, in my opinion it's worth it don't you think? again I don't know anything about dots so I could be completely wrong.

amber flicker
#

Reality is most games are gpu bound but if you're cpu bound then it can def help.

radiant oracle
#

What's the best way to learn the current DOTS syntax? Every time I come back to look at DOTS again the syntax changes and I find I'm doing everything the 'old way' and most tutorials and reference material (including officially released code) is outdated...

amber flicker
radiant oracle
#

I just remember looking through the movement component in the sample project and it was like...basically written as a Monobehavior and Dots was basically a wrapper for it

#

Like it wasn't actually 'coded in DOTs'

radiant oracle
#

Are all the dots sample projects compatible with 2020.3.20f1? Looks like they were made in 2020.1.9f1

robust scaffold
#

Take chess, there are at most 33 gameobjects in a very basic chess, 1 for the board, 16 for the black player, 16 for the white. Converting that to DOTS is not going to give you more performance, in fact probably less

#

What would help would be maybe a visual where 5,000 games of chess were happening at the same time

#

Or a city traffic simulator like Cities Skyline where there are a lot of identical cars on city roads

valid haven
#

data oriented programming performance benefits can be felt in most game genres, where scaling entity counts higher is useful. For example I am working on a large world survival game and its beneficial to be able to increase the number of systems/entities updating in the world at any given time, even tho the majority of those entities wont ever be see on screen by the player at the same time. It is also useful for any game where u want to save cpu cycles and/or power on mobile.

#

You can also still obtain a lot of these benefits without using DOTs entities, simply by following good DOP practices and using jobs where it makes sense. Doesn't have to be all or nothing to get benefits.

radiant oracle
green ledge
green ledge
#

Thanks

half jay
#

Does anybody has problems with Unity 2020.3.20LTS and ECS. I updated ECS to 0.17 and com.unity.platforms was updated as dependency. After that i have errors

coarse turtle
#

ObjectPool was introduced in 2021.1

half jay
#

but this package upgraded with im changed ecs from 0.16 to 0.17. And ecs with 2021.1 not officially supported. Im trying to use HybridRenderV2 with android URP and Unity 2020.3

coarse turtle
#

Yea I'm just saying that ObjectPool was introduced in the engine in 2021.1 and you're on 2020.3. I updated to 2021.1, but I don't use Hybrid Renderer πŸ€”

pliant pike
#

Is there no GetSingleton method on the EntityManager anymore? I'm sure their used to be πŸ˜•

whole gyro
robust scaffold
whole gyro
coarse turtle
pliant pike
tribal pollen
#

Anyone know why I get "The entity does not exist" error when checking GetComponentDataFromEntity inside a foreach lambda that has the entity as an argument?

#

Like if the entity doesn't exist, how did I get inside this lambda and inside checks for certain tags on that entity

left oak
#

If you're working on the entity in the argument, why don't you just pass the component data as an argument??

tribal pollen
#

I confused myself as i wrote that lol. It's checking tags on that entity which are valid, then it does the GetComponentDataFromEntity on the reference of a different data

#

I'm trying to check if the reference is null, but it passes that

#

if (targetData.Target == Entity.Null) return;
var dirToTarget = (positions[targetData.Target].Value - translation.Value);

positions is my GetComponentDataFromEntity

#

is there a safe way to check if an entity exists? clearly null isn't the way..

left oak
#

Well, the intended way is to just query for entities with the given tag, and operate on them if they exist in the query; no null reference check needed. I'd rethink whether you really need entity references in this case. If you do, I'd implement a system that cleans up entity references before entity destruction, so I'd know all entity references are up to date and valid.

tribal pollen
#

Well I have one entity that follows another entity so i have it keep a reference to the one it follows

pallid moat
#

Hey everyone! I'm using HDRP with the hybrid renderer and can't seem to get my entities to render. Even though I followed all of the documentation properly, I never got the confirming console output when trying to upgrade to the hybrid renderer v2, so I'm thinking that's my main issue. My color space is set to linear, the script define symbol is there, and srp batching is enabled in the HDRP asset. Here's the code I'm using to spawn an entity (just in case that's actually the issue): https://pastebin.com/Sh5BrbYV

amber flicker
left oak
tribal pollen
#

@left oak Kinda new to this lol. How would I do that?

tribal pollen
#

ah it's a special thing just for transforms?

left oak
#

You get a lot of utility from parenting, like included entity references

#

you also get this child's position in parent space

tribal pollen
#

Sounds like a nice piece i've been missing out on lol. Trying to figure out the syntax now. There's a lot of text on that page πŸ˜›

left oak
#

Yeah, but the diagrams help

#

It's easier to use with conversion, but can certainly be setup programmatically

tight blade
#

So, I realize this question is way too broad and I'm kind of expecting crickets, but is there a "beginners guide to building your first DOTS project as a standalone that you can distribute to friends" out there anywhere that anyone knows of? πŸ˜…

tight blade
#

right now it builds and I just see a grey screen when the splash screen ends

forest quest
# tight blade So, I realize this question is way too broad and I'm kind of expecting crickets,...

I don't know of one, but I would suggest ignoring everything geared towards optimization and focus on learning how to use ECS as a framework. Forget about burst and trying to make things multi-threaded. Forget about using the hybrid renderer or hybrid physics. You can make any class into a component by just adding IComponentData to it's implementation list. You will run into complexity with the way Unity has built their hybrid stuff, and I personally found I needed to write my own stuff to make the entity-gameobject hybrid shamelessly work the way I wanted it to work. If you do all this, then you can focus on just learning and following the principals of ECS. You won't benefit from the optimizations, but you will flatten the learning curve, you will still benefit from the stability benefits of sequential execution, system decoupling, and you will set yourself up for straight forward refactoring and optimization later.

tight blade
#

oh, sorry, I'm talking specifically about building. I'm pretty darn good with ECS / have a relatively complex little sim that works when I enter play mode

#

I just want to build the thing so that I can show it off

forest quest
#

oh, I don't know, I never had any issues with building

#

maybe that's because I didn't use unity's more experimental parts

tight blade
#

so, Im wondering if its related to the fact that I have "convert and inject gameobject" attached to the main camera

#

I use the CopyTransformToGameObject component so that I can control the camera position from ECS

#

maybe it doesn't like that

coarse turtle
#

Are you using the scriptable build pipeline?

tight blade
#

its an HDRP project, I can't remember if that's mutually exclusive

coarse turtle
#

hmm dunno anything about HDRP since I'm on URP

#

Do you get build errors?

tight blade
#

no build errors. got 2 warnings - unable to find player assembly - UnityEngine.TestRunner.dll and UnityEngine.PerformanceTesting.dll -, but I feel like that shouldnt matter

coarse turtle
#

Yea that shouldn't

#

I imagine you're just not seeing anything?

tight blade
#

yeah, just grey screen once the unity splash screen ends

coarse turtle
#

o, yeah not sure - maybe it's a hybrid renderer issue? πŸ€”

coarse turtle
#

I currently use that to control a camera

tight blade
#

ugh. okay nevermind. I really appreciate both of you helping but I'm just an idiot and committed the error I thought I wasn't stupid enough to make

#

The scene that as added to the build was not the one I was using to control the game

#

sorry, this wasnt DOTS related at all and I'm that guy tonight.

pallid moat
#

I might be understanding this wrong, but shouldn't these 3 objects be converted to entities and destroyed since I have the ConvertToEntity script on them?

tight blade
#

cant tell what the problem is from that shot, can you screencap them in the inspector before entering playmode_

pallid moat
#

Here ya go. It's just three copies of a prefab with a meshrenderer, meshfilter, and a ConvertToEntity script.

stone osprey
#

Quick question... when i use burst compatible structs as components for my entities. Are those allowed to inherit interfaces other than IComponentData ?

#

Like public struct Movement : IComponentData, IDisposable, IMyOwnInterface ?

zenith wyvern
half jay
#

i have this system. i want it to be burst compatible. It has few protected static methods in base system. Should i mark methods with [BurstCompile] attribute?

#

im look in DOTS compiler how its look like so attribute set to system. Is it enough ?

#

also should i move GetComponentData form singleton Entity into lambda and get data through GetComponentDataFromEntity

zenith wyvern
#

If you call a static function from inside a bursted function, it will be bursted

#

No need to decorate the static functions

digital kestrel
#

how do we run an entities foreach loop with dynamic "with" clause

#
        foreach (ComponentType t in types)
        {
            Entities
                .WithAll<t>
                .ForEach((Entity entity, Translation translation, Rotation rotation) =>
                {

                }).ScheduleParallel();
        }
coarse turtle
#

Cause it looks like you'll probably just want to construct the query using an Any clause

karmic depot
#

Is it expected, that the Parent component on an instantiated prefab points to itself?

amber flicker
devout prairie
#

Any particular reasons why EndFrameParentSystem might be using a looot of time compared to all other systems

#

Additional question - when trying to take advantage of hybrid renderer ( for example thousands of bullets ) is there anything special that needs to be done to take advantage of batching? Does enabling GPU instancing in the URP Lit marerial affect this at all?

whole gyro
# devout prairie Additional question - when trying to take advantage of hybrid renderer ( for exa...

According to this thread, there is no need to enable GPU Instancing on materials when using hybrid renderer v2: https://forum.unity.com/threads/confused-about-performance-of-srp-batching-vs-gpu-instancing.949185/. It also sounds like you should disable Dynamic Batching in the pipeline asset so that it doesn't interfere with the newer stuff in hybrid renderer, although I might have misunderstood that part.

devout prairie
digital kestrel
#

can entities v0.20 come out already lmao

devout prairie
digital kestrel
digital kestrel
#

honestly might have to do some codegen or something

coarse turtle
#

but you can pass in an array of ComponentTypes to an EntityQueryDesc?

#

plus you can also combine EntityQueryDesc together πŸ€”

#

Well I'm not really sure what you're trying to achieve

digital kestrel
#

you're right

#

I forgot about EntityQueryDesc

mental bison
#

does someone have an up to date example on how to handle trigger events?

safe lintel
devout prairie
karmic depot
#

anyone else noticed Companion GameObjects don't get destroyed, at least in the editor when quitting play mode?

zealous musk
#

GhostStatSystem is making my game almost unplayable

#

what is it?

#

its unity. i restarted unity and now its gone. wtf guys.

mystic quartz
#

Is there an idiomatic way to get player inputs from the player input component into an ECS system? I'm not converting an existing game. (I mean, I am, but what code existed is incredibly simple, and I'm redoing it from scratch.)

safe lintel
#

thats how I use it

mystic quartz
safe lintel
#

thought similarly originally, though after using it to me it seems fine and the least of my worries as far as any dots <-> unityengine based interaction

mystic quartz
#

Oh, is all that just for keeping things from breaking with multiple developers using source control?

coarse turtle
#

it's more of a state of unity since there are multiple input systems

#

and this example specifically uses the new input system

whole gyro
safe lintel
#

wow it was there in the first sentence and i missed the 1.0

mystic quartz
coarse turtle
#

Mb didn't read your message properly, to answer your question - yes

#

it's there to avoid breaking the system in case someone doesn't have the new input system enabled in their project

safe lintel
#

probably gonna sound like a broken record but wish the other dots repos were open. would feel a little bit better about the whole lack of communication

mystic quartz
whole gyro
#

I can guess that the answer is something related to unity being a publicly traded company...

#

Anyways, I'm just excited to see that DOTS 1.0 is still actively being worked on. Fingers crossed for a break in the radio silence by the end of the year.

safe lintel
#

i dont think its anything to do with them being publicly traded tbh, imo the whole roadmap productboard kind of disproves that(along with the safe harbour statement), i think its just par for the course with how unity operates, sometimes hot and sometimes cold as far as communication goes.

whole gyro
#

Hmm I dunno. Perhaps it has nothing to do with being publicly traded, but it really does feel like the unity folks were told not to discuss future DOTS changes anymore. There used to be very frequent posts by unity staff saying that various changes would land in the next version of entities in a month, or them participating in discussions of improvements and changes to the workflows. I find it hard to believe that they all just stopped being as active in the forums at the same time.

safe lintel
#

def agree that theres some general gag order as far as general communication, i just feel its more of a general strategy rather than in reaction to being publicly traded. feels reminiscent of how terrain was just ignored for the longest time, or the ire around state of unhappiness regarding render pipelines until they made a big post about it.

zenith stirrup
#

people are more understanding than they think

devout prairie
#

Rule number one of Dots Club - you do not talk about Dots Club

light ore
#

Hello

#

I need to have some meshes from a scene as DontDestroyOnLoad

#

Before, I could easily achieve making them persistent with DontDestroyOnLoad codes

#

Now, I have converted those meshes to Entities, as they're under Subscenes

#

Is there any way to make those meshes or entities, persistent?

coarse turtle
karmic depot
safe lintel
#

nice find with the picking, can only hope we will be able to edit entity data in the inspector soon enough to go along with that picking

karmic depot
gusty comet
#

as far as we know, dots have more people working on it than ever, but terrain for the longest time did not have a full team behind it.

coarse turtle
#

Thrilled to announce we have formed a C#/.NET Tech Group within Unity, bringing Scripting (C# compilation, .NET Runtime integration...), Burst & VM/IL2CPP teams all together to further standardize, modernize, and innovate with .NET technologies within the Unity platform! β™₯️

gusty comet
#

Imho, radio silence is definitely related to being publicly traded

safe lintel
#

yeah in that editor thread they mentioned it would only be readonly, but really hoping they are changed their minds on that. I mean picking entities is handy but picking and editing is like what I come to expect, not just reading that data.

coarse turtle
#

probably too many siloed teams all moving at once which is why they're silent. 🀷

mystic quartz
#

Can you change the behavior of a system based on the existence of a component in an entity?

#

And by that I mean the system always applies with the presence of specific components, like normal, but the way it processes changes depending on the existence or non-existence of an extra component.

drowsy oak
#

Hi all, just joined the discord. Brand new to DOTS and ECS. Hope to see you all around o/

left oak
#

@mystic quartz, the simplest way to do that is to have different Entities.ForEach() for the various possible combinations of components by using either the WithAll(), WithAny(), and WithNone() modifiers or by including different sets of captured variables in the ForEach lambda. This involves writing a lot of jobs with subtle differences in execution, but you gain the confidence that only the valid sets of ForEach run on any given frame. You could also simply do a HasComponent(Entity) check and then branch from there within a job, but I very much recommend the former over the latter

mystic quartz
coarse turtle
drowsy oak
#

It seems that you used to get access to a physics frame's triggerEvents in StepPhysicsWorld.Simulation.TriggerEvents (unless I'm mistaken), but it doesn't seem to be present. Has it been moved/api changed?

mystic quartz
#

Makin' a camera controller. I'm giving it a reference to an Entity for it to track, but I need to access the Translation component of that Entity in the ForEach. Tried a thing I found online that uses GetComponentDataFromEntity and WithReadOnly, but that just throws a load of InvalidOperationExceptions at me whenever I try to index the variable, which I think might come down to the possibility of reading from and writing to the same Translation.
Anyone know the pattern for what I'm trying to do?

safe lintel
#

paste how you're using it. also if you are using ForEach you can use GetComponent/SetComponent which compiles to cdfe

mystic quartz
# safe lintel paste how you're using it. also if you are using ForEach you can use GetComponen...
public class CameraDollySystem : SystemBase {
    protected override void OnUpdate() {
        float deltaTime = Time.DeltaTime;
        
        var translationComponentData = GetComponentDataFromEntity<Translation>();
        
        Entities.WithReadOnly(translationComponentData).ForEach((ref Translation translation, in CameraDolly dolly) => {
            var targetPosition = translationComponentData[dolly.target].Value;
                
            translation.Value = AMath.Approach(translation.Value, targetPosition, deltaTime, dolly.smoothingRate);
        }).Schedule();
    }
}```
drowsy oak
remote crater
#

How do you test if an entity exists and is not destroyed?

#

in a .foreach

safe lintel
remote crater
#

Weirdest thing I did ctrl+h for exist like twice and nothing showed up...

#

you da man baron von rick codin

mystic quartz
pallid moat
#

So I recently created a new HDRP project to test if the hybrid renderer v2 works on it, and it turns out it works perfectly. However, on my current HDRP project that I've been working on for months now, I can't get the hybrid renderer v2 to activate at all. Both projects follow the documentation exactly (hybrid renderer v2 enabled in script defines, color space is set to linear, srp batching enabled in the hdrp asset), but only the new test project is getting the confirming console output and is able to render an entity. The hdrp and hybrid renderer package versions are the same on both projects as well. Does anyone have any pointers as to what could potentially be causing this issue?

remote crater
#

Under Buildconfiguration, what are the components: Unity.Build.DOTSRUNTIME and do I need them to see entities in standalone?

pallid moat
safe lintel
#

@mystic quartz

Entities.ForEach((Entity entity, in CameraDolly dolly) => {
  var targetPosition = GetComponent<Translation>(dolly.target).Value;
  var translation = GetComponent<Translation>(entity)
  SetComponent(entity, AMath.Approach(translation.Value, targetPosition, deltaTime, dolly.smoothingRate));
}).Schedule();
//or
Entities.WithNativeDisableParallelForRestriction(translationComponentData).ForEach((Entity entity, in CameraDolly dolly)=>{
var translation = translationComponentData[entity];
// etc
})
#

@pallid moat you got the ENABLE_HYBRID_RENDERER_V2 define in player settings?

pallid moat
cerulean pulsar
#

Having a NetCode issue with child entities and interpolated-only ghosts. Posted here with a minimal example if someone is willing to take a look: https://forum.unity.com/threads/snapshot-not-sending-child-rotation-for-interpolated-entity.1183633/

I have a server-controlled ghost, which rotates a ghost child entity. The data updates in the server world, but does not transfer to the client world ghost child entity. The strange thing is that the translation data of the ghost root entity does transfer. This problem appeared when I converted a hierarchical ghost from an owner predicted ghost to a purely interpolated ghost. Provided some GIF visualizations in the thread

cerulean pulsar
twin raven
#

Is there a DisablePhysics ComponentTag or something similiar for dots physics? I remember seeing this somewhere, but can't find it πŸ€”

#

Ah found it PhysicsExclude It's not mentioned in the documentation

karmic depot
#

Does .NET Standard 2.0 vs Framework 4.x matter in terms of DOTS packages?

drowsy oak
#

Trying to work out if this is an ECS/DOTS issue or InputSystem issue. My horizonal and vertical actions are updated fine, but my button actions (jump and orient) are always false. Am I missing something?

        InputSystem.Update();

        float horizontal = playerActions.Horizontal.ReadValue<float>();
        float vertical = playerActions.Vertical.ReadValue<float>();
        bool jump = playerActions.Jump.triggered;
        bool orient = playerActions.Orient.triggered;
        Debug.Log($"Jump: {jump}, Orient: {orient}");
#

Is this the correct way to handle InputSystem stuff in Systems?

lethal pecan
#

Hi, does anyone know how to do raycasts inside a jobs struct?

pliant pike
drowsy oak
pliant pike
#

yeah that's what I mean I just used readvalue<float>() and that seems to work

drowsy oak
#

Ah cool thanks. Weird that non-preview package just isn't functioning according to the docs πŸ€”

#

Cool I'm just gonna use this for now:

bool jump = playerActions.Jump.ReadValue<float>() != 0 ? true : false;
#

Thanks for your help

devout prairie
vagrant lotus
#

what allocator do i need for MeshCollider.Create() for the vertices and triangles NativeArrays?

hollow jolt
#

when running a job is there a way to avoid using the main thread and only schedule it on the other cores ?

pliant pike
hollow jolt
#

i see thanks , any ideas about how to use compute buffers with DOTS ?

pliant pike
stiff skiff
drowsy oak
amber flicker
# pliant pike of course that's the whole point use either schedule() or scheduleparallel()

Although I think worth saying that it's difficult to avoid having the main thread do work to schedule the job. So although your job can run on another thread, especially for smaller jobs, the time taken to schedule it can be much longer than the duration of the job itself.
E.g. for <100 entities (esp entities with components used in other jobs), Run() is often less total main thread cost than just the scheduling and dependency management in a Sched/SchedParallel (ignoring the time to execute / do the work).

amber flicker
drowsy oak
#

Sorry, I misread your post, I thought you said it doesn't need the whole != 0 ? true : false.
You're right. I forgot c# syntax allows the conditional on it's own on the right side.
bool jump = playerActions.Jump.ReadValue<float>() != 0. Is fine on its own.

#

Or rather @stiff skiff said

pliant pike
#

I did not know that leahWTF

amber flicker
drowsy oak
#

It is a nice syntax. VB sadly has to use an if that makes it all messy.

hollow jolt
#

where can i find the dots repositories on github ?

amber flicker
hollow jolt
#

i mean we can download those in the package manager

#

and open the Library code

#

but i can't find it on github

amber flicker
#

not sure why you'd expect to? Unity don't want pr's

hollow jolt
#

pr?

amber flicker
#

pull requests, fixes, generally anyone contributing code outside of Unity

hollow jolt
#

ok thanks , ill just copy it from the Library folder then

drowsy oak
#

There is a needle mirror if you want it on github for looking at he code away from your project

amber flicker
#

btw if you only need access to the internal methods you can use the 'AssemblyInfo.cs' combined with assembly reference trick to make it accessible to your classes.

drowsy oak
#

etc.

hollow jolt
#

apparently the hybrid one writes to a compute buffer from a burst job if i understood it correctly

amber flicker
#

Just want to check you're aware you can generate project files for packages too? Can help follow code. e.g.

drowsy oak
#

Ha just beat me to it!

hollow jolt
#

yea im aware of this , my laptop is a bit slow and the project is already pretty big so wanted to avoid downloading this

#

thanks

remote crater
devout prairie
#

So does anyone have any pointers on reducing the load in EndFrameParentSystem.. it's showing up in Profiler as job called RenderGraph:ParallelRenderer (Burst):

#

Or even some way to trace why it's consuming so much time

devout prairie
remote crater
#

Oh is that next line tied to the line above?

devout prairie
remote crater
remote crater
# devout prairie uhh.. yeah?

I'm not familiar of coding when one line of code flags an error if the one after it isn't there outside not doing method returns... This dots stuff is curious.

devout prairie
remote crater
#

Its the same error I got before refactoring my code to accept parallel writing...

#

Ok, so what I get is you just didn't understand my question.

#

That answers my curiosity of why a line of code would show an error if a line of code after it was not there.

#

That's good to know. We just back to the original problem now.

devout prairie
#

Well the error is showing that the first argument of the ScheduleParallel for the job expects an EntityQuery

#

So it might be worth doing a quick search for other examples of where ScheduleParallel has been used on a job and how a query is typically passed in

#

Here's an example from the Animation package:

remote crater
#

Do you know if schedule parallel is even allowable in jobs?

#

Cuz I do parallel in some systemsbase scripts successfully now

#

Normally I end with: }).WithoutBurst().ScheduleParallel(this.Dependency);

#

You do not even need an EntityQuery my man.

devout prairie
#

It's obviously slightly different with a job, like in the above example..

remote crater
#

Maybe I need to shuffle a dependency in

#

That would make sense

devout prairie
#

So when you run the job you're passing in a query which represents the entities to run through the job

remote crater
#

I'm just helping you out... There is nothing that needs to be passed to .ScheduleParallel that involves an EntityQuery...

#

Its fun when two people with imperfect information come together to help each other.

#

I find this beautiful, not frustrating

devout prairie
#

It's literally telling you it wants a query..

remote crater
#

Frustrating is when you have no idea how to start going over a brick wall hurdle.

devout prairie
#

look at the example i posted above

remote crater
#

Where do you get the dependency from the above example?

#

I'm missing that part as well.

devout prairie
#

how du mean

remote crater
#

The line: .ScheduleParallel(m_ComputeSkinMatrixQuery,1,Dependency)

devout prairie
#

ahh i see

remote crater
#

The Dependency variable is not declared in the visible code.

devout prairie
#

Dependency is passed in to every SystemBase, it's already there

remote crater
#

in my system base, it is declared by setting it Dependency = Entities .Foreach

#

Oh!

#

wow!

#

ty

devout prairie
#

so i think in your case you're passing in Jobhandle inputDeps, that's i think the old way of doing it with JobComponents or something

#

using SystemBase is just magnitudes simpler than all that

remote crater
#

ok so I did have it then

#

mine is inputDeps

#

cool cool

#

I'm using this code because it works for collisions... Normally yah I use Systembase for everything

devout prairie
#

Here's basically how you can chain together two jobs in a SystemBase, really simple:


        protected override void OnUpdate()
        {
            Dependency = new ComputeSkinMatrixJob
            {
            }.ScheduleParallel(myQuery1, 1, Dependency);

            Dependency = new CopySparseBlendShapeWeightJob
            {
            }.ScheduleParallel(myQuery2, 1, Dependency);
        }
#

And here's another way using CombineDependencies:

protected override void OnUpdate()
        {
            var job1 = new ComputeSkinMatrixJob
            {
            }.ScheduleParallel(myQuery1, 1, Dependency);

            Dependency = JobHandle.CombineDependencies(job1, Dependency);
            
            var job2 = new CopySparseBlendShapeWeightJob
            {
            }.ScheduleParallel(myQuery2, 1, Dependency);
        }
remote crater
devout prairie
#

Ah it's a CollisionJob i didn't notice that.. let me have a quick look through the physics samples

#

is CollisionJob a custom job you've created?

remote crater
#

Here, I'll give the full code

#

It was working code for non parallel That I expanded

#

Enjoy...

#

It requires a custom component named EntityData... and that's just stuff custom to my game.

#

Remove all that and you can still be reading in collisions.

#

I ended up hitting same error as I did in my systembases

#

It would destroy an entity, while another systembase tried to post process the scheduler

#

Without parallel, one may destroy while other being used

#

You know what tho...

#

I'm probably going about this wrong.

#

Maybe I should flag it to be destroyed and use my destroyer process... That probably should work.

#

Unless stuff is being read/wrote same time multithread problems

devout prairie
#

Okay i think basically the ICollisionEventJob interface does not accomodate ScheduleParallel

remote crater
#

We good to go. Hey let me post one of my cool looking DOTS ECS videos, these things are funny

#

If I have future issues, I either need to do collision elsewhere or see how to do stuff before or after my parallel stuff... I get conflicts cuz my parallel isn't finding destroyed entities in my iCollisionEventJob

devout prairie
#

Yeah it's kinda the joy of dots/ecs is you get the benefit of being mega explicit over exactly what happens and when, but then you have to spend that extra time designing the systems and jobs to flow as linearly as possible etc

remote crater
#

No lie, Cow, I enjoy having a challenge. At least it aint mind twisty like circutboard chip coding where memory is the limit and not the processing... It flips the optimization habit processes in my brain and fries me. Unity DOTS is like mind expanding beauty.

devout prairie
#

Hehe looks nice. Reminds me of an oldschool space game that i can't put my finger on. Are you using hybrid renderer or gameobjects?

safe coral
#

Is there a cross platform deterministic physics engine in DOTS?

#

Fixed-point/integer based

mystic quartz
#

Is there a way to query two related entities at the same time?
I've got a player, and a gun. The gun is necessarily related to the player (Transform, velocity, friendly-fire checking,) but also requires its own composition (Rate of fire, projectiles, hitscan, bullet prefab, effects, transform offset, burst, ect)
The system needs to know about the player in order to correctly use the gun, and the gun must be an entity so it can be composed.

tribal pollen
#

Anyone ever dealt with entities spawning at 0,0,0? despite setting transform location at the start

tribal pollen
#

like it's only happening for 1 frame, but it's messing some things up for me :\

mystic quartz
tribal pollen
#

no, same place

#

well i guess it does get updated somewhere else later

#

to move it

mystic quartz
tribal pollen
#

it's even happening when i parent them. I can set a LocalToParent value, and in a different system it'll come back at 0,0,0 for 1 frame

#

I tried setting localtoworld instead of just translation or localToParent to see, but it didn't help

#

Ok so for at least one of my cases, this has something to do with the position in my prefab. despite me setting it right after I make it.
Am I creating it wrong? this is what I'm doing
Entities.ForEach((int entityInQueryIndex, in Spawner spawner, in Translation translation) =>
{
var spawnedEntity = ecb.Instantiate(entityInQueryIndex, spawner.EntityPrefab);
ecb.SetComponent(entityInQueryIndex, spawnedEntity, translation);
}

left oak
#

my guess is that it's spawning in time to be rendered, but not in time to be processed by the transform system group

#

the effect of that being the case is a single frame of entities being rendered at world origin

uncut rover
#

@tribal pollen Basically it has to do with what @left oak said. The rendering system is using the localToWorld component. that component is updated by the transform systems in the simulation group. If you spawn you entity at the end of the simulation group it will not have an updated localToWorld value it will be (0,0,0) or whatever value the default is for your prefab. After the simulation group comes the presentation group that display your entity on screen. since the localToWorld is not updated it will show up at world origin. So you can either spawn your entity at the begin simulation group command buffer (delaying the instantiation by 1 frame) which will give time for the transforms group to update the position of your entity or you can compute and set yourself the local to world. Option 1 is the simplest one but be aware that the simulation will also have the localToWorld at (0,0,0) until the transform group is run. So if the physics system uses the localToWorld and run before the transform group it will also "see" the entity at (0,0,0).

amber flicker
#

yup exactly what @uncut rover said. Some people set the LTW manually for the first frame but I wouldn't really recommend it. One additional thing - instead of delaying instantiation to the first frame, another approach is to ensure your spawning system updates before the Transform System.

tribal pollen
#

@left oak @uncut rover @amber flicker Thanks, for all your help. I didn't get to do much with it this morning before work but I did quickly test and changing it to the StartInitialization buffer seems to have fixed the issue for my normal spawned entities.
However, it seems like the issue is still there for my Child entities, LocalToParent is starting at 0,0,0 (Note I'm not spawning parent and child at the same time, parent already exists when I spawn a child). I believe this 0,0,0 is the same location as the parent, not the world 0,0,0
I'm pretty sure i tested with both setting LTP value on creation and also just setting transform.
Is there a similar order oddity happening within the System's Hierarchical Transforms?

uncut rover
# tribal pollen <@!344308581413289984> <@!336973088698662912> <@!190954630623002624> Thanks, for...

I have not yet tried to spawn an entity and parent it to an existing one. All I know from the conversion system is that the is a Parent component on the child and there is a Child buffer on the parent. These are used by the transform system to compute localToParent matrix. I would start by checking if the parent component and child buffer are properly populated after instantiation. If they are not the transform system will most likely not work as expected.

light ore
#

Hi, Im on Unity 2021.2.0b16.3733, URP 12.1.0, Hybrid renderer 0.11.0-preview.44

#

And on android platform.
On attempting to build the project, I get the following error:

#

Shader error in Universal Render Pipeline/Unlit: The DOTS_INSTANCING_ON keyword requires shader model 4.5 or greater ("#pragma target 4.5" or greater), at /NewUnity Projects/Android 2021.2ecs/Library/PackageCache/com.unity.render-pipelines.core@12.1.0/ShaderLibrary/UnityInstancing.hlsl(50)

uncut rover
#

Use of UNITY 2021 and DOTS packages is discouraged (https://forum.unity.com/threads/notice-on-dots-compatibility-with-unity-2021-1.1091800/) that being said, some managed to make it at least partly work : https://forum.unity.com/threads/dots-and-2021-2-known-issues.1183456/#post-7579792

light ore
#

Surprisingly, on unity 2020 Dots hasnt been working for me, to say the rendering part at least.
Spent 3 days working thru many unity versions and I came to this-

Unity 2019.4, Entities do get rendered (HybridRendererV1 only is supported), but they dont support Skybox/Ambient/Environment lighting.

Unity 2021.1, and even Unity 2020,
The entities never get rendered, no matter how much time is spent on "Importing EntityScene" (on the bottom of unity program where it shows loading).
On the scene view, on clicking the Subscene object, its forever stuck on Importing...
I spent 6 hours yesterday on trying out diff things like new subscenes and hitting saves and whatnot, but it didnt ever show up.

But, Unity 2021.2.0b16, a beta version of unity, seems to show the entities properly (as of now too), and it supports Skybox/Ambient/Environment lighting (probably cuz of HybridRendererV2)

#

And to see it now stuck on the build error, makes it more... Ugh

#

Oh and, on the Unity 2020, Entities do show up on PC build platform (Idk if I had URP set up in the graphics, but it did show)
Switching to Android build, and making a few changes as setting the URP to work, and it didnt show up afterwards

#

:/

#

I wish I could downgrade the URP version of possible? Tho I'm not finding an option how to with my searches

uncut rover
#

I can tell you I've experienced issue with subscenes and unity 2020 when have Entities + UITK+ new input system. that resembles your "infinite" import issue. I tested the latest 2021.1 version but have a bunch of errors.
Can you share you build configuration for this project ? maybe it will give more hints on the issue.

coarse turtle
coarse turtle
#

o right, 2021.1 should be 11.x.0, thnx πŸ‘

safe lintel
#

@remote crater didnt follow the entire convo but afaik trigger/collision stuff doesnt support parallel yet. i think its on the physics guys todo in the future(not sure when though)

light ore
#

@uncut rover @coarse turtle
Pinging as if to reply to the conversation

Sooo there was a "temporary solution" posted on the forum by somebody where I had to edit the UniversalTargets.cs of the URP package, and now it builds with no issue.

And now, to my another surprise (whew its been many surprises lately), the mobile screen is flickering like crazy, as if brightness is going rapid up-down, you know (Checked the player settings and its alright it seems)

Welp, I'm going to instal unity 2020.3.6f1 with URP 10.5.0, which seemed to be stable for Somebody on the forum. Nevertheless I want to give it a try and see how it goes
Posts a dead emote

muted star
#

Hello everybody, I want to use GetComponentDataFromEntity to modify the translation of an entity but for some reason it takes no effect. What can I do to address this?

public class UnitMoveToTargetSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            var allTranslations = GetComponentDataFromEntity<Translation>(false);

            Entities.ForEach((Entity unitEntity, int entityInQueryIndex,
                in HasTarget hasTarget) =>
            // ref Translation translation,
            {
                var translation = allTranslations[unitEntity];

                translation.Value.x += 0.1f * deltaTime;
            }).Schedule();
        }
    }
left oak
#

you have to then assign translation back to allTranslations, yeah?

muted star
#

Wow that was easy, thanks I was really banging my head against a wall ^^

left oak
#

np, just keep in mind these are all copied by value, not reference

tribal pollen
#

LocalToParent keeps starting with a value of 0 >_<

muted star
#

I'm stuck again. When I run this system I get an error. Any ideas what be going wrong here?

#
public class FindTargetSystem : SystemBase
    {
        protected override void OnUpdate()
        {
            var targetsQuery = GetEntityQuery(typeof(Target));
            var allTargets = targetsQuery.ToEntityArray(Allocator.TempJob);

            var allTranslations = GetComponentDataFromEntity<Translation>(true);

            Entities.WithReadOnly(allTranslations).WithNone<HasTarget>().WithAll<Unit>().ForEach(
                (Entity entity, int entityInQueryIndex) =>
                {
                    float3 unitPosition = allTranslations[entity].Value;
                    
                    for (int i = 0; i < allTargets.Length; i++)
                    {
                        var targetEntity = allTargets[i];

                    }

                }).Schedule();

            allTargets.Dispose();

        }
    }```
#

|| InvalidOperationException: The previously scheduled job FindTargetSystem:OnUpdate_LambdaJob0 writes to the Unity.Collections.NativeArray`1[Unity.Entities.Entity] OnUpdate_LambdaJob0.JobData.allTargets. You must call JobHandle.Complete() on the job FindTargetSystem:OnUpdate_LambdaJob0, before you can deallocate the Unity.Collections.NativeArray`1[Unity.Entities.Entity] safely. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <ca496b8c93454b2f9b9924292c19379f>:0) Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Dispose (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel) (at <ca496b8c93454b2f9b9924292c19379f>:0) Unity.Collections.NativeArray`1[T].Dispose () (at <ca496b8c93454b2f9b9924292c19379f>:0) Code.Systems.FindTargetSystem.OnUpdate () (at Assets/Code/Systems/FindTargetSystem.cs:70) Unity.Entities.SystemBase.Update () (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/SystemBase.cs:412) Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:472) UnityEngine.Debug:LogException(Exception)...||

#

|| Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/Stubs/Unity/Debug.cs:19) Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:477) Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystemGroup.cs:417) Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ComponentSystem.cs:114) Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/ScriptBehaviourUpdateOrder.cs:333)||

whole gyro
#

You want to use WithDisposeOnCompletion(allTargets) on your forearch call.

tribal pollen
#

@muted star instead of calling allTargets.Dispose();
try adding
.WithDisposeOnCompletion(allTargets)

muted star
#

Thank you that was the problem. This error message really confused me πŸ™‚

whole gyro
#

Also, it looks like you could add the entity translation as an argument to your ForEach() call since you don't need the random access of GetComponentDataFromEntity().

muted star
#

I think I need it this way, here is the full code I have so far for this system

whole gyro
#

Ah okay, I was about to ask if this was the entire system or not. Looks good to me

muted star
#

I still get a different error though ^^

#

Here it is if you want to take a look

whole gyro
#

Looks like an error with your UnitMoveToTargetSystem. Based on the error, I would guess that you don't have WithReadOnly(allTranslations)

muted star
#

Ah my bad yes just realized that

whole gyro
#

No worries. I normally can't decipher these errors in my own project so I'm glad I could help haha.

karmic depot
#

Does anyone have a hack to show BlobAssets in entity's inspector?

viral sonnet
#

I don't know why DynamicBuffer doesn't scale. I've lots of complex systems but those that are just for clearing a DynamicBuffer take the longest. I've checked dependencies now and gone back to Run() for these systems, no real reason to be found.

#

one of these clearing systems takes half the time of the whole frametime. completely absurd 😦

devout prairie
#

Maybe as an alternative have a bool flag inside the IBufferElement's to mark as active or updated, and basically try just never clearing?

viral sonnet
#

makes no difference when it's inside the buffer, the mere existence of the ForEach with the DynamicBuffer slows it down. (the buffers aren't used, so size is 0) - What I really need to do is not iterate over every buffer so I'd need to build some IComp flag. Really annoying ...

#

and again, not sure what's going on that takes so much cpu time. the buffer is 0. meh, it's always what happens when I use DynamicBuffer. The NativeMultiHashmaps scale much better. And to think DynamicBuffers are NativeArrays really

#

was stupid to use them to begin with, per-frame data shouldn't exist on entities

#

I got rid of most of those cases but some trigger buffers are left over

devout prairie
#

just out of curiosity if you don't mind me asking - how else would you use a buffer other than a for each and why are the size 0?

#

ah i think i see what you mean, so you're using the existence of the buffer as part of the query in a way for the for each

viral sonnet
#

sorry, I meant Entities.ForEach

#

yeah

devout prairie
#

so you've found even if the buffer size is zero it slows the ForEach job down?

viral sonnet
#

that's what happens

devout prairie
#

that's interesting πŸ€”

viral sonnet
#

i have a stress test running, 250k entities with such a DynamicBuffer and the Entities.ForEach takes around 10ms

#

I can ScheduleParallel it, to bring it down to 1.26ms but that's still too much for what's happening.

devout prairie
#

have you tested with just a tag instead of buffer to see what the difference is?

#

cos obviously the 1.2ms would depend on what else the job is doing

viral sonnet
#

Just using an Entities.ForEach with a tag that is on the same entity takes 0.75ms of iteration time

devout prairie
#

that's interesting to know..

viral sonnet
#

that's with Run()

#

so, yeah, factor 10 with just using a DynamicBuffer in the query

devout prairie
#

so does the IBufferElementData contain a bunch of different members

#

like even if it's empty, is it say just a struct with one bool or is it a bunch of different data

viral sonnet
#

the buffer has a struct with 2 Entity structs, 3 ints and 1 ushort.

#

another system uses a more complex buffer and the timings are rather equal. so size doesn't matter too much it seems

devout prairie
#

i'd guess the job has to allocate and deallocate memory for that maybe that's the issue.. if there's say a job running a query of 250k entities and each entity could have any number of buffer elements, maybe the allocation is the overhead

viral sonnet
#

I don't know, from my experience now I'd say don't ever use DynamicBuffer when a) it's on a lot of entities and b) when it's fast changing data, like for only 1 frame

#

the buffers should be allocated by then

hollow sorrel
#

did you set the InternalBufferCapacity

viral sonnet
#

I guess the buffers are all over in memory so that's why iteration is so slow

devout prairie
#

yeah just thinking about heap/stack business maybe slowing it down, cache misses galore etc

viral sonnet
#

hm, where would I set the InternalBufferCapacity? It's not a parameter in AddBuffer

hollow sorrel
#

you add it to the bufferelement

#
// InternalBufferCapacity specifies how many elements a buffer can have before
// the buffer storage is moved outside the chunk.
[InternalBufferCapacity(8)]
public struct MyBufferElement : IBufferElementData
{
}
#

try setting it to 0 to force buffers to always be out of chunk

viral sonnet
#

ah, thanks, ok I'll try that

hollow sorrel
#

by default it's occupying chunk space

viral sonnet
#

do you know what's the default value for InternalBufferCapacity?

#

ok that brought it down significantly, not as much as where I'd want it to be but from 10ms to 2.5ms

#

I think my archetype got way too big. Last I checked I could only bring 11 entities into the chunk

hollow sorrel
#

default seems to be 128 / elementsize (basically 128 bytes rounded up depending on your struct size)
but that's per entity so it adds up

#

also yea only 11 entities sounds like a pretty big archetype

viral sonnet
#

cool, saved a bunch of milliseconds, big thanks Scorr!

#

yeah, I need to split it up somehow. Not sure how though, lol. All the data is required. Still, I must be able to bring it down and split it into 2 other references. Hard to say how much I'll gain though

#

maybe I'll rather wait for the new entities version, at some point it should be possible to set the chunk size yourself

#

ah, i see with the capacity change to the buffers I can already fit 15 instead of 11 in a chunk

devout prairie
#

Have you considered splitting off some of you data onto different archetypes or entities assuming you're not using all of it in each job or system

viral sonnet
#

yeah, I wanted to finish the system before I make optimisations. now's a good time πŸ™‚

velvet panther
#

When I do this: using Unity.Collections ; I have access to NativeArray, but not NativeList, why? Unity 2020.LTS and latest Rider

solar spire
#

have you imported the collections package?

velvet panther
solar spire
#

... Why?

velvet panther
#

Because I don't want to download it through Package Manager. The last few times I've given Package Manager access to the internet, it's downloaded multiple versions of just about everything ever seen, and took up many, many gigs.

solar spire
#

Well, if you don't have the package, you can't use the classes. Unity doesn't host it elsewhere, but needle hosts mirrors of everything. I'm sure you can find it

velvet panther
#

Found that. THANK YOU!!!

#

Why the attitude?

#

Having downloaded it, how do I install it?

solar spire
karmic depot
#

how would I make an authoring component for a singleton entity? For example for a ScriptableObject or a prefab, so that it only adds a singleton once.

safe coral
#

Is that what you're asking?

#

Oh sorry, didn't realize I was in DOTS.

safe lintel
#

@velvet panther the package manager will just keep a cache of all packages you've downloaded in your appdata (local or localroaming) folder. it doesnt download things you havent personally needed. you can just delete that folder, but it will always 'fill up' again as you download packages.

devout prairie
#

yeah it's a bit irritating i think people have been asking for years for a way to change the default package cache, pretty sure it also caches paid assets which in some cases are huge

coarse turtle
#

you can change the directory of where it gets downloaded if anything and put it on an different drive

devout prairie
#

is it possible to do that now?

coarse turtle
#

Been that way for a few years

devout prairie
#

how is this wizardry achieved?

#

tbh it's not something i've looked at for a few years, other than to notice i have a pretty big chunk of space being eaten up by the package cache

karmic depot
#

there's an environment variable you can set IIRC

karmic depot
#

UPM_CACHE_ROOT I think edit: was too slow hah

devout prairie
#

ah yeah, i guess this would cover assets also then

velvet panther
#

Each time I bring it up, someone is dsimissive about it, in some way or another, as though it can't happen, or I've done something. I haven't. It's just happening, so I've cut off Unity from having any access to the internet

velvet panther
velvet panther
#

I recently started using Burst... the verified version for 2020,LTS... the next day... 1.6 and a bunch of earlier ones were in there, taking up a couple of gig. This is what first drew my attention to this behaviour.

devout prairie
#

yeah mines about 8gb at the moment and has a couple at least of versions of most of the packages

safe lintel
#

just deleted mine to see what exactly happens on a new project

devout prairie
#

i think the behaviour of assets has changed but it used to be assets would also mirror onto the c drive and it was almost impossible to prevent

#

having lots of large assets was a problem

safe lintel
#

collab, nunit, rider, visualstudio, vscode, test-framework, textmeshpro, timeline are the default for the package cache, theres also a larger npm cache that instantly went to 1.7gb that I assume is copied from the unity editor folder? package folder is only like 50megs though

#

@velvet panther I mean there should be the expectation that in a complex program like unity there will be a fluctuating amount of data with regard to custom projects. cutting unity off from the internet seems excessive to me but idk. you could setup a scheduled task to delete that folder. and if its really doing stuff that seems out of the ordinary and is a repeating factor, you could easily report it as a bug

velvet panther
#

Every X

#

every XR thing ... for example, small, but all there... added, over and over. Your excuse making is weird. NO APP should be downloading such things without express permission.

#

As for bug reporting. I've been using Unity for long enough to know how fruitless that experience is.

#

My general thoughts on the package manager are that it's better than the hub, but not any other part of Unity. And that's right at the bottom of the barrel. Worse than SRP.

#

speaking of DOTS, when can we use Span<T>?

remote crater
#

If I add an IComponentData not used anywhere in program except to be assigned to Entities, will they even be added? I'm trying to just tag something... for some reason the entity doesn't have the iComponentData attached.

coarse turtle
#

A builtin unsafe alternative is using stackalloc

#

or just stick with NativeArrays with Temp allocation

safe lintel
#

maybe unity does need a timed decay setting in which to purge that folder, but if you dont want to report something that is causing you that much frustration well I guess whatever then

devout prairie
remote crater
amber flicker
remote crater
#

My next question and I'm done asking for a while... If you Entity e = EntityManager.Instaniate(pooledEntity); You can then add and remove components. But if you do this with an EntityCommandBuffer Instantiate (pooledEntity) then EntityCommandBuffer RemoveComponent (pooledEntity)... What happens is the pooledEntity gets modified. How can I instantiate a pooledEntity in EntityCommandBuffer then modify the cloned instantiated entity without messing up the original pooledEntity?

devout prairie
remote crater
#

You can do that1?1

#

I thought the entity wasn't made until ECB instantiated after process

#

It makes a reference straight then and there? wow! I would have never guessed that!

devout prairie
#

yeah i'm not sure exactly how that works, i assume it returns a dummy reference and allows you to use that in additional commands

velvet panther
#

int**[] for now... πŸ˜‰

remote crater
#

That's really cool MidnightCow... The Unity Devs reallythought it out

#

Makes you wonder if they know about phantom references why we can't link Gameobjects as entities in scene

#

Should be trivial... Maybe they didn't care.

devout prairie
#

i think that's just more to do with using reference types and managed objects which is kinda anti-data-oriented

#

basically anything that is a class and not a struct or anything that is stored in managed memory is going to drag down your ecs systems performance so it kinda defeats the purpose

#

if i understand your meaning

coarse turtle
#

good to know too cause I just updated to 2021.2 lol

muted star
#

Hey everyone, how can I get the entities from a chunk (not the components)?
Something like this would be nice var entities = chunks[0].GetEntities()

#

I'm asking because I'm currently trying to optimize a job, so far it's gone horribly wrong. Maybe my approach is just wrong.

#

The current job is receiving NativeArrays instead of batches since I don't know how to get the entities from a batch

coarse turtle
# muted star The current job is receiving NativeArrays instead of batches since I don't know ...

I think you want to look at IJobChunk/IJobEntityBatch instead as they natively allow you to do chunk iteration.

To get the Entities of the chunk it'd would look like so

struct SomeJob : IJobEntityBatch {

  public EntityTypeHandle EntityType;

  public void Execute(ArchetypeChunk chunk, int batchIndex) {
    var entities = chunk.GetNativeArray(EntityType);
    for (int i = 0; i < chunk.Count; i++) {
      Entity e = entities[i];
      // Do something with e
    }
  }
}
// In SystemBase
new SomeJob { EntityType = this.GetEntityTypeHandle() }.Schedule(someEntityQueryToIterateThrough, Dependency);

https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_ijobentitybatch.html

karmic depot
#

Can I fill in a BlobArray by passing existing BlobAssetReferences instead of actual values?

#

or rather, is this legal: BlobArray<BlobAssetReference<SomeRegularStruct>>?\

remote crater
#

Let me show my code, I think its similar to what you gave.

#

Above is declared entity e, and the array is my object pool buffer of one entity each.

uncut rover
# karmic depot or rather, is this legal: `BlobArray<BlobAssetReference<SomeRegularStruct>>`?\

In entities 17 it is not, it will be in the next versions. The issue is that a validation method in hte entities pacckage does not allow for generic type.it can be fixed if you make a local copy of the entitites package https://forum.unity.com/threads/blobarray-with-valuetype-generic-parameters-fails.1045639/

karmic depot
uncut rover
#

As long a you release it properly I don't see an issue, but I'm no expert ;).

karmic depot
#

what do you mean release?

uncut rover
#

Blob asset are unmanaged memory allocation so they need to be disposed/released when no longer needed. if you dispose of the 'high' level blob it will not automatically dispose of the blob inside it, so you should probably do somthing not to leak memory.

karmic depot
#

are you sure about that? I thought they become part of the subscene and get disposed along with it

uncut rover
#

hmmm... I don't know if subscene do something 'magical', I'm not using them rigth now (issue with UITK+entites+Input system, long story...) but blob are not restricted to subscene so I don't see why subscene in particular would make the blob behave differently. Maybe the blobassetstore does the job. To be honest I make a blobasset reference on start up of my game and never destroy it so either I'm leaking memory or something magical happen on game shutdown. Either way, I will probably need to test it further at some point (once I figure out how to profile such cases) but I would not bet on thing happening automatically.

devout prairie
solar spire
velvet panther
solar spire
#

Are you looking at the local Packages folder?

#

The one in your project?

velvet panther
#

No, the one in the user root library.

solar spire
#

Then that's not where you install packages manually into a project.

velvet panther
#

I'm not currently discussing that, I'm replying to the bloat!

#

That didn't work. I tried that means from disk.

solar spire
#

My reply was directly discussing that

velvet panther
#

My mistake, I thought you were making the same claim that everyone makes about the packages folder in the library, that it shouldn't have all that extra stuff in it.

#

I've cleansed the manifest, etc. It still happens. Deleted all but one install of Unity (only using 2020.LTS on this) and it's still happening if I turn off Little Snitch for a sec.

solar spire
#

I just have a symlink for my packages directory. I just stick the entire Unity cache on a large drive

safe lintel
#

hey vertx while youre here, I think the dots wiki in the pinned messages should be removed, its kinda old and no one updates it and some of the info is a little bit "eh" and I dont have the desire to go sort it out(as a previous contributor)

solar spire
#

Sure, is there anything that should replace it? Or are we all just waiting for Unity to come out of hiding before recommending ECS πŸ˜›

devout prairie
#

when Unity Unity's..

safe lintel
#

Not sure theres any replacement but tbh the regular forums are better(though not really organizedπŸ™ƒ)

remote crater
#

Amatuer cow, I'm on 28 min now in one of my projects I am working on

#

key is to work on more than one project at once

#

Then when one is loading, you're coding in another

remote crater
#

So my original question stands: How do you use an EntityCommandBuffer to instantiate an entity from an entity then add or remove components without affecting the original entity?

devout prairie
#

Bear in mind also if it's a parallel job you should use a parallel ecb and pass entityInQueryIndex into the job

remote crater
#

Entity e;// Just declared.

#

I can post full code after a nap, adrenal fatigue got me. brb in a few min/hrs.

devout prairie
remote crater
#

wow

#

it was the var

#

somehow the var is generic enough to break typecasting or something

#

var e=ecb.Instantiate(firstEntity[index]); works

#

Thanks Cow, you da man... cow... maybe minotaurish thinger

devout prairie
remote crater
#

Thank you very much once again!

#

I actually smashed through two brick walls today.

#

One the reason entities were not rendering on my standalone had something to do with an HDRP configuration file. I'll figure the details later.

#

The reason I could not delete stuff before was because when I instantiated from an entity(pseudo object pooler), it was removing disabled and such from live components, rendering them able to be destroyed.

#

So now stuff is pretty good. I hope to finally get a standalone working and see how much I can render for real!

#

Also my players will like an update to benchmark their rigs.

#

Very cool, very cool, very cool, praise God. Ok, nap time for real. Remember, anyone who helps me, If I make bank, you make bank, but you gotta remind me. I get help from TONS of cool people. That's one thing that has made the Internet great as long as I've been on since 1994, the silicon valley tech worker desire to help others.

muted star
muted star
#

Is it just me or is SystemBase slightly slower than JobComponentSystem?

haughty rampart
digital kestrel
#

according to your picture

muted star
#

It had lower average fps but maybe that was because of a mistake on my part, I may have had a memory leak I didn't notice

digital kestrel
#

also does anyone's VS debugger get stuck in "Application.EnterPlayMode"

#

it's been 5 minutes

#

half the time my debugger gets stuck and crashes

muted star
#

No but you may try to enable fast enter playmode

digital kestrel
#

i have that enabled already

#

what's the difference between GetEntityQuery and EntityManager.CreateEntityQuery

haughty rampart
digital kestrel
#

makes sense, they're functionally the same though

haughty rampart
#

pretty much

digital kestrel
#

nice

coarse turtle
karmic depot
#

GetEntityQuery also attempts to cache the query

devout prairie
#

Anybody ever had the issue where suddenly most of the systems have just vanished

#

i removed a plugin folder and replaced it with newer version and now when i run most of the dots systems are just gone, including my own systems

#

This is all i'm left with..

#

No errors or anything, all entities/physics/etc packages still installed etc as before

karmic depot
devout prairie
#

yeah they seem to be, in Library/PackageCache

#

i wonder if i delete them all they'll automatically replace

karmic depot
#

they should, yea

devout prairie
#

deleting whole library folder, see what happens

tribal pollen
#

How do people generally handle most of unity's UI related things in dots? for example, GUI hub, displaying text/damage numbers in game or opening temporary skills/option panels?
Do you display them with normal unity components with monobehaviours, then use events to update them?
I could see that working for the UI hub, curious if there's a more pure ECS way.
Also, really curious how we'd spawn damage numbers to display...
Sorry if this is vague or basic πŸ˜›

coarse turtle
#

For 2D I just ended up writing out mesh data to display text and have a render pass draw it out in URP.

#

Shameless plug: https://forum.unity.com/threads/in-development-nimgui-a-1-draw-call-immediate-mode-gui-for-unity.1171601/
But I'm building this out so you can use immediate mode API to draw out UI via SystemBase or MonoBehaviour which is pretty much what I'm describing with building out the meshes and having a renderpass draw out the UI.

tribal pollen
#

all good need something like that to be standards.
Is there a nice list of hybrid components somewhere?
if I simplified things to attempting to spawn damage numbers (3d world), what's the best way?

coarse turtle
#

So you convert your entities as usual and unity internally tracks and create a hidden gameobject

#

I don't know how well it works with Unity's UI, mainly because I imagine you have to convert everything (including the canvas)

tribal pollen
#

Yeah the requirement of a canvas is why I couldn't just spawn some of the things I tried.

coarse turtle
#

I say start simple, figure out a way to get data from entities (maybe via events or write data to static container and at the end of the frame read the data from a monobehavior and display it)

you might need to double buffer if you're doing a lot of stuff in parallel and writing to a static container so that you don't mess with read/write access (so after jobs are completed, copy it over to a new buffer to avoid race conditions).

tribal pollen
#

If i wanted to create UI items during gameplay, how would I attach them to a canvas?
I feel like I could get a static GUI to work in a couple of ways like you just said, but the playtime display changes are a bit more confusing

coarse turtle
#

Well I'm more describing writing data that needs to be displayed to a static container (not a static GUI)

#

so it'd look sometihng like this

tribal pollen
#

well anything that's existing when you start the scene

#

so the stuff that doesn't exist statically, and might only be displayed for a few seconds at a time. Those spawned UI pieces are still pretty unclear to me right now

#

an image or prefab would be fine, but text and numbers that could change. idk

coarse turtle
#
// In a SystemBase
NativeArray<int> data = SomeStaticClass.NativeArray1; // Or use SharedStatic
NativeArray<int> data2 = SomeStaticClass.NativeArray2; // Our double buffer
Deps = Entities.ForEach((...) => {
  data[x] = some_data;
}).Schedule(Deps);

Deps = Job.WithCode(() => {
  for (...) {
    // Copy the data to double buffer, so we have a safe readonly data
    // for our gameObjects
    data2[i] = data[i];
  }
}).Schedule(Deps);

// In a monobehavior attached to a gameobject
void Update() {
  for (int i = 0; i < SomeStaticClass.NativeArray2.Length; i++) {
    // Your text mesh is cached and already created or pooled
    // and managed by a MonoBehavior
    someTextMesh.text = $"Data: {SomeStaticClass.NativeArray2[i]}";
  }
}
tribal pollen
#

kk then I guess that textmesh would be part of a prefab with that mono attached, and then you spawn it, having it's mono fetch the data

coarse turtle
#

Yea something like that

tribal pollen
#

kk, my thought's weren't far off the mark, I just didn't think to attach a mono to a textmesh prefab lol

#

thanks man.

karmic depot
#

The Entities.ForEach statement contains dynamic code that cannot be statically analyzed. what the hell does that mean, lol

devout prairie
#

What in the f* could cause this.

karmic depot
devout prairie
#

Even the unity package systems are missing

#

animation, physics, whatever else

#

last thing i want to do is have to setup another project and copy all of my assets etc over

digital kestrel
#

how do you guys reset / reload a scene

#

SceneManagement.LoadScene doesnt seem to reset the World

digital kestrel
#

i finally got 100k entities rendered using texture based bone animations

#

no LOD or culling though

#

shits pretty nice

devout prairie
digital kestrel
#

i used shader graph

#

used a custom function node and basically injected all the instancing code into it

#

i wish there was an asset

#

look at the Austin Untiy ECS demo

#

has everything you need

#

@devout prairie

devout prairie
#

Have you looked at implementing AI in some way?

digital kestrel
#

what kind of AI

devout prairie
#

I wonder what different approaches there could be to automating 100k characters

digital kestrel
#

you basically need to be really good at parallelizing your code

#

and optimizing it for BURST

devout prairie
digital kestrel
#

i use A*

devout prairie
#

true yeah

digital kestrel
#

Nav mesh would work too

devout prairie
#

do you have physics bodies for collision or raycasting for ground or anything like that?

digital kestrel
#

no lol

#

that would kill my pc

devout prairie
#

is your ground flat?

digital kestrel
#

if you want them to stay grounded you can sample a heightmap or something

#

and set it to that height

devout prairie
#

yeah i was thinking heightmap is an option

digital kestrel
#

my ground is flat, yeah

#

i haven't gotten that far yet unfortunately

#

wish i could be more helpful

devout prairie
#

just thinking out loud tbh i'm using Rival at the moment and it scales really well to thousands of ai with collisions etc

#

but not 100k hehhe

digital kestrel
#

yeah i have Rival as well

#

was good at like 30k in a build on my PC

devout prairie
digital kestrel
#

yeah i think Rival raycasts each character controller against the ground

devout prairie
digital kestrel
#

it's unfortunately not the most efficient way, but it's very good for a generic controller

#

i saw that

#

I talked to other ppl here who said that they're(Unity) basically going to develop a tool for ECS that does all of it for you anyway

#

so all the legwork you do now might not be very efficient use of time

#

i tend to agree

devout prairie
#

yeah it's a really good robust controller with lots of great features, maybe not applicable to 100k characters but it does work well for very reasonable numbers

digital kestrel
#

the shader based stuff I would say is easier and more efficient to do imo

#

than using the DOTS animation package

#

which relies on the DOTS Node package too

#

with barely any documentation. very steep learning curve

#

not as efficient as shader based gpu skinning either

devout prairie
#

yeah the dots animation package is i think a really nice starting point for what it is, but for skinning for sure there are more hyper-efficient ways

#

i think currently the simpleanimation system is building/updating the graph each frame etc

#

significantly faster than skinnedmeshrenderer though

digital kestrel
#

yeah i forgot the reason why

#

i think they were loading the skinning info into a compute buffer and calculating the transforms in a compute shader

devout prairie
#

tbh i think the overhead of Animator has a lot to do with it

digital kestrel
#

not really sure

#

the disadvantage of baking bone transformations into a texture is

devout prairie
#

so i think possibly the skinning and deform stuff was fast, but damn the animator is just a pain to use and slow

digital kestrel
#

that there are no blend trees for lerping different animations

devout prairie
#

was limited to circa 1-200 characters depending on complexity

digital kestrel
#

also the Austin demo limited it to 2 bones per vertex instead of the typical 4

devout prairie
#

yeah so is there no way to lerp with that system

#

not possible to sample the textures themselves to lerp or something

#

if you find a way to do 100k ragdolls with skinned meshes let me know πŸ™‚

digital kestrel
#

lol

devout prairie
#

i've built a ragdoll system that works with physics joints and basically overwrites the AnimatedLocalToRoot components on the skinned characters

#

it's faster than traditional unity ragdolls but i think could be faster still

digital kestrel
#

wow, nice

#

how'd you make it faster

devout prairie
#

well it uses a ragdoll built with unity.physics joints

#

then the systems that transfer data are parallel and bursted

safe lintel
#

how many ragdolls can you get going before a slowdown?

#

i think i had issues where it slowed down between 250-500

spice steeple
#

hi, is subScene.sceneGUID static, and if so is there a way to access it in the editor somewhere, without having to do it through scripts?

digital kestrel
mild ledge
#

Lets say I want to use DOTS just for the bullets in my game and have everyrhing else be normal. Is that possible and not a total clusterduck to achieve ?

amber flicker
minor sapphire
#

I came here to watch the live reactions.

#

But so quiet :)

devout prairie
#

To be fair, that sounds to me like an incredible performance optimization to an already incredible system..

#

runs away

amber flicker
#

You can use ISystemBase now if you want to see what it's like. It is an improvement but also a massive headache to avoid everything managed. I'm sure they'll make it easier. I'm more interested to hear of the optimisations to the type handle stuff.

deft stump
#

you guys have any sample code of getting the distance between 2 objects written inside normal Jobs?

#

or wait does the math library have that? (checking)

devout prairie
karmic depot
#

is branching code totally not supported in Entities.ForEach?

karmic depot
# frosty siren what u mean?

I'm trying to do sort of a "add or update" on a NativeMultiHashMap, using TryAdd. I'm getting an error The Entities.ForEach statement contains dynamic code that cannot be statically analyzed

#

there's an "IsUnsupportedBranch" check in CecilHelpers, which I think triggers that. But I don't understand those analyzers

digital kestrel
#

ruh roh

#

I remember they promised Unity 2021 DOTS support by like December

#

It's practically Nov and no update

digital kestrel
karmic basin
#

It was more in line with " incompatibility above 2020.3 at least until end of the year"

#

We have no estimate whatsoever, so could be Q2 2022, or worse

#

we just don't know

digital kestrel
#

i would guess late Q1 or Q2 like you said

karmic depot
#

I wonder if they have a dependency on changes needed to Unity Editor, so they can't even say if next version of Entities will be released to the public.

devout prairie
#

Any reason why dots animation and physics may play slowly or at a different rate, independent of framerate?

#

Having yet another weird issue.

karmic depot
#

does Entities.ForEach exclude Prefabs by default?

coarse turtle
#

even in entityqueries they're not included by default

#

unless you enable the option to query them in the EntityQueryDesc

whole gyro
#

Hey @digital kestrel, with your animation system, are you able to read the animated bone positions on the CPU? For example, let's say I wanted a character to be holding an item in their hand, but the character's arm and hand are being animated using your texture-based animation shader. Is there a way to do this?

#

I guess one option is to have the shader moving all the mesh vertices, and separately some CPU code that also reads the animation textures and writes to bone positions.

#

I'm currently using the animation package, but it seems a bit overkill. I don't need blending or multiple bone weights per vertex.

digital kestrel
#

not really

#

if you knew the final position, you'd just pass that to the GPU instead of handling the skinning in a shader

#

you would have to recalculate it on the CPU which would defeat the purpose

#

the advantage might be that you can skip the calculation for everything else (other body parts)

#

which could save you some time

whole gyro
#

well gpu would be moving all the vertices for you. cpu would just be moving the bones

digital kestrel
#

all the bone positions are baked into the texture

#

so the CPU doesn't do any bone transform calculations after the initial pass

#

it just sends the animationa's normalized time value and uses that to sample the texture which has the bone positions

whole gyro
#

Yeah, I understand that part. I meant cpu could sample the baked texture and move some bone entities around. This allows for things like item attachments.

digital kestrel
#

yeah

#

you could bake all of the transforms for the hand

#

and store that on the CPU and just apply it exactly how you would on the gpu

#

like you said

#

no need to store it in a texture, just store it as a separate float4x4

whole gyro
#

yeah good point about not needing a texture on cpu side

digital kestrel
#

it would be a lot more efficient since you're only calculating one bone per mesh instead of all N bones, and applying world transforms would be trivial

#

especially if you vectorize it correctly

whole gyro
#

yeah seems it could work well

digital kestrel
#

if you need blend trees, i wouldnt use texture based animation

whole gyro
#

I guess another considering is to do all the animation on the cpu side with the baked bone positions. I think I would need a separate mesh/entity for each bone. However, I like the idea of my characters being a single mesh, even if I don't need multiple bone weights. Makes it easier to apply material properties to the entire character.

whole gyro
#

But yeah, at that point, I would just use the animation package.

digital kestrel
#

you can lerp them yeah

#

it would cost twice as much for 2 animations

whole gyro
#

Thanks for the insight @digital kestrel! Not sure if I'm ready to switch to baked animations yet but good to know what is possible.

digital kestrel
#

i might release it on the asset store for like $10 lol

karmic depot
#

How am I supposed to pass BlobAssetReference to a IJobEntityBatch? I'm trying through a public field on the job and doing ref var array = ref TheReference.Value.SomeArray and debugger shows random numbers instead of what I expect 🀨

rotund token
#

You can't pass the value like that

#

Pass the actual blob asset or clone the value

karmic depot
rotund token
#

just pass in BlobAssetReference
var myAsset = MyBlobAsssetReference;

#

job.withcode(() => { ref var array = ref myAsset.Value.SomeArray; }).Schedule()

#

should work from memory

#

(been a while since I've used a blobassetreference that isn't attached to an entity, i have my own custom memory system that i use instead for memory not on entities)

karmic depot
#

interesting. thanks I'll try that tomorrow

robust scaffold
#

Holy shit, Unity is alive.

#

No info but the CTO is once again on the forums. Entities 0.20 ETA has moved from "Heat Death of the Universe" to "Sometime next year".

devout prairie
#

Misgivings over timescales aside, i think it's insanely cool that the co-founder is still balls-deep in the technology. A great many software companies have long since sold off and being run by money managers. I really genuinely believe what Unity is doing with dots/ecs will be massively transformative, but i do think it will take some time to achieve.

#

It can be frustrating i think but it's really cool to be in for the ride, and given access to the tech while it evolves. It feels less like a marketing exercise and more like a genuine contribution to realtime/game-engine technology.

digital kestrel
#

He started Unity at 19 lol

pliant pike
#

I didn't even realise he was the Co-founder leahWTF

safe lintel
#

yeah, its awesome hes super hands on with dots. I dont think I wouldve been an early adopter if we didnt have someone at his level of clout in unity being this enthusiastic about it

haughty rampart
#

how do we know 0.20 got moved from "Heat Death of the Universe" to "Sometime next year" ?

safe lintel
#

we dont really πŸ₯²

gusty comet
#

anyone know:

If I use ConvertToEntity scripts on an object with lightprobes component attached, will the lightprobes still work correctly?

robust scaffold
half jay
#

I have android app and in scene there are a lot of simple box colliders may be about 200k. Im using only one raycast and thats all. No collisions events or any rigidbody objects. So i have this profiler screen. Any tips or suggestion what should i check or what going on ?

last jasper
#

does Hybrid renderer v1 work with per-entity material properties in 2020.3.20f1? I try the override property declaration/hybrid per instance and it does not seem to work

amber flicker
last jasper
#

nope, webGL

#

v2 doesn't work for webGL but v1 does 😦

#

The mad thing is I have another project where the per-entity props worked fine and I can't seem to figure out why it doesnt in this one

half jay
#

i have problem with v2 on android and unity 2020.3.20f1

amber flicker
last jasper
#

same material on all ships, and a '_TeamColor' material property

devout prairie
#

I think the default is something like this:

#

Whereas i had cloned the Unity Physics Samples project, deleted all assets and scripts, and imported my own assets and scripts into this. It took me some time to realise the the Physics Samples project uses these settings, which essentially seemed to slow everything down:

#

Physics samples also has some code that sets:
Application.targetFrameRate = 60
I'm not exactly sure of what the implications are of all this, how these settings interact, but that's where the issue was.

gusty comet
frosty siren
gusty comet
safe lintel
#

they should, probes get a companion gameobject on conversion @gusty comet tbh Im not too familiar with companion gameobjects and subscenes

#

I view anything outside of just plain vanilla rendering kind of experimental when it comes to dots graphics, light baking is kinda glitchy, the actual results with stuff like spotlights only show as point lights, occlusion is buggy etc

karmic depot
#

speaking of Companions, I recommend adding DOTS_HYBRID_COMPONENTS_DEBUG define to see companion objects in scene hierarchy when needed

velvet panther
#

When writing a sequencing system, and wanting to ensure that it's possibly suited to Burst/Jobs if needed for performance, should it be that all the system exist in one class, and use structs for any separations of data/state and methods? And are static arrays OK?

gusty comet
karmic basin
north bay
#

Uhmmm

devout prairie
frosty siren
full epoch
#

good news finally πŸ™‚

pliant pike
#

I new it wasn't dead leahPOG ....(I didn't)

haughty rampart
#

dots was never dead

digital kestrel
#

They had to smooze the board before they could say anything to the peons >.>

half jay
#

Does Hybrid Renderer V2 need Vulkan API for android?

stiff skiff
#

It would be nice if they actually proved a timeline however

#

Because soontm Can be anywhere between next week to Q2 next year and beyond

pliant pike
#

timelines are bad because predicting how long this stuff takes is nigh on impossible

#

isn't there a saying with programming, that however long you think its going to take its going to be at least twice as long

shut hare
#

is querying for reference types as fast as for the data structs ?

#

lets say a Player monobehaviour and a PlayerData struct

haughty rampart
shut hare
# haughty rampart you cannot use reference types with dots. there are some .....workarounds but yo...

Yeah you can i saw that in the FPSSample i wondered what was the drawback

[DisableAutoCreation]
 public abstract class BaseComponentSystem<T1> : BaseComponentSystem
     where T1 : MonoBehaviour
 {
     ComponentGroup Group;
     protected ComponentType[] ExtraComponentRequirements;
    string name;

     public BaseComponentSystem(GameWorld world) : base(world) {}

    protected override void OnCreateManager()
     {
         base.OnCreateManager();
        name = GetType().Name;
         var list = new List<ComponentType>(6);
        if(ExtraComponentRequirements != null)        
            list.AddRange(ExtraComponentRequirements);
         list.AddRange(new ComponentType[] { typeof(T1) } );
        list.Add(ComponentType.Subtractive<DespawningEntity>());
         Group = GetComponentGroup(list.ToArray());
     }
 
     protected override void OnUpdate()
     {
        Profiler.BeginSample(name);

         var entityArray = Group.GetEntityArray();
         var dataArray = Group.GetComponentArray<T1>();
 
         for (var i = 0; i < entityArray.Length; i++)
         {
             Update(entityArray[i], dataArray[i]);
         }
         
        Profiler.EndSample();
     }
     
     protected abstract void Update(Entity entity,T1 data);
 }

#

i am looking for a solution to have an event when a player is instantiated without the start() callback so i turned to ecs

#

it looks like you can query monobehaviours

haughty rampart
#

i am not quite sure what that code does. nevertheless, it is vastly outdated

haughty rampart
shut hare
#

no ofc not but i'm trying to keep it at bay until its done

haughty rampart
amber flicker
shut hare
shut hare
haughty rampart
#

why do you not want to use the callbacks??

haughty rampart
#

if you want to use monobehaviours anyway, using dots to query for them is just a stupid idea

shut hare
haughty rampart
amber flicker
# shut hare Much slower than OOP ?

No. But if performance is your concern, you’ll have to run some tests with the type of data you have and the kind of transformations you want to do.

haughty rampart
#

i don't think you have an idea what dots is for. if you don't want the callbacks, just use your own methods

muted star
#

How do I use RequireForUpdate correctly? If I use it like this the system seems to stop running for some batches which match the query.

        {
            endSimulationEcbSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
            
            unitsWithoutTargetQuery = GetEntityQuery(new EntityQueryDesc
            {
                All = new[]
                {
                    ComponentType.ReadOnly<MoveOrder>(),
                    ComponentType.ReadOnly<Unit>(),
                    ComponentType.ReadWrite<Translation>()
                },
                None = new[]
                {
                    ComponentType.ReadOnly<HasTarget>()
                }
            });
            RequireForUpdate(unitsWithoutTargetQuery);
        }```
karmic basin
#

Looks okay at first read. You're saying you still have units without target that dont get processed ?

#

Never saw = new[], always saw = new ComponentType[] can you really be non-strict here ? πŸ€”

karmic basin
#

Oh good πŸ™‚

#

I don't see anything wrong in FlightFight code πŸ€·β€β™‚οΈ

#

Something else might interfere

muted star
karmic basin
#

If you really wanted to interrupt the system another way would be to calculate count on the entity query and early exit in update

sacred rune
#

Is there an equivalent to MonoBehaviour.OnRenderObject() but for DOTS/ECS?

coarse turtle
kind turret
#

are the terms "DOTS" and "ECS" interchangeable? i've been calling everything ECS

sturdy rune
#

Dots is data oriented technology stack, Unity's new approach to game development based on data oriented design. Ecs is entity component system, a piece of the dots "stack", Unity's way of connecting game design to systems and data.

#

So no. One is a component of the other, one is made of many components

velvet panther
#

the "TS" in DOTS stands for "technology stack" but it was a contrived name, to give them some sense of accomplishment when they realised that ECS was years away from being ready. Hence the switch in naming, from talking about ECS and performance by default to "DOTS", so they can claim some parts of it are done. (Jobs and Burst are fully operational).

solar spire
#

The name DOTS existed since they announced ECS, Jobs and Burst. They still talk about performance by default, they were separate and similar concepts introduced at the same time.

#

If you're talking about its elements, say them by name, if you're talking about them under an umbrella say DOTS.
People will know what you're talking about if you mix them up, but don't go talking about Jobs as if it's ECS for example.

kind turret
#

ok thanks

velvet panther
#

Look around the boards, the forums, in here... Stackoverflow, Reddit, conversatiosn in the real world. Anywhere you like. Many even write "DOTS/ECS" or "ECS/DOTS" when discussing them, just a way to be sure they've covered all bases.

solar spire
#

People constantly do mix them up and don't want to bother being specific, what's your point?
Why you feel the need to scare quotes facts as if what I'm saying isn't true is beyond me

velvet panther
#

why you want to be scared by quotes?

solar spire
#

It's a real term, feel free to google it

velvet panther
#

I know exactly what it is. I don't think you do.

solar spire
#

I'll let you be unbearable by yourself then πŸ‘

velvet panther
#

In this case, when using quotes around "facts", I'm drawing attention, in this construct. The use of the "scare" quotes is to draw attention to those things (the "facts") as separate from the subjective manner in which the terms have become commonly known. What you've presented as historical factuality no longer matters in the majority of conversations about ECS, because most consider it to be DOTS, and vice-versa. I'm, believe it or not, siding with you, on the original naming, meanings and terminology, whilst pointing out that that original definition is now a bit quaint.

#

One thing's for certain, it probably wasn't a good idea to let Unity's __A__cronym __R__esearch __S__pecialists & __E__nthusiasts also do the new logo.

muted star
#

Does anyone have an idea why is this exception thrown when I run this code?

var ecb = endSimulationEcbSystem.CreateCommandBuffer().AsParallelWriter();

Entities.ForEach((
                Entity unitEntity,
                int entityInQueryIndex,
                ref Unit unit) =>
            {
                var destroyedTargets = GetBuffer<DestroyedTargetsBufferElement>(unitEntity);

                if (destroyedTargets.Length >= 20)
                {
                    var maxLevel = unit.unitExperienceBlobAssetReference.Value.maxVeterancyLevel;

                    if (unit.veterancyLevel != maxLevel)
                    {
                        ecb.SetComponent(
                            entityInQueryIndex,
                            unitEntity,
                            new Unit
                            {
                                moveSpeed = unit.moveSpeed,
                                veterancyLevel = 3
                            }
                        );
                    }
                }

            }).ScheduleParallel();
            
            endSimulationEcbSystem.AddJobHandleForProducer(Dependency);
        }```
#
Unity.Entities.JobChunkExtensions.FinalizeScheduleChecked (System.Boolean isParallel, System.Int32 unfilteredChunkCount, Unity.Jobs.JobHandle prefilterHandle, Unity.Collections.NativeArray`1[T] prefilterData, System.Void* deferredCountData, System.Boolean useFiltering, Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& scheduleParams, System.Boolean& executed, Unity.Jobs.JobHandle& result) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/IJobChunk.cs:270)
Unity.Entities.JobChunkExtensions.ScheduleInternal[T] (T& jobData, Unity.Entities.EntityQuery query, Unity.Jobs.JobHandle dependsOn, Unity.Jobs.LowLevel.Unsafe.ScheduleMode mode, System.Boolean isParallel) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/IJobChunk.cs:246)
Unity.Entities.JobChunkExtensions.ScheduleParallel[T] (T jobData, Unity.Entities.EntityQuery query, Unity.Jobs.JobHandle dependsOn) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/IJobChunk.cs:150)
Code.Systems.UnitExperienceSystem.OnUpdate () (at Assets/Code/Systems/UnitExperienceSystem.cs:38)...```
#

Never mind I think I found the problem...

#

the variable destroyedTargets needs to be read only so I need to figure out how to do that now

muted star
#

Nice that works πŸ™‚

#

Here's another weird one, if I access the maxVeterancyLevel from my blobAssetReference it works fine but as soon as I use the ECB ParallelWriter.SetComponent I get a null reference error.

protected override void OnUpdate()
        {
            var ecb = endSimulationEcbSystem.CreateCommandBuffer().AsParallelWriter();

            Entities.ForEach((
                Entity unitEntity,
                int entityInQueryIndex,
                ref Unit unit) =>
            {
                var destroyedTargets = GetBufferFromEntity<DestroyedTargetsBufferElement>(true)[unitEntity];

                var maxLevel = unit.unitExperienceBlobAssetReference.Value.maxVeterancyLevel;
                ecb.SetComponent( // If I comment out this method call everything is fine
                    entityInQueryIndex,
                    unitEntity,
                    new Unit
                    {
                        moveSpeed = unit.moveSpeed,
                        veterancyLevel = 3
                    }
                );```
#

Exception with burst compilation disabled:

InvalidOperationException: The BlobAssetReference is null.
Unity.Entities.BlobAssetReferenceData.ValidateNotNull () (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/Blobs.cs:279)
Unity.Entities.BlobAssetReference`1[T].get_Value () (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/Blobs.cs:365)
Code.Systems.UnitExperienceSystem+<>c__DisplayClass_OnUpdate_LambdaJob0.IterateEntities (Unity.Entities.ArchetypeChunk& chunk, Code.Systems.UnitExperienceSystem+<>c__DisplayClass_OnUpdate_LambdaJob0+LambdaParameterValueProviders+Runtimes& runtimes) (at <f74c023565104fd3b6e455b2c48d320a>:0)
Code.Systems.UnitExperienceSystem+<>c__DisplayClass_OnUpdate_LambdaJob0.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at <f74c023565104fd3b6e455b2c48d320a>:0)
Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/IJobChunk.cs:386)
Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.17.0-preview.42/Unity.Entities/IJobChunk.cs:353)```
left oak
#

well, it looks like you're recreating the Unit component data, but not assigning the blob asset reference to this new component data, so it's null

muted star
#

Ah, yes that's it. Thanks for the help! I'll take a break

left oak
#

np, when it comes to ECS, code-by-error feels like the default process, haha

muted star
#

Is GetBufferFromEntity inefficient like GetComponentDataFromEntity?

#

Another question: Is it generally a better idea to store the BlobAssetReference on a singleton entity instead of a lot of entities?

sturdy rune
left oak
#

@muted star BufferFromEntity & ComponentDataFromEntity do have a price compared to captured variables, but if you're referencing data that doesn't belong to the Entities.ForEach, there aren't many ways around it. You could certainly put your BlobAssetReference on a singleton, and if there's only one Blob you're referencing throughout the entire Entities.ForEach, there's no reason not to, I feel.

velvet panther
muted star
velvet panther
left oak