#archived-dots

1 messages Β· Page 199 of 1

slim nebula
#

I set "found=true" in the query and it compiles now lol

karmic basin
#

Hmmm did I misread CommandBufferSystem ? Yes, yes I think I did ^^

pearl pulsar
#

Closest I've got to building and running sample projects has been

Loading Entity Scene failed because the entity header file could not be read: guid=46b433b264c69cbd39f04ad2e5d12be8.
stitch_shrug guess I'm not playing with Project Tiny for now.

karmic basin
slim nebula
#

netcode doesn't seem to work unless at least one player has a CommandTargetComponent... If it does then all clients work, otherwise no clients work... wtf...

rugged lark
#

Does it have to be a player? Can you generate a test entity with that sole component?

zenith wyvern
rugged lark
#

Disclaimer, no clue what I'm talking about.

slim nebula
#

lol i mean maybe I dunno

rugged lark
#

I was just thinking that I've been here a few weeks and still only understand about half of what gets said in this channel.

karmic basin
slim nebula
#

i mean server side I guess

#

that's client side in my file there

slim nebula
#

client 0 doesn't change. client 1 spawns in, box and player appear on client 0. client 1 spawns out, box and client disapear. multiple clients work tine too

pearl pulsar
#

System Requirements in the google doc doesn't seem to specify which Windows 10 SDK is needed

zenith wyvern
#

Don't think so. Maybe double check you're including all the correct assemblies in your "root" assembly too, and not including anything that references unityengine

#

@pearl pulsar

karmic basin
slim nebula
#

I'm guessing I just ALWAYS have to have a command target somewhere in each client

#

reading thru docs now to see if there's anything obvious but, I'm going to set it to an empty entity instead of null and see if that works

karmic basin
#

I guess after connect yeah

#

unless you want network vizualisation only

#

why not hehe

slim nebula
#

I guess I assumed it wasn't a requirement but apparantly it is

#

even if you don't have commands, you have to have some CommandTargetComponent or it sends nothing to any client

#

assuming I"m right

#

which I dunno

#

odds are I'm not

#

To store commands in the correct buffer, each connection has a CommandTargetComponent which must point to the entity where the received commands need to be stored. Your game is responsible for keeping this entity reference up to date.

#

yeah sounds like it's required...

#

technically the buffer is used for everything not just commands I guess?

#

Before the component is added to the connection, the client doesn’t send commands, nor does the server send snapshots.

#

yes

karmic basin
#

hmmm there's also NetworkStreamInGame which matters

#

maybe more

slim nebula
#

that one I got workin rite

#

got that on every client always, spawned in or not

#

aight no more insight in docs. ima try it

pearl pulsar
# zenith wyvern Don't think so. Maybe double check you're including all the correct assemblies i...

Doesn't appear to be the case. For example I'm taking a look at Tiny2D and it's just a simple rotation of a picture as far as I can tell. The components and systems seem to only reference Unity.Entities, Unity.Mathematics, and Unity.Transforms.

For reference:
https://github.com/Unity-Technologies/ProjectTinySamples/tree/master/Tiny2D

#

I guess I can go see if another Windows 10 SDK installation magically solves the problem. πŸ˜›

karmic basin
#

I would dumbly go for the last one ?

zenith wyvern
#

I assume you have the other bizarre requirements installed? Desktop C++ and .net desktop from visual studio. Also make sure you have all the platforms packages installed and up to date. From what I remember those are pretty much all the obscure things I had to fiddle with to get Tiny to stop throwing weird errors

pearl pulsar
#

Yeah 19041 seems like the most likely one to try first. Gonna reboot and try again real quick.

Desktop C++ and .net desktop from visual studio
Believe so, yes. That's from the more-general list in Visual Studio installer, right? Had those already existing.
https://i.imgur.com/dt7uzhH.png
Also make sure you have all the platforms packages installed and up to date
IIRC only a couple of seemingly unrelated Unity packages had a version bump (e.g. Test Framework)

zenith wyvern
#

Oh and if you have subscenes try building without them, I remember just giving up on trying to use subscenes solved some weird issues I was having

#

The joys of preview

karmic basin
#

Seems like a pain

zenith wyvern
#

Yup. I eventually had to give up on tiny when I hit a project killing bug that they don't seem to be in a rush to fix. I wish otherwise, being able to use ecs/dots on a web game is pretty cool.

pearl pulsar
#

There is a SubScene.unity in Assets\Scenes but I'd be surprised if that was root cause since this github example was updated 9 days ago to update samples to 0.32

zenith wyvern
#

You could try it without it just to see, subscenes aren't necessary anymore in Tiny

karmic basin
#

yeah but don't delete it, right ? Unpack GOs from it

#

yeah I like to state the obvious

rugged lark
#

Sark, is there no way to build ECS for web without Tiny?

zenith wyvern
#

Not that I know of. I tried it using the webgl build configurartion recently on my 2D game and it kind of worked - stuff rendered, some systems worked while others didn't, and it just threw lots of strange errors.

#

Like stuff was drawing to my terminal and I could move my player around but for some reason my monster ai systems just didn't work at all, while everything works perfectly fine in a normal build

rugged lark
#

Hmm. I'll need to look at that because I just sort of assumed you could build to webgl.

zenith wyvern
#

If it works for you let me know

rugged lark
#

Roger dodger.

pearl pulsar
#

Getting some various SDK plugins for Windows 10 and removing the subscene hasn't gotten me any further. I think I'll just call it for now. Thanks for the help @zenith wyvern !

zenith wyvern
#

Rip. No worries

slim nebula
#

how do I create an entity inside a query that I can save on a component? If I use EntityCommandBuffer.CreateEntity() it says the entity is still deferred (it's created, it's just my component has the deferred value that it was at the time I saved my component) and if I use EntityManager.CreateEntity() then the compiler complains that I'm not allowed to make structural changes (even though I specify WithoutBurst() in the query). How can I get this to work?

robust scaffold
slim nebula
#

just in query @robust scaffold

zenith wyvern
#

For the entity manager bit you need to use WithStructuralChanges

slim nebula
#

awesome. that'll do. thanks

#

(this one is just run once on startup so it's no biggie)

robust scaffold
#

Also WithoutBurst if you plan on using EntityManager itself inside a lambda function.

#

Although with both .WithoutBurst().WithStructualChanges, you practically made a for loop.

slim nebula
#

yup. that's fine

zenith wyvern
#

WithoutBurst is implicit when you use WithStructuralChanges I thought

slim nebula
#

I got withoutburst already. oh that's good to know sark

robust scaffold
#

Nope, you must also include WithoutBurst().

slim nebula
#

ok i mean I have both for clarity anyway

robust scaffold
#

I never use the EntityCommandBuffer, so slow and cumbersome.

slim nebula
#

so you just always use WithStructuralChanges?

#

how else would you avoid it?

#

I seem to have to put it everywhere...

zenith wyvern
#

It's necessary if you don't want to force one or more sync points in the middle of your update

#

Not to mention you can't make structural changes inside burst

robust scaffold
#

If you need to add, remove, or create entities or components, you must use WithStructuralChanges or use a ECB. Try to minimize doing the mentioned actions.

slim nebula
#

yeah. I get that. I'm just starting out tho so lots of creating initially hehe

#

not much processing so far

#

I guess I'll see less of it as things go on

#

buffer.Playback(EntityManager); still makes a sync point tho rite?

robust scaffold
#

Yea, for my initialization, I've made an extension method to chain together calling entity manager methods. Makes reading through the initialization code easier.

slim nebula
#

ah gotcha. nice

robust scaffold
slim nebula
#

yup

#

well... it's better to have fewer sync points I guess

robust scaffold
#

At initialization, it doesnt really matter. In the middle of runtime, definitely less sync points.

slim nebula
#

πŸ‘

robust scaffold
# slim nebula πŸ‘

Also, if you're making all the entities inside a system base, make sure you add Enabled = false; in your code or else the entity creation will happen again. InitializationSystemGroup is not OnEnable like Mono but more akin to Pre-Update.

slim nebula
#

i been using uh

#
            RequireSingletonForUpdate<Init>();
            EntityManager.CreateEntity(typeof(Init));
#

lol

#

but enabled is probably less lines haha

zenith wyvern
#

Really you should be using conversion for all your initialization stuff if possible

robust scaffold
slim nebula
#

can you put ICommandData buffers onto things with conversion @zenith wyvern ?

#

for netcode?

#

their examples show doing it with code, not cconversion

zenith wyvern
#

You can set up an authoring component that will attach whatever you want to the entity being converted

slim nebula
#

but still I Have to link things

#

like

zenith wyvern
#

Although I haven't messed with netcode really so I can't say if it's the best way to go

slim nebula
#

the command target needs to be linked for netcode. I"m not responsible for authoring that

#

then I need to link the ghost that netcode creates, etc

zenith wyvern
#

Yeah you can plug in another gameobject that's going to be converted, and it will properly link up the resulting entities

#

Assuming you do it right

slim nebula
#

uhhhh what

zenith wyvern
#

But again I'm not sure how to integrate it with netcode, if they don't use conversion in the examples then maybe there's a good reason for that

slim nebula
#

yeah cause all the ghost stuff is like created from the server programatically

robust scaffold
slim nebula
#

then it just pops up in the client and... it's not like any authoring runs at that point

#

it's just the ghost that was authored before. I still need to update things

#

that being said... this empty entity that I"m making, I could author it and find it and link it instead of creating it in code here you're right

#

just seemed easier this way for now. but I'll probably change it to authored

#

it's a good point

#

still need to change lots of components and stuff or w/e

#

but maybe that's more normal

#

thanks

gusty comet
slim nebula
#

Can it take only the sub-Folder of Git-Tree? no. taking a subfolder out of the repo is a more complex operation than a clone. if you just want the files, why not just download the repo as a zip?

gusty comet
#

all, but it took long to download, i read if there is a folder to take all list, but than specify a folder

gusty comet
gusty comet
#

checked x Recive submodules

light mason
#

Anyone know a good solution to draw line between object in tiny

#

Like connecting nodes is a good example, but in game

gusty comet
robust scaffold
gusty comet
#

@ocean tundra is there a data type for xnode so i can connect nodes not by value type? I just want to connect them

gusty comet
robust scaffold
#

Anyone ever tried using chunk splitting using shared components to isolate entities and share data (using chunk components)?

robust scaffold
#

As a note, I make my entities purely from code. My gameobject hierarchy is literally nothing.

gusty comet
robust scaffold
#

I'm going to try it. Splitting chunks by grouping positions then see how bad the performance is. Unity has so much warnings against using shared component data that im terrified.

deft stump
ocean tundra
#

how can i Schedule a job so it runs on every thread?

#

Im reading/writing to NativeStreams and the beginforeachindex is set to the threadindex

#

Oh the dots event system just loops over every index.. i guess ill just do the same

gusty comet
#

Entity = 3d model, Components = textures, System = animation/animator state machine

solemn ice
#

I want to set the world position (think transform.position) on an entity with the DOTS Transform system that has parents, do I really have make somehow use matrix transformations using LocalToParent of every parent in the chain every time I need to set the position? I can't directly set LocalToWorld since it's overwritten by the builtin systems

ocean tundra
#

@solemn ice na just set Translation on the parent

shy pilot
#

localtoparent sorry

ocean tundra
#

i think you just want to be before the TransformSystemGroup

#

if your after it will caculate the children next frame

solemn ice
#

but then I have to set it every frame, it will get overwritten every frame after that since the Translation and the LocalToWorld won't fit together, no?

#

And there's other children, setting the Translation on the parent is not the best option

ocean tundra
#

translation is never overridden

solemn ice
#

I know, so I have to set Translation, not LocalToWorld, and Translation is the local position, and I want to set the global position

ocean tundra
#

translation is whats used to build the localtowold

#

the world position of what?

#

a parent?

solemn ice
#

I want to set the child's world position

ocean tundra
#

can you just make it a parent?

shy pilot
#

Just a quick question, what is the current 'state' of dots, last time i looked at it was around september-august. Has it improved at all since then?

zenith wyvern
#

Not really

solemn ice
#

I can't set LocalToWorld since the Translation won't follow, I can't set the position I want directly in Translation, so my only option seems to make some kind of transformations using the parent's LocalToWorld or something like that. That or just not parenting my objet at all

ocean tundra
#

yea i would just unparent it

#

@shy pilot its progressing slowly πŸ˜›

zenith wyvern
#

What improvements are you looking for?

ocean tundra
#

i too was away for a bit (6 month) and no real changes

safe lintel
#

@shy pilot thats like a blink of an eye in dots time πŸ₯²

ocean tundra
#

its a bit more stable, and seems a bit easier

shy pilot
#

mmm

#

when i last used it i got pretty far in but kept having problems with the editor itself, all the dots related editor tabs and even the unity services stuff just broke completely

zenith wyvern
#

I think the editor stuff is getting a bit better in my experience. Less random exceptions and they actually have documentation for conversion now

#

Editor workflow is still really awkward, but it's less broken in my experience

ocean tundra
#

anyone have any ideas why this works?
I have a system that uses GetBufferFromEntity<TYPE> ... Job....
Then another system that uses EndSimulationEntityCommandBufferSystem command buffer to ADD that buffer TYPE to entitys that dont have it
It was failing loads untill I set the first system as a dependancy of of the COmmandBuffer System (AddJobHandleForProducer)

gusty comet
robust scaffold
ocean tundra
#

Na its pertty complex

robust scaffold
zenith wyvern
#

You're using GetBuffer inside a job?

ocean tundra
#

Outside and passing it in

zenith wyvern
#

That's why

ocean tundra
#

really?

zenith wyvern
#

You're creating a main thread dependency on your buffer

ocean tundra
#

so i should do it in the job?

zenith wyvern
#

You want to pass in a BufferFromEntity along with whatever entity, then get the buffer inside the job

#

Yeah

#

Well, you can just call GetBuffer, that will do what I described above

#

But there's a bug where it can't be readonly, so I usually pass in a BufferFromEntity manually

ocean tundra
#

omg how do you send code in discord πŸ˜›

zenith wyvern
#

Surround it with triple backticks

robust scaffold
#

three tildas, located to the left of the one key, shift that key.

ocean tundra
#

πŸ˜›

zenith wyvern
#

`

#

That guy

ocean tundra
#

thought it was 1

zenith wyvern
#

That's for single line code only

#

For a block you use triple backticks

ocean tundra
#
            var translationBuffer = GetBufferFromEntity<TranslationClientCurve>();


Job
                .WithReadOnly(idMap)
                .WithCode(() =>
                {

translationBuffer[ENTITY]
//use buffer
zenith wyvern
#

Oh, you're getting errors from that?

ocean tundra
#

kinda

#

its more like my system explodes and wont run

robust scaffold
#

What's the exact error message

ocean tundra
#
EntityCommandBuffer was recorded in AutoCurveAllClientSystem and played back in Unity.Entities.EndSimulationEntityCommandBufferSystem.```
robust scaffold
#

Ah, it's a dependency issue.

ocean tundra
#

So ClientReadStreamSystem = that system
AutoCurveAllClientSystem is the system thats adding the buffer to entities using command buffer

robust scaffold
#

Yea, that doesnt work. I'm going to need to see the entire OnUpdate code to restructure it so that it does.

zenith wyvern
#

Are you sure you're doing AddJobHandleForProducer in the buffer system?

ocean tundra
#

@zenith wyvern yea i am

#

@robust scaffold trying to think of how to simplify it a bit πŸ˜› its kinda crazy

zenith wyvern
#

At the end of the buffer system's onupdate?

ocean tundra
#

@zenith wyvern yea its at the end

#

i even swapped that system into Run to see what would happen

#

run is immediate right?

zenith wyvern
#

Yeah

robust scaffold
ocean tundra
#

@robust scaffold your gonna regret that but sure πŸ˜›

zenith wyvern
#

Not sure what it would be then, I use command buffers all over the place

#

Please don't screenshot a bunch of code in here

#

Use hatebin

robust scaffold
#

Oh true, this isn't a personal dm, yea copy paste it elsewhere.

ocean tundra
#

sorry if it dosnt make much sense

#

the issues are the bottom system the top one should be fine

robust scaffold
#

Right, give me a sec

ocean tundra
#

so all the dependency management is for the evil native streams, I have 2 worlds (Server, Client)
Server writes data into the streams, Client reads
BUT they are different worlds so need to manually pass JobHandles around

#

these systems are client

zenith wyvern
#

Ehh, it doesn't look like you're using your system's dependency property

ocean tundra
#

I ended up not using the System.Dependancy

#

but maybe i should

zenith wyvern
#

You need to combine any related dependencies with that so the rest of the framework handles dependencies properly

ocean tundra
#

that makes sense...

#

i guess ill try combine them all into Dependancy and see how it goes

robust scaffold
ocean tundra
#

from my understanding passing a dependancy into Schedule will ignore the built in Dependancy?

#

oh

#

that would probably cause that system to be scheduled with my Server world and not in time correctly with the client world

robust scaffold
#

Nope.

Job.WithCode().Schedule();

// Equal to ->

Dependency = Job.WithCode().Schedule(Dependency);```
#

Just add in Dependency to JobHandle.CombineDependencies(). Although I cant guarantee the problem will be fixed. Im glad I dont need to work with multiple dependencies.

ocean tundra
#

god it sucks

#

:p

#

just combineing dependancies after schedule helped

#

now im back to trying to use those NativeStreams

robust scaffold
#

That's good. Good luck with all that. Sounds like dots netcode.

ocean tundra
#

πŸ˜›

#

no its my own

#

i should probably rip down netcode and copy how they do some stuff

#

i had a version working with native lists

#

should have stuck with them instead

gusty comet
#

Unity.Animation.Samples\UnityAnimationURPExamples\Assets\Scenes\Introduction\Scorpion.scene

robust scaffold
#

Forgot to set clear to sky?

#

I've got to say, using ISystemBase and Bursting everything has given me such a feeling of euphoria. Despite the fact that all my tests, it does not effect framerate at all.

gusty comet
rugged lark
#

So the scorpion URP example converts a RigComponent to a Rig ECS component. But what if I want to create a Rig ECS component directly? I know the Unity DOTS Animation documentation is sparse. Is it currently only possible to come to terms with it by parsing through the package or am I missing a Scripting API document somewhere?

light mason
#

If I have a ref type with a IComponentData array, can pass this to a job somehow?

karmic basin
shy pilot
karmic basin
karmic basin
zenith wyvern
#

Particles!

karmic basin
#

Even if you use the UpdateAfter attribute on the system, you need to also combine dependencies for the job, right ?

deft stump
#

Sark doing god's work and making DOTS particles

amber flicker
karmic basin
#

Alright I see, thanks πŸ‘

warped fog
#

@zenith wyvern that’s pretty neat. Got more?

zenith wyvern
#

Nope, those were it for my rough first pass. I got a basic framework to expand on and a simple circle emitter

#

Dots continues to impress though, it can easily handle hundreds of thousands of particles in less than .5ms

rugged lark
#

Is your project a side-scroller?

karmic basin
#

He's making an ascii roguelike if I'm not mistaken

rugged lark
#

What are you working on?

#

Thank you for the links to the documentation also. That's where I'd landed, just browsing through Unity.Animation.Hybrid source. πŸ™‚

karmic basin
#

Me ? Exploring the state of netcode and physics to assess if I will be able to make a game or need to wait/switch solution.

#

I'm interested in other packages also like animation and dataflowgraph, but didnt have a look yet

#

and of course Tiny, but seems way early like you experimented yourself

rugged lark
#

What was your opinion of netcode?

gusty comet
#

from the start in unity we been threading-unsafe unsure, does the gpu cores of 1024 get to handle a gameobject each a zombie, other cpu 8 cores for player environment and physics, no it does not dots beta

karmic basin
#

I still need to push it, but like all previous Unity netcode solutions, it lacks a lot of features (for now let's just assume it's early, let's see where they go with it). Looks really promising to me for the future, hope they make something of it

#

Not so helpful of an opinion I know. I just move forward optimistically until I'll eventually meet a no-no blocker one day, or achieve the prototype I am aiming for, whatever comes first

#

And of course if you dont like boilerplate, it's too early, but hey if you're following DOTS you're already crazy like us

gusty comet
#

dots is not for productions use, we schould keep in mind (ecs, burst, c# c++ jobs)

karmic basin
#

Isn't Jobs already stable ?

#

Outside of DOTS/ECS

rugged lark
#

I've been wanting to build an alife sim in Unity and DOTS seemed like a great way to boost entity counts while allowing for systems-based emergence. This is my first brush with Unity. I don't have a production, I just figured I might as well come to terms with it in Preview since I'm learning from scratch anyhow.

rancid geode
karmic basin
#

Why not go hybrid ? a MonoB game, and use entities and jobs only for heavy computations

#

Alright didnt see your last sentence πŸ™‚

#

You're eager to learn like us ^^

rugged lark
#

Most of the experimentation/playing I want to do is going to be with AI and ML, so I'm fine building most of that from scratch since I likely would be anyhow. And as for why not hybrid? Because I'm less worried on getting the project done than I am learning unity (and DOTS) in the process.

#

πŸ™‚ Yeah, mostly I just think DOTS is shiny and I want to peck at it.

whole gyro
#

Ever since updating to 0.17, my game will grind to a halt for a second or two the first time a mesh is loaded. Specifically, it is when a prefab entity with a RenderMesh is instantiated as a non-prefab entity for the first time. Anyone know what's going on and if this can be avoided?

karmic basin
#

Did you try using the subscene workflow ?

#

If you're sure you can reproduce with same project between 0.16 and 0.17, file a bug report ?

#

(or forum thread)

whole gyro
#

No, haven't dug into subscenes yet. Was planning to eventually, but for now I'm doing manual conversion (GameObjectConversionUtility) when the game starts. I'll try to to revert to 0.16 and reproduce this. Just curious if this was a known issue already. Thanks for the quick response!

karmic basin
#

Yeah try it for heavy geometry count. Subscene serialises into disk a quick to load in RAM format. It could improve. But I guess you're not supposed to have 1 sec loading for only a mesh.

#

Maybe someone else will share experience with mesh loading

ocean tundra
#

@whole gyro Exaclty what part freazes up?
When you do something like em.instinate(prefabEntity)
OR
GameObjectConversionUtility.ConvertGameObject (probably wrong spellings/words )

light mason
#

i have a question i was wondering if someone could help me please

#

In tiny, im using TextLayout.SetEntityTextRendererString() to draw some text

#

how do i deactive the text

#

do i just delet the entity from World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName()

ocean tundra
#

ive never used tiny, are you trying to destory or hide the text/entity?

light mason
#

yes

gusty comet
ocean tundra
#

πŸ˜› that was not a yes no question

light mason
#

i have that var

#

but im using it like this

#

if (draw.MyText)TextLayout.SetEntityTextRendererString(EntityManager, nodeCountEntity, $"Hellot {x}");

#

but i guess i should not even create the entity ?

#

should i grab my draw entity as singleton and then if true do World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName()

ocean tundra
#

wow tiny is way different

#

in normal DOTS i would try to find the entity and add a disabled tag to it

light mason
#

i think this i kinda new

#

in tiny

ocean tundra
#

but no clue in tiny

#

sorry

light mason
#

im following what they did in the timer example

#

or trying

gusty comet
light mason
#

ok let me try that

#

does systemBase still have postcommands

#

was that removed or renames

#

renamed

ocean tundra
#

you need to get the commandbuffersystem

light mason
#

ah

ocean tundra
#

so in oncreate do World.GetExistingSystem ....

#

then system.createcommand buffer

#

and after your code

#

system.addhandleforproducer(dependancy

light mason
#

got it thank you

#

what system should i use

#

is there an end of render sys

#

Im guessing i do not want this in the EndInitizatoinCommandBufferSystem

ocean tundra
#

probably end simulation

light mason
#

ok thank you

#

is there an end render somthing cmd buffer sys

ocean tundra
#

theres a start and end for each of the built in system groups

light mason
#

presentation grp

ocean tundra
#

so yes

light mason
#

ok good to know

pliant pike
#

basic stupid question, but how do I set a single value in a componentdata without changing the other existing variables

ocean tundra
#

em.SetComponentData(entity, data)

#

em = entity manager

pliant pike
#
var tempflowfuld = tempdestination;
            tempflowfuld.DestinationCell = treenumb;
            tempdestination = tempflowfuld;```
#

so you can't do it like that?

ocean tundra
#

nope

#

well you can but need that em bit

#

basicly theres a HUGE difference with how the data exists, STRUCT vs CLASS

#

so you need to get/construct the data then use EM to set it back

pliant pike
#

the annoying thing about that though is I have to have two separate getsingleton one for the entity and one for the componentdata

#

yeah I know struct is by value

ocean tundra
#

pertty sure there are singleton helper methods

#

get/set Singleton data?

pliant pike
#

I just wish there was a way of getting the singletonentity from the singleton component

ocean tundra
#

isnt there a GetSingletonEntity method??

coarse turtle
#

Yeah

#

GetSingletonEntity<YourComponentTypeHere>()

pliant pike
#

yeah but that's what I mean it's a separate call type thing

#

I don't know what I'm saying I guess it doesn't make much difference πŸ˜•

ocean tundra
#

yea would make sense to have a overload with a out/ref paramenter

#

doubt it makes a big difference tho

zenith wyvern
pliant pike
#
tempdestination = GetSingleton<FlowFieldData>();
tempdestination.DestinationCell = treenumb;
SetSingleton<FlowFieldData>(tempdestination);```
#

it seems like that's the best way

ocean tundra
#

yup

whole gyro
ocean tundra
#

@whole gyro can you share some code

#

Using a ecb vs em shouldnt matter

#

as long as its already converted

whole gyro
#

Sure! Here is the instantiate code:

Entity previewBelt = commandBuffer.Instantiate(_beltPrefabSystem.GetBeltPrefab());
commandBuffer.SetComponent(previewBelt, position);
commandBuffer.AddComponent<PreviewTag>(previewBelt);
Connections connections = default;
if (_gridSystem.TryGetEntityAtPosition(position, out Entity existingBelt))
{
    connections = EntityManager.GetComponentData<Connections>(existingBelt);
}
commandBuffer.SetComponent(previewBelt, connections);
ocean tundra
#

and what does _beltPrefabSystem.GetBeltPrefab() do?

whole gyro
#

It returns the prefab entity that I create in _beltPrefabSystem in OnCreate().

ocean tundra
#

hmmm

#

so not doing any work in _beltPrefabSystem.GetBeltPrefab()?

#

and that above Instantiate code, is it in a OnUpdate directly or withing a job/entities.foreach?

whole gyro
#

The code for GetBeltPrefab:
public Entity GetBeltPrefab() => _basePrefabEntity;

#

And instantiate() is in OnUpdate() directly

#

@ocean tundra Just to clarify my problem, I don't think it is from the call to Instantiate() directly. The profiler shows the freeze in the hybrid renderer code, but I believe it is on the frame that the entity was instantiated. The call stack shows stuff related to updating batches and adding chunks so I assume it is some kind of setup work that hybrid renderer needs to do for the new mesh. And I also assume that the hybrid renderer skips doing this work for prefab entities since they don't need to be rendered.

ocean tundra
#

yea makes sense

#

i was just wanting to rule out the simple stuff

#

is the model/mesh/material anything special?

#

and does it happen with EVERY new belt? or just the first? or only after the world is 'busy' (lots of other stuff to render)?

whole gyro
#

Just the first frame that a given mesh needs to render. All other frames after that are very fast

#

The mesh has 2900 verts, 2800 tris. No idea if that is special haha

ocean tundra
#

πŸ˜› neither

whole gyro
#

I'm using shader graph for the materials. Don't think I'm doing anything too crazy in those though

ocean tundra
#

it only happens 1ce per mesh? even if you have many entities with the same mesh?

whole gyro
#

Right. I'm making a factorio-like game if you're familiar with it. So first time I need to place a straight belt, freeze for 2 seconds. But from then on, all straight belts can be instantiated and rendered extremely fast. But now if I need a corner belt, it will freeze again for 2 seconds and then all future frames are good again

ocean tundra
#

yea makes sense

#

(also love factorio)

#

your guess sounds right to me

#

something todo with a new mesh/material needing processing (maybe upload to gpu?) by hybrid renderer

whole gyro
#

Actually, that's a good point! I was using straight and corner belts in my example but it actually doesn't quite happen like that. The straight and corner belt use the same material. Whichever I instantiate first, I get a 2 second freeze. But the once I instantiate the second one, no freeze. However, when trying to instantiate a different mesh with a different material, I get the freeze again. So I think the issue is something with the materials/shaders.

ocean tundra
#

Agreed

#

i dont have anything like that happening in my tests atm

#

but also im not instantiating anything

#

yet

#

are you using URP or HDRP?

whole gyro
#

URP

#

I wonder if there is some kind of lazy shader compilation going on

ocean tundra
#

it used to be that the item would just render pale blue if the shader was compiling

#

but that was like 7 months ago

whole gyro
#

Yeah I remember it doing something like that at one point, but in magenta

#

hmm, found something about preloaded shaders in unity's graphics settings.

zenith wyvern
#

You said you're manually calling with ConversionUtility? Maybe try with IConvertGameObjectToEntity?

whole gyro
#

That only works for game objects in a scene, right? These are prefabs.

#

I do plan to switch to subscenes and I could also try IConvertGameObjectToEntity, but I was first trying to see what the issue is. This is a new issue for me with the latest packages. Was working fine before that.

zenith wyvern
#

Well you can store the entity version of your prefab on a component so it's "preloaded", then you can query for that and instantiate your entity prefab, but I'm not sure what your setup is exactly

whole gyro
#

The prefab entities are preloaded. In other words, they are converted when the game starts and exist as prefab entities in the world. That all works great. But I only hit this freezing issue later on when I first try to instantiate the prefab entity.

zenith wyvern
#

When you call GetBeltPrefab, is that when you're calling into conversion utility?

#

Ahh okay

whole gyro
#

Yeah, that just returns the already converted entity

ocean tundra
#

Hey All

What Native container would people recommend for Parallel Producing and Consuming messages (Custom structs, usually about 3-4 fields but could be more)?

I've tried with NativeStreams but I'm having major issues with its whole BeginForCount thing

#

Oh well theres a NativeQueue, Parallel Writing but single reading i think

robust scaffold
#

Hm, looking at all my IJobChunk structs, I now see why people like the ForEach lambdas. Writing chunk.GetNativeArray(ComponentTypeHandle); over and over again along with a for loop does get tiresome after the 30th struct.

deft stump
#

So you didnt get tired by the 29th time?

rugged lark
#

A man knows his limits.

rugged lark
#

So ECS recommend instantiating an entity from an archetype. But RenderMeshUtility only accepts entities. So I'd need to create an entity prototype, use RenderMeshUtility.AddComponents(<entity>,..) and then instantiate copies of that entity. Which is not the pattern ECS recommends. Am I missing something or is there a way to attach a RenderMesh directly to an archetype?

zenith wyvern
#

You should be instantiating entities from prefabs

#

If your prefab has the rendering components that conversion expects then it will get the rendermesh stuff on it automatically during conversion

#

With the authoring workflow you shouldn't need to manually piece together components in code outside of your conversion scripts

rugged lark
#

I know you're right. But where you see "shouldn't need to do this entirely in code" I see "but wouldn't it be cool if I could do this entirely in code"

#

I'll seek help. In the meantime I'll go make a prefab.

zenith wyvern
#

I definitely think it makes sense in some cases. Like for my particles thing I set up a builder pattern so you can say ParticlesUtility.MakeEmitter().WithEmitterRate(x).WithColorOverTime(a,b)...etc. But it was very annoying to set up, and I would only go out of my way to do something like that if you're sure you're going to be making variations of The Thing in code regularly. Otherwise just use a prefab, it saves a lot of time and is very customizable since you get to use the editor to tweak stuff

honest plinth
light mason
#

what is the fastet way to get an Obj.IComponetn[] to a NativeArray

#

var newArray = new NativeArray<MyComp>(len, Allocator.TempJob);

#

newArray.CopyFrom( OtherArray);

zenith wyvern
#

You can pass the managed array directly into the constructor

light mason
#

var newArray = new NativeArray<MyComp>(OtherArray, Allocator.TempJob);

#

like this?

#

ah yea , works , had typo

#

thank you

honest plinth
#

Thank you @karmic basin . That looks really strange, no work getting done at all during that time. @whole gyro do you think you can submit a bug for this? Would really like to see what it is waiting on during that period.

cerulean forge
#

Hey all,

I love DOTS and ECS (entities). But I'm a bit worried about how long it might take for DOTS to become stable. Are there parts that are more stable than others? E.g. am I safe to use ECS but should I avoid things like the DOTS physics system? Very hard to find any info or news, which is not encouraging to begin with.

amber flicker
feral plover
#

Hello, Im pretty new into jobs system, and I would like some help, especifically for using variables into a job

#

How can I use a string inside a job?

#

using this gives me an error public string enemyTag = "Player";

coarse turtle
#

it stores the bytes of a string - so you can do something like, new FixedString512("Player")

feral plover
pearl pulsar
#

For my own clarification/knowledge on the topic, Jobs are separate from the Systems part of ECS because systems are meant to run per-frame, while jobs are meant to be long-spanning and relatively asynchronous to the game loop. Is that a correct grocking of the differences?

hollow sorrel
#

they are seperate because they were developed seperately, ECS didn't exist when the job system was implemented

#

but also generally jobs are meant to be short and happen over 1 to a few frames

#

nothing stopping you from running a long spanning job but they're not really the best at that

zenith wyvern
#

Doesn't it whine if you run a job for more than 4 frames?

#

Or did they change that

hollow sorrel
#

if you allocate with jobtemp allocator it does for sure but if you don't use that I'm not sure

karmic basin
rancid geode
#

jobs are both for short running and long running stuff, be it something for less than 1 frame or a long running operation, I see them as "C# Tasks in Unity way"

#

the main capability of Jobs over C# Tasks is the Burst compatibility

rancid geode
#

if you don't need Burst, you probably don't need jobs neither

pearl pulsar
#

That makes a lot of sense. Thanks guys!

light mason
#

so im in the tiny time example and trying to swich off the time text entity

#

everytime i try add a Disabled IComponent it errors

#

is on main thread

#

TimeEntity = World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName("TimeText");

#

EntityManager.AddComponentData(TimeEntity, new Disabled());

#

is this not supported or am i doing this wrong

hollow sorrel
#

what is the error

light mason
#

well that the problem w tiny

#

can run in editor and in crome debug the stack is not anyting you can track

#

cant

acoustic spire
#

How to run system in edit mode and query a converted subscene? Is this even possible?
The system below is created in editor world but has no access to subscene entities

[WorldSystemFilter(WorldSystemFilterFlags.Editor)]
public class DebugRenderingSystem : ComponentSystem 
{
// ...
}    
warm panther
#

Does it make sense to use ComponentType.ReadOnly<T> for Entity Queries?

void girder
#

Yeah

warm panther
#

But... in what context. πŸ™‚ Because I can get an entity and just make EntityManager write to the component anyway.

#

I mostly use EQs in mono space, in burst systems I use the internal ones.

rare dew
#

Is there a way to use the more event based solution?

#

I'm currently trying this, but whatever happens in the performed block doesn't get executed

#

I was missing this line 😐

        protected override void OnStartRunning()
        {
            input.Enable();
        }  
void girder
#

@warm panther I've personally used them to get a query's entity count, and to set shared component data in batches, which I believe doesn't cause the chunks to move around

warm panther
#

Yeah I use them for that a bit too but... I don't understand the way readonly even affects the query itself.

void girder
#

I guess one reason is if you call ToComponentDataArray

whole gyro
deft stump
robust scaffold
#

Anyone know if physics is supported in ISystemBase?

#

I'll be amazed if it is.

rare dew
#

thanks for the repkly @deft stump

#

What did you do here? Also sorry it's always you I @, it's just you who's most relevant all the time πŸ˜…

robust scaffold
rare dew
#

version 0.6 preview 3 yes

robust scaffold
#

They'll still be converted but the values are more 1 : 1 with the Entity rather than some redirection.

#

Ah, nvm. You're using RigidBody and Collider 2D.

#

Those dont work.

#

DOTS only support 3D. You can kinda fake 2D by clamping the Y axis ( or another axis depending on how you orientate your ground ) but the stability is shaky.

rare dew
#

Right

robust scaffold
#

Stability in that the object literally shakes and vibrates as it moves with friction.

rare dew
#

That's a shame, because I really like ECS and the jobs system πŸ€”

robust scaffold
#

Unless you want to implement your physics with optimized spacial lookup and collision mechanics specifically in a 2D world, you're out of luck. It might not be too hard... kinda.

#

Grab your nearest decompiler and look at how Havok is doing, then remove one axis.

#

Reinventing the wheel sure but it's the only way you can get 2D to work in DOTS.

rare dew
#

I mean, I suppose rolling my own is the only solution 😦

robust scaffold
#

Or use Tiny with it's half implemented engine.

#

Tiny has kinda full 2D physics but you're missing a massive chunk of the engine as well. But there's 2D.

#

There's also the hybrid method, ditch Hybrid Renderer (it was a mistake to begin with) and manually translate whatever happens in the game object world to Entities.

#

Use all the solid built in physics provided by unity as movement and rendering code, far better than what DOTS has anyways, then do all the computation and data crunching with entities, then pass anything relevant back to Gameobject land. You'll have to do that anyways if you ever think of making a UI.

rare dew
#

That gives me headache to think about at 1 am

#

Do you have articles handy you could share?

robust scaffold
#

No articles. Anything you find will be largely outdated unless they're really specific and very abstract that can survive major version bumps. I'm just talking from a few months (or is it years now) of experience working with DOTS.

#

Not too hard anyways. You can use SystemBase for everything anyways. Gameobject is a static class and fully functional in DOTS SystemBase main thread. You just dont have the fancy editor inspector variable assignment. You can use a bootstrap monobehavior for that.

rugged lark
#

Can you describe what a non hybrid renderer would look like for ecs?

robust scaffold
# rugged lark Can you describe what a non hybrid renderer would look like for ecs?

Lets say you have a GameObject cube named Cube you want to move forward with at a speed located in a Component.
In the OnUpdate(), you get the cube's transform (standard Gameobject transform, not DOTS) using GameObject.Find("Cube").transform.
Then use a GetComponentData<SpeedComponent>(entity) and use the speed value to compute the transform like it's regular monobehavior.
Fairly inefficient for a lot of cubes but just one, two, or even a dozen, it'll be more efficient than using Hybrid Renderer.
It's also good if you have a lot of computation going on behind the scenes like a simulation with a lot of entities that ultimately reduces to a single property that you can then set on a single or a few gameobjects.

#

The overhead of Hybrid Renderer is massive and only pays off if you're thinking about moving and rendering hundreds of entities. At the low end of double digits, manually translating Entity data to GameObjects are more efficient.

#

In between those ranges, that's profiler and whatever you wish or plan to do.

zenith wyvern
#

You can just use conversionSystem.AddHybridComponent on a mesh renderer and mesh filter and it will give you built in rednering attached to an entity that you can query for and syncs position automatically

deft stump
#

if you want a full on 2D approach you're gonna get creative with Phy Shape

robust scaffold
#

There's also IJobParallelForTransform that relates to Gameobject transforms. No clue how it works though.

deft stump
#

for example:
a normal job:
native array = array of positions.
process job
array of positions = native array.

ijobparallelfortransform:
some special container for transforms = array of positions
process job

robust scaffold
deft stump
#

I believe you don't need pointers

robust scaffold
#

The short blurb when I type it in with my IDE shows void*. Might just be how unity handles the transform in the background instead of ref.

deft stump
#

I believe the container is called TransformAccessArray

rugged lark
#

@zenith wyvern how do you handle animations in your 2d roguelike?

zenith wyvern
#

My "World" ultimately gets rendered into a single mesh - the terminal. It's just a mesh layed out in tiles. So swapping out a "sprite" is just a matter of changing the uvs for a single tile.

rugged lark
#

So if an entity occupies a space, you swap the tile for that entities' tile?

zenith wyvern
#

If I were to do something like that today I would probably try to use hybrid renderer to render quads and swap out sprites with per-instance uv data using the built in hybrid renderer instanced ecs components

zenith wyvern
rugged lark
#

If I have a mesh in my assets folder, how do I get that asset assigned to MeshFilter?

#

Any idea?

zenith wyvern
#

When it needs to re-render it does a kind of "back to front" thing, so it clears, sets uvs for terrain, then sets uvs for characters and items, then ui

rugged lark
#

And by "conversion" you mean go look at the conversion code and see how it does it? πŸ˜‰

zenith wyvern
#

I mean set it up as a normal gameobject so it will get converted into an entity that renders, make it a prefab, convert that to an entity prefab, and instantiate that at runtime

rugged lark
#

I know, I was being stubborn because I want to do this entirely in code.

zenith wyvern
#

Without a smooth workflow to get an asset into an ecs friendly representation, it's kinda awkward. Easiest way would be to load it with Resources.Load, then set it on your RenderMesh.mesh

rugged lark
#

Resources was what I was missing, thank you.

#

I just couldn't figure out how to tell Unity to look in the damn folder for that mesh.

#

My only reluctance against prefabs is that I'm working towards an alife simulation and I'd like to allow entities's limbs to define their own meshes based on genes. I don't need any real fidelity, the lowest-poly representations will suffice, but I would like to know how to define and render meshes entirely via code for that purpose.

#

But right now for testing I just want to plug in some prebuilt meshes for testing

zenith wyvern
#

I assume you're aware of how bad hybrid renderer is at rendering lots of entities with unique meshes?

rugged lark
#

I absolutely am not.

#

And I love discovering these things.

zenith wyvern
#

Basically every set of entities that shares a mesh and a material will get put together nicely in chunks for faster rendering. Any time you change a mesh or material on entity, it will get put into a new chunk

#

Fine at a small scale, but if you're talking thousands of entities with unique meshes it's going to get real rough

rugged lark
#

I'm talking more on the order of ~200 unique meshes and maybe 10,000 entities

zenith wyvern
#

You should profile but my feeling is it would be really slow with hybrid renderer and you may want to look into gpu instancing

rugged lark
#

I'm looking into it now. Am I understanding correctly that it requires a GameObject?

zenith wyvern
#

Not really, you can use compute buffers and DrawMeshInstancedIndirect/DrawMeshInstancedIndirectProcedural, neither of those actually require a gameobject, they just take your mesh data and your per-instance-data and render. Although in the end you're still going to have to do one call for every unique mesh

#

No idea if that would be slow or faster than hybrid renderer

rugged lark
#

I guess I need to go try to understand hybrid renderer better so I can appreciate the difference. Thanks for giving me the heads up though.

#

Is this hobby or profession for you?

zenith wyvern
#

Hobby

rugged lark
#

What's your day job?

zenith wyvern
#

Although I did get freelance work recently for the first time

#

Which is cool

rugged lark
#

That is super cool.

zenith wyvern
#

My day job is nothing to do with programming sadly

rugged lark
#

Your experience with the unity APIs seems pretty robust. You been doing this for a while? πŸ™‚

zenith wyvern
#

Yeah, many years

rugged lark
#

Awesome. Well thanks for answering my questions. Do you have any specific resources you recommend in terms of coming to grips with Unity and DOTS

zenith wyvern
#

I always answer that question with the github samples and manual. The samples especially helped me really put everything together. The advanced samples are maybe a little too advanced but there's a lot to learn there

rugged lark
#

Awesome, that's what I've been going through. Have a good night. Thanks again.

cerulean forge
#

Hi all,

Is there a way to get all collisions in a scene? (instead of handling every individual collision in OnCollisionEnter, etc callbacks) As I understand it the physics engine calculates all collisions, and then calls these callbacks. Is there a way to get them at that stage?

I'm following an ECS approach for some things in my game through DOTS/entities but I'm trying to avoid the actual dots phsyics/rendering stuff as it's not stable yet. So I do want to process all collisions in one batch, but I don't want to rely on DOTS/physics.

From what I've googled it doesn't really seem possible with the regular phsyics engine? That would kind of surprise me.

(asked the same question in #βš›οΈβ”ƒphysics but though folks here might have ideas about this too :))

karmic basin
#

Yeah so that's a shame because the com.unity.physics package gives you acces to the broadphase with all colliding pairs in a Job you can "subscribe" to. You can also write your own HitCollectors 😎

But the legacy one I never looked. Heard it is pretty shy about the internals... :/

#

I'm trying to avoid the actual dots phsyics/rendering stuff as it's not stable yet
For now I'm pretty happy with it. Especially the determinism part vs physX. Can't say yet I'm amazed until I push it hard, but I love it.
Only for now I don't like the response to trigger and collision events, which are very verbose (so yeah lot of boilerplate that could easily get broken in the future).
I must admit I've seen some jittering and teleport shenanigans here and there some times, but could also be only me messing with the netcode and system ordering parts.

rare dew
#

DOTS Physics isn't open source, is it?

karmic basin
#

All DOTS is to be open source

rare dew
#

Soonℒ️

karmic basin
#

you can search your Library/PackageCache

cerulean forge
#

Seems like non-DOTS unity development really tries to shoehorn you in OOP :/

#

It seems so odd to me that there would be no access to the broadphase

rare dew
#

Well, I'm strangling OOP with my FP

karmic basin
#

I mean, like 99% current Unity API

rare dew
#

Which still isn't great with DOP

#

I am however pretty satisfied that I got this working:

#nullable enable
#region Usings
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine.InputSystem;
#endregion

public class InputHandler : SystemBase
{
    private PlayerInput input = new PlayerInput();
    private Movement? movement;

#region Handle Input
    protected override void OnCreate()
    {
        UnityEngine.Debug.Log("Test create");
        input.Player.Move.performed += Move;
        input.Player.Move.canceled += StopMovement;
        
    }

    protected override void OnStartRunning()
        => input.Enable();

    protected override void OnUpdate()
    {

        float deltaTime = Time.DeltaTime;

        Entities
        .WithoutBurst()
        .WithAll<PlayerControllable>()
        .ForEach((ref Movement move) => {
            move = movement ?? Movement.zero;
        }).Run();
    }
#endregion
#region Controls
    private void Move(InputAction.CallbackContext context)
        => movement = context.ReadValue<UnityEngine.Vector2>();

    private void StopMovement(InputAction.CallbackContext context)
        => movement = null;
#endregion
}
karmic basin
karmic basin
rare dew
#

It was actually much simpler than I thought it'd be!

karmic basin
#

It's clean, I like that

rare dew
#

well I say that, but I spend the entirety of yesterday to make it

karmic basin
#

Doesn't matter, you know how to do it now πŸ™‚

rare dew
#

It's clean because I made Movement to be cursed

using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;

[Serializable]
[GenerateAuthoringComponent]
public struct Movement : IComponentData
{
    public float3 Value;

    #region Operators
    public static implicit operator Movement(float3 value) 
        => new Movement() {Value = value};
    
    public static implicit operator float3(Movement movement) 
        => movement.Value;
    
    public static implicit operator Movement(Vector2 value) 
        => new Movement() { Value = new float3() {x = value.x, y = value.y, z = 0} };
    
    public static float3 operator * (Movement movement, float value) 
        => movement.Value * value;
    #endregion

    #region Static Members
    public static Movement zero => new Movement() { Value = float3.zero };
    #endregion
}
#

next in my todo is collision detection and comments

karmic basin
#

yeah implicit operators help a lot here πŸ‘

#

What do you mean by "comments" though ?

rare dew
#

You think my code is self documenting?

karmic basin
#

lmao I thought a "Comments System" ^^

#

Yeah don't really need comments as such. Understood it at a glance.

#

gtg eat, have a nice day

rare dew
#

thanks for the feedback, I'll make a gist with my system

deft stump
rare dew
#

if I remember, I'll share the gist once I arrive at my destination

ebon narwhal
#

Hello all. I have a question that i really find it hard to find any information on the documentation.

#

How can i make a custom made World object to render ?

#

This is a little bit puzzling.

ebon narwhal
#

hmmm I should have written this differently. sorry for that. I know how to use the default world. But i want to use a custom world to render. Is this even possible ?

zenith wyvern
#

You would have to make sure your custom world has all the systems that hybrid renderer requires to work

ebon narwhal
#

Oh. hmmm Sorry to ask again. Where can i find these requirements ?

zenith wyvern
#

An easy way would be to get all the systems from the default world and add them by type to the new world

#

Or maybe there's an easy way to just copy an entire world, not sure

ebon narwhal
#

Oh i found this one.

#

I think there is quite some juice to help me with my task.

karmic basin
#

@ebon narwhal make sure to switch to latest version. Click that blue button on the topbar

rugged lark
#

I do it all the time. I'll start searching the docs for something, have a "why can't I find this thing I know exists", and realize I'm on the old version.

karmic basin
#

and from entities you have quicklinks on the left menu to other packages

pliant pike
#

I'm probably being stupid as usual but what am I doing wrong with the below code, is it just not possible to set componentdata this way, I'm sure I did it before? πŸ˜•

#
var TempCelldata = CellDataQuery.ToComponentDataArray<CellData>(Allocator.Temp);
var tempcell = TempCelldata[i];
tempcell.bestCost = 100;
TempCelldata[i] = tempcell;```
mint iron
#

mmm looks fine as long as you assign temp cell back onto an entity. tempcelldata is a copy no?

zenith wyvern
#

CellDataQuery.CopyFromComponentDataArray(TempCellData)

pliant pike
#

That's it that's what I was forgetting I have to copy it back after the job right

#

awesome, it works, Thanks Sark

rugged lark
#

Sark you brought up Hybrid Renderer vs GPU instancing. In the Hybrid Renderer docs, at least for V1, it specifies that HR uses GPU instancing. I don't see anything about V2. Can you elaborate on why I'd want to avoid Hybrid Renderer in favor of GPU instancing?

zenith wyvern
#

V1 did use gpu instancing,v2 doesn't. Gpu instancing just gives you a "simple" way to render thousands or millions of a single mesh. I haven't really measured it against hybrid renderer but it worked well for the sprite renderer stuff we were doing a couple years ago.

#

I would go with hybrid renderer first and see if it works out

rugged lark
#

I was thinking the same thing. I'll deal with performance problems when I encounter them. I've been in the planning/tooling stage for too long lol

#

I'll proceed with HRv2 and just see how well it works for my needs before I go finding more windmills.

deft stump
zenith wyvern
#

I'm not sure. They replaced it with all the batching stuff which is barely documented

acoustic spire
#

Is there way to access an entity by its index directly in jobs (readonly)? ECB does not provide this kind of API.
I'm trying to implement iterating over entities and also need to access their "adjacent" siblings. So I store indexes of these adjacent entities as components

robust scaffold
#

Entity is a struct.

acoustic spire
#

You mean its copy? They're heavy

zenith wyvern
#

An entity is literally just two ints

#

It's expected and common to store them in components for referencing other entities

robust scaffold
#

Entity is an index. Contains the actual index and version number.

#

Unity uses that struct (2 ints) to index a component array

acoustic spire
#

So you mean that I can just write like this?

struct Something : IComponentData {
Entity next;
}
robust scaffold
#

Yep

acoustic spire
#

Perfect. That's even better

robust scaffold
#

100% intended. Unity also has a special way of tracking components with Entity properties for serialization and deserialization. Havent tried it personally but somehow it can be used to save worlds, even if the entities dont line up. Unity keeps track.

acoustic spire
#

But how do I access its component in jobs? afaik i cant use entity manager in there

acoustic spire
#

Okay. Thanks

rugged lark
robust scaffold
rugged lark
#

I just keep chuckling at how many "oh, and also..." moments I keep running into with Unity DOTS.

robust scaffold
#

I've given up on Hybrid. I will render my entities by hand, Drawing them on the screen at 120fps myself.

#

I got my sharpie and nail polish removal ready.

rugged lark
#

What was your pain point?

robust scaffold
#

Base SPF (seconds per frame) ~2.0ms. Hybrid with blank screen: ~6.5ms. What.

#

Hence, I draw the entities myself (learning compute buffers one painful tutorial at a time).

#

Took me 5 hours but I finally got a rotating triangle rendered on the screen.

rugged lark
#

lol that was me last night. Trying to figure out how to create and render meshes by hand

#

via code, I should say

robust scaffold
#

Yea. One half is learning how meshes are created. The other is learning how Graphics.DrawProceduralIndirectNow works. The method is very sensitive and seems to stop working the second I sneeze in the wrong direction.

#

Doesnt work in SystemBase unfortunately. Only works in Monobehavior's OnRenderObject

rugged lark
#

So if you want to use SystemBase, are you locked into Hybrid Render?

robust scaffold
#

No. Just use Mono for rendering and pass inbetween.

acoustic spire
zenith wyvern
#

I've been doing some testing and it actually seems like hybrid renderer is a lot better than it used to be at handling lots of dynamic meshes. It's been a long time since I tried it but before it was like comically bad compared to gameobjects, now it seems pretty comparable in a test scene with ~500 entities all with unique meshes that get changed every frame. It seems like it still won't scale well to crazy high numbers but it's at least a lot closer to gameobjects now in terms of performance.

karmic basin
#

I would not give up on HR. Especially if you have other walls to break elsewhere in your project: just focus on those meanwhile. Bet on the future. HR v2 is where Unity wanna go for now, expect performance to go up. What's the point spending 2 months circumventing it when they'll put a new release after you, and you put all that time to the bin. Focus on your game, not completing the engine on their behalf (unless your game is finished and you're just waiting for the tech ?).
At least that's my point of view πŸ˜‰

#

When they push a release, you refactor/migrate and earn the performance boost. Meanwhile you kept progress on solving your problem

#

/building your app

deft stump
#

the only thing I'm waiting for is enable/disable components

#

hoping in 0.18 release

amber flicker
deft stump
#

................

#

my day is ruined

#

I'm forever disappointed in Unity

#

time to ask WSB to buy Unity stocks to speed up DOTS development

rare dew
#

Is Unity even publicly traded

deft stump
#

it is

rare dew
#

also @deft stump did you stare at my implementation? πŸ‘€

deft stump
#

mine has so many roundabouts

rare dew
#

πŸ‘€

merry fossil
#

Is any part of DOTS production-ready?
I have been using other ECS systems for the past few years (Entitas to be exact) and would like to use the Unity ECS but it seems to be super unfinished.

rare dew
#

I'm super curious

rare dew
deft stump
#

Unity ECS is still unfinished.
but
you can use jobs and burst fine

merry fossil
#

I'm not very interested in the performance aspects, but more in the architecture/design pattern aspects of it

rare dew
#

You can even hook the new Input System into Jobs

#

Well you won't be getting burst

merry fossil
#

I do need 2d physics.. and I would not consider that advanced tbh πŸ˜„

rare dew
deft stump
#

on the architect side of things...
it

#

eh

merry fossil
#

Is there any rough estimate on when v1.0 will be out? I don't see any public roadmap

deft stump
#

lots of workarounds even if you want to use 2D physics

merry fossil
#

how is the usability of ECS so far? from what I saw it looks like a lot of boilerplate is still needed to set-up components and systems

rare dew
#

Putting entities on gameobjects is like 2 minutes tops

#

Just add the [GenerateAuthoringComponent] attribute on your components and you're good

#

Once you get the hang of components and jobs, it's really not all that different from MonoBehaviour

merry fossil
#

are there big in-editor performance improvements from the burst compiler? never tried it

rare dew
#

do you mean the game preview?

#

In that case, yes

merry fossil
#

i mean the workflow from change in code to entering play mode, basically: are there improvements in the time this takes?

rare dew
#

It's a bit slower

#

But the code is more performant

merry fossil
#

it's slower? 😲 wtf

rare dew
#

Compilation is

#

Because the code ends up more performant

#

Makes sense, doesn't it?

merry fossil
#

yeah it makes sense, my biggest problem with the current project is that the time from code change to playtesting takes >20 seconds

#

but that's not even that much from compile time but mostly from assembly reload time, which is something else entirely

#

any estimate on when DOTS will be production-ready?

#

like, 1 year off? 2 years? 6 months?

rare dew
#

Honestly, I don't know

#

I find the API still being a little volatile, so if you plan to release tomorrow maybe hold off

#

But if you plan to release in a year, I don't see an issue with implementing today

deft stump
#

no one really knows

#

we're alll fiddling with our thumbs

#

as unity doen't release a roadmap

#

on what to expect

rare dew
#

I'm thinking of either making my game 2.5D or make my own collision detection plugin for DOTS

#

the latter would use some raycasting

merry fossil
#

nah i'm just finishing up a big multi-year project that doesnt use DOTS but I will start a new one later this year and I'm doing research on what to use and what to hold out on

#

but it seems like i've been waiting on DOTS progress for years (from the sidelines) and it's gotten very quiet, looking in from the outside

#

just hope it doesn't get half-assed like many other features. i really love DoD

rare dew
#

there's progress, you can see that from the changelog

#

It's just anything like "look at my 3 million entities at 60FPS" so that may be why it's silent

merry fossil
#

did any of you use Entitas ECS and can tell me how Unity ECS compares to it? I have been using Entitas for years and my gut-feeling says that it has way more syntactical sugar due to its code generation (both pro and con imo)

amber flicker
#

The caveat with the enter play mode options is you have to be careful if you have much going on with statics around your codebase.

merry fossil
#

but i will definitely use this on the next project!

amber flicker
#

Yea, much easier from the start of a project and super nice.

merry fossil
#

i have a dream: make a change on a sizeable project and playtest it in <5 seconds. that would be my absolute dream and it would make game dev so much more fun. and there was this blog post by joachim ante (i think) a few years back that said the same thing. i just really hope that this will be achieved soon!

amber flicker
#

As for v1.0, @deft stump is correct - nobody knows. Including Unity I believe. They're taking the time to "do it right" so expect it to take quite some time. Unlikely to be this year, maybe not 2022 either. Very hard to say.

deft stump
#

if they could atleast give us a road map

#

like a believeable roadmap

rare dew
#

I've heard making seperate assemblies can speed that up

merry fossil
#

yes, as impatient as I am, it's probably better that they don't rush it. especially if they want to build their entire future architecture on it and eventually get rid of MonoBehaviours and GameOBjects entirely

deft stump
#

like... "HEY! this is our plan for the next 6 months!"

rare dew
#

If they could just make their trello board public

deft stump
#

I don't really care when v1.0 will be released.
at least give a roadmap

rare dew
#

like... "HEY! this is what we have done, this is what we need, and this is how fast we generally are"

deft stump
#

a believable one

rare dew
#

Input System v1 recently got released, so I'm hopeful

merry fossil
# deft stump like... "HEY! this is our plan for the next 6 months!"

yes, that would be super great. i am really frustrated with the state of unity because it feels like there are so many good things on the horizon but the state right now is full of half-baked non-solutions like the terrible animation & cutscene systems, monobehaviour and no real go-to architecture solution, wonky UI systems etc.

#

at least we have scriptable objects πŸ˜„

karmic basin
#

It's there, but undocumented

merry fossil
amber flicker
#

I think @merry fossil was including code changes.

rare dew
karmic basin
#

Still takes some time to boot up on first connection and kinda slow last time I tried

merry fossil
# rare dew Tell me more? πŸ‘€

people are doing cool stuff with scriptableobjects:

https://www.youtube.com/watch?v=6vmRwLYWNRo
https://www.youtube.com/watch?v=raQ3iHhE_Kk

also, Unity Atoms

Get the assets here: https://bitbucket.org/richardfine/scriptableobjectdemo/

This session goes over ScriptableObject class in detail, compares it to the MonoBehaviour class and works through many examples of how it might be applied in a project.

Richard Fine - Unity Technologies

β–Ά Play video

Scriptable Objects are an immensely powerful yet often underutilized feature of Unity. Learn how to get the most out of this versatile data structure and build more extensible systems and data patterns. In this talk, Schell Games shares specific examples of how they have used the Scriptable Object for everything from a hierarchical state machine...

β–Ά Play video
karmic basin
# merry fossil what's livelink?

What you think about I think when you talk about Joachim prez of editing realtime in the editor, and having a build kept open, reflecting changes realtime

amber flicker
karmic basin
merry fossil
#

@karmic basin ah, is live link that thing they demoed on the big DOTS talk a while back? where you change stuff and it's immediately in the live builds?

#

gotcha

karmic basin
amber flicker
merry fossil
#

to be honest, i really don't get how most people are building their games in unity at all. if you just follow "the unity way", every non-gamejam-game desintegrates into an absolute clusterf*ck of singletons and monobehaviour-hell. there is NO recommended architectural solution at all. DOTS is a good way forward and all, but again it seems to me like they're mostly focused on performance and scalability, like everyone wants to make a game with 60 million little soldiers.

the MOST important decision i make as the sole programmer of my team is how I will structure my game's core architecture. if I screw this up, even slightly, by using anti-patterns, singletons, statics, coroutines all over the place, it has repercussions that take up 90% of my dev time very quickly.

there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.

for me, i'm pretty sure that ECS is a pretty good baseline that at least prevents some huge mistakes i made before, but we still don't have a functioning framework that's production ready in the biggest game engine on the planet, and it's 2021.

deft stump
#

every non-gamejam-game desintegrates into an absolute clusterf*ck of singletons and monobehaviour-hell.
to be fair... I tried using interfaces... and I'm like... why am I using this? when I could just split it into another component

hollow sorrel
#

yes the "unity way" is bad, but I don't think it's fixable at this point
that's part of why I'm glad they're basically startingover with ECS, it's not just a way forward in performance but also architectural

deft stump
#

there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.
I'm with you there brother. as much as I like the freedom there's no one true way to properly write in classic unity. and because it's so "free" it ends up being a paralysis of which x and y do I use today

#

to quote from a certain anime "when you know everything, you can't do anything"

karmic basin
rare dew
#

But honestly

there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.
I get where you're coming from, but Unity is great if you got some computer science fundementals

karmic basin
#

Actually the "unity way" (the legacy one) is not bad at all. It's components based, but people don't understand that and try to force-feed OOP concepts down the engin throat

#

And DOD is a design pattern, you can still mess your architecture πŸ˜‰

rare dew
#

I'm so happy to learn scriptable objects exists!

deft stump
#

@karmic basin so you mean I can stop using interfaces?

karmic basin
#

Interfaces are great

rare dew
karmic basin
#

Actually I would have the same Movement system for player and enemy,just one from input, other from AI. But hey depends a lot on your game

rare dew
#

That's the joke

#

I shared my input system earlier

karmic basin
deft stump
#

still though...
I am still confused on project tiny's existence

#

why does that thing exist?

karmic basin
#

Yeah your input system was great @rare dew

rare dew
#

I should put it on my blog

karmic basin
#

Sure, a lot of people will ask how to do so

#

You'll get lot of traffic πŸ™‚

low tangle
#

Hm

rare dew
#

@karmic basin do you need ad space? πŸ˜›

low tangle
#

this is going to sound rude, but thats overly done

rare dew
#

It's cheap

low tangle
#

a input system is just the place where you gather your inputs into a struct, then stripe it into your desired input component

rare dew
#

That's uhm.. that's what I did?

low tangle
#

I assume its because your integrating with input system v2?

rare dew
#

It's actually v1.0.2

low tangle
#

most people I saw using that we're using a manual polling example that was posted to the forums a year ago

rare dew
#

I personally don't like polling

low tangle
#

I mean, v2 as in, not the old legacy unity Input.GetKey* functions

karmic basin
#

Yes; new Input System

low tangle
#

well ecs is all about polling, and inverted polling where its activated by the input data set

rare dew
#

Well in the old code it just did in Update or FixedUpdate eventually

low tangle
#

also minor tip, if you remove the null coalescing you can use burst on the foreach lambda

rare dew
#

oh? πŸ‘€

low tangle
#

which will flatten that code down to a struct copy only - as long as you default set the movement struct

rare dew
#

so that's the issue, ty!

low tangle
#

minor thing really but yeah

#

oh, your using a nullable movement struct

rare dew
#

I got a Movement.zero I'll just use that

low tangle
#

you will need to capture it right before the foreach, which is where you could keep the nullable coales

rare dew
#

or move it like that, better idea

low tangle
#

Movement v = movement ?? Movement.zero;
outside the foreach,
inside
move = v;

#

then remove the withoutburst and you will gain a insignificant amount of performance

#

feel free to profile it

rare dew
#

But imagine thousands and thousands of controllers!

karmic basin
#

Lmao

rare dew
#

It's just cleaner to have burst

low tangle
#

well it does tune it to the simplest form, which is just a data stripe from a source input struct

rare dew
low tangle
#

which can be fed in from anywhere

rare dew
#

Gotta have something to make the audience clap at

deft stump
#

OOOOOOH MY GOODNEEEESSSSS!

karmic basin
rare dew
#

Who're we kidding here

#

Thousands of projectiles controllable to kill snakes

low tangle
rare dew
#

Lol

#

Works like a charm, now with burst!

#

I'm a little sad however that I can't hook the new input system on a Component, so I can have some more composable control of players

#

If anyone knows of a way to do this, besides

struct ControlScheme : IComponentData
{
  public KeyCode up, down, left, right;
}

I'd be more than happy!

amber flicker
#

not sure I understand but.. enums?

merry fossil
#

does the DOTS/Unity ECS approach have reactive systems or something similar? Meaning: Systems that react to component changes on entities

low tangle
#

change filters

#

or just reactive components though query exclusion

pliant pike
#

one thing I've discovered about the new input system is you have to be careful using the input.Player.Move.performed += Move; for buttons

#

move if its a bool will remain true for however long the button is pressed

rare dew
pliant pike
#

so you end up with lots of inputs for a single button press, depending on how high the frame rate is because you can't press the button that quickly

rare dew
#

you can use enums for that

#

I had an idea in my head, but as soone as a began writing, I thought "nah"

#

but using .performed to switch a bool, and then flip it to false once the action actually has been performed isn't a dumb idea imo

pliant pike
#

yeah but I mean .cancelled doesn't become true until there is no input at all

#

its ok for movement I guess but not so great for button presses

torn kestrel
#

i'm trying to copy over data into a gameobject from an entity but my object doesn't render properly when I copy over the values despite. Not sure if I'm missing something ?

    {
        var ecb = _commandBuffer.CreateCommandBuffer();
        var gameObjectIndex = World.GetOrCreateSystem<GameObjectIndexSystem>();
        
        Entities
        .WithStructuralChanges()
        .WithAny<UpdateMeshTag>()
        .ForEach((Entity e, in DynamicBuffer<Point> points, in DynamicBuffer<Triangle> triangles, in GameObjectRef gameObject) =>
        {
            Debug.Log("UpdateMeshSystem");
            var go = gameObjectIndex.gameObjects[gameObject.index].gameObject;
            Debug.Log(go);
            var mesh = go.GetComponent<MeshFilter>().mesh;
            
            var newVerticesArray = new Vector3[points.Length];
            var newTrianglesArray = new int[triangles.Length*3];
            for (var i = 0; i < points.Length; i++)
                newVerticesArray[i] = new Vector3(points[i].x.x, points[i].y.x,points[i].z.x);
            for (var i = 0; i < triangles.Length; i++)
            {    
                newTrianglesArray[i*3] = triangles[i].a.x;
                newTrianglesArray[i*3+1] = triangles[i].a.x;
                newTrianglesArray[i*3+2] = triangles[i].a.x;
            }
            mesh.vertices = newVerticesArray;
            mesh.triangles = newTrianglesArray;
        
            ecb.RemoveComponent(e, typeof(UpdateMeshTag));
        }).Run();
    }```
zenith wyvern
#

Maybe try calling mesh.UpdateRenderBounds

#

Assuming your debug is being called I don't see an error.

#

Oh

#

Change GetComponent().mesh to .sharedMesh

#

@torn kestrel

torn kestrel
#

okay thanks I'll try that!

zenith wyvern
torn kestrel
#

oh sweet had no idea these existed i'll read up on that thanks πŸ˜„

#

So when i call addcomponentobject it takes care of linking automatically to a go it creates?

zenith wyvern
#

AddComponentObject is for adding a "class" component to an entity, AddHybridComponent is for associating a monobehaviour with an entity (that will link your monobehaviour to a hidden gameobject whose position/lifetime is tied to your entity)

torn kestrel
#

Ah great

rare dew
#

Or only use that

#

depending on your usecase

pliant pike
#

yeah that's why I'm not, I'm using the direct float value

#

it's just there seems to be lots of tutorials and examples using .performed or .cancelled when I don't think its always a good idea

acoustic spire
#

How do you refactor static methods with a lot of arguments used in jobs? You can't use non-static methods nor structs with ref/in keywords.

zenith wyvern
#

Put all the arguments into a struct

#

Not sure what you mean about not being able to use ref, I'm not aware of any restriction on that

acoustic spire
zenith wyvern
#

I don't even think you can do that can you. Ref implies it's already assigned before you pass it in

#

And no it wouldn't be a copy. That's what ref means, it's a reference

torn kestrel
#

@zenith wyvern hey, just wanted to say thanks. Finally got to sit down and try the AddHybridComponent. Worked great!

gusty comet
#

in the entity debugger what does it mean when a component on an entity is white instead of green?

light mason
#

Can someone explain to me the purpose of ISystemBase

#

i see a lot of excitement around it but in not sure i understand why

#

i would like to be excited too so please help lol

deft stump
pliant pike
#

yeah I was wondering that, I missed the memo when that came out

#

so is the idea to move all your code ultimately to ISystembase

torn kestrel
#

The dots best practices course on unity learn has some realy great information.... highly recommend checking it out if you havent!

zenith wyvern
#

ISystemBase let's you burst your OnUpdateFunction. Including job scheduling.

#

But it's seriously limited right now so I'm not bothering with it yet myself

acoustic spire
#

How to trigger conversion without changing anything?

granite spoke
#

Hi
I logged a bug for a hybrid renderer issue and posted it in the forum too . not sure if I should have posted it here or not but in case that the response is yes

light mason
#

just wondering if there is a way to set

#

pixels in texture2D using jobs

honest plinth
rare dew
#

Even null coallacing??

deft stump
#

of course not

#

but everything in it (so long as its burstable) can be bursted

karmic basin
granite spoke
granite spoke
# light mason just wondering if there is a way to set

There are methods in Texture2D which give you the NativeArray of colors and you can modify them if the texture is not compressed at runtime, if it is then you need to copy the pixels to a native array and modify and again set them on the texture. Here is a script from one of our project changing object colors using burst which works blazing fast even on mobile
I'll attach the file

#

this gets texture arrays and modifies them with burst

pulsar jay
#

Can anybody help me with this dependency problem:
"ArgumentException: The previously scheduled job SpeedModifierSystem:<>c__DisplayClass_OnUpdate_LambdaJob0 writes to the Unity.Entities.EntityCommandBuffer <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.ecb. You must call JobHandle.Complete() on the job SpeedModifierSystem:<>c__DisplayClass_OnUpdate_LambdaJob0, before you can write to the Unity.Entities.EntityCommandBuffer safely."

#

I am using AddJobHandleForProducer everywhere I use this command buffer

rare dew
#

Have you called the JobHandle.Complete() as the error tells you to?

rare dew
#

@pulsar jay can you share your code this happens in?

ebon narwhal
#

Guys is it a good practice to instantiate new entities from Systems? and if that is the case how would be a preferable way to inject thje mesh into the struct that inherits from ISystemBase ?

coarse turtle
amber flicker
#

Also.. has anyone noticed much in the way of gains with ISBs (for those who have dabbled)? I've been getting pretty mixed results.

coarse turtle
#

Most of my stuff with ISBs have been negligible too, but I guess my scale isn't really large for it to be better πŸ˜…

amber flicker
#

arguably you see the best gains for when you're processing hardly any entities? Had a weird one yesterday where the thread timings were much more consistent but the total job time was slightly longer than the exact same code as a SB.

ebon narwhal
#

is there any easy way to get a component data inside an ISystemBase system ?

north bay
north bay
amber flicker
#

yea definitely gotta be good for multiple runs of a system you'd think

ebon narwhal
#

Has anyone experienced his entities not rendering if they are not fully inside the camera's frustrum ?

#

view

zenith wyvern
#

Any time that's happened to me it's because I was manually changing my mesh without setting the RenderBounds component to match the new bounds of my mesh

ebon narwhal
#

hmmmm

gusty comet
#

in the entity debugger what does it mean when a component on an entity is white instead of green?

#

Also is there a way to control update order of systems?

ocean tundra
#

@gusty comet yup, UpdateBefore(typeof(System))

#

and UpdateAfter

pulsar jay
#

@rare dew thx I got it sorted out. It wasnt clear to me that I had to use AddJobHandleForProducer everywhere I use any command buffer. Thought the dependency management would manage that automatically. Adding it to every system that uses ecbs fixed the problem

ocean tundra
#

@gusty comet you can also use/create SystemGroups but its a bit harder to order groups

gusty comet
#

@ocean tundra Awesome thank you!

#

Hmm did they update ecs package? Launched unity and now my systems OnUpdate are not being called at all xd

ocean tundra
#

dosnt matter if they released a update, did you update?

gusty comet
#

Nah

#

Not sure if package manager auto updates xd

ocean tundra
#

it dosnt

#

would be a very very bad idea if it did

gusty comet
#

Ah found the issue

#

how tf does unity make it so onupdate only triggers if there is an entity being used by the system created lmao

ocean tundra
#

its part of the code gen

#

your Entities.Foreach will create a EntityQuery (same as calling CreateEntityQuery)

#

and then the system will tie that into its onupdate calls

gusty comet
#

oh, I didn't even realize ecs did codegen

ocean tundra
#

πŸ˜›

gusty comet
#

they do a pretty good job of hiding it

ocean tundra
#

to always update add [AllwaysUpdate] or something like that to the system

#

theres a way to see it somewhere, not at my pc. I think its in the DOTs menu somewhere

gusty comet
#

Found it

#

so is there a way I can incriment a value in one parralel job and read it in another?

#

I tried using Interlocked.Incriment but the value is always 0

zenith wyvern
#

Put the value in a component or a native container that gets passed to each job

gusty comet
#

@zenith wyvern there isn't any way to just let the value be a variable in the system itself?

zenith wyvern
#

There's NativeReference for single values

gusty comet
#

I just need to add 1 to a number each time something happens inside of a parralel job

zenith wyvern
#

Yes, it can be a variable in the system but the only way to get output from a job is v=with a native container

gusty comet
#

What do you mean?

zenith wyvern
#
var val = new NativeReference<int>(Allocator.TempJob);
Job.WithCode(()=>{ val.Value = 10 }).Schedule().Complete();
Debug.Log(val.Value); // Prints 10
#

Just don't forget to dispose it after

#

You can make it persistent and create in OnCreate if it's long-lived

gusty comet
#

awesome

#

thank you!

karmic basin
#

This part is documented on the manual if you wanna check

pliant pike
#

does NativeQueue not work with burst?

#

Burst error BC1042: The managed class type Unity.Collections.NativeQueueBlockPoolData*is not supported. Loading from a non-readonly static fieldUnity.Collections.NativeQueueBlockPool.pData is not supported

#

I'm getting that as an error

zenith wyvern
#

It works but you can't create it inside burst. You need to create it on the main thread and pass it in

pliant pike
#

I see, thanks sark

honest plinth
pulsar jay
#

I just wondered: How does ecs handle components on children of prefabs? As the prefab tag is disabling all of the entities components how can it do that for the prefabs children? As far as I know there is no WithNoneInParents<Prefab> kind of thing?

amber flicker
#

I think the tag is just added to all the children? Though I might be wrong

pulsar jay
#

πŸ€¦β€β™‚οΈ oh yes that correct

#

so the code adding/removeing the prefab/disabled tags has the "overhead" of doing it on all linked entities I guess

amber flicker
#

yup

ebon narwhal
#

Hello there i am still bugged with this issue of objects not rendered if some propoprtion of them have not entered the camera view.

#

I tried to find if there is any information on the documentation but no lack :/

ebon narwhal
#

omigosh

#

found the issue. It had to do with the AABB that i had to manually create.

acoustic spire
pliant pike
acoustic spire
pliant pike
#

that looks like a buffer πŸ˜• I didn't know you could use componentdata like that

acoustic spire
coarse turtle
#

Does it compile in Unity or do you get the same error?

#

Im thinking it might just be an issue with VSCode πŸ€”

#

Might be worth regenerating the csproj files

gusty comet
#

can I create a command buffer once in OnCreate or do I have to call
barrier.CreateCommandBuffer().AsParallelWriter();

in OnUpdate

sand prawn
#

@gusty comet Grab the command buffer system in OnCreate and create a new buffer instance in OnUpdate before any queries, basically

acoustic spire
gusty comet
#

Alright thanks wasn't sure if I had to do it. Thanks @sand prawn

coarse turtle
#

@acoustic spire oh this was ComponentSystem - the QueryBuilder doesn't support in parameters.

acoustic spire
#

Is System.OnUpdate without jobs and burst somehow faster than MonoBehavior.Update? What kind of optimizations remains when we work with managed components in systems? AFAIU we still have to query entities and that's anyway slower than accessing needed object by reference in MonoBehavior

amber flicker
karmic basin
#

Thanks for sharing

zenith wyvern
#

Oo I've never seen that, shiny

zenith wyvern
#
Currently the best way to express this dependency between a scheduled job and a main thread job that must run after it is to use a sync point to ensure that the scheduled job has completed. In this example, the systems are using EndSimulationEntityCommandBufferSystem. 

Hmm, maybe it would throw a dependency error from trying to access the component on the main thread after a scheduled job accesses it, but adding the command buffer dependency resolves it?

rancid geode
#

it doesn't seem to be doing anything really, AIState is already defined as "in" in the query below which ensures that at the time that the job below runs the job above will be completed before hand

zenith wyvern
#

That's what I figured

#

I'll ask in the thread, maybe they know something I don't

pulsar jay
#

Is my assumption correct that all game logic that depends on positions has to run after TransformSystemGroup? Otherwise instantiation seems to be really problematic as all logic will run with the instances being at position 0,0,0

robust scaffold
#

Oh wow, a best practice guide from Unity themselves. Would've saved me months of fumbling around in the dark back when I first started. Lets see what I'm doing now that's actually bad practice.

#

Hm, I'm surprised they dont mention the use of FixedLists. In various tests, FixedListX is nearly 10x faster in accessing, iteration, and modification than a DynamicBuffer. I recommend that all lists that can be made into a fixed list do so since the performance is that much better.

zenith wyvern
#

For iteration you can use Reinterpret<whatever>().AsNativeArray() and it should remove any cost related to safety checks from the buffer

robust scaffold
#

Same problem with native arrays inside bursted jobs. Much better to use a fixed list rather than NativeArrays or other dynamically allocated memory structures.

zenith wyvern
#

For my pathfinding library I originally used FixedLists for neighbours. After profiling I found NativeLists were almost identical, and a lot more flexible, at least for that use case

robust scaffold
#

Other stuff in this guide seems fairly logical and what I discovered over time. Dont use persistant allocation, dont use shared component data, readonly everything, and so on.

#

Hm, really?

zenith wyvern
#

As long as you re-use the lists as much as possible

robust scaffold
#

For pathfinding, I've gone from DOTS to compute shaders and flow fields, or at least attempting to. How is your pathfinding performance?

zenith wyvern
#

Very fast on small maps. I wrote performance tests where it paths across an empty map, it started to slow down a ton at 500x500 maps

#

But I'm not doing any parallelization in the pathinding itself, I just do it per agent and let unity do it for me with schedulparallel