#archived-dots

1 messages · Page 193 of 1

last lintel
#

What part of the program is that?

dry dune
#

Hi
I have a tree like entities structure using LinkedEntityGroup

A 
+ B
+ C 
  + D
  + E

and when i'm cloning A entity using instantiate i've found that it doesn't properly clones whole tree, only 1 level
so entities D and E aren't cloned

do you know a way to clone whole tree?

safe lintel
#

are D & E on a linked entity group on C? and A only contains B & C?

deft stump
safe lintel
#

anyone used IJobEntityBatch successfully? I keep getting nullreferences when accessing my batches in Execute(ArchetypeChunk batchInChunk)

safe lintel
#

hmm just to amend that, the problems are with IJobEntityBatchWithIndex but I dont get errors with IJobEntityBatch

sullen dagger
#

unity offers 3d animation for DOTS/ECS yet?

untold night
mighty remnant
#

I want to calculate the size of a sphere in Screenspace. If possible i would like to do it in a scheduled job. The question is, can i somehow access the maincamera from within it to use WorldToScreenPoint ? from within a systembase class.

north bay
#

You can create your own WorldToScreenPoint method and sample the camera data before you schedule your job

mild ledge
#

ok I actually got confused already and I just started. [GenerateAuthoringComponent] is supposed to generate the class that I can slap on a gameObject and it gets converted to a entity right ?

#

Im using it in this

#
{
    public float MoveSpeed;
}
#

but nothing is being generated. Do I still need to write the Authoring component myself or what ?

mighty remnant
#

@north bay ah nice. thanks.

mild ledge
#

so [GenerateAuthoringComponent] just straight up does not work for ISharedComponent data or what ?

deft stump
#

for IShared and the rest, you have to make your own authoring component

mild ledge
#

can you explain the reasoning behind this? It seems strange

next latch
#

Am i correct in understanding that neither unity physics or havok physics (for dots) have a breakable joint?

#

Aka breaks when enough force is applied

mighty remnant
#

@north bay any chance you know what temp.w represents? 🙂

#

@north bay or alternative. a function for screenToWorldPoint ^^

north bay
#

Ehhh

#

I got the method from some Unity answer thing and changed it to work with the new math lib.

#

Let me see if I can find it

mighty remnant
#

@north bay thanks. will take a look 🙂

late marsh
#

Hey folks, I'm trying to create an entity using Instantiate on an entity created from a gameobject using the conversion workflow. It works fine unless I add a PhysicsShape component to the game object, at which point using Instantiate throws InvalidOperationException: The BlobAssetReference is not valid. Likely it has already been unloaded or released.

#

Any ideas what I'm doing wrong?

amber flicker
late marsh
#

I just tried getting rid of the PhysicsShape and instead adding the PhysicsCollider after creating the entity and that works.

amber flicker
#

Also.. I supposedly have a converted (entities) urp skinned mesh but if I e.g. rotate an entity, it doesn't update the mesh... I have I believe a correct shader so I assume I'm missing some kind of update step or something that dots animation does? Anyone looked into this at all?

next latch
#

Is there a way to create a joint in ecs from a system? CreateJointEntity() seems to require a monobehaviour as the first parameter

crystal helm
#

how i can find out which job causes this waiting? iam playing cluedo since 3 days >.<

hollow sorrel
#

check timeline view to see what job it's waiting for

safe lintel
#

@dry dune guessing thats the reason, probably wasnt designed with nested linkedentitygroups in mind? might be able to check out the source and implement your own system

safe lintel
#

i think i used the hdrp version though? cant remember

amber flicker
#

I did actually find smth on the samples repo with around 2500 basic animated characters on urp I think. Still wondering how I can get skinned mesh working/animating without the animation package though.

safe lintel
#

you mean the other gpu instancing anim repo by joachim?

safe lintel
#

ah. i think what influences the end performance is the complexity of the model + bones in combination with how complex the graph is. he sent a link to that model(its free on the asset store) and i think hes just using an nmixer. i did plug that model into the stresstest scene and you get far better fps numbers with the same number of animated characters

solar ocean
#

Nice

safe lintel
#

i think that the CreateJoint job is the most performance heavy part of this test, at 512 characters my system(8700k) chokes

#

im hoping that there are performance improvements to physics later down the line but i really have no idea what to expect if this is like as good as it gets or if it can be improved

#

i also dont really know how mecanim+physx can compare for numbers, too lazy to do a test

#

also cant test in a build atm, animation needs subscenes to work in any build and uitoolkit has bugs preventing subscenes from working 😩

warm panther
#

What the hell is this (assertion failure in entity conversion... no idea what causes it)

safe lintel
#

you arent trying to use the serializeworld stuff?

warm panther
#

No.

#

It's some kind of problem that occurs in a Subscene all by its own.

#

I'm now "binary searching" by enabling and disabling all the objects in it to see what it might be.

safe lintel
#

also @amber flicker using mecanim with dots is fairly simple, might be able to answer some questions if you have any. all of my current project works well enough with it(though I want to rid myself of it for simpler destroy/instantiate reasons), if thats what you meant by using skinnedmeshes without the animation package

amber flicker
warm panther
#

What causes scenesections to be created?

#

I don't do it deliberately

#

But it seems to crash internally while creating some in a subscene.

next latch
#

How can i change a colliders motion type from kinematic to dynamic in code?

safe lintel
#

kinematic bodies have 0 inversemass(i think it means its interpreted as infinite mass) and dont have a PhysicsDamping component

mighty remnant
#

what is WorldToLocal? Just the inverse of LocalToWorld?

viral comet
#

Hi guys! Is there a way to display the API documentation in Visual Studio for the Entities package?

#

I see it in the source. By not in the package. It's anoying

#

I'm sure there is a way to turn it on 🙂

visual juniper
#

Edit > preferences > External Tools > generate .csproj files for : (and then you decide for what, toggle the top 3)

fading nest
#

Hey folks,
Does anyone have experience dealing with rotations in DOTS? Do I just have to learn to deal with quaternions, or is there a way to use euler angles? I want a system which rotates an object to a specific orientation when a certain condition is met but idk how to do that with quaternions.

hollow scroll
#

@fading nest you can use the EulerRotation component

#

I think that's how it's called

fading nest
#

ahh thank you

#

feel slightly stupid for not finding it but thanks 😅

hollow scroll
#

na, things are constantly changing a lot, it's not always easy to find the docs

warm panther
#

Singleton Entity Architecture Question... I have a TagUIFocus, if it's on an entity that's TagPlayer, that's the "center" of the player's control (keyboard input goes there, camera looks at that entity's CameraTargets buffer, etc.)

I want that entity in a lot of systems and Behaviours, many of them Debug or - more relevant - UI.

There will only ever be one of these.

How do I make this Singleton available to ~20 classes? My current approach is a system, itself a singleton, that exposes that data to static variables. Or... entityquery.toentityarray()[0]

How do I nicely deal with the case when that entity is destroyed, or Entity.Null?

I don't know if and how a SingletonEntity/Component would solve this.

I am considering letting those 20 classes subscribe to an event channel (any given messagebus implementation, I have one), that the ExposePlayerState system then pumps when there's an update.

safe lintel
#

Look up the transform system in the entities docs. It gives a thorough breakdown of all combinations @fading nest

hollow sorrel
#

@warm panther i've been using singleton entities for this, seems to be easiest

warm panther
#

@hollow sorrel But I need an entityquery for that.

#

@hollow sorrel And does that entity belong to that query alone? And... can I make my player entity the singleton entity? No, right? I have to set some singleton ICD on it.

This is exactly why I ask, it seems to me as super tedious instead, so there's something I am not seeing perhaps.

hollow sorrel
#

you can just use GetSingleton<TagUIFocus>(); and SetSingleton, it's built into systembase

#

not sure if it lets you set other entities as the singleton entity, but instead i'd prob have a Entity target; field in there and never change the singleton entity

thorn flame
#

Anyone here using pure ECS on a project with a planned release?

warm panther
hollow sorrel
#

ah

#

well i still use it that way but i kinda cheat

#

i just GetSystem (can cache this) the system that's in charge of the singleton entity (e.g. creating it on startup), then .GetSingleton on that system

#

from monobehaviours

warm panther
#

That's one option I considered.

#

thanks for your input. 🙂

plush meadow
#

Hey I'm pretty new to this new DOTS thing and i'm experimenting around for now. Currently I want to manage a variable (namely, increase it every update) that multiple system would use, what would be the easiest way to go about it? Of course I could use a monobehaviour but I thought that would kind of defeat the point since i'm learning DOTS right now

thorn flame
#

I'm not on the DOTS team so, take this with a grain of salt but I'd say if multiple systems need to read or write data, that data should be a component.

plush meadow
#

i don't exactly want all my entities to include that component

thorn flame
#

What data is this? I can't think of any data that would be shared across every entity?

plush meadow
#

it's just one number that used in multiple places, having multiple entities include it and then process it every entities that include it seems like a waste

thorn flame
#

Thing is, if you want to use it in systems that are run on every entity then it doesn't make a huge difference, aside from memory usage

#

The processing shouldn't be much different?

plush meadow
#

okay what i'm precisely making is a timer, other system update entities based on this timer value

thorn flame
#

Aaaaah, I gotcha

plush meadow
#

i could use time.time, but then i'd have to subtract it from the time value at the start of the process to get the actual time value i want, if i go this route i'd want this value to be computed in once place only once per update then multiple system read it, so my problem is still the same

thorn flame
#

any reason why you can't just use deltatime tho?

plush meadow
#

i can just have every system does that operation, that probably won't make a huge different in performancebut still, that can't be the right way right?

zenith wyvern
#

But all you need is the start time

#

You can calculate elapsed from that everywhere else

thorn flame
#

No you're right, you don't want to repeat operations in every system

plush meadow
#

so what i'm asking is where should i put that operation, if i'm not using monobehaviour

zenith wyvern
#

In a component, like everything else. Then if you want to add a timer to an entity you just add the component and include it in your queries

thorn flame
#

Problem is, I'm pretty sure they want this timer to be global.

#

Putting it in a component will duplicate the data

#

and create boilerplate. Not great.

plush meadow
#

exactly

zenith wyvern
#

In that case you can use a single entity with your timer, and do GetSingletonEntity<Timer>() before your job, pass it in, and get your timer with GetComponent<Timer>(timerEntity)

thorn flame
#

That seems like a better idea.

plush meadow
#

ah i see

thorn flame
#

That way you dont end up with 4 * n memory usage lol

zenith wyvern
#

Just keep in mind GetComponent can be expensive if you're doing it a lot

thorn flame
#

My only concern at that point is the processing time of fetching an entity but 🤷

#

You could also just extend Time with the data/function you need and call that

#

Thats kind of what extension methods are for in the first place

vague cargo
#

anyone know how to iterate other list inside the IJobParrelleFortransform job?

thorn flame
plush meadow
#

i'll look into that as well

thorn flame
#

Just make a CalculateTimer method and a Timer property

plush meadow
#

i can always go back to monobehaviour if i want to but it's nice to know how you'd do it in pure ECS

thorn flame
#

Calculate it once in an update somewhere and then just Time.Timer

plush meadow
#

thanks for the help @thorn flame and @zenith wyvern

thorn flame
#

Pure ECS doesn't mean you do everything in systems. That's not a great idea imo. Pure ECS just means you don't use traditional game objects

zenith wyvern
thorn flame
#

Monobehaviors are still very useful for things that don't fit into what a system should be

deft stump
#

^. such as UI (for now)

plush meadow
#

ah i see, didn't make that distinction before

thorn flame
#

Systems are for things that utilize or manipulate components, components are for data that represent and define entities. Don't try to make everything into ECS, you're gonna have a bad time

zenith wyvern
#

I don't think the term "pure ecs" should even be used anymore, it just confuses people into thinking the conversion system will slow down their game or something

thorn flame
#

For example, does your system HAVE to run all the time? Is it mandatory for the game to function? If so, its probably not a system.

deft stump
#

it's only kinda slow on startup. but that's going to be the same even if you code your entities by hand.

zenith wyvern
#

If you're using subscenes it won't have any effect on your startup at all

vague cargo
#

i did this last time and got me error

zenith wyvern
#

Mmm, the "Count" there makes it seem like you're using a managed list?

#

You can't used managed objects in burst or jobs

#

You have to use a NativeList/NativeArray/Some other native container

vague cargo
#

no , just a sample to show , im using NativeList

zenith wyvern
#

Then yeah, it should be fine as long as you add [ReadOnly] to the otherList in your job struct

vague cargo
#

noted! thx amigo

#

☺️

stone osprey
#

Still playing around with different buff approaches... My player looks like this : Player{ BaseDamage, Damage, BaseHealth, Health, Inventory} and the item he wears is an entity that looks like this Item{ BuffDamage... other stuff }... i actually want to transfer the BuffDamage of the item to the player's Damage so that he deals more damage. But thats kinda tricky in an pure ECS environment. So i thought about a buff entity : When we equip an item, it spawns its buff entities. Those buff entities are getting processed by an buffsystem that simply runs logic for each buff to apply it on its owner. This way we can add conditions to the buff or timers. Is this the most common solution for this problem ?

#

Im in fear that i create too many "entity archetypes"... Probably a buff shouldnt be an entity, but its much more flexible if it is

gleaming plank
#

Buffs as entities would be my go-to if I were implementing a stat modifier system.

I wouldn't be concerned about the number of archetypes. I can't imagine it takes a large number of different components to cover all the buffs. You won't need to add/remove components, so you'll only incur 1 cache miss per archetype when you're iterating. That's nothing, but when in doubt, profile.

stone osprey
#

@gleaming plank Thanks a lot ! I quickly made some sort of test system and it seems to work 🙂 But theres still one problem left... This case here included buffs that are applied forever or over a duration. Like more life, more speed, more base attack damage. But how should we deal with buffs that deal more damage to a certain entity type ? For example a holy sword that deals 50% extra damage to zombies ? Would we realize this with buffs too ? And if yes, how would that look like when our buff is its own entity ?

warped coral
#

do you guys recommend using ecs? is it still going through a bunch of API changes and stuff?

stiff skiff
#

Depends, and Yes

gleaming plank
safe lintel
#

@warped coral if you want to learn ecs, now is as good a time as any. the api for Entities is relatively stable as far as change churn, but its the surrounding ecosystem that is undergoing significant work. if you want to make a game, well then the advise would be to steer clear for now. you can use Jobs and Burst without using ecs.

stone osprey
#

But probably there are other ways to tie in some sort of combat modifiers

gleaming plank
#

You can recalculate the stats when buffs are created or destroyed. I'd either modify the Stats component directly or have another component of the same structure that just has the amount to add on top and modify that (one way or the other you need to be able to reset to the base stats).

stone osprey
#

@gleaming plank No i mean... Lets say we equip a sword and a damage buff of 10 is added to the player... But the weapon should deal +50% damage when its an ice golem that gets hit. The damage buff is already applied ( +10 ) due to wearing the weapon. But we dont permantly add the +50% to his stats, because those should only be applied when he is attacking a mob... So there needs some sort of check... Thats the hard part

gleaming plank
#

I mean, you could do it how I described, as contrived as it sounds. Stats.WayTooSpecificIceGolemBonus.
If you want modifiers that granular, you'll have to bite some bullet.

A different thing you could do is have a dynamic buffer on all player entities that contains all the Entity IDs of their buffs. Create intermediary "AttackEvent" entities (EntityA attacks EntityB) somewhere else. Then, in your damage system, pass in all buff arrays and the array of dynamic buffers and iterate the AttackEvents, resolving each attack event with random accesses into those arrays.

stone osprey
#

@gleaming plank The last idea is actually an life saver... Firing an attack event that mentions the attacker, defender, then another system could check for some of the buffs to increase the attack damage and then... One frame later it gets applied, thanks !

sharp stump
#

Does anyone know of a tutorial or some kind of expert on the ECS mesh/rendering/shader/etc paradigm? It seems like everything I run into talking about how to actually import mesh assets to an ECS project is through GameObject conversion

#

seems restrictive, and I feel like the RenderMesh and related components are not totally well documented, or is it that there are legitimate code limitations with these parts of the ECS components

#

?????

zenith wyvern
#

Rendermesh is horrible if you need to frequently change/update your meshes at runtime. They haven't optimised it at all for thelat scenario yet. Plus it seems to be particularly buggy in this version.

sharp stump
#

I just want to know how I am supposed to update that field. I tried setting the mesh field on the RenderMesh component but it kept on saying I was mixing types or trying to use a monobehaviour method or something

#

It complained that basically I was trying to use the mesh field as a Mesh type I think

#

I wasn't, and it didn't work.

#

How are we supposed to make a game with ECS if we don't even have a straightforward method of importing assets

zenith wyvern
#

Show the code and the actual error

sharp stump
#

I killed that project, sorry

#

I could try to recreate it

#

probably a me thing, but I read the docs all over trying to figure out what to do and it seemed impossible

#

or at least not straight forward

zenith wyvern
#

ECS is still in early days. They don't expect people to be able to easily make complete games with it while it's still in early stages.

sharp stump
#

true, and I am thankful I am here early for it

zenith wyvern
#

There's going to be roadblocks and lots of undocumented issues, I would not mess with it if you're not ready for that

sharp stump
#

I have cool ideas like everyone else and I can't wait to see peoples projects come together

#

I am very ready for it actually.

#

I am critical because my profession is Technical Writing

zenith wyvern
#

I doubt you'll find anyone here that doesn't wish they had better documentation

sharp stump
#

I also have been doing nothing but programming all last year because of COVID so I have been hanging out in TOOONS of doc sets 😄

#

I wish I could help them. I think I have some ideas on how, but that would be like having a second job. LoL

#

I saw there was some sort of community docs page somewhere but I can't find it

thorn flame
zenith wyvern
#

There's a community wiki link in the pinned messages. I can't vouch for it though, seemed a bit odd when I last looked at it. Personally I stick with the github samples and official manual for learning purposes.

#

If you have a specific issue or error you encounter though you can just ask here and usually someone will help if they can

sharp stump
#

@thorn flame Okay, cool. Sorry for asking. UnityChanSorry 😦

thorn flame
#

Oh, no, I didn't mean it like that 😂 Asking questions is good

#

I'm just telling you what you should expect going into DOTS.

safe lintel
#

feel free to edit that community wiki, im too lazy but i removed one of the more egregious edits someone made to it

#

im genuinely curious how meshes will be treated once sharedcomponent is made blittable, and what the dots/ecs friendly approach for editing meshes during runtime would be

amber flicker
vagrant lotus
#

how do i generate a physicsCollider by turning a Convex Collider into a Physics.Collider ?
the Mesh is generated in runtime
this is in full dots

hollow sorrel
#

@vagrant lotus you mean you are generating a mesh, then generating a physx convex collider for it, then want to convert that into physics.collider?

#

if it really is about conversion between physx then you should prob check out LegacyColliderConversionSystem in physics package to see how unity does it

#

also either channel is fine but i guess you'd prob get more answers here if it's about dots physics

vagrant lotus
#

no, i was referring to the Struct ConvexCollider in inity.physics

#

thanks for the response

hollow sorrel
#

ah i misunderstood

#

unity just seems to cast Collider* to *ConvexCollider* if the collidertype is set to convex so i'm guessing that ConvexCollider already is a Physics.Collider

#

just implicitly

fading nest
#

Suppose I have a component, and I want to know its entity, is there a way to do that? And is it advisable?

For context I have a system which, when checks a bunch of 'wires' to see which are connected to which, then 'electrifies' any connected to the source wire.

The way I try to do this is with a recursive function which for a given wire, IF it isn't already electrified, electrifies itself, then electrifies all the wires connected to it

#

However if I get wires with a ComponentDataFromEntity query then I can't update them

#

(whilst in the same job)

coarse turtle
#

well a safe alternative is to queue the connected wires via a CommandBuffer when you recurse through the children wires

// Some pseudocode
SomeRecurseFunction(...) {
  for child in children {
    EntityCommandBuffer.SetComponent(child, new Electrified { ... });
    SomeRecurseFunction(...);
  }
}
fading nest
#

I suppose an answer might be to get the entire graph locally without using recursion and just electrify everything I reach in one swoop

fading nest
coarse turtle
#

There is also GetComponentDataFromEntity<T>(false) where false allows you to write the value (has some caveats since you will need to ensure there's data write safely)

fading nest
fading nest
#

but I think it's probably nicer to to just collect a set of entities and set them all to electrified: nonetheless this is useful stuff to know so thanks very much 🙂

coarse turtle
#

yeah I can see your point, collecting unique elements for an update sounds reasonable. Another thought if you want to go through the command buffer route and scheduling them for later is to recurse and keep a state within a hashmap so you can check whether or not a connection has been "visited/updated"

fading nest
#

yeah that makes sense

#

Thanks

low tangle
#

There is some stuff for graph traversal in data flow graph that animation and audio use. But personally I like to keep the game logic simple, I'd use a job to collect all your elements into native arrays and a single job to traverse and update their entities with a entity comand buffer.

#

Performance wise it's fine up to several thousands so that might meet your needs and be totally simple

fading nest
#

oh yeah my game will not be computationally expensive: mainly using DOTS for experience and the code being nice

odd ridge
#

what ui tools do you use for to accompany dots?

low tangle
#

I use the last version of ui elements that works with 2019.4 though a monobehaviour bridge

#

Which is replacing a old unity ui setup of the same

coarse turtle
#

dear imgui bindings for c#/unity mainly (it uses MonoBehaviours for a setup so I pretty much just bridge it over like @low tangle)

deft stump
low tangle
#

Ui is both a graph traversal and a event system problem. Right now those are both tricky to do in unity ecs

#

Ecs and data oriented design are really enjoyable

#

Eventually unity is working on a direct bridge to the cpp runtime of ui elements/toolkit

#

Keep forgetting the name change

deft stump
odd ridge
#

I'm trying to learn the UI elements right now, it seems broken (text not scaling properly, text disapearing, button has wrong offset until I reset my scene)

deft stump
#

now I'm just waiting for DOTS UI, if there will be

odd ridge
#

doesn't seem to work with the pixel perfect camera either

low tangle
#

Hm you could always overlay the ui using a second camera for it

odd ridge
#

I need UI but I don't want to touch UGUI if it's gonna be removed from unity anyway

fading nest
low tangle
#

Ui layer, mask it out of main pixel, only layer on ui camera

#

Your making a game now

#

Not on unity of tomorrow with everything changed

#

If the tool is in your version of unity and it will do the job, use it

odd ridge
low tangle
#

native resolution yeah, you can still turn filtering off and keep all the visuals pixel art

warped coral
#

is it possible to do text stuff with dots?

#

is there something like textmeshpro in dots

safe lintel
#

via hybrid or make your own

amber flicker
safe lintel
#

thanks, wondering if im having invalid rotations and not realizing it now

robust scaffold
#

Burst says this with regards with generic types in structs: Burst supports generic types used with structs. Specifically, it supports full instantiation of generic calls for generic types with interface constraints (e.g when a struct with a generic parameter requiring to implement an interface)

Does it allow for something like this?

public struct ElementBuffer<TType> where TType : unmanaged
{
    private readonly TType _element0;
    private readonly TType _element1;
    private readonly TType _element2;
    private readonly TType _element3;
    // Continued later...
}```
#

Well, burst isnt complaining so I assume it works?

proper silo
#

Hello! I feel like I am missing something important about commandBuffer: if in a system I use a commandBuffer to destroy an entity, and in an other system I use another commandBuffer to set a component to the same entity, will there be an error thrown if the Entity is deleted before the component is set? If so how am I supposed to avoid this kind of issue?

robust scaffold
#

will there be an error thrown if the Entity is deleted before the component is set
Yes. Well actually it depends on the order of operations that is being done, or in this case the systems.
If the deletion happens first, then the command buffer will enqueue delete to Entity.Null and then the second system's command buffer will attempt to add something to that entity, resulting in an error. If it's the other way around, it will work, set component data then delete.
You can ensure the second case to happen using [UpdateAfter(typeof(SettingSystem))] on your deleting system. Or [UpdateBefore(typeof(DeletingSystem))] on your setting system.

#

Just stick it on the very top of the system class name:

#

Well, my system StartupEntities updates in InitializationSystemGroup so that tag also is included. Isnt necessary if your system is default system group.

proper silo
#

I see, it makes sense, will try to set it up this way, thanks 🙂

proud tapir
#

I'm just getting started with Unity and would like to know what to learn so that I can make such an explosion (I'm interested in the effect of spreading fog)

stone osprey
deft stump
tight blade
#

2020.1.17f1 or 2020.2.1f1 for dots work?

#

upgrading from 2020.1.6f1 lol. looking forward to catching up

zenith wyvern
#

I'm using 2020.2.1, haven't had any issues

pulsar jay
#

Is there an easy way to add/set material property override on an object and all its children? I am trying to change a material value if an object has a 'Selected' component. But it uses multiple meshes so I have to change the material on all child objects

fading nest
#

Do I initialise it in OnCreate or OnUpdate?

zenith wyvern
zenith wyvern
#

The blue button at the top will take you to the latest version too (if you're on desktop)

scarlet inlet
#

does anyone use Version Defines here?

pseudo plover
#

how may I use mobile inputs on unity DOTS?

amber flicker
scarlet inlet
#

I posted on the forum now, it's about this Unity parameter. It seems to work on 2021 but not on 2020

dull copper
#

@scarlet inlet what is the issue specifically here?

#

if it doesn't work in 2020, it's a bug

scarlet inlet
#

I didn't notice this Unity parameter before, I wonder if it's something new. If it's not it may be a bug yes

frosty siren
#

Is it okey that i can't GetSingletonEntity() in OnCreate()? Unity telling that there is no entity with requested component.

mighty remnant
#

someone knows how the transform system handles the case if a parent has a parent? is it looking recursively to the top to get the localToWorld?

safe lintel
#

afaik no recursive searches, gotta handle it yourself

rancid geode
rancid geode
rancid geode
safe lintel
#

are you sure about that? theres no concept of a root transform in the transformsystem, my understanding is that ltw are updated by nature of the system processing every entity relative to any parent it also references, but as far as recursively updating methods I havent seen any

mighty remnant
#

updating an entity relative to its parent, means that his parent needs to be already updated. but if this parent is a child of a parent, how do you make sure that it is already updated? thats why i think it needs to be a recursive function, but im curious if i overlooked another way.

rancid geode
#

the update is made from the root to its children, recursively, not the other way around, so it only updates once each LocalToWorld in each TransformSystemGroup and only for the entities which had its transform changed (or one of its parent's transform)

#

to ensure that it is already updated, just do something like [UpdateAfter(typeof(TransformSystemGroup))] and you are good to go

#

be it a root, a child of a root, a child of a child of a root.....

rancid geode
safe lintel
#

in the context of when dealing with an entity that is a part of a hierarchy, there isnt a builtin way to just access "root" though

mighty remnant
#

i think i got it. i though [TRSToLocalToWorldSystem] is a system group. but its just a system. then it makes sense with a recursive function from top to bottom.

warped coral
#

whats the difference between the entitymanager methods ```AddChunkComponentData<T>(Entity)
AddComponent<T>(Entity)
AddComponentData<T>(Entity, T)
AddComponentObject(Entity, Object)

safe lintel
warped coral
#

oh ok thanks

rancid geode
slim nebula
#

how do I get subscenes working in a build? it seems to be looking for a file in "StreamingAssets/SubScenes" but that SubScenes folder isn't there. I've added Platforms.Windows. Is there some other step I need?

warped coral
#

whats the proper way to reference entities in ECS? so like... if you have a container full of items

slim nebula
#

you could have a buffer on your container entity. each element in the buffer would point to an item entity

#

apparantly I need this for subscenes? I dont get it

robust scaffold
slim nebula
#

how do I use it tho @robust scaffold ? I double click it and it asks me what to open it with. how do I make a build with it

robust scaffold
#

I'm not using Hybrid so I dont have anything in the list.

slim nebula
#

i mean

robust scaffold
#

But if you are, you should see Win64.Build and so on in one

slim nebula
robust scaffold
#

Yep

slim nebula
#

I dunno what I"m supposed to see here

#

how do I add my new file to this window?

robust scaffold
#

Click on it. It should move your file manager to a folder in the packages list.

#

Copy paste that into Assets or any folder you want.

#

Then, once it's in Assets or a subfolder, double click

slim nebula
#

it's there

#

double clicking brings up windows asking me what to open it with

robust scaffold
#

Is that just a text file?

#

No, you need to copy the build manager's version.

slim nebula
#

if I click the one in the build manager and double click it, same thing

robust scaffold
#

Hrm. Right, let me start up a new project so I can illustrate what I'm trying to do.

#

Yea copy that fourth asset

slim nebula
#

that's what it gives me when I double click the existing asset

#

or the asset I put in

#

same dialog

robust scaffold
#

Give me a min, Unity's spinning up a new project.

slim nebula
#

I'm guessing I'm missing some package that has the UI editor for this file type

#

but I dunno what it is

robust scaffold
#

Nah, Hybrid Renderer is enough

#

Also in that time, make sure you add unity.com.platforms.windows

#

to packages list

slim nebula
#

I did. i got that

robust scaffold
#

Good.

slim nebula
#

ooo i havnt restarted unity since tho

#

lemme do that

#

editor shit sometimes needs that I forgot

#

ok now things are happening

robust scaffold
#

Oh, good. Make sure you build using the buildconfig... Oh.

#

Hrm.

slim nebula
#

should I need this one I linked? or is the default one good?

robust scaffold
#

No, you need to check off one box and you cant do that on the default one.

#

It's the "add all open scenes" box.

slim nebula
#

face palm

#

one sec

robust scaffold
#

Otherwise, nothing will actually be built. So you need to copy the configuration and be able to edit it.

slim nebula
#

ok I can edit it now. do I add my subscenes in here somehow?

robust scaffold
#

Inside the editor with inspector?

slim nebula
#

i dunno. anywhere?

#

do I just run this empty thing and it'll work now?

#

I dunno

#

how do I run it

#

:S I'm sorry I'm so confused haha

robust scaffold
#

Haha, no problem. I'm trying to get my packages in order as well.

slim nebula
#

so I selected mine I guess

robust scaffold
#

I actually have no clue what the build manager window itself does.

slim nebula
#

if I do file->build, does it just use this now somehow? or do I start it differently?

robust scaffold
#

I dont recommend touching it. Nah, not from file -> build.

slim nebula
#

how then?

robust scaffold
#

Do you not see this in the inspector?

slim nebula
#

yeah

#

i do

robust scaffold
#

Gooooood

#

You see the second tab, Scene list?

#

Check "Build current scene".

slim nebula
#

ok

robust scaffold
#

Make sure the current scene is selected in the hierarchy.

#

Then you see the button on the top right of the inspector? "Build and Run".

#

Click that. That's how you build, and run.

#

If you dont want running, just click the arrow and select Build.

#

You can also customize the build like in the File -> Build. Like Scripting Backend for Mono or IL2CPP and that's pretty much the most important one.

slim nebula
#

ohhh awesome

#

looks like it's building

#

hopefully my subscene is there this time XD

robust scaffold
#

Well, you might run into bigger problems, like the subscene not existing in build and such.

#

I had that problem, apparently the new UI system (UI Toolkit) breaks the build with hybrid renderer, so dont use that package with HR.

slim nebula
robust scaffold
#

And it's really sensitive to other packages. If you have a problem with subscenes not existing, remove one package at a time.

#

There ya go.

slim nebula
#

YES

#

it loaded

robust scaffold
#

Congrats, really simple but a lot of unexplained shit.

slim nebula
#

the subscene

#

yeah it's convoluted and not really easy to find

#

thanks so much!

#

ezpz now

robust scaffold
#

No problem. That path took a few hours of googling and debugging back when I started. Hopefully you wasted less time than me.

slim nebula
#

yesssss I think maybe 40 minutes

robust scaffold
#

Anyways, good luck in DOTS. I've got to go. Ask any other question and probably someone else will answer. And the forums are good places to look as well.

slim nebula
#

haha

robust scaffold
#

🙂

slim nebula
#

welll sorry it took me like 3 hours to diagnose the issue

#

but thanks so much 😄

#

ok and how do I disable vsync :S

#

the editor didn't limit me to 60fps. but I want to see the standalone client performance

#

or do I just set QualitySettings.vSyncCount

#

🤞

#

yess it worked

#

it's hitting my 240fps limiter. perfect

warped fog
#

Hey if you folks were going to make a flow field system in ECS, how would you store multiple grids (for multiple destinations)

zenith wyvern
#

Dynamic buffers

warped fog
#

that's what I was thinking too. Groovy

zenith wyvern
#

Flatten your grid to one dimension and stick it in a buffer

warped coral
#

whats the use case for blobs? is it for unique data that can be used by many different archetypes?

#

oh nvm i found some forum thread. so.. it's just like scriptable objects for ecs

#

when to use blob assets and when to use shared component data?

#

like how do they differ

deft stump
#

if you don't want to separate your entities to another chunk based on a ISCD's value then use blob assets. that's the only reason i can think of

low tangle
#

blob assets are for immutable data for job threads to use

#

the analogy of them being scriptable objects for ecs is pretty apt

warped coral
#

so uh.. whats the proper way to reference entities in an entity in ecs? I can't do something like EntityRef : IElementBufferData since like... entity isn't blittable or a valid field type i can use?

#

like how would you have a container entity that holds a bunch of item entities in ecs?

worldly pulsar
#

you can have a component/buffer element with Entity fields

warped coral
#

oh

#

oh right entity is now a struct with just the id. im dumb. thanks

deft stump
#

is there a faster way to copy a list of vector3's to nativearray<float3>?

zenith wyvern
#

Pass it into the constructor

#

And reinterpret

#

var nativeArray = new NativeArray(managedArray, Allocator.Temp).Reinterpret<float3>();

deft stump
#

learn something new everyday

#

wow

raw shadow
#

Any idea when DOTS is supposed to be deterministic?

low tangle
#

current year + 1

#

or year when dots gets 1.0 + 1

#

(its not till after a 1.0 release iirc)

deft stump
#

but when will get 1.0?
in 2 years probably lolololol

safe lintel
#

ah wasnt that supposed to be last year? 😏

deft stump
#

Us : So when will DOTS 1.0 be released again?
Unity DOTS Team : yes

robust scaffold
#

I mean, DOTS is functional on the data handling side. Lots of changes coming up so it's not stable but it is functional.

gleaming plank
#

Burst is deterministic across x86, just not between x86 and ARM, etc. yet AFAIK.

raw shadow
gleaming plank
#

Yeah, then it's not ready. The standard way to handle it is using fixed-point integers. Unity is trying (something novel) to do it with floating-point.

raw shadow
gleaming plank
#

I have no way of knowing this, but I can't imagine very many fighting games rely on a full blown physics engine, maybe just some collision detection.

raw shadow
# gleaming plank I have no way of knowing this, but I can't imagine very many fighting games rely...

https://www.youtube.com/watch?v=FIZMMTBSBFQ
I'm pretty sure this has its won physics engine

Quer 10 reais para usar na steam? Usa o código: 3TWBPL no aplicativo Pic Pay http://www.picpay.com/convite?@3TWBPL

I got some random stuttering when record the gameplay
NARUTO SHIPPUDEN: Ultimate Ninja STORM 2 PC
NARUTO-ナルト- 疾風伝ナルティメットストーム2

I hope you enjoy. If you like, please click on like and subscribe for more gameplay videos.

PC Specs:...

▶ Play video
gleaming plank
#

I mean like rigidbody physics.

#

I assume to get frame-perfect, repeatable actions, you have to fake it.

raw shadow
#

wait what no why would you have to fake it?

gleaming plank
#

Physics engines like PhysX are like "true to life" simulations. Mass, accelerations, forces, etc. Normally this isn't needed or desirable for the cartoony physics most games want.

deft stump
#

most fighting games fake stuff up to be deterministic in the players eyes.
i.e. when a character gets hit with knockback effect.

gleaming plank
#

^ I assume you'd only need collision detection for hitboxes.

deft stump
#

^ yes

raw shadow
#

What do you mean by fake stuff up? those games have, to deterministic to enable replay functionality no?

deft stump
#

what I mean fake stuff up is they don't use physics simulations to determine, i.e, a knockback effect.
tekken7 with their increasing knock back effect per hit when a juggle is performed doesn't use physics simulations to do so.
They have their own formula to do it.

raw shadow
#

I feel like everyone in the GGPO discord server would disagree with you

gleaming plank
#

They'd be wrong.

#

Like when you say "physics" I think you just mean motion. When people developers say "physics engine," they're usually talking about something intended to simulate actual physics, like Newtonian mechanics or whatever goes on in Kerbal Space Program.

If you just want a character to jump like Mario or punch a character precisely 90 pixels across the screen, you should hard code it.

raw shadow
#

Really

gleaming plank
#

lol I'm not sure how to explain the distinction clearly, I mean, in the end neither will be cross-platform determinstic

raw shadow
#

but some of those games are cross platform.....? Street Fighter, Power Rangers Battle 4 The Grid

deft stump
#

imagine this.
3D fighting game. (with actual physics simulations)
both characters have their own idle (breathing) animations.

1st character does dragon punch.
2nd character goes up 20 pixels.
so far so good.

1st character does dragon punch again.
but because it has breathing animation, the punch hits the 2nd character's elbow or some other shit like that.
2nd character goes up 30 pixels.
wtf.

contrived example but that's usually what most, if not all, fighting games are trying to avoid.

raw shadow
gleaming plank
#

No idea. Cross-platform determinism is just a matter of avoiding floating-point numbers. You can probably design a Unity game that uses some external fixed-point C# library for the math.

What we're saying is that Unity's physics means its Rigidbody physics, which obey realistic laws. You have very little control over the motions. To have consistent controls, you need to hard code things.

#

Like a jump would be implemented with the formula for a parabolic motion or an animation curve.

#

Instead of adding a force to an object with mass and having gravity pull it back down.

#

The only relevant piece of the physics engine is collision detection.

raw shadow
#

So would I write my own collision detection then or no?

gleaming plank
#

yes, AFAIK it's necessary to implement hitboxes

#

collision detection and response are still pretty involved, though

#

actually wait

#

I dunno if you're going for a 3D fighter or not. For a 2D fighter, I think could be a simple as checking if rectangles overlap each tick. Like full collision detection involves spatial partitioning to support hundreds/thousands of objects, with support for arbitrary shapes, but you'd only have a handful of rectangles.

raw shadow
#

no its 3d

gleaming plank
#

ah, well

deft stump
raw shadow
#

so we'd have to create hitboxes, hurtboxes and collision without using PhysX?

deft stump
#

yes

raw shadow
#

are there any solutions for this already done by other people?

gleaming plank
#

I'm not sure. Cross-platform play is still pretty new. Photon has a deterministic engine for Unity called Quantum, but it's paid IIRC (the pricing is sort of unclear).

raw shadow
#

Quantum is $1000 USD per month

deft stump
#

ooof

gleaming plank
#

I mean if you just wanted to release a game on multiple platforms, you could just use the built-in stuff. Having PC users play iPhone users and whatnot is a new use case.

raw shadow
#

We want crossplay between console and PC its a fighting game

gleaming plank
#

Hmm, Unity might be deterministic between PC, PS5, and XSX if their CPUs use the normal x86 instruction set (perhaps the previous gen also), but idk.

#

probably a question for the forums

gleaming plank
gilded bay
#

Can someone explain ECS to me? I looked up a few tutorials and it looked like I would essentially be writing my own physics from scratch?

#

Can someone explain dots to me, as if you were explaining it to a 3rd grader

#

Not sure if I've fully wrapped my head around it yet

#

My goal though, is to write physics based multiplayer that supports clientside prediction and reconciliation with controllable first person physics objects.

amber flicker
#

I'll take a stab.
DOTS => basically three technologies. Burst, Jobs & ECS.

Burst -> Given a strict subset of c# can assume things about code that allows it to compile to very optimised native code. It generally provides a lot of perf improvement but at the cost of managed types - e.g. classes

Jobs -> A way of distributing work across cpu cores in a thread-safe way - perf improvements (though not necessarily linear with core count) and comes at the cost of scheduling and all related code somewhat async (vs main thread code) - consequently also at the cost of direct manipulation of Monobehaviours etc

ECS -> The above require a strict subset of c# and ideally many structs, few classes. ECS is often conflated with DOD (Data oriented design) and indeed, it's a completely different paradigm with many pros/cons. One often unmentioned part though is that Unity's ecs is designed around the aforementioned subset, hence working really nicely with Jobs & Burst and is also why it's considered a 'data oriented tech stack'.

gilded bay
#

So one of the limitations with the default unity physics engine is that its pretty awful at rewinding and replaying physics, to use in reconciliation on the client

#

does dots solve this problem in any way?

amber flicker
#

in a way. Unity Physics (DOTS) is stateless - meaning things like rollback it theoretically works great. It also means it's e.g. unstable with stacking - which is where Havok comes in.

#

It's still very much in development. There are a couple of people here attempting a similar thing that should be able to provide more specific comments when they come online.

gilded bay
#

alright

amber flicker
#

there's also the netcode aspect of that problem - I know very little about the state of both except you're in for a rough ride if you pick it up now

gilded bay
#

That's what i'm afraid of

#

I looked at some tutorials and it looked rather complex

#

just for basic things

amber flicker
#

there's an awful lot to learn. Not to mention animation, the conversion workflow, rendering pipelines etc.

#

DOTS let's you do things you simply can't do in traditional Unity. You also can't simply do anything. 🤣

gilded bay
#

Very true

#

So does all of the physics have to be done from scratch?

#

like there's no rigidbody component for it, or anything like that?

amber flicker
#

you can check out the examples - there's editor support and a lot is similar. The devil is in the details - e.g. you have to be very careful when your code runs relative to the physics systems.

gilded bay
#

hmmm

gilded bay
#

So eventually is dots going to be merged with regular unity?

#

Or will they stay separate?

#

And will it become easier to use over time?

deft stump
#

DOTS stack will probably stay as a series packages.

#

which I don't mind but good lord, please add batch install for packages

amber flicker
#

My expectation would be they become integrated with the editor over time, yes. Though you're starting to get to 'what does the future look like?' - some of us here have been pleading for years for an updated roadmap... commitments and deadlines have been repeatedly missed... by years

hollow sorrel
#

damn i missed a good convo

hollow sorrel
#

but yea if you want true cross-architecture as in pc vs mobile vs console you'd either have to wait a long time or roll your own physics with fixed point, which might not be easy but even if you start with 0 knowledge you'd prob finish yours before unity does

#

if it's fine for your game to only be pc vs pc and console vs console (like many games are) then you can still use unity physics for deterministic rollback

#

no idea about mobile tho

raw shadow
#

I do get it now though

hollow sorrel
#

ah yea in that case

#

i'm still waiting for unity's cross platform burst too

#

but they keep pushing it forward and at this point i'm not even sure they are going to pull it off anymore

deft stump
#

just like the promised blogpost

#

when will that happpen unity

low tangle
#

I know fighting games love their deterministic over engineering, but you really just want the basics, which is world state replay as inputs come in from the other clients. That's the core that's most important. After that it's just a matter of verifying your floating point math doesn't diverge on your systems or swapping all simulation math to fixed's. It's the exact same thing RTS's require for only input sync networking.

#

You don't use physics engines for the core simulation state on anything other than full world state sync networking games (think source engine, or unreal, classic mp fps)

#

Dots and ecs are great fits for net code and core simulations driving the game. But it's technical work that your likely not used to with normal unity

warped coral
#

is it a bad choice to make ecs systems to handle behaviours that are oneshot? stuff that doesn't take place over multiple frames? like if you trigger an instant ability that takes effect on the same frame

amber flicker
low tangle
#

yeah, I'd encourage it. people tend to focus on performance so much they overlook useful good patterns like that

#

its not hard to rip up logic after the fact and redo it. as long as you consider your input data as a contract

#

smaller the team, the more aggressive you can refactor your systems. don't be afraid to work in a certain way, your always learning and reworking your mistakes

amber flicker
#

Agree with June though would say I'm also unconvinced that another approach is necessarily faster anyway - depends on so much. In a similar vain to what June's talking about - .Run() is like a really good option for any system usually expecting less than a chunk or two's worth of entities.

warped coral
#

so.. how would the system work? is it ok to leave the update method empty... or... idk? isn't there a better way to do it?

#

i just need it to be like... i have a monobehaviour check the input and find the system to use -> system gets component data on the relevant entity -> system does a single method using the data on the same frame

#

seems wasteful though.. cuz like idk.. i dont need the update method i dont think... but i do need the component data and oneshot method. is it still a good idea to use a system in these cases

#

is it ok to just like.. have a monobehaviour get the entity using the entitymanager and do it

#

or is that bad practice in ecs

pliant pike
#

I don't think there's many bad practices in ECS currently, its all new so do whatever works

warped coral
#

it would be wonky to have like.. a trigger component.. and then a system that requires that component to run, and put the oneshot method in the OnStartRunning method of the system which'll schedule removal of the trigger component right...

pliant pike
#

I don't see why not, if it works it works, just be aware OnStartRunning can seemingly run more than once sometimes

safe lintel
#

just use onupdate, if there arent any matches for entities than the system doesnt run and theres zero overhead to it.

pliant pike
#

yeah and you can use RequireSingletonforupdate if necessary

warped coral
#

that requires me to come up with some trigger component to make the system update right? i cant just use a bool otherwise it'll always be uh.. checking the bool values?

robust scaffold
safe lintel
#

systems operate on matching entity queries, so yes you will need to operate under(example) if a b & c component exists, do work, otherwise if its only a and b (but missing c) do nothing

warped coral
#

would it be slower or uh.. bad practice to just have a monobehaviour use the entity manager to do the oneshot method instead of using a system?

safe lintel
#

well kind of bad practise in the larger sense to use a monobehaviour if you can use a system instead

warped coral
#

idk i guess it just seems odd to use a system that constantly checks or something when i just need uh... to call a method in response to an input and the method is done in the same frame. i know in OOP it would just be a method call. ecs makes things seem weird i guess

gleaming plank
#

You can separate out some functions as long as they don't mutate the data. Not every little utility has to be its own system.

safe lintel
#

its basically zero work to check for entity queries, i have like 200 systems but only maybe a quarter are running at a given time and its nbd, and the inactive ones contribute to basically zero overhead.

warped coral
#

oh

stiff skiff
#

I wouldn't say zero overhead, it certainly starts counting once you hit a few hundred systems. But it's pretty low.

safe lintel
#

my inactive systems show as 0.00ms on my profiler in the editor, and things are far faster in a build 🤷‍♂️

low tangle
#

don't overly separate systems

#

if you already have some data close, and the other thing you could do isn't too distinct you should do the extra work there and then

#

systems are not so cheap that you can push 1000s, you should expect a final game to be in the 100-500 system range depending on game complexity. with way less than that active every frame

#

rough numbers from experience on my game the last two years

warped coral
#

how do i make sure systems that use read/write the same data don't conflict? does Entities.ForEach take care of that for me with its implicit dependency stuff?

rancid geode
#

this is a pretty old post, besides the screenshots saying "Today", I just had it saved for reference

#

so I imagine that with the burstable systems that are coming next those numbers could be even higher

gleaming plank
# warped coral how do i make sure systems that ~~use~~ read/write the same data don't conflict?...

You manually specify system update order with [UpdateBefore][UpdateAfter][UpdateInGroup] attributes. You can specify the order between systems and other systems, systems and system groups, groups and other groups, etc.
https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/system_update_order.html

example:

[UpdateBefore(typeof(Group2))]
public class Group1 {}

public class Group2 {}
     
[UpdateInGroup(typeof(Group1))]
class A : SystemBase
     
[UpdateInGroup(typeof(Group1))]
[UpdateAfter(typeof(A))]
class B : SystemBase
     
[UpdateInGroup(typeof(Group2))]
class C : SystemBase
     
[UpdateInGroup(typeof(Group2))]
class D : SystemBase

A -> B -> C || D

low tangle
#

I think at peak before other things happened, I hit about 250 systems in the main world, with two other worlds at 100 systems each

#

you can schedule a ton more than that, but I'd be weary about fragmenting your logic too much

low tangle
#
    [UpdateInGroup(typeof(SimulationSystemGroup), OrderFirst = true)]
#

written like this

#

also you should use the nicer dots UI's if you are not already. only fallback to the entity debugger if something is broken

zenith wyvern
#

Every time I try to use that it keeps throwing annoying exceptions all the time

low tangle
#

I'm on 2019.4.17

zenith wyvern
#

Well it's been a while, maybe it's better now

low tangle
#

I'm pinned on this older version for awhile

zenith wyvern
#

Do you use subscenes at all btw?

low tangle
#

not at all

#

game doesn't fit the pattern

#

I don't use the build system either, still using my custom pipeline using the older build manifest system

zenith wyvern
#

Gotcha. I'm curious to hear if anyone actually uses them. They just seem very bad with the whole ConverterVersion thing

low tangle
#

I finally moved to using companion gameobjects just recently, didn't know they were from the ConversionSystem object not entitymanager. didn't think I had access to them till I updated to 2020, but I was mistaken

#

its too bad we don't have a wiki with a bunch of latest dots stuff somewhere, gotta skim the docs and intelsense browse for the new stuff

zenith wyvern
#

I recently started using them too to avoid having to use hybrid renderer which was performing hilariously bad with just a single dynamic mesh

low tangle
#

yep, I haven't touched hybrid in a long time because of how slow it was

zenith wyvern
#

Very convenient to just be able to query directly for a meshfilter

low tangle
#

yeah I was already using the AddObject() convenience to do that kind of logic, but being able to fully use the conversion interface is super nice

north bay
low tangle
#

what kind of game?

north bay
#

Also the converter version thing is pretty straight forward when you get used to it

zenith wyvern
#

It's given me nothing but headaches every time I try to use them. I think I just never understood when I needed to increment my ConverterVersion and I incorrectly assumed the "reimport" button would save me from having to do that

north bay
#

Ehh

#

Incrementing the version forces all subscenes to be reimported

#

Reimport "should" work

warped coral
#

how difficult is it to serialize worlds in ecs? (for saving loading)

coarse turtle
#

the only downside I had with subscenes - is when you have a component which utilizes a pointer - it's not obv on how it would handle that use case

rancid geode
zenith wyvern
#

@warped coral I was literally just doing that yesterday for my roguelike - it's dead simple as long as you have no managed objects

warped coral
#

oh cool

zenith wyvern
#

Basically as straightforward as you'd expect

warped coral
#

how do you do it?

zenith wyvern
#

Just call serializeutility.serializeworld

#

The .deserializeworld to load it and it "just works"

#

Again, as long as you have no managed objects

low tangle
#

does that still fully replace the world contents?

zenith wyvern
#

I'm not sure, I cleared my world before I did it

#

Not sure if you can do it to a non empty world

north bay
#

I think the world has to be empty for it work at all

low tangle
#

yeah, thats what I ran into awhile ago

north bay
#

That's why you have that 'streaming world' setup

low tangle
#

you can use a temp world, and merge from it, but I remember the transaction causing issues with my old setup

warped coral
#

nvm. i think i understand now

safe lintel
#

are you serializing any blobs @zenith wyvern ?

zenith wyvern
#

Yeah you create a separate world tondeserialize into then do MoveAllEntities or whatever

#

Nope I don't use blobs in my roguelike

safe lintel
#

ok, well might be issues with de/serializing there using serializeworld

zenith wyvern
#

I was curious how you would even handle stuff like that. Like I tried it with a managed objects and it literally just gives you a list of Objects after serializing. Not sure how you would even remap that after deserialization

#

I guess if the entity IDs are consistent it wouldn't be that bad. Which I imagine they would be

safe lintel
#

i had some simple tests that mapped every reference object to a file, and then on serializing it would store the id of that referenced object, and then on deserializing just lookup the id, but blobassets dont get serialized the second time around funnily enough.

hollow sorrel
#

yea ran into that one too

#

still hasn't been fixed

hollow sorrel
#

2nd one is fixable by only cherry picking save data into a seperate world and serializing that but still doesn't have any versioning

warped coral
#

oh

normal viper
#

as someone whos starting out with unity could there be any idea to starting with dots or is it better to learn the standard object oriented stuff and then come look at dots later?

gleaming plank
#

DOTS is very much still in preview. The documentation is pretty sparse, so digging through sample code would probably be necessary.

If you're new, most tutorials involve GameObjects and most people who can answer questions ware going to have more experience with them. I'd vote for starting with GameObjects on that basis alone.

The style of thinking OOP encourages doesn't translate nicely to ECS, but experience is experience. It's less difficult to make the jump than it seems when you really understand whatever features you're trying to implement. ECS won't really change algorithms, only how/when things are done.

That said, don't get caught up on the best way to learn something. Learning "bad habits" that have to be corrected later is better than never learning.

normal viper
#

alright will continue down the path i was going and maybe look a bit at dots stuff out of sheer interest thanks dude Unity

fair stirrup
#

I'm triggering ECS system updates from the editor side, any reason this might cause major memory leaks. I visited this issue recently here however it seems to end at a GCHandle .free() not working / an object no disposing correctly.

zenith wyvern
#

Not that I know of. You're always going to see a lot of allocations in the editor just from the safety system/editor stuff in general though

#

You can use the standalone profiler to get an actual non-editor picture

fair stirrup
#

@zenith wyvern Thanks, i thought the same typing that out. I'm going to try running the same systems in standalone and see if i see the same leaks.

fair stirrup
#

Looks like running in playmode is working fine (performance is way higher). I'm wondering if its how I'm creating and triggering the system update. There must be something different in the playmode setup thats correctly allowing the dispose of the object.

desert topaz
#

.

#

^this is a dot

deft stump
#

is it expected to see this much garbage from FixedStepSystemGroup?

#

sure it's 1KB but it's frequent

hollow sorrel
#

@deft stump turn off leak detection, safety checks etc

fluid kiln
#

Do you guys have any guidance on implementing click to move in NetCode? Is there a way to implement owner prediction without the stuttering? Or am I forced to use server movement once the destination is set?

fair stirrup
#

@hollow sorrel Did the test, code seems to work fine in playmode with no leaks but fails to dispose references in editor mode running systems

north bay
fluid kiln
#

My command buffer contains the destination set by the client. I then move the player towards the destination in a ghost prediction system.

#
    //Destination was received from the server and set using input buffer
    protected override void OnUpdate(EntityCommandBuffer ecb)
    {
        var deltaTime = Time.DeltaTime;

        Entities.ForEach((Entity entity, ref Translation translation, in Destination destination, in Speed speed) =>
        {
            var distance = destination.value - translation.Value;

            if (math.length(distance) < DISTANCE_DEADZONE) return;

            var direction = math.normalize(destination.value - translation.Value);
            var movementDelta = direction * speed.value * deltaTime;

            translation.Value += movementDelta;
            ecb.SetComponent(entity, translation);
        }).Schedule();
#

I understand it's not synced but I'm not sure how to make it synced

north bay
#

You should directly write back into the translation, not set it through a command buffer. Where does that command buffer come from?

#

I don't remember such a method signature

hollow sorrel
#

@fair stirrup what is leaking?

fluid kiln
#

I've extended SystemBase to simplify the fetching of the ECB

#

Just less code rewriting

fair stirrup
fluid kiln
#

I'll try to write into the transition, but now I'm confused as to when use an ECB and when to write in the object directly

deft stump
#

you use ECB when you need to do structural changes

fair stirrup
north bay
fluid kiln
#

Yeah right structural changes, been a few weeks

north bay
#

The ghost prediction system group executes multiple times in a frame on the client which is the reason why you can not buffer those changes

#

On the server that would work fine

fluid kiln
#

Interesting

#

So basically just remove the last line?

north bay
#

Ye

#

You also need to include the PredictedGhostComponent in the query to only iterate over components you have authority over

fluid kiln
#

Absolutely

north bay
#

Before you do anything inside the Entities.ForEach you need to check if you should predict by calling GhostPredictionSystemGroup.ShouldPredict with the currnetly predicting tick which you can fetch from the GhostPredictionSystemGroup

#

If that method returns false you should early out

fluid kiln
#

Ok, I thought you would only make that check when working with the input command buffer, but now that you mention it it makes sense

#

Thank you very much

hollow sorrel
#

@fair stirrup ah i dunno, i don't use GCHandles
but make sure it's being called, maybe you're not freeing when transitioning to play mode

#

alternatively maybe try doing it without GCHandles

fair stirrup
#

ALINES package. Wish i could lol. I'm just trying to get some clues as to why the leak might only happen in the editor.

hollow sorrel
#

oh still that

#

i'm still not convinced it's due to ALINE, i'm also using it in editor mode without issues

#

and also you def don't need to be touching GCHandles with ALINE

fluid kiln
fair stirrup
#

I've just snooped the dispose method to see whats going on. The CommandBuilder doesn't seem to be getting diposed.

fair stirrup
hollow sorrel
#

both

fair stirrup
#

I must be missing something. In editor mode I use world = DefaultWorldInitialization.Initialize("Editor World", true);

#

To get things going i currently EditorApplication.update += () => System.Update();

hollow sorrel
#

hmmm

fair stirrup
#

I can suspect it has something to do with not being in playmode because it works in playmode.

#

obviously the += isn't required then.

hollow sorrel
#

ok now that you mention it does seem to be allocating GC

#

no actual leaks tho, as in mesh memory isn't increasing for me

fair stirrup
#

For me it starts to bottle up in DrawingManager.instance.gizmos.meshes after looking into the profiler.

#

Thats using WireBox.

hollow sorrel
#

is this still same as that doc snippet code?

fair stirrup
#

Nothing complex. CommandBuilder draw = DrawingManager.GetBuilder(); Entities .WithName("VoxelDataProcessing") .WithoutBurst() .ForEach((ref VoxelDataComponent voxelData) => { draw.WireBox(voxelData.position, 1f, new Color(0, 0, 0, 0.2f)); }).Run(); draw.Dispose();

hollow sorrel
#

yea that looks fine

fair stirrup
#

Works fine once in playmode but bottles strictly in editor.

#

Wonder its a problem with it being executed within a OnGui call.

#

Ill try invokeing += on a mono object instead

opaque escarp
#

What's the best way of deferring execution of an operation on the main thread until certain jobs have completed?
I have mesh data that is being constructed, after which I apply it to the mesh and draw it, but that has to be done on the main thread, so at the moment I schedule the mesh construction jobs, then immediately wait with Dependency.Complete, which kind of defeats the purpose of using the jobs in the first place, since afaik that blocks the main thread. Ideally I'd be able to have the main thread continue with all its scheduling system shenanigans, then by the time it's done with that the job in question would be complete and I could run the mesh assignment without having blocked the main thread at all. Alternatively, a way of drawing a mesh that doesn't block the main thread at all would work.

gusty comet
#

How are things in dots land? Any proper 2d support that is not the hacked together hybrid renderer yet?

rancid geode
opaque escarp
#

Storing the JobHandle manually is viable, though executing later seems like such a common and basic operation I would have thought there'd be built-in support for it.
And thank you for the resource, though I think I want to avoid using external thread stuff. In the past I rewrote a friend of mine's code to use the job system and Burst, from await/async, and saw an over 100x performance improvement, so I think sticking to what's available in jobs is the way to go

rancid geode
#

Yeah, if I need burst I usually do something like:

Enabled = false; // stop the system from running every frame
JobHandle theJob = new TheJob().Schedule();

await UniTask.WaitUntil(() => theJob.IsCompleted);

// do stuff
Enabled = true; // resumes the system

I believe you can do that without UniTask too, I am just too used to it already, as it allows me to easily switch thread context

opaque escarp
#

I'll give it a shot, thanks

fluid kiln
#

I'm not seeing the Hybrid Instancing checkbox on shader graph, is there a setting I have to enable with Hybrid Renderer V2?

fluid kiln
#

Found it, it changed:

deft stump
#

still hacking away XD

zenith wyvern
#

Although performance is not great right now, as far as I know

#

Seemed to work fine for me for a fairly large tilemap that gets updated often

low tangle
#

hm bit wordy still, but good idea here to wrap ecb grabbing into a method. saves a bit of boilerplate, maybe.

#
override OnUpdate()
{
   var ecb = this.GetCommandBuffer<EndSimulationEntityCommandBufferSystem>(Dependency);
}

public static class SystemBaseExtensions
{
    public static EntityCommandBuffer GetCommandBuffer<T>(this SystemBase system, JobHandle Dependency)
        where T : EntityCommandBufferSystem
    {
        var sys = system.World.GetExistingSystem<T>();
        var ecb = sys.CreateCommandBuffer();
        sys.AddJobHandleForProducer(Dependency);
        return ecb;
    }
}

zenith wyvern
#

Don't you need to call AddJobHandleForProducer after your jobs though? I could be wrong about that

fluid kiln
#

I remember reading somewhere that you could now pass Entities in NetCode RPCs. Is that the case, if so, where is the doc?

#

I guess I'll try to put an entity reference in an RPC and we'll see if it's magic 😉

worldly loom
#

What is this channel for?

fluid kiln
deft stump
#

does int2.zero does new int2(0,0) underneath?
similar to vecto2.zero?

solar spire
#

Surely you can look a the source

deft stump
#

I forgot it is on github

solar spire
#

It's also in your project

#

if you have it imported

fluid kiln
warm panther
#

Best practice question: I want a System to have a reference to an asset or scene object. What are elegant ways to inject one?

#

Locator pattern comes to mind, but I'd really like something as straightforward as for Monobehaviours, if feasible. Maybe I need to wait for ISystemBase in Entities 0.17 for that.

#

Arrrrgh I hate this.

#

If Systems were at least scriptable objects, it would all make so much more sense -.-

#

It's as if they tried really hard to make it interoperate with classic unity as much as possible.

#

(I'm also just lazy)

#

(which, I must insist, is a commendable attribute in a programmer)

deft stump
#

You can put that class ICD in empty entity

warm panther
#

That's a lot of boilerplate but yeah that's one option I suppose.

#

Managed ICD I guess.

#

But then the system has to:

  • formulate a query for that entity
  • actually get it at the right moment
  • then manually find the field in the ICD it cares about
  • copy and store this.
#

Compare to Monobehaviour: I drag scriptable Object on Script Asset or Component Property Inspector as I wish. In particular, the default Behaviour for mapping serialized objects to Script assets is sorely missing with DOTS, but I would only need it a few times so I could cope.

amber flicker
#

An authoring component with a gameobj field will be an icd with a mapped entity when converted if that helps. I also use conversion to eg make a scriptableobj a blobasset

hollow sorrel
#

imo the real issue is unity's asset file handling is really lacking
if you could just do load(assets/someprefab) without resources.load or assetbundles or addressables (tho this one seems like best option atm) things would be really easy

#

for my game with small assets it doesnt matter loading entire game in memory at once so i put all runtime assets in a scriptableobject (editor script that looks up assets in folder and assigns automatically), then put that in a dictionary at runtime so can just use the load(whatever) syntax for any asset

#

but thats only suitable for games where you can load everything in memory at once

amber flicker
#

Agree but we know they’re working on prefabs/addressables so hopefully they come up with a good solution

fair stirrup
#

@hollow sorrel finally found a possible solution.

#

Invoking EditorApplication.QueuePlayerLoopUpdate(); OnGui instead of adding the systemupdate to the application update seems to fix this.

#

That under the hood should invoke the rest of the system groups incase ALINE for some reason depends on them.

#

DefaultWorldInitialization.Initialize("WorldManager:EditorWorld", true); Does a "add to game loop" under the hood

#

The other option is to use a custom bootstrap.

tall pasture
#

Generating 3D terrain data using noise and its mesh using Naive surface nets algorithm. All in c# Jobs. I managed to program all the stuff separately. Now I need to make it work together in a manageable fashion.
The Main problem is that even so terrain data is a predictably sized array of float[32*32*32], the generated mesh size is not. It can be as little as few vertices,indices or tens of thousands.
As i understand i could use NativeList for that purpose, but then in the end I need to call ToArray() to assign the result to the mesh. So my question is : am I supposed to use Lists or is making NativeArray with Allocation.Temp inside jobs' execute() and assign it's size dynamically a more appropriate if even possible. I'd only use that array to assign to the mesh and dispose it. Also I want it to be Burst enabled and no unnecessary allocations.

Also I schedule mesh gen job as a dependency of data gen job. My thought is that if all the jobs are scheduled, then after data generation is complete, mesh creation can start immediately without me tracking if job isComplete. I could do dynamic array allocation in Main thread, but I thought that making it work with dependencies and allocate stuff without main thread participating would perform and scale better.

zenith wyvern
# tall pasture Generating 3D terrain data using noise and its mesh using Naive surface nets alg...

You don't need to call ToArray to assign it to the mesh. There are overloads on SetVertices and SetIndices that will accept a NativeArray, IE:

        Entities
            .WithoutBurst()
            .ForEach((
            in DynamicBuffer<IndexBuffer> indexBuffer,
            in DynamicBuffer<VertsBuffer> vertsBuffer) =>
            {
                var verts = vertsBuffer.Reinterpret<float3>().AsNativeArray();
                var indices = indexBuffer.Reinterpret<int>().AsNativeArray();
                mesh.SetVertices(verts);
                mesh.SetIndices(indices, MeshTopology.Triangles, 0);
            }).Run();
tall pasture
#

Yeah i know that, at least for NativeArray. Is it overloaded for NativeList as well ?

zenith wyvern
#

list.AsArray() returns the underlying native array. It doesn't do any copying

tall pasture
#

So it will be as fast as nativeArray, no significantly more memory and burst compile enabled ?

zenith wyvern
#

Correct

tall pasture
#

Cool. What about NativeArray Temp allocation inside a job. Is it acceptable to do so ?

zenith wyvern
#

Yes, and it's extremely fast as far as I understand it. I've heard if you allocate very large arrays that way it can start to slow you down though, in which case you can just allocate them as TempJob or Persistent outside the job and pass them in.

tall pasture
#

Ok, I saw a blog post where it was shown that it slows down after 820 4byte allocations. At least it was the case for the author.

#

Also a more high level question. The big picture of my algorithm is that it created a procedural world many chunks at a time using jobs for each chunk.
Most examples shedule jobs early in update and grab results in LateUpdate. My generation logic can be longer, up to several frames. So i am thinking of sheduling many jobs and placing then with their handles in a dictionary which i am going to loop periodically, check if individual job isComplete() and grab result when it is.
It makes me thinking if I am not overcomplicating things, but I don't see anything build in what could manage many jobs which would not halt the main thread if they fail to complete their stuff in one frame.

zenith wyvern
#

There's no alternative if you want to wait for a job to complete on the main thread. Storing the job handle and checking IsComplete every frame is how you do it.

#

Oh actually I've seen on the forum someone recommend the "UniTask" asset which makes it a bit smoother. I've never used it myself

tall pasture
zenith wyvern
#

Could be, I don't know how it works at a low level honestly

tall pasture
#

Well I discovered jobs 3 days ago, and I reached my limits of research capability 😄

#

Seems like jobs can be a deep topic, and naturally there is a fear that I am doing something wrong or inefficiently.

zenith wyvern
#

Well I will say if you work in ECS it makes it a lot smoother to work with the job system. But there's about a million other issues you'll run into at the same time so I wouldn't recommend it

tall pasture
#

I was wondering tho, i red that jobs won't be burst compiled if there is dynamic allocation or reference types. Wouldn't it make NativeList not burst compilable ?

zenith wyvern
#

Managed allocation is not allowed. All native containers are unmanaged

#

So yes, all native containers are burst compatible

#

Although some you can't allocate inside a job like NativeHashMap, but you can still use them in bursted jobs

tall pasture
#

Got it. So basically List is quite powerful, only that it must grow several times if you wanna insert many items you didn't planned for

#

And if i want to allocate memory from inside the job, then NativeArray with Temp Alloaction is the only choice if i want to be burst compiled ?

zenith wyvern
#

No. I know at least NativeArray and NativeList are fine to allocate inside a job. The rest you'd have to see for yourself.

tall pasture
#

Ah ok. I thought it was a part of Unity's plan to make Temp Allocation unpassable to the job so that it would be easier for Burst compiler to do its stuff.

zenith wyvern
#

Allocating inside a job and passing it to the job are two different things. You can't pass temp containers inside or outside of a job.

tall pasture
#

Also that List.AsArray(), wouldn't it create a copy of data or something? Because i quite fail to understand how the data is passed to the mesh knowing that list and array are two different structures that are (probably?) differently laid out in memory. Or when list grows , it's entire data get's copied to bigger flat area in heap and so it is same as array ?

zenith wyvern
#

NativeList uses a native array internally. You can read the source for yourself to understand it better

#

Actually it doesn't, but both a native array and a native list are just a fancy wrapper around pointer to a block of memory, so it does make sense that it can convert between them without any copying

#
        /// <summary>
        /// This list as a [NativeArray](https://docs.unity3d.com/ScriptReference/Unity.Collections.NativeArray_1.html).
        /// </summary>
        /// <remarks>The array is not a copy; it references the same memory as the original list. You can use the
        /// NativeArray API to manipulate the list.</remarks>
        /// <returns>A NativeArray "view" of the list.</returns>
        public NativeArray<T> AsArray()
        {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AtomicSafetyHandle.CheckGetSecondaryDataPointerAndThrow(m_Safety);
            var arraySafety = m_Safety;
            AtomicSafetyHandle.UseSecondaryVersion(ref arraySafety);
#endif
            var array = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>(m_ListData->Ptr, m_ListData->Length, Allocator.None);

#if ENABLE_UNITY_COLLECTIONS_CHECKS
            NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref array, arraySafety);
#endif
            return array;
        }
tall pasture
#

Cool. How can i peek into source. I am using VS Code , and if i click Peek definition of nativeList then it works, but not implementation

zenith wyvern
#

The full source for all packages in your project are in the packages folder in Unity

tall pasture
#

Aha, thanks ! I feel dumb 😄

#

Regarding arrrays vs List i though that native containers don't actually point to the same data type. I thought that for arrays it was c++ arrays , and for list it was std::vector. Tho, my c++ knowledge is next to zero so perhaps you debunked my bet

zenith wyvern
#

My knowledge with low level stuff is near zero too, but as far as i understand it there's no "data type" for the native array pointers, it's just a block of void* memory. All the type safety stuff is an abstraction on top of that

north bay
#

Anyone tried dots with 2021.1?

zenith wyvern
#

For a long time now, yeah

#

Haven't had any issues related to 2020.1 that I can think of

tall pasture
#

Ok to summarize "data gen job" does it stuff, then when it finishes its dependency "mesh gen job" determines how large mesh will be and allocates Array with Allocator.Temp of just that size (or allocator TempJob if array size is very large). Then Values get populated and sometime in a main thread job gets checked in a loop if it isComplete. Then Mesh.SetVertices is called with the result of the job, and then it get's disposed. Seems reasonable ?

zenith wyvern
#

Why do you need a data gen job and a mesh gen job. Just work with one set of data that gets applied directly to the mesh

tall pasture
#

because Data gets generated once and serialized to persistent memory.

#

You can think of a Minecraft type world where chunks get generated and then stored in your drive

zenith wyvern
#

Oh I see what you mean, then yeah that sounds about right

#

To make it simpler I would say just use NativeLists instead of NativeArrays for your mesh data, then you can add your vert/uv/index mesh data as you iterate over your game data

#

NativeLists will re-use the memory as they get "cleared" and re-grow

tall pasture
#

Oh so i am talking with a right person 😄

zenith wyvern
#

My "block data" is just an array (dynamic buffer) of shorts representing a flattened 3d array for a chunk of space. When generating the mesh data I first clear my mesh data lists, then looper over the block array and Add to lists for any block that exists

tall pasture
#

I should have said word Minecraft at a very beggining\

#

Are you using shorts because you want to support 65k types of blocks ?

#

or you bit encode some other info in it?

zenith wyvern
#

Yeah I just figured a byte might be too small in the imaginary world where the project would grow any bigger than it is

#

I don't encode any extra data in it

tall pasture
#

What do you mean by "When generating the mesh data I first clear my mesh data lists"

#

You are reusing Mesh() objects ?

#

Or are you clearing native container which is Allocation.Persistent

zenith wyvern
#

No, for any "chunk" I have my block data (DynamicBuffer<ushort>) and my mesh data(DynamicBuffer<float3> for verts, DynamicBuffer<int> for indices, DynamicBuffer<float2> for uvs). All the mesh data buffers get cleared and rebuilt from scratch any time a "chunk" needs to be rebuilt - IE any time a block changes in that chunk or a neighbouring chunk

#

Then the buffers get pushed to the mesh on the main thread at the end of the frame

#

In your case you're using NativeLists, you can basically just think of dynamic buffers as native lists, they work the same essentially

tall pasture
#

Are Dynamic buffers always present for every chunk ? So if there are lots of chunks loaded , then there is a lot of data constantly hanging as well ?

zenith wyvern
#

Yeah. In that project a chunk was 16x16x16, so it wasn't too bad

tall pasture
#

It sounds flexible if world are small. I strive for something at least 4x more distance than that in every axis

#

gonna make LOD eventually

zenith wyvern
#

16x16x16 was a single chunk, obviously in game you would have many many chunks loaded around a player at once

tall pasture
#

Actually when i see this picture there are seams. How did you managed to overcome it ? are you referencing blocks from World controller or are you making redundant padding ?

zenith wyvern
#

It's complicated. My project was fully ECS, so to reference a nieghbouring chunk (to read it's block data) you need access to that chunk's entity. I don't remember how I did it in the original project. In my latest attempt I had a hashmap of all chunk entities that were loaded in the world that I would pass between jobs, which was annoying but it worked.

#

Since chunks can be loaded or unloaded at any time it's a huge pain in the neck to keep references to them up to date.

#

There's no easy solution that I can think of

warm panther
#

Try anything even remotely fancy to inject asset dependencies into UI systems, and - besides nothing working without manually disabling every system (can't seem to do it to the parent class without a warning) - and you get a reload script assemblies even if you switch from one gameobject to the next. Jeez.

#

What's interesting is, it tries to AutoCreate my system 3x. What. Maybe this is behind my performance issues.

#

But srsly, the absence of a default constructor ought to have been enough of a hint to perhaops not auto-create this system in the first place... or the [DisableAutoCreation] on its abstract parent class.

#

... /vent

#
        [UpdateInGroup(typeof(LateSimulationSystemGroup))]
        [DisableAutoCreation]
        public class CameraSystem : ChannelResponderSystemBase<Entity>
        {

Gee thanks, so that doesn't work. Unity still tries to instantiate this one.

#

Ahhh, so GetOrCreateSystem is the culprit here.

#

Which kinda makes sense. Except this system is already instantiated in Awake...

rotund schooner
warm panther
#

Best place IMHO are the unity ECS examples.

rotund schooner
rotund schooner
#

hmm, according to the entity view, the entities are being correctly created and physics is running, but the views are not being displayed. It's odd, since int he Physics Sample I can create the exact same scene and they display correctly

#

okay, looks like I needed the hybrid renderer package installed

fluid kiln
#

Any idea how to send entities by RPC or Command in NetCode 0.5.0? The changelog says it's now possible but it doesn't seem to work for me

opaque escarp
#

How can one detect if the current object is a prefab, rather than a scene object, when doing stuff within IConvertGameObjectToEntity.Convert?

At them moment I'm creating some linked entities (manually, with LinkedEntityGroups), but the Prefab component in the parent doesn't seem to be propagated to the linked entities by default, and it doesn't seem like the Prefab component has been added by the time of conversion.

north bay
#

It works fine on rpcs tho

fluid kiln
#

Okay so maybe they meant only RPCs for now

#

Shame that authoring component doesn't work for a dynamic buffer of entities

pallid gale
#

Hey guys. I'm looking into making myself a DOTS demo with physics cubes, however I ran into some difficulties.

When I'm making simple (transform+render) entities, I can put alot on a scene - render job is perfect, having 20k objects is easy.

When I'm adding to the entities a Body and Shape things gets sad - on 2k objects, I have 50 fps (macbook pro 2018). I noticed in the inspector though - that all the slowness comes from render job, instead of physics job for some reason. I've spent some time browsing though the forums, but to no avail. I have an impression like I missed some setting somewhere - since youtube videos I watched on DOTS all seems to be working perfectly well, and I followed every step.

#

Here is how it looks. I tried different simple shaders (legacy, mobile), but to no avail. All the collision shapes are non-unique cubes

#

To me it looks like physics system is somehow slowing down RenderMeshSystemV2, but since I've just started with DOTS, I don't understand what's going on. Forums about RenderMeshSystemV2 seem to be on other issues, or I could not make a connection between my issue and theirs.

zenith wyvern
#

Are you sure all your cubes are ending up in the same chunk - do they all share the same material and mesh?

#

If you find click on the archetype for your cubes on the right side of the debugger it should show you how many you have

pallid gale
#

I instantiate cubes from prefab, so I hope the will share a mesh. Also, when I enable\disable GPU instancing, there is a difference in draw calls in stats

zenith wyvern
#

Well I know for sure there's been a LOT of reports of Hybrid Renderer being very slow and buggy with the current version of entities - are you running 0.17?

#

Err 0.16

#

If it looks like your cubes are being chunked out correctly based on archetype I would say try downgrading to 0.14 and seeing if it's still horribly slow

#

As annoying as that is

pallid gale
#

I honestly can't undestand how to see how many archetypes I have

zenith wyvern
#

So for every "Entry" in that list when you have "all entities" selected, that's one archetype

#

If all you have in your scene are your cubes and all your cubes are identical there should only be like 2 or 3 archetypes afaik

pallid gale
zenith wyvern
#

Yeah that looks right to me

pallid gale
#

I spawn exactly 2k entities

zenith wyvern
#

Are you using Hybrid Renderer "v2"?

pallid gale
#

no, I have unity2019

#

let me check my version of Hybrid renderer

zenith wyvern
#

Ahh, that might be why? I can't say for sure but the original hybrid renderer is pretty outdated at this point

#

And if I remember right the original renderer did use GPU instancing so it would make sense that would affect performance

pallid gale
#

so my only real option is moving to unity2020?

zenith wyvern
#

The current version uses some kind of fancy batching with URP as far as I know

#

Honestly I'm not familiar enough with physics OR the hybrid renderer to 100% say it would fix your performance problems, but that would be what I would try

neon pewter
#

I am receiving a Burst error... Does anyone know how I might track this down and fix it?

  %3 = bitcast i64 %2 to float, !dbg !83

  at Burst.Compiler.IL.NativeCompiler.Compile () [0x001a1] in <d4152694e4174e21af29a45a4de4e8f4>:0 
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethodInternal (Burst.Compiler.IL.Jit.JitResult result, System.Collections.Generic.List`1[T] methodsToCompile, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x00484] in <d4152694e4174e21af29a45a4de4e8f4>:0 
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethods (Mono.Cecil.MethodReference[] methodReferences, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x0027a] in <d4152694e4174e21af29a45a4de4e8f4>:0 
  at Burst.Compiler.IL.Jit.JitCompiler.CompileMethod (Mono.Cecil.MethodReference methodReference, Burst.Compiler.IL.Jit.JitOptions jitOptions) [0x0001c] in <d4152694e4174e21af29a45a4de4e8f4>:0 
  at Burst.Compiler.IL.Jit.JitCompilerService+CompilerThreadContext.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x00468] in <d4152694e4174e21af29a45a4de4e8f4>:0 

While compiling job: System.Void Unity.Jobs.IJobExtensions/JobStruct`1<Doc.CodeSamples.Tests.RandomSumJob/Doc.CodeSamples.Tests.<>c__DisplayClass_OnUpdate_LambdaJob0>::Execute(T&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
at <empty>:line 0
deft stump
#

okay crazy idea...
but i know blobs are very expensive to make...

#

but... does it make sense to temporarily write over a value within a blob?

#

so instead of them being a readonly databank.
I can temporarily store relevant data in there

zenith wyvern
#

I don't think you can do that can you? To "modify" a blob you have to create a new one and overwrite and dispose the original

#

Or that's what I thought at least

#

Plus you would have to update all existing references to point to your new blob

pallid gale
#

thanks for tips @zenith wyvern , I will try to install 2020 later and check how is it working there with hybrid renderer.

zenith wyvern
safe lintel
#

Are you profiling using the entity ddebugger? Good chance hybrid renderer is simply waiting for physics to finish its work.

zenith wyvern
#

Oh good call. The timeline in the profiler should make it pretty clear if that's the case

safe lintel
#

Anyway: check the profiler timeline, it shows bottlenecks properly

real spindle
#

what does dots mean

zenith wyvern
opaque escarp
#

Using NativeStream.Writer, I get a lot of red bars in the Profiler Timeline referencing MemoryManager.FallbackAllocation, makes it sound like I'm doing something wrong. Is there a way of allocating the necessary stuff ahead of time so the Fallback isn't necessary?

#

I see there's an allocate method, but it returns a byte pointer, and I'm not sure how I can make use of that

warped coral
#

with ecb.. since it doesn't have entitymanager.setenabled(), i can just use ecb.removecomponent<Disabled>() and it does the same right?

warped coral
#

also... how does async/await interact with ecb?

#

like if i create a command buffer... then set it to create an entity, add a disabled component, and then await a few times, adding components to it, would it work or is that bad

#

does the ecb get disposed when the buffer system uses it the first time?

#

do i gotta create a new ecb in between awaits?

fair stirrup
#

Do need to bother with guid's with sharedcomponentdata?

#

or should i just fetch a timestamp?

pallid gale
# zenith wyvern No problem - don't forget to read up on the package docs: https://docs.unity3d.c...

well I managed to install 2020.1.17f1, but it doesn't help. for some reason, either renderer or physics is still dramatically slow, compared to videos I can find online, for example https://www.youtube.com/watch?v=U6idEdIEsa0&ab_channel=LaCreArthur - I just cannot reproduce that results with the same approach

In this video we push Unity Physics to its limit again with the new DOTS physics engine. Will it crash this time ?

Link to the Brackeys video : https://youtu.be/8zo5a_QvJtk

We will create a script that generate a tower of cubes, first with regular GameObjects and Rigidbodies then with ECS Entities and DOTS physics

This is the very first video...

▶ Play video
zenith wyvern
#

Did you check the profiler timeline?

pallid gale
#

like the profiler or the entity inspector?

#

I cannot enable hybrid renderer 2, since URP 9.0.0 is not out yet

#

so basically it's the same setup, but I'm using URP instead of built in

zenith wyvern
#

Urp 9 is definitely out

#

I think 10.2 comes pre-installed if you select URP on a new project

#

But you should be able to install it through the package manager if it isn't already

pallid gale
#

I have 8.3.1 for some reason

#

is unity 2020.1.17f1 too old of a version for that?

zenith wyvern
#

This is the profiler timeline. Notice the timeline tab where the cursor is. It's under Window->Analysis->Profiler

#

Shouldn't be. Look in the package manager for "Universal RP" and update it

pallid gale
#

do I have to manually install it like unity physics?

zenith wyvern
#

Oh, hmm. Maybe you do need 2020.2?

#

I don't think so, the "Up to date" button there should be where you update it unless I'm crazy

pallid gale
#

this "package management" reminds me strongly of npm

zenith wyvern
#

That's mine but I'm on 2020.2

pallid gale
#

I see. I guess I need to switch to 2020.2

#

profilers shows the same as entity debugger. there is something called "debug stream" and it's eating all the CPU

zenith wyvern
#

Try making a new project with your current version and selecting the "URP" template if you haven't yet

pallid gale
#

I did that with my current version, urp was enabled

#

but of version 8

zenith wyvern
#

Ahh okay, then yeah maybe you do need 2020.2

#

Can you open up the "Job" dropdown at the bottom of the profiler and take a screenshot of whatever's taking up all the time?

pallid gale
#

debug stream is in fixed time step group, so I guess physics is now acting up

#

it's weird since on 2019 physics was fine on 10k objects, this is just 5k

zenith wyvern
#

Huh. I haven't messed with the physics package at all but yeah I was under the impression it should be able to handle what you're throwing at it pretty easily

pallid gale
#

I guess I'm just doing something wrong, or have the unfortunate combination of unity version\packages version

#

but it seems clear in the tutorials

#

I'll try 2020.2 tomorrow

#

thanks for help @zenith wyvern

pallid gale
#

2020.2 doesn't run at all on my computer

#

oh well

#

I guess this tech is too raw at the moment

amber flicker
deft stump
#

this friday woooooooo

#

calm down my beating heart

stiff skiff
#

I wonder if the changelog they provided is still accurate

#

beyond the release date they put that top that is 😉

neon pewter
#

I have a copy of com.unity.dots.editor@0.11.0-preview-3 in my packages folder in preparation for making a few modifications to it to support modifications I'm planning to make in another Unity package. Aside from packages, there is no other code in the project. I am using Unity 2020.2.1f1. When Unity attempts to compile com.unity.dots.editor, it gives me a bunch of occurrences of a single error: Operator '+' cannot be applied to operands of type 'Chunk.<Buffer>e__FixedBuffer' and 'int'. Every line where it complains looks like this:

var entityDataPtr = (Entity*)(chunk->Buffer + archetype->Offsets[0]);

However, Chunk->Buffer is:

public fixed byte Buffer[4];

And Archetype->Offsets is :

public int*    Offsets;

I'm at a loss on why this is causing the error specified. Does anyone have any insights into this they can share?

karmic basin
neon pewter
#

I did not; thanks. In any case, I simply modified the lines slightly to make it work. Though, I'm not 100% certain the change I made is correct and I haven't gotten around to testing it yet aside from seeing that it now compiles with .NET 4.x. Hopefully, I will have some time tonight or early tomorrow morning to test the change.

#

Basically, what I did was put an & in front of chunk->Buffer. In two cases, I did (byte *)&chunk->Buffer instead. Though, I am much more familiar with C pointers than C# pointers, so I am uncertain if I am now getting a pointer to a pointer which, while it would compile, it would not produce the intended memory location in entityDataPtr. Hence why I said I still need to test. If anyone on here knows more about C# pointers and can attest one way or the other whether what I did is actually correct, that would be great. From reading online, I was thinking I may have to do this instead:

fixed (byte* tmp = chunk->Buffer) {
  var entityDataPtr = (Entity*)(tmp + archetype->Offsets[0]);
}

And then I would need to move everything referencing entityDataPtr into that code block. But I have not done much work with C# pointers in the past, so I am not entirely sure if that's necessary.

pliant pike
#

Is there an opposite of ComponentDataFromEntity<>() or like a simple way to get the entity from the component data I can't remember if there was 😕

fluid kiln
#

I don't think there's any link from the component to the entity

#

Since a component is just a struct

pliant pike
#

Yeah figured thanks, probably best to just store the component data instead of the entity in the buffer

fluid kiln
#

Any guidelines or best practices to synchronize the addition or removal of components in NetCode?

#

At the moment I add or remove the component on the client, send an RPC, and do the same thing on the server

#

But that seems... unpredictable?

neon pewter
#

In most server-authoritative models, the order of operations would be to remove the component on the server and have it trigger a notification to the client(s) to remove the component. In general, assuming the latency is low enough, you shouldn't get any weird behavior from that. The only time it might matter is if the component is used in some way that might add or remove other components or do other things which could get your state out of sync in the meantime. But if it's a server-authoritative entity, you should technically not be making such decisions on the client. If it's client-authoritative, they should propagate to the server and the server shouldn't be doing anything which could get out of sync. Basically, one side should be "read only" / "view only". If you are trying to do some sort of client side simulation of a server authoritative object and are worried about your simulation getting out of sync, then you have to rely on more complex re-sync messages.

fluid kiln
#

My use case is a client-triggered event in a server-authoritative model (being to attack x target). If I send an RPC first, add the component on the server and broadcast the component addition, will it feel responsive to the client? Since it will be 2x latency

neon pewter
#

Also, for what it's worth, the use of RPCs is not the most robust solution when dealing with synchronized objects over a potentially lossy connection. Most RPCs I've seen implemented require that they actually fire on the remote side. But if you are on a lossy connection and using UDP for lower latency, then you run into the case where an RPC may not actually get called remotely.

fluid kiln
#

Is there other methods of communication than Command Buffers, ghost fields and RPCs?

neon pewter
#

What I personally use instead of RPCs is just some events on a channel. For the action you are talking about, I just fire an event out over the message bus and if I want to be more certain it gets through, I fire it more often with a specific timestamp on when it happened so it only plays once on the receiver.

#

For example, the attack I would write into an event which updates the server on current keys pressed

#

I would fire the event off every 20ms or something

#

And the event's body would indicate which keys are currently depressed

#

And it would encode the latest mouse coordinates

#

That input would then be read on the server side as part of a client input system which then fired any required methods locally

fluid kiln
#

That's interesting. I'm trying to recreate a top-down click to move and attack type of gameplay (like LoL). Instead of processing the attack on the client, should I instead send to the server the coordinates of the click ,and process it there?

neon pewter
#

If you lose 1 or 2 or even 10 events, your input still works

#

Yes

#

You send the coordinates of the mouse and the list of currently depressed keys

fluid kiln
#

Right now, to move for example, the client clicks, finds out the wanted destination, and the destination is sent via the command buffer

#

I understand sending the coordinates would be more flexible

#

I'll try that!

neon pewter
#

If a key was pressed and released between the events, you send it as a "clicked" key

#

Then you can simulate the press and release locally

#

You could potentially even send it how long it was depressed

fluid kiln
#

Yeah that could be interesting. Well thank you for the guidance I'll try a few things out 😄

neon pewter
#

If you want to support higher frame rates, you will need faster than every 20ms

#

16.67ms = 60fps

#

@fluid kiln Also, for things like "clicked" events, you probably want to create something in your input event like "buttons pressed for the last 10 seconds" and it would be a list of all the button press and release events and their corresponding timestamps during the past 10 second rolling window. The server can track internally which ones it has replayed and ignore any it has already dealt with. Then these will show up across several messages instead of only being present on a single message which might potentially be dropped.

#

You should also probably encode the mouse coordinates for each click and each release independently

light mason
#

Is there a detail quick startup doc for project tiny building to webGL ?

#

Something simple like a cube spinning

light mason
#

Can I not use IConvertGameObjectToEntity in projectTiny?

karmic basin
#

Lot of useful info there

slim nebula
#

is there a good way to get the entity debugger to be less of a shitter? seems when I filter in one world, then go to another world and filter on the same component, it just ignores me.

fluid kiln
#

Have you tried the entity editor package?

steel pike
#

How should I handle pathfinding on large, chunked maps? AStar has a limit of 1024x1024, but my map is larger than that. I was thinking of making graphs for each chunk and disable/enable them based of off whether or not players were nearby, but I'm not sure how to do this (or if it is feasible). How do I handle this?

north bay
slim nebula
light mason
#

I took that doc recommendation and just copies in the tiny3D .. so from waht ive read I can just build from build setting for webGL ?

#

I also noticed no sub scene.. I thought it all had to be in sub scenes

zenith wyvern
#

It's a new thing in the most recent version, I guess there's some fancy stuff happening behind the scenes where it turns the base scene into an entity scene. And yes, if you open any tiny sample you should just be able to build the wasm target

#

Assuming you have the requirements installed listed in the getting started guide

light mason
#

So it seem to do that conversation when I build and it seems to be working but I can’t run the scen in there editors

zenith wyvern
#

Yeah, it explains it in the getting started guide

#

You can't run tiny projects in the editor. You have to build and run every time

calm olive
#

hi

light mason
#

O man

zenith wyvern
#

Playing in the editor is being worked on, but even when it works it will just be building behind the scenes

calm olive
#

do you know how to change the center of a cube

#

in unity

light mason
#

Ok well I missed that part

calm olive
#

does anyone know how ?

zenith wyvern
#

No worries it's a lot of info in that guide

light mason
#

The tiny race example has a sub scene

calm olive
#

anyone know ?

zenith wyvern
calm olive
#

thanks

zenith wyvern
light mason
#

The sub scene remove was added?

#

And not the improvement

#

Seems backwards or am I missing something

zenith wyvern
#

Sorry I'm confused by the question