#archived-dots

1 messages ยท Page 6 of 1

robust scaffold
#

Also reading through the code line by line, seems like unity does not actually reduce the memory taken by physics world unless a hard reset (disposal and then restarting the physics systems) is done. Physics allocates the maximum amount of bodies across all frames and uses it. Fine except in cases where there's a sudden spike in bodies and then reduces back to normal. Physics will continue to operate with the spike quantity as its capacity.

#

#1 change I would make 100% if I was CTO at unity: remove batchIndex from IJobEntityBatch Execute() parameter list. Make one with BatchIndex if people will be using it. Dont include it by default in IJEB because it fucks with intellisense since the var that needs to be used starts with batchIn... I want to be able to type: ba and instantly get the variable I want first and by default.

rotund token
#

#1 change I would make 100% if I was CTO at unity: remove batchIndex from IJobEntityBatch Execute() parameter list. Make one with BatchIndex if people will be using it.
what benefit does this provide?

#

just your intellisense?

#

my ide learned that it was the wrong one ^_^"

robust scaffold
#

It cant be that hard. We have a separate IJEB with entity index. Just make a third with batch index as a parameter as well. Come on unity.

rotund token
#

i doubt it'd be hard but it's kind of annoying

#

even having withindex is annoying

#

but that is done for performance reasons

robust scaffold
rustic rain
#

just naming pattern?

#

tbh, you can simply use IJobParallelFor

#

you'll simply have to switch 1 line in which you assign query to scheduling

#

to assigning chunk list to field of job

#

oh wait

#

you'll still have index...

#

nvm xD

robust scaffold
rustic rain
#

ah, this

#

it is indeed annoying xD

robust scaffold
#

I have found 0 actual use for it in my logic so far so it's just a complete annoyance.

rustic rain
#

simply renaming

#

IndexOfBatch

#

will fix it, hehe

rotund token
#

i think i've only ever used it once for something else, something thread safe related

#

index for native stream maybe

robust scaffold
#

You know what else I would change?

#

This giant list

#

It's getting as large as my screen is tall.

#

Huh, did they change how struct systems work? I cant cache a native array into the property field of the ISystem struct.

#

And yes, i'm disposing of it in OnDestroy(). I get that error one frame 1.

rotund token
#

you can't until 1.0

#

the dispose sentinel is a managed object

#

it gets nulled in burst

robust scaffold
#

Oh, oof. Right.

rotund token
#

so it's lost and can't be disposed

#

can only store unsafe collections atm

robust scaffold
#

It is just one sized array so nothing major. Shame.

rotund token
#

the one major remaining painpoint in ISystem imo

#

oh and commandbuffer i guess

robust scaffold
rotund token
#

You did note earlier that arrays allocated with the update allocator can be reused across frames
did i? because it can't really

#

they last 2 frames

#

and the memory is then re-used

#

2 frames because the world alternates update allocators every frame

#

this means you don't need to sync point end of frame to return the memory

#

and can still update through to the next time the system updates (in which case it auto completes)

robust scaffold
timber ivy
#

is it bad practice to change the mesh frequently on the hybrid renderer?

robust scaffold
timber ivy
#

Yeah I was just looking

#

looks like I can just adjust vert positions in shader

#

and bake verts to a texture

robust scaffold
#

Hybrid renderer is just a really fancy dynamic indirect draw call system. Doesnt change the rules around rendering.

robust scaffold
#

A heightmap texture, generate a plane with vertices at every pixel.

timber ivy
#

So how would I go about generating a texture from a 3d animation I am trying to google around but just keep getting stuff about 2d

robust scaffold
#

However it is fundamentally the same. The math though is exponentially harder.

timber ivy
#

What data do I need to save to the texture? vert position ofc anything else?

robust scaffold
#

It's tessellation shader so it's a decent jumping off point to proper vertex welding and ordering.

#

There's no index buffer so it's a simplified version.

timber ivy
#

awesome thank you very much!

robust scaffold
#

That might also help. Typically 3D mesh generation will use a combination of the two.

robust scaffold
rustic rain
#

Float3x3 let's go

robust scaffold
#

Yep. But then I'll have to either messing with the very slow 2D Entities sprite renderer or roll my own procedural drawing system

rustic rain
#

Off roll your own

#

I suggest making auto atlassing

#

And simply draw all sprites indtanced

robust scaffold
#

I dont want to do the latter since I've seen how good the hybrid renderer API (dont know about the package) of 2022 is and I want to work with Unity, not against if I had a choice.

rustic rain
#

Well

#

In this case

#

You can use RenderMesh

#

But it won't use atlassing

#

My suggestion roll your own

robust scaffold
#

Ehhhhh, I dont want to put up a temp solution if it's gonna be superseded within an update.

rustic rain
#

It shouldn't be too complex

#

It all can be done in just 2 systems

robust scaffold
#

The only reason I rolled my own lighting is due to custom needs. My own physics because Unity themselves said they fired everyone working on 2D DOTS. And possibly my own netcode because I want peer to peer, not peer to server.

rustic rain
#

Sit I swear 2d rendering will be fast

#

Sir*

robust scaffold
#

I know, I made my own 2D lighting. I know how fast it is.

rustic rain
#

If you just use combination of atlas and instancing

#

You don't need procedural

#

Even

#

Or if you really want

#

You can make it the way turtle did

#

By creating mesh every frame

robust scaffold
#

I just, really dont entirely care about the performance cost of sprite rendering right now. I will have to either roll my own or somehow bend a material to my will as my lighting needs hooks into determining what to render so I'm thinking about it.

robust scaffold
rustic rain
#

No

robust scaffold
#

And scale it in shader using a compute buffer.

rustic rain
#

It's complex mesh

#

With as many vertices as there are entities x 4

#

Or more

robust scaffold
#

Why?

rustic rain
#

Since you need uv too

#

Because you want to draw it call in one call

robust scaffold
#

Fuck, you're gonna make me roll my own sprite renderer just to prove you wrong

#

i dont want to though, physics is more interesting

rustic rain
#

But it's literally what tertle did

#

Kek

#

We compared his drawing system and HR

#

It was similar somewhat

robust scaffold
#

Does the sprite atlas v2 in unity pack concave sprites within / on top each other?

rustic rain
#

Concave?

robust scaffold
#

Like a U sprite and a N sprite, does the atlas merge the U and N on top of each other? A leg of the N inside the bowl of the U.

#

Or does it specify rectangular bounding boxes for each sprite?

rustic rain
#

You define it

#

Either full rect or as packed as possible

#

I prefer full rect

robust scaffold
rustic rain
#

Due to simplicity

#

So what I suggest

#

2 options

robust scaffold
#

No need for complex meshes. 6 vertices is all you need and you can make it a const static float2 in the shader.

rustic rain
#

Either collect all matrices and draw quads instances

#

Or use matrix to get local to world quad vertices and uv

#

Combine all in one

#

And draw in one call

#

Two ways I know of

robust scaffold
#

Sprites can rotate though, but for a 2D sprite renderer, the GPU upload would be a 3x3. 2x3 used by the L2W and 2 floats on the C2 row for sprite UV on the atlas.

rustic rain
#

Both proven to be fast

#

Rotation is simple

robust scaffold
robust scaffold
rustic rain
#

You just get matrix for each vertice and multiply by ltw or entity

#

Best part it's super fast math

#

At least in float4x4 world

#

No idea if you can vectorize float3x3

robust scaffold
#

That means GPU upload can be 1 float for angle, 2 floats for position, 4 floats for min max UV of the sprite in the full rect sprite atlas. 7 floats though.

rustic rain
#

Hmmm

robust scaffold
#

3x3, with 2 floats left over for anything else.

rustic rain
#

That's some custom stuff

#

GPU will only accept 4x4 matrix

#

Or maybe vector3

#

Or mesh

robust scaffold
#

Definitely not, my lighting shader, which is basically a sprite-less sprite renderer I'm talking about, accepts float4s:

rustic rain
#

Through custom buffers

#

But I talk about normal shaders

robust scaffold
#

That is a normal shader.

#

It's all shaderlab.

rustic rain
#

I mean literally shaders for built in or srpw

#

Not your custom

robust scaffold
#

And this is constructing a 4x4 L2W from a float3.

robust scaffold
rustic rain
#

Or thus

#

This

#

I mean

#

Do you really expect every 2d enthusiast to write their own shaders? xD

rustic rain
#

Rip

#

I don't see a problem using 4x4

#

Just converting from 3x3

#

On bursted jobs

robust scaffold
#

3x3 only advantage is memory size. Burst will treat a 3x3 as a 4x4 regardless

rustic rain
#

Yeah

robust scaffold
#

well no, a 3x4

rustic rain
#

Anyways

robust scaffold
#

as the last row wont need a vp operation.

rustic rain
#

Your approach means no compatibility with 3d

robust scaffold
#

Yea, I have 0 plans for 3D.

rustic rain
#

Meanwhile I don't want to miss out on that

robust scaffold
#

How would 3D even interact with 2D?

rustic rain
#

Well

#

Ships asteroids and etc are 2d

#

Starts planets 3d

#

And they rotate

#

Without any spritesheet

#

Thus no need for pre drawn animation

#

Ability to use shaders for burning effect

#

Or planets atmosphere

#

That's my perspective

robust scaffold
rustic rain
#

I don't have enough strength to implement all of it kek

#

I want to be close to release in one year

robust scaffold
#

It's just an addition to the UV multiplied by time

#

Ah, release

rustic rain
#

At least playable alpha

robust scaffold
#

I am also not planning on ever releasing this.

rustic rain
#

I can't afford simply developing stuff with getting nothing out of that

#

Can't even apply for a job sadkek

robust scaffold
#

Thats why I hobby dev. I'm grinding away at grad school in an completely different field from game dev.

#

hobby dev is fun. professional dev is not

rustic rain
#

I am very happy that I'm finally working with internal logic of game

#

Currently making Dev tools

#

Which will be used by modders or cheaters kek

#

Although implementing it is pain kek

#

Have to work with UI a lot

robust scaffold
#

Maybe look into how unity dots editor tools interact with the editor's UIE.

rustic rain
#

Dev tools are runtime

robust scaffold
#

it should be directly applicable considering they're working with the sum of all entities in a world and displaying it

rustic rain
#

No editor here

#

Hehe

robust scaffold
#

As in use their method of interacting with UIElements to help with figuring out a way to interact with runtime UI Elements.

#

It's the same API.

rustic rain
#

Ah

#

It's already a thing

#

Ui debugger

#

Let's you inspect unity ui

robust scaffold
#

It's more the Entities to UI hook that I'm interested in. Not the actual construction of the UI itself.

rustic rain
#

Oh

#

It's all open source

#

Why hooks?

robust scaffold
#

They have to display a lot of data from a lot of entities every frame. And they do so.

rustic rain
#

You can literally just copy package to local and modify it

robust scaffold
#

Yea, I need to see what they use though. I havent dug into the package yet.

#

UI is a long way away so it's not a priority.

rustic rain
#

I constantly get error from internal logic xD

#

I'll send you stacktrace

#

Smth related to null archetype

#

I think it's because I use generics

robust scaffold
#

What, Im not gonna be looking into it now.

#

I'm already going line by line through the physics package. I cant start on the UI at the same time.

rustic rain
#

Yeah

#

That's kinda what I also mean by using simpler approach with urp xD

robust scaffold
#

Sprite rendering with custom shaders is simple enough though

rustic rain
#

Don't think I'm capable of reimplementing everything without burning out

robust scaffold
rotund token
#

just be a full time dev and do long hobbyist hours

#

really maximize the burnout

rustic rain
#

Can't apply kek

#

Have to burn out on part time job

pulsar jay
#

Anybody knows if its possible to sort systems from another assembly. E.g just define that SystemA should be updated after SystemB although those are defined in other assemblies?

rustic rain
#

Only during runtime I think and through reflection

#

You have access to system's list

#

And you can probably edit constraints

#

Idk how tho

#

No idea about System's thi

#

ISystems

rotund token
#

easier to just add them to your own system group

#

and override the sort

#

rather than use reflection probably

rotund token
#

basically just have to train up everyone from scratch

rustic rain
rotund token
#

we're hiring atm! fully remote just unfortunately australian time zone =\

candid epoch
#

Well a lot of people dont trust experimental packages ๐Ÿ˜‰

rotund token
#

good chance not a single applicant i interview on friday will have even heard of dots

candid epoch
#

Had a lof of interviews where they heard about it but never used it.

pulsar jay
#

But the relation is not implicit in either of the packages / assemblies. It might be project specific. So there should be a way to define their order in a third assembly

#

Otherwise it might get even worse with package manager and package dependencies. Packages would need to have a lot of dependecies on packages they might not even know of just for sorting and on the other hand you might have packages that you just cannot use because they dont fit in the order of your system groups ๐Ÿค”

rotund token
#

where that project wouldn't have a 3rd assembly couldn't simply put ordering on IK/Movement

#

and achieve the same thing

pulsar jay
candid epoch
pulsar jay
candid epoch
rotund token
#

it doesn't need to be in either package

pulsar jay
#

but this does feal like a hacky solution. having and empty system as a splitter hanging around

#

it should be pretty ease for unity to implement some static method like UpdateAfter(System a, System b)

#

Otherwise this will get a real mess when working with a lot of external packages using ECS

pulsar jay
rotund token
#

that was my original suggestion

rotund token
#

every single system group would need to look for this

#

they specifically switched away from explicit ordering a long time ago

pulsar jay
#

The only thing this would change would be that this Ordering Attribute or Method would not have to be attached to a specific class definition

pulsar jay
viral sonnet
#

Unity 2023.1.0 Alpha 4 is out

rustic rain
#

is that supposed to be a version with entities as default workflow? xD

robust scaffold
safe lintel
#

noticed that joachim's gpu repo uses some of the new baking api that I assume is 1.0 stuff

robust scaffold
#

It's replacing the GameObjectConversionSystem for a much more succinct name.

#

And better code gen

safe lintel
#

yeah

#

any hints on if the baking system can be multithreaded?

robust scaffold
#

Ugh, im gonna see if I can roll my own local to world. 2D is only 6 floats. 3D is 16. That's 10 floats of wasted bytes per entity

safe lintel
#

gonna have so many authoring components to convert with this update

rustic rain
#

oh man, I hope I will be able to avoid codegen fully

robust scaffold
safe lintel
#

I always kinda hated that thing so I dont think I ever used it more than once or twice for test components

robust scaffold
safe lintel
#

maybe its because I keep renaming things but it broke a few times here and there and I just swore off it. wonder if they do some replacement for it though

#

was enable disable supposed to make it for 1.0? almost forgot about that ๐Ÿ˜…

rustic rain
#

๐Ÿ‘ด

#

wonder if it'll actually make it to production

viral sonnet
#

i have c# templates for authoring comps (so just copy/paste). who needs code'gen for something that simple. plus, i like the versatility it gives to customize the editor

viral sonnet
#

the superluminal profiler is really quite something. it's vtune + vs profiler in a package that actually works without weird problems. funny in that sense that it just looks like a remix of both profilers at first glance

#

and it weaves code lines + assembly together which is probably the coolest thing about it

coarse turtle
#

yep ๐Ÿ˜„

robust scaffold
#

Tada. Removes 10 unused floats from my entities.

viral sonnet
#

now i just need to get better at reading assembly because most issues i have are related to random memory access

balmy thistle
#

An evergreen skill to have

viral sonnet
#

i'm looking for r11, yet the whole assembly of the method has no other mention of r11

#

makes me think i'm just looking at a fragment. :/

#

the burst inspector needs a simple, open in browser

robust scaffold
#

Wow, math.select drastically changes the burst output. And I dont know if for the better or not.

viral sonnet
#

which type are you using it with?

robust scaffold
#

float2s

#

math.select(new float2(1), position[i], hasPosition) vs hasPosition ? position[i] : new float2(1)

viral sonnet
#

ah yeah, should be for the better. have you used it instead of branching?

#

what's the assembly?

#

i was more thinking about the selector type. you are using bool, right?

robust scaffold
#

yea, bool

viral sonnet
#

kind of surprised to find it different. if you look at the math select code it's literally the same "? :"

robust scaffold
#

I cant really post the assembly. it's such a drastic change it changes full pages worth of assembly

viral sonnet
#

i've never seen new(1) instead of 1.0f ๐Ÿ™‚

robust scaffold
#

Math.select definitely simplifies the code. If all three checks were inline tertiary ifs, it would create a branch for each one

robust scaffold
#

Makes refactoring a lot easier as there's less strongly typed new statements floating around

gentle harness
#

Is this valid?

...Inside system...
protected override void OnCreate()
    {
        controls.Player.SelectSingle.performed += _ =>
        {
            Entities.ForEach...
        };
    }
robust scaffold
#

You'll be safer off making a IJobEntityBatch and then adding the scheduling code inside the event rather than a ForEach lambda.

robust scaffold
# viral sonnet kind of surprised to find it different. if you look at the math select code it's...
float2 trans  = hasPos ? pos[i] : float2.zero;
float2 scale  = hasScalar ? scalar[i] : new(1);
float2 sinCos = hasAngle ? angle[i].ToSinCos() : new(0, 1);
// float2 trans  = math.select(float2.zero, pos[i], hasPos);
// float2 scale  = math.select(float2.zero, scalar[i], hasScalar);
// float2 sinCos = math.select(new(0, 1), angle[i].ToSinCos(), hasAngle);
``` It seems like the tertiary if (not commented) generates a branch for each if statement (since they're constant for the duration of the for loop) whereas math.select requires a check every loop iteration despite the bools being constant.
safe lintel
#

@gentle harness ill say sort of no because assuming you are using the builtin bootstrap, you want to perform anything involving iterating over entities inside of OnUpdate

robust scaffold
#

hrm, for best efficiency, i might need to gently nudge the compiler to generate a jump table...

safe lintel
#

@viral sonnet supposedly burst knows how to handle math.select specifically

robust scaffold
#

Actually, that code doesnt even matter. I no longer have optional transform components so all three bools will always be true.

#

Custom local to world matrix is nearly 1/3 the size of a full one.

#

Wait. Holy shit: It's fixed. I didnt realize it until now but I think 2021.3.6 fixed the DOTS inspector blue highlighting of selected entities.

#

I was wondering, why is this inspector workflow so usable and then I realized, the selected entity was actually highlighted.

rustic rain
#

nope

#

21.3.7

#

not fixed

robust scaffold
#

Huh. Why is mine fixed then?

rustic rain
#

no idea

robust scaffold
#

In that case. I am never updating my unity editor until 1.0 releases. This makes the 3 new windows actually pretty good.

pallid shale
#

the selection highlight issue is a com.unity.entities package side issue - the fix was package side. So maybe you need to update your package version? Can confirm, as the dev that fixed it, it was indeed bugged and subsequently fixed. @rustic rain

robust scaffold
#

Yea, it was updated yesterday. I have no recollection of actually pressing the update button last night.

viral sonnet
#

oh what? stealth entities update?

#

yep, any other changes? there's no changelog

rotund token
robust scaffold
#

Oh my god, they also fixed the very annoying source gen hard error. I even put together a script to delete the temp folder and then recompile all scripts.

viral sonnet
#

time to finally move to 2021?!?

robust scaffold
#

Wait what?

com.unity.jobs to version 0.70.0

robust scaffold
# balmy thistle The ILPP error?

Nah, the source gen error where randomly it would stop code gen'ing entirely if it could not delete and recreate the temp folder (where the generated code output would go for viewing, not actually used in the code).

balmy thistle
#

Aaaaah, yes

robust scaffold
#

You either had to completely restart the editor to clear the folder or make a script to do it.

#

Also seems like the jobs package just got rolled into collections

#

com.unity.jobs is a deprecated package. This code for this package has been combined into com.unity.collections-1.4.0, please prefer that package instead.
Thats the 0.70 jobs change.

#

The com.unity.jobs package has been merged into com.unity.collections to resolve circular dependency issues that can occur when using Unity 2022.2+.
Seems like they're prepping for release soon^tm.

balmy thistle
#

Very exciting

rustic rain
#

Smth that will never be fixed

rotund token
#

It's not fixed? I fixed it locally was easy.

viral sonnet
#

hehe ๐Ÿ˜„ yeah, i'll move to 2021 when the il2cpp generic bug is fixed

robust scaffold
#

You can compile with il2cpp, if you turn on the smaller builds setting

rustic rain
viral sonnet
#

solving random memory access is such a pain. everything that involves source->target is ... ugh. what's the secret behind it to untangle this. a few ptr accesses are like 90% of my performance when calculating a spell.

robust scaffold
robust scaffold
rotund token
#

@rustic rain

robust scaffold
viral sonnet
rotund token
#

It's a nice little window and I wanted to reuse it so had to fix!

robust scaffold
# viral sonnet solving random memory access is such a pain. everything that involves source->ta...

For example, i had a bunch of light entities that formed a halo around a light source for soft lighting emulation. When I tried to figure out a way to properly transfer the "parent" light's position to the "child" halo lights, i ran into a problem of random access. So instead I completely restructured my light GPU data generation to instead re-compute a halo light position from the original parent light. No child light entities needed.

rustic rain
#

I meant build assets

viral sonnet
#

my current problem is calculating a spell and about stats from source/target. i could make a data structure that is linear to the problem but maintaining this is not feasible and it gets absurd when AoE spells with several targets are involved. i would have a great data structure that is linear to my problem with lots of other read+writes to maintain it, which would make it overall slower because i can't really cache it. i'm not seeing the solution here.

robust scaffold
#

Then have the spells only apply modifiers onto those universal components. From there, it's the same as a physics sytem.

#

Where spells are "forces" and whatever they modify being the "transform"

rustic rain
viral sonnet
#

one method is rolling a spell result. it's simple and fast, what's not is getting the stats var targetDodgeChance2 = targetStats[(int)StatType.Dodge]; var targetParryChance2 = targetStats[(int)StatType.Parry]; var targetBlockChance2 = targetStats[(int)StatType.Block]; var sourceCrit2 = spellStats[(int)StatType.CriticalStrike]; var hitChance2 = spellStats[(int)StatType.HitChance]; i have even aligned them in memory to get advantage of a cache line but it's still 2 random access. :/

#

i mean, all things considered. it takes 3.5ms for 250k spells to calculate

#

i just think, if i could solve this i could apply the solution to more places

rotund token
#

This would only happen once in spell creation right?

viral sonnet
#

yes

rotund token
#

Which at 250k would mean you're creating 15 million spells a second at 60fps

#

That seems like enough for most use cases =D

viral sonnet
#

oh no, it's really just the 250k spells per frame

#

what i meant previously was caching a data structure that is linear for spell calculation on target switches but it's not a solution for AoE spells sadly ๐Ÿ˜ฆ only for single target

#

now i get what you mean... lol, yeah it would really be 15 million spells haha

#

not concerned about performance that much, i mean, yeah a side effect. more about getting rid of random memory access and i feel like source/target is such a common pattern in game design

rotund token
#

My problem is less about random access performance

#

More about managing references

#

When target or source destroyed etc

viral sonnet
#

yep, also painful. it's pretty much either check for existence or manage a reference buffer. both are not great solutions imo. a simple HasComponent check is faster, although when there are more references it doesn't scale well

gentle harness
#

What happens if I create a ecb from BeginSimulationEntityCommandBufferSystem from a system running at LateSimulationSystemGroup?
Does the buffer play back next frame or is it lost?

rotund token
#

Next frame

gentle harness
#

Sweet, thanks

rotund token
robust scaffold
#

Huh, they did

drowsy pagoda
#
[ReadOnly] public EntityTypeHandle entityTypeHandle;

public void Execute(ArchetypeChunk batchInChunk, int batchIndex) 
{
  var entities = batchInChunk.GetNativeArray(entityTypeHandle);

  var i = 0;
  while (i++ < batchInChunk.Count) 
  {
    var entity = entities[i]; // this is where IndexOutOfRangeException is thrown
  }
}

Can anyone enlighten me as to why, or what situation, the IJobEntityBatch would throw index range exception on an array retrieved via EntityTypeHandle?

rotund token
#

because you're using 1,2,3,4... not 0,1,2,3...

#

use a for loop mate ^_^'

drowsy pagoda
#

Yeah I realized this after change to for loop. I thought that i++ returns current value, then increments?

rotund token
#

it does

#

var entity = entities[i];

#

but it's incremented here

#

the check is fine

#

but on the next line it's now incremented which is where you are using it

#

0 < count
entities[1]
1 < count
entities[2]

drowsy pagoda
#

Oh! duh.

#

I suppose I could've just entities[i++], but yeah it's bad practice

robust scaffold
drowsy pagoda
#

I bet!

viral sonnet
#

next up, using goto

robust scaffold
#

Does anyone know of a way to get a singleton during conversion from a separate conversion system?

rotund token
#

I assume you're suggesting what you're doing is not working?

#

Why not?

robust scaffold
#

nvm, figured it out

viral sonnet
#

how would i do this best? i want to debug step a certain assembly line. i just have no idea how to either setup rider to debug an assembly or in VS to find the actual assembly line i'm looking for. scrolled through endless code but never found the right method.

rotund token
#

i'm kind of confused what you're trying to look at

#

are you trying to profile a specific line of assembly? or figure out what generated a specific line of assembly?

#

or actually hook up a debugger and step through assembly?

viral sonnet
#

rider to the rescue, missed the native debugger and i'm looking at the right memory address now. for some reason VS was being VS and couldn't find it... i'm actually just trying to figure out which values are accessed because i'm too dumb to just figure that out from the assembly alone ๐Ÿ˜„

drowsy pagoda
#

What a peculiar debacle. I have a IJobFor that does var unitEntity = command.Instantiate(unitInfo.prefab); that runs on single schedule. It works, entity spawns properly. BUT! There's always a butt. In the job itself, after command.Instantiate(prefab) I set some components and conditionally AddComponent. The entity is instantiated as a Prefab (with the prefab) tag instead of an instance. This only happens to entities that have that condition met. And when I comment out that condition all together, it instantitates as an instance normally! WTF? Any thoughts?

#

If you need to see code, I'll post it.

viral sonnet
#

the add is also with the ecb, yes?

drowsy pagoda
#

Yup.

viral sonnet
#

no idea really, that should work fine. post a code snippet of this

drowsy pagoda
#

Any thoughts/ideas?

rotund token
#

that seems extremely weird

#

it should not be possible to instantiate with prefab

drowsy pagoda
#

Maybe it doesn't instantiate at all, I can't see it in DOTS Hierarchy, but unit actually does appear in game and scene view lol. So I have to assume it's the prefab because its the only one in the hierarchy.

rotund token
#

that you instantiated from

drowsy pagoda
#

Yeah, but how else can I explain the phenomenon?

#

When it "instantiates" it get's placed on float3.zero position instead of non-zero where it should be (the actual instance I mean)

rotund token
#

best explanation is probably something else destroyed it ^_^'

#

unitInfo.prefab
needs to exist in your hierarchy

drowsy pagoda
#

hmm...I'll look into that. If any other ideas pop up, shoot them over.

rotund token
#

you're saying you only have 1 prefab in your hierarchy

drowsy pagoda
#

It does

#

I have 1 prefab of that unit yes, but I have other prefabs for all other units.

#

this does not occur on start, this occurs because of user input way later then the start, so unit.prefab has to exist by then 100%, but I will run the check just to be sure.

viral sonnet
#

any idea what rax is? the struct? it's aligned so well so it's unlikely they are my parameters

#

but it's also unlikely that the struct is moved to a bunch of registers. ๐Ÿค”

#
    {
        public SpellOwner spellOwner;
        public float* snapshotSpellStats;
        public float* spellStatsPtr;
        public TargetInfo targetInfo;
        public byte sourceTeamId;

        public AttackResult forceSpellResultHit;

        public void* spellBlob;
        public bool fromMainEffect;
    }```
rotund token
#

long register

#

rax 64bit
eax 32 bit

viral sonnet
#

any idea what it could be in that context?

drowsy pagoda
# rotund token best explanation is probably something else destroyed it ^_^'

So before the job runs, there is a destroy all units job (because this is a load request and needs to destroy previous units then write new ones from save file. I thought you were on to something and completely skipped the destruction job and went straight to writing new units. And they all appear and it's the same thing, that second unit that appears (because 1st wasn't deleted), it shows up in game view but not in hierarchy. And at this point there is no other place in the project that deletes units.

#

gotta step away, just tag me when if you have something else to suggest. Otherwise no worries.

robust scaffold
#

So far, 0 DOTS compiler crashes. Seems like they did fix it.

eager pawn
#

can i identify an entity in the foreach by it's value, for example id=1 or id=2 etc, instead of identifying it by it's archetype? im thinking of using empty tag components, but for a 100 ids that would be 100 tags right?

#

filter by shared component data?

winged bane
#

If its just for the sake identification, you can add an identification IComponent that stores an ID. If you don't care about using different IDs during different system iterations, you can skip that and just use the entityInQueryIndex

robust scaffold
#

identify an entity in the foreach by it's value
You mean indexOfFirstEntityInQuery? Entity is also just 2 ints together in a struct. If you need a guaranteed unique int thats might not be in sequence, you can just cast Entity to Long.

#

Or just just the first int if you just need a value that no other entity has this frame

eager pawn
eager pawn
robust scaffold
#

Then filter by shared component.

#

Entities will then be grouped in chunks by the exact same int.

#

Just dont over use too many shared components. Ideally you want at most 3 or 4 per entity. Beyond that, combinatoric fragmentation will lead to very low cache utilization.

eager pawn
#

okay thanks i will look more into shared components. i heard they would create syncpoints cuz of structural changes. im not too sure if i have to be weary of that

#

okay i will probably use 1-2 per entity

robust scaffold
eager pawn
#

well i think i would like to use the job system

robust scaffold
#

Accessing and reading from a shared component requires EntityManager. So ideally you can set an entity's shared component to some ID just to get chunks separated and then have the actual data you want to read from located in a chunk component.

#

You can access a chunk component (IComponentData, just one per chunk rather than per entity) in a bursted job. Must be IJobEntityBatch though.

winged bane
#

Shared components are something I would only use if I had to, or if they perfectly matched the use case. Because of the aforementioned restrictions I try to avoid them.

robust scaffold
#

They're for specific use cases but yea, I generally try not to use them

eager pawn
#

well im open to any options including a different design. i just have a bunch of database tables right now

robust scaffold
#

Shared component data and deliberate chunk fragmentation is specifically designed for enabling burst vectorization.

eager pawn
#

i heard the mesh renderer i think is a shared component

#

can i use like a non-bursted system for the shared component, and then use burst job for all the other data except the id?

robust scaffold
#

If you know for certain that the operations you will be conducting on sets of entities can be vectorized so long as they were ordered in a specific way and willing to take the hit of now needing to jump across chunk boundaries, yea shared component data is pretty good

robust scaffold
#

One "advantage" is that shared components can contain managed classes.

eager pawn
#

oh okay xd

robust scaffold
#

As there is currently no other way to link a managed class to an entity, they use a mesh renderer (which is managed) as a shared component

#

in 2022, the new hybrid renderer API provides a way to "register" meshes with the rendering system. Returning an int / unmanaged struct.

#

No longer requiring a shared component to fragment entitys by mesh / material.

winged bane
#

Oh I didnt hear about that, that will be great.

robust scaffold
#

Shared components are not intended to contain any read/write data. Just an indexer to deliberately fragment chunks if your burst vectorization or mem-copy would work with it. Otherwise, it's pretty much a noob trap. Seems easy to use but it's very easy to shoot yourself in the foot.

robust scaffold
# eager pawn oh okay xd

That being said, having 100 entities having the same exact properties and you want to minimize component usage per entity by instead designating a chunk wide component data that is identical across all entities in the chunk, yea thats one of the use cases.

#

Just be careful about chunk utilization and if you ever need cross chunk / universal data access as low cache utilization will harm performance.

robust scaffold
winged bane
#

I will have to take a look

eager pawn
#

yeah, the exact same properties but with completely different values. both the id and names are unique and would work for indexing. i honestly have to look into it a bit more, like how chunk utilization works and such

#

๐Ÿ“Œ Download the project files from this video: https://tmg.dev/SharedComponents ๐Ÿ“Œ
๐Ÿ‘จโ€๐Ÿ’ป Code used in this video: https://tmg.dev/SharedComponents-Code ๐Ÿ‘จโ€๐Ÿ’ป
๐Ÿ“• Book: Data Oriented Design by Richard Fabian: https://tmg.dev/dod-book ๐Ÿ“•
๐Ÿ’ฌ Join the conversation https://tmg.dev/Discord ๐Ÿ’ฌ
๐Ÿ’ป My Game Development Setup: https://tmg.dev/GameDevPC ๐Ÿ’ป
๐Ÿ‘‡ See below f...

โ–ถ Play video
#

this is pretty much it right

robust scaffold
#

You would use shared component data in situations where there are multiple players in an RTS game for example. Same unit archetypes but you dont want the chunks to be intermingling.

#

But you would not use shared components if you want to separate unit types

rustic rain
#

why not?

#

shared comps are perfect for groupping

robust scaffold
#

Separate unit types, like say a knight or a swordsman, should be identified by a component with an enum property if all other components are identical / shares same archetype for best burst performance.

#

If they're different, then you dont need a shared component anyways. The archetype will automatically separate the two units into separate chunks.

eager pawn
robust scaffold
#

For example, knight and swordsman sharing same archetype. Only difference is a component governing it's speed. Knight has a speed of 5, the swordsman a speed of 1. You would not separate these using a shared component.

eager pawn
#

yes that example applies to my case

rustic rain
#

yeah, in this regard shared component splits entities to different chunks

#

but

robust scaffold
#

Because what if a specific knight entity was moving over mud terrain and the speed got reduced? With shared component fragmenting the chunks and using instead a chunk component to define chunk wide constant properties, you now need a component on every entity to define any modifiers to the chunk properties that apply only to that specific entity.

rustic rain
#

if you use HR

#

they still will lie in different chunks, kek

robust scaffold
#

at that point, just define the entity component as the root speed property.

robust scaffold
eager pawn
#

so a tag would be better? SwordsmanTag KnightTAg

rustic rain
#

yeah

#

hmmm

#

depends on your game structure

#

sometimes you want different components (thus name will be in a tag)

robust scaffold
rustic rain
#

sometimes you want one component for all with different values

robust scaffold
#

Components in ECS/DOTS replaces the inheritance structure of OOS. Archetypes are the "classes". Components are the "interfaces".

#

The entity itself is the "object". Would you make a class specifically for knights? Another class for swordsmen?

#

No. You would make a generic class for "units" and inside it will be the sprite, speed, damage, etc

#

That way, you can easily extend the units possible beyond knights and swordsman without needing to make a unique class for every single unit.

eager pawn
#

oh i think i would make a Knight : Unit and Swordsman : Unit

rustic rain
#

not possible

robust scaffold
rustic rain
#

inheritance requires managed component, and with managed components you can't use burst

#

what isntead you might want

#

struct Unit : IComponentData{ public Type typeName = Knight;}

#

smth like that

#

a problem that comes with that - you can't easily query through them

#

so if you want all Knight at once

#

you'll have to iterate entity one by one to make a check

#

Shared Components solve this problem, but bring another:
they are consider managed components, but you can still differentiate between entities with them using burst

#

shared components basically create a unique component by it's value

#

so 2 entities with all same comps, but different values in same shared comp will lie in 2 different chunks

#

and Unity has a way to filter Query by value of shared component (so this way you'll have able to query all knights at once)

#

but once again they are considered managed, so you can't read value in jobs or burst

#

but! you can read their index

#

since all shared components are stored in a literal List

eager pawn
#

im having some trouble moving along

rustic rain
#

๐Ÿ˜…

#

if you still haven't

robust scaffold
#

Yea. It's a completely orthogonal way of thinking from usual programming

rustic rain
#

I suggest to go through this

rotund token
rustic rain
#

also potentially not a case for 1.0

#

allthough I don't see how not using such separation is not useful for graphics

#

ah, yes I'm finally updated xD

robust scaffold
rustic rain
#

so you can easily group same entities

#

in graphics regard

robust scaffold
#

Does the renderer really need to dictate the structure of the entire DOTS entity store if it could just sort and group the rendering data with a hashmap?

rustic rain
#

๐Ÿค”

balmy thistle
#

hashmaps aren't great for iteration

robust scaffold
#

You have the number of possible entries up front. You have a unique index corresponding to a shared rendering, you can just sort them by that index and boom, you have the indirect draw command buffer.

rustic rain
#

but you'll have to regenerate whole map

#

every time entities change

#

personall

#

I simply use separate entities for this

#

one for drawing

#

one for AI

#

and etc

eager pawn
#

well so if i simply just want to transfer all my rows in my CharacterClasses table to dots, and have like Class1 { id = 1; name = "swordman"; } Class2 { id = 2; name = "knight"} etc, and i want to instantiate both these entities at the start of the game, what method would i use?

rustic rain
#

you use conversion workflow

robust scaffold
#

1 pass to count how many entries per material. 2nd pass to populate a draw command buffer with the relevant per instance data (local to world and so on). 3rd pass to execute a indirect draw call.

rustic rain
#

structural changes will be a bottleneck

eager pawn
rustic rain
winged bane
#

One does not simply transfer all the CharacterClasses. Though it seems reasonable you would make your prefabs available for when you do need to spawn a CharacterClass.

robust scaffold
rustic rain
#

and they are pretty simple

eager pawn
rustic rain
#

sir

#

do you want hybrid between your existing project and DOTS or pure DOTS?

winged bane
#

^ Good question

eager pawn
#

would prefer pure dots

rustic rain
#

then go and read that manual from 0 to 1 xD

#

pure DOTS is ECS

#

with a lot of unique to Unity stuff

#

and it has nothing to do with classic Unity

#

literally nothing

#

meanwhile ECS suffers a lot of from all good OOP practices

winged bane
#

You must forget your earthly OOP ways

rustic rain
#

yeah

#

totally other way of thinking

robust scaffold
#

Unity seems to be constructing a pathway down to the land of ECS from OOP but the best way is just to jump off and land hard. Unfortunately there really isnt that many good guides on landing without breaking your legs on many failed projects until it finally clicks.

robust scaffold
rustic rain
#

you can't expect a newbie to jump in learn correctly without not knowing any of that

robust scaffold
#

If I was being paid to tutor someone to learn to code DOTS. I would tell them to completely forget the existance of classes and inheritance and start them on the Hello Cube samples. The goal will be moving 1000 cubes at once using WASD.

rustic rain
#

and then make this task harder by saying: only cubes of selected color should move

robust scaffold
#

That's the next semester's course.

#

I say it's realistic to expect that it'll take a month or two just to teach people how to properly (read best performance) move a cube.

rustic rain
#

no way

robust scaffold
#

Even longer if they come from programming backgrounds. Maybe a week or two for someone who knows just HTML.

rustic rain
#

a week max

eager pawn
#

maybe i could have a system that sets the id, then have another system that reads that id and does something based on it?

robust scaffold
robust scaffold
eager pawn
#

okay i didn't read that page issue linked but i will. it's generally used to convert from managed unity code to unmanaged dots code right?

robust scaffold
#

Not just reading, but following along. Dont copy paste, type it out by hand.

#

Then see what happens if you change numbers, if you author more entities, and so on.

rustic rain
eager pawn
#

maybe im thinking of something else

robust scaffold
#

The questions you are asking are basic fundamental ECS design. It's not unique to Unity. There's bevy for Rust and so on. But you need to know what ECS is before trying to use Unity's version of it.

#

we can answer your questions, it's very simple, but that wont help if you move on to the next mechanic in your project/game and dont know how to properly structure your data

eager pawn
#

i think i got misled by a video saying pure ECS vs hybrid (conversion)

#

cuz you said conversion happens anyway right

robust scaffold
robust scaffold
eager pawn
#

okay well thanks for the ecssamples and the conversion link, im reading through it rn and things make a bit more sense ^^

robust scaffold
#

It's all open source which is nice.

rustic rain
#

videos are hit or miss hehe

#

some teach a really bad practices

#

like old CodeMonkey videos

robust scaffold
rustic rain
#

they didn't know back then all goods of ECS

robust scaffold
drowsy pagoda
rotund token
#

something silly?

drowsy pagoda
#

Very, but it was a doozie tracking down. The code I wrote for the job and all is fine, this was being caused by another job that runs when this one adds that component based on condition. There was an error, I was setting a Parent, and where I was supposed to input the item, I was inputting the character instead, which told ECS to parent the character to one of it's own children lol. This causes the character to disappear from hierarchy but remain in scene.

#

For for future reference, in case anyone else runs into this weird behavior.

robust scaffold
drowsy pagoda
#

๐Ÿ˜‚

#

Even with 0.51 there isn't a built-in way to destroy entity with all children? Or did I miss something?

eager pawn
#

this makes more sense (:

robust scaffold
rotund token
robust scaffold
rotund token
#

yeah its super annoying

#

they need to remove it from chunk

#

should not be in there by default

drowsy pagoda
robust scaffold
#

I dont even know why it's that big. It's ideal to be something located outside the chunk.

#

the second you have a LEG in an entity, the chunk capacity falls to the low 30s, even high 20s, adding on the 4x4 LTW and all the default 3D transforms.

#

Add on the components required for your own project and you have single digit numbers of entities per chunk.

#

At that point, you have a glorified game object.

#

I think Unity made the LEG exist inside the cache just to punish people who use parenting and hierarchy.

drowsy pagoda
#

Does LEG show ALL children flattened into buffer so I don't need to tap into children?

robust scaffold
drowsy pagoda
#

Then you're right, it does feel redundant considering you can just use the Child buffer...

robust scaffold
drowsy pagoda
#

Oh nice! Thanks for double checking.

#

Ok, I got another riddle for y`all. In what scenario would your entities be Instantiated, and when you move them (in-player) they actually move according to inspector data, but visually they are where they were instantiated. And when you click to select (via raycast collider) you have to click on their actual position and not where they are visually (stuck), like their collider updates but their mesh doesn't. WTF?

robust scaffold
drowsy pagoda
#

The RenderBoundsUpdateSystem performs a query on

ChunkWorldRenderBounds
WorldRenderBounds
RenderBounds
LocalToWorld

I verified that when the entities are instantiated that they have all four components!

robust scaffold
#

@rustic rain Here's my "sprite" renderer. Where the sprites are only circles and squares.

#

Main issue is that the circles draw on top of everything else because in order to render without Z fighting, it needs a non-0 Z value, which then breaks my poor lighting.

drowsy pagoda
rustic rain
#

is NativeParallelHashMap<DefData, Entity> fixed size?

#

Or basically: can I use it in blobs?

rotund token
#

you can't use it in blobs

#

it needs allocation

rustic rain
#

hmm

rotund token
#

but then unity broke it in 0.17 with too aggressive static analysis

#

i havent tested doing it in 0.51+ but i suspect it's still broken

#

unless you want to turn off a check in the entities package

rustic rain
#

eh, it's not critical

#

can always use queries

#

unless they fail me, like above xD

frosty siren
rustic rain
#

why EntityQuery doesn't work?

#

Is EntityManager reference valid after a while?

#

for example if I assign it to some class objects during OnCreate

#

and then use it a while after?

#

<@&502884371011731486>

rotund token
rustic rain
#

yes

#

I forgot they have Prefab tag

#

๐Ÿ˜…

rotund token
#

that one not that silly

#

easy to overlook

rustic rain
#

hmmm

#

How to deal with Destroyed entities and their references?

#

for example I have Entity X that follows Entity Y
Entity Y gets destroyed. Entity X throws exception in it's pathfinding system, because Entity Y does not exist

rotund token
#

welcome to my biggest annoyance and unsolved problem with entities

#

the only way I've found apart from just having Exists/Has checks everywhere

#

is just to have a really solid cleanup pipeline

#

i only have 1 DestroyEntity in my entire project

rustic rain
#

so, how does it even work?

#

you attach destroy tag

#

you know this entity is about to be smacked

#

what happens next?

rotund token
#

thats a way to do it, but i have static archetypes

#

so everything has a EntityDestroy component on them

#
    /// Unified destroy component allowing entities to all pass through a singular cleanup group.
    /// </summary>
    public struct EntityDestroy : IComponentData
    {
        public static readonly EntityDestroy Destroy = new() { Value = 1 };
        public static readonly EntityDestroy CancelDestroy = new() { Value = -1 };

        internal sbyte Value;

        public bool IsDestroyed => this.Value != 0;
    }```
rustic rain
#

huh, so you have existance state component

rotund token
#

I have a CleanupSystemGroup that updates After EndSimulationEntityCommandBufferSystem with its own command buffer

#

that just listens to destroy changes

#

and destroys entities

#

however, libraries can add systems to this cleanup group as well and also react to certain entities being destroyed

#

and as the component shows above, they can also cancel entity being destroyed

#

this is really useful when you have a library that needs specific cleanup

#

for example, i have a fracture system. when something gets destroyed for whatever reason it shouldnt be destroyed

#

it should fracture into pieces

#

so it cancels destroy then sets its fracturing to all

#

anyway this is a recent (1 month) unification of how i want to handle this

rustic rain
#

yeah, that totally makes sense

rotund token
#

as i'm trying to write my code in a way i dont have to check states (except maybe 1 place)

rustic rain
#

as in Destroyable

rotund token
#

i'm not sure this style would be good in a game you want for modding though

#

a more defensive structure is probably worthwhile

#

(the cleanup pipeline can still exist)

#

(i just mean, never check for safety - this requires static archetypes and for everything to stick to very specific rules)

rustic rain
#

yeah, I just got the idea, now gotta think it through

#

I don't see how static archetypes is a requirment tbh

#

as nothing stops me from simply having component

#

that indicates the state

rotund token
#

because if my archetypes aren't static i can't be certain something hasnt removed a component

#

i can't get
GetComponent<Translation>(target.Entity)

#

if someone has removed Translation

rustic rain
#

ah, in this regard

#

don't think it's a problem tbh

#

I want to try and make per object entities separately

#

so

#

rendering has 1 entity

#

"brain" has another entity

#

ship stats and etc has another entity

rotund token
#

yeah and what if a modder

#

deletes the stats component

#

on your entity

rustic rain
#

I haven't implemented it yet in any way

rotund token
#

or just destroys the entity with EntityManager.Destroy()

rustic rain
#

so it's all for me to think through

#

xD

rustic rain
rotund token
#

yet it might not be broken

#

until another moder has a mod

#

that expects the entity to exist

#

and it does with your base game

#

both work fine

#

you combine them

#

and bam game just random crashes all the time

rustic rain
#

yeah, I get that part

rotund token
#

we used to have A LOT of crashes due to things destroying

rustic rain
#

but if I want to implement destruction pipeline

#

Modders will have to use it

#

that's how life is for a modder

rotund token
#

the bare minimum you need to do if you use ECB is have your destroys in a command buffer system after your regular command buffer system

rustic rain
#

in RW, you mimic game logic

rotund token
#

yeah that's fine if you set it up properly

rustic rain
#

you aren't really playing the game as normal game dev

rotund token
#

you can define rules

#

but yeah that above concept is what i'm trying atm

#

it's been working well

#

any library can destroy an entity without worry

#

and then the owning library can let it through or cleanup, or stop it or whatever is required

#

oh yeah if you dont care about static archetypes you can just use a tag component

#

but it's a little harder to 'stop' an entity being destroyed

rustic rain
#

I can't really use tag component

#

because I can't check archetypes

#

in job

rotund token
#

what do you mean by that

rustic rain
#

so entity is destroyed and other entity wants to use it to get it's LTW component

#

once it's destroyed, nothing changed for other entity

#

and it tries to access dead entity

rotund token
#

oh yeah

#

i have 2 way references on my entities

#

so when 1 is destroyed

#

it tells the other entity's that are referencing it that they are dirty and needs to recheck its references

rustic rain
#

I don't think I like that one very much

#

but I'll have to think all options

#

through

rotund token
#

neither it's a pain

#

i just haven't found a better option

rustic rain
#

why not just have state

#

component with value/enum

#

whatever

#

which will be readonly

#

for most jobs

#

and only those that actually destroy entity

#

will change value

#

so you do end up with checks for dead state

#

but you'll read component this way

rotund token
#

oh the other thing you can do is if you know you only have 1 place in project that destroys stuff

#

simply have a system update after it (or start of next frame)

#

and simply check every reference is valid

#

and just assume everywhere else in your project it is safe

rustic rain
#

oof

rotund token
#

it's actually reasonably fast to do with EntityStorageInfo

rustic rain
#

simply checking every reference not that simple ๐Ÿ˜…

#

I have a lot of components that have Entity field

#

but don't need to store entity

rotund token
#

all my AI uses a single target buffer

#

for this reason

#

it just re-uses the same buffer for targetting whether its another actor, a resource, a collectable etc
they basically have "knowledge"

rustic rain
#
    public struct QueuedAction : IBufferElementData
    {
        public int integer;
        public float @float;
        public float2 float2;
        public Entity entity;
        public ComponentType actionType;
    }

My AI looks like this xD

rotund token
#

but yeah the problem is a pain

#

yet to see anyone solve it properly

rustic rain
#

I'll have to give a lot of thought

rotund token
#

obviously easiest way (what we do at work) is just literally check every call

#

its gross, it works

#

i really do want to find a generic universal kind of pattern i can apply

rustic rain
#

hmm

#

what if

#

we get all component types with entity reference

#

and upon trigerring destruction

#

run a job

#

that makes a check

#

and swappes Entity with null

#

meanwhile inside of jobs

#

you rely on Entity.Null

#

comparison

rotund token
#

if you're doing entity null checks

#

why not just do hascomponent check

#

in the first place?

rustic rain
#

how?

rotund token
#

ComponentDataFromEntity.HasComponent

rustic rain
#

oh

rotund token
#
        {
            if (!Exists(entity))
                return false;```
#

first thing it does is simply check if entity exists

rustic rain
#

yeah I get it

#

well, this is the most reliable option

rotund token
#

i want to solve it without have any other job in project need to check

rustic rain
#

even though least fast

rotund token
#

if you dont use hascomponent/getcomponent with codegen

#

pass in ComponentFromEntity

#

and just use TryGetComponent instead

#

to combine both the calls

#

it's not that bad

rustic rain
#

tbh

#

seems like all solutions include checks

#

so far

rotund token
#

well yeah

#

if you want to solve it

rotund token
#

and i just dismissed it ^_^'

rustic rain
#

if (action.entity == Entity.Null && action.float2.Equals(float2.zero))
That's like the first thing I do in a job

rotund token
#

yeah because null is probably a legit state for setting something up

#

but it's still the problem of setting it to null

rustic rain
#

idk how fast it would be running through literally all entities

#

and checking whether their references exist

#

๐Ÿ˜…

rotund token
#

it depends on your scale

#

and number of components

#

but yeah you wont be getting into 6 figures without doing this with both way references and relying on change filters

#

unless its only like a component or two

rustic rain
#

I will probably have way too many components with Entity reference

#

and getting each will be a problem already

rotund token
#

yeah its pretty normal

rustic rain
#

Feels like having checks would be the only option, unless smth way smarter is figured

#

hmm

#

I just thought of very dirty and at the same time clean way

#

every time you want to assign reference to entity to other entity

#

you have to create a chain entity

#

that has reference to both

#

entity1 and entity2

#

and then job simply iterates through all them with checks

rotund token
#

i've thought of doing that

rustic rain
#

alltohugh, that sounds expensive

rotund token
#

but adding that entity to the linkedentitygroup

#

so when the linkedentitygroup gets destroyed it destroys that entity

#

it requires some fun magic with caching archetype chunks to do checking on it

rustic rain
#

nah, I think the easier would be simply using it as trigger for when entity reference is broken

rotund token
#

something i was having to to handle the 100mill entities i was testing with this for stats

#

like i should say, i wrote a solution for this

#

that handled 100mill effects referencing 10mill actors

rustic rain
#

nvm, I don't like that solution at all

rotund token
#

but i had some crazy optimizations like chunk components with a list of all archetype chunks that these entities reference

#

but it was fast enough to handle this problem in 2ms

#

for 100mill entities

#

but yeah its not something i would actually recommend - was just a theoretical challenge for myself

rustic rain
#

ok, my best bet is callback buffer

#

everytime you want to write Entity reference

#

you access occupation buffer on it

#

and add entity that saves reference and component type

#

upon destruction system gets reference, gets component type and modifies it

#

but I'll probably just stick to checking

#

data

#

I don't want to create super complex and easy to break systems

rotund token
#

yeah if you're referencing another entity you are doing random access anyway

#

the check is the least of your worry anyway

rustic rain
#
            private bool ShouldSkip(in QueuedAction action, out float2 targetPoint,
                in ComponentDataFromEntity<LocalToWorld> ltws)
            {
                var entityNull = !ltws.TryGetComponent(action.entity, out var gtp);
                var tarZero = action.float2.Equals(float2.zero);
                targetPoint = math.select(gtp.Position.xy, action.float2, entityNull);
                return entityNull && tarZero;
            }

I wonder if that can be vectorized, kek

half jay
#

what's new in the new DOTS 0.51.1 ?

rotund token
#

Fixed annoying code gen fails

viral sonnet
viral sonnet
#

vmovups ๐Ÿ™‚

#

the good stuff

rustic rain
#

oh

viral sonnet
#

i'm just pretty sure it's not the TryGetComp because that has conditions in it

#

ah the call to it is later

rustic rain
#

hmmm

#

Idk where to start when implementing "entity separation" by logic

#

or should I even do that

#

one obivous way - use child Transform hierarchy

latent quest
#

How would one iterate over all entities with a certain component while already in an Entities.ForEach? Currently I'm using two and even while using .WithoutBurst it still doesn't allow such. Will I need to use a pregenerated list/array/such perhaps?

rustic rain
#

yes, you need to get data about those entities beferehand

latent quest
#

Alrighty, that's fair :P

dire ingot
#

Hey, I'm still new to ECS. I have problem with changing scenes and having entities remain. I have read this thread https://forum.unity.com/threads/ecs-tear-down-and-restart.539722/ and have this in one of my managers:

    private void OnDestroy()
    {
        var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
        entityManager.DestroyEntity(entityManager.UniversalQuery);
    }

I have MainMenu scene which serves as level selection. When I enter level, everything works okay, on exit entities are destroyed, but the PhysicsSystemRuntimeData is destroyed as well and upon selecting another level it is still gone. I don't know how to properly reinitialize that. What am I missing here?

rustic rain
#

why not just destroy world

#

and create new one?

#

if you have scene management that relies on Unity scenes

dire ingot
#

won't destroying world also get rid of everything?

rustic rain
#

I'd disable automatic world creation

#

and create new on each scene

dire ingot
#

but if I create new world, I would need to add manually things like PhysicsSystemRuntimeData , or I am wrong?

rustic rain
#

what is that?

dire ingot
#

nvm, it seems to work better, but now i have world is null error from WorldProxyManager when i change scene (and dispose all worlds and create new one)

#

it keeps on giving errors even when i'm not in play mode

rustic rain
#

did you disable automatic world creation?

dire ingot
#

no, i didn't. But the error just stopped now and it seems to work fine, not sure yet what happened

latent quest
#

Why would this not work pray tell?

// collect locations first
DynamicBuffer<Entity> locs = new DynamicBuffer<Entity>();
Entities.ForEach((Entity entity, in WorldLocation wl) => {
    locs.Add(entity);
}).Schedule();

// acquisition method things
ComponentDataFromEntity<Translation> entgettrans = new ComponentDataFromEntity<Translation>();
ComponentDataFromEntity<WorldLocation> entgetwl = new ComponentDataFromEntity<WorldLocation>();

// update agents
Entities.ForEach((ref PathFollower pf, ref Translation tr) => {
    // get direction and vector from it
    float r = math.atan2(pf.Destination.z - tr.Value.z, pf.Destination.x - tr.Value.x);
    float x = math.cos(r) * 5;
    float z = math.sin(r) * 5;
    // move
    tr.Value += new float3(x, 0, z) * deltaTime;

    // check if at destination
    if (tr.Value.x < pf.Destination.x + 1 && tr.Value.x > pf.Destination.x - 1 &&
        tr.Value.y < pf.Destination.y + 1 && tr.Value.y > pf.Destination.y - 1)
    {
        // acquire new destination
        pf.Destination = entgettrans[locs[random.NextInt(0, locs.Length - 1)]].Value;
    }
}).WithoutBurst().Run();

Sorry for asking question is such succession orz

#

It gives me an error Object reference not set to an instance of an object Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow but I have no idea what it means...

#

All the values should have values. Removing the
pf.Destination = entgettrans[locs[random.NextInt(0, locs.Length - 1)]].Value;
and
locs.Add(entity);
fixes it but I'm not 100% sure why.

#

I've tried setting up the first Entities.ForEach with .WithoutBurst().Run() but that does nothing.

#

Putting the locs DynamicBuffer in the system and doing an IsCreated check in update doesn't seem to change the IsCreated bool (if that's even what IsCreated is for...).

viral sonnet
#

new ComponentDataFromEntity<Translation>(); this doesn't work. use GetComponentDataFromEntity<T>

#

same goes for the buffer. you can't just new them

#

equivalent is GetBufferFromEntity

rustic rain
#

hmmm, what would be a best way to store arrays of vertices/uvs/triangles?

#

the trouble I experience - size is not defined

#

the biggest problem is that this data is meant to be per entity

winged bane
#

Use a blob

#

It's better if you don't have to store them, especially if you are doing procedural meshes

rustic rain
#

yeah

#

I am figuring out what to do

#

I potentially should just use index

#

I am doing 2D renderer

#

hmmm

#

I realised

#

I can store it by Shared comp

#

and use index for per entity data

viral sonnet
#

will the data change? i suppose not.

#

currently, as HR is working the same you could store it in a shared comp. it's just not future proof

rustic rain
#

yeah, I can

#

and I'm figuring out how

#

the problem is that, uuugh

#

I don't know full data of atlas

#

upon conversion

#

and if conversion will be split

viral sonnet
#

sharedcomp + unsafelist. although you could just make a blob then

rustic rain
#

I might end up with several duplicate shared comps

viral sonnet
#

then a blob is the best course. that deals with same-ish entries

rustic rain
#

here's what I think:

    public struct RenderSprite : ISharedComponentData, IEquatable<RenderSprite>
    {
        public Material material;
        public Texture2D texture;
        public bool atlas;
    }

so if it's atlas I will need vertices, triangles, uvs arrays

#

list of those arrays

rustic rain
#

I don't really see it

#

so, for example I converted 10 entities that occupied 50% of atlas

#

and now after a while second subscene is loaded

#

and sprites from it use other 50% of atlas

#

how conversion system will figure

#

that it needs to combine blob/shared comp

rustic rain
#

hmm

#

Can I keep native arrays in shared component?

#

I think I can

#

what kind of Allocator do I need to use then

#

when creating it

safe lintel
#

persistent

rustic rain
#

will Unity dispose it

#

once no entities has this SharedComp?

safe lintel
#

doubtful

rustic rain
#

oof

rustic rain
#

ok, I guess I can use blob arrays

robust scaffold
# rustic rain here's what I think: ```cs public struct RenderSprite : ISharedComponentData...

The main issue I found with a fully featured sprite renderer is packing the sprites into 1 texture. The conversion system with incremental conversion will only iterate upon entities with something changed. However all sprites will need to be packed into a single texture so either turning off incremental conversion so all sprites are re-packed if a single sprite was changed or roll your own texture packer.

rustic rain
#

yeah

#

you don't need texture packer though

#

you pack them in atlas in editor

#

so you already get atlas as texture

#

and uvs, vertices and etc

robust scaffold
#

So instead of doing all of that pain, I am only rendering circles and squares, I just made my own rendering system that dynamically computes the circle or square inside the shader and let the scale in the LocalToWorld dictate the width and height.

rustic rain
#

well, I obivously could also draw simple quads

#

BUT

#

I really want tight packed meshes

#

this way

#

I can draw any mesh

#

graved out of texture

#

fully dynamic and bursted

robust scaffold
rustic rain
#

it's also low level and not as feature present

robust scaffold
#

But I have to admit, the options are... limited.

rustic rain
#

I want to have full power of sprite renderer

robust scaffold
#

I thought about it, even including animation, but I have made 0 progress in my physics engine and I need something now.

#

And Unity will probably include their own fully featured DOTS sprite renderer sooner or later. Sprites are important in 3D as well.

rustic rain
#

yeah

#

I want to roll it along with 3D

robust scaffold
#

As opposed to other 2D ecosystem structures like tilemaps and a conversion of Box2D.

#

The issue is that my custom renderer doesnt function in editor (before pressing play).

rustic rain
#

you can add

#

[UpdateAlways]

#

and it will

safe lintel
#

hmm uh (0,0): Burst error BC1025: Accessing the type Junk.Transforms.BillboardSystem/CameraPositionJob (e.g. using typeof) is not supported what is this all about?

robust scaffold
rustic rain
#

yeah...