#archived-dots

1 messages ยท Page 89 of 1

dreamy spear
#

yeah i just started doing ECS stuff today...

pliant pike
#

interesting @coarse turtle , I'll check that code out thanks

dreamy spear
#

i forgot it needs to be created using an entity manager. Say I want to create a bunch of archetypes in a separate class... and the entityManager is declared in a monobehaviour.. as long as is create the entityManager in a an accessible place it should work then?

while i have you well informed peoples around... world.active.entityManager
is there one that isn't WORLD.. or active ones under it etc... trying to understand that line of code

#

I know it works this way.. just want to know why that.. and if there are others like it that do something else (ie inactive entitiy managers? O_o)

pliant pike
#

you don't need world. in a componentsystem if I remember correctly

dreamy spear
#

and component systems basically run/update an entity right?

pliant pike
#

I dont use it generally anyway, you have to use world. to get existing systems though and thats about it

dreamy spear
#

so its just there to grab ALL systems

pliant pike
#

componentsystems basically do anything monobehaviour does

dreamy spear
#

but for entities

#

and I'm assuming for jobs

pliant pike
#

yeah they have specialised entities iterators

dreamy spear
#

also componentSystems (im watching a coding tutorial)....

the person is using a Entities.Foreach() with a ref to a specific component... im assuming this will iterate through ALL the entities in the world.active.entitiyManager that have said component, am I right to assume that?

#

whats the way to differentiate entities... are there specific functions or ways to do that (say I have 100 entities of two types... ) do i need to create a "tag" component to differentiate them if both have the same component types?

pliant pike
#

well entities just automatically searches in the active world(I wonder if you can search in an inactive one) ๐Ÿค”

#

you can use tags yeah

dreamy spear
#

so that's the way to do that then... i ask this in case there is an actual built in way to do this... (say use the actual editor "tags") or something

#

ok i think that's got me set for a while thanks @pliant pike ! been a big help

pliant pike
#

you create tags the same way as other components except they are empty of any data

dreamy spear
#

oh one more thing... is there any reason then.. to ever use two "componentSystem"s ?

#

it seems like all of it can run off one

slow epoch
#

Well you could also say all your game can be only one MonoBehaviour

dreamy spear
#

true... but I'm not sure how the entity system and job system tie in with componentSystems... especially when the job system tries threading things

pliant pike
#

componentsystems are just single threaded mostly just used to test and debug or things you know strictly cant be jobified

slow epoch
#

Also Jobs started from JobComponentSystems are handled automatically by the EntityManager

dreamy spear
#

thats good to know.. because I was assuming thats how entities SHOULD run normally.. not just for debug purposes

slow epoch
#

But yeah, JobComponentSystems and normal ComponentSystems are two different things

dreamy spear
#

ok.. so I'm looking at the wrong thing then XD... i need jobComponentSystems

#

but basically is the syntax similar in how the two componentSystems run?

#

except that one runs on the main thread and the other multi?

pliant pike
#

not completely jobcomponents are a bit more complicated

dreamy spear
#

i dont expect an in depth answer ... imma have to look them up and read up on them... just a generic answer is cool

#

thanks again tho : )

pliant pike
#

it might be best to get used to componentsystems before you go fully into jobs

dreamy spear
#

true... as long as I can extend that knowledge lol

slow epoch
#

As long as you are doing pure ECS, a lot of the simple stuff can be moved to jobs without a lot of trouble

dreamy spear
#

pure ECS?

#

you mean the entire project?

wary anchor
#

Single Responsibility Principle: 1 system, 1 task. Keep it simple for yourself by not making enormous monolithic blocks

slow epoch
#

Yeah

dreamy spear
#

like the link above.. from a day ago.. about the zombie game... i'm trying to use ECS and jobs for a mass amount of units that will translate and rotate.. (and hopefully animate)... but the rest will be normal monobehaviour code

slow epoch
#

I mean your entities hold simple data, not managed stuff like GameObjects or MonoBehaviours or stuff like that

dreamy spear
#

i know... which is why it's appealing for my purpose.. i only really need translation, rotation, and animation

#

but for units.. not the rest of my game

slow epoch
#

There are at this point a lot of ecs tutorials about how to setup a ComponentSystem and a JobComponentSystem

#

The unique difference is that you have to know which stuff you can't use on jobs

#

As long as you know that, you can do the same thing

dreamy spear
#

im going through one atm lol.. i just kinda spirllaed this conversation into too much depth XD sorry about that

#

I'm assuming I can't use jobs on things that wont thread well ๐Ÿ˜› but yeah ill def google that up to check

slow epoch
#

There are a lot of different jobs for different scenarios, don't know if it covers all of them but i think it does to the majority

pliant pike
#

yeah the only way to really know is to test and try things theres no strict rules or particular ways of finding out beforehand

dreamy spear
#

question: whats the difference between an archetype with say: translation, rotation and a component holding 2 floats...
and a component with a translation, rotation and 2 floats?

#

apart of course from being able to use the component in other archetypes

wary anchor
#

float does not require the interface IComponentData.

#

or do you mean, One component with 2 floats vs 2 components with 1 float each?

#

The answer to that question is then: depends. If you always need those 2 floats together, put them both in one component. If they can be used independent of each other, use 2 components.

dreamy spear
#

im saying.. imagine... a component called "Comp"

#

Comp has 2 floats... (they don't matter)... comp can have 1 float doesn't matter...

#

what I'm asking is... whats the difference between an archetype with: translation, rotation, and Comp in it

#

and another component... lets say called Other.. with a translation, rotation and 2 floats.. or 1 or w/e

#

im asking.. apart from reusability.. if there is a difference in having a component with all of the values needed and an archetype with all of those values

pliant pike
#

do you mean whats the difference between if they are separate on their own or all stuck in a component together?

dreamy spear
#

yes

#

seperated.. but then an archetype made of them...

#

or if its just an archetype made of one component

#

which has all of them in it

pliant pike
#

generally you want to keep componentdata separate because its more efficient for the cpu

dreamy spear
#

so componentdata should ideally have one value in it..?

wary anchor
#

I think you just asked:

CreateArchetype
(
    typeof(Translation),
    typeof(Rotation),
    typeof(float)
);

which doesn't make any sense to me as float does not use the IComponentData interface

dreamy spear
#

no I asked:

CreateArchetype
(
typeof(Translation),
typeof(Rotation),
typeof(Comp)
);

pliant pike
#

you should watch a vid about it, its difficult to explain exactly, ecs is all about the data and pushing it through the cpu using the cache as efficiently as possible

dreamy spear
#

of which Comp is:

public struct Comp : IComponentData
{
public float something;
}

#

OR

#

CreateArchetype
(
typeof(Comp)
);

#

of which Comp is:

public struct Comp : IComponentData
{
public Translate thing;
public Rotation anotherthing;
public float something;
}

wary anchor
#

Oh right, well the archetype is the collection of components you are defining as making that type of entity

#

no definitely not the latter

pliant pike
#

that second comp is way less efficient for the cpu

dreamy spear
#

my question is... apart form reusability... does it hurt to have your component contain all the things you need.. vs making the archetype carry them

pliant pike
#

only group data together that really needs to be calculated together

dreamy spear
#

@pliant pike even if all the fields are used?

#

ahh so its for caching and burst compiling?

#

to seperate them

#

if so.. that makes sense

pliant pike
#

rotation and translation are already separate components I dont even think you can use them in your own

dreamy spear
#

fair enough.. i mean i used them.. but they may as well have been another type of variable

pliant pike
#

yeah you might be making your own unique types

dreamy spear
#

so for the most part... componentData components should be single variables?

#

structs... of single values

pliant pike
#

it depends like I said

dreamy spear
#

just trying to understand when I should use them as single values.. or as multiple

wary anchor
#
using Unity.Entities;
using Unity.Mathematics;

public struct UpAxisComponent : IComponentData
{
    public float3 DesiredUpVector;
    public float3 CurrentUpVector;
    public float VerticalSpeed;
    public float GravityAxisSmoothRate;
}

here's an example of one of mine

dreamy spear
#

so... when would you do THAT^ vs use four components each with one of those in them?

wary anchor
#

I ended up usiong more values in there than I wanted because I was up against the 6 components per JobForEach<> limit

pliant pike
#

you have to think about the data and how its going to be used

wary anchor
#

yup, it's all about the data.

dreamy spear
#

care to elaborate? also 6 component per JobForEach<> limit?

pliant pike
wary anchor
#

Well now this is where it's helpful to say this stuff... I did hit the limit of IJobForEach but during refactoring must have changed things around (I remember moving Translation and LocalToWorld components from this, probably some more too)
private struct SmoothVerticalAxisJob : IJobForEach<Rotation, UpAxisComponent>
So now UpAxisComponent could be split up into its component parts (pun intended)

dreamy spear
#

so if I have this right... unaligned structures are more cache friendly than aligned ones unless their working sets are relatively small

#

that makes sense... i didn't go too deep into it (my head hurts already XD) but just seems like they work better on the cpu caches than when they are large structs with lots of data in them

wary anchor
#

and also from your development perspective, maybe you have some enemies with health, a player with health, and some NPCs with health, you want to deal only with health in one component, not health & movement & status effects & etc etc. Separate as much as you can

dreamy spear
#

yeah.. i initially asked because I was only going to use ecs on one entity... but lots of them

#

so wanted to compact them as efficiently as possible.. that said, I think it seems that unless the struct has 1-8 values in it... its best to keep em seperate for making them cache friendly

wary anchor
#

welcome to the rabbit hole we all fell down

dreamy spear
#

its a good rabbit hole... this is part of future game dev.. might as well learn it as soon as I can and have optimizations that feel more natural to me in the future : P

mint iron
#

can you use the blob stuff in a Burst Job ?

pliant pike
#

I'd presume so, well I'll find out soon enough

pliant pike
#

@mint iron that's a yes

#

is 0.01ms the fastest you can get?

gusty comet
#

Been trying to access the NavMeshAgent on an entity (hybrid ecs). In a ComponentSystem I'm manually iterating over chunks, then doing var agent = entityManager.GetComponentObject<UnityEngine.AI.NavMeshAgent>(entity);but agent is always null - anyone have any idea why?

#

I'm using a query, so it should have the component added correctly I think. When converting a scene object to an entity I'm doing dstManager.AddComponent<UnityEngine.AI.NavMeshAgent>(entity);Also tried with AddComponentObjectdstManager.AddComponentObject(entity, GetComponent<UnityEngine.AI.NavMeshAgent>());same result

safe lintel
#

if you are doing chunk iteration why are you accessing the entity through the entitymanager?

#

also EntityManager is a direct property of a component system so no need to rename it with lowercase

#

ok just tested, technically should work by doing it that way, are you sure the entity is getting converted?

gusty comet
#

well the query is returning the entity

#

I'm trying to access the UnityEngine.AI.NavMeshAgent component, and nothing seems to work, that's why I'm trying GetComponentObject on the entity

#

also tried var chunkNavMeshAgents = chunk.GetComponentObjects(navMeshAgentType, entityManager);

safe lintel
#

first line of code works, so theres something else happening preventing your code from working

#

are you absolutely positive that the entity is converted?

gusty comet
#

convert and inject instead of convert and destroy?

safe lintel
#

it does have to be convert and inject if you want to use monobehaviours

gusty comet
#

when I was away from the computer I had that thought actually ๐Ÿ™‚

#

thanks for the help, looks like it works

safe lintel
#

great ๐Ÿ™‚

gusty comet
#

Might just make my own dots-based pathfinding solution if I can

safe lintel
#

tempted to just drop pathfinding and just have dumb enemies for my own project until unity does an official package

gritty grail
#

Is PhysicsVelocity.Linear not relative to the rotation?

mint iron
#

anyone know if you can make Editors for components in the EntityDebugger inspector?

coarse turtle
#

at most i've only read data and displayed it in an editor window

#

I imagine you could grab the desired entity index -> get the entity and call the entitymanager to to set the data though when you update the value though ๐Ÿค”

#

plus I wonder if the struct has to be serializable

compact hound
#

hello

#

@coarse turtle back to our yesterday talk, have you any example of accessing childs entities? I did't found any reasonable example.

coarse turtle
#

the entitycomponentsystemsamples should have one, although they use the conversion workflow to set up parents and children

gusty comet
#

@safe lintel just so you know, after fixing the issue with injection I was able to get the mono component just by chunk.GetComponentObject<T> rather than messing with entityManager

compact hound
#

you mean they store child reference while converting from go?

coarse turtle
#

yes

#

so typically all you really need is the DynamicBuffer<Child> on the parent and a Parent component on every children entity if you happen to be building the entities manually

compact hound
#

I saw this in debuger. Im not creating it by my own i do it from conversion.

coarse turtle
#

well to get the Cannon component

gritty grail
#

Does anyone know how to calculate the velocity of an object relative to it's rotation with the Unity.Physics.PhysicsVelocity?

#

Or a similar component that does it automatically?

coarse turtle
#
var cannons = GetComponentDataFromEntity<Cannon>();

...
for (var i  = 0; i < buffer.Length; i++) {
  var childEntity = buffer[i].Value;
  var cannon = cannons[childEntity];
}
...

@compact hound

compact hound
#

oh

coarse turtle
#

fixed the mistake, it should be buffer[i].Value

#

If you have children entities that dont have cannons, you should do a check like
if (cannons.Exists(childEntity)) { ... }

neon shore
#

A few new DOTS related videos uploaded again today I see.

compact hound
#

@neon shore from unite of something new?

neon shore
#

Yes, talks from Unite.

compact hound
#

so nothing exciting ;<

#

@coarse turtle thanks, one step further ๐Ÿ™‚

#

Can I access buffer from job?

coarse turtle
#

Yes, there's an interface you can use IJobForEach_B<T> where B is a dynamic buffer

compact hound
#

oh

#

those all EBCC EBCCC EBCCCC are funny ๐Ÿ˜„

tawdry tree
#

Would be a bit more helpful with a short manual of what each of them mean

safe lintel
#

ugh subscenes are so buggy, really hope the next update fixes my issues

compact hound
#

@coarse turtle thanks i finally get something working

coarse turtle
#

np

compact hound
coarse turtle
#

and yeah the interfaces are bit weird

For job interfaces
B -> IBufferElementData
C -> IComponentData

But for EntityQueryBuilders
B -> IBufferElementData
C -> ComponentObject
D -> IComponentData

and @compact hound looks good, I think you can defer the ToEnityArray() call to a job - by passing an out JobHandle deps

dreamy spear
#

as someone who just started entities... the above like 20mins... is scaring me... i understanding NOTHING

compact hound
#

@dreamy spear i spend 3 days to just make something moving and shooting ๐Ÿ˜„

dreamy spear
#

lel

compact hound
#

not whole 3 days but still ๐Ÿ˜‰

#

@coarse turtle i don't get it, can you tell more?

dreamy spear
#

is there somewhere that has a good set of tutorials to go from basic setup.. to ^^^THAT XD (ie structs that extend IjobforeachwithSatan_BBSBSBDBCBC)

coarse turtle
#

actually nvm, I need to a look a bit more into the entity queries

compact hound
#
#

And Unite talks for really basic stuff

coarse turtle
#

Okay so you can actually defer query.ToEntityArray(Allocator) as a job to be executed later by doing query.ToEntityArray(Allocator.TempJob, out var deps) and schedule this to a worker thread to fetch the entities

compact hound
coarse turtle
#

yea - pretty much

#

it's something small - but I did notice it was quite pleasant on large volumes of entities

#

to just be able to defer it later in the pipeline than to immediately on that frame

compact hound
#

@coarse turtle InvalidOperationException: The system AICaptain.ProcessInputSystem reads AICaptain.RotationInput via ProcessInputSystem:ProcessRotationInputJob but that type was not returned as a job dependency. To ensure correct behavior of other systems, the job or a dependency of it must be returned from the OnUpdate method.

dull copper
#

Not all gameplay needs to happen immediately. In fact, there are many cases in which deferring commands may offer a better outcome โ€“ improved user experience...

โ–ถ Play video

This session addresses how we are expanding the scope of the Burst Compiler to enable even the most demanding, hand-coded engine and gameplay problems to be ...

โ–ถ Play video

If you've heard about Burst but aren't sure how to start using it in your games, then this is the talk for you. The first part of this session is hands-on in...

โ–ถ Play video

This session gives an overview of the physics systems and workflows powering our Data-Oriented Technology Stack (DOTS). Get insight into design consideration...

โ–ถ Play video
coarse turtle
#

you probably want to do ```
var cannons = cannonsGroup.ToEntityArray(Allocator.TempJob, out var eDeps)
...

var jobShot = new ProcessInputJob { ... }.Schedule(this, JobHandle.CombineDependencies(jobMove, eDeps));

compact hound
#

oh i see

#

out var eDeps i guess this is .net 4.6 feature?

coarse turtle
#

likely 4.7.x

compact hound
#

i was stuck with 3.5 ๐Ÿ˜„

coarse turtle
#

its a just a short hand for stating

JobHandle eDeps;
var cannons = cannonsGroup.ToEntityArray(Allocator.TempJob, out eDeps)
compact hound
#

ye i guessed

#

@coarse turtle thanks for today, i will be again latter ๐Ÿ˜„

frosty holly
#

Anyone know if there are any world space UI text solutions for ECS even if they are quite experimental

I know that that Unity is working on the UI run-time coming out later and I have found a git repository that deals with screen space world UI. I was curious if anyone had any experience

neon shore
#

You're late with the videos today, 0lento. :P

coarse turtle
#

the other way, which is what Im doing is interfacing with a scriptable render pass and projecting an orthographic plane to do my UI

magic frigate
#

Is that last video supposed to be private?

neon kraken
#

Hello, i want make an scriptable color on entity and i want know how i can pass my color (when i convert entity) to the mesh renderer

warm yacht
#

you can grab the renderer of the object and set a new color normally @neon kraken

#

if you get the Renderer component of the object, then you can access the ".material.color" API

neon kraken
#

i can get the component MeshRenderer in Convert method ?

warm yacht
#

Oh sorry, dunno why i answered in dots. For ECS i don't know

mint iron
#

@neon kraken make a component with a Color field inside and add it during conversion. If you want to apply it to a RenderMesh:

var mesh = EntityManager.GetSharedComponentData<RenderMesh>(entity);
if (mesh.material.HasProperty("_Vector1_Opacity"))
{
    var material = new Material(mesh.material);
    material.SetFloat("_Vector1_Opacity", 0.5f);
    mesh.material = material;
    EntityManager.SetSharedComponentData(entity, mesh);
}

They don't yet support something like a MaterialPropertyBlock so you have to replace the mesh.

neon kraken
#

@mint iron ok but on Convert method i doesn't have RenderMesh ๐Ÿ˜ฆ

dire frigate
#

Is the new physics authorative body deterministic in terms of movement?

mint iron
#

@neon kraken that sounds plausible ๐Ÿ™‚ i'm not sure if the default components are converted before or after IConvertGameObjectToEntity scripts. I would store the color on an entity then make a system that can apply it in update when its needed.

compact hound
#

Is it worth doing JobSystem for every thing? Or for systems that operates on small amount of entities better do normal one?

mystic mountain
#

@compact hound Normal as in ComponentSystem with Entities.ForEach?

#

I would imagine it's faster with JobSystem as you can schedule all jobs with dependencies and let the workers do their job without have to wait between JobSystem and ComponentSystem, (Not actually sure if this creates sync points?), you will also be able to have smaller jobs in parallel.

pliant pike
#

I'm kind of curious about that, is it worth creating a job that works on a single entity say every half a second, or just keeping that to the main thread ๐Ÿค”

mystic mountain
#

I mean are you talking about something that has a heavy execution load, or you intend to have multiple instances of this pattern?

compact hound
#

I mean something like system which handles shot input. I dont know process max 20 entites?

#

I curious also If Its worth to Creat job for this

#

Not much data and not much execution time

pliant pike
#

yeah mine is simple really light calculations for each entity, I might batch them all into say a group of 100, and have them precalculating and then throw away any excess when called by another system

#

or just calculate each individual as and when because the total sum have to keep roughly timed to another system

slow epoch
#

How does a large project with a lot of different Archetypes grow in terms of performance?

mint iron
#

They've said they intend to have it scale well into the thousands of systems, i don't think its quite there yet.

#

Archetype performance is linked to the number of components it contains. More components is worse for performance of Add/Remove/GetComponent methods.

Which is because each component type could be organized in a different order between chunks. e.g. one chunk has just a Translation, another chunk has Translation+Rotation, and you do a ForEach<Translation>, it returns chunks for two different archetypes.

So it can't know in advance the offset or index within that specific chunk for a component type, and so it looks through them all.

Lots of loops within loops and its going to multiply with more component types.

slow epoch
#

Yeah that was my concern

#

So having different Archetypes will be worse for performance

#

More archetypes = more chunks

vagrant surge
#

if you have 1 entity per chunk, the performance is harmed but still similar to what monobehaviors are

#

and that is worst case scenario

#

i did benchmarks in my own unity-style ECS by creating 1024 different archetypes

#

and querying stuff on them

slow epoch
#

But that chunk has occupies more than a MonoBehaviour right?

vagrant surge
#

yes

#

but the memory is pooled, and doesnt run the GC

slow epoch
#

Yeah that's right

vagrant surge
#

they also want to improve memory usage. At the moment all chunks are 16k

#

so minimum is 16kb

#

its possible to make stuff like 4kb memory chunks

slow epoch
#

I suppose if i'm gonna need a lot of different archetypes to notice that

vagrant surge
#

1024 archetypes in my benchmarking and it wasnt an issue at all

slow epoch
#

1024 as 1024 different components or just some components mixed to make 1024 archetypes

vagrant surge
#

(not exactly the same as unity, but a very similar chunked memory model)

#

10 components mixed completely rng

#

creating 2^10 combinations

slow epoch
#

Well that means

#

Transform + Rotation is not the same as Rotation + Transform

vagrant surge
#

nope

#

they are the same

#

unity ECS doesnt care about the "order"

#

it orders stuff by itself

#

so did mine (in mine i order components by their hash)

slow epoch
#

Yeah i know but i'm talking about your test

#

Oh okay but then it is not 2^10

#

(I think)

#

And if it's mixed randomly i suppose some of them would be repeated

vagrant surge
#

nope, its 2^10 combinations

#

imagine it as a bitfield

tawdry tree
#

Your point is that for the purposes of the combinatororsomething, you don't care about order, just unique combinations

vagrant surge
#

you have 10 items

#

and each of the items can be either 0 or 1

tawdry tree
#

That's be 2^10, yeah

vagrant surge
#

so 2^10 different archetypes

slow epoch
#

Okay i got it with the bitfield

vagrant surge
#

i did it with a 50% chance at each comp to get it or not

#

so i had to move some pretty seriously huge numbers of entities, i did it on stuff like half a million

slow epoch
#

Well it's really scary the amount of archetypes you can do with that few components

vagrant surge
#

and then i could test matching different combinations. For example trying to match 8 out of 10 components would be pretty rare

#

not in a real project

slow epoch
#

So it should always work from archetypes instead of adding the components manually

vagrant surge
#

yes, that allways

#

you should allways do an archetype switch (not sure if unity ecs has it?) instead of doing add component multiple times

#

so you do the heavy cost at once

slow epoch
#

Yeah that would be the way to go

vagrant surge
#

adding/removing components in unity ecs (and mine) is about the same cost as removing one entity AND creating a new one

#

because after all that is exactly what the model is doing, just with some copying in the middle

slow epoch
#

Well then is not a good practice to use Components as flags

#

As unity does in their videos

vagrant surge
#

it really depends

#

of the ratio beetween "times you iterate" and "times you change state"

#

in an ECS like Entitas/Entt where adding/removing components is crazy cheap, state components are a good idea

#

in unity ECS, adding/removing will need a thread sync point, and its much more expensive

slow epoch
#

I supouse ECS has a long way for now

vagrant surge
#

for stuff like "Dead"? good idea to use it as a component

#

as far you only set it once and it significantly changes things

#

for things like "ReceivedDamage" (refreshed every frame)... hell no

#

tho in my experiments i did culling by adding/removing a Culled component

#

and i could handle 400.000 in 1-2 miliseconds

#

and it also depends on how "fat" your entity is

#

if you have a Player entity with 20 components, PLEASE dont add/remove anything from it

#

if you want a state machine on the player, you could have it on a smaller entity that points to parent (but loses a bit of perf)

remote coyote
tawdry tree
#

Anyone else having an issue where opening a link to the Unity forums (from bookmarks, search engine, or linked like above) takes you to an error page about unique usernames with an URL starting with https://forum.unity.com/register/genesis?code=?
Closing that tab and retrying works.

remote coyote
#

Weird, I don't have that

tawdry tree
#

More like, probably weird that I do.
I should probably report it...

slow epoch
#

Okay on what scenarios should i make different worlds?

#

I've seen people doing it for procedural generation

vagrant surge
#

worlds have completely separated multithread models. I think there is a way to move stuff from one world to another

#

so one use is to have background threads doing loading into a "background" world, and once stuff is loaded, copy the entire chunks directly into the main world

#

in a similar fashion, ive seen a "unactivated" world being done sometimes. Instead of deleting entities temporarely, have them moved into a background world where there is no code running, until you move them back into the real world

slow epoch
#

There is no docs about how moving entities from world to world?

#

That could be really useful also for stuff like saving games

#

Also i've seen people using it as regular scenes

#

Which i sure hope it's not the same in any way

#

But that makes me think if we have any way to load different levels that have entities

vagrant surge
#

why save games? but the scene case is legit

#

not in unity, but one of the things ive done is to have one world per level

#

including main menu

#

so when you load the main menu, thats one world

#

and then the load screen is on that world, but a second world is being loaded for the level itself

#

and then you just switch execution into the other world

compact hound
#

interesting

vagrant surge
#

i think unity physics also has its own internal world

#

for physical state

#

it has its own entities and physics shapes and stuff, and the "game" world is a different one

tawdry tree
#

Move/copy everything you want into a "save" world and run a system that serializes literally everything?`
I seem to remember a talk which used some world-magic with deterministic physics to enable you to rewind time and stuff. IIRC the world was to 'save' a snapshot, though I don't remember why.

vagrant surge
#

thats the overwatch ecs talk

#

and yeah, they do exactly that

#

they create backups of the entire world state for every frame

#

for the last 10 frames or something

slow epoch
#

Also

#

If we can have multiple worlds at once

#

What means World.active

compact hound
compact hound
#

How to get world position from entity that have parent component? I need to iterate all its parents?

compact hound
slow epoch
#

Best way for a component to reference another entity's component?

#

For example to mimic the positions

mint iron
#

I'm aware of only two ways, 1) store the Entity of the other and use it to look up the position and copy it 2) lock the chunks involved and store a pointer directly to it (probably not a safe idea)

slow epoch
#

Oh so directly storing the Entity?

#

For some reason i thought that was a bad idea and it would be more complicated

mint iron
#

yeah its the primary way relationships are done. The default conversions do parent/child this way - storing a list of Entity. The entity Id never changes so you can rely on it and even if the entity is removed you can just check with EntityManager.Exists(Entity)

crystal zephyr
#

And getting data from the related entity you can use in a componentSystem GetComponentData<Type>(entity)
or in a job with GetComponentDataFromEntity<MyType>(true);

slow epoch
#

What's the difference between one and the other?

crystal zephyr
#

GetComponentDataFromEntity<MyType>(true) gives you a lookup data structure which you can pass a job and then you a receive the component by entity. (lookup[entity])

slow epoch
#

But why not using that for everything then?

amber flicker
#

Because doing so is essentially random access - sometimes that's just needed but the idea behind e.g. IJobForEach<X> is you iterate everything with linear access

slow epoch
#

Yeah sorry i think i've not explained myself properly. I mean why using GetComponentData over GetComponentDataFromEntity if the second one works everywhere and the first one does not

amber flicker
#

hmm.. for the reason I just described... when you do e.g. (CDFE) allTranslations[entity] that is rand access - when you do IJobForEach<Translation>... translation[i], that's linear (so faster)

slow epoch
#

But on IJobForEach<Translation> you don't need to use GetComponentData

#

It already gives you the component

#

I feel like i'm missing something here

amber flicker
#

yea, it's hard to guess what you're missing tbh... you could think of IJobForEach doing GetComponentData behind the scenes if that helps?

#

I'd recommend writing a couple of IJobChunk's if you haven't yet. It makes it much clearer what all the other IJob...'s are doing.

slow epoch
#

I mean i need one particular component from one entity and i know i can use GetComponentData and GetComponentDataFromEntity to get it

#

But both feel like doing the same

amber flicker
#

imagine you have IJobForEach<Translation,Bob> - you will have a chunk (or multiple) of linear memory of all the entities that have both those components. The execute method is iterating over the entities in that chunk. One by one, getting the next entity linearly in memory. When you use e.g. allTranslations = GetComponentDataFromEntity<Translation>() then do allTranslations[someEntity], you are leaving the linear memory layout of the chunk to go and look through all entities with a translation component

#

So if entity 1 has Translation & Bob but entity 2 has Translation & Sally, the job won't iterate Sally (because it requires Bob) and the only way you could get the Translation of entity 2 would be to use ComponentDataFromEntity

slow epoch
#

Okay i think i got it now actually

#

I really hope that ecs documentation could be a bit more detailed about stuff like this

crystal zephyr
#

I would always prefer this IJobForEach<Translation>... translation[i].
But I thought it was the problem that a component in your query is just linking to an other entity.
For example you have a Parent component which hold the Entity. So if you have a query for all parents you can access the parent component like parents[i]. But if you want to have the translation of this parent you need a dynamic lookup like allTranslations[parent.Entity].

amber flicker
#

yea the docs are actually a lot better than before (see pinned msgs if you haven't already) but it certainly isn't easy to just pick up straight away. If you managed to follow my rough paragraph above, you got this ๐Ÿ‘

pliant pike
#

this is a good talk that explains Componentdatafromentity

stuck hatch
#

Hello, I want to move data from ECS into my domain layer. For Example, I have a character who walks to a target position, if he reaches it, I want to signal my application, how can I achieve this?
I already thought about making a system, that checks distance to target but how reference Objects outside of ecs without using singleton?

pliant pike
#

maybe create an entity when the target is reached or add a component to another entity?

stuck hatch
#

I dont think that this would help me

pliant pike
#

personally I'm using an int which is normally used to iterate and move entity's through the waypoints, I can then check that value in other jobs or whatever to see if its the max value in which I destroy the entity, or if its any other value I can count them

stuck hatch
#

Sounds like ECS walks into my domain layer

pliant pike
#

there's lots of way of doing it, I'm not sure why would adding a tag component not work?

stuck hatch
#

Well, I am coming from a MVC project structure and until now, I though about ECS like view-data. But right now I think it is mixed. Example: An Entity can have both components. Something that moves and something that represents metadata like a car components describing the brand and color. you know what I mean?

#

I always seperated them

pliant pike
#

not sure, its all data either way

slow epoch
#

If adding and removing components from entities is that much of a problem for performance, i hope they come up with a solution in the future

candid bough
#

lol whole idea of dots is to not move stuff around in memory; changing components makes the system have to

#

is it safe to ask a question or are you guys discussing something

pliant pike
#

I think they've said or the general rule is just to use a boolean if you have lots of entity's and want it to be really performant

slow epoch
#

Well the talks are constantly saying using Components as Tags and adding and removing them constantly

candid bough
#

https://i.imgur.com/HT8YPX0.png
i copied the code 1:1 from the sample to my new project, using a simple cube for both, where could this huge difference in performance and batches come from, does anyone have an idea

#

i doublechecked packages, im using the same versions etc

pliant pike
#

I'm not an expert or anything but it seems like you have a lot more entity's or geometry

candid bough
#

same 10 by 10

#

entity debug window shows the same amount of entities too

pliant pike
#

your tris are 16.1k the example is 4.1k

candid bough
#

i just doublechecked and there are 201 entities vs 101
that's weird

pliant pike
#

maybe duplicate code somewhere or to many iterations

candid bough
#

i copy pasta'd the code 1:1
so i'll have to check where they are coming from lol
good tip tho

#

well that was dumb
i still had another system .cs which autoran

#

'saved by batching'
it seems that it somehow optimizes the sample project but doesnt for mine

#

crazy

#

turns out it was the material i used for my cube

#

so much to get the batches down but still a factor 10 less in fps

#

sneaky little bees
they tweaked quality settings etc

coarse turtle
#

https://gametorrahod.com/tag-component/ I think this blog is a good read on tag components instead of checking for bools

Game Torrahod

Tag component or "zero-sized component" is a special case in Unity ECS where IComponentData doesn't contain any field. The use is to intentionally separate entities to more chunks because a chunk is defined by one set of archetype.

vagrant surge
#

very important detail on tag components

#

when combined with manual chunk iteration, they get crazy powerful

#

because you can do branching on a chunk level

slow epoch
#

Okay that blog about tags is super helpful

#

Didn't know about the problems with If and Burst Compiler

coarse turtle
#

branch statements always have complexity on the compiler ๐Ÿ˜‰

#

and yea @vagrant surge that's a very important detail about chunk iterations w/ tags ๐Ÿ™‚

vagrant surge
#

@slow epoch no need to worry so much about the IFs

#

but yeah branchless gets optimized better and runs faster

#

tho it goes straight into microptimization territory

zenith drum
#

Hi

#

Need HElp

#

With dots

tawdry tree
#

Hello!
In order to provide 'HElp', pleas expand your query.

zenith drum
#

Ok Ok

#

I want to run some method

#

from ecs

tawdry tree
#

Jokes aside, this is the place for that, so just write what you're trying to accomplish and what's not working

zenith drum
#

inside other ecs class

#

Any ideas????

#

I just want to run Execute command in other class from other class

#

Is it possible

#

First i will say

tawdry tree
#

Might I suggest the usual programming best pratcice of extracting shared code to some mutually accessible class?
This could be done with inheritance (Ie. job A and job B both inherits from JobCWithExecute)
This could potentially be done with a static function both of them can access.
Or you could hvae duplicated code (genrally considered not-so-good)

zenith drum
#

Ok

#

I will try

#

Thx

gusty comet
#

For some reason I keep getting warnings like gnoring invalid [UpdateBefore] attribute on System1 because System2 belongs to a different ComponentSystemGroup. even though System1 and System2 both have the same ComponentSystemGroup specified in UpdateInGroup

tawdry tree
#

Have you checked that's actually the case, in the entity debugger?
Could be some black magic causing oddities

gusty comet
#

Did a few things and it went away, reverted those changes to the way it was (when I was getting the warnings) and now I'm still not getting the warnings. How weird

#

was trying to reproduce/confirm the fix ๐Ÿ™„

tawdry tree
#

Restarting the editor has a tendency to randomly fix random problems, too.
It should probably be item #3 or #4 on your "how do fix ECS" list (when it's not just clearly your code that's broken, anyway)

gusty comet
#

I can't be upset or anything, I'm using the alpha version anyways ๐Ÿ˜„
You're right in that restarting the editor helps alot, but I try to find fixes for bugs (or ways to avoid the same bug in the future) too

torpid panther
#

I'm just starting to learn the specifics of DOTS, and I know it has a long way to go before the entire engine is rewritten for DOTS, but I really hope there is a lot of work put into making it beginner friendly, especially if it's the future and meant to replace monobehavior eventually. Right now is seems hard for someone in 10-15 years to pickup Unity and get a box moving around a screen easily.

gusty comet
#

To learn it I watched some videos (udc, gdc, tutorials) and took notes (~150k characters so far ๐Ÿ˜… ) on every documentation page I could find about it. I'm still probably only 25% through all the links I've gathered

compact hound
#

ye i feel like I'm learning programming from the beginning xd

coarse turtle
compact hound
#

what is the best way to communicate UI <--> DOTS?

slow epoch
#

What should i do to make a camera movement system since the camera cannot be converted to entity yet

coarse turtle
#

A camera can be injected into an entity using ConvertAndInjectOriginal

#

that's the current work around and you can access the camera's xform and settings to start moving it around

#

@compact hound no ideal way atm

#

uGUI doesn't really scale and relies heavily on monobehaviours, you could try representing a 'fake button entity' with an ID and on click you just query for the button ID and set the value to true in a MonoBehaviour's function call

#

and at the end of the frame, unset the value to false if you want specifically a button press

#

UIElements for runtime should be coming in late 2020, and it might have dots support

#

ยฏ_(ใƒ„)_/ยฏ

tawdry tree
#

@compact hound You can access the entitymanager from monobehaviors, so the button could create an event entity, or set values on an entity. Not entirely optimal, but should work fine; UI stuff doesn't happen all that often (unless you hook up some every-frame stuff, I guess. Still low volume)
That would be the 'write relationship mentioned in the video Calabi linked to above (Options for Entity interaction - Unite Copenhagen), and the video also mentions (but does not detail) entitymanager from mono.

compact hound
#

And how UI should react based on DOTS like hp bar?

gusty comet
#

If a gameobject has its mesh filter/renderer on a child object, and that gameobject is converted via convert & inject gameobject - does that mean it won't have a LocalToWorld?

#

seems like the child object has it, but not the parent

compact hound
#

every entity have it

#

with translation/rotation

gusty comet
#

I'm looking at it in the entity debugger and don't see a LocalToWorld (in the inspector when I select it)

#

but the child has a LocalToWorld ๐Ÿคท

#

So strange, oh well I'll figure something out

#

huh, I'm getting InvalidCastException: Specified cast is not valid. when I select the entity I'm talking about - that's why the inspector isn't showing some of its components I suppose
Ah figured it out, had to remove the collider (there are unsupported datatypes which break the inspector when inspecting an entity)

coarse turtle
#

@compact hound if you wanted an HP bar, all you would really need is your normalised health between [0, 1] and find which health you want to apply on your image

#

Let's say we converted we injected an image to an entity with an ID (a custom component) of 0 and similarly we have another entity with the <Health, ID> components

#

we can build a map from player entity -> image entity, normalise the health and apply it to the image's fill amt

compact hound
#

but who should tell ui to update? just system?

coarse turtle
#

you can have a system do it

#

preferably I would do that to try and keep the logic in the ECS ecosystem

#

buttons are a whole diff story

rugged wagon
#

I'm running into an issue where C# doesn't know how to differentiate between the quaternion struct and method. I have this at the top of my code:

using Unity.Mathematics;
using static Unity.Mathematics.math;

The using static lets me access all the methods within Unity.Mathematics.math without having to type math.
It makes my code look like this:

var point = mul(meshToAxis, float4(vertices[index], 1f));

instead of

var point = math.mul(meshToAxis, math.float4(vertices[index], 1f));

However this is preventing me from accessing the quaternion struct because it thinks I'm calling the quaternion method.

var rotation = quaternion.LookRotation(position - cameraPosition, cameraUp);

This code here ^ throws an error because it wants quaternion(float, float, float) not quaternion.LookRotation

Removing the using static fixes this, but I have to put math. at the beginning of everything. Is there a way to get the best of both worlds and have the succinct math methods while still being able to access static methods from the encapsulated structs?

tawdry tree
#

Use an alias
using ALIAS = Full.Namespace.To.Class
then access the class via the alias
ALIAS.StaticMethod()
var foo = new ALIAS()

#

Check the official C# docs if you wanna delve into that

rugged wagon
#

Thanks @tawdry tree! That looks like exactly what I need

compact hound
#

i think this makes code less readable

rugged wagon
#

Ideally c# would know I'm referencing the struct because quaternion is followed by a dot instead of parentheses, but I rarely need the *structs static methods so this is fine every once in a while

#

Unless you're talking about not having to prepend every math method with math. in which case I'd have to disagree with ya

#

Looks just like shader code!

#

@tawdry tree Idk if this is specifically what you were suggesting, but I can actually force c# to recognize quaternion as a struct and not a method by doing

using quaternion = Unity.Mathematics.quaternion;

Kinda sucks because I can't create a quaternion via the quaternion method but:

  1. I never need to assign the components of a quaternion directly - I just create them from utility methods like LookRotation
  2. If I need to I can still use the constructor var r = new quaternion();
#

Actually nevermind with using quaternion = Unity.Mathematics.quaternion; I can now do
quaternion.LookRotation(forward, up) and quaternion(0f, 0f, 0f, 1f);
that's so weird that it can differentiate after the using statement instead of flip-flopping whether it expects a struct or method

wispy walrus
#

are the intrinsics and assembler style math available in the unity alpha yet?

compact hound
#

What CommandBuffer should i use to apply changes after system update, like to precess shot command in next system in same frame

tawdry tree
#

@compact hound Did you see the "Options for entity interaction" Unite talk?
It talks about how to 'communicate' between entities (very useful, made a few things 'click' for me), and a bit about ordering (which would let you make it happen in the same frame). There's an illustration of the default system groups and their ECBs around 31:30
https://www.youtube.com/watch?v=KuGRkC6wzMY

Interaction is fundamental in games, both in how players interact with a game and receive responses, and in how parts of the game interact with one another. ...

โ–ถ Play video
compact hound
#

@tawdry tree ye i actually was there but back then i haven't tried DOTS by my self yet ๐Ÿ˜„ You are talking about this adding and removing tag in the same system?
I would need few of of such ECM that will resolve after system update. But this talk don't cover this topic.

#

And passing do job ComponentDataFromEntity like LocalToWorld component isn't too heavy?

tawdry tree
#

It talks about communicating between entities, and by extension, systems.

What CommandBuffer should i use to apply changes after system update, like to precess shot command in next system in same frame
By this it sounds like you wanted to hook up some input (player or otherwise) to something you want to happen. That's exactly what the talk is about.

#

Though I'm not entirely sure if I understand what you're trying to achieve. Care to elaborate?
What systems are doing what to what entities?

compact hound
#

Input add Tag to player entity
InputSystem process that tags and for eg. tells player to shot
ShootingSystem take specific player weapon nat tell it to spawn projectile
SpawnProjectileSystem ....

#

I think it takes 3-4 loops to actually spawn bullet

tawdry tree
#

So in short:
Player input->player shoot?

#

If it already works for you, but the issue is that it takes multiple frames, you should be able to make it take less frames (possibly just one) by using [UpdateBefore(otherSystem)] [UpdateAfter(otherSystem)] and the ECBs as illustrated in that talk. The input should probably be in the InitializationSystemGroup, and for the stuff after that, use Before and After on the ECBs

compact hound
#

yes im using UpdateAfter attributes but every system is in simulation group (shooting,spawning) and I'm using BeginInitializationEntityCommandBufferSystem

#

i probably would need ECB between shooting and spawning system

#

To SpawnProjectileCommand (Compnent tag) was already created

tawdry tree
#

If you put ALL of them in that ECB, then the commands aren't executed yet

#

For any entity command, you need anything dependent on the effect to run AFTER the ECB

mint iron
#

Does it matter if theyโ€™re a few frames behind? I guess If itโ€™s a fast paced FPS maybe youโ€™d notice 1/6 or 1/12 of a second.

#

You could put some of the systems in initialization, late or render group. Or add your own groups to simulation group and setup your own ECB start/end within it.

frosty siren
#

I'm trying to understand ConvertToEntity workflow. Is it only for Pure ECS?

compact hound
#

@frosty siren its for doing all stuff still in editor like prefabs, scenes then convert all those objects to entites

#

You will see all those objects will disappear from scenes on play (when they are converted)

mint iron
#

Yeah it produces pure ecs stuff. So you setup your scene in editor then when game starts, from that point on you work with the entity/component version of it.

tawdry tree
#

You can still use gameobject, too. Anything you haven't created conversion for will stay as GOs

mint iron
#

Itโ€™s also super useful for converting go prefabs into entity prefabs. I canโ€™t imagine spawning complicated/real object structures manually - especially if physics is involved- without entity conversion. it would be a huge waste of time.

compact hound
#

@mint iron this few frames matters, i see that i cannot spawn bullets as fast as i could

modest reef
#

Hey so how do I remove the child safety lock on the job system? So that I can use an instance of a class in the job system? FYI my stuff is thread safe so don't tell me its so that I can't run unsafe thread stuff.

tawdry tree
#

The video I just linked mentions it, something about allow unsafe or something? Anyone know the exact attribute? (it goes on a particular variable/parameter)

mint iron
#

@compact hound Iโ€™d put input system in initialization group. Add an EarlySyncGroup at the start of simulation (or end of initialization if you have trouble ordering it) since creating the bullets will cause all other jobs to complete and I would just use the bulk instantiate overload rather than ECB if possible. Then your movement system can update bullet position before rendering hits and it should all work in one frame.

compact hound
#

Its better to have IBufferElementData that stores some list like child or better to have nativearray in component (for eg. for list of bulletspawners) NativeArray may be better because this data wont change its size?

#

@mint iron can you tell more about build instantiate and early sync group?

mint iron
#

Im away from my pc until Monday if youโ€™re still blocked I can post some examples then.

#

Essentially Iโ€™m not using ECB since right now itโ€™s pointless. (Iโ€™m hopeful next weeks entities release will introduce structural changes in burst to change that). But anyway, the idea is that you do all your add/remove entities/components at the start or end of simulation group. Then in the middle you allow all your jobs to run side by side for as long as possible without getting interrupted.

#

Bulk instantiate means to pass in a NativeArray to EntityManager.Instantiate and it just allocates all of them in one go which is light years faster than doing it one by one.

compact hound
#

@mint iron what about my other 2 questions?

  • Its better to have IBufferElementData that stores some list like child or better to have nativearray in component (for eg. for list of bulletspawners) NativeArray may be better because this data wont change its size?
  • Passing do job ComponentDataFromEntity like LocalToWorld component isn't too heavy? (many entities)
tawdry tree
#

I fail to parse the last of those two... Passing components to ComponentDataFromEntity? As for heavy or not.... try! Run basic profiling and see if there's any red flags. Know roughly the volume of changes you'll make. The video above also mentions the perf impact of the two interactions they explain.

gusty comet
#

Does anyone know if it is worth to code a player controller using DOTS? or this something that is better done using regular object orientated programming with Monobehaviour classes.

frosty siren
#

@mint iron , @compact hound so if i need some MonoBehaviour like SkinnedMesh and animation and i want compute some data with ECS way (which is Hybrid approach) i need to use GameObjectEntity?

tawdry tree
#

@gusty comet If you're using primarily ECS, then I'd say yes. If you're already mixing mono and ECS, then maybe.
At any rate, you can do it as easily as in monobehaviors, just make a 'PlayerInputSystem : IJobForEach<Player, OtherRelevantComponent(s)>' which checks for input and does the thing(s). Can have multiple, too, to be closer to ECS best practice/standards: PlayerMoveSystem, PlayerShootSystem, etc.

frosty siren
#

Sorry for against dumb questions from me, I just never went the Hybrid way

gusty comet
#

@tawdry tree I'm contemplating whether to go fully ECS or a hybrid of Mono + ECS.

#

I'm just worried if there's anything which ECS would make harder than it has to be or doesn't support something I'll need that will end up forcing a hybrid approach?

tawdry tree
#

My tip there would be that unless you'reconverting an existing project, it's probably easier to go as pure as possible, unless you have something completely sectioned off (not interacting with the other side).
Some things are a lot easier to do in mono-world, though.
What kind of project are you working on? There are a few core components (animation is one, I believe) that isn't DOTS ready yet, but if you don't need any of those...

#

Or tl;dr: Do ECS where you can. If you don't think you can, investigate (ask here) before falling back to mono.

gusty comet
#

@tawdry tree I want to make a game with a procedural world and where the player navigates it using a first person controller. I've done some research and it seems doable mainly using ECS but the animations part is what I think will require a hybrid approach.

shut siren
#

personally I would assume that some degree of hybrid is inevitable for many projects right now, althouh I also understand the attraction of being able to do it all in a pure ECS world, and why some developers want to explore that pure world (which is much easier to do if you have the luxury of being able to not use all sorts of Unity systems that are not ECS ready yet)

tawdry tree
#

So fully rigged 3D models? Is that core to the experience? What if you don't have it? Have you considered alternatives? Are they good? Bad?
I'm not trying to make you change your mind here, but if you look at the history of games, working with limitations has created some of the best remembered games out there.
Point is, if you can achieve your goal and make things easier for yourself... why not?

shut siren
#

as for ECS making some things harder, this is really a question about the developers own knowledge, understanding, confidence etc in data oriented design and the way Unity is doing it. Plus things liek the fact that this stuff is still immature and evolving, so we are chasing a moving target more at the moment.

tawdry tree
#

Another thing is when these things come out. I think animation is in the near future(a month? Months?), but haven't been paying much attention to it in particular, and most time estimates are really fuzzy right now. Could you work without it for now, then add it later? That's one of ECS' strengths, after all, a strong separation of concerns and extremely low coupling.

shut siren
#

Another way that ECS may 'make things harder' is if the developer never really considered performance, optimised code, etc in the past with the old systems. The benefits of ECS & DOTS obviously require those designing and developing the game and its systems to embrace performance-focussed ways of thinking about your game and its data, and if this stuff is a new concept, it will seem harder than the old ways

tawdry tree
#

True, with monobehaviors it's a lot easier to do something 'brainlessly', just make something that (barely?) works. Of course, that's great for prototyping, but code has a tendency to stick around, even when it's long past it's best before date.

gusty comet
#

@tawdry tree @shut siren You both make very compelling point and I think ECS seems to be the best way to go as I can do without animations for the moment and after seeing some of the Unite Copenhagen talks on DOTS it seems super easy to add things it when they do become available (e.g. animations). Also seems like all the core things I'd need for everything else.

#

Plus making it well using DOTS would allow me to really think this through and use this system in all my new projects.

shut siren
#

I waited till this stage before starting my own DOTS journey because I wanted certain things to be in place so I could try the pure approach, and I was hoping for less boilerplate code and it looks like I got my wish

#

but to be honest, since they've decided not to try some kind of pure entity authoring approach, and instead to keep gameobjects etc for the authoring side, and focus on conversion of that stuff to the runtime entity world instead, the question of purity, hybrids, forgetting about monobehaviours etc reduces in importance to me.

#

I expect to be working in both worlds for years to come, so I'm not going to worry about whether a particualr project will end up a hybid or not

#

the important thing is to learn where to use new DOTS stuff where performance actually matters to your project

#

and how to think about everything in game systems design from a data oriented approach

tawdry tree
#

From the very beginning (of looking at ECS) my goal was only ever to learn the concept, the basic principles, and to keep up with development, but after watching a bunch of the Unite ECS talks and having a couple more things 'click', so I feel like if I am to make anything in Unity soon, it will be in ECS.

#

Well, as you say they do authoring at least in monoBehavior, so it's not like I'm never gonna touch that. But it would be for actual prototype code, dev/debug stuff, and of course, authoring

gusty comet
#

Yeah some of the developer case study like talks seem to have been using Monobehaviour and applied ECS to things which seems to hinder performance such as spawning a huge zombie hoard and the rest doesn't really matter or is up-to personal preferences which way you go about implementing.

mint iron
#

If you try to go as pure as possible you end up hitting things like UI, animation, sound, cameras and addressables etc - broader aspects of making a complete game. And many of those have to be in monobehavior world still with some kind of custom interop you cook up to make it work together with the ecs side. You canโ€™t make purely pure right now really.

shrewd night
#

Hello everyone! Just found out about the discord channel ๐Ÿ™‚ I've been playing with the DOTS stack for a bit now and have a pretty good general understanding, however I can't figure out how to make a game that uses the new Unity Physics module to run the same on different devices. I really don't know where to involve the deltaTime, if it's needed or not. Maybe someone can point a relevant sample or some sites where I can learn more about this.

#

on the forums, under unity physics, my post with this questions is the last post made there... maybe if someone knows more about this they can give a helping hand ๐Ÿ™‚

frosty siren
#

Why i have 0 entities at all but BuildPhysicsWorld takes 0,4~0,5ms?

neon shore
#

Basic call overhead?

gusty comet
#

Hello! Could anyone explain to me please how I would be able to delete an entity? I'm currently cycling through the entity list with ForEach loop, which doesn't allow me to get the entity so that I could delete it with "EntityManager.DestroyEntity(instance);" found here: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/entity_manager.html

The entities are instanced in a spawner script that uses native array and Allocator.Temp

My goal is to delete an entity that runs out of "hp". Currently the ForEach loop manages the locations of entities and the hp values.

I would really appreciate any help! I've managed to overcome and avoid all the other obstacles so far but this one is just a great source of frustration for me. Thanks!

shrewd night
gusty comet
#

Ohh, thanks alot! Haven't been able to land there yet!

shrewd night
#

there are good examples for basic usage there; make sure you check the readme.md files; good luck! ๐Ÿ˜„

gusty comet
#

I will, thanks again! ๐Ÿ™‚

shrewd night
#

welcome

round roost
#

Hi, I've been playing quite a lot with DOTS recently and been making simple zombie shooter. Everything works fine, but what's the easiest way to show damage numbers above the enemy when bullet hits? Basically I would like to use tmpro and show the number above enemy head few secs

neon shore
#

I'd create a separate entity and give that components to show the text and for destroying it over time etc. on hit

dry dune
#

Hi, I'm trying to make a custom BinaryReader that can read from byte[], but i'm new to unsafe side of c#, am I doing it right?

public unsafe class ByteArrayReader : BinaryReader{
  private byte* ptr;
  
  public ByteArrayReader(ref byte[] arr){
    fixed( byte* fixedBuffer = arr ){ // it's not 100% clear for me what this line does
      ptr = fixedBuffer;
    }
  } 

  public void ReadBytes(void* data, int bytes){
    UnsafeUtility.MemCpy(data, ptr, bytes);
    ptr += bytes;  
  }
  public void Dispose(){}
}```
#

is it ok to fix the array i'm passing by ref ?

mint iron
#

@dry dune probably a good idea to check the msdn docs but fixed will prevent the managed object from moving during its scope. So the pointer it gives you is safe to use until you leave the fixed statement. Storing it as a field for later use would end badly because itโ€™s almost certainly going to move. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/fixed-statement. You could pin it formally see GCHandel https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.gchandle?view=netframework-4.8

limpid bough
#

The obvious question though is what is that code for? In light of the binary stream stuff they provide and native arrays, just curious what the use case even is for that

dry dune
#

what i'm trying to achieve is a jump-back-in-time mechanic for my ecs game
my goal is to serialize world to memory and to restore it to that state later

limpid bough
#

have you looked at using worlds for that?

#

I haven't played around with worlds but I've used their binary serialization stuff enough to know that they do have a good amount of existing code to serialize all things ECS

dry dune
#

yes "backup" world is what i was thinking first, but in my case i need many restore points

limpid bough
#

Ok might work fine, my gut instinct on it is still stay a bit higher level with containers. I think that should be easier and more performant because due to less copies

#

How much data are we talking about?

dry dune
#

@mint iron thank you, this is exactly what was i suspected, but how to fix it for longer period?

#

not that much few hundred small entities

#

maybe i need to serialize to NativeArray instead?

limpid bough
#

If it's not a ton of data you could just save the entities and components into native arrays. Then a restore would be destroy all entities and use the batch api to create new entities from your saved data. But worlds might make that easier I really don't know as I haven't used them.

#

Like it might be relatively simple to just create a world for each save point. I would at least investigate that because it seems to have the best potential of making this easier

dry dune
#

I'll try to use worlds, and also try to figure out how to serialize to persistent NativeArray

potent cape
#

The issue is that it does update the system once and after it is listed as "Not run"

tawdry tree
#

Have you checked the entity debugger to make sure entities it would affect actually exist? Systems tend to turn off if they don't have anything to affect.

potent cape
#

oh yeah... forgot to add an component, you shouldn't do late night coding kids

#

Thanks @tawdry tree ๐Ÿ˜„

tawdry tree
#

Always check the entity debugger to make sure your entities are what you think they are!

#

I've burnt myself on that, and related 'system deactivates' issues, several times

potent cape
#

Well for sure this ended up in other issues, but i think i can resolve those ๐Ÿ˜›

potent cape
#

Well now im at a point where from inside Unity i get the error

InvalidOperationException: The previously scheduled job GatherEntitiesJob writes to the NativeArray GatherEntitiesJob.Data.Entities. You must call JobHandle.Complete() on the job GatherEntitiesJob, before you can deallocate the NativeArray safely.

So the GatherEntitesJob (which is one of unity) doesn't Dispose it's own native array?! ๐Ÿ˜…

stuck hatch
#

Hello, I just found out, that string are not allowed in componentData, is there a workaround to enable strings?

potent cape
#

no since strings are objects and not structs

#

I haven't tried, but maybe you can do a NativeArray<char>

#

i recommend before comparing all the letters if the size is unequal

low tangle
#

NativeString64

#

512

#

8192

potent cape
#

Oh there are strings by now? Didn't know ๐Ÿ˜ฎ

stuck hatch
#

yeah just found it, but NativeString64 produces weird result

#

The "C" is gone

#

even more weird, the last letter changes every frame

potent cape
#

Maybe a 64 isn't big enough?

#

Try 512

stuck hatch
#

for 3 chars?

potent cape
#

yeah it should be... i guess

stuck hatch
#

Unity quote "NativeString64 - consumes 64 bytes (one line) of memory. suitable for short names and descriptions."

#

NativeString512 - consumes 512 bytes (eight lines) of memory. can hold a few lines of text, a filename, a URL.

#

Well NativeString512 gives at least the same result only "AB" never with "C".

potent cape
#

I just tried it. When you debug.log it it gets converted back to ABC

#

or in my case 123

#

Maybe the debugger is weirded out by NativeArrays ๐Ÿ˜„

#

or better NativeStrings

stuck hatch
#

ok, debug.log works so it's riders fault

potent cape
#

It's the same in visual studio code. Probably an issue that the debugger doesn't know how to handle the new data layouting

stuck hatch
#

one more question, I am thinking about a software design with ecs, but I am struggling with either go the full ecs way and do everthing with or to use a hybrid between ecs and classic approach. But on hybrid, how can I reference back objects from ecs? Do I have to use some kind of Ids and dictionaries?

potent cape
#

Umm i personally handle it by having a double representation of the gameobject in the entity world

#

And the GameObject still has the Entity stored to access things that changed

stuck hatch
#

do you have an example for me?

low tangle
#

for my one system that manages gameobject instances, I use the hashcode from the UnityEngine.Object (gameobject) and store that into a dict

#

everything newer I use a simple linked entity like the old hybrid proxy workflow

stuck hatch
#

@low tangle yeah I also thought about it, but I dont like it

#

What is the the old hybrid proxy workflow

low tangle
#

you pretty much want to do a reverse, everything in ecs, and only touch the monoworld as needed

#

the conversion workflow is the future, but still requires a full pure entity approach

#

the old proxy workflow is where you attach a gameobjectentity to a gameobject, it creates a entity in OnEnable() and deletes the entity on disable / destroy

stuck hatch
#

But there is also one downside of do everything in ecs, I dont like that each system can theoretically access every single data component

low tangle
#

it was a bit cumbersome and I needed to run a much simpler setup

#

thats not a bad thing

potent cape
#

Yeah that is what i am doing, since it is the most understandable way for me @low tangle

low tangle
#

ended up taking a pointer from the conversion workflow

#

this is a low n of gameobjects so I'm okay with the cost

#
class LinkedEntity : MonoBehaviour
    {
        public Entity entity;

        private void Start()
        {
            var em = ECS.EntityManager;
            if (em != null)
            {
                entity = em.CreateEntity();
#if UNITY_EDITOR
                Debug.Log("Creating linked entity for " + gameObject.name);
                em.SetName(entity, "Linked Entity:" + gameObject.name);
#endif
                em.AddComponentObject(entity, transform);

                var linked = gameObject.GetComponents<ILinkedEntity>();
                foreach (var link in linked)
                {
                    link.Attach(entity, em);
                }
            }
        }

        private void OnDestroy()
        {
            var em = ECS.EntityManager;
            if (em != null && em.IsCreated)
            {
                if (em.Exists(entity))
                    em.DestroyEntity(entity);
            }
        }

    }

    interface ILinkedEntity
    {
        void Attach(Entity entity, EntityManager manager);
    }
#

it only converts the few components I care about

#

which is my interaction components

#
class Hoverable : MonoBehaviour, ILinkedEntity
    {
        public bool Hovered;

        public void Attach(Entity entity, EntityManager manager)
        {
            manager.AddComponentObject(entity, this);
        }
    }
#

this allows you to run systems over top monobehavours instead of componentdata's

#

in low numbers its alright

#

for the love of god, dont build your whole game off this kind of setup

potent cape
#

Overall i would recommend having as little as possible interactions from entities to gameobjects, but there are just things that aren't possible (yet) to do with ecs

low tangle
#

yep

potent cape
#

But still does someone have an idea on'
nvalidOperationException: The previously scheduled job GatherEntitiesJob writes to the NativeArray GatherEntitiesJob.Data.Entities. You must call JobHandle.Complete() on the job GatherEntitiesJob, before you can deallocate the NativeArray safely.

#

This happens when i dispose my nativearray

low tangle
#

two jobs accessing that array?

potent cape
low tangle
#

or did you not gather(jobhandle) into the job that uses it

potent cape
#

there is the current thing

#

all the way at the bottom

low tangle
#

oh, you cant dispose like that

#

you are disposing right after you schedule

potent cape
#

when should i dispose instead?

low tangle
#

you've already got the tag to cleanup

#

right up here

#

ln:23

#

yeah that would clean up the entities nicely after running it

potent cape
#

Like i just converted this from a old ECS project, with some minor changes ๐Ÿ˜›

low tangle
#

no worries

stuck hatch
#

Thank you for help, you made me quite curious about the "AddComponentObject" Method, according to Unity "Accessing data in a managed object forfeits many opportunities for increased performance. Adding managed objects to an entity should be avoided or used sparingly." I am thinking about using it, but not sure. I dont want to use it everywhere, but if I use it to call back from a system to a monobehaviour for futher process, is this a way to go?

low tangle
#

yep thats a okay thing to do

#

I process a few like this

#

    class PlayerGrabHoverSystem : ComponentSystem
    {
        private EntityQuery query;

        protected override void OnCreate()
        {
            query = GetEntityQuery(
                typeof(Transform),
                typeof(PlayerHand)
                );
        }
#

            Entities.With(query).ForEach((Entity ent, Transform t, PlayerHand hand) =>
            {
                if (hand.HoveredItem != null)
                {
                    hand.HoveredItem.Hovered = false;
                    hand.HoveredItem = null;
                }
#

process a entity as normal, but you can touch monobehaviours

stuck hatch
#

It would be even better if I could throw normal c# objects in it

low tangle
#

you can in the monobehaviours

stuck hatch
#

but I can go with monobehaviour

low tangle
#

also this is a normal component system, so its all main thread, use whatever you want

low tangle
#

if you treat monobehaviours as databags instead of scripts like we used to, you can just do whatever in them dod style. which I highly recommend

stuck hatch
#

Type is System.Object but in Description it is UnityEngine.Component.

potent cape
low tangle
#

yeah, it wasn't a error and you couldnt get the safety system to shutup if you didnt

#

in the older entities version

stuck hatch
#

Well actually it has nothind to do with monobehaviours, I have a MVC software design in my projects, only a small part is monobehaviours, I am trying to integrate ECS in my MVC System

low tangle
#

ah I see

#

why not manage the entities directly from the mv (c)'s then?

#

its as simple as getting a global ref to the entity manager and keeping a few entity refs here and there

stuck hatch
#

This is what I am looking for, i hope the AddComponentObject helps me to build the bridge

low tangle
#

alright

stuck hatch
#

thank you for the help, I try now

potent cape
#

Well can i still force the safety system to shut up? ๐Ÿ˜„

low tangle
#

kinda?

#

I ran into some problems with the transport layer, with the same kinds of problems

#

its a pain in the ass to get around

#

I actually commented out the safety check

potent cape
#

Best solution ๐Ÿ˜„

stuck hatch
#

Unity wants me to use RegisterGenericComponentType, I tried to set it above the class, but now I need a special file, how to you use it?

#

AddComponentObject / GetComponentObject only takes Monobehaviour or other unity related objects

tawdry tree
#

Integrating MVC and ECS, in unity? I'm kinda wondering WTH you're making...
That aside, why does Unity 'want' you to use RegisterGenericComponentType?

potent cape
#

manager.SetSharedComponentData<RenderMesh>(entity, new RenderMesh { mesh = mesh, material = material });

I added the HybridRenderer, the mesh and material aren't empty, but as soon as i look at the entity in the inspector the mesh and material aren't there. ๐Ÿค”
Any idea why this could be?

tawdry tree
#

Uh, meshrenderer should be one of those things that auto-convert, i think

potent cape
#

Yeah i created from archetype

dry dune
#

few hours ago i've been asking about BinaryReader
here is what i have now

public unsafe class NativeListWriter : BinaryWriter{
  public NativeList<byte> data = new NativeList<byte>(Allocator.Persistent);

  public void WriteBytes(void* srcData, int bytes){
    int length = data.Length;
    data.ResizeUninitialized(length + bytes);
    UnsafeUtility.MemCpy((byte*)data.GetUnsafePtr() + length, srcData, bytes);
  }
  public void Dispose() => data.Dispose();
}


public unsafe class NativeListReader : BinaryReader{
  private byte* ptr;
  
  public NativeListReader(NativeListWriter writer){
    ptr = (byte*) writer.data.GetUnsafePtr();
  }

  public void ReadBytes(void* data, int bytes){
    UnsafeUtility.MemCpy(data, ptr, bytes);
    ptr += bytes;  
  }

  public void Dispose(){}
}```

do you see any problems with this code?
tawdry tree
#

@potent cape In my case I do

//In system
protected override void OnCreate(){
 _archetype = EntityManager.CreateArchetype(/*All components except shared RenderMesh*/); 
}
protected override void OnStartRunning(){
  _renderer = EcsUtilities.GetLookFromPrototype("ProtoType");
}

//In job - IJobParallelFor (spawn X things):
public void Execute(int index){
  Entity thing =  ECB.CreateEntity(index, _archetype);
  //Set components
  CommandBuffer.AddSharedComponent(index, thing, _renderer);
}
potent cape
#

Do i miss any for rendering necessary components or so?

tawdry tree
#

@dry dune Never really worked with pointers in C#, not binary readers/writers, but I see no clear errors there. What kind of errors do you get? Or does it just not do what you want? What are you trying to achieve here?

compact hound
potent cape
dry dune
#

@tawdry tree i'm also not fill comfortable with unsafe code, this code works for me, but i'm not sure if it is safe enough to do it this way, would be nice to get some feedback from someone who has a deep understanding of unsafe code magic

stuck hatch
#

@tawdry tree I am using a MVC Software Design pattern to split view and domain logic

tawdry tree
#

Yeah, but I meant more what kind of thing you're making, it doesn't sound like a game.
At least, I can't think of any real-time game that MVC would be suited to. Maybe some on-interaction games like solitaire, but other than that...
Game engines already split render and logic, though the UI tend to be pretty tightly couple with the game, ie domain. Are you making a library/asset?

potent cape
#

I personally have used MVC for idle games

tawdry tree
#

That sounds like a remarkable good fit actually

#

And, in fact, I have an ASP.NET Core (Blazor webassembly) project for an idle game, or at least the framework of one.

#

But I don't really consider them real-time games

potent cape
#

Well they have progress bars and stuff that updates in real time ๐Ÿ˜›

stuck hatch
#

let me start with monobehaviour, often I see developers use them to represent view related things and make domain related things. I dont like to mix them because it produces bad code. I am using a self made design. I have a model the represents something in the game, multiple controller are for the functionality and the view represents data changes to the player.

#

My Monobehaviours are only like output behaviours, sometime they take input, like raycast or button input, are most of the time, they only react to the domain layer

tawdry tree
dry dune
#

@stuck hatch this is a DOD related channel, why we discussing MVC here, it is meant to discuss ECS here which is very different from MVC

stuck hatch
#

sry, it pulled me away

tawdry tree
#

@stuck hatch Are you doing ECS or MonoBehaviours? MonoBehavior discussion is better suited in some other #channel.
Also ECS already splits data and logic, and each system should only have a single responsibility - be that UI stuff ('view layer') or game logic ('domain layer').
Remember that design patterns are just tools, and you ought to choose the right tool for the right job - Even if you're a lot more familiar with the hammer-for-all-nails.

dry dune
#

All native collections are unmanaged, does it mean that they never move in memory after creation?

vagrant surge
#

@stuck hatch mvc with ecs is kinda doing the same thing twice

#

ecs already does most of what mvc is for

#

by the way it works, it already splits everything by default

dry dune
#

key difference is that in mvc data layer is active (it sends notifications to presentation layer about it's changes) but in ecs data layer is completely passive (logic layer have to check for data changes)

vagrant surge
#

MVC is also a heavily OOP based pattern

tawdry tree
#

@dry dune They shouldn't move unless whatever (manualyl) manages then does so, at least. In this case, that would mean deleting and recreating or possibly resizing the collection.

dry dune
#

All native collections are unmanaged, does it mean that they never move in memory after creation?
found an answer: at least NativeList do move while resizing

documentation says:

If the list has reached its current capacity, it copies the original, internal array to a new, larger array, and then deallocates the original.

#

so for my case it should be safe to use memcopy on native list until i'm not writing there at the same time

worldly pulsar
#

if all you need is memcopy, you can just do list.AsArray().CopyTo(otherArray), it does MemCpy under the hood

dry dune
#

i'm doing memcopy to chunk not to another array
i'm trying to write a custom BinaryReader and BinaryWriter to serialize world
to NativeList<byte>(Allocator.Persistent) and deserialize it back

tawdry tree
dry dune
#

yep

tawdry tree
#

Does SerializeUtility.SerializeWorld(EntityManager, BinaryWriter, out Int32[]) and SerializeUtility.DeserializeWorld(ExclusiveEntityTransaction, BinaryReader, Int32) not do the trick for you? Why not?

#

Becauseif that's the case, I'm sure the Unity ECS folks would love your feedback

dry dune
#

yes i do it using SerializeUtility.SerializeWorld
but second parameter is a BinaryWriter i'm trying to create
there only 2 exist, one writes to NativeList<byte>(Allocator.Temp) and returns unsafe pointer to it, another writes to file
what i need is to store serialized world in memory for a long period of time

#

my goal is jump-back-in-time mechanic for my game

#

code i posted above seem to work great, the only thing i'm worry about is if it is safe enough

tawdry tree
#

The NativeList, is that where you store it in memory? Because that Temp allocator is an issue, in that case

dry dune
#

i'm using NativeList<byte>(Allocator.Persistent) for storage

tawdry tree
#

So the temp list is just... temporary, while you copy to a persistent one?

worldly pulsar
#

@tawdry tree see the code like 30 msgs up ๐Ÿ˜‰

tawdry tree
#

Oh yeah, that code

worldly pulsar
#

@dry dune as long as you don't write to the writer after creating the reader, and don't dispose of the writer while you still may need the data, you are fine
(I'd say the fact that writer owns the list and the only way to dispose it is to dispose of the writer is a design issue)

tawdry tree
#

Now that I took a deeper look, I was wondering why the reader needed a writer to be instantiated, but what Rett says is a good point. Why is the list owned by the writer? That seems unnecessarily coupled to me.

worldly pulsar
#

It's a copy of what Unity does, I guess it's fine with Allocator.Temp because it doesn't really care about Dispose()

dry dune
#

@worldly pulsar i'm not sure how to make writer that writes to the given list that he doesn't own

#

but I agree that it is better to store it outside

worldly pulsar
#

I mean "own" in the sense that disposing the writer is the same as disposing the list

#

just grab the list from it instead of deallocating it, and pass the list to the reader

dry dune
#

yes i'm disposing the writer only when do not need data anymore

worldly pulsar
#

then you're fine, again, it's more of an API design issue

dry dune
#

just grab the list from it instead of deallocating it, and pass the list to the reader
i'd like to avoid extra copying so right approach i think is to provide writer with a list to write to, but i have no idea how to pass it this way

mystic mountain
#

Anyone got any experience with using UnityWebRequest with ECS/Jobs?

rare umbra
#

Anyone know if the self writing boilerplate stuff from the keynote has been released in a package yet?

dry dune
#

this week i hope

rare umbra
#

Cool canโ€™t wait

dry dune
#

i'm personally waiting for Hybrid Render package update

instance material property overrides are part of the next entities / hybrid renderer release.

vagrant surge
#

thats huge

#

like really huge

#

it will make easier to do shader trickerye on the instanced units

#

like animation for example

dry dune
#

yes this going to make shadergraph exposed properties work with ecs, you finally be able to make instanced meshes look different

gusty comet
#

Is the Hybrid Renderer required for ECS? Because I'm seriously about tired of it being broke the moment I import it. (on 2019.3 beta 6), newest HDRP and tried the latest two Hybrid Renderers.

twilit coral
#

I got the same errors a second ago, only thing I know is that it works with standard RP

tawdry tree
#

Have you tried restarting the editor after importing/enabling new packages?

slow epoch
#

Is there any reason why when using injection with a gameObject and modifiyng the position of the entity, the gameObject stays in the same spot?

gusty comet
#

@tawdry tree Yeah just tried restarting again just to make sure and yeah the errors stay.

mint iron
#

@gusty comet HybridRenderer and LWRP/URP have been an absolute nightmare for me, breaking more than they fix at the moment it feels like.

gusty comet
#

Yeah it's pretty annoying

mint iron
#

Latest core version for example broke any shadergraph linked to a material with gpu instancing enabled.

gusty comet
#

Dang that sucks

mighty violet
#

I got those hybrid addtional light data errors as well, deleting the files in package cache solves in until I restart unity, then it comes back...

gusty comet
#

Eh I'll just wait I suppose to use Entities. Seems like it's just a lot of annoyances just to spawn in some projectiles lol.

slow epoch
#

I have no idea how to use NavMeshQuery inside a Job

dry dune
#

for me Hybrid Renderer works good with URP

#

but i'm on 19.3.0b1

shut python
#

Hey there, I want to get into ECS and started with these 40 lines of code

https://hatebin.com/fzqycumoar

Unfortunately the Conversion throws an error at the AddComponent method Argument 2: cannot convert from 'NameComponent' to 'Unity.Entities.ComponentType'

Would someone mind telling me what's wrong =?

dry dune
#

@shut python

public struct NameComponent : IComponentData{
    public string Value; // <- string not blittable
}```
shut python
#

@dry dune pardon, what is blittable =?

shut python
#

@dry dune thanks, I already figured that out. But what would be the workaround for that =?

lime kettle
#

Look at NativeStrings

shut python
#

@lime kettle but when I use NativeString64 the error still remains

dry dune
#

if i remember it right you can't burst compile Debug.Log

compact hound
#

Any one know how to add or remove components from job that not have index like ITriggerEventsJob? Don't know what index pass to CommandBuffer. Just 0?

Second question is how to check if component exist form a job that will pass to command buffer.
Case:
2 bullet collides with one body. Both will try to add destroy component to one entity. I can check if component exist before adding it to command buffer but when it will resolve it will try to add 2 components and throw error.

shut python
tawdry tree
#

cannot convert from 'NameComponent' to 'Unity.Entities.ComponentType'
Sounds like NameComponent is Unity.Entities.ComponentType == false, or a fancy way way to say it can't cast NameComponent to ComponentType. Not sure what ComponentType is, though.
Is the error compile-time or runtime?

dry dune
#

dstManager.AddComponentData

tawdry tree
#

Ah, that might just be it

#

WTH is/does AddComponent then? ๐Ÿค”

shut python
#

oh ...

#

thanks ...

dry dune
#

initially misinformed you
AddComponent take a type as second argument not component data itself
to add UnityEngine.Component should be used AddComponentObject

tawdry tree
#

Ahh, so for hybrid?

dry dune
#

yep

tawdry tree
#

Mistakes like that can often be corrected with proper intellisense

dry dune
#

also you can add tag components with AddComponent(entity, type)

mint iron
#

@compact hound for the index you could pass 0 if you're not running a threaded job or probably the proper way is to use an attribute to get the threadindex of the current job injected. I can't look it up for you right now. Check inside any .concurrent collection source code and you'll find it. (Or maybe don't use the concurrent version of command buffer?)

dry dune
#

@compact hound
for double adding same component
before AddComponent command you can add RemoveComponent in order to delete first one
(if i'm not mistaken RemoveComponent do not throw an error if component is missing)

compact hound
#

@mint iron thanks, found this one [NativeSetThreadIndex]

#

@dry dune thanks too, RemoveComponent don't throw errors

gusty comet
frosty holly
#

Subscenes will automatically be converted to entities and you therefore don't need a convert to entity component

If its a prefab and you double click on it. Unity will think its a subscene when its not. This is very confusing and likely will be changed in a future release of Unity

@gusty comet

gusty comet
#

Wait so....do I just leave the ConvertToEntity component on then and ignore the error message? (it's a prefab)

low tangle
#

They are harmless

frosty siren
#

What now the best way to sync Transform with Translate/Rotation DOTS Components when using ConvertToEntity with Injection of GameObject?

dry dune
#

@frosty siren normally after conversion GameObject is removed and you have nothing to synchronize

frosty siren
#

I use hybrid approach and set Conversion Mode to "Convert And Inject Game Object", so entities relates to archetype with Mono components.

slow epoch
#

Also with some monobehaviours that still doesn't have conversion that is needed like the camera

frosty siren
#

The problem is Transform and Translate/Rotation have no auto sync, and the only way i know is to use IJobParallelForTransform job and set transforms manually

dry dune
#

if you need things like camera on ecs side best approach imho is to create your own synchronizer system for it

#

but, camera isn't something that affects performance, so it is not a problem to leave it as game object

frosty siren
#

Actually i need NavMeshAgent that also have no representation with DOTS (i know about git repo with DOTS NavMesh System from one of forum users). I use Move() method of NavMeshAgent and manually rotate my GameObject, so i'm trying to push rotation calculation to the JobSystem

dry dune
#

as far as I know nothing prevents from using NavMesh api directly from entityes, you have to pass colliders and agent data and get tracks, it is all possible without NavMeshAgent wrapper (but I never tried to do it myself)

slow epoch
#

I've tried recently using the NavMesh API for jobs but right now is really incomplete and was only made for the first demo of ecs

#

They have not updated it since then

#

And the user that made it easier hasn't updated it either and it doesn't work anymore

mystic mountain
#

Is there a better way to write string to byteArray than this in a job? x) "acceptLoginData.token" is a NativeString64

            NativeArray<char> tempData = new NativeArray<char>(NativeString64.MaxLength, Allocator.Temp);
            var len = acceptLoginData.token.Length;
            dataWriter.Write((byte)len);
            acceptLoginData.token.CopyTo((char*)Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetUnsafePtr<char>(tempData), out outLen, len);
            dataWriter.WriteBytes((byte*)Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetUnsafePtr<char>(tempData), len * 2);
mint iron
#

maybe you can skip the temp array

        NativeString64* tokenPtr = &acceptLoginData.token;
        dataWriter.Write((byte)tokenPtr->Length);
        dataWriter.WriteBytes(tokenPtr, tokenPtr->Length);
#

or if you know the destination ptr you could just UnsafeUtility.MemCpy it

compact hound
#

I wonder how to apply different logic to different projectiles/skills/abilities. I have ShootingSystem that fires projectile from weapon. For eg. how to apply to some weapon autoaim logic?
I came to one solution to add some component to weapon and ShootingSystem will apply specific shot logic (in this case add target to projectile). But I don't know if its best solution.

dry dune
#

Do anybody have idea how to clone the world with everything it contains
CopyAndReplaceEntitiesFrom does it with errors

#

@compact hound add tag to weapon, put specific logic in separate dedicated system

compact hound
#

@dry dune so there will se actual few shooting systems that will fire projectiles with different behaviors?

dry dune
#

whenever you came to point when your system need a switch/case to behave differently in some cases it is a reasonable time to split that system into two

#

or even 3 if there still a common part

gusty comet
#

If I throw a ConvertToEntity script onto a game object (in this instance the main camera), with Convert And Inject Game Object set, is there a way for me to write a system to interact with it and it alone? All it has is some transform properties so asking for that in a entities foreach would net me basically everything.

slow epoch
#

You can use component as a tag to identify it

gusty comet
#

Just a monobehaviour?

#

or can you place component data onto a converted entity

slow epoch
#

Something like a PlayerCameraTag which is only an empty IComponentData

#

And use the RequiresComponentTag in your job

gusty comet
#

how do you actually add that component into the converted entity though?

slow epoch
#

You can make an authoring monobehaviour that converts itself into the tag

gusty comet
#

oh shit fr

#

ill look into that ty

compact hound
#

@dry dune ok thanks

mystic mountain
#

@mint iron I modified to try cast it, but it doesn't seem that NativeString64 starts with the data of the chars so can't directly cast it x(

            fixed(NativeString64* stringPtr = &connectData.username)
            {
                dataWriter.Write((byte)stringPtr->Length);
                dataWriter.WriteBytes((byte*)stringPtr, stringPtr->Length*2);
            }
mystic mountain
#

@mint iron Changing the order in the Entities packet fixed it (Y) ๐Ÿ˜„

pliant pike
#

I dont suppose anyone knows how you add a component tag to converted entity's in a subscene?(edit figured it out was a wrong naming of a thing)

pliant pike
#

it's interesting though it seems .SetName and RemoveComponent don't seem to work in the conversion

mint iron
#

@mystic mountain sorry that was my mistake, i forgot they have the length first, you could also just add sizeof(int) to your base ptr to skip over it.

mystic mountain
#

@mint iron Yeah, I was considering that, but then I'll have to change code in a lot of places if they change it. Const are memory wise elsewhere right?

pliant pike
#

I dont suppose anyone knows how I get data from entity's converted in a subscene? I thought because they show in the debugger before the program is even loaded that would mean you could use an Oncreate or Onstartrunning method, but it seems like they don't exist till much later

mint iron
#

@mystic mountain yep static&const live elsewhere

pliant pike
#

yeah thanks xzjv I swear it worked at one point I'm having to use this currently to get it to work

#
protected override void OnUpdate()
    {
        NativeList<Translation> tempwapslist;
        tempwapslist = new NativeList<Translation>(Allocator.Temp);
        
        Entities.WithAll<WaypointsActual, Translation>().ForEach((Entity eppy, ref Translation chippy) =>
        {
                        tempwapslist.Add(chippy);
        });
        
        Debug.Log("How large is the list " + tempwapslist.Length);
        if (tempwapslist.Length == 13)
        {
            var entity = EntityManager.CreateEntity();
            EntityManager.AddComponentData(entity,
                new WaypointWalker {Waypoints = WaypointBlobs.ConstructBlobdata(tempwapslist.ToArray())});

            tempwapslist.Dispose();
            Enabled = false;
        }```
dry dune
#

I dont suppose anyone knows how I get data from entity's converted in a subscene? I thought because they show in the debugger before the program is even loaded that would mean you could use an Oncreate or Onstartrunning method, but it seems like they don't exist till much later
when you close the subscene all it's content is converted to entities, those entities are stored on disc in [EntityCache] folder, next this cache loads to the world (this take some time to load), same way when you start the game, cached subscene start loading, so entities are not present in the world for few frames

dry dune
#

i have a singleton component... is it possible to make a system run only when this singleton do not present?

#

something opposite for RequireSingletonForUpdate

naive parrot
#

how do you go about handling animations in ecs?

dry dune
dry dune
naive parrot
#

thanks for heads up!

coarse turtle
#

@dry dune if (!HasSingleton<T>())?

#

or i guess you can make an entity query with none of type <T>

dry dune
#

this not going to prevent system from running

#

query with none of type <T> will give me everything else

coarse turtle
#

Hmm guess you might need something more than just 1 component on said entity or maybe im just not getting the question...

dry dune
#

yes with 2 components it easy, but i'm asking about one singleton component

coarse turtle
#

Hmm, I wouldn't know from the top of my head

mystic mountain
#

@dry dune Early out with a query of singleton component?

dry dune
#

subtractive singleton query

mystic mountain
#

You can do a isEmptyIgnoreFilter on a query to early out on the system.

dry dune
#

interesting idea

mystic mountain
#

I think it would be somewhat equal if(!HasSingleton<T>()) though, if you early out with that as well.

dry dune
#

early out is easy i'd like to not run it at all )

mystic mountain
#

Is there any difference in performance?

dry dune
#

not sure

magic frigate
pliant pike
#

thanks for that info @dry dune that makes sense

coarse turtle
#

only other way I can think of is having a multiplexer system on other systems or component system groups, so you can just loop through a set of systems and turn them off based on some condition

pliant pike
#

yeah I've been trying to figure out something similar with singletons

#

they do need the negative for requireforupdate

quaint snow
#

hello Everyone,
does anyone tried to change subscenes generated Files.entities in "Assets\StreamingAssets\EntityCache" to another location or have an idea on haw to do it?
im trying to do that cause im having a big problem of APK size, the ganerated .entities files are too big arround 150mo but goes down to 10mo after compression.

neon shore
#

Weird, I watched that Havok talk last week already and now it's also unlisted.

winter onyx
#

does Rocket League use havok?

#

has anyone used Cap'n'Proto? maybe in the unity team?

gusty comet
#

So I've been following this vid https://www.youtube.com/watch?v=mL4qrt-15TE&t=921s and it says that "the way we write job systems changed" so the job code example isnt the newest system. Could anyone point me to the talk on the reworked system?

Get a high-level overview of the Entity Component System (ECS) and turn-based game loops, and see a proof of concept built using ECS. The session covers some...

โ–ถ Play video
pliant pike
#

I dont suppose anyone has a clue how I'm getting this warning

#

The previously scheduled job TurnTowardsWhatever:TurnTowardsjob reads from the NativeArray TurnTowardsjob.Data.wappapoints. You must call JobHandle.Complete() on the job TurnTowardsWhatever:TurnTowardsjob, before you can write to the NativeArray safely.

#

I've set it to [readonly] no job anywhere writes to the data, it worked before and now for some reason it doesn't work

naive parrot
#

@pliant pike strangely enough (not really ) i faced the very same thing today. i was scheduling jobs in Update and reading output ( jobHandle.Complete() ) in LateUpdate. as it happens , my routine was wrapped in a class that was polled from a monobehavior and i forgot to poll LateUpdate from main monobehavior resulting in same error. it could be that you are missing something similar in game loop code.

pliant pike
#

yeah, thanks, I dont know its weird the job is really simple, I'm not polling anything

#

it doesn't really matter I just wanted to go back to previous code to check that it still worked

#

guess I cant do that

gusty comet
#

I see a lot of code referencing the attribute [Inject] but it doesn't seem to exist? Is it deprecated, what's the new way? It seems like some magical way people got data into their systems.

pliant pike
#

yeah I'm pretty sure that's depreciated, you use subscenes or convertoentity now

gusty comet
#

what did it used to do? I'm looking into ways to access one entity's translation component to add it to another and I keep seeing [Inject] ..ComponentDataFromEntity

pliant pike
#

yeah just use componentdatafromentity or entityquery now

hollow sorrel
#

from what i remember inject is really old from when they had multiple ways to do things because they weren't sure what people preferred to use and then removed 1 of them (injection) for clarity

gusty comet
#

oh perfect, thank you :)

old pulsar
worldly pulsar
#

@old pulsar replied on the forum, forgot to mention that JetBrains Rider apparently doesn't have any problems with this (and the forum doesn't like it when I try to edit posts for some reason)

dry dune
#

btw Rider is free for open source projects and for students

old pulsar
#

@worldly pulsar worked, thanks!

gusty comet
#

kind of a bummer to find out new in game uielements isn't dots based ๐Ÿ˜ฆ

dull copper
#

a lot of these new systems that release or are about to release now have been set in motion years ago when DOTS wasn't as big focus

#

but yeah, I get what you mean

gusty comet
#

So I've been following this vid https://www.youtube.com/watch?v=mL4qrt-15TE&t=921s and it says that "the way we write job systems changed" so the job code example isnt the newest system. Could anyone point me to the talk on the reworked system?

Get a high-level overview of the Entity Component System (ECS) and turn-based game loops, and see a proof of concept built using ECS. The session covers some...

โ–ถ Play video
dull copper
#

@gusty comet that probably just refers to the constant changes on Unity ECS API. not having watched that video, I'd still suggest to look at the dots sample repo and docs for recent usage info

#

especially the sample repo should be more up-to-date

#

(you can find all these in the pinned message on this channel)

gusty comet
#

thx olento

twin raven
#

@winter onyx I remember Rocket League using modified Bullet physics engine

slow epoch
#

@gusty comet he's talking about the authoring i think, he says that cuz in a prev talk they showed how it's gonna work the authoring from now on and is not necessary to make the monobehaviour component ourselves

mystic mountain
#

One question I've had on my mind lately. Many things can use timers, like after X time do X. Simple here would be to use a component to store currentTime and finalTime and add a tag when it should do X (combined with some other component ofc). Would it be better to have a timerData + system for each individual action that is independent? E.g. timer to send data, timer to swap color on entity. I'm thinking if you have every timer in one system wouldn't it create sort of a sync point?

mint iron
#

Not really sure what you mean about creating a sync point.

I needed a timer to make game elements be destroyed after a few seconds. My solution was to have a 'PendingDestruction' component that contains the time when it should happen. A system goes through each of them and checks the time and destroys only the ones that are ready. Its been super useful.

Some objects start with the PendingDestruction component already on the entity prefab from conversion but its effectively idle until SetComponent populates it so i don't take the costs of adding a component.

mystic mountain
#

@mint iron What I mean is e.g. generic timer system. TimerData { currTime, finalTime}, TimerTriggeredTag {} , TimerSystem (checks timers and adds TriggerTag&RemovesTimer)
Then have SystemA,SystemB,SystemC,SystemD ... etc , query TimerTriggeTag with other Components.
Or have specific AAATimerData, BBBTimerData, CCCTimerData ..., TimerAAASystem, TIMERBBBSystem, TimerCCCSYstem ...

mint iron
#

i see... i think the generic version risks losing some readability. Like, how easy would it be on a larger solution to figure out what any particular timer is for and debug when things go wrong compared to them each being separated and explicit as to what they're supposed to be doing. Like oh its the 'DoThatThing' timer, i imediately know i have to go find the DoThatThingSystem.

mystic mountain
#

Mhm yeah. Also you can have multiple timers on same entity if that's useful. But was wondering in terms of performance of execution : )

mint iron
#

probably faster* to have them consolidated, each extra system does cost you.

#

maybe you could do a DynamicBuffer for timer+enum of what its for. a central system could just go through them with a chunk job buffer accessor, remove the timer, add your tag with ECB or (maybe add to second DynamicBuffer/Queue for triggered timers).

mystic mountain
#

I'll try with one system and see what happens when I hit the wall with full speed^^ ๐Ÿ˜„

dire frigate
#

Anyone had luck compiling DOTS to a build? ๐Ÿ˜…

#

Tried installing the platform packages from the package manager

#

but still get the "Burst Compiler failed running"

dull copper
#

@winter onyx I can confirm that RL used bullet, but not because it would be deterministic (it actually isn't 100% deterministic) but because it was their best option when getting hands on the source code for physics engine and bending it to their will

#

there really isn't a thing like 100% determnism on fast paced physics games anyway, on most physics engines the cache comes in the way, altering the simulation when you resimulate it

#

last mentioned thing is what Unity Physics package tries to avoid with it's stateless design

#

but then there's more things that come into play that make the 100% determnism impossible and that's basically the latency

#

to get 100% same results on each client, each client has to have same inputs for all physically simulated objects

#

and since there's latency between players, you can't have that

#

so your local predictions will always be somewhat off and need to be corrected

#

of course if you got like LAN connection and you got fully determnistic physics sim, then that's another thing

dry dune
#

@mystic mountain about timers,
for my game i need programmatic animations king of DoTween, after trying few approaches i ended up that it is better to store timer data on separate entity.

I have a dedicated entity for each pair of keyframes, that 2-keyframe-animation-entity has a target(object being animated), timing properties(tween duration, delay, current tween time, easing method etc) and values for properties i'm animating.

so for a single target object there may exist few animations for different properties, animation generic system walks over all animations and and updates target's values

https://gph.is/g/4wP09kj
on this gif each cube has 3 animations attached: move up, move down, and rotate, each with it's individual timers

#

all that runs at 300fps with 40k parallel tweens

mystic mountain
#

@dry dune What I'm asking is if I should run it through one system or multiple systems though.

On other note, RemovingTag (triggering) where it is used, or in a separate system at end of frame?

dry dune
#

I have all time calculations in a single place universal for all animations, but specific things for each kind of motion in a separate system

in my case time system that calculates progress for all tweens creates tween-end-tag components (events) and puts them on tween target entity, also it destroy used tween entities

#

consuming that event is a responsibility of that system who started animation

#

but there are few options for event-deletion:

  1. event component may be deleted at the end of the frame (in this case system that run before event creation will never see the event)
  2. allow system that use that event to delete it (problem here is that in some cases this may never happen)
  3. same system who created the event should destroy it on next frame (maybe best option)
mystic mountain
#

Hmm yeah. Didn't consider last. So how bad is it using the entity command buffer then? Doing option 2 would have multiple systems using one.

dry dune
#

entity command buffer is a tool to schedule structural changes after the loop/job end, how it can help with events?

#

i don't think that sharing same ECB across few systems is a good idea

mystic mountain
#

Since "event component"/"tag component" removal is strucural change? I've got the notion that using commandBuffers are slow, hence I wonder if spreading it out on multiple systems would be a bad approach.

dry dune
#

ECB is the only option when you need to destroy something from a job, there is no other faster option

mystic mountain
#

Well as you mentioned yourself you can do it in different ways. One way is using EntityCommandBuffer.RemoveComponent(EntityQuery, TagComponent);

#

Of what I've read, this is extremely fast.

dry dune
#

yes this is very fast

#

this works with the whole chunks instead of separate entities

#

it simply changes chunk archetype

hot comet
#

hi, i'm thinking to re-code my mobile game in ECS but i'm not sure what it will do about performance
currently at my game scripts gets 5-6ms in 1000ms
10-50ms at rendering
so generally i'm like 30-60fps in android
if i re-code it in ECS, what would change?

forest gulch
#

Hey, how can I make a MonoBehavior component without the Update/FixedUpdate call? I want to make a hybrid-esque game with DOTS but I don't want to use a MonoBehavior because of the Update/FixedUpdate methods and stuff.

dull copper
#

@forest gulch just don't put the Update or FixedUpdate methods there?

forest gulch
#

Aren't they gonna be called anyway though?

dull copper
#

no

forest gulch
#

I mean, I don't really know how Update, Start and these methods work. Normally I'd use override but I don't see them there, so I don't know what's going on

#

Oh, I see. I that does make sense.

#

Alright, thanks :)

hot comet
#

could anyone help me?

hi, i'm thinking to re-code my mobile game in ECS but i'm not sure what it will do about performance
currently at my game scripts get 5-6ms in 1000ms
10-50ms at rendering
so generally i'm like 30-60fps in android
if i re-code it in ECS, what would change?
worldly pulsar
#

@hot comet You're asking us to analyze a game we know literally nothing about. The only thing I can tell is I doubt rewriting to ECS will reduce rendering time.

hot comet
#

actually the only thing i was curious about it was this, does it reduce the rendering time or not @worldly pulsar

vagrant surge
#

no

frosty siren
#

why no?)

#

If he have hundreds GameObjects with the same mesh renderer and filter, rewriting the game to DOTS with GPU instancing will give huge performance gain i suppose

worldly pulsar
#

In my experience the MeshRenderer pipeline is about on par in terms of performance with the Hybrid renderer, and if you want to render anything other than static meshes you pretty much have to use Hybrid ECS anyway (i.e. you don't drop the spawn/move gameobject overhead)

#

Yea, or you can just use GPU instancing with MeshRenderer

frosty siren
#

Is ECS system that renders graphic uses Jobs?

worldly pulsar
#

MeshRenderers use jobs as well

dull copper
#

unity's internal rendering is jobified too

#

I don't know how far they've gone with the built-in but the native side on SRPs is jobified

vagrant surge
#

yes

safe lintel
#

wasnt it a work in progress for jobifying the srp though?

frosty siren
#

If we raised the topic of DOTS using by built-in part of unity... I saw that animator does some work in job threads. And i'm very interest in new Animation Rigging package, because documentation says that it uses jobs. In my project i see terrifying duration of animation execution on a main thread, so i thought about using this package. But does it make sense?

dull copper
#

@safe lintel I talked with HDRP dev at Unite about this and the reason why we don't see bursted jobs on the SRPs is because most of the heavy lifting is already done on the native side

safe lintel
#

ahh

dull copper
#

I guess there could be still some c# things they could do better but that was like the general reason why it is like that

coarse turtle
#

oh interesting to know

dull copper
#

I'm just happy I asked many of these things on the expo floor and not on the NDA events so I can share what I know ๐Ÿ˜„

#

too bad my memory isn't doing me favors, I was told so much more in depth answer on that but can't rememer the fine details anymore

#

the main point was still that they do have all that stuff jobified, just not on c# side

safe lintel
#

glean any tidbits that you can share for dots that they didnt mention in the videos?

dull copper
#

I didn't really have time to discuss much with dots people, kinda missed most of the dots sessions too due to scheduling

#

I only briefly talked with Lucas about hybrid and DXR

#

but answer was pretty much expected

#

it was along the lines it'll happen at some point when they have time to integrate everything properly, it's not broken by design, just not developed right now to be compatible as it's done in parallel

#

well, I did talk briefly with the Andreas who does low level Burst code

#

his response to my questions wasn't super surprising either ๐Ÿ˜„

#

I asked if double precision SIMD is coming to burst with AVX etc at any point and the response was pretty much that you'll be doing things very wrong if you need doubles in game code

#

so, wouldn't hold my breath on getting the extra speed on double math ๐Ÿ˜„

vagrant surge
#

the only reason you might want doubles is if you are doing planetary scale logic

#

with milimeter detail

dull copper
#

I can understand his stance on this but not everyone cares about the brute force speed here, when you do like proper simulations, you care about the extra precisions

#

well, it doesn't even have to be huge scale

#

but yeah, if they would just support 4wide double math on burst via AVX, it would be easy 4x speedup

#

it doesn't matter if it's still way slower than single precision floats

#

as it's still fast enough for most purposes

#

but getting that free perf would still be nice

#

like, I did my own double precision physics solver on ue4 that ran single threaded and I could simulate my limited rigidbodies at 10kHz rate with it... with zero SIMD math

#

but with proper optimizations I could have easily done way more

#

the actual target I was heading at was like 240-360 Hz rate so that was totally within reach

#

other question I asked was about burst function calls without jobs... because they would be just so handy

#

but the response I got there was that I should just jobify everything

#

of course they want to make that happen eventually but it's probably not going to happen soon

safe lintel
#

i reckon a lot of people will be inquiring about the lack of double precision as time goes by

dull copper
#

it's not really a thing game engines usually support

#

and in general, I'm happy that we even got double support on the new mathematics lib

#

it's still not burst supported but at least it's not totally neglected

#

I think mainly transform math is missing

#

like, if you want to do double precision world, you have to roll out your own double precision transform setup

#

but rest of the math operations should be there in doubles too

#

I was actually one of the first people who kept nagging about the lack of doubles on the new math lib

#

as more people kept asking, they just implemented it on the math lib, I guess to keep us quiet ๐Ÿ˜„

#

it wasn't really huge effort for them as it's just mirroring what they do with regular floats minus the burst optimizations

#

I don't think the AVX support would be that huge task for them if they really wanted to make it happen either

#

but it has more limited platforms that can benefit from it

vagrant surge
#

their vectorization is basically llvm default vectorization

#

they dont really do that much, other than some LLVM codegen that allows LLVM to vectorize it well

dull copper
#

tbh, I haven't tested if burst actually does vectorize doubles

#

probably should have

#

but the official stance have always been it's not supported by burst

#

oh wait, Burst compilation is still restricted to SSE4 on PC

#

so even if it would do that, it wouldn't help much as SSE4 can do doubles only 2-wide

#

they did make the cpu extension autoselection somewhat recently, so they could just add AVX to that if they wanted

#

right now PC builds can have both SSE2 and SSE4 compiled and it picks the right one at runtime

#

because there are still old amd phenoms and some other same era cpu's around that don't support SSE4

#

those computers wouldn't run modern games well anyway but people can get quite vocal when the game just refuses to launch vs when it runs 15 fps

covert spire
#

So I'm trying to start a project using DOTS but the only tutorials I can find are from 2018. Is making a "bootstrap" with [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] still necessary?

coarse turtle
#

Best to use the EntityComponentSystemSamples github pinned to this channel as a good way to see how DOTs works

#

You can try recreating the examples to have a basic understanding/practice how to get things working

#

The RuntimeInitialization isn't necessary

dull copper
#

@covert spire try the official docs first, all internet tutorials are just horribly outdated

#

you can find the official stuff linked in the pinned message here

#

along with the already mentioned sample repo ๐Ÿ™‚

old pulsar
#

Are chunk components a recent edition? Their documentation is very thin, and I can't find any videos talking about them.

They sound like shared components in that a chunk only has one value for a chunk component rather than per entity, but unlike shared components these are regular IComponentData blittable types and so can be accessed in jobs. It also seems to differ in that multiple chunks with the same chunk component value have their own copies (whereas ISharedComponentData values can be shared across multiple chunks).

They are also stored external to the chunk itself, though I'm not clear on how exactly. Looking through the entities package code, they seem to be stored on a 'metaentity' of the chunk, but the code gets very hard to follow from there.

I'm especially unclear on what happens when you add a new entity with a given chunk component value: if the entity is guaranteed to be added only to chunks that share the same value, how is that guaranteed? Are the values hashed like ISharedComponentData?

What is the full list of differences between chunk components and ISharedComponents and their intended use cases?

safe lintel
#

where did you see mention of chunk components? did you mean chunk jobs?

gusty comet
#

out of curiosity, being stateless unity dots physics should be easy to modify for origin shifting right? I'm not sure if havok has that kind of support since its cached and all

dull copper
#

shouldn't be super hard

safe lintel
#

or did you mean ArchetypeChunkComponent(Type)s?

#

bah shouldnt check discord before sleep ๐Ÿ˜„

mint iron
#

@old pulsar its not something i've played with yet but i'm also pretty curious about it. Here's some relevant info from the source:

A chunk component is common to all entities in a chunk. You can access a chunk IComponentData instance through either the chunk itself or through an entity stored in that chunk. In either case, getting or setting the component reads or writes the same data.

So can be accessed with a reference to any entity in the chunk or the chunk itself (or EntityQuery). Internally there's a metaChunk Entity and Archetype attached to the chunk which contains the layout and data and presumably is shared across multiple chunks.

Removing the chunk component from an entity changes that entity's archetype and results in the entity being moved to a different chunk (that does not have the component). Adding a chunk component to an entity changes that entity's archetype and results in the entity being moved to a different chunk, either one that already has an archetype containing the chunk component or a new chunk.

So you could deliberately split data with same Archetype using this mechanism, similar to with SharedComponentData. I wonder what happens when there are no longer any entities matching an archetype with added chunk data).

low tangle
#

also what about race conditions?

#

I guess per chunk thread so its okay

#

still seems odd, I think it was used for chunk render bounds for the level streaming system

#

for mega city

#

the uh talk on how they did hlods has it in it, for megacity

simple cradle
#

is it possible to use the 2d animation package (the bone based animation stuff) with ECS? At least in some hybrid way?

old pulsar
gusty comet
#

btw, How do you guys go about doing controlled system activations? Do you add/remove flag components at runtime? Do you have a bool on a component and check against it?

plain cloak
#

Depends on the activation frequency for me. If it keeps changing every couple frame or so I use bool check but if it is less frequent I try to use tag components. Here is good article about it https://gametorrahod.com/tag-component/

gusty comet
#

so I guess you define flags as the ones with bools in them

plain cloak
#

edited the typo, my bad