#archived-dots
1 messages Β· Page 199 of 1
the one highlighted cries for it
Hmmm did I misread CommandBufferSystem ? Yes, yes I think I did ^^
Closest I've got to building and running sample projects has been
Loading Entity Scene failed because the entity header file could not be read: guid=46b433b264c69cbd39f04ad2e5d12be8.
guess I'm not playing with Project Tiny for now.
Alright, so it's codegen'ed and looks more related to command serialization than a commandBuffer...
netcode doesn't seem to work unless at least one player has a CommandTargetComponent... If it does then all clients work, otherwise no clients work... wtf...
Does it have to be a player? Can you generate a test entity with that sole component?
I think that might be caused by missing the windows SDK dependencies they list as requirements in the getting started guide. At least it was for me.
Disclaimer, no clue what I'm talking about.
lol i mean maybe I dunno
I was just thinking that I've been here a few weeks and still only understand about half of what gets said in this channel.
You wrote it in the file you shared : GetSingleton<CommandTargetComponent>()
Hmm. Is it a specific one? https://i.imgur.com/LfdybsK.png
client 0 doesn't change. client 1 spawns in, box and player appear on client 0. client 1 spawns out, box and client disapear. multiple clients work tine too
System Requirements in the google doc doesn't seem to specify which Windows 10 SDK is needed
Don't think so. Maybe double check you're including all the correct assemblies in your "root" assembly too, and not including anything that references unityengine
@pearl pulsar
client 0 spawns immediately on my side (as server/client) lemme make a build and check when another client joins
I'm guessing I just ALWAYS have to have a command target somewhere in each client
reading thru docs now to see if there's anything obvious but, I'm going to set it to an empty entity instead of null and see if that works
I guess after connect yeah
unless you want network vizualisation only
why not hehe
I guess I assumed it wasn't a requirement but apparantly it is
even if you don't have commands, you have to have some CommandTargetComponent or it sends nothing to any client
assuming I"m right
which I dunno
odds are I'm not
To store commands in the correct buffer, each connection has a CommandTargetComponent which must point to the entity where the received commands need to be stored. Your game is responsible for keeping this entity reference up to date.
yeah sounds like it's required...
technically the buffer is used for everything not just commands I guess?
Before the component is added to the connection, the client doesnβt send commands, nor does the server send snapshots.
yes
that one I got workin rite
got that on every client always, spawned in or not
aight no more insight in docs. ima try it
Doesn't appear to be the case. For example I'm taking a look at Tiny2D and it's just a simple rotation of a picture as far as I can tell. The components and systems seem to only reference Unity.Entities, Unity.Mathematics, and Unity.Transforms.
For reference:
https://github.com/Unity-Technologies/ProjectTinySamples/tree/master/Tiny2D
I guess I can go see if another Windows 10 SDK installation magically solves the problem. π
I would dumbly go for the last one ?
I assume you have the other bizarre requirements installed? Desktop C++ and .net desktop from visual studio. Also make sure you have all the platforms packages installed and up to date. From what I remember those are pretty much all the obscure things I had to fiddle with to get Tiny to stop throwing weird errors
Yeah 19041 seems like the most likely one to try first. Gonna reboot and try again real quick.
Desktop C++ and .net desktop from visual studio
Believe so, yes. That's from the more-general list in Visual Studio installer, right? Had those already existing.
https://i.imgur.com/dt7uzhH.png
Also make sure you have all the platforms packages installed and up to date
IIRC only a couple of seemingly unrelated Unity packages had a version bump (e.g. Test Framework)
Oh and if you have subscenes try building without them, I remember just giving up on trying to use subscenes solved some weird issues I was having
The joys of preview
Seems like a pain
Yup. I eventually had to give up on tiny when I hit a project killing bug that they don't seem to be in a rush to fix. I wish otherwise, being able to use ecs/dots on a web game is pretty cool.
There is a SubScene.unity in Assets\Scenes but I'd be surprised if that was root cause since this github example was updated 9 days ago to update samples to 0.32
You could try it without it just to see, subscenes aren't necessary anymore in Tiny
yeah but don't delete it, right ? Unpack GOs from it
yeah I like to state the obvious
Sark, is there no way to build ECS for web without Tiny?
Not that I know of. I tried it using the webgl build configurartion recently on my 2D game and it kind of worked - stuff rendered, some systems worked while others didn't, and it just threw lots of strange errors.
Like stuff was drawing to my terminal and I could move my player around but for some reason my monster ai systems just didn't work at all, while everything works perfectly fine in a normal build
Hmm. I'll need to look at that because I just sort of assumed you could build to webgl.
If it works for you let me know
Roger dodger.
Getting some various SDK plugins for Windows 10 and removing the subscene hasn't gotten me any further. I think I'll just call it for now. Thanks for the help @zenith wyvern !
Rip. No worries
how do I create an entity inside a query that I can save on a component? If I use EntityCommandBuffer.CreateEntity() it says the entity is still deferred (it's created, it's just my component has the deferred value that it was at the time I saved my component) and if I use EntityManager.CreateEntity() then the compiler complains that I'm not allowed to make structural changes (even though I specify WithoutBurst() in the query). How can I get this to work?
Let me get this right. You want to create an entity inside a job that is then set as a parameter inside a component data?
For the entity manager bit you need to use WithStructuralChanges
awesome. that'll do. thanks
(this one is just run once on startup so it's no biggie)
Also WithoutBurst if you plan on using EntityManager itself inside a lambda function.
Although with both .WithoutBurst().WithStructualChanges, you practically made a for loop.
yup. that's fine
WithoutBurst is implicit when you use WithStructuralChanges I thought
I got withoutburst already. oh that's good to know sark
Nope, you must also include WithoutBurst().
ok i mean I have both for clarity anyway
I never use the EntityCommandBuffer, so slow and cumbersome.
so you just always use WithStructuralChanges?
how else would you avoid it?
I seem to have to put it everywhere...
It's necessary if you don't want to force one or more sync points in the middle of your update
Not to mention you can't make structural changes inside burst
If you need to add, remove, or create entities or components, you must use WithStructuralChanges or use a ECB. Try to minimize doing the mentioned actions.
yeah. I get that. I'm just starting out tho so lots of creating initially hehe
not much processing so far
I guess I'll see less of it as things go on
buffer.Playback(EntityManager); still makes a sync point tho rite?
Yea, for my initialization, I've made an extension method to chain together calling entity manager methods. Makes reading through the initialization code easier.
ah gotcha. nice
If you use WithStructualChanges, you dont need the ECB. Just use EntityManager directly.
At initialization, it doesnt really matter. In the middle of runtime, definitely less sync points.
π
Also, if you're making all the entities inside a system base, make sure you add Enabled = false; in your code or else the entity creation will happen again. InitializationSystemGroup is not OnEnable like Mono but more akin to Pre-Update.
i been using uh
RequireSingletonForUpdate<Init>();
EntityManager.CreateEntity(typeof(Init));
lol
but enabled is probably less lines haha
Really you should be using conversion for all your initialization stuff if possible
Hrm, that's actually a good idea. Wow, I never use Hybrid renderer so I never thought of the conversion stage.
can you put ICommandData buffers onto things with conversion @zenith wyvern ?
for netcode?
their examples show doing it with code, not cconversion
You can set up an authoring component that will attach whatever you want to the entity being converted
Although I haven't messed with netcode really so I can't say if it's the best way to go
the command target needs to be linked for netcode. I"m not responsible for authoring that
then I need to link the ghost that netcode creates, etc
Yeah you can plug in another gameobject that's going to be converted, and it will properly link up the resulting entities
Assuming you do it right
uhhhh what
But again I'm not sure how to integrate it with netcode, if they don't use conversion in the examples then maybe there's a good reason for that
yeah cause all the ghost stuff is like created from the server programatically
Yea, looking through the conversion documentation, it seems a bit rough. https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/conversion.html
then it just pops up in the client and... it's not like any authoring runs at that point
it's just the ghost that was authored before. I still need to update things
that being said... this empty entity that I"m making, I could author it and find it and link it instead of creating it in code here you're right
just seemed easier this way for now. but I'll probably change it to authored
it's a good point
still need to change lots of components and stuff or w/e
but maybe that's more normal
thanks
SourceTree by https://www.sourcetreeapp.com/ is from altassian, i try to checkout
localhost
clone to local https://github.com/Unity-Technologies/Unity.Animation.Samples/tree/master/UnityAnimationURPExamples
Can it take only the sub-Folder of Git-Tree?
UnityAnimationURPExamples
From: https://github.com/Unity-Technologies/Unity.Animation.Samples
yes
Can it take only the sub-Folder of Git-Tree? no. taking a subfolder out of the repo is a more complex operation than a clone. if you just want the files, why not just download the repo as a zip?
all, but it took long to download, i read if there is a folder to take all list, but than specify a folder
Unity.Animation.Samples/UnityAnimationURPExamples/ <-- this sub-folder only instead of all?
in your desciption is only goto file! https://github.com/Unity-Technologies/Unity.Animation.Samples/tree/master/UnityAnimationURPExamples
there is no copy to clpboard download but only go to file!
because of Unity-Documentation: This repository uses Git LFS to track resources' files (models, textures, etc.). You will need to install Git LFS
Restarting SourceTree, shows this again, does this tool work?
This repository uses Git LFS to track resources' files (models, textures, etc.). You will need to install Git LFS and clone the repository to get the files. If you download a ZIP, the files will not be included and the projects will not work.
checked x Recive submodules
Anyone know a good solution to draw line between object in tiny
Like connecting nodes is a good example, but in game
Wrong guy?
almost, if you dont know that, else you now it, good (enter the matrix was funny doday someone sad about DOS (freedos hwinfo) hwinfo32 ), dots is not dos! https://4.bp.blogspot.com/-dhn6qFVgN90/WDQu_0IrqsI/AAAAAAAADw0/tKWsKXFvQsggEMPw6ELWgQq6Te5a0nxRwCLcB/s1600/CaptureHWINFO.PNG
Heh. I dont use Git or version control. I live on the edge of my hard drive failing. It's going to bite me one day....
@ocean tundra is there a data type for xnode so i can connect nodes not by value type? I just want to connect them
you doing right real HDD, i have detected that github does fake-modify Fbx!!!
From ellen.Fbx: Kaydara FBX Binary !!!into-non3d-model!!!-->
github invalid Fbx: version https://git-lfs.github.com/spec/v1
oid sha256:878d200bceaf875151f8a989aa79cc3e2c8104c941fe12442b17196918016adb size 1559856 http://www.freedos.org/images/screenshots/640x480/freedos12.png F R E E D O t S
Anyone ever tried using chunk splitting using shared components to isolate entities and share data (using chunk components)?
addressables
Do they work with the Job system?
As a note, I make my entities purely from code. My gameobject hierarchy is literally nothing.
why not, they are like old bundles
Quick google search says it's for gameobjects to group data. But I'm using pure entities and Burst is a very sensitive thing.
I'm going to try it. Splitting chunks by grouping positions then see how bad the performance is. Unity has so much warnings against using shared component data that im terrified.
I believe addressables is yet to work with DOTS in a seamless way
how can i Schedule a job so it runs on every thread?
Im reading/writing to NativeStreams and the beginforeachindex is set to the threadindex
Oh the dots event system just loops over every index.. i guess ill just do the same
On onld pc some shaders are not working, instead calc by cpu!
Entity = 3d model, Components = textures, System = animation/animator state machine
I want to set the world position (think transform.position) on an entity with the DOTS Transform system that has parents, do I really have make somehow use matrix transformations using LocalToParent of every parent in the chain every time I need to set the position? I can't directly set LocalToWorld since it's overwritten by the builtin systems
@solemn ice na just set Translation on the parent
if i remember correctly as long as your system updates after localtoworld you should be fine
localtoparent sorry
i think you just want to be before the TransformSystemGroup
if your after it will caculate the children next frame
but then I have to set it every frame, it will get overwritten every frame after that since the Translation and the LocalToWorld won't fit together, no?
And there's other children, setting the Translation on the parent is not the best option
translation is never overridden
I know, so I have to set Translation, not LocalToWorld, and Translation is the local position, and I want to set the global position
translation is whats used to build the localtowold
the world position of what?
a parent?
I want to set the child's world position
can you just make it a parent?
Just a quick question, what is the current 'state' of dots, last time i looked at it was around september-august. Has it improved at all since then?
Not really
I can't set LocalToWorld since the Translation won't follow, I can't set the position I want directly in Translation, so my only option seems to make some kind of transformations using the parent's LocalToWorld or something like that. That or just not parenting my objet at all
What improvements are you looking for?
i too was away for a bit (6 month) and no real changes
@shy pilot thats like a blink of an eye in dots time π₯²
its a bit more stable, and seems a bit easier
mmm
when i last used it i got pretty far in but kept having problems with the editor itself, all the dots related editor tabs and even the unity services stuff just broke completely
I think the editor stuff is getting a bit better in my experience. Less random exceptions and they actually have documentation for conversion now
Editor workflow is still really awkward, but it's less broken in my experience
anyone have any ideas why this works?
I have a system that uses GetBufferFromEntity<TYPE> ... Job....
Then another system that uses EndSimulationEntityCommandBufferSystem command buffer to ADD that buffer TYPE to entitys that dont have it
It was failing loads untill I set the first system as a dependancy of of the COmmandBuffer System (AddJobHandleForProducer)
restart unity 2020 but now it takes like forever on dots project
EntityCommandBuffers are very sensitive. I recommend you dont use it. What struct are you enqueueing? Is it simple like a float or int?
Na its pertty complex
Did you upgrade? Dots does not like upgrading.
You're using GetBuffer inside a job?
Outside and passing it in
That's why
really?
You're creating a main thread dependency on your buffer
so i should do it in the job?
You want to pass in a BufferFromEntity along with whatever entity, then get the buffer inside the job
Yeah
Well, you can just call GetBuffer, that will do what I described above
But there's a bug where it can't be readonly, so I usually pass in a BufferFromEntity manually
omg how do you send code in discord π
Surround it with triple backticks
three tildas, located to the left of the one key, shift that key.
π
thought it was 1
var translationBuffer = GetBufferFromEntity<TranslationClientCurve>();
Job
.WithReadOnly(idMap)
.WithCode(() =>
{
translationBuffer[ENTITY]
//use buffer
Oh, you're getting errors from that?
What's the exact error message
EntityCommandBuffer was recorded in AutoCurveAllClientSystem and played back in Unity.Entities.EndSimulationEntityCommandBufferSystem.```
Ah, it's a dependency issue.
So ClientReadStreamSystem = that system
AutoCurveAllClientSystem is the system thats adding the buffer to entities using command buffer
Yea, that doesnt work. I'm going to need to see the entire OnUpdate code to restructure it so that it does.
Are you sure you're doing AddJobHandleForProducer in the buffer system?
@zenith wyvern yea i am
@robust scaffold trying to think of how to simplify it a bit π its kinda crazy
At the end of the buffer system's onupdate?
@zenith wyvern yea its at the end
i even swapped that system into Run to see what would happen
run is immediate right?
Yeah
Yea, just screenshot the entire code. I have some time to restructure it. It cant be as bad as the nonsense I'm trying to pull together.
@robust scaffold your gonna regret that but sure π
Not sure what it would be then, I use command buffers all over the place
Please don't screenshot a bunch of code in here
Use hatebin
Oh true, this isn't a personal dm, yea copy paste it elsewhere.
sorry if it dosnt make much sense
the issues are the bottom system the top one should be fine
Right, give me a sec
so all the dependency management is for the evil native streams, I have 2 worlds (Server, Client)
Server writes data into the streams, Client reads
BUT they are different worlds so need to manually pass JobHandles around
these systems are client
Ehh, it doesn't look like you're using your system's dependency property
You need to combine any related dependencies with that so the rest of the framework handles dependencies properly
that makes sense...
i guess ill try combine them all into Dependancy and see how it goes
Yea, nothing out of the ordinary except for the fact you aren't tying in Dependency.
from my understanding passing a dependancy into Schedule will ignore the built in Dependancy?
oh
that would probably cause that system to be scheduled with my Server world and not in time correctly with the client world
Nope.
Job.WithCode().Schedule();
// Equal to ->
Dependency = Job.WithCode().Schedule(Dependency);```
Just add in Dependency to JobHandle.CombineDependencies(). Although I cant guarantee the problem will be fixed. Im glad I dont need to work with multiple dependencies.
god it sucks
:p
just combineing dependancies after schedule helped
now im back to trying to use those NativeStreams
That's good. Good luck with all that. Sounds like dots netcode.
π
no its my own
i should probably rip down netcode and copy how they do some stuff
i had a version working with native lists
should have stuck with them instead
Unity.Animation.Samples\UnityAnimationURPExamples\Assets\Scenes\Introduction\Scorpion.scene
Forgot to set clear to sky?
I've got to say, using ISystemBase and Bursting everything has given me such a feeling of euphoria. Despite the fact that all my tests, it does not effect framerate at all.
No, it was with layers dispos now, compress of chrome fails, but if you open as new image in new tab it looks ok https://cdn.discordapp.com/attachments/497874303463850004/806768134987972618/output.gif
So the scorpion URP example converts a RigComponent to a Rig ECS component. But what if I want to create a Rig ECS component directly? I know the Unity DOTS Animation documentation is sparse. Is it currently only possible to come to terms with it by parsing through the package or am I missing a Scripting API document somewhere?
If I have a ref type with a IComponentData array, can pass this to a job somehow?
Same here, the editor is messed up
mmm, good to see i'm not the only one, happened for me after copying from one computer to another via usb
I didnt check yet what it looks like, but you could create your own component directly yes. From your own conversion system, or pure ECS. Again, I don't know what needs to be inside
There will be this of course https://docs.unity3d.com/Packages/com.unity.animation@0.9/manual/index.html
But for now yeah, better look at the samples, dig code in the PackageCache (Tests if they done it), and follow the related subforum
And scripting API here if you like to guess https://docs.unity3d.com/Packages/com.unity.animation@0.9/api/index.html
Even if you use the UpdateAfter attribute on the system, you need to also combine dependencies for the job, right ?
Sark doing god's work and making DOTS particles
yes, [UpdateAfter] is just the order that the system executes
Alright I see, thanks π
@zenith wyvern thatβs pretty neat. Got more?
Nope, those were it for my rough first pass. I got a basic framework to expand on and a simple circle emitter
Dots continues to impress though, it can easily handle hundreds of thousands of particles in less than .5ms
Is your project a side-scroller?
He's making an ascii roguelike if I'm not mistaken
What are you working on?
Thank you for the links to the documentation also. That's where I'd landed, just browsing through Unity.Animation.Hybrid source. π
Me ? Exploring the state of netcode and physics to assess if I will be able to make a game or need to wait/switch solution.
I'm interested in other packages also like animation and dataflowgraph, but didnt have a look yet
and of course Tiny, but seems way early like you experimented yourself
What was your opinion of netcode?
from the start in unity we been threading-unsafe unsure, does the gpu cores of 1024 get to handle a gameobject each a zombie, other cpu 8 cores for player environment and physics, no it does not dots beta
I still need to push it, but like all previous Unity netcode solutions, it lacks a lot of features (for now let's just assume it's early, let's see where they go with it). Looks really promising to me for the future, hope they make something of it
Not so helpful of an opinion I know. I just move forward optimistically until I'll eventually meet a no-no blocker one day, or achieve the prototype I am aiming for, whatever comes first
And of course if you dont like boilerplate, it's too early, but hey if you're following DOTS you're already crazy like us
dots is not for productions use, we schould keep in mind (ecs, burst, c# c++ jobs)
I've been wanting to build an alife sim in Unity and DOTS seemed like a great way to boost entity counts while allowing for systems-based emergence. This is my first brush with Unity. I don't have a production, I just figured I might as well come to terms with it in Preview since I'm learning from scratch anyhow.
both burst and jobs are production ready, just ECS that isn't
Great π
Well you'll hit another wall: AI (if you want to go the dots way too) Unless you're ready to implement it yourself.
Why not go hybrid ? a MonoB game, and use entities and jobs only for heavy computations
Alright didnt see your last sentence π
You're eager to learn like us ^^
Most of the experimentation/playing I want to do is going to be with AI and ML, so I'm fine building most of that from scratch since I likely would be anyhow. And as for why not hybrid? Because I'm less worried on getting the project done than I am learning unity (and DOTS) in the process.
π Yeah, mostly I just think DOTS is shiny and I want to peck at it.
Ever since updating to 0.17, my game will grind to a halt for a second or two the first time a mesh is loaded. Specifically, it is when a prefab entity with a RenderMesh is instantiated as a non-prefab entity for the first time. Anyone know what's going on and if this can be avoided?
Did you try using the subscene workflow ?
If you're sure you can reproduce with same project between 0.16 and 0.17, file a bug report ?
(or forum thread)
No, haven't dug into subscenes yet. Was planning to eventually, but for now I'm doing manual conversion (GameObjectConversionUtility) when the game starts. I'll try to to revert to 0.16 and reproduce this. Just curious if this was a known issue already. Thanks for the quick response!
Yeah try it for heavy geometry count. Subscene serialises into disk a quick to load in RAM format. It could improve. But I guess you're not supposed to have 1 sec loading for only a mesh.
Maybe someone else will share experience with mesh loading
@whole gyro Exaclty what part freazes up?
When you do something like em.instinate(prefabEntity)
OR
GameObjectConversionUtility.ConvertGameObject (probably wrong spellings/words )
i have a question i was wondering if someone could help me please
In tiny, im using TextLayout.SetEntityTextRendererString() to draw some text
how do i deactive the text
do i just delet the entity from World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName()
ive never used tiny, are you trying to destory or hide the text/entity?
yes
do you think of having a public variable, than drag and drop it, and in process deactivate
π that was not a yes no question
i have that var
but im using it like this
if (draw.MyText)TextLayout.SetEntityTextRendererString(EntityManager, nodeCountEntity, $"Hellot {x}");
but i guess i should not even create the entity ?
should i grab my draw entity as singleton and then if true do World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName()
wow tiny is way different
in normal DOTS i would try to find the entity and add a disabled tag to it
EntityManager PostUpdateCommands.AddComponent<Disabled>(entity); //.WithEntityQueryOptions(EntityQueryOptions.IncludeDisabled) https://forum.unity.com/threads/is-there-a-way-to-disable-entities.671458/
ok let me try that
does systemBase still have postcommands
was that removed or renames
renamed
you need to get the commandbuffersystem
ah
so in oncreate do World.GetExistingSystem ....
then system.createcommand buffer
and after your code
system.addhandleforproducer(dependancy
got it thank you
what system should i use
is there an end of render sys
Im guessing i do not want this in the EndInitizatoinCommandBufferSystem
probably end simulation
theres a start and end for each of the built in system groups
presentation grp
so yes
ok good to know
basic stupid question, but how do I set a single value in a componentdata without changing the other existing variables
var tempflowfuld = tempdestination;
tempflowfuld.DestinationCell = treenumb;
tempdestination = tempflowfuld;```
so you can't do it like that?
nope
well you can but need that em bit
basicly theres a HUGE difference with how the data exists, STRUCT vs CLASS
so you need to get/construct the data then use EM to set it back
the annoying thing about that though is I have to have two separate getsingleton one for the entity and one for the componentdata
yeah I know struct is by value
I just wish there was a way of getting the singletonentity from the singleton component
isnt there a GetSingletonEntity method??
yeah but that's what I mean it's a separate call type thing
I don't know what I'm saying I guess it doesn't make much difference π
yea would make sense to have a overload with a out/ref paramenter
doubt it makes a big difference tho
tempdestination = GetSingleton<FlowFieldData>();
tempdestination.DestinationCell = treenumb;
SetSingleton<FlowFieldData>(tempdestination);```
it seems like that's the best way
yup
It freezes during Instantiate. I'm instantiating using an ECB, not the EntityManager directly. Not sure if that matters.
@whole gyro can you share some code
Using a ecb vs em shouldnt matter
as long as its already converted
Sure! Here is the instantiate code:
Entity previewBelt = commandBuffer.Instantiate(_beltPrefabSystem.GetBeltPrefab());
commandBuffer.SetComponent(previewBelt, position);
commandBuffer.AddComponent<PreviewTag>(previewBelt);
Connections connections = default;
if (_gridSystem.TryGetEntityAtPosition(position, out Entity existingBelt))
{
connections = EntityManager.GetComponentData<Connections>(existingBelt);
}
commandBuffer.SetComponent(previewBelt, connections);
and what does _beltPrefabSystem.GetBeltPrefab() do?
It returns the prefab entity that I create in _beltPrefabSystem in OnCreate().
hmmm
so not doing any work in _beltPrefabSystem.GetBeltPrefab()?
and that above Instantiate code, is it in a OnUpdate directly or withing a job/entities.foreach?
I just tried rolling back to the previous version of hybrid renderer (and entities, burst and dots editor due to dependencies) and confirmed that the issue is new in the latest packages. I'm going to try and repro in a smaller project.
The code for GetBeltPrefab:
public Entity GetBeltPrefab() => _basePrefabEntity;
And instantiate() is in OnUpdate() directly
@ocean tundra Just to clarify my problem, I don't think it is from the call to Instantiate() directly. The profiler shows the freeze in the hybrid renderer code, but I believe it is on the frame that the entity was instantiated. The call stack shows stuff related to updating batches and adding chunks so I assume it is some kind of setup work that hybrid renderer needs to do for the new mesh. And I also assume that the hybrid renderer skips doing this work for prefab entities since they don't need to be rendered.
yea makes sense
i was just wanting to rule out the simple stuff
is the model/mesh/material anything special?
and does it happen with EVERY new belt? or just the first? or only after the world is 'busy' (lots of other stuff to render)?
Just the first frame that a given mesh needs to render. All other frames after that are very fast
The mesh has 2900 verts, 2800 tris. No idea if that is special haha
π neither
I'm using shader graph for the materials. Don't think I'm doing anything too crazy in those though
it only happens 1ce per mesh? even if you have many entities with the same mesh?
Right. I'm making a factorio-like game if you're familiar with it. So first time I need to place a straight belt, freeze for 2 seconds. But from then on, all straight belts can be instantiated and rendered extremely fast. But now if I need a corner belt, it will freeze again for 2 seconds and then all future frames are good again
yea makes sense
(also love factorio)
your guess sounds right to me
something todo with a new mesh/material needing processing (maybe upload to gpu?) by hybrid renderer
Actually, that's a good point! I was using straight and corner belts in my example but it actually doesn't quite happen like that. The straight and corner belt use the same material. Whichever I instantiate first, I get a 2 second freeze. But the once I instantiate the second one, no freeze. However, when trying to instantiate a different mesh with a different material, I get the freeze again. So I think the issue is something with the materials/shaders.
Agreed
i dont have anything like that happening in my tests atm
but also im not instantiating anything
yet
are you using URP or HDRP?
it used to be that the item would just render pale blue if the shader was compiling
but that was like 7 months ago
Yeah I remember it doing something like that at one point, but in magenta
hmm, found something about preloaded shaders in unity's graphics settings.
You said you're manually calling with ConversionUtility? Maybe try with IConvertGameObjectToEntity?
That only works for game objects in a scene, right? These are prefabs.
I do plan to switch to subscenes and I could also try IConvertGameObjectToEntity, but I was first trying to see what the issue is. This is a new issue for me with the latest packages. Was working fine before that.
Well you can store the entity version of your prefab on a component so it's "preloaded", then you can query for that and instantiate your entity prefab, but I'm not sure what your setup is exactly
The prefab entities are preloaded. In other words, they are converted when the game starts and exist as prefab entities in the world. That all works great. But I only hit this freezing issue later on when I first try to instantiate the prefab entity.
When you call GetBeltPrefab, is that when you're calling into conversion utility?
Ahh okay
Yeah, that just returns the already converted entity
Hey All
What Native container would people recommend for Parallel Producing and Consuming messages (Custom structs, usually about 3-4 fields but could be more)?
I've tried with NativeStreams but I'm having major issues with its whole BeginForCount thing
Oh well theres a NativeQueue, Parallel Writing but single reading i think
Hm, looking at all my IJobChunk structs, I now see why people like the ForEach lambdas. Writing chunk.GetNativeArray(ComponentTypeHandle); over and over again along with a for loop does get tiresome after the 30th struct.
So you didnt get tired by the 29th time?
A man knows his limits.
So ECS recommend instantiating an entity from an archetype. But RenderMeshUtility only accepts entities. So I'd need to create an entity prototype, use RenderMeshUtility.AddComponents(<entity>,..) and then instantiate copies of that entity. Which is not the pattern ECS recommends. Am I missing something or is there a way to attach a RenderMesh directly to an archetype?
You should be instantiating entities from prefabs
If your prefab has the rendering components that conversion expects then it will get the rendermesh stuff on it automatically during conversion
With the authoring workflow you shouldn't need to manually piece together components in code outside of your conversion scripts
I know you're right. But where you see "shouldn't need to do this entirely in code" I see "but wouldn't it be cool if I could do this entirely in code"
I'll seek help. In the meantime I'll go make a prefab.
I definitely think it makes sense in some cases. Like for my particles thing I set up a builder pattern so you can say ParticlesUtility.MakeEmitter().WithEmitterRate(x).WithColorOverTime(a,b)...etc. But it was very annoying to set up, and I would only go out of my way to do something like that if you're sure you're going to be making variations of The Thing in code regularly. Otherwise just use a prefab, it saves a lot of time and is very customizable since you get to use the editor to tweak stuff
Can you provide a screenshot pf the profiler for a frame that hitches? Would be interesting to see
what is the fastet way to get an Obj.IComponetn[] to a NativeArray
var newArray = new NativeArray<MyComp>(len, Allocator.TempJob);
newArray.CopyFrom( OtherArray);
You can pass the managed array directly into the constructor
var newArray = new NativeArray<MyComp>(OtherArray, Allocator.TempJob);
like this?
ah yea , works , had typo
thank you
Hello Void, he posted that one earlier #archived-dots message
Thank you @karmic basin . That looks really strange, no work getting done at all during that time. @whole gyro do you think you can submit a bug for this? Would really like to see what it is waiting on during that period.
Hey all,
I love DOTS and ECS (entities). But I'm a bit worried about how long it might take for DOTS to become stable. Are there parts that are more stable than others? E.g. am I safe to use ECS but should I avoid things like the DOTS physics system? Very hard to find any info or news, which is not encouraging to begin with.
Welcome - I think the broad consensus would be that Jobs & Burst are safe. Everything else (ECS, physics, animation, subscenes) are all quite experimental.
Hello, Im pretty new into jobs system, and I would like some help, especifically for using variables into a job
How can I use a string inside a job?
using this gives me an error public string enemyTag = "Player";
You can't, I would look at FixedString struct
it stores the bytes of a string - so you can do something like, new FixedString512("Player")
Alright, thanks you, Imma look into that
For my own clarification/knowledge on the topic, Jobs are separate from the Systems part of ECS because systems are meant to run per-frame, while jobs are meant to be long-spanning and relatively asynchronous to the game loop. Is that a correct grocking of the differences?
they are seperate because they were developed seperately, ECS didn't exist when the job system was implemented
but also generally jobs are meant to be short and happen over 1 to a few frames
nothing stopping you from running a long spanning job but they're not really the best at that
if you allocate with jobtemp allocator it does for sure but if you don't use that I'm not sure
Yep. SystemBase.OnUpdate() executes on the main thread.
From them, you can schedule Jobs, which will scatter the task on your chunks to your multiple cores. So you get multi-threading.
Also, you can .Run() immediately, .Schedule() or .ScheduleParralel() your Entities.Foreach() or Job.WithCode() lambdas.
jobs are both for short running and long running stuff, be it something for less than 1 frame or a long running operation, I see them as "C# Tasks in Unity way"
the main capability of Jobs over C# Tasks is the Burst compatibility
Ahh, makes sense
if you don't need Burst, you probably don't need jobs neither
That makes a lot of sense. Thanks guys!
so im in the tiny time example and trying to swich off the time text entity
everytime i try add a Disabled IComponent it errors
is on main thread
TimeEntity = World.GetExistingSystem<ProcessUIEvents>().GetEntityByUIName("TimeText");
EntityManager.AddComponentData(TimeEntity, new Disabled());
is this not supported or am i doing this wrong
what is the error
well that the problem w tiny
can run in editor and in crome debug the stack is not anyting you can track
cant
How to run system in edit mode and query a converted subscene? Is this even possible?
The system below is created in editor world but has no access to subscene entities
[WorldSystemFilter(WorldSystemFilterFlags.Editor)]
public class DebugRenderingSystem : ComponentSystem
{
// ...
}
Does it make sense to use ComponentType.ReadOnly<T> for Entity Queries?
Yeah
But... in what context. π Because I can get an entity and just make EntityManager write to the component anyway.
I mostly use EQs in mono space, in burst systems I use the internal ones.
Is there a way to use the more event based solution?
I'm currently trying this, but whatever happens in the performed block doesn't get executed
I was missing this line π
protected override void OnStartRunning()
{
input.Enable();
}
@warm panther I've personally used them to get a query's entity count, and to set shared component data in batches, which I believe doesn't cause the chunks to move around
Yeah I use them for that a bit too but... I don't understand the way readonly even affects the query itself.
I guess one reason is if you call ToComponentDataArray
I'm submitting a bug report now through the help menu in unity. Let me know if there is another way I should be submitting this instead. Thanks!
In theory yes. You can assign a function as a listener to your actions inside a system base.
thanks for the repkly @deft stump
What did you do here? Also sorry it's always you I @, it's just you who's most relevant all the time π
My 2D entity
Do you have dots physics package installed?
version 0.6 preview 3 yes
Hm. Try using Physics Body and Physics shape components directly instead of having them be converted.
They'll still be converted but the values are more 1 : 1 with the Entity rather than some redirection.
Ah, nvm. You're using RigidBody and Collider 2D.
Those dont work.
DOTS only support 3D. You can kinda fake 2D by clamping the Y axis ( or another axis depending on how you orientate your ground ) but the stability is shaky.
Right
Stability in that the object literally shakes and vibrates as it moves with friction.
That's a shame, because I really like ECS and the jobs system π€
Unless you want to implement your physics with optimized spacial lookup and collision mechanics specifically in a 2D world, you're out of luck. It might not be too hard... kinda.
Grab your nearest decompiler and look at how Havok is doing, then remove one axis.
Reinventing the wheel sure but it's the only way you can get 2D to work in DOTS.
I mean, I suppose rolling my own is the only solution π¦
Or use Tiny with it's half implemented engine.
Tiny has kinda full 2D physics but you're missing a massive chunk of the engine as well. But there's 2D.
There's also the hybrid method, ditch Hybrid Renderer (it was a mistake to begin with) and manually translate whatever happens in the game object world to Entities.
Use all the solid built in physics provided by unity as movement and rendering code, far better than what DOTS has anyways, then do all the computation and data crunching with entities, then pass anything relevant back to Gameobject land. You'll have to do that anyways if you ever think of making a UI.
That gives me headache to think about at 1 am
Do you have articles handy you could share?
No articles. Anything you find will be largely outdated unless they're really specific and very abstract that can survive major version bumps. I'm just talking from a few months (or is it years now) of experience working with DOTS.
Not too hard anyways. You can use SystemBase for everything anyways. Gameobject is a static class and fully functional in DOTS SystemBase main thread. You just dont have the fancy editor inspector variable assignment. You can use a bootstrap monobehavior for that.
Can you describe what a non hybrid renderer would look like for ecs?
Lets say you have a GameObject cube named Cube you want to move forward with at a speed located in a Component.
In the OnUpdate(), you get the cube's transform (standard Gameobject transform, not DOTS) using GameObject.Find("Cube").transform.
Then use a GetComponentData<SpeedComponent>(entity) and use the speed value to compute the transform like it's regular monobehavior.
Fairly inefficient for a lot of cubes but just one, two, or even a dozen, it'll be more efficient than using Hybrid Renderer.
It's also good if you have a lot of computation going on behind the scenes like a simulation with a lot of entities that ultimately reduces to a single property that you can then set on a single or a few gameobjects.
The overhead of Hybrid Renderer is massive and only pays off if you're thinking about moving and rendering hundreds of entities. At the low end of double digits, manually translating Entity data to GameObjects are more efficient.
In between those ranges, that's profiler and whatever you wish or plan to do.
You can just use conversionSystem.AddHybridComponent on a mesh renderer and mesh filter and it will give you built in rednering attached to an entity that you can query for and syncs position automatically
my game is 2.5D sooooo I don't think my game will be relevant to you.
but what i do is.
I use Hybrid for the Sprite Renderer.
then just use Physics Shape for the collission detection.
if you want a full on 2D approach you're gonna get creative with Phy Shape
There's also IJobParallelForTransform that relates to Gameobject transforms. No clue how it works though.
a job that works directly to the transform of the object. it skips the process of copying back to the transform in a normal job
for example:
a normal job:
native array = array of positions.
process job
array of positions = native array.
ijobparallelfortransform:
some special container for transforms = array of positions
process job
It also requires an array of pointers to the transforms. I've never touched unsafe so it'll require some experimentation on my part to see how to get it functional. Also unity has repeatedly tried to deprecate and remove it but the forums reliably pull out pitchforks and torches to stop them.
I believe you don't need pointers
The short blurb when I type it in with my IDE shows void*. Might just be how unity handles the transform in the background instead of ref.
I believe the container is called TransformAccessArray
@zenith wyvern how do you handle animations in your 2d roguelike?
My "World" ultimately gets rendered into a single mesh - the terminal. It's just a mesh layed out in tiles. So swapping out a "sprite" is just a matter of changing the uvs for a single tile.
For a more general solution you could try something like the old "thousands of sprites" stuff we were messing with a coupleyears ago on the forum, one guy has a somewhat up to date version of it. https://forum.unity.com/threads/1-million-animated-sprites-at-60-fps.811116/
So if an entity occupies a space, you swap the tile for that entities' tile?
If I were to do something like that today I would probably try to use hybrid renderer to render quads and swap out sprites with per-instance uv data using the built in hybrid renderer instanced ecs components
Yeah. My terminal is fast enough that I can clear it and re-render everything whenever state changes and it's barely a drop in the bucket
If I have a mesh in my assets folder, how do I get that asset assigned to MeshFilter?
Any idea?
When it needs to re-render it does a kind of "back to front" thing, so it clears, sets uvs for terrain, then sets uvs for characters and items, then ui
Conversion.
And by "conversion" you mean go look at the conversion code and see how it does it? π
I mean set it up as a normal gameobject so it will get converted into an entity that renders, make it a prefab, convert that to an entity prefab, and instantiate that at runtime
I know, I was being stubborn because I want to do this entirely in code.
Without a smooth workflow to get an asset into an ecs friendly representation, it's kinda awkward. Easiest way would be to load it with Resources.Load, then set it on your RenderMesh.mesh
Resources was what I was missing, thank you.
I just couldn't figure out how to tell Unity to look in the damn folder for that mesh.
My only reluctance against prefabs is that I'm working towards an alife simulation and I'd like to allow entities's limbs to define their own meshes based on genes. I don't need any real fidelity, the lowest-poly representations will suffice, but I would like to know how to define and render meshes entirely via code for that purpose.
But right now for testing I just want to plug in some prebuilt meshes for testing
I assume you're aware of how bad hybrid renderer is at rendering lots of entities with unique meshes?
Basically every set of entities that shares a mesh and a material will get put together nicely in chunks for faster rendering. Any time you change a mesh or material on entity, it will get put into a new chunk
Fine at a small scale, but if you're talking thousands of entities with unique meshes it's going to get real rough
I'm talking more on the order of ~200 unique meshes and maybe 10,000 entities
You should profile but my feeling is it would be really slow with hybrid renderer and you may want to look into gpu instancing
I'm looking into it now. Am I understanding correctly that it requires a GameObject?
Not really, you can use compute buffers and DrawMeshInstancedIndirect/DrawMeshInstancedIndirectProcedural, neither of those actually require a gameobject, they just take your mesh data and your per-instance-data and render. Although in the end you're still going to have to do one call for every unique mesh
No idea if that would be slow or faster than hybrid renderer
I guess I need to go try to understand hybrid renderer better so I can appreciate the difference. Thanks for giving me the heads up though.
Is this hobby or profession for you?
Hobby
What's your day job?
That is super cool.
My day job is nothing to do with programming sadly
Your experience with the unity APIs seems pretty robust. You been doing this for a while? π
Yeah, many years
Awesome. Well thanks for answering my questions. Do you have any specific resources you recommend in terms of coming to grips with Unity and DOTS
I always answer that question with the github samples and manual. The samples especially helped me really put everything together. The advanced samples are maybe a little too advanced but there's a lot to learn there
Awesome, that's what I've been going through. Have a good night. Thanks again.
Hi all,
Is there a way to get all collisions in a scene? (instead of handling every individual collision in OnCollisionEnter, etc callbacks) As I understand it the physics engine calculates all collisions, and then calls these callbacks. Is there a way to get them at that stage?
I'm following an ECS approach for some things in my game through DOTS/entities but I'm trying to avoid the actual dots phsyics/rendering stuff as it's not stable yet. So I do want to process all collisions in one batch, but I don't want to rely on DOTS/physics.
From what I've googled it doesn't really seem possible with the regular phsyics engine? That would kind of surprise me.
(asked the same question in #βοΈβphysics but though folks here might have ideas about this too :))
Yeah so that's a shame because the com.unity.physics package gives you acces to the broadphase with all colliding pairs in a Job you can "subscribe" to. You can also write your own HitCollectors π
But the legacy one I never looked. Heard it is pretty shy about the internals... :/
I'm trying to avoid the actual dots phsyics/rendering stuff as it's not stable yet
For now I'm pretty happy with it. Especially the determinism part vs physX. Can't say yet I'm amazed until I push it hard, but I love it.
Only for now I don't like the response to trigger and collision events, which are very verbose (so yeah lot of boilerplate that could easily get broken in the future).
I must admit I've seen some jittering and teleport shenanigans here and there some times, but could also be only me messing with the netcode and system ordering parts.
DOTS Physics isn't open source, is it?
All DOTS is to be open source
Soonβ’οΈ
you can search your Library/PackageCache
Seems like non-DOTS unity development really tries to shoehorn you in OOP :/
It seems so odd to me that there would be no access to the broadphase
Well, I'm strangling OOP with my FP
I mean, like 99% current Unity API
Which still isn't great with DOP
I am however pretty satisfied that I got this working:
#nullable enable
#region Usings
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine.InputSystem;
#endregion
public class InputHandler : SystemBase
{
private PlayerInput input = new PlayerInput();
private Movement? movement;
#region Handle Input
protected override void OnCreate()
{
UnityEngine.Debug.Log("Test create");
input.Player.Move.performed += Move;
input.Player.Move.canceled += StopMovement;
}
protected override void OnStartRunning()
=> input.Enable();
protected override void OnUpdate()
{
float deltaTime = Time.DeltaTime;
Entities
.WithoutBurst()
.WithAll<PlayerControllable>()
.ForEach((ref Movement move) => {
move = movement ?? Movement.zero;
}).Run();
}
#endregion
#region Controls
private void Move(InputAction.CallbackContext context)
=> movement = context.ReadValue<UnityEngine.Vector2>();
private void StopMovement(InputAction.CallbackContext context)
=> movement = null;
#endregion
}
It's nVidia tech behind, maybe that's why. But again, that's how far my knowledge goes on the matter, so don't listen to me
π ooooh new input system with ECS, nice ! it's on my todo π
It was actually much simpler than I thought it'd be!
It's clean, I like that
well I say that, but I spend the entirety of yesterday to make it
Doesn't matter, you know how to do it now π
It's clean because I made Movement to be cursed
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
[Serializable]
[GenerateAuthoringComponent]
public struct Movement : IComponentData
{
public float3 Value;
#region Operators
public static implicit operator Movement(float3 value)
=> new Movement() {Value = value};
public static implicit operator float3(Movement movement)
=> movement.Value;
public static implicit operator Movement(Vector2 value)
=> new Movement() { Value = new float3() {x = value.x, y = value.y, z = 0} };
public static float3 operator * (Movement movement, float value)
=> movement.Value * value;
#endregion
#region Static Members
public static Movement zero => new Movement() { Value = float3.zero };
#endregion
}
next in my todo is collision detection and comments
yeah implicit operators help a lot here π
What do you mean by "comments" though ?
You think my code is self documenting?
lmao I thought a "Comments System" ^^
Yeah don't really need comments as such. Understood it at a glance.
gtg eat, have a nice day
thanks for the feedback, I'll make a gist with my system
make it public please. I wanna compare my solution with yours
if I remember, I'll share the gist once I arrive at my destination
Hello all. I have a question that i really find it hard to find any information on the documentation.
How can i make a custom made World object to render ?
This is a little bit puzzling.
hmmm I should have written this differently. sorry for that. I know how to use the default world. But i want to use a custom world to render. Is this even possible ?
You would have to make sure your custom world has all the systems that hybrid renderer requires to work
Oh. hmmm Sorry to ask again. Where can i find these requirements ?
An easy way would be to get all the systems from the default world and add them by type to the new world
Or maybe there's an easy way to just copy an entire world, not sure
@ebon narwhal make sure to switch to latest version. Click that blue button on the topbar
oh damn you are right.
I do it all the time. I'll start searching the docs for something, have a "why can't I find this thing I know exists", and realize I'm on the old version.
I bookmark the latest link https://docs.unity3d.com/Packages/com.unity.entities@latest
and from entities you have quicklinks on the left menu to other packages
I'm probably being stupid as usual but what am I doing wrong with the below code, is it just not possible to set componentdata this way, I'm sure I did it before? π
var TempCelldata = CellDataQuery.ToComponentDataArray<CellData>(Allocator.Temp);
var tempcell = TempCelldata[i];
tempcell.bestCost = 100;
TempCelldata[i] = tempcell;```
mmm looks fine as long as you assign temp cell back onto an entity. tempcelldata is a copy no?
CellDataQuery.CopyFromComponentDataArray(TempCellData)
That's it that's what I was forgetting I have to copy it back after the job right
awesome, it works, Thanks Sark
Sark you brought up Hybrid Renderer vs GPU instancing. In the Hybrid Renderer docs, at least for V1, it specifies that HR uses GPU instancing. I don't see anything about V2. Can you elaborate on why I'd want to avoid Hybrid Renderer in favor of GPU instancing?
V1 did use gpu instancing,v2 doesn't. Gpu instancing just gives you a "simple" way to render thousands or millions of a single mesh. I haven't really measured it against hybrid renderer but it worked well for the sprite renderer stuff we were doing a couple years ago.
I would go with hybrid renderer first and see if it works out
I was thinking the same thing. I'll deal with performance problems when I encounter them. I've been in the planning/tooling stage for too long lol
I'll proceed with HRv2 and just see how well it works for my needs before I go finding more windmills.
really? why did they take a stepback from GPU instancing?
I'm not sure. They replaced it with all the batching stuff which is barely documented
Is there way to access an entity by its index directly in jobs (readonly)? ECB does not provide this kind of API.
I'm trying to implement iterating over entities and also need to access their "adjacent" siblings. So I store indexes of these adjacent entities as components
Why not store the entity themselves?
Entity is a struct.
You mean its copy? They're heavy
An entity is literally just two ints
It's expected and common to store them in components for referencing other entities
Entity is an index. Contains the actual index and version number.
Unity uses that struct (2 ints) to index a component array
So you mean that I can just write like this?
struct Something : IComponentData {
Entity next;
}
Yep
Perfect. That's even better
100% intended. Unity also has a special way of tracking components with Entity properties for serialization and deserialization. Havent tried it personally but somehow it can be used to save worlds, even if the entities dont line up. Unity keeps track.
But how do I access its component in jobs? afaik i cant use entity manager in there
Okay. Thanks
Can you explain what you mean by "even if the entities don't line up?"
I havent tried this myself but according to unity, the order of Entities (their indices) are not guaranteed to be the same once undergoing the process of serializing and deserializing the world. That's why they created a bunch of systems to handle entity remapping: gametorrahod.com/entity-remapping/
I just keep chuckling at how many "oh, and also..." moments I keep running into with Unity DOTS.
I've given up on Hybrid. I will render my entities by hand, Drawing them on the screen at 120fps myself.
I got my sharpie and nail polish removal ready.
What was your pain point?
Base SPF (seconds per frame) ~2.0ms. Hybrid with blank screen: ~6.5ms. What.
Hence, I draw the entities myself (learning compute buffers one painful tutorial at a time).
Took me 5 hours but I finally got a rotating triangle rendered on the screen.
lol that was me last night. Trying to figure out how to create and render meshes by hand
via code, I should say
Yea. One half is learning how meshes are created. The other is learning how Graphics.DrawProceduralIndirectNow works. The method is very sensitive and seems to stop working the second I sneeze in the wrong direction.
Doesnt work in SystemBase unfortunately. Only works in Monobehavior's OnRenderObject
So if you want to use SystemBase, are you locked into Hybrid Render?
No. Just use Mono for rendering and pass inbetween.
Is it even possible to render with ECS without hybrid? Using Graphics.DrawMesh?
UPD: After reading the whole thread, I got it
I've been doing some testing and it actually seems like hybrid renderer is a lot better than it used to be at handling lots of dynamic meshes. It's been a long time since I tried it but before it was like comically bad compared to gameobjects, now it seems pretty comparable in a test scene with ~500 entities all with unique meshes that get changed every frame. It seems like it still won't scale well to crazy high numbers but it's at least a lot closer to gameobjects now in terms of performance.
I would not give up on HR. Especially if you have other walls to break elsewhere in your project: just focus on those meanwhile. Bet on the future. HR v2 is where Unity wanna go for now, expect performance to go up. What's the point spending 2 months circumventing it when they'll put a new release after you, and you put all that time to the bin. Focus on your game, not completing the engine on their behalf (unless your game is finished and you're just waiting for the tech ?).
At least that's my point of view π
When they push a release, you refactor/migrate and earn the performance boost. Meanwhile you kept progress on solving your problem
/building your app
From what they said before, imo sounding more like 2022 at the earliest (year not Unity version)
................
my day is ruined
I'm forever disappointed in Unity
time to ask WSB to buy Unity stocks to speed up DOTS development
Is Unity even publicly traded
it is
also @deft stump did you stare at my implementation? π
yes. it said my implementation sucks.
I like yours better than mine
mine has so many roundabouts
π
Is any part of DOTS production-ready?
I have been using other ECS systems for the past few years (Entitas to be exact) and would like to use the Unity ECS but it seems to be super unfinished.
I'm super curious
If it's not too advanced what you need, like 2D physics, then DOTS is perfectly fine
Unity ECS is still unfinished.
but
you can use jobs and burst fine
I'm not very interested in the performance aspects, but more in the architecture/design pattern aspects of it
I do need 2d physics.. and I would not consider that advanced tbh π
Is there any rough estimate on when v1.0 will be out? I don't see any public roadmap
lots of workarounds even if you want to use 2D physics
how is the usability of ECS so far? from what I saw it looks like a lot of boilerplate is still needed to set-up components and systems
Putting entities on gameobjects is like 2 minutes tops
Just add the [GenerateAuthoringComponent] attribute on your components and you're good
Once you get the hang of components and jobs, it's really not all that different from MonoBehaviour
are there big in-editor performance improvements from the burst compiler? never tried it
i mean the workflow from change in code to entering play mode, basically: are there improvements in the time this takes?
it's slower? π² wtf
yeah it makes sense, my biggest problem with the current project is that the time from code change to playtesting takes >20 seconds
but that's not even that much from compile time but mostly from assembly reload time, which is something else entirely
any estimate on when DOTS will be production-ready?
like, 1 year off? 2 years? 6 months?
Honestly, I don't know
I find the API still being a little volatile, so if you plan to release tomorrow maybe hold off
But if you plan to release in a year, I don't see an issue with implementing today
no one really knows
we're alll fiddling with our thumbs
as unity doen't release a roadmap
on what to expect
I'm thinking of either making my game 2.5D or make my own collision detection plugin for DOTS
the latter would use some raycasting
nah i'm just finishing up a big multi-year project that doesnt use DOTS but I will start a new one later this year and I'm doing research on what to use and what to hold out on
but it seems like i've been waiting on DOTS progress for years (from the sidelines) and it's gotten very quiet, looking in from the outside
just hope it doesn't get half-assed like many other features. i really love DoD
there's progress, you can see that from the changelog
It's just anything like "look at my 3 million entities at 60FPS" so that may be why it's silent
did any of you use Entitas ECS and can tell me how Unity ECS compares to it? I have been using Entitas for years and my gut-feeling says that it has way more syntactical sugar due to its code generation (both pro and con imo)
I think as of 2020.2, only the assemblies that actually need recompiling get recompiled. i.e. if you use asmdef's properly, it should be improved. Also please check you have the following checked. (None of this is related to DOTS - dots won't improve this iteration time).
The caveat with the enter play mode options is you have to be careful if you have much going on with statics around your codebase.
yes, i had tried to change the enter play mode settings in my existing project but i am using way too many static variables and can't be bothered to manually reset those for it to work
but i will definitely use this on the next project!
Yea, much easier from the start of a project and super nice.
i have a dream: make a change on a sizeable project and playtest it in <5 seconds. that would be my absolute dream and it would make game dev so much more fun. and there was this blog post by joachim ante (i think) a few years back that said the same thing. i just really hope that this will be achieved soon!
As for v1.0, @deft stump is correct - nobody knows. Including Unity I believe. They're taking the time to "do it right" so expect it to take quite some time. Unlikely to be this year, maybe not 2022 either. Very hard to say.
I've heard making seperate assemblies can speed that up
yes, as impatient as I am, it's probably better that they don't rush it. especially if they want to build their entire future architecture on it and eventually get rid of MonoBehaviours and GameOBjects entirely
like... "HEY! this is our plan for the next 6 months!"
If they could just make their trello board public
I don't really care when v1.0 will be released.
at least give a roadmap
like... "HEY! this is what we have done, this is what we need, and this is how fast we generally are"
a believable one
Input System v1 recently got released, so I'm hopeful
yes, that would be super great. i am really frustrated with the state of unity because it feels like there are so many good things on the horizon but the state right now is full of half-baked non-solutions like the terrible animation & cutscene systems, monobehaviour and no real go-to architecture solution, wonky UI systems etc.
at least we have scriptable objects π
Talking about LiveLink ?
It's there, but undocumented
what's livelink?
I think @merry fossil was including code changes.
Tell me more? π
Still takes some time to boot up on first connection and kinda slow last time I tried
people are doing cool stuff with scriptableobjects:
https://www.youtube.com/watch?v=6vmRwLYWNRo
https://www.youtube.com/watch?v=raQ3iHhE_Kk
also, Unity Atoms
Get the assets here: https://bitbucket.org/richardfine/scriptableobjectdemo/
This session goes over ScriptableObject class in detail, compares it to the MonoBehaviour class and works through many examples of how it might be applied in a project.
Richard Fine - Unity Technologies
Scriptable Objects are an immensely powerful yet often underutilized feature of Unity. Learn how to get the most out of this versatile data structure and build more extensible systems and data patterns. In this talk, Schell Games shares specific examples of how they have used the Scriptable Object for everything from a hierarchical state machine...
What you think about I think when you talk about Joachim prez of editing realtime in the editor, and having a build kept open, reflecting changes realtime
re communication, you're certainly not alone in wanting more transparency: https://forum.unity.com/threads/dots-sentiment.956936/
The prez from 2016 is awesome and hilarious π a must see yeah
@karmic basin ah, is live link that thing they demoed on the big DOTS talk a while back? where you change stuff and it's immediately in the live builds?
gotcha
Yes, they showcased it in the DOTS FPS sample IIRC
For the tween/anim lib I'm building I store the authored animations as SOs - whenever they're changed the entities get rebuild - meaning this should allow livelink to near-instantly preview changes to an animation timeline (sorta old ref of what I'm talking about here: #archived-dots message) - for non-code changes, workflow should be near-instant in a lot of cases if you set things up right.
to be honest, i really don't get how most people are building their games in unity at all. if you just follow "the unity way", every non-gamejam-game desintegrates into an absolute clusterf*ck of singletons and monobehaviour-hell. there is NO recommended architectural solution at all. DOTS is a good way forward and all, but again it seems to me like they're mostly focused on performance and scalability, like everyone wants to make a game with 60 million little soldiers.
the MOST important decision i make as the sole programmer of my team is how I will structure my game's core architecture. if I screw this up, even slightly, by using anti-patterns, singletons, statics, coroutines all over the place, it has repercussions that take up 90% of my dev time very quickly.
there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.
for me, i'm pretty sure that ECS is a pretty good baseline that at least prevents some huge mistakes i made before, but we still don't have a functioning framework that's production ready in the biggest game engine on the planet, and it's 2021.
every non-gamejam-game desintegrates into an absolute clusterf*ck of singletons and monobehaviour-hell.
to be fair... I tried using interfaces... and I'm like... why am I using this? when I could just split it into another component
yes the "unity way" is bad, but I don't think it's fixable at this point
that's part of why I'm glad they're basically startingover with ECS, it's not just a way forward in performance but also architectural
there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.
I'm with you there brother. as much as I like the freedom there's no one true way to properly write in classic unity. and because it's so "free" it ends up being a paralysis of which x and y do I use today
to quote from a certain anime "when you know everything, you can't do anything"
Hey, same in software dev, that's why you have Software Engineers, to think about Architecture.
I for one welcome our ECS overlords!
I also really love how the ECS forces one to architecture the game!
But honestly
there have to be many people like me that suffer silently from the absence of good foundational advice about how to setup game architecture, and I have pretty much gobbled up all the talks and blog-posts i could find about all of this.
I get where you're coming from, but Unity is great if you got some computer science fundementals
Actually the "unity way" (the legacy one) is not bad at all. It's components based, but people don't understand that and try to force-feed OOP concepts down the engin throat
And DOD is a design pattern, you can still mess your architecture π
I'm so happy to learn scriptable objects exists!
@karmic basin so you mean I can stop using interfaces?
Interfaces are great
Easy!
struct PlayerMover : IComponent
{
public float3 Value;
}
struct EnemyMover : IComponent
{
public float3 Value;
}
Actually I would have the same Movement system for player and enemy,just one from input, other from AI. But hey depends a lot on your game
aaaaaaaaah hahaha my bad
still though...
I am still confused on project tiny's existence
why does that thing exist?
Yeah your input system was great @rare dew
Here's my personal implementation
I should put it on my blog
Hm
@karmic basin do you need ad space? π
this is going to sound rude, but thats overly done
It's cheap
a input system is just the place where you gather your inputs into a struct, then stripe it into your desired input component
That's uhm.. that's what I did?
I assume its because your integrating with input system v2?
It's actually v1.0.2
most people I saw using that we're using a manual polling example that was posted to the forums a year ago
I personally don't like polling
I mean, v2 as in, not the old legacy unity Input.GetKey* functions
Yes; new Input System
well ecs is all about polling, and inverted polling where its activated by the input data set
Well in the old code it just did in Update or FixedUpdate eventually
also minor tip, if you remove the null coalescing you can use burst on the foreach lambda
oh? π
which will flatten that code down to a struct copy only - as long as you default set the movement struct
so that's the issue, ty!
I got a Movement.zero I'll just use that
you will need to capture it right before the foreach, which is where you could keep the nullable coales
or move it like that, better idea
Movement v = movement ?? Movement.zero;
outside the foreach,
inside
move = v;
then remove the withoutburst and you will gain a insignificant amount of performance
feel free to profile it
But imagine thousands and thousands of controllers!
Lmao
It's just cleaner to have burst
well it does tune it to the simplest form, which is just a data stripe from a source input struct
I mean, what if I get to talk at Unite 2021?
which can be fed in from anywhere
Gotta have something to make the audience clap at
HOLY S*** HE MADE INPUT BURSTABLE!
OOOOOOH MY GOODNEEEESSSSS!
show thousands cube spinning. Instant clap

Lol
Works like a charm, now with burst!
I'm a little sad however that I can't hook the new input system on a Component, so I can have some more composable control of players
If anyone knows of a way to do this, besides
struct ControlScheme : IComponentData
{
public KeyCode up, down, left, right;
}
I'd be more than happy!
not sure I understand but.. enums?
does the DOTS/Unity ECS approach have reactive systems or something similar? Meaning: Systems that react to component changes on entities
one thing I've discovered about the new input system is you have to be careful using the input.Player.Move.performed += Move; for buttons
move if its a bool will remain true for however long the button is pressed
I want the input system reference in a component
so you end up with lots of inputs for a single button press, depending on how high the frame rate is because you can't press the button that quickly
you can use enums for that
I had an idea in my head, but as soone as a began writing, I thought "nah"
but using .performed to switch a bool, and then flip it to false once the action actually has been performed isn't a dumb idea imo
yeah but I mean .cancelled doesn't become true until there is no input at all
its ok for movement I guess but not so great for button presses
i'm trying to copy over data into a gameobject from an entity but my object doesn't render properly when I copy over the values despite. Not sure if I'm missing something ?
{
var ecb = _commandBuffer.CreateCommandBuffer();
var gameObjectIndex = World.GetOrCreateSystem<GameObjectIndexSystem>();
Entities
.WithStructuralChanges()
.WithAny<UpdateMeshTag>()
.ForEach((Entity e, in DynamicBuffer<Point> points, in DynamicBuffer<Triangle> triangles, in GameObjectRef gameObject) =>
{
Debug.Log("UpdateMeshSystem");
var go = gameObjectIndex.gameObjects[gameObject.index].gameObject;
Debug.Log(go);
var mesh = go.GetComponent<MeshFilter>().mesh;
var newVerticesArray = new Vector3[points.Length];
var newTrianglesArray = new int[triangles.Length*3];
for (var i = 0; i < points.Length; i++)
newVerticesArray[i] = new Vector3(points[i].x.x, points[i].y.x,points[i].z.x);
for (var i = 0; i < triangles.Length; i++)
{
newTrianglesArray[i*3] = triangles[i].a.x;
newTrianglesArray[i*3+1] = triangles[i].a.x;
newTrianglesArray[i*3+2] = triangles[i].a.x;
}
mesh.vertices = newVerticesArray;
mesh.triangles = newTrianglesArray;
ecb.RemoveComponent(e, typeof(UpdateMeshTag));
}).Run();
}```
Maybe try calling mesh.UpdateRenderBounds
Assuming your debug is being called I don't see an error.
Oh
Change GetComponent().mesh to .sharedMesh
@torn kestrel
okay thanks I'll try that!
Also for associating monobehaviours (like meshfilter/meshrenderer) with entities you should really use hybrid components https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/hybrid_component.html
oh sweet had no idea these existed i'll read up on that thanks π
So when i call addcomponentobject it takes care of linking automatically to a go it creates?
AddComponentObject is for adding a "class" component to an entity, AddHybridComponent is for associating a monobehaviour with an entity (that will link your monobehaviour to a hidden gameobject whose position/lifetime is tied to your entity)
Ah great
don't use cancelled then π
Or only use that
depending on your usecase
yeah that's why I'm not, I'm using the direct float value
it's just there seems to be lots of tutorials and examples using .performed or .cancelled when I don't think its always a good idea
How do you refactor static methods with a lot of arguments used in jobs? You can't use non-static methods nor structs with ref/in keywords.
Put all the arguments into a struct
Not sure what you mean about not being able to use ref, I'm not aware of any restriction on that
As far as I understand when I use static void foo(ref MyComponent c), the component is passed by pointer. But when I use something like below I make a copy of MyComponent
struct MyStruct { MyComponent c; }
// ...
foo(new MyStruct { c = c }) // Is MyComponent copied here?
I don't even think you can do that can you. Ref implies it's already assigned before you pass it in
And no it wouldn't be a copy. That's what ref means, it's a reference
@zenith wyvern hey, just wanted to say thanks. Finally got to sit down and try the AddHybridComponent. Worked great!
in the entity debugger what does it mean when a component on an entity is white instead of green?
Can someone explain to me the purpose of ISystemBase
i see a lot of excitement around it but in not sure i understand why
i would like to be excited too so please help lol
everything can be bursted. in isysbase
yeah I was wondering that, I missed the memo when that came out
so is the idea to move all your code ultimately to ISystembase
The dots best practices course on unity learn has some realy great information.... highly recommend checking it out if you havent!
ISystemBase let's you burst your OnUpdateFunction. Including job scheduling.
But it's seriously limited right now so I'm not bothering with it yet myself
How to trigger conversion without changing anything?
Hi
I logged a bug for a hybrid renderer issue and posted it in the forum too . not sure if I should have posted it here or not but in case that the response is yes
this is the thread https://forum.unity.com/threads/hybrid-renderer-0-11-bug-out-of-space-case-1312866.1053683/ and case number is 1312866
Thanks. I think we have a duplicate of this already and will look into it.
Everything everything??
Even null coallacing??
Add a ConvertToEntity component to your GO , with the default Convert And Destroy value for the mode.
OR Check the ConvertToEntity checkbox at the top of the inspector panel of the GO to achieve same result.
OR convert/put your GO into a subscene
I'd be really thankful if you update me on this or give me the issue to be able to check it so I'll know when we can upgrade. We are not in rush for the update but I'd prefer us do it sooner rather than later to make it easier to upgrade to next versions when they come out
There are methods in Texture2D which give you the NativeArray of colors and you can modify them if the texture is not compressed at runtime, if it is then you need to copy the pixels to a native array and modify and again set them on the texture. Here is a script from one of our project changing object colors using burst which works blazing fast even on mobile
I'll attach the file
this gets texture arrays and modifies them with burst
Can anybody help me with this dependency problem:
"ArgumentException: The previously scheduled job SpeedModifierSystem:<>c__DisplayClass_OnUpdate_LambdaJob0 writes to the Unity.Entities.EntityCommandBuffer <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.ecb. You must call JobHandle.Complete() on the job SpeedModifierSystem:<>c__DisplayClass_OnUpdate_LambdaJob0, before you can write to the Unity.Entities.EntityCommandBuffer safely."
I am using AddJobHandleForProducer everywhere I use this command buffer
Have you called the JobHandle.Complete() as the error tells you to?
@pulsar jay can you share your code this happens in?
Guys is it a good practice to instantiate new entities from Systems? and if that is the case how would be a preferable way to inject thje mesh into the struct that inherits from ISystemBase ?
Don't think you can use Bursted ISystemBase since meshes are managed classes. You can prepare mesh data using burst + jobs and the low level mesh API, but OnUpdate would not be bursted.
Also.. has anyone noticed much in the way of gains with ISBs (for those who have dabbled)? I've been getting pretty mixed results.
Most of my stuff with ISBs have been negligible too, but I guess my scale isn't really large for it to be better π
arguably you see the best gains for when you're processing hardly any entities? Had a weird one yesterday where the thread timings were much more consistent but the total job time was slightly longer than the exact same code as a SB.
is there any easy way to get a component data inside an ISystemBase system ?
We finally have a netcode subforum https://forum.unity.com/forums/dots-netcode.425/ β€οΈ
I've seen the biggest performance improvements when using RunWithoutJobs in systems that run multiple times in a frame (GhostPredictionSystems, etc)
yea definitely gotta be good for multiple runs of a system you'd think
Has anyone experienced his entities not rendering if they are not fully inside the camera's frustrum ?
view
Any time that's happened to me it's because I was manually changing my mesh without setting the RenderBounds component to match the new bounds of my mesh
hmmmm
in the entity debugger what does it mean when a component on an entity is white instead of green?
Also is there a way to control update order of systems?
@rare dew thx I got it sorted out. It wasnt clear to me that I had to use AddJobHandleForProducer everywhere I use any command buffer. Thought the dependency management would manage that automatically. Adding it to every system that uses ecbs fixed the problem
@gusty comet you can also use/create SystemGroups but its a bit harder to order groups
@ocean tundra Awesome thank you!
Hmm did they update ecs package? Launched unity and now my systems OnUpdate are not being called at all xd
dosnt matter if they released a update, did you update?
Ah found the issue
how tf does unity make it so onupdate only triggers if there is an entity being used by the system created lmao
its part of the code gen
your Entities.Foreach will create a EntityQuery (same as calling CreateEntityQuery)
and then the system will tie that into its onupdate calls
oh, I didn't even realize ecs did codegen
π
they do a pretty good job of hiding it
to always update add [AllwaysUpdate] or something like that to the system
theres a way to see it somewhere, not at my pc. I think its in the DOTs menu somewhere
Found it
so is there a way I can incriment a value in one parralel job and read it in another?
I tried using Interlocked.Incriment but the value is always 0
Put the value in a component or a native container that gets passed to each job
@zenith wyvern there isn't any way to just let the value be a variable in the system itself?
There's NativeReference for single values
I just need to add 1 to a number each time something happens inside of a parralel job
Yes, it can be a variable in the system but the only way to get output from a job is v=with a native container
What do you mean?
var val = new NativeReference<int>(Allocator.TempJob);
Job.WithCode(()=>{ val.Value = 10 }).Schedule().Complete();
Debug.Log(val.Value); // Prints 10
Just don't forget to dispose it after
You can make it persistent and create in OnCreate if it's long-lived
This part is documented on the manual if you wanna check
does NativeQueue not work with burst?
Burst error BC1042: The managed class type Unity.Collections.NativeQueueBlockPoolData*is not supported. Loading from a non-readonly static fieldUnity.Collections.NativeQueueBlockPool.pData is not supported
I'm getting that as an error
It works but you can't create it inside burst. You need to create it on the main thread and pass it in
I see, thanks sark
I can try to remember that. It's a regression so it will be looked at quite quickly I expect
I just wondered: How does ecs handle components on children of prefabs? As the prefab tag is disabling all of the entities components how can it do that for the prefabs children? As far as I know there is no WithNoneInParents<Prefab> kind of thing?
I think the tag is just added to all the children? Though I might be wrong
π€¦ββοΈ oh yes that correct
so the code adding/removeing the prefab/disabled tags has the "overhead" of doing it on all linked entities I guess
yup
Hello there i am still bugged with this issue of objects not rendered if some propoprtion of them have not entered the camera view.
I tried to find if there is any information on the documentation but no lack :/
Why I can't use only readonly arguments in entity query? ref does work
what does the componentdata selectedblock look like?
The problem was in the base system class. Used ComponentSystem. SystemBase works fine. One time I will remember the difference between those
that looks like a buffer π I didn't know you could use componentdata like that
Ah, yeah. Another mistake. It doesn't affect the previous error anyway
Does it compile in Unity or do you get the same error?
Im thinking it might just be an issue with VSCode π€
Might be worth regenerating the csproj files
can I create a command buffer once in OnCreate or do I have to call
barrier.CreateCommandBuffer().AsParallelWriter();
in OnUpdate
@gusty comet Grab the command buffer system in OnCreate and create a new buffer instance in OnUpdate before any queries, basically
It's ok now since I switched to the job based SystemBase. It's strange that it won't work on QueryBuilder in ComponentSystem though. I may have skipped some mandatory param
Alright thanks wasn't sure if I had to do it. Thanks @sand prawn
@acoustic spire oh this was ComponentSystem - the QueryBuilder doesn't support in parameters.
Surprise for me, thanks
Is System.OnUpdate without jobs and burst somehow faster than MonoBehavior.Update? What kind of optimizations remains when we work with managed components in systems? AFAIU we still have to query entities and that's anyway slower than accessing needed object by reference in MonoBehavior
https://forum.unity.com/threads/introducing-the-dots-best-practices-guide.1054991/ - dots-best-practices
Thanks for sharing
Oo I've never seen that, shiny
A bit confused about this, is the reference to the command buffer system actually doing anything here?
Currently the best way to express this dependency between a scheduled job and a main thread job that must run after it is to use a sync point to ensure that the scheduled job has completed. In this example, the systems are using EndSimulationEntityCommandBufferSystem.
Hmm, maybe it would throw a dependency error from trying to access the component on the main thread after a scheduled job accesses it, but adding the command buffer dependency resolves it?
it doesn't seem to be doing anything really, AIState is already defined as "in" in the query below which ensures that at the time that the job below runs the job above will be completed before hand
Is my assumption correct that all game logic that depends on positions has to run after TransformSystemGroup? Otherwise instantiation seems to be really problematic as all logic will run with the instances being at position 0,0,0
Oh wow, a best practice guide from Unity themselves. Would've saved me months of fumbling around in the dark back when I first started. Lets see what I'm doing now that's actually bad practice.
Hm, I'm surprised they dont mention the use of FixedLists. In various tests, FixedListX is nearly 10x faster in accessing, iteration, and modification than a DynamicBuffer. I recommend that all lists that can be made into a fixed list do so since the performance is that much better.
For iteration you can use Reinterpret<whatever>().AsNativeArray() and it should remove any cost related to safety checks from the buffer
Same problem with native arrays inside bursted jobs. Much better to use a fixed list rather than NativeArrays or other dynamically allocated memory structures.
For my pathfinding library I originally used FixedLists for neighbours. After profiling I found NativeLists were almost identical, and a lot more flexible, at least for that use case
Other stuff in this guide seems fairly logical and what I discovered over time. Dont use persistant allocation, dont use shared component data, readonly everything, and so on.
Hm, really?
As long as you re-use the lists as much as possible
For pathfinding, I've gone from DOTS to compute shaders and flow fields, or at least attempting to. How is your pathfinding performance?
guess I'm not playing with Project Tiny for now.