#archived-dots
1 messages ยท Page 36 of 1
about how much data you send....
i mean in general
implementation wise it shouldn't matter what i decide on how to network
the system as a whole just sounds majorly wonky and confusing
I feel like your prediction layer is going to be very tough
likely very hard to track down bugs
that sounds like a you issue thou?
like if i do run into those problems sure thats on me
exactly, it's gonna be a you issue
but it shouldn't matter to you
this isn't a library
i built for this game
so its not like it hasn't been tested
is it a library built for entities?
Just out of interest what player count does it handle up to
unfortunately i've never stress tested that
And what network conditions
i've never considered making a mmo
or anything with large mp design
(so at most 4 player testing)
Will it handle say mobile conditions of say 5% or even 10% packet loss
Just curious
yeah packet loss isn't a problem
it does packet replay
and has a way internally to resync where possible
but thats assuming non-corrupted state
There's a point where that causes more issues by adding an ever increasing delay
going back to your previous issue: sync a timer over the network
We've had issues resending world data when missed
oh just to confirm
this isn't a realtime library
or not designed for realtime
ie/you wouldn't use this for a fps
?? so a turn based game or smth
doesn't have to be turn based
but high paced real time sync isn't the design in mind
anyway
like i said
you can just sync every 5 seconds or so
this isn't a you problem
its a me problem if it has any problems
i just wanted to know how to change / cap the simulation speed
told you that already
i'm not asking you to tell me again
i was just reiterating what the question originally was
you can also just adjust the targeted framerate if that's an option for you
where?
entities has a own clock on framerate and stuff independent of mb things
the targetframe adjustment is context sensitive?
there's a framerate for MB and a independent one for entities
so how do you change the entities one?
am trying to find it currently.
fair enough
haven't needed that for a while
i'm still searching, and unfortunately i don't have any pre 1.0 projects anymore, but iirc, in the entities Time class (not UnityEngine.Tme) you can say Time.timestep = 0.2f or similar.
if that's not there, you could set the fixedtimestep and put your systems into the fixed update group
(or maybe that's even what i remembered in the first place, not sure)
apparently its systemClass.Timestep = blah;
๐
var timeStepGroup = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<FixedStepSimulationSystemGroup>();
timeStepGroup.Timestep = 60;
yeah seems like you have to put your systems in the fixed simulation group then
hi... is the dots system fully ready and we as users should starting using it or is it still in beta?
it's prerelease 1.0, so good foundation. but even 1.0 release is marketed as: for advanced users who want to leverage the performance.
so for the near future there won't be any more huge breaking changes and the system is stable, but it's not targeted to beginners
I understand... thank you ๐
you're still highly encouraged to try it and it's production ready.
but there are also many features missing you might be used to with monobehavious. e.g. animation, sound, pathfinding,...
oooooh... I NEED animations and mono behaviours
it is encouraged to do a hybrid workflow for now, so animation and stuff still sticks to monobehavious while you do the hard lifting of logic and game managing with entities
I see
thank you
I will start learning ๐
thank you again
How come if I change the scale with Scale component data, it does not change the mesh graphic's scale?
#if ENABLE_TRANSFORM_V1
EntityManager.AddComponentData(e, new LocalToWorld());
EntityManager.AddComponentData(e, new Translation
{
Value = transform.position
});
EntityManager.AddComponentData(e, new Rotation
{
Value = transform.rotation
});
EntityManager.AddComponentData(e, new Scale
{
Value = _bulletData.Scale
});
#else
EntityManager.AddComponentData(e, new LocalToWorldTransform
{
Value = new UniformScaleTransform
{
Position = transform.position,
Rotation = transform.rotation,
Scale = _bulletData.Scale
}
});
#endif
But if I change it in LocalToWorldTransform it scales the mesh's scale
What's going on why? @@
Are you using physics?
oh just an update its 1/60f assigning it 60 makes it simulate an update every 60s lol
now its decoupled from fps woot
Yes
well, duh
You need composite scale
Ok I'll try that
shh i knew that
it's the timestep, not the fps :P
Do I need both Scale and CompositeScale or just one of them?
Just composite
Ok cool
Does not work, or maybe I setup wrong?
Show what you do
_combatEntityManager.AddComponentData(e, new LocalToWorld());
_combatEntityManager.AddComponentData(e, new Translation
{
Value = transform.position
});
_combatEntityManager.AddComponentData(e, new Rotation
{
Value = transform.rotation
});
_combatEntityManager.AddComponentData(e, new CompositeScale
{
Value = _bulletData.Scale
});
_bulletData.Scale is float
I found that changing the y rotation value scales the projectile
Rotation.y is the new scale component y'all bamboozled me
just sounds like it's scaled in wrong direction
Jokes aside it isn't solved, I'll just brute force it
4x4 means 256 possible combination, I'll try it all
just convert game object with scale
and see
how it's done
lol
Boom
yeah, that's what I meant
Unity 2022.2.0b11 has fixed the player crashing when containing a subscene in the scene. When having set the compiler to IL2CPP
Yep
So, setting Composite Scale does not change the LocalToWorld scale matrix
hopefully subscene baking doesn't require running game anymore
Burst: Support for detecting managed breakpoints in code compiled with burst, and automatically switching the affected code to the mono execution path to allow managed debugging. Requires Burst 1.8
from the patch notes
cool
Is this a good or a bad thing?
it's a promised feature
now you can attach breakpoint
and it'll disable burst for this job
if you use managed debugger
Cool ๐
I ran a quick 2022.2.0b11 test with a IL2CPP build to the Quest 2.
Although it didn't crash, I'm not seeing my object in the Subscene...

Odd, I do have a problem with with one of my objects which appears pink for some reason. And if you have the Android build set to "Release" instead of "Develop" it will appear invisible. Maybe you have it set up this way?
Nope, Dev...
I believe someone else had issues with materials as well but don't remember who...
Hum
Well, magenta anyhow...
Well this material has its texture generated on runtime so maybe for some reason it doesn't like that
On the editor works 100% fine though
Maybe a syncing issue?
Wait, are you waiting until the subscene is loaded?
I mean on your issue...
Oh
I'm not waiting, should I?
I do a bunch of stuff on a "Awake" void of one of my scripts that requires the subscene to be loaded
To make sure its loaded I infinitely check for one of the necessary entities to appear with the EntityQuery function
If it doesn't find it, it waits a frame and then it repeats
Actually this simple test has Zero scripts...
When it finds it it turns on all scene objects
Well it's not what I was talking about then
Is there no callback for it?
I assume so...
Shows up in editor also...
I'll try a mono build...
Mono works...
Ok, btw I have updated from 2020.3 and since then my right eye on the Quest 2 has a lot of visual glitches on the edges of objects. (Lots of flickers and Magenta pixels) Do you by any chance have the same problem? I'm running vulkan.
Odd
Just checking (I don't know if it matters) have you also set the compiler to IL2CPP on the project settings or only in the build configuration?
Also I have set it to only compile for ARM. 64
No magenta...
I kind of expected it to work with Mono as it seems to be an IL2CPP thing...
Have you tried this to fix your issue?
This is my configuration if you want to compare
this was already working
not sure why it was added again
Resizing with old transform Entities 1.0ex8
What is this?
didn't work for me ๐ค
I also have it set to runtime data
also for some reason prefab instantiation doesn't work for me in baking
Try clearing the Entity cache
what's worse - Editor gets corrupt and requires restart
Where is this?
^
worked for me ^
it was added in like ~b6
sometimes the IDE disconnects weirdly though and the breakpoints stop working, usually requires a resync of projects
Is experimental Entities 1.0 only for Unity 2022? Should I still use Entities 0.51 and Unity 2021 LTS to make a full game?
1.0 will only work in 2022.2b8+
do not expect it to be backported
full release should come with support for 2022.3 LTS
so it depends entirely on your timescale
if you aren't aiming for a release for say 2 years the you should definitely use 1.0
but if you were looking at a release in next 6-12months then i would definitely consider staying on 2021/0.51
Are you not using the Build Configuration Pipeline to compile DOTS projects?
I would be making the game from around this December to June 2023.
You have to use it or it won't work
To use it Right Click your project > Create Build Configuration
And then configure the same way I did
Ah, shoot!
I forgot about that...
oh god, I'm getting so done with all these bugs ๐ฅ
var planet = buf.Instantiate(planetSetting.planet);
buf.AddComponent(planet, new Parent { Value = e });
buf.SetComponent(planet,
new Translation { Value = new float3(planetSetting.distanceToStar, 0f, 0f) });
this causes error in baking resulting in errors spammed until editor restart
How stable is Entities 0.51.x at this point?
Great, thanks!
I may look into it tomorrow. It's not a high priority for me any more since my client changed my directive...
Alright ๐
it's stable enough, but it's just dead-born
Good night!
too many changes compared to 1.0
so
I wouldn't start project on 0.51
unless you are ready to fix entities package yourself
I doubt stable 1.0 will release early next year though.
is there a simple way to calculate chunk capacity in query?
archetype should have it
chunk have it by itself, but i want to get all possible entities count for query without allocating new chunks
just count all chunks?
all chunk's capacities
like currently possible count of entities
how much space i have for entities with current set of chunks
all chunks * capacity of archetype
yes, but query can include various archetypes
I guess it would be
get chunks for your query
and just calculate it one by one
yes, so how to do it quickly?๐
bursted?
i guess in 1.0, when all chunks have 128 entities (or somewhat) i can just multiply chuck count to 128 without checking it's capacity, but maybe in some future updates some chunks can again exceed 128 capacity, because they will have no switch state components
not all
128 is a cap
it can be lower
oh, yes, lol, stupid mistake ๐
i remember there was some unity's example of custom native container which was a simple parallel sum writer, so i can try to implement parallel sum container for such purposes.
what i'm trying to achieve is:
i have some number wich is current count of entities. and i want to detect new chunks and resize current count to chunks summary capacity
๐ค
why?
changing count of entities would be removing/adding
and I doubt you want to fill unwanted archetypes
No no, sorry, I didn't express myself clearly
i have compute buffer i want to resize to entities count in some query. But i want to resize it accordingly to new chunks capacity
like if there is some count exceed, i want to detect what chunk it was and expand compute buffer to it's cap
why not just calculate entity count then?
Because in this way i can be i situation, when i create new entity every frame and expand (reallocate) compute buffer and then fill it with data every frame, which is not great, so i have some step
but do it only on higher value
maybe i'm over complicating, so i can just have const step
if (bufSize < entCount) { bufSize = entCount;}
yeah, so you can update buffer size every frame with such solution
only if it's above
this way at some point you'll reach some highest value
and buffer will be fixed size for a while
what you mean highest?
assuming you don't increase entity count every frame without ever removing them, no?
i can imagine case when i just create entity every frame without any removing
like spawning some units in strategy game without killing old ones
well then, you're gonna run out of memory anyway soon, so does it matter? ๐
good luck reaching entity limit
theoretically if your entity has lots of components with lots of data you can reach your memory limit
of course
but still spawning one entity in frame will take so much time to reach any limit
but chances of that is pretty low
I struggle to handle 100m entities on 32gb ram in editor
i should try that for fun
did you just spawn 100m entities?
or did they also have components
50:50 crash
Full components
No they aren't renderable entities
ahh okay
I was stress testing my effect and condition system
lets see...
Technically 110m entities
whats the max size tilemaps handles
10m being targeted by 100m effects
welp
nativearray has a max length
it looks like
doesn't like 50,000 * 50,000 length
int should be max size
ahh its int.maxvalue sure
that makes sense
welp that was easy
is the editor window only 32bit?
(aka does it only allocate 4gb of ram)
oh shit nvm
Haha yeah nah unity editor only using 4gb of memory is a really good day
How to fix this? structs cannot be passed to or returned from external functions in burst. To fix this issue, use a reference or pointer.
Trying to create extensions.
public static class Float2Extensions
{
[BurstCompile]
public static float3 ToFloat3XY(this float2 position)
{
return new float3(position.x, 0, position.y);
}
public static float2 MoveTowards(float2 current, float2 target, float maxDistanceDelta)
{
return current + MoveTowardsDelta(current, target, maxDistanceDelta) ;
}
public static float2 MoveTowardsDelta(float2 current, float2 target, float maxDistanceDelta)
{
float2 toVector = target - current;
float sqDist = toVector.x * toVector.x + toVector.y * toVector.y;
if (sqDist == 0 || (maxDistanceDelta >= 0 && sqDist <= maxDistanceDelta * maxDistanceDelta))
return target;
float dist = math.sqrt(sqDist);
return new float2(toVector.x / dist * maxDistanceDelta,
toVector.y / dist * maxDistanceDelta);
}
}
Why these can't be burst compiled?
Nvm I found out they will be bursted if the calling method is burst compiled.
use in or ref
for every parameter
burst only works with pointers
Ok I see, thanks!
Anyone know how we access the destination world in baking systems?
should be World
property
doesn't seem like it
my entity index/version is different between baking system and runtime system
In my case, which params would be in or ref? I don't really understand.
in - readonly
ref - writeaccess
Is your goal to burst compile these?
If you want to burst compile static methods you can't have a return I think. All arguments must be either ref, out or pointer.
you can
didn't work for me last time I tried, but maybe they changed it idk.
hmm
actually
not sure
Yep, they seem to be perfect target for burst compile
Extension methods usually are a lot of operations right
I'll do some more research and see if someone alrd encountered it
you don't need to compile such methods specifically
just call them from jobs
or burst compiled code
they will be compiled authomatically
you attach compile attribute on methods only if you want to call Bursted method directly in your code
Ok I see, thanks!
๐ฅฒ windows il2cpp build still not working properly yet but seems like it's better now at unity 2022.2b11
[Worker0] ArgumentException: DestroyEntity(EntityQuery query) is destroying entity Entity(64:1) 'Pluto' which contains a LinkedEntityGroup and the entity Entity(64:1) 'Pluto' in that group is not included in the query. If you want to destroy entities using a query all linked entities must be contained in the query..
Unity.Entities.EntityComponentStore.ThrowDestroyEntityErrorFancy (Unity.Entities.Entity errorEntity, Unity.Entities.Entity errorReferencedEntity) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityComponentStoreDebug.cs:592)
Unity.Entities.EntityComponentStore.ThrowDestroyEntityError (Unity.Entities.Entity errorEntity, Unity.Entities.Entity errorReferencedEntity) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityComponentStoreDebug.cs:582)
Unity.Entities.EntityDataAccess.DestroyEntitiesInChunksDuringStructuralChange (Unity.Entities.EntityQueryImpl* queryImpl, Unity.Entities.SystemHandle& originSystem) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityDataAccess.cs:596)
Unity.Entities.EntityManager.DestroyEntitiesInChunks (Unity.Entities.EntityQueryImpl* queryImpl) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityManager.cs:4763)
Unity.Entities.EntityManager.DestroyEntity (Unity.Entities.EntityQuery entityQuery) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityManager.cs:3338)
Unity.Entities.RemoveEntityInBakeDestroyEntitiesSystem.OnUpdate () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities.Hybrid/Baking/RemoveEntityInBakeDestroyEntitiesSystem.cs:21)
i wasnt aware of this behaviour 0.o is this new?
idk what's up with it
but it's super annoying
and I don't know how to deal with it
looks like
I can't instantiate anything
which sucks
baking only allows to instantiate additional entities right? not entities spawned from a prefab
is that true even for baking systems?
well you could let the linked entities match the query in RemoveEntityInBakeDestroyEntitiesSystem
@rustic rain instantiating gameobjects inside bakers to then let their bakers run doesnt work right?
not allowed
you'd need a prebaking step ๐
anyway from the editor to tell how many entities exist?
(also can you custom name your entities)
๐ฅด
๐ฅฒ omg. This baker behavior differently
Hi, is there a way to check if burst is enabled in code?
declare boolean
and use [BurstDiscard] method
to change it's value
if changed - no burst, if not changed - burst
cool, I'll give it a try ๐
Hey guys, what's the proper way of loading/reloading a hybrid ECS level? I run into errors no matter what I try, here's the closest I've gotten:
SceneSystem m_SceneSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystem<SceneSystem>();
manager.DestroyEntity(manager.UniversalQuery);
manager.CompleteAllJobs();
SceneManager.LoadScene(0);
m_SceneSystem.LoadSceneAsync(m_SceneSystem.GetSceneGUID("Assets/Scenes/World1.unity"));```
I get this error:
u can use EntityManager.SetName()
๐ฅฒ
Unity.Entities.IBaker.CheckValidAdditionalEntity (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities.Hybrid/Baking/Baker.cs:1383)
Unity.Entities.IBaker.AddComponent[T] (Unity.Entities.Entity entity, T& component) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities.Hybrid/Baking/Baker.cs:1556)```
you can only use CreateAdditionalEntity while baking
๐ฅฒ This is disaster. I need to rethink and rewrite most of the code just to make it compatible with baker
I feel you. Took 4 days to just get to the point where i could press play again. Now i have to rewrite some systems to match the baker workflow too.
Where unity devs when you need? ๐
So I've been reading over the new DOTS guide, and reading through the ECS tutorial, and I've noticed that it doesn't ever actually use state.Dependency when scheduling jobs. My impression (from reading the documentation it's made quite clear) is that you should always use/set state.Dependency whenever you schedule a job in a system. Is this excluded in the tutorial just because their jobs don't happen to overlap? Is it still the best practice to use/set state.Dependency anyways?
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/DOTS_Guide/ecs_tutorial/README.md
You should always pass in state.Dependency for jobs, HOWEVER. IJobEntity has automatic implicit dependencies (as the exception). So when you pass your own JobHandle into an IJobEntity you'll take control, however if you don't pass in a jobhandle, it will complete the dependency for you, so:
new MyJobEntity().Schedule();
// is equal to:
state.Dependency = new MyJobEntity().Schedule(state.Dependency);
// but this is not equal, and since you passed a jobHandle yourself, you have to set state.Dependency yourself:
new MyJobEntity().Schedule(state.Dependency);
Huh, okay! The other page on SystemState.Dependency (https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/DOTS_Guide/intro/intro-entities.md) doesn't mention that, and I don't see any other docs on that, but maybe that's excessive information for that section. I know it's all WIP. But that's really good to know - thanks!
I think what's really confused me is that many of the examples I've seen online just kinda do it anyways.
No worries! I'll take that into account for the IJobEntity docs, thx for the feedback! ๐
I suppose maybe that's what the (directly or indirectly) bit means, and I just wasn't aware of the indirectly bit!
Potentially ๐
What would be the intended way to instantiate additional GameObject (or entities) during baking?
let's say I want to have one MonoB with fields for prefabs and then spawn them through code during Baking. Is there even a possibility to do that atm?
@proud jackal Btw any plan to improve this for baker?
actually this is directly related to my question above ๐
I guess it's different. What I want is able to add component to child entity at baker
oh, little confused
Now with baker it's not possible anymore
yeah, that's not supported and shouldn't be actually according to current workflow
๐ฅฒ
Well, baking can't spawn GOs, as SubScenes can't contain GOs, but you can have baking create the runtime rdy format to spawn them as soon as the scenes load 
class MyAuthor : MonoBehavoiur {
public GameObject[] prefabsToSpawn;
class PrefabsToSpawn : IComponentData {
public GameObject[] prefabsToSpawn;
}
class Baker : Baker<MyAuthor> {
protected override Bake(MyAuthor myAuthor){
foreach (var go in myAuthor.prefabsToSpawn)
DependsOn(go);
AddComponentObject(myAuthor.prefabsToSpawn);
}
}
}
partial struct MySystem : ISystem {
//..
public void OnCreate(ref SystemState state) => RequireForUpdate<PrefabsToSpawn>();
public void OnStartRunning(ref SystemState state){
Object.Instantiate(state.EntityManager.GetComponentObject<PrefabsToSpawn>(SystemAPI.GetSingletonEntity<PrefabsToSpawn>()))
}
public void OnStopRunning(ref SystemState state){
Object.Destroy(state.EntityManager.GetComponentObject<PrefabsToSpawn>(SystemAPI.GetSingletonEntity<PrefabsToSpawn>()))
}
}
I think will do the trick
bakers are run in parallel and meant to only add data or temporary data to main or secondary entities
ah that sucks
I suspected that this is the only way rn
but I didn't want to accept it ๐
btw
is there any baking specific components rn
so for example
I create additional entities
in Baker
and then I just copy archetype and all component/sharedComp data from prefab entity to that additional entity
Do pls write you message in one message haha ๐
can it break anything?
I mean that sounds right but I wouldn't be the person to go to there, depends on the behavoiur you want? 
Here's the code I want to run to copy entity data into another
question is:
there used to be conversion specific components that were removed after conversion and they also used to be entity specific.
So is there anything like that in Baking so that maybe I should avoid it for certain Component Types?
When baking happens there can be baking comps, if you were to copy an entity's data from one to the next inside a baking system, then both entities will now contain the same comps including baking comps, and any subsequent baking systems dependending on those comps will take affect run their baking stuff, just like how it works in runtime. This said, the baking comps won't be there if you were to copy in normal runtime, as baking comps are only present in baking systems.
The baking comps (components not serialized) are marked by [BakingType] and [TemporaryBakingType]. If I were you I would just search for those and see which comps use them.
I'm talking about internal comp types
which currently we can only find out by debugging baking execution
When detecting when an entity is instantiated within a system, is CleanupComponent the way to go? I understand how to use it for detecting destruction, but creation, I just do With<SomeData> and None<Cleanup> ? Is that the new convention now?
yes that is how it's always been
if you dont have to cleanup i guess you could just use a normal IComponent to mark it
thx. I'll add it anyway in case later I will need to do some cleaning.
you need to be aware that you specifically HAVE to cleanup the component then when you destroy the entity.
As a somewhat more complex extension of my previous dependency question - The automatic (implicit) dependency system seems to automatically operate on entities/components and figures out the right depedency chaining. Is there any way to build on top of this automatic system? Is it attribute based? Or completely internal to components?
In my case, I'm basically trying to pass a few NativeQueues to a number of systems that spin off jobs, and I want those jobs to complete prior to the job that processes the queues. I can certainly handle this explicitly (seems like Tertle's event system takes this approach?), but I'm just wondering if there's any way to be implicit about it to avoid the duplicate code?
that basically works automatically. just order the systems with the [UpdateAfter/Before] attributes
Auto dependency uses components to figure it out. If you add your queues to a component and access them via the various EM/SystemBase/SystemAPI/ISystem methods the dependency will be handled for you.
My impression is that that doesn't imply job ordering in the way I'd want it to?
That is, the UpdateBefore/UpdateAfter attributes.
UpdateBefore/UpdateAfter is just the order the systems update, it doesn't affect the dependency directly
Right.
So, I did consider using a component as a placeholder. My concern is how that would order the using systems. If they're all on one component, and I want (A,B,C) as generators with (D) as a consumer, then you'd end up with an A -> B -> C -> D dependency chain or something like that.
im pretty sure it does. one systems dependencies are resolved before other System that is depending on it runs. Dependency = new job.Schedule(Dependency) basically tells the next systems to wait for this Systems Dependency
yes
So you'd have to create a separate component per-queue to get the chaining right. Which... works. But honestly isn't much better (or maybe worse) than the explicit dependency management approach. Maybe it would look nicer.
No, only if the two systems happen to read/write to the same component
Dumb question, can ECS systems be run in Edit mode? ie non-playmode? I saw there is a WorldFilterFlags.Editor
yes thats true
If system A reads and writes Comp1 and system B reads/writes Comp2 and they update after eachother, then their jobs will run in parallel.
you can see them running if you check out the editorworld in the systems tab.
Thank you
So, maybe to get back to my initial question - is it possible to tie into the automatic/implicit dependency system at a deeper level? Or is that automatic/implicit system strictly for IComponentData?
Their system uses Types (Components) as the granularity, if you want finer granularity you'll have to handle it manually.
Well, I'd generally say that I'm okay with type-based granularity. My queues do have types, after all. But they're not IComponentData types.
I suppose that's not really true. What I'm really trying to avoid is the "this.Dependency bookending" in every Update method that something like Tertle's event system seems to require:
protected override void OnUpdate()
{
this.Dependency = this.eventSystem.GetEventReaders<TestEventEmpty>(this.Dependency, out var readers);
...
this.eventSystem.AddJobHandleForConsumer<TestEventEmpty>(this.Dependency);
}
But the automatic/implicit system that exists for entities isn't really a bookending system. The dependency property for entities is generated each time from the dependent data. I'd prefer that approach. But I'm pretty sure it's entirely internal and can't be tied into.
Won't be required soon
How?
Same way command buffer systems don't need it anymore
Doesn't that cause a dependency chain for all the jobs that use the singleton?
Or am I just totally misunderstanding how it works. Probably just misunderstanding.
It won't be a single singleton, each event type will have its own
Yeah, okay. That's what we were discussing up above. My main concern was that I wasn't sure how the boilerplate would look, and if it would be much better. Do you know of any examples of it?
My other concern was that you'd still end up dependency chaining if there were multiple systems that could trigger the same event type, I think.
There's no chain of access via read only singleton
I'm just misunderstanding, then. I'll look more into the ECB singleton implementation. Thanks a lot!
mind explaining that bit?
I don't quite get how dependency works here either.
So if you do RO read of singleton in query it only ensures no RW jobs run at the moment?
where can i enable live conversion? i want to see the result of baking
icomp and entities just use the job system. it gets a bit mkre complex via queries but it's still built on the job system, job handles and revolves around explicitly declaring read/write job parameters
afaik this is the option that's hidden in preferences and internal options. to enable open about and type internal
in case a rw job was scheduled before the next ro job the rw job will finish.
Yep, that definitely makes sense. But the Entities package also includes its own dependency system for helping get your job system dependencies right. That Entities dependency system is based purely off of components. If I have a custom thing that I need to make sure gets dependency chained (like a queue), the only way to do that automatically is through components. I think Tertle's suggestion is the only possible one - just wrap whatever that data is in an entity and then let the entities dependency system sort it out.
Either use the internal toggle to get access to live bake or just run the project once. The baking result from entering play mode gets cached.
from what I understand:
- GetSingleton writes to Dependency
- Dependency is written into job's JobHandle
then if next system does same GetSingleton, it's RO == no completing previous job
jobhandles and dependencies are from the job system. you can declare a chain of dependencies just as easy with native containers
meanwhile as soon as some system does GetSingleton RW - sync point, chain completes
I'm just trying to understand how it works, so I can implement similiar feature
yes, though the sync point can be circumvented when declaring GetSingletonRW in OnCreate. only with GetSingletonRW in update you have a real sync point
so what works is declaring GetSingletonRW in oncreate and then just use GetSingleton in onupdate. the job system figures it out
though the sync point can be circumvented when declaring GetSingletonRW in OnCreate
wdym by that?
Well, the base concept of job handles and dependencies are from the job system. The entities system then seems to add an additional automatic-dependency-management layer on top of that that's based on entities. And only on entities. I was wondering if you can get the automatic-dependency-management layer from the Entities package to react to something other than entities. I'm pretty sure you cannot.
WTF happened to physics? Before with 0.51 i had 80 fps. now im down to 8 and im not even running my heavy logic... physics takes 80ms
though the sync point can be circumvented when declaring GetSingletonRW in OnCreate
as you said, calling GetSingletonRW in OnUpdate calls .Complete on the jobs. it has that built in to resolve dependent jobs. doing it as i mentioned will leave it to the job system dependency and the job will get scheduled (with no .complete) and just runs after the system jobs that have RW depdency.
i'm not quite sure what you want to achieve here. it's still automatic even with no entities and query dependencies. just set [ReadOnly] in job parameters and schedule the jobs in the correct sequence
physics integrity enabled or safety checks?
Seems like a possible fixed step doom spiral. What does the profiler say?
also, afaik leak detection is enabled by default to full trace. all in preferences now
Yea, and it's toggled back on every time editor resets as well. Annoying.
for me its not in preferences.
Safety is off. integrity checks off. leak detection i cant find
ah damn its in a jobs tab
I'm just trying to avoid boilerplate. You can see Tertle's response to me up above where he mentions how using a wrapping singleton around the relevant data helps with that and gets the automatic dependency management system to sort things properly. The ECB singletons do indeed do this.
Lots of red. Lots of allocations? What's going on there?
idk why i sometimes get so many fallback allocations. after editor restart it looks like this :
so allocs are not the reason
NarrowPhase is just extremely slow. but i wonder why. there shouldnt be alot of collisions happening.
I'm doing my first dip into dots physics so I dont know what's going on in that image unfortunately. Try setting the FixedStep update manager to null. Disable the fixed step nature of it.
Should I use BoxOverlap over BoxCast where I can? I assume overlap is cheaper or no?
hmm i give up for today... for me CreateContactsJob somehow is 500x slower in 1.0.
Is there a quick way to replace a Mesh/PhysicsShape/Physics Collider on an entity?
i got the same amount of colliders in the scene and they are all correctly disabled as far as i can tell
what's disabled? i had some regression with a disabled body that wasn't actually disabled
Is this the way to replace Mesh and colors? https://www.youtube.com/watch?v=XMRSNlTYHFY&lc=UgxR4f9bI0Dc0z_oAhl4AaABAg
๐ Download the full project files: https://www.tmg.dev/MaterialOverrides ๐
๐จโ๐ป Code/Scripts from this video: https://www.tmg.dev/MaterialOverrides-Code ๐จโ๐ป
๐ฌ Come chat with other DOTS/ECS devs: https://tmg.dev/Discord ๐ฌ
๐ง Resources Mentioned ๐ง
Using Random in Unity ECS: https://youtu.be/s-nr9EMmhfo
๐ป My Game Development Setup: https://tmg.dev...
i do spawn ProtoTypeAbilities on a far off location. they are excluded from physics. when i instantiate copies of them i enable the physics
so first thing I'd say is that all disabled physics entities are actually calculated. best explanation why the job takes so long now
maybe test the query of the job
Sorry, I have this fielded.
that's the way to modify materials
to modify meshes you need Mesh advanced API
I forgot I have the code laying around.
I actually just spawn gameobjects, change mesh and let it roll, it's not that big of hit ATM
I'll look into Mesh advanced API tho
Its good to become cultured! Thank you man of culture, Issue bro.
can use TODO for that
Looks like what I did was had a special case to not access my Entity datapool
It returns a handle to the gameObject instantiated before it was converted
Then surgeries the Mesh etc etc
the physicsexclude component doesnt work anymore right?
the mainability got both disable and physicsexclude. Subabilities only got the physicsExclude component because they still have to run in some systems. now all those subabilities are colliding like crazy
I can see why Unity placed a 128 entity max cap, I add DOTS physics to an entity and the cap falls to 32 per chunk:
They throw bytes at components like it's free.
i dont want to talk about my chunk utilisation... at some point i had it down to 2 entities per chunk.
how do i best get the physicsworldindex?
It's an unmanaged shared component. You can get it anywhere.
sry i meant the uint i need to put in there.
state.EntityManager.SetSharedComponent();
{
Value = ???
});```
i mean where do i get the index from the physicsworld to enable physics on an entity that had physicsworldindex component removed at some point
just use 0
unless you setup multiple physics worlds per Entity World
it'll be just 0
I think values other than 0 are used for smoothing and alternate worlds
ah so more a netcode thing
no
they are used to different simulations
you can have as many physics worlds as you want
or maybe yes, maybe that's what is required for smoothing
kek
lol [InternalBufferCapacity(16)] public struct PhysicsColliderKeyEntityPair : IBufferElementData { /// <summary> The key. </summary> public ColliderKey Key; /// <summary> The entity. </summary> public Entity Entity; }
16!
what the
12 bytes per element. ridiculous
what is even purpose of this, lol
if you use 208 reserved bytes per entity you have a DAMN good reason
so i hope you don't have 1 entity pair with 1 collider ๐คฃ
Absolutely ridiculous Unity's memory utilization.
what's the cap if you add a LEG too?
oh no, unity is dying, give me a sec
math says 25 haha
Huh, how do you add that again?
I added a child game object and then disabled them both. Didnt show up
there's a LEG authoring mb
LEG pales in comparison to the absolute waste of space that is the PCKEP
i mean, this problem here is salvageable very easily. the cap puts a bit of a damper into it but i'm often coming back to the idea of parallel chunks. (as unity isn't keen on making chunks bigger or modular) anything physics or transform related has huge data implications but often isn't accessed that frequently or none at all from game mechanics. however, moving them to a seperate entity would require random acess and i have tried it more than enough times with different methods, it's a hassle and slows everything down with the amount of random access required. if you would have a parallel chunk the you could directly access this would be much faster, i just haven't found a good way to do this yet.
I think this is what Physics Render Entity is doing:
I'll take a look at it. seems interesting
Wait no, it's for physics shape authoring. Primarily the compound mesh authoring
- A new
CompoundCollider.Child.Entityfield is automatically populated through the conversion system, to point at the converted Entity associated with the GameObject that contacted thePhysicsShapeAuthoringcomponent.
* This default setting can be overriden by adding aPhysicsRenderEntitycomponent data. The common use case for this is where noMeshRenderercomponent is on the converted child Entity, and it is desirable to redirect to another Entity with a graphical representation in a different branch of the hierarchy.
- Added a
PhysicsRenderEntitycomponent data. This is primarily used for populating aCompoundCollider.Child.Entityfield where there was no graphical representation on the same GameObject that has aPhysicsShapeAuthoringcomponent.
anyway, if you go below 32 entities per chunk the job overhead really eats into it
mainly the small iteration count and GetNativeArray
Well, what can I do. The only custom components on that list is 20 bytes of light rendering data. I cant remove that.
yeah not much you can do other than editing the physics package and lower the buffer capacity
Im sure if I spend several hours / days / weeks slowly combing over the physics package manually and instituting 2D components, I can half the component byte utilization.
But for now, I just want things to work. Optimization hopefully whenever 1.0 enters pre-release in december
unity should do the same thing that I did and make a config struct that has constants to define the InternalBufferCapacity. hardcoding this is just bad practice
Is that possible to create child entity and add component to child entity at custom baking system?
yes, it's even possible in a baker
๐ฅฒ I just tried it it's not possible. Child entity never create
I mean custom baking system using [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]. Not Baker<xxx>
yeah you're right. not working for me either. it does work though in a Baker
very odd, baking systems should have all the same freedom. did anyone have a baking system that can successfully create entities or childs?
accoriding to docs only CreateAdditionalEntity should work.
Docs say :
"Baking systems are updated on every single Baking pass."
does that mean all entities are getting rebaked every time? or is there some mechanism to ensure that only entities that had their data changed are present in the baking world?
Oh man i just found out the baker keeps its internal state even between entering and exiting playmode. I somehow assumed each bake would have its own baker instance. instead they all share the same baker.
yeah, there's DependOn method for this purpose
to track changes
for live conversion
i used state inside the baker to aggregate a list of distinct components to add to avoid the error of adding the same component multiple times from one baker.
This list of components is different for each entity i bake.
So imagine my surprise when all entities came out the same way except for some of the early baked ones ^^
what Chunk.DidOrderChange do?
docs says: Reports whether a structural change has occured in this chunk since the specified version.
does it mean Creating/Destroying/Moving entities?
yes
and no matter what happened with values
yep
try to take a look at source of SetComponentData
if there is version checking for it
it will write to it
during RW operation
@viral sonnet i remember some time ago you were linking guide about creating custom parallel native container on an example of parallel sum. Do you have a link, i'm struggling to find it through google
ah yeah that's it. the safety implementation is outdated though.
is class based IBufferElementData possible?
why not just make class with List then?
just wondering
I bet the baking won't track changes in a list but might do it for Dynamic buffers
hmm
there's a semi unmanaged solution to this
store index to some collection instead
There are so many pitfalls with baking I feel like, what works what doesn't? Apparently "AddComponent" in a baker doesn't add the component if it was removed during runtime.
are you talking about live baking?
yes
I just want my runtime system to rerun once the baker runs, but it seems impossible.
the component is never added, so my runtime system doesn't run again.
you mean you add comp in baker which gets removed in runtime, and then component is not readded if you modify it?
DependOn what?
yes ik, but what should it depend on
The issue is not making the baker run, the issue is the comp is not added.
even though the method is named "AddComponent"
๐ค
I think they assume something like: "Oh this comp is not present on the target anymore, I bet he doesn't want to add it anymore, lets skip it"
where can i read of or how can i figure out what is outdated in this tutorial?
all works though
did you try with a baking system?
inside baking system the component is indeed added, but that change is not propagated to the runtime world.
And as far as I can tell there is no direct way of accessing the runtime world from the baking system.
and you did use Entitmanager.AddComponent in baking system?
yes tried that too.
oof thats good to know. ill run into those problems too for sure
What I'm resorting to now is to never remove the component during runtime, and poll for changes instead. Sucks we cannot take advantage of structural filtering here.
๐ค
you can use change filter
for a quick fix
I do, but I still have to poll since change filter gives false positives.
Random thought: now that we have enabled components, I wonder if it would be feasible to do change filter per entity with same bitmask logic.
Do you mean enabling a component temporarily every time you modify a component?
I suppose you could create an aspect that hides the enabled component as an implementation detail:
[Serializable]
public struct MyData : IComponentData
{
public float3 Value;
}
[Serializable]
public struct Changed : IComponentData, IEnableableComponent { }
readonly partial struct MyDataAspect : IAspect
{
private readonly RefRW<MyData> _myData;
private readonly EnabledRefRW<Changed> _changed;
public MyData MyData
{
get => _myData.ValueRO;
set
{
_myData.ValueRW = value;
_changed.ValueRW = true;
}
}
public bool DidChange
{
get => _changed.ValueRO;
}
}
Then you could have a separate system that disables the changed component at the end of the frame. You could even query for changed components by including the Changed comp in the query.
Oh interesting, I didn't realize we could do this ourselves with aspects. That seems pretty useful. Probably could even use the same system that is setting the values for resetting the changed bit.
Actually do we even need the tag? can't we reuse the component for enabling?
Yeah, assuming that is the only system that cares about the changed bit
So here's an odd collections question - Many of the native collections use [NativeSetThreadIndex] and m_ThreadIndex to have things write into different buffers. From a bit of testing and searching online, this value is 1-indexed. That is, I get 1-32 for my 16c/32t. That's great, presuming 0 is for the main thread, and the collections seem to operate under that assumption. But I've noticed that most of the allocations made in the native collections use JobsUtility.MaxJobThreadCount (=128) when allocating. Doesn't that leave the collection logically 1 entry short? Or are there actually only 127 jobs allowed? Or can index 0 actually be used by a jobs thread in some scenario?
Not sure. I haven't actually used aspects yet, but I remember someone saying that they couldn't have an EnabledRefRW and a RefRW for the same component in the same aspect
It also depends on how you want your queries to work. If you combine MyData and Changed into a single component, normal queries for the data won't return unchanged entities. You would have to remember to use the IgnoreEnabledBits option in your query.
By separating them into two components. Systems that don't care about changed bits can just query for MyData. And those that do can query for MyData AND Changed. So for a more flexible and less error-prone workflow, I would keep them separated. But it really depends on the use case I think.
true
Not sure about that one, but my guess is that there is max 127 threads and +1 for main thread.
I did find a unit test somewhere that ranges to MaxJobThreadCount-1, so I guess that must be it!
Is one usecase for sharedcomponentdata to make ComponentLookup less likely to experience cache missed? I have a StatComponent that may have tens of thousands of entities with it, and many systems like StatAdd, StatSubtract, etc. each one of these โoperation systemsโ always reference three entities - A, B, and Output, and itโs highly likely that those 3 entities will only ever be used by one of StatAdd, StatSubtract, etc. so if I attach a sharedcomponentdata called UsedByStatAdd, then all StatComponents that will be used by StatAdd will be grouped together. That way when the StatAdd job executes and uses the ComponentLookup for StatComponent, the relevant statcomponents will be highly likely to be grouped together in the same chunk
Do the three entities have the same archetype?
They do without using the sharedcomponentdata scheme
The Stat entities have just StatComponent
The Operation entities have 3 component, each one just having one field referencing a Stat entity
The Opertaion job will do a component lookup and write to the 2 input Stats and 1 output Stat, respectively
I know it sounds convoluted/overkill, but Iโm only interested in if sharedcomponentdata couldโve used to group entities together in a cache friendly way
I'm not sure if there is any value in using an empty shared component over simply using a tag component
Oh no, Iโll assign the sharedcomponent a single integer
1 means used by adder, 2 means used by subtractor
This can be extended further if needed
I honestly have never had to use shared components, but I'm pretty sure different shared component values (yes even just changing the integer inside) will mean different chunks.
So it effectively is the same as a tag in that each chunk will only have the entities with that specific shared comp value
Yes, I want that to happen to group all Adder-used Stats into one chunk, and all Scaler-used Stats into another
So why not use a UsedByAdd tag? Just seems simpler than a shared comp
Right, but I want a generalized way of doing this for my use case. Youโre right about the component tags, but Iโd have to create a new one for each partition. With a SharedComponentData I just inject an integer
Again, thereโs not just Stat, but also DecisionMaker and a bunch of others that could benefit from this
So a single UsedBy shared component to be useful across different domains
that's nice but honestly changes very little. a chunk can be skipped with change filters and for a chunk where some comps are disabked you still have to iterate over the enabled bits. a reinterpreted bool comp will be just as fast and has much nicer code
Got it. I'd probably still just create all the tag components, but I understand that it is extra work. From my own experience, I've found that simple verbose solutions are better than complex generic ones in DOTS. But yeah, shared comp will probably work for what you're trying to do. I've actually never had to use them in my own project so not sure if there are other gotchas with them.
You only have to iterate over the enabled bits in IJobChunk. Maybe I'm a minority but I mostly use IJobEntity which does that all automagically (actually I mostly use Entities.ForEach in SystemBase but I'm slowly migrating). I know enabled comps are basically equivalent to a bool comp, but being able to write the code as if its a tag component without paying the cost of a structural change is really nice imo
I don't quite get what it does
@proud jackal Dont know if you still read discord but if you can, please put in a word over at the documentation team to fix this small code snippet: https://docs.unity3d.com/2023.1/Documentation/ScriptReference/Unity.Collections.LowLevel.Unsafe.UnsafeUtility.MemCpyStride.html
The third line in the for loop should be source += sourceStride, not destination.
In writing systems, you use the MyDataAspect to write changes. Internally, this also enables the Changed comp on the entity. Then in reading systems, you can query for changed values by querying for MyData and Changed. Or if you don't care about changes, you can just query for MyData.
So its just a nice way to do change filtering per-entity without any false positives.
๐ค
Here is some sample usage code using the idiomatic foreach.
// Write new values:
foreach (MyDataAspect dataAspect in SystemAPI.Query<MyDataAspect>())
{
dataAspect.MyData = new MyData { Value = float3.zero };
}
// Iterate only changed values
foreach (MyDataAspect dataAspect in SystemAPI.Query<MyDataAspect>().WithAll<Changed>())
{
// ...
}
// Iterate only unchanged values
foreach (MyDataAspect dataAspect in SystemAPI.Query<MyDataAspect>().WithNone<Changed>())
{
// ...
}
// Iterate all values
foreach (MyDataAspect dataAspect in SystemAPI.Query<MyDataAspect>()
.WithEntityQueryOptions(EntityQueryOptions.IgnoreComponentEnabledState))
{
// ...
}
// Alternate way to iterate all values.
// By not going through the aspect, we don't have to ignore the disabled Changed
// component since it isn't in the query.
foreach (MyData data in SystemAPI.Query<MyData>())
{
// ...
}
Is there a way to access aspects in IJC?
At what point does DOTS become a requirement for entities? Could you remake Vampire Survivors without DOTS for example, or would that amount of entities on the screen at once always require it?
DOTS is never required. If you're willing to take the low road, you're completely free to write your own procedural rendering pipeline to render a lot of meshes on screen.
It's honestly not that hard either IMO.
I just use DOTS because I'm lazy.
I'm not trying to stay away from DOTS, just wondering where the line is drawn between 'I should use DOTS for this' and 'I shouldn't bother'.
Unless that line doesn't exist at all ๐
why would anyone not use DOTS?
Ehhhhhh, it's a frame of mind. DOTS is never required for anything.
That's what I'm saying with the line maybe not existing.
I'm still just looking into it now -- "Why would anyone not use DOTS" sort of tells me what I want to know ;p.
One reason to not use DOTS is that most of the tutorials out there are complete garbage at best, completely harmful at worst.
And it's impossible to tell the difference unless you already know what DOTS / ECS coding is and dont need to tutorials.
What are people waiting for? Figured there'd be a bunch of half decent tutorials with how slow the release has rolled out. I thought it's been in the making for quite a while with another update recently(?)
ECS is just brand other way of coding, which most people don't get
Experimental 1.0 released earlier last month. That's practically yesterday in the world of DOTS release schedule.
everything else is already part of Unity in a way
several classic components were remade with burst and jobs
Vampire Survivors is made in Phaser. Not an engine that's known for blazing fast processing. The game works for the most part so it will even work without DOTS in Unity.
I've seen VS clones without DOTS whatsoever, so I'm quite sure its good enough. I'm quite interested in DOTS though and I hope there's better training infrastructure in the future.
It really is, at least it's much nicer and easier to write than anything involving change filters.
so what's your question then? ๐
Hiya. Any tips on how to let a component know of its children? I'm working on a ship multiplayer game and would like to rotate all of its cannons according to user input. The input is in the form of DynamicBuffer<ShipInput> which is placed on the root Ship object.
Perhaps instead add a tag component (IComponentData with no properties) that indicates which cannons are controlled by user input. Then use that tag as a RO WithAll query when applying user input.
[BurstCompile]
[WithAll(typeof(PlayerControlledTag))]
private partial struct ApplyInputs : IJobEntity
{
public float2 RawAxis;
public float Speed;
[BurstCompile]
private void Execute(ref PhysicsVelocity velocity)
{
velocity.Linear.xy += RawAxis * Speed;
}
}``` Here's an IJE version of my input job.
That's an idea but that too requires me to be able to differentiate the user's cannons from other users' cannon in order to add that tag, right? I know which root is controlled by the user, but I'd need to know which cannons belong to that root.
That's where SharedComponentData come into play. Use a shared component filter then.
Assign each cannon a ISCD with a property index indicating which player that cannon is controlled by. Then use the SCD value within the job to access an array of relevant input controls for that frame to change the direction of the cannon.
Okay thanks! I'll look into SharedComponentData
what's not accounted for here is the query overhead which can be quite large. maybe i'll get around to profile all the different options available to us now
Well, it is literally pulling ICDs from entities.
that's really simplifying it. the query iterates over fitting archetypes and creates a list of valid chunks. then each chunk is checked for the state. this could be all merged into 1 loop instead without any information lost.
// Pointer to velocity values.
void* vel = chunk.GetRequiredComponentDataPtrRW(ref Velocity);
// Shift pointer to access velocity.linear.z.
float* linear = (float*)vel + 2;
// Mem-copy zero out all Z linear velocities.
UnsafeUtility.MemCpyStride(linear, sizeof(PhysicsVelocity), &zCl,
0, sizeof(int), chunk.Count);
// Fixed float2 zero value.
float2 xyC = float2.zero;
// Shift pointer to access velocity.angular.
float* angular = (float*)vel + 3;
// Mem-copy zero out all XY angular velocities.
UnsafeUtility.MemCpyStride(angular, sizeof(PhysicsVelocity), &xyC,
0, sizeof(float2), chunk.Count);``` I am shocked this works.
just, why?
Because ultra optimization enforcing 2D physics using DOTS 3D physics.
mind sharing whole system?
Im sure if I dug into ToEuler I can optimize constraining rotation to Z axis only but eh.
Not sure I follow. How is this any worse than a component with a bool? Don't you still need to query for chunks with that component and then iterate the chunk and check the bool? Is the overhead from querying for two components instead of one?
Do you have an idea of how to figure out which player that cannon is controlled by? I did find the Parent component which I could use to traverse the hierarchy but I wonder if there's a better way to set up this relationship.
My first idea was to set it up during baking, but the network id ofc isn't available then yet. Maybe I could pass a reference to the Ship to the Cannons during baking, though ๐ค
Ideally, your entire hierarchy will be flat. No parents and no children. Baking probably wont work, you will need to do runtime authoring.
Spawn the player and all entities related to it at bake and on network connect during runtime you spawn the entities related to other players.
This is where Subscenes will probably help. Make a generic "player" subscene containing bare minimum entities required to make a player function. Then spawn that repeatedly for every network connection then populate per instance properties and classes later.
Hey if I wanted to change the Mesh of an Entity, how do I do that? I can't find my question from the other day.
i believe you're talking 0.51?
sure
it's changed a lot in 1.0
I hear 1.0 isn't working for a lot of people. I'll wait til it works to upgrade.
just set RenderMesh
Thank you
how so?
Its a conglomerate of information sources I use.
Don't worry about it, I judge my upgrade times based on if the steps of upgrading is easy or hard.
When they become very hard to upgrade one step,I just park on an old tech and wait til there is a feature I'm missing. A long jump later is shorter than many long jumps before.
1.0 is a long jump for an existing product
Its just general software engineer stuff, would have saved about 400 hrs dev time if I just stayed on 2021.5.f1 instead of going 2021.11.f1. upgrading for the sake of upgrading ain't always good
we won't be upgrading at work
Exactly
but it is nice to finally be on what should be a reasonably stable api going forward finally
True that!
Unity people do Unity people stuff. We plebs would have liked to have smaller manageable jumps, but we understand if they gotta burn the house down to make a new foundation.
Many young software engineers are learning the lesson of it not being bad stuck on legacy techs. I learned my lesson of relying on Unity releases to be stable.
Let me give you wisdom for that...
If you want to fly, you don't start.
If you want to run, you're disappointed if you can't.
If you want to walk, that isn't for sure either.
Start every session with the mentaily,"Let me grunt pick and shovel this."
If you do that, you'll be flying and running more often than you'd think.
Tell yourself,"The thing I like doing the most is organizing my design documents."
design documents? ๐
And you'll stumble over stuff you want to implement.
TODO/NOTEs
Between starting every day with grunt coder attitude and saying your passtime is organizing todo lists and design docs... You'll get more timeclocked
Ok, good talking with you, back to grind, gonna have an AWESOME release this Friday
Putting in anime boys
who give a MADlib about their backstory noone cares about
before they attack
randomized madlib anime backstory
Should be in within a few hours
but need more enemies, random loot boxes dropped and a inventory system of some sort by Fri
Does anyone know the setting to change how unity names duplicated GOs? from (1) to _1 or something?
should be in either preferences or project settings
use search by keywords
I know it exists but my googlefu is lacking
search in editor...
Ah, hrm. Doesnt seem to be working for me? Duplicating a GO inside a subscene doesnt increment the (X).
huh yeah same for me
It does so outside a subscene but not within it. Huh.
damn, i tested LEG and physics keypair with optimized cap bringing the chunk capacity from 17 to 29. my machine has way too many threads to see anything noticeable ... ๐
a bit curious, why you modify translation?
without velocity it won't ever change
I use Z value for depth
same for rotation
Good point. Im thinking about using z for layering. Just comment it out. I commented rotation out due to how expensive it is already.
I'v been doing same thing
without modifying anything but velocity
it worked out great, no glitches related to 3rd axis at all
your approach is just way faster it seems ๐
I've been chucking it against spheres and other objects. Just enforcing 2D on PhysicsVelocity seems to work okay.
and i have no idea to get my performance tests working in 1.0 because it relied on runtime conversion. the lack of entities related performance tests is really bugging me.
welp, now this system is just 50 lines long ๐
I'm keeping it in there just in case but yea.
querybuilder is doing what I'm doing anyways. So eh
but it's just less boiler plate
if it wasn't for type handle
could leave OnCreate empty
Yea. I really hope unity will make a codegen for type handle and updating. Would be incredible.
Hrm. Seems like collisions against mesh plane colliders result in an introduction of 3D force values.
You mean smth affects z value during physics step?
Yea. I use CreateMesh() from a composite collider 2D of a tilemap collider and feed that into a physics shape mesh.
In that case...
Sliding a box collider along the surface of it works for a while until it somehow decides to roll over it.
Should make a system
That modified world during step
Doing same thing - nullifying z value
Enforcing 0 z axis fixes the rollover. No need for rotational setting so that's good.
You mean translation?
I'd want to avoid that
Yea. Either that or the expensive XY rotation constraint.
Infinite inertial dampers? I mean, that could work.
Before it's data written to entities
That's not what I had in mind ๐
I mean modifying translation inside physics world
This is what it's doing. I think
Point is to do it before data is written to chunks
Also should be way faster
Since it's all giant array
Vs chunks
I havent really dug into what's going on in there. Give me a minute to see if I can find it
Just look at physics world
ugh, that is pain
To modify that, we would need to write our own ExportPhysicsWorld.
Huh, anyone else having a build issue where any level of managed stripping above None for Mono result in companion GOs not having their transforms changed?
Scene 700485ca34f7b45488702c50add65ebf - Data length mismatch: Dependencies: 39, Types: 41, Paths: 39. I think it might have to do something with this error?
well, this focused test on PhysicsColliderKeyEntityPair turned out more interesting than I thought. just look at this alone. the left part has a cap of 16, the right part after the huge init spike runs on internal cap 0
the same job for a heavy object (57 chunk cap) takes 11.4ms, the other light object (99 chunk cap) 3.01ms. i have no clue what's going on right now. seems a bit too extreme
i should take out physics of this test. on that note, i can't get a static physic object to not run any CreateRigidBodies jobs. all frames are full of it which shouldn't be the case. all are spawned on the same position so maybe that's the problem
spawning a lot of things on the same place in physics goes poorly
if the goal is to add alot of elements to alot of entities
whats the goto to do that
otherwise it would just freeze on that frame
ie/need to add 2000~ elements to n * m entities at the start of the game
where n / m is anywhere between 1~50 so we could be talking about 2500 entities with 2000 elements each which is 2500 * 2000 elements
how does entity query help me add elements?
oh sorry by elements i thought you meant components
buffer elements i should say yeah
do they already have the buffer? can't you just do it in a parallel job
-facepalm what
DynamicBuffers work fine in jobs
they are 3 units apart now. doesn't change anything. ๐ค
I'd love to have TilemapCollider2D working with Dots Physics -- any idea how to do it? how to create a collider mesh like that?
currently I'm reading through https://github.com/Unity-Technologies/UnityCsReference/blob/d76ca0c1f57f36891cb231ed36e80a795d9244d2/Modules/Tilemap/ScriptBindings/Tilemap.bindings.cs
can all these external thingies be found somehow?
You're in luck. I'm doing that right now.
Im using a composite collider 2D that generates a polygon mesh to be used in a PhysicsShape custom mesh.
GCMA is real simple, just calling CreateMesh and saving it as an asset:
From there, I constrain movement in the world to 2D and it works.
Runtime changes to tilemaps though are still an unsolved problem. So eh
Sorry for the late reply, but I was trying to figure out if there was a hard line to look for when transitioning a project to DOTS based architecture.
I didn't mean I know it's possible based on seeing VS clones because I actually assumed they were leaving a lot out (that may require DOTS).
I think I got my answer though in that DOTS wouldn't be required for this project and that there is not necessarily any one scenario where you should not use DOTS, let alone a scenario where you should.
removed the wall of images. thread here: https://forum.unity.com/threads/hierarchy-data-as-core-feature.1350353/#post-8526518 feel free to raise your voice or opinion
https://assetstore.unity.com/packages/tools/physics/rival-dots-character-controller-for-unity-225129
I see a new release of Rival Character Controller has occurred - any idea if it's ECS 1.0 compatible now?
"Changes:
Removed unsafe requirement in Standard Characters" doesnt seem like it
thanks! โค๏ธ
hmm, it seems it's placed in a subscene or with a convert to entity component -- how do you get the tilemap to render in DOTS tho? I'm using DOTS 1.0 if that matters
I encountered a problem. I got the behavior tree variable of AI in the game and could be accessed, but it could not be modified.
Why is this? Is there any way to modify it, thank you
Am I missing something or, when we use the idiomatic foreach, we can't actually set the component we are iterating over?
you can
Is a System's update framerate independent like fixed update?
Oh, right
update is called by system group
But that doesn't work for managed comp
๐ค
why do you need ref for managed comp?
it becomes angry at me Cannot assign to 'instance' because it is a 'foreach iteration variable'
mind showing code?
Ok just finished reading about [UpdateInGroup(typeof(FixedStepSimulationSystemGroup))] thanks!
foreach (var instance in SystemAPI.Query<CompanionGOInstance>())
{
instance = CreateNewInstance(); <- Compile error here
}
well yeah
you are supposed to modify instance instead
That works but it's annoying.
{
var newInstance = CreateNewInstance();
instance.a = newInstance.a;
instance.b = newInstance.b;
instance.c = newInstance.c;
instance.d = newInstance.d;
}
๐ค
I am using BaseUnit : MonoBehaviour in a system.
Entities.ForEach((Entity e, BaseUnit unit) =>
{
unit.SomeUnitMethod();
}
Can I make it query Hero : BaseUnit as well? or even Interface?
ForEach is obsolete
This the new one?
foreach (var (rotateAspect, speedModifierRef) in
SystemAPI.Query<RotateAspect, RefRO<SpeedModifier>>())
foreach (var (e, transform) in
SystemAPI.Query<Entity, RefRO<WorldToLocalTransform>>())
{
}
How do I ref entity?
Gets error
add WithEntity or something at end
WithEntityAccess()
yeah that one
foreach (var (transform, e) in
SystemAPI.Query<TransformAspect>()
.WithEntityAccess())
{
}
It ends up way uglier than Entities.Foreach
๐ Actually it's so much better than Entities.Foreach
It's damn lag when using Entities.Foreach lol
Not to mention need to create bullshit local var just to pass into Entities.Foreach
I like this formatting:
foreach (var (transform, e) in SystemAPI
.Query<TransformAspect>()
.WithEntityAccess())
{
}
Ah yes that's better
var queries = SystemAPI.Query<TransformAspect>().WithEntityAccess();
foreach (var (transform, e) in queries)
{
// Do Stuff
}
How do I tell it not to run with burst, and what about Run/Schedule/ScheduleParallel?
it's not running with burst
it's main thread only
oo
it's not a job
it will run in burst if you have it in a bursted ISystem
but it's still main thread
^
think of it as a replacement for EFE.Run
๐ฅฒ Now I only realize that dun have .WithoutBurst() like Entities.ForEach
EFE.Schedules should be replaced by IJobEntity
because it's never using burst unless your system is
it's always withoutburst
Okay I see
Then how to debug it without burst just like Entities.ForEach?
So jobs still the same syntax :)
there never is burst
you can't turn burst off if burst isn't running
I mean with Entities.ForEach u can put .WithoutBurst to make the code at Entities.ForEach not burst compiled to debug
foreach (var (transform, e) in SystemAPI.Query<TransformAspect>().WithEntityAccess()) { }
Entitys.ForEach((Entity, in TransformAspect) => { }).WithoutBurst().Run()
these are the same thing in SystemBase
but now with idiomatic foreach u can't do tat anymore
๐ฅด
there is no burst
var queries = SystemAPI.Query<ManagedType>().WithEntityAccess();
foreach (var (managedType, e) in queries)
{
managedType.SomeMethod();
}
I can't query a monobehaviour with this
SystemAPI.ManagedAPI is coming next release i believe
๐ฅฒ I see. Now become like usual foreach but from wat I see I guess official still can do it if they want
query managed component they still working on it I think
Gave me an error
Can't convert ManagedType to IQuery something
Welp, Entities.Foreach for now
Its working for me to query managed comps
What ok, I'll try again tomorrow
Oh so only query classic unity component like Monobehavior cannot work?
or wait, maybe it doesn't work for monos
I have only tested with class IComponentData
yeah it might only work for that
๐ฅฒ I just upgrade my production project to able to enter play mode state but there's still lots of runtime errors need to fix
Where can I read about this?
just randomly in this channel
for example
#archived-dots message
just use EntityManager.GetComponentObject for now
Indeed, and that's mostly what SystemAPI.ManagedAPI uses underthehood anyways! ๐
@proud jackal ๐ฅฒ Can u make sure next version fix this issue? Entities Hierarchy is completely broken at my side
I can't clear them fast enough ๐ https://i.gyazo.com/7f42ae5d93c5a60c8b35b5f5460041e8.mp4
Also, I don't think this is a supported usecase to type a query inside a variable.. Pretty sure we give an error? 
what is alignment in UnsafeUtility.Malloc method?
Data structure alignment is the way data is arranged and accessed in computer memory. It consists of three separate but related issues: data alignment, data structure padding, and packing.
The CPU in modern computer hardware performs reads and writes to memory most efficiently when the data is naturally aligned, which generally means that the da...
Need to put SystemAPI.Query<> inside foreach?
essentially alignment of 1 means allocation can happen anywhere, alignment of 4 means it can happen only at addresses divisible by 4, and so on. Computers can read and write data faster if it is aligned correctly. An int for example wants and alignment of 4. UnsafeUtility.AlignOf<T>() can check what the alignment is for your type.
thank you, yeah, i need this UnsafeUtility.AlignOf<T>()
yeah
this API is codegen
what you do is basically just give hints to code generators made by Unity to generate correct code
Indeed,.. oh Issue got it way before me ๐
we really need some tutorial or explanation how to make our own very simple implementation of this
For idiomatic foreach, is there any plan to bring back .WithoutBurst() and .WithStructuralChanges and .WithName("Foo") Entities.ForEach equivalent? I guess those are method builder or something? I forget the formal naming of it. Btw have u see the Entites Hierarchy window issue I posted above?
smth that caches field in OnCreate and uses it in OnUpdate
No plans, WithoutBurst is already a thing since bursting is only happening if the containing function is bursted e.g. OnUpdate with [BurstCompile] on top. And .WithStructuralChange is currently meant to be ECBs instead until we figure something better out :3
And yeah, posted it to the UI folk :3
๐ฅฒ I see. So now really become real foreach. I guess now only left ECB.AddComponentObject() api for classic unity components like MonoBehavior
I think FixedString64Bytes is not enough. Need to increase more to like System windows. Maybe it's caused by system name too long?
I'm not sure if here or in graphics, but currently I am disabling hybrid rendering on entities by adding and removing <Prefab>. Is there a more efficient way to be doing this?
yes, Disabled comp. you should not remove or add prefabs for no good reason.
I haven't tried running it, but VS2022 doesn't give me errors
But why disable it? It looks way neater & readable in a variable.
And is actually in line with the usual foreach usage. Create a list, then iterate on it. Rather than creating the list in the for loop declaration.
I mean, not wrong, but we didn't want to open that can just yet (the more we initially restrict it, the better support we can make sure to give once we open the can)
That said, it shouldn't really be thought of as creating a list, more so retrieving one, as most of it is cached and not created :3
I see, that's cool, thanks!
Which component are you refering to out of the components that RenderMeshUtility.AddComponents adds
/// Disables the entity.
/// </summary>
/// <remarks> By default, an <see cref="EntityQuery"/> ignores all entities that have this component. You
/// can override this default behavior by setting the `EntityQueryOptions.IncludeDisabledEntities` flag of the
/// <see cref="EntityQueryDesc"/> object used to create the query.</remarks>
/// <seealso cref="EntityManager.IsEnabled(Entity)"/>
/// <seealso cref="EntityManager.SetEnabled(Entity,bool)"/>
public struct Disabled : IComponentData
{
}``` It's a standard Entities component.
Do you just want to disable rendering?
Yeah, I guess I could disable entity if I instead dropped them on a child linked entity, but for now its on the primary entity I wanted rendered
hm, I'm not aware of any way to just disable rendering. the query operates on RenderMesh and LocalToWorld, both are not enableable components. maybe someones else has an idea to achieve this without structural changes.
DisableRendering
just like Disabled
haha, nice ๐
Thanks!
Still add/remove, but at least I feel better. Maybe it can be a bitflag one day
yeah, Disabled comps could really profit from the enabled comp feature
it is already
just on query level
Anyone know how to fix this android crash? ๐ฅฒ
lib_burst_generated.Unity.Entities.EntityQueryImpl.GetSingletonChunk(Unity.Entities.EntityQueryImpl* this, Unity.Entities.TypeIndex typeIndex, ref int outIndexInArchetype, ref Unity.Entities.Chunk* outChunk) -> void_af0ee2df0b1e2158fa5c6d394d81afa0 from Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null(Unity.Entities.EntityQueryImpl.GetSingletonChunk:120)
lib_burst_generated.Unity.Physics.Systems.BroadphaseSystem.OnCreate(Unity.Physics.Systems.BroadphaseSystem* this, ref Unity.Entities.SystemState state) -> void_af0ee2df0b1e2158fa5c6d394d81afa0 from Unity.Physics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null(Unity.Physics.Systems.BroadphaseSystem.OnCreate:600)
Are you using minimal stripping?
I had the same issue and it was indeed from a game object with a long name. Shortening the name fixed it for me.
Not sure later I will check. So for now it's better to change to None?
generally yeah
Alright. Currently I'm using Low.
try disabling it for now
Entities is experimental after all
๐ฅฒ Sadly l have lots of long name. So I can't rename all of them 1 by 1
You could write a script to do it. I'd probably do it textually since you're just talking about manipulating strings but you could also do it in editor.
Oh yeah I realized that it's probably caused by system singleton entity that has long name . I still want to keep the naming. I hope next release official can fix it. For now I guess can I modify the FixedString64 to like FixedString128 to make it larger?
If you are gonna modify source, I would just make FixedString64 truncate instead of throwing an error.
does anyone know how to deal with NavMeshLinks in DOTS? the characters nicely "jump" to the other navmesh, but I wish them to teleport :p
any clever way to find out when they're traversing a link so I can speed things up?
I am attempting to instantiate a prefab with a nested linked entity group. My issue is only the linked child of the instantiated prefab is being generated, the children of that prefab which are also linked do not. Is this not possible? Or is this something that the original prefab needs to have each child of child linked manually? Or is it possible and I am making a mistake.
Looks like adding to the primary prefab entity worked... but this can be a tad tedious. Can this still work nested and I am just making a mistake?
Does anyone know what happened to firstEntityIndex in IJobChunk?
Oh boy, now query.CalculateBaseEntityIndexArrayAsync is required...
Anything above "None" stripping resulted in bugs for my Mono Windows build.
I havent been this confused about DOTS in years. My god is netcode so confusing.
Why are all my ghosts disabled? How do I properly enable them? Why are there a quarter billion components tacked onto everything?
I am so confused. Is this how people look at DOTS starting out? I see why people just give up after spending a few hours on this
hehe, i remember schnozzle showing a screen with 4 or something chunk capacity ๐
Yea, it's around 15 right now. The only custom components is a 20 byte sized light data. The rest are unity physics and netcode components
like god damn, i wish I knew what was going on
i sound like a broken record. 16k chunk size is not enough
i don't know how much has changed in 1.0. the doc was good enough to get me started
The problem is that the docs are very outdated. There's a sample repo updated by unity yesterday that Im using to try and reverse engineer what they're doing
16k is sufficient if the components werent wildly oversized and wasteful.
have you found the get started tutorial?
In the docs? That's still using 0.5X components
hm, yeah i see no upgrade guide for 1.0. that would be helpful when lots has changed
Oh yeah netcode documentation is lacking
There are a lot of features or helpers that are just unknown because no mention
I think the getting started basic setup kind of works
my ghosts are all spawning in disabled for some reason. They're all enabled on the GO side... ugh
can you post such an archetype?
How are you trying to spawn them
Just in a subscene?
Subscene ghosts are kind of special