#archived-dots
1 messages · Page 193 of 1
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?
are D & E on a linked entity group on C? and A only contains B & C?
you can just schedule your dependencies as described here. https://docs.unity3d.com/Manual/JobSystemJobDependencies.html
anyone used IJobEntityBatch successfully? I keep getting nullreferences when accessing my batches in Execute(ArchetypeChunk batchInChunk)
hmm just to amend that, the problems are with IJobEntityBatchWithIndex but I dont get errors with IJobEntityBatch
unity offers 3d animation for DOTS/ECS yet?
@sullen dagger - yes, but the tooling is still in heavy development. I haven't messed with it but they have a dedicated DOTS animation sub-forum now: https://forum.unity.com/forums/dots-animation.583/
I suspect more features/tooling to roll out over the next year
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.
You can create your own WorldToScreenPoint method and sample the camera data before you schedule your job
That's what mine looks like https://hastebin.com/aqehemizix.csharp
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 ?
@north bay ah nice. thanks.
so [GenerateAuthoringComponent] just straight up does not work for ISharedComponent data or what ?
it doesn't. it only works on IComponentData and IBufferElementData (provided that it's just a single field)
for IShared and the rest, you have to make your own authoring component
can you explain the reasoning behind this? It seems strange
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
@north bay any chance you know what temp.w represents? 🙂
@north bay or alternative. a function for screenToWorldPoint ^^
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
@north bay thanks. will take a look 🙂
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?
Has anyone tried this (https://github.com/Unity-Technologies/Unity.Animation.Samples/blob/master/UnityAnimationURPExamples/Assets/Scenes/StressTests/PerformanceNClipsAndNMixer/README.md) or in more general has anyone done any performance tests with dots animation?
I just tried getting rid of the PhysicsShape and instead adding the PhysicsCollider after creating the entity and that works.
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?
Is there a way to create a joint in ecs from a system? CreateJointEntity() seems to require a monobehaviour as the first parameter
how i can find out which job causes this waiting? iam playing cluedo since 3 days >.<
check timeline view to see what job it's waiting for
@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
@amber flicker yeah, actually asked others to help benchmark it on other hardware https://www.shacknews.com/chatty?id=40239116#item_40239116
i think i used the hdrp version though? cant remember
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.
you mean the other gpu instancing anim repo by joachim?
Nah
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
i managed to get unity physics working with animation, for ragdolls https://gfycat.com/discreterawamericanshorthair
Nice
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 😩
What the hell is this (assertion failure in entity conversion... no idea what causes it)
you arent trying to use the serializeworld stuff?
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.
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
Appreciate it. Just wanted to try animating an entity skinned mesh with my dots tween library- animating the bones/entities but I guess I need to setup more than just how I’d animate gameobjects.
What causes scenesections to be created?
I don't do it deliberately
But it seems to crash internally while creating some in a subscene.
Well I guess maybe there is always at least one.
How can i change a colliders motion type from kinematic to dynamic in code?
kinematic bodies have 0 inversemass(i think it means its interpreted as infinite mass) and dont have a PhysicsDamping component
what is WorldToLocal? Just the inverse of LocalToWorld?
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 🙂
Edit > preferences > External Tools > generate .csproj files for : (and then you decide for what, toggle the top 3)
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.
@fading nest you can use the EulerRotation component
I think that's how it's called
na, things are constantly changing a lot, it's not always easy to find the docs
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.
Look up the transform system in the entities docs. It gives a thorough breakdown of all combinations @fading nest
@warm panther i've been using singleton entities for this, seems to be easiest
@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.
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
Anyone here using pure ECS on a project with a planned release?
the "20" classes don't inherit from SystemBase, they inherit from anything (usually MonoBehaviour)
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
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
Wouldn't that just be a component that multiple systems use?
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.
i don't exactly want all my entities to include that component
What data is this? I can't think of any data that would be shared across every entity?
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
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?
okay what i'm precisely making is a timer, other system update entities based on this timer value
Aaaaah, I gotcha
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
any reason why you can't just use deltatime tho?
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?
But all you need is the start time
You can calculate elapsed from that everywhere else
No you're right, you don't want to repeat operations in every system
so what i'm asking is where should i put that operation, if i'm not using monobehaviour
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
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.
exactly
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)
That seems like a better idea.
ah i see
That way you dont end up with 4 * n memory usage lol
Just keep in mind GetComponent can be expensive if you're doing it a lot
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
anyone know how to iterate other list inside the IJobParrelleFortransform job?
For more information on extending classes
i'll look into that as well
Just make a CalculateTimer method and a Timer property
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
Calculate it once in an update somewhere and then just Time.Timer
thanks for the help @thorn flame and @zenith wyvern
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
You would have to pass in the list to your job with the [ReadOnly] attribute
Monobehaviors are still very useful for things that don't fit into what a system should be
^. such as UI (for now)
ah i see, didn't make that distinction before
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
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
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.
it's only kinda slow on startup. but that's going to be the same even if you code your entities by hand.
If you're using subscenes it won't have any effect on your startup at all
noted!! thx ! but is it possible to do that ?
i did this last time and got me error
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
no , just a sample to show , im using NativeList
Then yeah, it should be fine as long as you add [ReadOnly] to the otherList in your job struct
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
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.
@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 ?
do you guys recommend using ecs? is it still going through a bunch of API changes and stuff?
Depends, and Yes
Hmm, I think type resistances could be realized with buffs. The simplest thing I can think of is to just treat them as stats and include them in your Stats component. That sounds like it might require a fixed damage formula in your system that calculates damage, idk.
There are probably more elegant ways to do it rather than just having a struct field for every type , but I got nothing rn.
@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.
Alright, thanks ! The problem i see here is that we cant simply call "recalculateBuffs" before the player attacks to recognize type resistances e.g. and apply them on the players stats... So the buff entities would always come in when its too late. Always after the attack happened :/
But probably there are other ways to tie in some sort of combat modifiers
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).
@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
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.
@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 !
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
?????
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.
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
Show the code and the actual error
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
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.
true, and I am thankful I am here early for it
There's going to be roadblocks and lots of undocumented issues, I would not mess with it if you're not ready for that
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
I doubt you'll find anyone here that doesn't wish they had better documentation
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
You're not. ECS is still in preview.
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
@thorn flame Okay, cool. Sorry for asking.
😦
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.
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
In this instance I don't quite see why the data needs to change? The weapon has an additional modifier to all e.g. cold susceptible enemies? Whether that 50% is evaluated (or the proportion applied) can be based on enemy stats - e.g. ala divinity, % weakness to cold
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
should I ask further Unity.Physics question here or in #⚛️┃physics
@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
if you can skip the middleman and the question is more about how do i generate a Unity.Physics collider at runtime, then the physics samples have some examples on that https://github.com/Unity-Technologies/EntityComponentSystemSamples
also either channel is fine but i guess you'd prob get more answers here if it's about dots physics
no, i was referring to the Struct ConvexCollider in inity.physics
thanks for the response
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
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)
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(...);
}
}
I suppose an answer might be to get the entire graph locally without using recursion and just electrify everything I reach in one swoop
Ah, I will look into this, thanks
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)
The problem with this, I think, is that connections are not currently 1-way
which is why I want something like this
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 🙂
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"
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
oh yeah my game will not be computationally expensive: mainly using DOTS for experience and the code being nice
what ui tools do you use for to accompany dots?
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
dear imgui bindings for c#/unity mainly (it uses MonoBehaviours for a setup so I pretty much just bridge it over like @low tangle)
same. my game is just a simple 2.5D game. There won't be any heavy compute too. at max the number of entities to move on a given frame is 4.
I dunno why I'm subjecting myself to this "learning experience" 😄
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
ngl. It actually made more sense to me to write a game in ecs rather than classic-gameobject.
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)
now I'm just waiting for DOTS UI, if there will be
doesn't seem to work with the pixel perfect camera either
Hm you could always overlay the ui using a second camera for it
I need UI but I don't want to touch UGUI if it's gonna be removed from unity anyway
relatable, I'll have more than 4 entities but otherwise exactly the same 😅
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
do you mean rendering the UI in high resolution, and layering on top of the low res pixel perfect camera?
native resolution yeah, you can still turn filtering off and keep all the visuals pixel art
is it possible to do text stuff with dots?
is there something like textmeshpro in dots
via hybrid or make your own
re earlier convo, found a related thread: https://forum.unity.com/threads/localtoworld-rotation-affected-by-entity-scale.882133/#post-6717394
thanks, wondering if im having invalid rotations and not realizing it now
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?
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?
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.
I see, it makes sense, will try to set it up this way, thanks 🙂
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)
Probably not the right chat... this is about the data oriented tech stack... #💻┃unity-talk #archived-code-general #✨┃vfx-and-particles are probably what you should look into 🙂
Wrong tool for the job imo. You can use particle system or vfx graph for such an effect.
2020.1.17f1 or 2020.2.1f1 for dots work?
upgrading from 2020.1.6f1 lol. looking forward to catching up
I'm using 2020.2.1, haven't had any issues
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
So I have got round to actually trying to implement this and idk now how to get access to an EntityCommandBuffer within a SystemBase job.
Do I initialise it in OnCreate or OnUpdate?
There's an example in the manual https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/entity_command_buffer.html
https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/entity_command_buffer.html somehow my googling took me here
I guess I need to bookmark the 0.16 manual
thanks 🙂
The blue button at the top will take you to the latest version too (if you're on desktop)
how may I use mobile inputs on unity DOTS?
I do in an asset that optionally supports ecs but I'm not sure if I can be of much help related to it.
I posted on the forum now, it's about this Unity parameter. It seems to work on 2021 but not on 2020
@scarlet inlet what is the issue specifically here?
if it doesn't work in 2020, it's a bug
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
Is it okey that i can't GetSingletonEntity() in OnCreate()? Unity telling that there is no entity with requested component.
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?
afaik no recursive searches, gotta handle it yourself
You should not query for entities inside OnCreate, OnCreate can be run before any entity is created at all, specially if it doesn't have DisableAutoCreationAttribute on it (which means it will get created with the World, which occurs even before the first scene gets loaded)
localToWorld gets updated inside TransformSystemGroup, and yes, it does a recursive search to update it
seems like something new to 2021, in 2020 we can create version defines based on some package existence, seems that now in 2021 we can have version defines for Unity version too, which seems useful
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
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.
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.....
the concept of a "root transform" is any entity that matches the query WithAll<LocalToWorld>().WithNone<Parent>()
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
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.
whats the difference between the entitymanager methods ```AddChunkComponentData<T>(Entity)
AddComponent<T>(Entity)
AddComponentData<T>(Entity, T)
AddComponentObject(Entity, Object)
- for use with chunk components - https://docs.unity3d.com/Packages/com.unity.entities@0.16/manual/ecs_chunk_component.html?q=chunk
- adds a component with just default /uninitialised values
AddComponent<Translation>(entity); - adds a component and allows you to specify its data(ie
AddComponentData(entity, new Translation{Value=new float3(10,70,3)}); - adds a class(reference type) component, such as hybrid UnityEngine stuff like
Transform
oh ok thanks
from a single Entity you are right, to know its root you need to go from parent to parent until you find one without parent recursively, but from a system just query WithNone<Parent> and gg
thank you 🙂
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?
whats the proper way to reference entities in ECS? so like... if you have a container full of items
you could have a buffer on your container entity. each element in the buffer would point to an item entity
I found this build configuration but I have no idea how to use it.... help? https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Assets/BuildConfigurations/Win64-Build.buildconfiguration
apparantly I need this for subscenes? I dont get it
Yep, if you're using Hybrid Renderer (Dont need it if you're using just plain Entities + Mono).
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
I'm not using Hybrid so I dont have anything in the list.
i mean
But if you are, you should see Win64.Build and so on in one
Yep
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
Hrm. Right, let me start up a new project so I can illustrate what I'm trying to do.
Yea copy that fourth asset
that's what it gives me when I double click the existing asset
or the asset I put in
same dialog
Give me a min, Unity's spinning up a new project.
I'm guessing I'm missing some package that has the UI editor for this file type
but I dunno what it is
Nah, Hybrid Renderer is enough
Also in that time, make sure you add unity.com.platforms.windows
to packages list
I did. i got that
Good.
ooo i havnt restarted unity since tho
lemme do that
editor shit sometimes needs that I forgot
ok now things are happening
should I need this one I linked? or is the default one good?
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.
Otherwise, nothing will actually be built. So you need to copy the configuration and be able to edit it.
ok I can edit it now. do I add my subscenes in here somehow?
Inside the editor with inspector?
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
Haha, no problem. I'm trying to get my packages in order as well.
I actually have no clue what the build manager window itself does.
if I do file->build, does it just use this now somehow? or do I start it differently?
I dont recommend touching it. Nah, not from file -> build.
how then?
ok
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.
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.
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.
Congrats, really simple but a lot of unexplained shit.
the subscene
yeah it's convoluted and not really easy to find
thanks so much!
ezpz now
No problem. That path took a few hours of googling and debugging back when I started. Hopefully you wasted less time than me.
yesssss I think maybe 40 minutes
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.
haha
🙂
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
Hey if you folks were going to make a flow field system in ECS, how would you store multiple grids (for multiple destinations)
Dynamic buffers
that's what I was thinking too. Groovy
Flatten your grid to one dimension and stick it in a buffer
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
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
blob assets are for immutable data for job threads to use
the analogy of them being scriptable objects for ecs is pretty apt
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?
you can have a component/buffer element with Entity fields
is there a faster way to copy a list of vector3's to nativearray<float3>?
Pass it into the constructor
And reinterpret
var nativeArray = new NativeArray(managedArray, Allocator.Temp).Reinterpret<float3>();
Any idea when DOTS is supposed to be deterministic?
current year + 1
or year when dots gets 1.0 + 1
(its not till after a 1.0 release iirc)
but when will get 1.0?
in 2 years probably lolololol
Us : So when will DOTS 1.0 be released again?
Unity DOTS Team : yes
I mean, DOTS is functional on the data handling side. Lots of changes coming up so it's not stable but it is functional.
Were you asking about cross-platform determinism?
Burst is deterministic across x86, just not between x86 and ARM, etc. yet AFAIK.
yes cross-platform determinism. for fighting games for rollback netcode
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.
We'd have to use fixed point to write our own physics engine which none of us is experienced enough to do
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.
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:...
I mean like rigidbody physics.
I assume to get frame-perfect, repeatable actions, you have to fake it.
wait what no why would you have to fake it?
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.
most fighting games fake stuff up to be deterministic in the players eyes.
i.e. when a character gets hit with knockback effect.
^ I assume you'd only need collision detection for hitboxes.
^ yes
What do you mean by fake stuff up? those games have, to deterministic to enable replay functionality no?
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.
I feel like everyone in the GGPO discord server would disagree with you
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.
Really
lol I'm not sure how to explain the distinction clearly, I mean, in the end neither will be cross-platform determinstic
but some of those games are cross platform.....? Street Fighter, Power Rangers Battle 4 The Grid
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.
Hmm ok, then what are the folks in the GGPO server going on and on about. They keep saying they built their own physics implementation because Unity's is not deterministic and stateless
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.
So would I write my own collision detection then or no?
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.
no its 3d
ah, well
3D?
well this is an example of tekken 7's hitbox.
so we'd have to create hitboxes, hurtboxes and collision without using PhysX?
yes
are there any solutions for this already done by other people?
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).
Quantum is $1000 USD per month
ooof
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.
We want crossplay between console and PC its a fighting game
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
Which forum to check?
I don't know, you'll probably have to ask in the DOTS forum. Maybe here: https://forum.unity.com/forums/dots-physics.422/, although this question isn't specific to physics.
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.
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'.
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?
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.
alright
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
That's what i'm afraid of
I looked at some tutorials and it looked rather complex
just for basic things
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. 🤣
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?
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.
hmmm
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?
DOTS stack will probably stay as a series packages.
which I don't mind but good lord, please add batch install for packages
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
damn i missed a good convo
new DOTS physics is stateless, and deterministic across same architecture cpu (including amd vs intel, assuming both 64bit)
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
We're only targeting pc vs console. From a marketing perspective we thinkit its very important
I do get it now though
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
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
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
Totally fine and generally encouraged I'd say.
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
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.
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
I don't think there's many bad practices in ECS currently, its all new so do whatever works
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...
I don't see why not, if it works it works, just be aware OnStartRunning can seemingly run more than once sometimes
just use onupdate, if there arent any matches for entities than the system doesnt run and theres zero overhead to it.
yeah and you can use RequireSingletonforupdate if necessary
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?
You can make a completely empty entity. RequireSingleton only checks if the entity with the component designated exists in the system.
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
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?
well kind of bad practise in the larger sense to use a monobehaviour if you can use a system instead
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
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.
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.
oh
I wouldn't say zero overhead, it certainly starts counting once you hit a few hundred systems. But it's pretty low.
my inactive systems show as 0.00ms on my profiler in the editor, and things are far faster in a build 🤷♂️
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
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?
about that, there is an official answer on the topic:
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
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
respect for finding that, I hadn't seen them talk about it. not for awhile anyways
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
also UpdateInGroup has two extra bools that are OrderFirst OrderLast which help too
[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
Every time I try to use that it keeps throwing annoying exceptions all the time
Well it's been a while, maybe it's better now
Do you use subscenes at all btw?
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
Gotcha. I'm curious to hear if anyone actually uses them. They just seem very bad with the whole ConverterVersion thing
oh ok. thanks
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
I recently started using them too to avoid having to use hybrid renderer which was performing hilariously bad with just a single dynamic mesh
yep, I haven't touched hybrid in a long time because of how slow it was
Very convenient to just be able to query directly for a meshfilter
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
Using subscenes for all conversion these days. The only problem I encountered so far is that sometimes the conversion messes up and you have to clear your scene dependency and restart unity until your component finally appears in the subscene. But overall the subscene workflow is pretty solid.
what kind of game?
Also the converter version thing is pretty straight forward when you get used to it
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
Ehh
Incrementing the version forces all subscenes to be reimported
Reimport "should" work
how difficult is it to serialize worlds in ecs? (for saving loading)
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
yeah, to reach 2k systems I imagine it would be something super complex like Horizon Zero Dawn or Zelda Breath of the Wild
@warped coral I was literally just doing that yesterday for my roguelike - it's dead simple as long as you have no managed objects
oh cool
Basically as straightforward as you'd expect
how do you do it?
Just call serializeutility.serializeworld
The .deserializeworld to load it and it "just works"
Again, as long as you have no managed objects
does that still fully replace the world contents?
I'm not sure, I cleared my world before I did it
Not sure if you can do it to a non empty world
I think the world has to be empty for it work at all
yeah, thats what I ran into awhile ago
That's why you have that 'streaming world' setup
you can use a temp world, and merge from it, but I remember the transaction causing issues with my old setup
nvm. i think i understand now
are you serializing any blobs @zenith wyvern ?
Yeah you create a separate world tondeserialize into then do MoveAllEntities or whatever
Nope I don't use blobs in my roguelike
ok, well might be issues with de/serializing there using serializeworld
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
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.
also i wouldn't use serialize/deserialize world for saving/loading, that's really easy to break
it doesn't have any versioning so when you update your game you might break existing savegames
or if a player runs into a bug that infinitely duplicates a particle effect in your game, their savegame is now forever broken too
2nd one is fixable by only cherry picking save data into a seperate world and serializing that but still doesn't have any versioning
oh
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?
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.
alright will continue down the path i was going and maybe look a bit at dots stuff out of sheer interest thanks dude 
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.
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
@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.
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.
is it expected to see this much garbage from FixedStepSystemGroup?
sure it's 1KB but it's frequent
@deft stump turn off leak detection, safety checks etc
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?
@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
Stuttering normally means that the prediction of the client is not in sync with the server simulation. How are you moving your ghost?
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
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
@fair stirrup what is leaking?
I've extended SystemBase to simplify the fetching of the ECB
Just less code rewriting
Mesh data
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
you use ECB when you need to do structural changes
GCHandle.free() doesn't seem to work for some reason keeping mesh data around.
Depends on when you want the changes to occur, CommandBuffer is as the name suggest just a buffer to execute stuff later
Yeah right structural changes, been a few weeks
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
Ye
You also need to include the PredictedGhostComponent in the query to only iterate over components you have authority over
Absolutely
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
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
@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
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.
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
That was just it. It works now. Thanks!
I've just snooped the dispose method to see whats going on. The CommandBuilder doesn't seem to be getting diposed.
Are you using it in editor mode before or after play?. I'm trying to use it before play in tooling
both
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();
hmmm
I can suspect it has something to do with not being in playmode because it works in playmode.
obviously the += isn't required then.
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
For me it starts to bottle up in DrawingManager.instance.gizmos.meshes after looking into the profiler.
Thats using WireBox.
is this still same as that doc snippet code?
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();
yea that looks fine
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
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.
How are things in dots land? Any proper 2d support that is not the hacked together hybrid renderer yet?
@opaque escarp you can store the JobHandle and check for IsCompleted every frame. An alternative option that I personally recommend is using UniTask (https://openupm.com/packages/com.cysharp.unitask/) for those kind of stuff
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
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
I'll give it a shot, thanks
I'm not seeing the Hybrid Instancing checkbox on shader graph, is there a setting I have to enable with Hybrid Renderer V2?
Nope lol
still hacking away XD
Project Tiny has 2D support with proper entity sprites no less
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
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;
}
}
Don't you need to call AddJobHandleForProducer after your jobs though? I could be wrong about that
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 😉
What is this channel for?
does int2.zero does new int2(0,0) underneath?
similar to vecto2.zero?
Surely you can look a the source
I forgot it is on github
It's also in your project
if you have it imported
https://github.com/Unity-Technologies/Unity.Mathematics/blob/master/src/Unity.Mathematics/int2.gen.cs#L27
It's just using the default value
As soon as I add an entity field to my ICommandData I receive this error
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)
why not just... ref the scene object in a class ICD?
You can put that class ICD in empty entity
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.
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
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
Agree but we know they’re working on prefabs/addressables so hopefully they come up with a good solution
@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.
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.
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();
Yeah i know that, at least for NativeArray. Is it overloaded for NativeList as well ?
list.AsArray() returns the underlying native array. It doesn't do any copying
So it will be as fast as nativeArray, no significantly more memory and burst compile enabled ?
Correct
Cool. What about NativeArray Temp allocation inside a job. Is it acceptable to do so ?
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.
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.
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
Also as I understand it is fast because its memory is not unique for each job and not flushed every frame. So If next job writes something to Temp, previous content could be potentialy still be there instead of being zeros, which could lead to some bugs like Aliasing if you do your code wrong. I might be wrong.
Could be, I don't know how it works at a low level honestly
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.
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
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 ?
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
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 ?
No. I know at least NativeArray and NativeList are fine to allocate inside a job. The rest you'd have to see for yourself.
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.
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.
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 ?
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;
}
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
The full source for all packages in your project are in the packages folder in Unity
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
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
Anyone tried dots with 2021.1?
For a long time now, yeah
Haven't had any issues related to 2020.1 that I can think of
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 ?
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
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
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
That's what I did for this https://github.com/sarkahn/dots-blockworld
Oh so i am talking with a right person 😄
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
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?
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
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
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
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 ?
Yeah. In that project a chunk was 16x16x16, so it wasn't too bad
Early prototype using minecraft like mesh. Billions of blocks
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
16x16x16 was a single chunk, obviously in game you would have many many chunks loaded around a player at once
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 ?
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
I. Hate. Unity.
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...
anyone know if there's an up to date getting started for DOTS physics? When following this page, Convert to Entity (with convert and destroy set, as in the diagram) removes the game objects...not sure what the difference is with Convert and Inject, if I'm doing something incorrectly or if this doc is just out of date: https://docs.unity3d.com/Packages/com.unity.physics@0.0/manual/getting_started.html
Best place IMHO are the unity ECS examples.
thanks!
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
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
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.
Just tested that and it also doesn't work for me
It works fine on rpcs tho
Okay so maybe they meant only RPCs for now
Shame that authoring component doesn't work for a dynamic buffer of entities
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.
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
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
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
I honestly can't undestand how to see how many archetypes I have
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
I guess it means that it's fine? seems like
Yeah that looks right to me
I spawn exactly 2k entities
Are you using Hybrid Renderer "v2"?
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
so my only real option is moving to unity2020?
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
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
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
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
thanks for tips @zenith wyvern , I will try to install 2020 later and check how is it working there with hybrid renderer.
No problem - don't forget to read up on the package docs: https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.10/manual/index.html#v2 You have to add a scripting define to get v2 working
Are you profiling using the entity ddebugger? Good chance hybrid renderer is simply waiting for physics to finish its work.
Oh good call. The timeline in the profiler should make it pretty clear if that's the case
Anyway: check the profiler timeline, it shows bottlenecks properly
what does dots mean
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
with ecb.. since it doesn't have entitymanager.setenabled(), i can just use ecb.removecomponent<Disabled>() and it does the same right?
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?
Do need to bother with guid's with sharedcomponentdata?
or should i just fetch a timestamp?
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...
Did you check the profiler timeline?
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
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
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
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
this "package management" reminds me strongly of npm
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
Try making a new project with your current version and selecting the "URP" template if you haven't yet
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?
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
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
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
2020.2 doesn't run at all on my computer
oh well
I guess this tech is too raw at the moment
re 0.17 (or whatever version it'll be): "At this point we're basically waiting for teams to update their respective packages for the core packages published at the end of last week. At this time I would still expect to release by Friday." https://forum.unity.com/threads/entities-0-17-changelog.1020202/#post-6739324
I wonder if the changelog they provided is still accurate
beyond the release date they put that top that is 😉
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?
@neon pewter did you see that ? https://forum.unity.com/threads/solved-issues-with-dots-editor-package.887056/
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.
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 😕
I don't think there's any link from the component to the entity
Since a component is just a struct
Yeah figured thanks, probably best to just store the component data instead of the entity in the buffer
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?
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.
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
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.
Is there other methods of communication than Command Buffers, ghost fields and RPCs?
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
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?
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
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!
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
Yeah that could be interesting. Well thank you for the guidance I'll try a few things out 😄
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
Is there a detail quick startup doc for project tiny building to webGL ?
Something simple like a cube spinning
Can I not use IConvertGameObjectToEntity in projectTiny?
Preview 0.31- DOTS Runtime & Project Tiny: Getting Started Table of contents Document Change log 4 What Is Project Tiny and DOTS Runtime? 4 System Requirements 5 For Development 5 For Runtime 6 About Linux support 6 Filing Bugs and Providing Feedback 7 Getting started: use Sample Projects 7 ...
Lot of useful info there
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.
Have you tried the entity editor package?
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?
That happens to me all the time..
Super annoying
i have not. I will now tho thanks!
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
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
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
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
hi
O man
Playing in the editor is being worked on, but even when it works it will just be building behind the scenes
Ok well I missed that part
does anyone know how ?
No worries it's a lot of info in that guide
The tiny race example has a sub scene
anyone know ?
@calm olive Not really the right channel for it, you should ask in #💻┃code-beginner or #💻┃unity-talk maybe
thanks
Yeah you can still use subscenes if you want to, but I would guess they just didn't bother to update all the old samples after they removed the need for subscenes in the latest versions
The sub scene remove was added?
And not the improvement
Seems backwards or am I missing something
Sorry I'm confused by the question
