#archived-dots
1 messages ยท Page 257 of 1
And I do wish I could remove Transform from a GameObject. That is a major reason why ECS is so much more powerful.
And you don't do this at runtime
this only works in authoring so that's not an issue
hmmm, I am well out of the loop on how the current authoring works so perhaps I do not fully understand how the authoring works now.
authoring pre-creates all entities in 1 giant block of memory
Then just loads that giant block into the world
So on the fly entity creation, like for example big ropes which may be generated at runtime. What happens then?
are you talking manual creation via CreateEntity or via runtime conversion?
if you're talking runtime conversion, from memory it all happens in a separate conversion world then is copied into your actual game
so it's not creating new archetypes either
I don't know exactly what I am asking :P.
though i highly recommend against runtime conversion as it's slow, won't work with entities 1.0 features and has no real benefit over pre-converting
I just knew that I was frustrated with the authoring they released for .17. So I should probably just shut up and actually look at .50
๐
well there ain't much difference except a bunch of bug fixes
There's a big difference between instantiating entity prefabs and generating new archetypes
You should author whatever combination of entities you need to make the long rope
Then at runtime instantiate the prefabs
And link them together or w/e
I will just need to review how Unity wants us to do it
from what I remember, it just seemed messy and complicated instead of just creating code to create whatever components you wanted on objects.
on a tangent about instantiation, i wish i could improve this somehow =\ (it is 2 lots of 50k entities but still)
But I like doing the low level stuff and I understand they are trying to make it easier for people
yeah that is frustrating, especially since you are generating a lot of temp allocations too
By that you mean an authoring that tags those entities with "PositionlessComponent" or something like that, and a system that executes only at the first frame that strips away components like that? Or can the Authoring itself do that - do entities returned by conversionSystem.GetPrimaryEntity() already have LocalToWorld and all that?
a literal conversion system
public class NoLocalToWorldConversionSystem : GameObjectConversionSystem```
something like that
I was told that conversion system is discouraged in favor of authorings
not sure who said that but it's there for a reason
and this is the reason
you need to update after unity runs their conversion for transform/localtoworld
so you can remove the component
Welp, now I feel dumb for making my own StartSystem that does funky stuff to run only once. Thanks tertle, I'll use GameObjectConversionSystem from now on
My StartSystem was causing a ton of issues -_-
Do shared components with floats work?
https://youtu.be/TdlhTrq1oYk good video about conversion ๐ค
Uncover the process of converting GameObjects to Entities and how this can be extended and customized.
Find the code samples on GitHub: https://github.com/Unity-Technologies/unite2019-scenedatatodots
Speakers:
Simon Mogensen - Unity
Fabrice Lรฉte - Unity
More about DOTS: https://on.unity.com/2litTAx
Slides available here: https://www.slidesh...
Thanks, this looks like it will answer a lot of future questions
is conversion setup still same with 0.50?
(I haven't followed the development that closely, saw the proposal about 1.0 workflow)
pretty much
Hybrid renderer (v2 but there's no more v1 anymore) does have OC I believe. Just using whatever ships with the RP you're using.
how can I use it? I'm on v2 but I don't have it by default
I believe the current HR is just a bootstrap to the current RP (HDRP and URP). The experiemental HR is an entirely different render pipeline
HR works in tandem with the RP's, from what I gather the next iteration for 1.0 should have picking but it will still be reliant either URP or HDRP
GameObjectConversionSystem inherits from ComponentSystem instead of the newer SystemBase. This won't cause any issues down the line?
its been this way since conversion systems were introduced. id expect them to give some sort of basic utility like an api updater if they switch it in the future(as currently they havent introduced any alternatives for it)
Ok, thanks. I can still use ECBs in the older ForEAch like this?
var ecb = new EntityCommandBuffer(Allocator.Temp);
Entities
.WithAll<PositionlessComponent>()
.ForEach((Entity positionlessEntity) =>
{
ecb.RemoveComponent<LocalToWorld>(positionlessEntity);
ecb.RemoveComponent<Translation>(positionlessEntity);
ecb.RemoveComponent<Rotation>(positionlessEntity);
ecb.RemoveComponent<Parent>(positionlessEntity);
ecb.RemoveComponent<PreviousParent>(positionlessEntity);
ecb.RemoveComponent<Child>(positionlessEntity);
});
ecb.Playback(EntityManager);
ecb.Dispose();
yeah
Thanks!
have you specified ENABLE_UNITY_OCCLUSION
I had errors last time I tried it though it was prior to .50
yes, I also ran the occlusion sample but it doesn't seem to work, whichever angle I look at the cubes, it says 0/130 occlusion and the number of triangles doesn't change
the sample image says that it should cull something but for some reason it doesn't work for me
(that's the documentation image showing that it culls, but mine shows 0)
haven't tested the sample, will look at it tonight
I'm having a hard time understand the whole conversion process. Here ```
[UpdateInGroup(typeof(GameObjectAfterConversionGroup))]
public class PositionlessSystem : GameObjectConversionSystem
{
protected override void OnUpdate()
{
Debug.Log("running");
Entities
.WithAll<PositionlessComponent>()
.ForEach((Entity positionlessEntity) =>
{
Debug.Log("removing position");
EntityManager.RemoveComponent<PositionlessComponent>(positionlessEntity);
EntityManager.RemoveComponent<LocalToWorld>(positionlessEntity);
EntityManager.RemoveComponent<Translation>(positionlessEntity);
EntityManager.RemoveComponent<Rotation>(positionlessEntity);
EntityManager.RemoveComponent<LocalToParent>(positionlessEntity);
EntityManager.RemoveComponent<Parent>(positionlessEntity);
EntityManager.RemoveComponent<PreviousParent>(positionlessEntity);
EntityManager.RemoveComponent<Child>(positionlessEntity);
});
}
}
It looks like PositionlessSystem is updating in the wrong group, because it's trying to pick up PositionlessComponent which is injected during IConvertGameObjectToEntity. How should I configure this system so that it can pick up converted IComponentData, and is this even the r ecommended approach?
I've attached PositionlessAuthoring to both GameObjects and Prefabs in my Scene, but PositionlessSystem is never detecting any injected PositionlessComponent
were you able to use it successfully in your project? I got a stacktrace from using it in my project ```C#
IndexOutOfRangeException: Index 6089 is out of range of '1' Length.
Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Collections.NativeArray1[T].CheckElementReadAccess (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
Unity.Collections.NativeArray1[T].get_Item (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Rendering.Occlusion.MOCTestJob.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.50.0-preview.24/Unity.Rendering.Hybrid/Occlusion/BurstIntrinsics/MOCTestJob.cs:83) Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:401) Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:368)
but when I look at the debug data, both the sample and my project look alike
i haven't tried it
It looks like you can only iterate over Monobehaviours, so
Entities
.WithAll<PositionlessAuthoring>()
is able to find the Entities, and using
DstEntityManager.RemoveComponent<PositionlessComponent>(positionlessEntity);
I can remove the position-related components. However, this is causing issues elsewhere
Out of space in the NewChunks buffer
UnityEngine.Debug:Assert (bool,string)
Unity.Rendering.ClassifyNewChunksJob:ClassifyNewChunk (Unity.Entities.ArchetypeChunk) (at Library/PackageCache/com.unity.rendering.hybrid@0.50.0-preview.24/Unity.Rendering.Hybrid/HybridV2RenderSystem.cs:679)
hmm, I think the demo isn't up to date. reading the commit messages, it seems like they updated entities to 0.5 but the code for occlusion is still based on 0.17
but that's just related to the sample repo itself, maybe they didn't update the occlusion backend to 0.5?
hmmm, it seems like the occlusion isn't 0.5 ready yet, but I can't even get it to work with the previous version, 0.17
my demo works fine once i set it up
updates as well
hmmm, I must have missed something. I just tried HDRP and it didn't work either. can you explain what you did to set it up? I verified the steps in the documentation and every step seems to be already applied by default, unless I missed something
didn't read the document tbh
just setup an empty entities 0.50 project on 2020.3.30 with HDRP
and added the occlusion folder
and the shared asset folder
loaded the scene
reimported subscene
hit play
I see, the method I used was simply opening the sample's project in unity hub and let it configure itself, I didn't configure anything
I'll give it a try
opening sample had compile errors for me
in something i cant remember, didnt want to deal with it
@rotund token did you add these flags in your player settings too? ```C
ENABLE_HYBRID_RENDERER_V2
ENABLE_UNITY_OCCLUSION
yes
wow okay, it does work when I copy the occlusion scene folder into a new project ^^
hmmm, so the occlusion scene works on its own, but when I try to open the scene within one of my scenes, I'm getting this error ```C
IndexOutOfRangeException: Index 1089827641 is out of range of '41' Length.
Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Collections.NativeArray1[T].CheckElementReadAccess (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0)
Unity.Collections.NativeArray1[T].get_Item (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Rendering.Occlusion.MOCTestJob.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.50.0-preview.24/Unity.Rendering.Hybrid/Occlusion/BurstIntrinsics/MOCTestJob.cs:83) Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:401) Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:368)
I have 1529 objects in my scene but the moment I toggle a 1530th one, it crashes with the error
I will try to use a subscene
hmmm, I just had this crash happen while trying to run the occlusion in my scene ```
not sure if it's related, stack trace shows it's coming from physics
subscene doesn't work either, I'm getting out of range errors when having more than 1529 mesh entities in a scene that uses occlusion C IndexOutOfRangeException: Index -82 is out of range of '33' Length. Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <3be1a7ff939c43f181c0a10b5a0189ac>:0) Unity.Rendering.Occlusion.MOCTestJob.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.50.0-preview.24/Unity.Rendering.Hybrid/Occlusion/BurstIntrinsics/MOCTestJob.cs:83) Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:401) Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:368)
now I'm thinking it's an implementation bug, it's not like 1529 mesh objects is that many
also, none of my 1529 mesh entities have the occlusion components
but when I add a 1530th one, I get this crash (despite not having any occlusion components)
hmm, but then again, I can put 5k cubes in my occlusion scene without error. it seems it has an issue with detailed meshes (1k-15k tris)
hmm, with 5k cubes all with occlusion components, I'm getting 10 fps or so when entering play mode
I think I'm gonna leave that one alone for now, probably too experimental
interesting, im at 3k cubes (spawning 10/second just watching what happens) and it's only doing 0.20ms
maybe not a great sample though since most are culled
im quite curious about this though because we have a new project coming up that will really need something like runtime capable occlusion culling
6k cubes now and its only taking 0.23ms so not sure why your fps was so low, these are only cubes though
did you not have burst on?
Just found out why my companion objects dont show up in scene view:
I saw this Runtime/Authoring view thing on their GDC talk but I didnt know it was implemented already ๐ฌ
Anyway it seems inconsistent and broken. As it does not hide runtime instanced entities but only their companion objects ๐
(this has been authenticated for years)
Also weird that the default behaviour is the Authoring one
nice that you solved your problem though!
This did exist prior to 0.50?
I see. Was wondering as the LiveConversionMenu.cs
file is new
But it did not do anything then did it? The scene view never hid any runtime stuff before
i think that's more the change of companion/hybrid objects
it's definitely been 'improved' and a lot of bugs fixed in 0.50
Right now it feels like its implemented halfway as it only hides runtime instanced companion objects but not entities
what happens if you turn off live conversion
For me it only introduced new bugs
Nothing. The only thing that changes anything is switching to runtime view
This is Scene view in Authoring mode:
And this in runtime mode:
The instanced cube is visible in both. The entities using companions are not
0.17
Does this make any difference for you in 0.17?
i haven't had this issue
it works as i expect for what i'm using atm
so i can't really say
I mean does it actually show any different state if you switch the sceneView mode?
(also i rarely use scene view with dots since picking isn't implemented yet anyway so it's a bit useless)
looks the same for me in my setup, but i wouldn't expect it to be different
yeah thats right. but it helps with camera perspectives
i have a free cam that replicates scene view camera built into my game
mostly use that
judging from the presentation any runtime change e.g. moving object should be invisible in authoring mode
also my project is netcode
so some of my subscenes are loaded twice (server/client)
some on 1 or other
i'm not really sure what behaviour i'd expect to be honest
i guess you wouldn't see anything on server because there's no renderers
if there is anything that is instanced at runtime or changed at runtime like movement it should only be visible in runtime view
they basically had a moving platform as an example which just stands still in authoring mode
yeah everything is static in my subscene
i only have a plane and 2 trees
im curious and will create a moving platform or something tomorrow
and see if it works
but for now going to continue my occlusion tests
at 35k boxes now for only 0.44ms pretty happy with this performance
not sure what bug michael was running into
alright. thanks for your help. at least one problem is "solved" now ๐
sounds pretty good to me
seems to break down ~32700 entities culling which I feel is too close to 32767 to be a coincidence
ah, you're right. I had turned it off to look into the stack trace and forgot about it ๐ so performance is fine, but it's still crashing lol
getting index out of range errors whenever I put more than 1529 relatively detailed meshes in my scene
Yeah I can repo this, happens everytime just over 32k cubes for me
I'm very happy with performance so this will have a lot of potential in future
Which is good for preproduction research in doing atm
But I would like to get it working earlier than 1.0...
@odd ridge how many verts are your meshes total when it errors out
because i think you said you are error at 1529 meshes
but it takes me 32k cubes
so it doesn't seem be to entity count
or is it just 1529 meshes in view
just about 1 million triangles and 2 million vertices
but... none of these have the occlusion components so I'm not sure it would affect it
if I only have 1 entity with occlusion components it will crash after 1529 meshes
thanks
HybridV2Culling can give StartIndex a negative value
going to branch this and see if i can fix it
yep ok switching that to ushort doubles number of cubes i can have (64k)
i think it just needs to be an int but they seem to have layed this out in memory very specifically so not sure what'll break, but hey let's give it a shot
seems to fix it
@odd ridge if you want a fix
HybridV2Culling - line 419 remove the cast to short
HybridV2RenderSystem - line 827 change StartIndex to int
(I think this struct should be reordered for memory saving now)
ah nice!
while you're here, have you tried building the occlusion scene? I tried building the sample scene but nothing was showing up in the camera view
i have not tried i can give it a shot
yeah fails by default
the shader is bad
works fine if i replace material with default (though its just grey not colored)
oh okay, thanks
Is is possible for you to report a bug on this? It's absolutely something that should be fixed (the int/short problem that is)
just heading to bed but I can make a report tomorrow
That would be great!
Is there any convinient way to get the component object from an entitiy. Getting it from the CompanionLink componet would be the obvious way bat thats internal so I cannot even use GetComponent with it ๐ฌ
Has anyone tried out DynamicComponentTypeHandle<T>? Curious to know if this struct will be a "stable" API i can use in the long term
dots 1.0 will come with 2021lts right? when it will be available on 2022?
I heard rumors either late 2022 or 2023
how I've understood it, they plan to ship it with 2022.2 atm
if it even runs on 2021 or older is still a question mark
I wouldn't count on it
so if i want to use Dots best call is to aim at unity 2021 right? and its LTS
at 2022.2 alfa i did not see Dots package tho
they plan to ship it with final 2022.2, so next christmas
ohhhhh, that is soooo far away ๐ญ
and considering the past delays, it's not granted it will make it
if past experience means anything, it will not make it
there's no best calls with experimental packages like entities atm, other than if you want to use it, stick to latest but you still have to redo bunch of things when they get to 1.0
but expermental packages are fun :DTo be honest I amjust aiming to learn using it in more realistic enviroment thats all.
also 2022.1 doesn't play nice out of the box with Entities 0.50 I think or there was some changes needed at least for rendering
Unity also removed animation package support on 0.50 I think.. so be prepared that things you use now might not exist on 1.0
Note taken. I though 0.5 was only on 2020, and not on 2021
- Reach compatibility with 2020 LTS: this is what is achieved today with the release of experimental Entities 0.50 and its compatible packages. Entities 0.50 is a breaking change from Entities 0.17.
2. Reach compatibility with 2021 LTS: we are preparing a minor update to Entities, experimental Entities 0.51, that will make Entities and its compatible packages usable on both Unity 2020 LTS and Unity 2021 LTS projects. This update is currently scheduled for Q2 2022. More details will be shared as we approach its release.- Reach compatibility with 2022 Tech Stream: the version Entities 1.0 and its compatible packages represent the ECS foundation supported for production for the entirety of the 2022 release cycle. Entities 1.0 will be a breaking change from Entities 0.51.
Thank you, I was aware of that forum, but thought maybe there are more updated data ๐
so asked discrod ๐
๐
Can you shedule jobs, inside of jobs?
Not allowed
Alright thanks
Could need some help... trying to build my dots project and well when using the build configuration i ALWAYS get this...
But there no errors in my scripts... no idea why it tells me that
Restart didnt helped either
any other errors?
the screenshot doesn't show much besides the 2 errors
are we allowed to internalize and modify packages like unity.physics or the hybrid renderer?
yes
as long as it's for a unity project*
sweet I had found that and thought I was in the clear
so is EntityQuery.SetSingleton() not working in the new 0.5
i believe its broken if you have a multi component query
get the entity, just call SetComponent
or just ordinary query with element [0] I guess
yeah
your way is probably better though ๐
Is there a way to automaticly dispose native container?
I have the problem that I return them from a class and then after the return I can't dispose them anymore
apart from Allocator.Temp, WorldAllocator is currently the only built in solution for automatic memory handling
if your having problems disposing them after a job then you can use a jobwithcode after that job to do some cleanup and dispose of stuff
Dispose(Dependency) is usually more than enough
WorldAllocator ? is this something new?
yeah it depends on what your doing, I've seen it recommended from unity devs that they sometimes use the jobwithcode thing
yes in 0.50 there is a new allocator that auto disposes end of (every second) world frame
Oh dang nice, didnt know. Time to upgrade
only works with native array atm though
Thanks gonna check it out
Anyway an array guy ๐
thanks guys
if you do use it make sure its WithoutBurst().Run()
what do you mean?
you can't allocate it in a job, sure, but it's meant to be used to allocate outside of a job then passed in
I mean if your using jobwithcode to cleanup you need to run it on the main thread as far as I'm aware
oh you may as well just call complete() then and do it on main thread
because that's what withoutburst/run is doing
is it really the same though ๐
Job.WithCode(() => {// Do Something}).WithoutBurst().Run()
what is that doing
except just running main thread on the spot?
I know it is running on the main thread but I thought it was more efficient
only if you use burst
because its not going straight back to the update method in that system
and there might be less of a gap between those jobs
Job.WithCode(() => {// Do Something}).WithoutBurst().Run()
is the same as
Dependency.Complete()
// Do Something
but I guess I'd have to do tests to find out
yeah I did speak to a unity dev and they said they were using jobwithcode instead of dependency.complete
Job.WithCode(() => array.Dispose()).WithoutBurst().Run();```
You can see the codegen do exactly that
``` var __job = new CullingStatsToolbarSystem_LambdaJob_0_Job{array = array};
CompleteDependency();
__job.Execute();```
I might have been doing a bit more than just disposing that's why it wasn't optimal to just use Complete.Dependency()
How can I convert a bool3 to an int3 (0 or 1)?
Oh never mind, I could just do
math.int3(myBool3)
yeah I had to update a bunch of gameobjects and clear a bunch arrays in reverse and also playback a dynamicbuffer all after a threaded bursted job
I am always using bytes instead of bools
I'll do a quick test to see if there's any difference though
if your comparing things like int3s or float3s I think its best to use float3.equals()
Wait a second, c# as a destructor too, never used it but I just remembered. You can clean up there too
destructor is not reliable
at least for this
it might /work/ but there is a good chance under certain circumstances unity complains about leaks before the destructor runs
when doing stuff like leaving play mode
i.e. you're basically relying on your destructor to run before unity's destructor on allocation tracking
so yeah, it might work fine but it doesn't seem like the best approach if you ask me ๐คทโโ๏ธ
true that
ok Dependency.Complete() might be slightly faster or no difference according to my not very good repeatable tests
because it's exactly the same thing ^_^'
codegen calls
{
// Previous frame job
m_JobHandle.Complete();```
Dependency.Complete() is the same handle
``` public JobHandle Dependency
{
get
{
return m_JobHandle;```
well you don't always know until you try these things ๐คท
sorry i'm not trying to be an ass - i just prefer to read the source code to figure out what's going on
hey no, its cool I barely know what I'm doing, so I appreciate all info
Anyone sticking with .17 since they can't do the super complex upgrade to .5? Why not make it incremental steps? Its like a zillion different things to do and you're not sure if any is right.
I can't tho
did my own libraries in 3 hours, then did work libraries over 12 hours
15 hours straight upgrading
and now i'm done
(my own libraries only took 3 hours because i did it first and wasn't sure about the quirks yet)
I did it it wasn't so bad
https://pastebin.com/HmMHJ4vd In this was like a black box I'm not sure how it worked, now it wants me to .foreach it
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
why do you need to foreach it?
are you adding the new RegisterDependency for physics?
oh... you're still using JobComponentSystem?
Its a JobComponentSystem that was the only way I could do collision detection
should have stopped using that like 2 years ago ^_^'
No other way worked
there's nothing systembase can't do that JobComponentSystem can
yeah that is slightly behind 
I'm sure, but I spent like 30 hours finding out how to do collision detection
no one knew how, and someone linked me code that worked
No, this is .5 stuff
The documentation : https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/upgrade-guide.html#systembase explains you must do this.
There's a truck ton of things to do: https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/upgrade-guide.html#systembase
yes but jobcomponentsystem was deprecated 2 years ago
you could have done this before 0.50 is what i'm saying
you're just forced to do it now
Like when I update stuff, I wish there was one step I could validate I did it right.
what exactly is your issue on updating?
You get no liberties unless you upgrade like 30 things at once
This is not how its supposed to be done
why not just upgrade your project in 0.17 from JobSystem to SystemBase
then get it compiling
then upgrade to 0.50
this way you don't have to worry about other 0.50 issues stopping you compiling
Not a bad idea, I'd be set back 6 hours
while you get rid of your JobComponentSystems
Oh what I could do
is
Fix it in one version
bring it to my advanced possibly version 6 hours in future
yeah just copy the JobComponentSystem upgraded systems into your 0.50 branch
see if it works. But I have zillions of errors
My main error is something about a windows build
Sec
I think you guys may be able to help me!
do you still have the windows build package installed?
You already helped me a ton
you need to get rid of that
all those .windows .ios etc packages are gone
there is only 1 package now for building everything
(imported as a dependency)
You helped me in the past bro
I'm so so so close to launching a mmo
Probably shoulda just did it in game object
Woulda had it out like last year lol
I was stubborn and wanted parallel processing even before I heard of dots
someone told me you did parallel and I was stoked I didn't have to code it myself
Would be cool if we could specifiy the transformaccessarray even further. I know you can do that yourself, just ease of use.
Like transformsaccesarray.positions or transformaccessrray.rotations
What exactly does this error mean? does it mean my types inside my struct are nullable?
The type 'ImageParsingJob' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'IJobParallelForExtensions.Schedule<T>(T, int, int, JobHandle)' [Assembly-CSharp]
For reference this is my Job:
public class ImageParsingJob : IJobParallelFor
{
[ReadOnly]
public NativeArray<Color32> imageData;
public NativeArray<float> res;
public int numThreads;
int width = 256;
int height = 256;
public void Execute(int index)
{
for (int i = 0; i < width * (height / numThreads); i++)
{
res[
(width * (height / numThreads)) * index //offset from 0
+ i //how far into the chunk we are
] = imageData[
(width * (height / numThreads)) * index
+ i
].r;
//TODO: Math
}
}
}
Your IJobParallelFor needs to be declared as a struct not a class
oh whoops i missed that
ok well it's telling me I need to use double buffering strategies but i have no idea what that means
I'm trying to read a specific channel of a texture 2D to an array
Can you guarantee that whatever is being written to res at the index can never interfere with another thread?
logically yes but the conmputer doesnt know that
Cool, if you know that you can try putting in NativeDisableParallelForRestriction attribute onto res
wait, how?
like with []
[NativeDisableParallelForRestriction]
public NativeArray<float> res;
yea
well good news is my code runs
is there a way this could cause 115 ms of garbage collection lmfao
safety system?
my code for this section that the profile says is causing it is
NativeArray<float> results = new NativeArray<float>(256 * 256, Allocator.TempJob); //result array
ImageParsingJob jobData = new ImageParsingJob();
jobData.imageData = tex.GetPixelData<Color32>(0); //feed in image data
jobData.res = results;
jobData.numThreads = 8;
jobData.width = 256;
jobData.height = 256;
JobHandle jobHandle = jobData.Schedule(8, 1);
jobHandle.Complete();
float[] bufferArr = results.ToArray();
Buffer.BlockCopy(bufferArr, 0, heights, 0, sizeof(float) * bufferArr.Length); //should hopefully copy over the read height information
results.Dispose(); //Release memory
results.ToArray() allocates a new array.
then you're doing a Buffer.BlockCopy from bufferArr into heights. Since bufferArr is no longer needed - gc would collect it
what you can do instead is
fixed (float* head = heights) {
UnsafeUtility.MemCpy(heights, results.GetUnsafePtr(), results.Length * sizeof(float));
}
or just write directly into heights via pointers.
What namespace is this in?
Unity.Collections.LowLevel.Unsafe or Unity.Collections.Unsafe.LowLevel - I can't remember the order from the top of my head
Only needed it for local max sized buffers inside an IJob
I think in a job it lasts for the whole job, right?
yea
dang it this is supposed to be simple
Am I allowed to pass an array to a job or is it only nativearrays
o\nly nativearrays, right?
You can convert an array to a NativeArray if you don't want to deal with pointers
yeah im trying to figure how to do that
Give me one moment I can give an example
public static NativeArray<T> AsNativeArray<T>(this T[] array) where T : unmanaged {
unsafe {
fixed (T* ptr = array) {
return NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>(
ptr,
array.Length,
Allocator.None);
}
}
}
When you put the native array into a job, I would put [NativeDisableContainerSafetyRestriction], mainly because I got lazy and didn't want to hook the safety system for something I had pinned.
if it's a void pointer then how does it copy??
oh changing it to head made the red line go away
Wait, what? So I'm calling this job spawning and scheduling routine like 5 times for this one frame, and it takes 4ms for every call (not great) except the last one, which then gets hit with a massive 100 ms garbage collection run
i even used memcopy?...
using (s_ProcessHeights.Auto())
{
NativeArray<float> results = new NativeArray<float>(256 * 256, Allocator.TempJob); //result array
//Get pixel data from image and convert to native array
NativeArray<Color> pxData = new NativeArray<Color>(256 * 256, Allocator.TempJob);
pxData.CopyFrom(tex.GetPixels()); //TODO: Color32?
//Construct job data
ImageParsingJob jobData = new ImageParsingJob();
jobData.imageData = pxData; //feed in image data
jobData.res = results;
jobData.numThreads = 8;
jobData.width = 256;
jobData.height = 256;
//Job handle creation
JobHandle jobHandle = jobData.Schedule(8, 1);
jobHandle.Complete();
//Copy memory
fixed (float* head = heights)
{
UnsafeUtility.MemCpy(head, results.GetUnsafePtr(), results.Length * sizeof(float));
}
//Release memory
results.Dispose();
pxData.Dispose();
}
is it releasing tex.GetPixels()?
other than that it does work correctly (except for the parts that dont but that's my own fault)
I wopuld get GetPixelData<> but that seems to only return white colors
yea most likely, since GetPixels returns a copy of the pixel data from the texture.
Argh, this is frustrating. I wrote a compute shader to do this but it somehow broke unity so I am stuck with this
do Scriptable Objects have efficient ram usage like the Entity Component System?
no
I mean if you Pack the intensiv parts in native container, why not? Its not perfect but at least you get less cache misses and can prefetch
I am having a general problem with my DOTS systems. Basically I have two systems which have an Entity.ForEach that gets their own unique component types (A and B). Both systems want to modify another component (SharedType) based on conditional logic in their respective systems. Is it fundamentally possible for these two systems to run in parallel over multiple threads or is the race condition of writing to the same data mean they always have to run one after the other? I find I get this sort of logic a lot in my code.
protected override void OnUpdate()
{
NativeArray<SharedType> data = sharedTypeQuery.ToComponentDataArray<SharedType>(Allocator.TempJob);
Entities
.ForEach((Entity entity, int entityInQueryIndex, ref ComponentType_A A) =>
{
// do stuff with data conditional on A
}).ScheduleParallel();
}
protected override void OnUpdate()
{
NativeArray<SharedType> data = sharedTypeQuery.ToComponentDataArray<SharedType>(Allocator.TempJob);
Entities
.ForEach((Entity entity, int entityInQueryIndex, ref ComponentType_B B) =>
{
// do stuff with data conditional on B
}).ScheduleParallel();
}
theres no way to do it without turning off safety
unity can't know that you won't write to the wrong index
Another question. I have a NativeArray that I want as read only. Despite using the syntax below, the system says it is still read and write. I have checked and there aren't any places where the array is written to. Whats going on?
NativeArray<Tile>.ReadOnly tiles = m_tilesQuery.ToComponentDataArray<Tile>(Allocator.TempJob).AsReadOnly();
AsReadOnly(tiles) on the Entities.ForEach
most people would not bother with NativeArray.ReadOnly
Safety will ensure the regular array is only read from anyway
Its just that my Entity system overview shows that data type as read&write, I thought readonly was much faster and allows multiple jobs that only read from the type to be run in parellel.
This is a basic system I just made, the editor says the Tile type is read&write
public partial class Test : SystemBase
{
public EntityQuery q_tiles;
protected override void OnUpdate()
{
NativeArray<Tile>.ReadOnly tileMap = q_tiles.ToComponentDataArray<Tile>(Allocator.TempJob).AsReadOnly();
}
protected override void OnCreate()
{
q_tiles = GetEntityQuery(typeof(Tile));
}
}
Wait readonly native array cant be disposed? Would be cool if we can still dispose readonly n arays, not only readonly for the job
That's because it is read and write
q_tiles = GetEntityQuery(typeof(Tile));
is getting Tile Read/Write
if you want it readonly
q_tiles = GetEntityQuery(ComponentType.ReadOnly<Tile>());
your native array has nothing to do with this
my Entity system overview shows that data type as read&write
it's showing your entity read/write permissions not the entity array
oh right
so that other devs can know that they can't write to the array without having to look through code and find [ReadOnly] attributes etc
so when I get the query, that determines rw access
yes there is a bit of confusion here
(not just you but in general)
there are really 2 permission systems going on here
ReadWrite on components
ReadWrite on jobs
so is my example actually readonly as far as unity optimisation and it just appears in the editor as read&write?
for job scheduling and component safety it appears as having write access
for burst optimization it appears as readonly
ahhhh gotcha
if you have 2 jobs with readonly permission on the entity query, unity can schedule these at the same time
but as you are currently using write permission, it will schedule them after each other
So everywhere I have put
m_tileMapGroup = GetEntityQuery(ComponentType.ReadOnly<Tile>());
and use it like so in a system onUpdate
var tileMap = m_tileMapGroup.ToComponentDataArray<Tile>(Allocator.TempJob).AsReadOnly();
Is saying that a native container has not been disposed. Even though I can no longer dispose it as it is flagged AsReadOnly().
Why aren't they disposing properly now?
oh I found your forum post tertle, ill look at that first
Is there an easier way to iterate linkedentities than using .Reinterpret<Entity>().ToNativeArray(Allocator.Temp) to create a native array?
Is it possible to get the entity reference using IJobEntity?
How do I handle the PhysicsSystemRuntimeData if I have no way to access it because its internal? For example I have a query that is used to destroy all runtime instanced entities. I would have to exclude the PhysicsSystemRuntimeData from that query which seems to be impossible?
why can't you just iterate over the dynamic buffer? or use AsNativeArray?
there's no reason to copy
Oh I think the reason was just that foreach didnt work ๐ค But a for loop should work direktly on the buffer I guess
if you use AsNativeArray()
you can get a native array from the buffer
that aliases the same memory
with no copies
and do your foreach
I think my fault was that I thought I have to use Reinterpret<Entity>(). But I could just use buffer[i].Value instead ๐
The execute method of the job struct will...execute for each chunk matching the query. From this chunk (it's one of the parameters) you can GetNativeArray(_entityTypeHandle) https://docs.unity3d.com/Packages/com.unity.entities@0.50/api/Unity.Entities.ArchetypeChunk.GetNativeArray.html#Unity_Entities_ArchetypeChunk_GetNativeArray_Unity_Entities_EntityTypeHandle_
_entityTypeHandle here is a job field you populate from the system with the GetEntityTypeHandle() helper
you can then iterate your entities collection and do whatever you need
I'm not on 0.50 yet but I wonder, if you can't restrict from this component you don't have control over, can you do the opposite: add your own tag to runtime entities you need to select
Yeah I thought about that. The thing is instances are created in many different places and I would have to add code to add the component in each place.
I just thought I could just add my DontDestroyOnLoadTag to the PhysicsSystemRuntimeData entity. But I forgot that I cant because I cannot use it in a query. These internal components really give me a headache ๐ฌ
they are runtime instanced but also built ? I mean not authored from GameObjects ?
Most of them are prefabs referenced in scriptable objects. But there are also entities created as data containers for various systems (like the PhysicsWorld does) etc.
oh so this component is internal and unity adds it to some of your entities but not all of them, and you want to pick those without it. Uhm I didn't have a look at that yet.
Did you consider local copy of package to modify the internal component ?
Kind of. It does not add it to my entities. The physics system creates a singleton which is used to handle physics dependencies. It is created in BuildPhyicsWorld in OnCreate
The problem is it must not be destroyed because otherwise all systems depending on physics will throw errors
But I have no way to exclude it from the destruction query nor any way to reacreate it.
Before modifying the package I would rather use an AssemblyDefinition hack to just make it public. But I would like to avoid such hacks ๐
Does it have any other component you can target for the query instead ?
Nope sadly it does not
oh sad. Ok I didn't study it so I'm gonna stop throwing random suggestions ๐
Afaik there is no (public) way to get a component by its type id or is there?
public static ComponentType FromTypeIndex(int typeIndex)
Oh thanks that might work. Do you know if the type ids are always the same?
they generally arent
if you add more types it changes
better to grab the type index from the type
on runtime
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffb9ade1f9c (f2f191b2eb06a2441dee69db0f498ab) [unknown:0] Unity.Collections.NativeArray`1<SharpDx.Int3>::Unity.Collections.NativeArray`1<SharpDx.Int3>.set_Item
0x00007ffb9ade2c8a (f2f191b2eb06a2441dee69db0f498ab) [unknown:0] Unity.Jobs.IJobExtensions.JobStruct`1<Assets.Systems.World.Regions.Territories.Sectors.NewSectors>.Execute ```
any ideas on this.. am I reading this backwards or is it saying [0] is invalid for a array of 1 length? I remove the burst compile flag and I don't see an error. This code also used to work, not sure if its now failing due to new burst compiler and better sanity checks or what.
You are probably trying to write to something in parallel
If you know what you are doing you can add NativeDisableParrelleRestriction to the array
Yeah thats what I was trying to circumvent by using the type id. I cannot acces PhysicsSystemRuntimeData because its internal. But I need to exclude it from may query
So I guess FromTypeIndex wont help with that if the ids arent fixed
I have a similar issue, I just load it by the type path. So string -> type -> typeindex
Since you know the type you're looking for the string can be const is what Im thinking
oh that works? which method do you use to get ComponentType by path?
hmm adding NativeDisableParrelleRestriction does not appear to avoid the issue
ComponentType.ReadOnly(Type.GetType("the_full_path_to_type"))
Great. Thats just what I need. Thx ๐
I suspect the issue is with this index
[BurstCompile(FloatPrecision.High, FloatMode.Strict, OptimizeFor = OptimizeFor.Performance)]
public struct UpdateWorldTransform : IJobParallelForTransform
{
[ReadOnly]
public readonly NativeArray<int> WorldIndexMap;
[WriteOnly]
public NativeList<WorldPositionCache>.ParallelWriter WorldPositionCache;
[WriteOnly]
public NativeList<TransformChange>.ParallelWriter Change;
[NativeDisableParallelForRestriction]
public NativeArray<WorldTransform> WorldTransforms;
public UpdateWorldTransform(in NativeArray<WorldTransform> worldTransforms, in NativeArray<int> worldIndexMap, in NativeList<WorldPositionCache>.ParallelWriter worldPositionCache, in NativeList<TransformChange>.ParallelWriter change)
{
WorldTransforms = worldTransforms;
WorldIndexMap = worldIndexMap;
WorldPositionCache = worldPositionCache;
Change = change;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Execute(int index, TransformAccess transform)
{
var worldIndex = WorldIndexMap[index];
var worldTransform = WorldTransforms[worldIndex];```
hmm it seems to be tied to a dependent job.
yes
That is probably your issue then. When doing things in parallel you are only usually allowed to write to the same index
So in this case you are trying to write elsewhere and the safety system kicks in
yes I am aware, in this case I know it should be safe and was working fine with older burst with the proper safety flags disbled hmm
Well unity wants to make it dummy proof so they probably added more catches
well thats sad. Been awhile since i looked at this code, but from memory I am avoiding having to use a dictionary for these lookups.
well adding "[BurstCompile(FloatPrecision.High, FloatMode.Strict, OptimizeFor = OptimizeFor.Performance, DisableSafetyChecks = true)]" to either of the dependent jobs which both share a collection seems to avoid the error... which isnt a great solution.
both jobs share a public NativeArray<WorldPositionCache> WorldPositionCache; collection, the first writes to it the second reads.
problem solved, yeah I don't know why that is happening. I am not too familiar with IJobParallelForTransform
Ya, I guess I should just not worry about it as I will be switching all of this code to DOTs once 1.0 is out ๐
haha yeah
I've decided to just avoid DOTS till 1.0
i wrote a bunch of stuff in .4, then they changed a lot
wrote some stuff in .17, seems to be changing even more
We have dual work efforts at the moment, some of the code that is safer to refactor to 1.0 is being designed around dots 0.5 while the rest that has been focused on unity 2022 will wait until 1.0alpha drops at which point we will merge the two effortss.
We are exploring how best to integrate our large world coordinate system in to dots at the moment and the transition from PhysX to Unity Physics.
sounds like suppper fun
hopefully, getting large coordinates working in PhysX w/ gameobjects was not super fun lol
well parts of it was fun.. the parts that didn't need to interface with Unity Scenes/Physics heh
I am glad they are adding their own physics engine. Seems like PhysX is no longer having anything added to it
Definitely, the fact they provide source is also super cool. For our project it still isn't clear if we will be best served with unity physics or havok. Seems like Unity Physics will be a bonus for our multiplayer, but we also will have a ton of dynamic colliders so we are somewhat concerned about the cacheless nature of it.
I don't really understand stateless but I only do simple physics stuff.
I do love DOTS though. And Burst is the best thing to happen to the games industry in 10 years
Ya burst is great.
I know how to do that within IJobEntityBatch or IJobParallelFor, but the thing is you don't have access to chunks when you use IJobEntity, and thus don't have access to GetNativeArray().
Oh damn really ? Didnt try yet but manual says it autogens an IJEB
So I would expect params to be passed over
Oh damn having another look at the manual it looks like you're right, method signature is the same as the foreach lambda
Apologies I was wrong
I was misleaded by this description here https://docs.unity3d.com/Packages/com.unity.entities@0.50/api/Unity.Entities.IJobEntity.html
"The generated IJobEntityBatch type in turn invokes the Execute() method on the IJobEntity type with the appropriate arguments."
Ah I see my mistake, it was the other way around, my bad
Is this what you're trying to do?
struct Job : IJobEntity {
public void Execute(Entity e, in ComponentA a) {
// Use e in your logic here
}
}
Hey all, I'm sure most of you have seen by now but our very wonderful @rotund token wrote a massive post on serialization strategies in DOTS. https://forum.unity.com/threads/dots-0-5-and-serialization.1258140/
Thanks so much @rotund token
๐ณ just trying to get a discussion started! everyone so secretive about saving
I am just waiting for tertle to release his saving tech with MIT license so we can stea.... use it ๐
@rotund token how does your new method handle entity references? i saw someone mentioning that in the thread
i wrote a follow up post on exactly how i do it
aah remap part
also when using GetDynamicComponentDataArrayReinterpret would size be TypeInfo.SizeInChunk?
been using typeinfo elementsize
btw do your artists/designers use a custom prefab/material/texture/asset browser when dealing with scene design related duties(goes back to my prev comment about not using prefabs enough apparently)?
We may be diving into serializing entities soon - all code and insights are greatly appreciated- thanks tertle ๐
at work our game is completely procedural - our scene is only single UI element for the first load screen
in our template editor, which are i guess mini scenes are just a collection of prefabs + bunch of data
(i was told it was written before nested prefabs even existed)
ive kinda always wondered whats best; have some sort of prefab database and only instantiate from a central location or just use prefab references here and there(or I guess a mix). also wish unity had a more dedicated asset browsers(and dont want to code my own)
i feel a bit sorry for our designers/artists
our tooling is shocking for them
im doing a bunch of pre-pre-production research for a new project
and dedicating a lot of time trying to ensure we have really good workflow for them
my objective as a developer is to basically code myself out of the job
i want to build enough generic and flexible tools that at some point, we only need design/artists on the project!
it's a dream that won't ever be reality but we can definitely reduce the need for artists/designers to rely on devs for adding content
the level editors of old(worldcraft, radiant etc) just have so much useful stuff that unity lacks
probuilder was a fantastic acquisition but it makes me sad it hasnt really changed since being bought out
i wonder if techblox is something that might interest you. It looks like they have a pretty deep level editor for users (made in Unity & by the guy who made Svelto.ECS)
have any links of the editor?
uhh, sorry i dont. Though you could download it cause that's where I saw it & played around with it: https://www.techblox.com
ah I was thinking more along the lines of say hammer for source2 https://i.redd.it/pmv0rnqe03041.jpg
ah thought you meant in game. Although I will say I'd be probably paralyze over an editor like this with all the buttons ๐
How come I can't seem to find any docs on ICollisionEventsJobBase? I wrote a struct that implements that interface, but I can't find where to call it? Or is it supposed to be called automatically?
I havent touched physics collision events for some time, but maybe theres something in the physics samples you can glean info from? iirc there is an updated branch now(though not sure how wip that branch is)
@coarse turtle maybe if I can figure out tertles saving system, I can make a half decent ingame editor for my project though, powered by nimgui ๐
dont think you're meant to use that
use ICollisionEventsJob (it inherits from it)
then just schedule using
.Schedule(this.stepPhysicsWorld.Simulation, this.Dependency);
Yup, you're right. My intellisense wasn't recognizing it because I didn't add Havok.Physics ASMDEF reference. Now I can I see ICollisionEventsJob
Why would it only execute once? I just do a simple Debug log in there. And on play the collision triggers (I'm assuming it's when the player lands on the floor) But any collisions after not are not intercepted by my script.
have you marked them as send events during authoring?
Yes my player character has Collide with Raise Collision Events.
Do colliding parties both require that flag? Or just one?
from memory you'll just get events on the entity that has the flag
my character's movement system alters the character's PhysicsVelocity. I confirmed that when the character "falls" on play, collision event triggers when hits floor (which does not have raise events). But when my character moves to an "item" and hits it, no collisions events are raised.
Can anyone help me when i start my own apk game it just shows a black screen
what do your logs say
Logs?
yeah the logs that tell you why you crash
its been a good 6+ years since i've touched android development but I assume you can still hookup logcat
I figured out why it was triggering only one time. It was because the system I wrote this in is only needed for that one frame until another circumstance triggers it on. How can I force the system to stay on even if no queries match?
[AlwaysUpdateSystem]
ah I see. thx.
Is there a place I can add a component to a prefab entity just after it has been converted from a gameobject?
I tried in the convert function but the entity doesnt have all its component data set (or converted) yet
you can use a GameObjectConversionSystem to do post processing if you want
public class PostConversionSystem : GameObjectConversionSystem```
does anyone know when unity 2021 will receive DOTS?
thanks
does someone know when hybrid renderer will get spot lights ๐
According to the manual it's supported for HDRP but not yet for URP
https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.50/manual/hybrid-renderer-versions.html
And they only say :
A future version of the package will contain a new version of Hybrid Renderer that will support all the features marked as "No" on this page.
Maybe more info on the forum ๐คทโโ๏ธ
I want the HDRP features without paying for the performance cost, do you know if there's a way to downgrade or lower the quality of the HDRP shaders to get performance close to URP?
Unfortunately I'm not a graphics expert so I'll will refrain to answer ๐
i'll ask on the srp area
@odd ridge should come with 2021 and deferred
it was actually working fine all the way back in 2021(year not version๐ข ) for a time in the betas before dots/entities reached that incompatibility and prior to the announcement of stay on 2020 lts
well, point lights with hybrid that is, I didnt try spotlights at the time
I have two systems, movement and sensory. Movement system schedules an ICollisionEventsJob which reads BuildPhysicsWorld.PhysicsWorld.Bodies.
The Sensory system does a point distance query on BuildPhysicsWorld.CollisionWorld.CalculateDistance.
Both are scheduled.
As a result, unity throws a safety error saying that one is trying to read to physics world bodies while another write. (I'm assuming CalculateDistance, forces a write?).
Anyways, what's a conventional way to have one system use Dependency of another system if they are separate systems?
Oh turns out I forgot to buildPhysicsSystem.AddInputDependencyToComplete(Dependency) after I schedule the ICollisionEventsJob.
Quick one for the Netcode folks.
Can I add commands on the server side of things for stuff like AI?
I feel like this would work fine but not 100% if I'd need some manual stuff to handle some auto acks or something like that?
@molten flame not sure what you mean by commands on the server side? The server can run your entire AI and just sent the positions for the result of an AI actor for example. So then the client has nothing to do with AI doing anything
It would be nice if I could reuse all the systems I use for players that take commands.
For example, I have a system that handles interactions between characters and other objects.
The input for the interaction is a command from the client.
I would like to be able to fake this signal for use on the server, e.g. pretending that an AI is just another client.
Commands are just a dynamic buffer, so I was just thinking this would be easy by adding commands on the server for the AI ghost.
So long as there are no gotchas..
i havent tried but if it doesn't work you can just reverse it, make command receivers simply convert them to 'server commands' that the AI also uses
let us know if it works though could have handy
If I am trying to debug a single system, if I use [DisableAutoCreation] on all other systems is that the same as a new entities project with just that system I want to test in it?
That's what we have been doing and it's working great
All you have to do is to make sure that the AI commands are stored with the correct ServerTick before the GhostPrediction runs
Hello all. I'm trying to do something with the Unity C# Job System that's trivially easy to do in single-thread but seemingly impossible to do with the C# Job System. Any help would be appreciated.
Basically I just need a job that calculates the distances between all positions. You would think that could be done with IJobParallelForTransform, but instead Unity is constantly throwing the error:
InvalidOperationException: CalcDistancesJob.dists is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
I obviously don't want the dists variable to be ReadOnly because that's what I'm using to store the distance values.
Anyone know a way to get around this issue and simply create a C# job to calculate distances between all positions?
For reference, here's the related code:
CALC DISTANCES JOB DECLARATION
[BurstCompile]
public struct CalcDistancesJob : IJobParallelForTransform {
[ReadOnly] public float3 starPos;
public NativeList<float> dists;
public void Execute(int i, TransformAccess tfm) {
dists[i] = math.distance(tfm.position, starPos);
}
}
SET UP AND SCHEDULE THE JOB
calcDistancesJob = new CalcDistancesJob {
starPos = transform.position,
dists = starDistances
};
calcDistJobHandle = calcDistancesJob.Schedule(taa);
Why don't you use a NativeArray?
@austere wren
Lists aren't great in multi thread because you can't change the size of the list while in a job so they are basically pointless
May as well use a standard Array
Funny enough, I'm actually reworking my code to convert from NativeList to Native Arrays. I still need a resizeable list outside of the Job, but within the job I'm using NativeArray and then casting the list to an array using .AsArray()
Still working on it but fingers crossed
Yeah I hardly use lists anymore. They used to be my go to
Hi, I'm trying to update my package to entities 0.50 but having issues with rendering anything. My existing entities don't render with a custom material which is fine if I need to change that, but I tried with just a simple Cube GO with ConvertToEntity set and this doesn't render either. I have also tried to render a default cube in a fresh project with entities 0.50, hybrid renderer 0.50, and URP 10.8.1 installed. What's the simplest way to just get something rendered as an entity for testing?
components from the cube
Component looks fine
I'm having issues removing a value from NativeMultiHashMap
I've written this, which I assumed would work:
if (map.TryGetFirstValue(originSquare, out Entity item, out NativeMultiHashMapIterator<int2> it))
do
{
if (item == e)
{
map.Remove(it);
UnityEngine.Debug.Log("Removed");
break;
}
} while (map.TryGetNextValue(out item, ref it));
Of course, it did not
Could anyone help a complete moron out.
I'm just trying to fill a fixed list with random floats...
public struct ThrusterTrail : IComponentData
{
//...
public FixedList4096Bytes<float> FlickerNoiseTexture;
}
//...
var thrusterTrail = new ThrusterTrail();
for (var i = 0; i < thrusterTrail.FlickerNoiseTexture.Capacity; i++)
thrusterTrail.FlickerNoiseTexture.Add(UnityEngine.Random.value);
I'm doing this in authoring code to setup a small noise texture but when I try to loop through the texture in a system its empty.
When does the component get added to the entity? After you fill the FixedList?
Yeah immediately after
next line is dstManager.AddComponentData(entity, thrusterTrail);
๐ค Honestly the snippet looks right to me. I don't think you have to do:
ref var list = ref thrusterTrail.FlickerNoiseTexture;
list.Add(random_value);
That's the only entity being generated and being read by your system?
Yeah, when I create the texture in the system as a global one using NativeList I don't have any issues
yea, I'm not really sure
before 0.50 I would fetch unity's default systems and add them to a custom world with world.GetOrCreateSystem(type);, but now that errors because some systems are now ISystem and cannot be constructed
what's the new way to do it then?
DefaultWorldInitialization.Initialize() I think
Mmmm this is at some point during runtime though isnt it
yeah that used to be in old version too but am not using that because i'm handling custom world
with not every unity system needed
oh but i could check how they do it in there so that's a lead at least, thanks @molten flame
AddSystemsToRootLevelSystemGroups maybe?
looks like there is some code for handling ISystem there
I need to handle joining a server, either start/stop systems that run the gameplay, or using some kind of event sent to the systems. Does anyone here have an experience, or know any resources that might be helpful?
are you using netcode or some other package?
no it's custom
we just have our default world with limited systems for menu/assetsmanagement/game management etc
and then we create separate client/server worlds when we want to start/join a server
we just have an interface to determine if a a system should be on client/server/both - IClientSystem, IServerSystem etc
though i'd do it with an attribute instead like netcode
which is how i do it in my personal project
though my personal project i use netcode and do things quite a bit different
I don't really have a default world i just create the client world in menu and then on join connect or on self host create the server (in future i'll figure out how to merge client/server for listen servers for performance)
i'm doing this so i can run mini game simulations in my menu to make interesting screens
but yeah that is not standard i dont think
I'm a little wary of adding a new world because it's going to be a big change
but I broke some stuff that used to use game objects for lifetimes but now with systems it's running all the time
Tertle do you have any published games using ECS right now?
You willing to share what it is?
i wouldn't use it as an example of how to develop an ecs project
Haha I wouldn't I'm just curious
the dev team basically converted an existing project to entities after a half week game jam to learn it
i was basically hired to help, let's say, iron out some problems
anyway it's called beyond contact on steam (consoles coming soon~)
if you were interested playing, i recommend waiting a few months we have some really large content drops coming - it was released as an actual early access with no advertising or anything yet to get feedback
but yeah my interest is more in our next project which I hope to build from the ground up as pure entities (as the vision for it is ridiculous)
Haha we also have a ridiculous vision we hope entities will help with
will probably be a bit healthier for me, i might not need to spend so much personal time to get my dots hit ^_^'
and here I am retrofitting systems to a 5+ year old game ๐
yeah so thats the problem, the code is over 5 years old
the server is nearly pure ecs but the client is 80% monobehaviours
and it's a nightmare
if i was to give advice to a team looking at converting an existing project it would be don't
if you need performance, rewrite chunks of critical code to use burst/jobs
it requires a big shift in thinking and if you do it on an existing project you'll most likely have to refactor it half a dozen times
and most teams who are looking to shift an existing project to dots are doing it for performance reasons
and if you design it poorly it can just run worse
apart from that, it is still an experimental package and many people who weren't up to date with how Unity wants you to use the package got caught out on just the 0.50 update
and the 1.0 package will be even more breaking
also takes quite a bit of time to train a team for it
way back when entities was first released publicly i actually took off 6 months of work to learn it
i was a bit burnt out at the time and was lucky i was in a position to be able to do this - but most people aren't
luckily these days there are plenty more resources and help available and it shouldn't take that long to get to a competent ability but it still takes quite a bit of time
and it's much harder if you aren't starting from scratch
i would say, evne though they've been working with dots for 2+ years i would say 75% of our devs still don't really have a good grasp on it because they haven't had to learn
not from a fault of their own, but because either they still spend a lot of their time on the client which is still mostly monobehaviours or most of their work involves basic systems that they can just mostly replicate from existing resources
they've never had a chance to learn, something i hope to rectify in our next pure project
anyway long slightly off topic rant >_> back to saving!
its dots, its on topic!
Are Hybrid Components no longer a thing in ECS 0.50? I can't find docs about it...
not meant to be touched by the user, theyre all internal now(or should be)
Oof. What would be a hybrid equivalent of 0.17 now? Or that whole concept is now out the window?
I did notice that if you place any GO in a NON-ECS sub scene, and slap a ConvertAndInject component on it, it will actually convert all of it's components to hybrid companions that you can access from ECS.
you can make a class component and store any managed unityengine component in it
I found a way. During conversion you can dstManager.AddComponentObject(myAuthoringCompanion), this will create a companion link in ecs. So when I instantiate my player, for instance, I have a global method that will Instantiate the registered prefab on ECS side, and instantiate a "shell" prefab on legacy side, and add that component as companion.
Is there a recommended way to run a โStartSystemโ just once at the beginning of the Scene? Right now I have a system group that is updated from a Monobehaviorโs Start method and then disabled, but systems running in that group tend to have issues like ECB. playback not working.
Iโve been thinking of using [UpdateInGroup(typeof(GameobjectAfterConversionSystemGroup))] and extending from GameObjectConversionSystem, but Iโm not sure if thatโs worth a rewrite
Nor if thatโs the intended use of GOCS
I think doing it in conversion in that group is best if you are able to
I had a few systems inside the initialize system group or whatever its called but changing components unnecessarily increases the archetypes and if you can avoid that during runtime its better
I do a lot of things in GameobjectAfterConversionSystemGroup so imo its quite handy and you should utilize it, not avoid it
Thanks. GOCSG runs only once at the beginning of the scene, correct?
should happen only once per gameobject converted but it could be runtime or edit time, depends how your project is setup
Got it. I have these Unit authorings which spawns a single Formation, a single Officer, and dozens of Soldiers. May I ask if these are the correct steps for spawning all of them and wiring up their references to each other?
- In the Prefab conversion group, spawn the officer, formation, and soldiers prefabs. Those are still authorings at this point
- In the pre conversion group, have the authorings reference each other correctly. For example, formation referencing the officer and soldiers, and soldiers referencing the formation
- Let the conversion group do its job
- All entities are now converted and wired up after post-conversion group
seems fine
Hello, when in Jobs -> Burst the Safety Checks are on, will this also be for the compiled game or is this setting just for playing in editor?
Just editor.
ok, thx
I have a fun problematic: I want to send information about my entities over the network.
For example, I have a packet that initializes a Unit (in my game) and takes in various data from said unit: It's health, equipment, name, owner etc..
Is it better to have one component with all the data for said unit, or is it better to have many components and "grab" them all, pass them into a function that serializes my data to send over the network?
One reason I have many components is stuff like Translation: I'd rather use Unity's built in translation component (I should, right?) instead of having my own
generally speaking I think the recommended approach is more components
it lets you have better control over exactly what's needed for each system
and lets the safety system be more finegrained
IE if you put health as a health component
it lets systems determine if they need to read/write to it individually
vs if you have it inside of a "stats" component
I figured that was the best approach. I do wonder how good it is to grab components around tho
I always have difficulty finding the changelogs for the Entities package.
Is there a list of changes somewhere for the new 0.50 version?
Id like to know what new things there might be to check out. Its been a few months since I worked with Unity
Awesome, thanks a lot
- you may find the upgrade guide useful https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/upgrade-guide.html
I have no idea how we are supposed to be able to install DOTS
since the build documentation is missing: https://docs.unity3d.com/Packages/com.unity.platforms@0.60/index.html
the com.unity.platforms package does not exist
I tried installing the entities package but I got a lot of build errors and a ton of .csproj files in my root
is there a starter project or something I can just download?
the https://github.com/Unity-Technologies/DOTSSample project was never updated lol 
0.50 not 0.60
and since 0.50 you need to uninstall any com.unity.platforms.X package, only com.unity.platforms remains
it's indeed an outdated Unite demo, try those instead : https://github.com/Unity-Technologies/EntityComponentSystemSamples
Why did unity add like 50 .csproj files to my project root?
is that intended?
I'm still getting around a dozen errors from the entities package
make sure you are on the latest 2020.3
anyone having trouble finding the hybrid renderer package? im adding it by git url and im getting an error
im on 2020 lts
oh it appears 2020 lts doesnt let you use those packages
I was off by one patch version and that was enough apparently, thanks
yes a detailed changelog would be great...
I see people had this problem, but being on the wrong version, so I'm a bit confused... I'm on 2020.3.31f1, the forum post about 0.50 (https://forum.unity.com/threads/experimental-entities-0-50-is-available.1253394/) mentioned min version of 2020.3.30, but when I try to install it, I get an error about it the package not being found https://i.imgur.com/K9zebpv.png
Yeah install the latest version. That fixed the issue for me. The docs are quite wrong
it is the latest
https://i.imgur.com/u14DRpF.png
So I am trying to reinstall Unity after a complete windows reinstall and now it won't let me install the jobs packages or the collections packages. Have those been rolled in with Burst?
Nope. Can you share your manifest.json file?
I am trying to manually add the jobs to my editor and returrns this error
Cannot perform upm operation: Unable to add package [com.unity.jobs@0.50]: Package [com.unity.jobs@0.50] cannot be found [NotFound] UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
Seems like Visual Studio 2017 has been completely depreciated
How are you adding the package? From the list in the package manager window?
I can't even find the jobs in the package manager window. The above error happens when I try to add it from a GIT URL
What are you typing in for the git url?
com.unity.jobs@0.50
Hmm, not sure why that isn't working. Try editing the manifest.json file instead
tried that, throws an error when I boot
this is crazy frustrating
thank you for the help
I've installed a ton of stuff before in the exact same way
there is something funky going on with my computer. I don't know why it is just refusing to find certain packages
Are you using "0.50" or this:
"com.unity.jobs": "0.50.0-preview.8"?
My project already has the package installed, but the git url method also isn't working for me
I mean it gives me the same error
oh thanks a ton. I just updated my manifest file with that exact line
and it can't be found. I bet something is blocking the URL
Yeah or maybe their package registry is having issues
Oh yeah, that is gonna be frustrating if this is entirely on Unity and just bad luck. Thank you for the help.
Seems you might not be the only one
same problem here
ah, I should have just looked up above
even if it were not, there's no reason to use 2017 anymore whatsoever. especially if you want to use dots, since 2017 has no support for source generators
ah fair enough. I've found updating my IDE super frustrating in the past so I tend to avoid it
I am trying to add the collections package and it just isn't flying -> the correct way to add a git URL is just hit the plus and then add com.unity.collections right?
it...should be working this way i think, but i'll get the a line directly from the manifest that you can paste into your manifest file and test it
I did that as well, no dice. Keeps throwing an error. I thinks something is wrong on Unity's side
i copied this manifest https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/ECSSamples/Packages/manifest.json like 7 of the packages don't work
and even though vs 2022 is not yet 'officially' supported, i've used it since preview version and had no real problems with it, even with unity. but vs 2022 is definitely waaaaay smoother and nice than vs before it
Thanks dragonblade, I am not going crazy after all
@worn valley @split cargo try pasting ONLY this into your manifest, preferrably empty project to test, "com.unity.rendering.hybrid": "0.50.0-preview.24", that should add everything of the other packages as a dependency
I should probably go directly to 2022 so I don't have to upgrade for years and years
I am actually only using Jobs / Math / Burst. I am not doing ECS right now
Just core DOTS
i recommend that at least, but like i said, not yet 'officially' supported by unity
2019 already felt slower to me than 2017. Maybe just imaging it
well, if it works though, you can just remove any packages you don't need via the package manager
oh true
2022 is the first time ever it's a 64bit process
yeah, maybe your local server is just fucked.
Dragonblade has the same problem too ๐ฆ
i mean, i could send you a cached version if you need it urgently
nah I think I'll take a break. This is too frustrating
https://i.imgur.com/Z9Ojlzm.png didn't work, I will give it a few days I guess
i looked at the preview packages for each of the unity versions. i was having the same problem. it looks like if you look at https://docs.unity3d.com/Manual/pack-preview.html then you change versions, it shows you what packages you can use
it looked to me like 2020+ didnt have any ecs packages
but 2019 does
but 2020 has netcode
so im confused
Tried typing this into the + git url com.unity.collections@1.2 and error thrown
does anyone know whether it's Ok for me to generate game objects for the purposes of converting them
the latest gave me errors, I had to go back to .pre @worn valley
and where it would be safe for me to do that
I was trying to generate them in an IDeclareReferencedPrefabs
but the gameobjects just end up in the world without being converted
what do you mean exactly?
I have a prefab cube
I want to generate a bunch of different scalings of it
and turn those into entities
and let the collider baking process run on those game objects as normal
but I don't want to save all those game object prefabs
I just want the entities
convert 1 prefab and set the different scalings / etc. at runtime
you can actually
not without regenerating the colliders
+1
then just do not add any collider and add all only at runtime
But the part that I'm trying to get out of this is having Unity prebake all of those various scaled colliders
im not exactly sure how you want to do this but you could make more entities in a conversion system that runs during GameObjectAfterConversionGroup and modify rthe collider
So I don't have to do that logic myself
I'm just trying to find a spot where I can add more game objects to the conversion process
Programmatically
what do you mean by .pre? Am I putting in the git urls wrong?
you dont want to make more gameobjects
you could do that, but that's kinda anti dots
I don't want to make any game objects at run time
I want to have generated game objects that get authored into entity prefabs
How is that possibly anti dots
yeah then do that. it's anti dots because you save many equal things that are only different in very few aspects
@worn valley easiest to not explicitly add collections and use whatever the other package requires as a dependency
@worthy rampart more generated gameobjects sounds like an editor script rather than conversion. if you want more entities from a singular cube gameobject, thats easy in a conversionsystem where you dont make new gameobjects
+1
@safe lintel Ah I see. I specifically need to use collections so I have access to NativeList<T>. So yeah, kind of hooped now.
you can still use it if it's brought in as a dependency
I am getting weird errors that won't load specific packages.
Yea that makes total sense, I probably will end up using an editor script
I am guessing yes
if you want to add it manually
I guess I thought it wouldn't be weird to want to generate game objects specifically for the purposes of immediately converting them
Thanks so much @haughty rampart
https://github.com/needle-mirror
has most of them if you ever need
I had no idea, you are awesome
i haven't actually checked but i assume 0.50 physics doesn't support uniform scale yet right? i believe it's a coming feature though
that's a shame
i believe they said they don't intend to support non-uniform scale
Yea I think I read that as well
Hey guys, hope everyone is well. I finally have time to stab at .5 upgrade. Tertle is very helpful and gave me many ideas.
0.50
can I rely on stablehashes in EntityArchetype's for serialization?
ive sort of been looking forward to trying it(but then at the same time not needing to use it is preferable)
How are you all handling animation at this point
you have to use Mecanim. the gameobject based animator
Hello. How do I change this to a .foreach Systembase in order to convert to .50? The code I think of interest is in UPDATE(){} https://pastebin.com/mGzjXw9F
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I have no idea what the old code did, but it was the only code that was able to check for collisions properly for me
you dont need to change anything really
just override the correct OnUpdate
change inputDeps to Dependency
and for 0.50 you'll want to add this.RegisterPhysicsRuntimeSystemReadOnly(); in OnStartRunning
i cant remember if ICollisionEventsJob schedule method changed
I do not have a for each in this.
How do I change that Update to a .foreach. I know what a .foreach is, but have no clue what that blackbox style thing that is in the update is doing.
Thank you for help tertle. I believe I can get to .5. You helped me before.
yeah you dont have an entities.foreach so you dont need to change anything
just use your same job
After updating everything to .50, nothing that uses the hybrid renderer is rendering anymore, was there any guide for needed updates for rendering?
are you manually creating your entities or using authoring
also were you using V2 before the upgrade?
manually, and I'm not actually sure
probably not adding all the components you need - i usually strongly advise against doing it manually for this reason
the only explanation in the docs seems to be https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.50/manual/runtime-entity-creation.html
so I updated my list of components with the ones RenderMeshUtility.AddComponents uses
ok that's working now, I had to set the rendering layer and world transform params components
I'm creating an archetype but AddComponents wants a live mesh
What is fastest way to add all basic entities packages?
"com.unity.rendering.hybrid": "0.50.0-preview.24",?
Steal them from one of the projects on that
If you just want to edit the file in repo
nah, installing renderer is enough kek
I don't need it
๐
i find it works quite well
You don't use that, right?
no
Is there any tutorial on what you are doing?
I am trying to find it in google, but no luck yet
doubtful
since i kind of just invented the pattern i use without reading anything ^_^'
tldr: my settings have bindings setup via InputActionReference
these are stored on class based IComponentData
i have a system that creates bindings in OnStartRunning
that reacts to the input events
then I apply it every frame in OnUpdate
i also have a state system that enables/disables separate entity mappings
which just requires me to call the extension method
this.InputEnable("build");
in my game state system
to enable the key bindings for this
basically all my keybindings in inputsystem are separated into their various action maps and these maps match to different game states
many benefits, can easily enable/disable a bunch of keys for different game states
but also it makes rebinding keys really easy
you can disallow duplicate key bindings within a mapping but safely allow duplicate key bindings in different mappings as you know* they won't be active at the same time
So in other words you create action map for every action?
no
groups of actions
Might be
Player
Vehicle
Menu
GameMenu
etc
(I have no vehicles in my game but it's a common example)
I already tried once and failed. This is calling a loop outside the CollisionJobLoop? Can .Foreach call loops outside loops? I have no idea how this chunk of code I downloaded worked, so I don't know how to turn it into a .foreach https://pastebin.com/mGzjXw9F
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
hmmm
is it possible for me to attach an existing scene
as a subscene to a different scene
why do you keep mentioning foreach? you aren't using one
This is what I'm hung up on: https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/upgrade-guide.html#systembase
don't download code. write it yourself so you understand how it works. stop everything you're doing
I have two JobComponent Systems I need to turn into SystemBase. In order to do so. I need to know what I have in this boilerplate code I downloaded in order to turn it into a .for each. I took about 30 hours trying to do collision on my own, and this was the only stuff someone directed me to download that worked. I don't know what it does, but it worked.https://pastebin.com/mGzjXw9F
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm a professional software engineer, coding since 1980 and have a computer science degree from Carnegie Mellon. I've coded millions of line on my own... ECS/DOTS just sometimes you gotta go with what you get, right?
I'm not asking a million questions, just one.
then it should be no problem for you to figure out what that code actually does
Sir
Let me tell you a story.
There was once a man who bought Toyota.
He's been telling time since elementary school. He knows digital and analog.
But to set the clock, he must read the mind of a Japanese Engineer.
It is not his inability to tell time that prevents him for doing this... Just like a software engineer can be great at coding, and not know someone else's API.
literally, just rename the base class to SystemBase, keep everything the same, and only change the things like Dependency, etc...
I'm aware I do not have a .foreach. You jumped into this one fast.
I repeat : I already tried once and failed. This is calling a loop outside the CollisionJobLoop? Can .Foreach call loops outside loops? I have no idea how this chunk of code I downloaded worked, so I don't know how to turn it into a .foreach https://pastebin.com/mGzjXw9F
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
How do I turn that update into a .foreach I don't know how an inputDeps = new CollisionJob translates into a .foreach
what loop are you referring to? that code is like 500 lines
It's physics job
.5 does not accept JobComponentsystems
Stop looking at entities foreach
Yes
Its in my class: public class ObstacleHitSystem : JobComponentSystem
And job vs system has nothing to do with this
You can write foreach in job component system
+1
I have two classes of JobComponentSystems which are critical to my game to keep playing.
Yes change it to system base
Rename the on update
Change inputdeps to Dependency
And you're done
literally what you've been told before
Oh I don't need a .foreach? Thank you.
You need foreach as much as you need it in the job component system
Plz Mind, you're not being helpful, but kinda just putting me down for some reason...
System base is really just job component system and component system
Merged into a single system
(at least that's how it started)
I've seen it used interchangably.
wtf, we've been telling you that you don't have / need a .foreach
no. JCS is an old legacy version. SystemBase is the new way since at least .17
I was able to change to system base, and fix the update. That went off without a hitch. I am not familiar with what a "inputDeps = new CollisionJob()" should become. There are three problem lines inputDeps is causing as illustrated here: https://pastebin.com/4Uhw5ZAe
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
remove inputDeps =
Thank you. I did that before, but the remaining two problem lines persisted so I wasn't sure I was ahead.
what's erroring now?
}.Schedule(_stepPhysicsWorldSystem.Simulation, ref _buildPhysicsWorldSystem.PhysicsWorld, inputDeps);
&
_endSimEntityCommandBufferSystem.AddJobHandleForProducer(inputDeps);
remove inputDeps
I have tried that. It produces new errors.
or rather, change inputDeps to Dependency
That took away errors. Much obliged. Remember, I'm a nice guy. I really am altruistic. If my games make good money and you remember helping me, get ahold of me in the future and I help you back n stuff. Love's the way bro. Thank you so much for help guys. We are all team humanity. Lets see if I can get it running or if there are more errors.
I really appreciate all the help of all of younz.
I'm a solid software engineer, but techs really brick wall me hard. Both Mindstyler and Tertle I really appreciate the help from or I'd be stuck for days on this, maybe never get past it.
๐ i was just a bit irritated because you've been told what to change before. i apologize
You don't have to apologize, you fixed something of utmost importance to me. Being burnt with sarcasm kinda actually is funny. But fixing my problem is a billion times better than that.
On runtime I get this error: InvalidOperationException: The system ObstacleHitSystem reads EntityData via TriggerHitSystem:TriggerJob but that type was not assigned to the Dependency property. To ensure correct behavior of other systems, the job or a dependency must be assigned to the Dependency property before returning from the OnUpdate method.
where you previously had inputDeps = change it to Dependency =
Ohok!
yeah....physics jobs are a bit different than normal jobs, so that's maybe why you get the error
no actually, i wasn't smart. you only don't need to assign to Dependency when using Entities.Foreach(), but since you have a job struct, you definitely have to assign to Dependency
Looks like I'm flying in space and still colliding. I need to do more tests.
Are there any pitfalls with the following setup?
SystemA requires some setup
SystemB does that setup, but is [DisableAutoCreation]
In it's OnCreate, SystemA GetOrCreateSystem SystemB, enables it, and calls Update() once. Then it disables it.
The reason is that SystemA's setup requires iterating over entities, so like any query, but only at the start of the game
why don't you just do a query in OnCreate() then?
I'm worried that making SystemB a GameObjectConversionSystem instead would trigger it every time Monobehavior conersion happens
I never knew that was allowed. I'll try it
Does that mean that Systems' OnCreate are called after all entities are converted?
or you could also just put the query in OnUpdate() with .RequireSingleton() and after it's done, remove the 'empty' singleton component. then it will only ever run once
Thank you. Your first suggestion worked perfectly and it's behavior implies that it ran after the conversion completed
No, they're called when the world is created and it adds the system to the world. (If you also call World.GetOrCreateSystem, and the System wasn't created, then it's also called.)
That's odd. I just had OnCreate do EntityQuery.CalculateEntityCount and it returned the correct number of entities with a certain archetype in the scene.
Oh I remember now, conversion happens in the Conversion World but the systems are instantiated in the Destination World which happens after CW, and thus after all entities are converted
exactly
A beginner's question: Can ECS 0.50 be used in Unity 2021? Or will this be possible when ECS 0.51 is published?
0.50 is only compatible with 2020.3 right now. 0.51 will be compatible with 2021
ok, ty ^ ^
One more question that may sound strange: Can I use DOTS with the standard Unity environment
(GameObjects, MonoBehavior), a kind of hybrid? For example, can I call a function, from a MonoBehaviour class / component, inside the "DOTS class"?
Yes, you can. Where you should and shouldn't is another matter ๐
Please use MonoBehaviours responsibly ๐