#archived-dots
1 messages ยท Page 39 of 1
If unity provides a systemAPI for CTH<>, there will be 0 reason to ever use IJE.
this will be so good
but i disagree
Well, short of very small jobs. I got a few IJE sitting around doing basic menial work.
once i get my ExecuteChunk in IJE (distant future ๐ค or do it myself)
there will be nearly no reason to use IJC
Better yet, IJE with raw pointers in the params instead of ref and in variables. On a per chunk basis. And that's basically all that Im doing IJC.
hehe, they already get pointers in the codegen, just pass the ref then
and i find it funny the codegen doesn't use GetNativeArray
Yea, if I was brave, I would go into the package and do it myself.
well, i dont know how the codegen can assume RW or RO from pointers though
Maybe a RefRW/RO variant that's PtrRW/RO?
for (int i = 0; i < chunk.Count; i++)
{
if (!healthMask[i])
continue;
// code
}``` is this how the bitmask is used then?
Yea.
WTH is that? Interlocked.Add(ref UnsafeUtility.AsRef<int>(m_PtrChunkDisabledCount), value ? -1 : 1);?
lol wat this this?
Imagine: public void ExecuteChunk([AssumeRange(1, int.MaxValue)] int count, PtrRW<Translation> pos...)
You might have an invalid [UpdateBefore/After] tag on a system somewhere.
did you see burst added new interlock intrinsics?
no clue.
Interlocked min and max. Neat.
InterlockedAnd & InterlockedOr
Oh, huh, did min and max already exist?
it's interesting what you write but i was skipping a line and thought this was get ... haha
Wow, an interlocked operation on every [] indexing? That's disgusting
Use the bit mask and manually << i > 0 check.
it's only on set isn't it?
Oh, it is. Huh
just on set.
In that case, yea, makes sense
has anyone a successful vectorization with enabled bits?
The enabled comp also stores the count of disabled comps
AoS vectorization yea. SoA not across if there exists gaps.
kind of ironic we have this super involved simd intrinsic and then it kills every loop anyway
theoredically you could use vp maskset but I dont see that being generated in burst code.
if you're not constantly enabling/disabling components it still makes sense to just add/remove them
Well if you're using enabled components, dont expect cross entity vectorization anyways. Structural change for that.
yeah, i question enabled comp for health state right now :/
if it's being changed every 10ish frames, might be worth. Just random number i pulled. Beyond that, structural change or if it's a gap of 1 or 2 entities and majority enabled, use math.select. And then use the bitmask to populate a bool4 and swap in changed and unchanged values for a final write.
I'll go with an IsAlive tag. need to persist health when something is resurrected ๐ and the tag is much nicer to group everything nicely together
ArgumentException: A component with type:Unity.Scenes.SubScene has not been added to the entity. Entities Journaling may be able to help determine more information. Please enable Entities Journaling for a more helpful error message. This appears every time I try to see a thin client world. Anyone knows what going on?
Client, Server, and default worlds work fine but not thins
has anyone profiled enabled comps? i would bet it's not any faster than a bool comp
ehhhh, probably
Pretty sure unity discussed the difference of this on forums a while ago
And it was quite a bit different
CEE and IJE can skip checking large gaps using bitwise operations (lzcnt probably).
If it's very fragmented, such as when every other component is enabled, it most likely has equal performance.
Huh, the error disappears if the hierarchy mode selection (the yellow dot thing) has no yellow in it.
And then I can increase its yellowness to see the rest of the entities.
that means authoring state doesn't it
No clue, it has no hoverover
i think it will only be faster when a large amount of chunks is completely disabled
Oh yea, and the ability to skip chunks entirely at schedule is a big bonus as well
i think skipping chunks is a pretty laughable reason. especially when you can do that with change filtering
Change filtering breaks easily and you have to structure everything to support it though
@rotund token Do you know of a way to improve owner predicted - owner predicted collisions? It's so bad because of the interpolated collision.
I could set the other thin clients to predicted but i havent seen any sample that had the player entity be predicted mode.
dont use physics?
huh, no prediction? that's the best thing about netcode. otherwise it feels laggy
Yea, the prediction with regular entities is smooth as butter. With some slight teleportation. But with other players it's ugh
I got this massive table of numbers that I've gotta find a good sweet spot for
hm, i sadly can't tell you what i did around 2-3 years ago. i had a perfect implementation of KCC + netcode running. even collision was perfect.
collision between player owned objects?
i used no interpolation that much i know
collision with everything else works out of the box but with players, not so much
i'm trying to hit spheres together
Think pool but what if every ball was a player?
KCC was really stable after I found out the problems with it. something that bugged for the longest time was the grounded state which introduced jitters
so where's the trouble, only local or on server?
local
I hit two player owned spheres together and it pauses for a fifth of a second then teleports
it's the interpolation delay
I can use predicted movement for everything but then the other player's movement when not colliding becomes jittery
mh, so the physics are not predicting?
Rather, it's physics predicting too much when not colliding
hm, ok, yeah that's surely a tough one. i mean i couldn't move other players around. on collision a player would need to be locally calculated.
yea, hrm. gotta play around with those numbers above.
predicting every network player makes no sense when you can't get it stable
but that would be the easiest route when there's a solution to it
I mean, I'm using the worst possible (realistic) network statistics with this:
i think it should be possible to fix the jitter when everything is predicted
otherwise it would be pretty sad for physics
how's your quantization for position?
Delta pos for input movement is just 2 sbytes. +1 and -1 axis.
translation isn't synced?
default was way too inaccurate for me
i think it has like 2 decimals or smth?
in any case, try to increase the accuracy. i think it should help with the jitter
i use physics
click to move games don't feel so bad (i.e. path of exile)
Hrm, changing quantize factor for translation and rotation doesnt really change anything
from what did you change it to?
i tried 100, 1000, and 10000
10k should be more than enough. :/ hm, wonder why it's jittering then
it's just interpolated collisions
client side the interpolated object is an unmovable brick and clientside physics calculates it as such
but server side it's a dynamic object that can be pushed by other physics objects
where clientside calculates the player bouncing off the other player and then server side says no, you actually pushed the other guy
While predicted everything fixes the collisions, other player movement under predicted become very stuttery
poe uses lockstep
they have an optional predictive path but it feels horrible
you constantly desync
(it was originally predictive via this path only and they added lockstep like 5-7 years ago)
hrm, one option is to just not let players collide with each other.
a common approach in games
Another option is to just validate the interpolation physics. Make player - player collisions kinematic. As in players can collide but not push other players
But making this possible required a IJacobiansJob that will enforce this very specific collision physics on a small subset of collisions but the job iterates over all collisions occuring
Nope, doesnt look good. There's no way to determine who's colliding with whom so it's a kinematic - kinematic collision. Or no collision at all.
solve it with game design. the player can only push other players when charging, which makes his ball uncontrollable (for a while) for the local player
Ah, here's the other subscene header corruption error: Exception thrown during SubScene import: System.ArgumentException: Multiplayer.Components.PredictSwitchProps must already be filtered by ComponentSystemBase or ISystem at Unity.Entities.TypeManager.FilterSystemType (System.Type type, Unity.Entities.TypeManager+LookupFlags lookupFlags)
That's probably the best idea so far. Maybe in the future whenever I get to use these physics
You know, setting everything to interpolated actually works
oh yeah the other reason is a technical one
i need to be able to let the player take control of any ghost (that is npc controlled by default)
and you can't change ownership of owner predicted
so i'd have to like despawn, respawn etc
i couldn't find a nice solution
and since the style of game doesn't feel that bad interpolated just decided to save myself a lot of work with prediction
and just make whole thing interpolated
The issue is with full interpolated is that what's the use of deterministic then. I guess it'll be great for when havoc comes out because interpolated will be the only way you can use havoc in a network environment.
yeah actually havoc is something i want to test
it provides a much better simulation for something i want
but by default doesn't really work with predictive stuff
Is havoc actually better performing? I know it has better stacking and contact stability.
not sure about performance
could be worse for all i know
but a key part of what i've been doing is making large chunks of hte game (like full buildings) destroyable
and debris could really use some stability
True. And does havoc do soft bodies?
no idea
ive only used it for like 5min
was going to be a 1.0 project
but ah yeah
that's on hold for now ๐
hrm, maybe interpolated ghost ownership but predicitive everything else. Sure, movement and action might have ping delay but bullets will have immediate action
As for havoc, unless it has better performance, my game is 2D top down and no stacking so I dont think I'm gonna get any benefit from it
I wonder if I could implement a sort of reverse owner predictive behavior. Have predictive physics until another player enters within a certain range, and then it's interpolated.
Have instant predictive responsive physics until 2 unit distance with another player and then you feel the input lag
can you just not make other players interpolated
so only the local player is predicted
why though
Netcode forces interpolated objects to be kinematic
That little monologue is why predictive - interpolated collisions are bad.
As long as you manage what is predicted yourself instead of relying on owner predicted you can implement logic to disable prediction when another player gets close if you want to try that out. The prediction switching sample - https://github.com/Unity-Technologies/multiplayer/tree/master/sampleproject/Assets/Samples/PredictionSwitching - shows how to manage what is predicted / interpolated manually. That specific sample makes everything close to the player - including other players - predicted and everything far away interpolated, which could also work in your case
guys, I'm again coming with the stupid questions. We have a projectile prefab. Let's say we create the authoring components for the projectile. We detect input in a monobehaviour. How do we spawn a entity from that mono with the projectile prefab ?
get reference to World in your mono, query for that prefab (it can be singleton comp with Entity fields of your choice)
once you have Entity prefab - instantiate it
@rustic rain ok so var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
" query for that prefab (it can be singleton comp with Entity fields of your choice)" I dont get this at all
you need subscene
once subscene loaded you can get your prefab out of it
question is where you store your prefab
well right now the projectile prefab is just a public GameObject field on the player
in the main scene lets call it
it's not Entity?
you need to convert your prefab then
if I place my prefab in a subscene and play the projectile moves
{
}
class ProjectileBaker : Baker<ProjectileAuthoring>
{
public override void Bake(ProjectileAuthoring authoring)
{
AddComponent(new Projectile
{
Pos = authoring.transform.position,
Dir = authoring.transform.forward
});
}
}```
the system works on this component lets say
but our player is not a entity, we dont want our player to be a entity
he has a OnShoot method
what do I do in that OnShoot to Instantiate a entity ?
you have to get a reference to the entity manager
and the prefab entity
and instantiate it
but how do you plan to have projectiles hit the player if it's not an entity? (or anything interact with it)
Is there a way to instantiate prefab and associated it with Entity? I have seen how to create entity out of prefab, but how to add necessary components to existing Entity so that it has visual representation?
You convert prefabs and then instantiate them
anything related to visuals should be done that way
or else you'll have to dig into graphics package and how it works which is not very nice
What do you mean when you say "convert"?
drop go with authoring comps into SubScene
but this just makes a single projectile in the subscene that runs sure
how do we dynamically spawn it ?
you get reference to prefab and use EntityManager's Instantiate
.Instantiate() wants Entity not GameObject
that's why you convert GO to get Entity
How?
Great, I want that dynamically from a scene
runtime conversion is obsolete
here is example go ecs tutorial : https://github.com/Unity-Technologies/EntityComponentSystemSamples/tree/master/DOTS_Guide
and will be removed when 1.0 is out of experimental
I have read the whole thing but thank you
So you are telling me that there is no way a GameObject from a normal scene to create dynamically Entity with prefab associate with it?
Like, its a bad practice or literally there is no way to do it?
do we somehow cache the conversion with the Baker API or what ?
it's bad practice and it's obsolete. Soon to be removed
So, you either go 100% entities or 100% game objects?
you can use gameobjects for (for example) camera or ui and you can access them from SystemBase systems
How do you propagate data out of system to gameobject to UI?
I doubt there is way to update UI from ECS
from OnUpdate easy
so you can reference Canvas and GameObjects?
no, you can do hybrid
Didn't you just say that its obsolete and it will be removed? I am super confused.
you can have GameObjects as fields in SystemBase class
runtime conversion is, hybrid approach is recommended currently
but a system does not live in the scene as a monobehaviour
how do you drag the reference to the field ?
you can't convert game object into entity in runtime, but you can prepare all prefabs you need beforehand
Get them from the code in main thread
do we store the reference on a Component and query the entities or what ?
with Singletons ?
other way is for example explained in ecs tutorial (see link above) just go to the end where is camera related code
You don't need entities for UI unless you want to literally control inside jobs
Are there good examples for the "hybrid" approach?
so with Singletons
yes a kind of
for particle systems and all sort of components you can use this approach : https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-managed-create.html
Not that I'm aware of. To summarize: you can use UnityEngine.Object.Whatever in a SystemBase. So you can get your gameobjects that way. Another way is to make a class IComponentData with a GO prefab in it that you instantiate with a system during runtime. Check out tertle's implementation of this: https://discord.com/channels/489222168727519232/1027355900496851027. You can also access entities from monobehaviours via: World.DefaultGameObjectInjectionWorld.EntityManager.
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
@robust scaffold sir. Mind showing again code to create custom companion links?
I probably should save it somewhere ๐
If i have N jobs which processing same query, then is it more performant to fetch chunk array from query and them do manual IJobParallelFor (instead if IJobChunk) iteration? I mean how collecting chunks goes before running IJobChunk? Does it happen for every job or for example query cache it's chunks on first collecting?
why not combine jobs into one then?
they are conditionally running
so, why not store conditions then?
what you mean?
best way - just run single job instead of multiple. No scheduling and dependency costs
bool fields in job struct
ah, ok. In my case
1st job count sum capacity of all chunks in query
then this job gets forced to complete
then if sum exceed compute buffer's size i reallocate it and run set of jobs A
else I run set of jobs B
so i can't store bool fields, because some main thread logic depends on 1st job results
oh
yeah
better run multiple jobs then I think
but yeah, you can convert into Parallel job
if you want
so would it be more performant to fetch chunk array for all possibly running jobs instead of passing query?
u can also use GameObject.Find in main thread of SystemBase class OnUpdate method if you really need but i think tertle's approach(look above there is a link) and singletons are better solution - also you can put for example callbacks for buttons in SystemBase class and you can use a AddListener method in OnUpdate main thread(having buttons as fields in the same class)
i'm asking because such trick brings LOTS of boilerplate code
well, you'll save a bit of time that creates chunk arrays, yes
you can take a look
at Execute method
of IJobChunk
called in Run
this is pretty much how it works
should be pretty clear, what you save by doing this custom approach
in my system i sync components data with compute buffers to then send it to shader, so per shader's property i have sync process which means 1 job every frame
so as a result i have [1;3] + Np jobs running, where Np is a count of synced shader's properties. And all of them uses the same chunks, so there is no reason why chunk collecting should happen more then 1 time
how do you get a entity in a Mono from the EntityManager. ??
use a query
new EntityQueryBuilder(Allocator.temp)
finalize with .Build(EntityManager)
public abstract class BakerExp<T> : Baker<T> where T : Component
{
protected void AddCompanionType(ComponentType newType)
{
#if UNITY_EDITOR
BakingUtility.AddAdditionalCompanionComponentType(newType);
#else
throw new("Adding companion time outside editor is impossible.");
#endif
}
}```
hold up
is BakingUtility Editor only assembly?
Adding new components is editor only
As in that function is wrapped with the if unity editor assembly define
I see, alll right
oh, also
then in Baker
do you simple AddComponentBoject()?
during Bake
One another question:
ArchetypeChunk.DidOrderChange(uint) is just int comparing, so it has O(1) complexity as well as NativeParallelHashSet<T>.Contains(T) ?
Using BakerExp yes
Does NativeMultiHashMap have a scale factor to its capacity? Like say I need 100 elements, and I set the capacity to 100, but if a scale factor of 1.7 exists, the internal backing array size would be 170. That would help reduce the number of collisions
Nevermind, https://forum.unity.com/threads/nativemultihashmap-capacity.843421/ says it doubles when the current Capacity is exceeded
Itโs rather taxing on memory, but I think Iโll set the initial capacity of my spatial partitioning to the initial number of eligible entities times 2
NativeMultiHashMap still uses a โNextIndexโ style of resolving hash collisions, right? So having some breathing room in capacity would decrease the number of jumps across memory
That way itโs highly likely that the current elementโs NextIndex is just right next to it
this is old thread
it was reworked multiple times
after tahat
I see. Is the current source code anywhere?
packages are sources
compiled in editor
pretty much most of DOTS code is open sourced
Increasing capacity increases your misses
Because you're increasing the number of valid hashes
Which is equal to 2x capacity
Also capacity is scaled up to power of 2
But yeah hash maps start being noticeably slower with larger capacities
If you care about performance you should be keeping capacity as small as possible
Gotcha. So a small capacity combined with a good hashing function will make NativeMultiHashMap fairly close to O(1) for each element?
Weโre still talking about Multi Hashmaps right?
Would around 8000 elements for example cause an explosion of overhead?
Right now mapping spatial hashes to all resident entities in a NativeMultiHashMap is my current and simplest solution, but a ton of locations will be inputted into this spatial hashing to help with AI decision making
There are online solutions proposing a dynamic buffer of entities, each with their own dynamic buffer to represent a 2d grid with variable elements per cell
It wouldnt be a problem to refactor my spatial hashing class to use that approach instead, but Iโd like to know if Iโve been using the wrong DOTS approach to 2d spatial hashing
Are you trying to use hash maps to query distances?
If you are, consider building a BVH tree. Using the physics engine works for 3D and for 2D maps, making your own isnt difficult.
Hammered out this new prediction switching job stack.
nice, did it help with your problem?
8k is like nothing ๐
i can have multiple ones with 250k and they run fine
No, but it's fancier.
switching the player itself from predicted to interpolated is very stuttery. The transition flickers really badly.
It's not a seamless transition, the moment where predicted converts to interpolated and vice versa results in a significant teleport
The transition duration doesnt help. That's there to smooth the graphical visualization, not the actual position
huu, yeah the predicted object is a few frames ahead. might need some kind of delay
Oh no, that would be overkill. I only need distance queries as if everything in my game is a spherecollider. Your predictor looks cool though
Sounds good.
Hm, the Unity relay service is pretty nice but on desktop competing against Steam which is free.
relay is also free up to a certain point
50 ccu, i dont know how concurrent users are calculated but i think 50 unique users per month is the free tier.
What kind of flickering are you seeing? It should apply smoothing to LocalToWorld which is used by the renderer - so visually it should smoothly transition. The position used for simulation will teleport but we have not seen any use-cases where that is a big problem so if you have one I would be interested in hearing about it
Oh, I'm trying to collide 2 owned predicted spheres together smoothly.
Wasd controls the client sphere, arrows controls thin client sphere. And hitting them together over 300ms round trip ping results in extreme amounts of teleportation and stuttering. Using interpolated client and thinclient results in smooth collision and movement but massive input delay
Using predicted client and thin client results in smoothish collisions (good enough for me) but stuttering movement
I tried all sorts of values in client tick rate and client server tick rate but no combination I found fixes the predicted thin client movement.
Collisions between interpolated and predicted can't really be smooth, one is behind the server and the other ahead of the server so they are not at the same simulation time. The only way I see to make that smooth is to have both interpolated or both predicted.
So now I'm trying to implement a joint that links a kinematic collider that exists in the same place as player entities but only collides with other players. Such that players can not push players. That way client owner predicted physics is validated server-side and there's no teleportation between predicted and interpolated collisions
The problem with predicting other players is that you will always have a significant delay in the inputs, and the simulation will proceed with old inputs, the correct in rollback when it gets correct inputs. It usually works good enough for objects with some inertia, but if you can change direction or velocity too fast it will become obvious that it miss-predicts. It should not stutter when inputs are not changing though - if it does that there is a bug somewhere
I'm applying direct physics velocity for movement. Not forces.
But yea, just moving in a straight line, no input changes beyond the initial key down, results in stuttering movement with predicted thin client spheres.
Well no, input buffer is not replicated for thin clients. The buffer on the thin clients for input exist but they're size 0. Only transform and translate are being communicated to the client-side ghost.
I have send to not owner and prefab type of all predicted selected in the ghost component of the command buffer but the values from thin client inputs are not being communicated to the full client for prediction.
As long as the input buffer is on the ghost and all fields are marked with [GhostField] it should be replicated to the real client - but you need a bit of custom code for thin client input handling to get that setup right since thin clients don't spawn ghosts
I see two network ID and command target singletons on the server but only 1 on client worlds. I think that's intended. So how do I hook up the command buffers of non-current player ghosts to recieve the input command data from other clients? Do I need to make more network ID singletons?
Yea, I got the thin clients working and communicating with the server at least
The full client does not need command target singletons for the thin clients, but it does need the input buffer to be on the ghost prefab for the player rather than some other entity. Since the thin clients are not spawning ghosts you need custom handling there - something like the ThinInputSystem in https://github.com/Unity-Technologies/multiplayer/blob/master/sampleproject/Assets/Samples/Asteroids/Client/Systems/InputSystem.cs which spawns a non-ghost to hold thin client inputs
Yea, i got that. My thin clients successfully move using arrow keys after all. Give me a min, unity is crashing on me again. Entity headers are corrupted and all that jazz.
Hrm, maybe I can record what happens when I use predicted thin clients (ghosts with owners not local)
In text form, using this as my input command buffer:
This is my very basic movement system
I had to chop a bunch of frames off in that gif. There's about 1 sec pause where no inputs are registered before switching directions
The problem is that giant teleportation on changes in movement direction
Both of those look correct, only common pitfall I can think of if you're not getting any data is that you must add the input buffer to the ghost prefab at authoring time, if you add it at runtime it will not be serialized. It's not obvious from the gif that you are not getting inputs though - with changing the velocity from one frame to the next like that I would expect some issues like that when changing direction, the client gets the new direction after it already predicted in the wrong direction for a bit and will teleport. You can smooth that out with prediction smoothing but it will never be perfect
There's just this strange instant teleportation by about 1 unit in the direction of movement when first receiving input of control and then a teleporation back when arrow keys are released.
300ms round trip ping, teleportation doesnt appear on lan settings for example
Doesn't look completely unexpected to me. If you have 300ms ping and 60 fps you have 18 or so frames delay on all remote inputs. So when the client receives a snapshot it will see, oh - I was suppose to start moving 18 frames ago, I'll just resimulate those 18 frames to figure out where I should be now. In other words - it will perform 18 frames of movement in a single tick. Similar when you release, it will see that it was suppose to stop 18 frames ago, resimulate those frames and move back to where it should be after moving forward 18 frames too much. If your remote inputs are not received and always length 0 I would expect that you do not predict movement at all, and you will get the stutter of not having prediction instead of miss-prediction when starting/stopping/changing direction
Huh, makes sense. Let me see what happens when I disable remote input handling
Ya know, actually. Looking at the predicted thin client without remote inputs, it's slightly jittery but honestly not that bad
So I got rendering working and what not, but now my issue is that nested entities don't seem to be following their parents localtoworld position. No matter what I change the only rendering location its its own localtoworld
This is converted or runtime authored?
Its all done runtime, just testing starting with a nested entity where a child has a RenderMeshArray added via RenderMeshUtility.AddComponents
Worked with the same setup on entities .51 and previous hybrid renderer, so I don't know if this is now expected behavior or not
1.0 dots graphics changed drastically so the api probably changed
Yeah, just not sure if there's something I need to do with LocalToParent that I didn't before, or another component I am missing
I wonder, with the introduction of enable-able components, will there be an option of disabling components instead of removing them when switching between interpolated and predicted?
So, I have a strange issue trying to launch my project on linux
On Windows I don't have any issues but when I try to play the scene on my laptop with linux I get a shader related error
Sounds like a graphics problem. Using dots?
Yes, that's why I'm here
Is it pink shader error or is it not rendering shader error
@robust scaffold
Uh, V2 is dead. Are you using 1.0 dots?
At the moment I'm using 0.51
Hmm urp had a lot of fixes in 1.0
Oh, then there might be some remaining bugs. Havent heard anything about using it on linux though. And yea, Entities Graphics / HybridRenderer has been massively overhauled in 1.0
I dont know if it'll fix the problem though. I imagine testing on linux is at the bottom of the list, if it's even on there for these preview builds
BTW, does 1.0 has any easy ways to add animations or is it the same situation as it was with 0.51?
Nope. No dots animation yet
With RenderMeshArray you can at least manually do basic animations at this point
I guess for now I will just have a job that just syncs a child entity to its parent entities LocalToWorldTransform every frame? Kinda lame
why isn't this handled for you?
I have no idea
did you mark your entity as static or something
Not that I am aware of. This same solution worked prior to 1.0,
Mmm It appears to work in the sample scenes, so I have obviously something off somewhere. Strange it didn't do this prior to switching to 1.0 though
Ok, kind of a dumb question but how do you build a project using entities 1.0?
Build configs from 0.51 don't work and I can't really find any information about it on 1.0
Do I just build it like normal?
Yeah you build using the normal unity build window
It's mentioned here: https://forum.unity.com/threads/exciting-developments-in-upcoming-entities-1-0-releases.1341071/
Not sure why it isn't in the upgrade guide
Well, the game build for linux worked on my laptop without issues
Let's hope that the editor will also work without major issues
Sooo anyone work with Layers with the new RenderMeshDescription on a Orthographic camera? I can't get any consistent results, and now position.z doesn't seem to matter like it did for hybridrenderer
Is Dynamic Buffer still thr only option for arrays/lists?
NativeArray?
Can you put it in IComponentData now?
Dynamic buffer is the way to go
Thanks!
Yes
It's just a couple ints and a pointer. You have to manage disposal though
you mean to store it as a pointer?
That's what a native array is. A few ints and a pointer to Allocator.Persistant or wherever you put it
All NativeContainers work in an IComp now because the managed DisposeSentinel was removed that prevented it. Hashmaps, Queues, all NativeX really. Best to use them in a singleton entity. For several lists that are on entities, DBs are still the best choice.
You can use the struct directly now. pointers have always worked
Wait, new version came out today?
Oh, nothing really new ๐ข https://github.com/needle-mirror/com.unity.entities/commit/137125fb32d093274f57222385924e7751ca2b64
Well, it fixed world update allocator reset and uh, CurrentGroupAllocators are public. No fixes to the jank that is baking or subscenes sadly.
how does those changes result in jumping 6 versions?
5 source files changes + 1 for new docs ๐คฃ
wonder why they even bothered to release this ^^
some more SystemAPI features would have been nice :/
The allocator reset change is due to merging over netcode systems into 1. So that wasnt even much of a change
Huh, current group allocator to public is also due to changes in the netcode package.
is there a new netcode version?
Yea, the whole ecosystem got a minor patch
ah then it makes sense for just a minor update
Netcode changes are basically replacing tempjob with world update allocator
finally my leaks
And some improvements to the editor inspector
Yea, the reason for this bump in version was netcode. Graphics got improved documentation and uh, dont know what the small amount of rest is doing
think they fixed a crash in physics
Sorry, what problems are those?
The subscene problem is I assume the hang you mentioned the other day
Just subscene headers breaking for random reasons. I think my most reliable is just adding new systems. And also GetEntity(GameObject prefab) does not add to linked entity buffer.
Hmmm, thanks
Ooh they might have fixed the issue with physics objects falling through the floor when an entity is picked in the scene view
[CreateBefore(typeof(BroadphaseSystem))]forPhysicsSimulationPickerSystemwithinUnityPhysicsSimulationSystems.csscript file.
The hang is probably something I'm doing in netcode TBF.
Is that with the subscene open? I dont think I was ever able to click on any entities
Netcode also doesnt support physics joints, which is absolute pain
yeah, but haven't updated yet so not sure if its fixed
i don't need to dispose anything allocated with WorldUpdateAllocator, right?
Nope, automatically disposed
cool, so there's really no reason anymore to use TempJob
It's real nice, i've replaced everything with either temp or WUA. Never call dispose anymore except for compute buffers.
So WorldUpdateAllocator is an allocator that disposes automatically at the end of the frame?
at the end of the next frame. It allows you to reuse the memory slot of the same NA, and only native array, every frame without re-allocating.
Although to do that, you need to use the full state.WorldUnmanaged.UpdateAllocator.AllocateNativeArray<>()
wait so it only works for native arrays?
There's also AllocateNativeList<>() but the NL that is returned from it is fixed capacity and basically a NA with a length int.
No, the WUA works for all collections. Just some special properties of it only work for NAs
If you wanted to tag a NHM to it, you would just do so normally like NativeHashMap<int, int>(5, state.WorldUpdateAllocator); but you'll be re-allocating that 5 capacity every update.
Do I need to call dispose then or will it do that automatically? Wondering if there is any reason to switch to WUA over TempJob for things like one-frame native hash maps
Nope, no need for disposal.
Okay cool. So WUA always automatically disposes, and in some special cases avoids re-allocating entirely.
yep
Hmm, so I updated packages and it seems to have broken my subscenes. They don't render properly in the hierarchy window:
restart editor?
And the inspector doesn't draw the subscene component correctly
I did. And updated unity to b12 since I was on b8
Remove and re-add the subscene?
Oh shit, mine as well
AHHHHHHHHHHHHHHHHHHH
@viral sonnet @rotund token @rustic rain Do not update to the newest entities. Broke subscenes, somehow.
what if you look at dots hieararchy
interesting though considering the minor changes
Oh I think I know what's going on, something's broken in AssetDatabase in B12.
2D tilemap extra's also had this problem for a few weeks now
They said a fix is coming down the pipeline, no ETA
Hmm, re-adding the subscene kinda worked, but still having problems
Right, i didnt have anything in my subscenes frankly so reconstructing them wont be a problem, lets see if downgrading fixes the problem
I was able to restore the subscenes without fully recreating them. I right clicked in the hierarchy and said "New Sub Scene > Empty Scene". Saved it as a random file. Then clicked on the subscene and had it reference my old subscene.
I have a manual workaround to fix this issue but it's incredibly annoying
deleting your caches didn't work?
nope
No, this is a engine problem, not DOTS specific
i had this once and reimported subscene.cs
yea, you need to reimport the packages. AssetDatabase fails to register the scripts required to make everything work.
You have to do this every time you restart unity so hopefully downgrading fixes the problem
i had this in b9
no idea if this is related
but that somethings's broken in the asset database makes sense to what's going on
Downgrading seems to fix all the scripts and subscenes
let me see if it persists across restart
for me it was kind of random when it happened.
Yeah I think I'm just gonna go back to b8 and old package versions
Yea, just downgrading the packages work
well, that's was a concerning few minutes
@balmy thistle Just want to point out that on B12, the newest entity release seems to have broken nearly all the scripts.
so I just downgraded packages but stayed on b12. Seems to be fine expect for the fact that my scene view no longer renders with correct post processing
man i'm glad i'm always slow on upgrading
i even kinda scanned the update deltas, nothing was immediately red flag in terms of sensitivity
i don't think the packages are unstable. all points to b12
oh b12 is problematic for me
fresh project
add any library
crashes on asset importing for me
works fine on an existing project
but just cant get into app on fresh project if i add most packages
oh boy, wow very buggy
hmm damn, guess I should downgrade
Any detail in the AssetImport log?
just on a prefab
i stripped it back to just importing a single package at a time
entities crsahes
urp crashes
if i start the project with a template though it was no issue ๐คทโโ๏ธ
anything tricky about the repro?
let me try it again
i mentioned this on slack i was trying to get dani a repo for another bug
Just installed entities exp 12 on a fresh 2D built in project.
Ah, they disappeared on reload though
Right, i'm not getting any crashes on this new project.
well i can't repo my previous crash, going to try again from fresh
but i got a new one instead
Next Refresh will do full enumeration.Directory monitor buffer overflow for 'Assets'Next Refresh will do full enumeration.Directory monitor buffer overflow for 'Assets'Next Refresh will
infinite loop of this
I've never actually gotten any errors from asset database
And i've been experiencing roughly similar bug for the past few weeks
Yea, fresh project, no bugs, no crashes
i'm pretty good at crashing unity
Heh
There is a known issue with Prefabs in the Assetdatabase that causes crashes. The fix has landed in our mainline and it's en route to 2022.2. The bug existed in b8 but it relies on memory re-use and only runs when it needs to re-import a prefab, so you may get lucky and then not hit the issue again -- but if you clear your cache I could see it popping up again.
Once a day?
Eh, if unity crashes, reload usually fixes it for an hour or two before the next crash
i couldn't load project once
Oh no, prefabs are the problem? Netcode requires prefabs everywhere
though loading same project 4 days later seems to have magically fixed it ๐คทโโ๏ธ
=================================================================
Native Crash Reporting
=================================================================
Got a UNKNOWN while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
=================================================================
Managed Stacktrace:
=================================================================
=================================================================
Received signal SIGSEGV
Obtained 13 stack frames
0x00007ff65e539a43 (Unity) ImportAsset
0x00007ff65e55dada (Unity) AssetImportWorker::Import
0x00007ff65e58deea (Unity) AssetImportManager::ImportInProcess
0x00007ff65e58ae64 (Unity) AssetImportManager::Import
0x00007ff65e58e811 (Unity) ImportOutOfDateAssets
0x00007ff65e5997b9 (Unity) RefreshInternalV2
0x00007ff65e5a13bf (Unity) StopAssetImportingV2Internal
0x00007ff65e58eced (Unity) InitialRefreshV2
0x00007ff65dd994d2 (Unity) Application::InitializeProject
0x00007ff65e22c745 (Unity) WinMain
0x00007ff65f5e940e (Unity) __scrt_common_main_seh
0x00007ffedbcc7034 (KERNEL32) BaseThreadInitThunk
0x00007ffeddca26a1 (ntdll) RtlUserThreadStart```
from one of the random crashes
yea, prefabs borked unity. Fudge.
hopefully the known issue
well, exp8 entities seems to work fine enough
If this is the same crash (perhaps there is more than one -- but the callstack looks identical to the issue I found) then yes it's due to prefab importers using memory after a free. The bug went unnoticed most likely since the heap wasn't as aggressively re-used but changes in the memory system could make that crash more likely to happen.
i wish every dev would move to an archive file. deleting library and 100k files ... zzz (i gave up on hoping MS would make a good filesystem)
That is a different error and quite surprising. Do you have a local edit to netcode? That error throws when we are trying to add a non component type to the typemanager. Since we do the discovery based on if the type implements a component interface, this is surprising
No, I only have 2d tilemap extras as a local package. This was produced earlier today when upgrading to exp.12 broke everything and all the scripts failed. I think it was just cascading errors from an initial point of failure.
Seems like import pipeline is buggy at 2022.2 like platform build config is broken, subscene not working like can't compile properly. You always need to right click reimport dots related package to fix it.
I think the build configs are deprecated right now (although the only way to compile a client-server netcode build seems to be through the config). Companion / Hybrid is broken in build as well.
Thanks I'll do some investigation. If it's easy to reproduce I would be very interested what line is adding in SnapshotPreSerializeData to componentTypeSet in the TypeManager.cs InitializeAllComponentTypes() as right now it seems like possibly a bug in the UnityEditor.TypeCache which would be a bit surprising.
Build configs are indeed deprecated, and the usual Build Settings window should be used for creating builds.
Or use the Scriptable Build Pipeline
Ya. I ady switch to Build Settings window but because of the issue I mention just now that failed to read dots settings SO. Build Settings window also broken. It's not really reliable
For some reason this combination of build settings window (built in builds enabled) defines UNITY_CLIENT and un-defines UNITY_SERVER. Constantly breaking the CreateServerWorld() on initialization.
This error? Delete the DOTS client settings found in root assets
{
var extraScriptingDefines = GetSettingAsset().GetAdditionalScriptingDefines();
if(NetCodeClientTarget == NetCodeClientTarget.Client)
return extraScriptingDefines.Append("UNITY_CLIENT").ToArray();
if (NetCodeClientTarget == NetCodeClientTarget.ClientAndServer)
return extraScriptingDefines;
return Array.Empty<string>();
}```
check out
EntitySceneBuildPlayerProcessor
im not exactly sure what triggers this
It might be that dots client settings not working.
but they have build switches in there
Think it's talking about this right?
Nope. Something like that. Basically it's the same issue that need to reimport entities package to fix it. When u see this dots setting at project settings will also missing
hmmm looks right
Yea, it's the asset importer bug that's been a problem for a while. Now big problem as it breaks dots when upgrading to exp12
๐ Btw Entities exp12 seems like dun have any new updates. Just only few lines of new codes that I dunno wat it's for.
It was for netcode switching over to world update allocator for NAs.
But dont upgrade
oh yeah i didn't head your warning
and it works fine for me after i manually reimport subscene file
what about after restarting the editor?
this was after restarting editor
because i did it 30min ago
and i forgot to take a screenshot
hrm, let me try again
@rotund token just so you are aware, this code is buggy: foreach (var (linkedEntityGroup, entity) in SystemAPI .Query<DynamicBuffer<LinkedEntityGroupBakingData>>() .WithEntityQueryOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities) .WithEntityAccess()) { if (linkedEntityGroup.Length <= 1) ecb.RemoveComponent<LinkedEntityGroupBakingData>(entity); } my avatar baker creates a stat entity and the avatar gets a reference to the stat entity. this code removes the LEG. so on instantiation the breaks resolving the stat entity reference and a prefab stat entity is referenced.
i'm confused
must be some sequence thing. length is 1 when it should be 2
ah i see
I tried for hours earlier today to attempt to edit the LEGBD in a baking system and nothing worked.
๐ I ady upgrade
well i'll have to try find a repo
because i havent run into issues so not sure what the timing is
yeah, i was hunting this bug for the 1 hour now ๐
until it hit me that it might have to do with the leg
I just purge LEGs at startup runtime. The baking process is extremely fragile.
I dont know why netcode ghosts mandate the inclusion of LEG buffer on a ghost entity. If I had anything linked to it, I'll include it myself.
every prefab gets a leg
for no logical reason
i say it over and over again. make an internalcap of 0 for leg ๐
Of course it's the LEG authoring that somehow still works
LEG just wants to be loved
oh no
i see why this fails
are you using CreateAdditionalEntity?
yep
{
var additionalEntities = AdditionalEntities[entity];
for (var k = 0; k < additionalEntities.Length; k++)
{
if (NoBakeOnlyMask.MatchesIgnoreFilter(additionalEntities[k].Value))
{
Commands.AppendToBuffer(unfilteredChunkIndex, entities[i], new LinkedEntityGroup() {Value = additionalEntities[k].Value});
}
}
}```
it's done in the actual LinkedEntityGroupBaking system
as an append
ok well i'll just have to detect this case as well and ignore
hm, can we even get this data?
AdditionalEntitiesBakingData
ah cool
{
var leg = linkedEntityGroupBakingDataHandle[i];
if (leg.Length > 1)
{
continue;
}
var remove = true;
for (var j = 0; j < leg.Length; j++)
{
if (this.AdditionalEntities.TryGetBuffer(leg[j].Value, out var additionalEntities))
{
if (additionalEntities.Length > 0)
{
remove = false;
break;
}
}
}
if (remove)
{
this.CommandBuffer.RemoveComponent<LinkedEntityGroupBakingData>(unfilteredChunkIndex, entities[i]);
}
}```
completely untested
but thats my theory when i finish work tonight
will probably have a bit more of a read of the source as well
ion theory i should just be able to check LinkedEntityGroup itself in PostBakingSystemGroup
and not worry about this whoel thing
but i ah, couldn't get that to work when i first tried for some reason (though i think this was user error)
{
var bakingSystemGroup = conversionWorld.GetExistingSystemManaged<BakingSystemGroup>();
bakingSystemGroup.Update();
}
bakingSystem.UpdateReferencedEntities();
using (s_LinkedEntityGroup.Auto())
{
var legSystem = conversionWorld.GetOrCreateSystemManaged<LinkedEntityGroupBaking>();
legSystem.Update();
}
using (s_PostBakingSystemGroup.Auto())
{
var postGroup = conversionWorld.GetOrCreateSystemManaged<PostBakingSystemGroup>();
postGroup.Update();
}
because it happens after the linked entity group stuff
so that would be ideal
then i dont need to worry about LinkedEntityGroupBakingData or AdditionalEntitiesBakingData
nice to avoid internals if i don't have to
yeah, that would be a better hook
if you look at the source though it seems to check every entity in the LEG
for additional entities
as a child can have additional entities
as well
you're only covering the case when the root parent has additional entities
right, better safe than sorry ๐
foreach (var (linkedEntityGroup, additionalEntities, entity) in SystemAPI
.Query<DynamicBuffer<LinkedEntityGroupBakingData>, DynamicBuffer<AdditionalEntitiesBakingData>>()
.WithEntityQueryOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities)
.WithEntityAccess())
{
if (linkedEntityGroup.Length > 1 || additionalEntities.Length > 0)
continue;
bool remove = true;
for (int i = 0; i < linkedEntityGroup.Length && remove; i++)
{
if (additionalEntitiesLookup.TryGetBuffer(linkedEntityGroup[i].Value, out var childAdditionalEntities))
{
if (childAdditionalEntities.Length > 0)
remove = false;
}
}
if (remove)
ecb.RemoveComponent<LinkedEntityGroupBakingData>(entity);
}```
i wonder if it's possible to have a LinkedEntityGroupBakingData without AdditionalEntitiesBakingData
probably not by default
yeah, need to test that better. from a quick glance the legs are correctly removed
oh
if there's a child though
then leg length > 1
so that's not a concern
so yeah your short version seems fine
Did something happen to PhysicsUtils class?
ah ok, i leave it at that for now. don't want to run into any weird edge cases ๐
anyway the post version seems to work fine, no idea why when i first tried i couldn't get it to work
no wait i lied hmm
it's like it gets magically added back
yeah that was the issue
it clearly removes it via ECB i can see that with a breakpoint
but when i play, it still exists
ha, you can't query a component in Entities Hierarchy when it's in a system entity
yeah, i hope they refine this because it's pretty annoying that for some calls it is included and sometimes it's not. for the debug window it definitely should.
new EntityQueryDesc { Any = componentTypes.Set.ToArray(), Options = EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities }
imo system entities shouldn't be treated special to begin with
it's terrible
Any is not what anyone wants
at minimum that should be All
i will probably inject my own query into it soon
that does an All query and hides prefabs/disabled entities by default
me neither ๐คฃ
(i've used it in systems, just not for debugging)
when debugging i want to find a specific entity
you know
something with GivesOxygen that is an Actor
or a Building
i dont want to search GivesOxygen and have a list of 1000 entities to manually look through
or search building and have a list of 10,000 entitites to look through
i want to narrow it down...
or OR query it and have ~11,000 to look through!
its the biggest feature missing from entity debugger
i was shocked when it wasn't fixed in 1.0....
because i don't know how anyone who actually uses entities for large project development could live with how it is atm
i know how to inject this
into the hierarchy window
i just haven't thought of a nice way without having to hit some random button somewhere
That's 0.17
Ah, good catch, Thanks!
๐ฅฒ Built-in build at 1.0 not really reliable. Always easy to fail to build runtime player build.
When you do a 0.51 build you have to use a special Build Configuration Asset:
So... no updating yet?
๐ฅฒ dots 1.0 Builtin build feature still not stable yet?
Asset has disappeared while building player to 'globalgamemanagers.assets' - path '', instancedID '-39510'
UnityEditor.BuildPipeline:BuildPlayer (UnityEditor.BuildPlayerOptions)
We have considered using enabled bits for the difference in component set for interpolated / predicted ghosts - but we have not yet investigated if it is worth it so I don't know if we will do it or not. We are not working on it right now so I do not expect it to be in 1.0
In general I feel like switching between interpolated and predicted would be a more long term change (long as in at least seconds+) which seems less suited for enable components?
So it would just make the archetype a lot larger for minimal benefit
well that was pretty easy
{
var hierarchyField = typeof(HierarchyWindow).GetField("m_Hierarchy", BindingFlags.Instance | BindingFlags.NonPublic);
var hierarchy = (Hierarchy)hierarchyField!.GetValue(hierarchyWindow);
var filterField = typeof(Hierarchy).GetField("m_Filter", BindingFlags.Instance | BindingFlags.NonPublic);
var searchElement = hierarchyWindow.rootVisualElement.Q<SearchElement>();
searchElement.RegisterSearchQueryHandler<HierarchyNodeHandle>(_ =>
{
var filter = (HierarchyFilter)filterField!.GetValue(hierarchy);
if (filter == null || filter.FilterQueryDesc == null)
{
return;
}
// Swap our any and all queries
var desc = filter.FilterQueryDesc;
desc.All = desc.Any;
desc.Any = Array.Empty<ComponentType>();
desc.Options |= EntityQueryOptions.IncludeSystems;
});
}```
swapped Any to All and added Systems into the query
avoided changing entities package at all
just 10min and a little reflection
will probably spend some time adding a simple UI for this to make the Options optional
what did you?
modify package?
^
public static class CustomHierarchy
{
private static HierarchyWindow currentWindow;
static CustomHierarchy()
{
EditorApplication.update += Update;
}
private static void Update()
{
if (currentWindow == null)
{
if (EditorWindow.HasOpenInstances<HierarchyWindow>())
{
currentWindow = EditorWindow.GetWindow<HierarchyWindow>();
Setup(currentWindow);
}
}
}
private static void Setup(HierarchyWindow hierarchyWindow)
{
var hierarchyField = typeof(HierarchyWindow).GetField("m_Hierarchy", BindingFlags.Instance | BindingFlags.NonPublic);
var hierarchy = (Hierarchy)hierarchyField!.GetValue(hierarchyWindow);
var filterField = typeof(Hierarchy).GetField("m_Filter", BindingFlags.Instance | BindingFlags.NonPublic);
var searchElement = hierarchyWindow.rootVisualElement.Q<SearchElement>();
searchElement.RegisterSearchQueryHandler<HierarchyNodeHandle>(_ =>
{
var filter = (HierarchyFilter)filterField!.GetValue(hierarchy);
if (filter == null || filter.FilterQueryDesc == null)
{
return;
}
// Swap our any and all queries
var desc = filter.FilterQueryDesc;
desc.All = desc.Any;
desc.Any = Array.Empty<ComponentType>();
desc.Options |= EntityQueryOptions.IncludeSystems;
});
}
}```
full source
ah
just getting VE reference
and modifying it
I'm guessing what you did there just register second callback
that overwrites
can i schedule parallelFor job but length depending on previous job result?
thank you, so i have 2 option: pass int ref with unsafe context or pass nativelist
yes native list is the usual strategy here
yeah it's the same callback that sets the filter
Btw currently SystemAPI.Getbuffer<>() only support read only?
Dun have read & write SystemAPI.Getbuffer<>() yet?
its always write i think
If that's the case then I shouldn't get this error lol
InvalidOperationException: The BufferLookup<xxx> has been declared as [ReadOnly], but you are writing to it.
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <4f34b520fe644a2c9c25d8f755df793d>:0)
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <4f34b520fe644a2c9c25d8f755df793d>:0)
Unity.Entities.DynamicBuffer`1[T].CheckWriteAccess () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/Iterators/DynamicBuffer.cs:158)
Unity.Entities.DynamicBuffer`1[T].Add (T elem) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/Iterators/DynamicBuffer.cs:342)
xxx.OnUpdate (Unity.Entities.SystemState& state) (at Assets/xxx.cs:206)
xxx+__codegen__OnUpdate_00000730$BurstDirectCall.Invoke (System.IntPtr self, System.IntPtr state) (at <fa6bc290fd464bd69e81e0d76f7e0693>:0)
xxx.__codegen__OnUpdate (System.IntPtr self, System.IntPtr state) (at <fa6bc290fd464bd69e81e0d76f7e0693>:0)
(wrapper native-to-managed) xxx.__codegen__OnUpdate(intptr,intptr)```
Anyone has experience of choosing between Persistent/TempJob allocators? I have job which writes to list every frame, this list can include count of chunks in query at max. So I can expect, that count of chunks won't change every frame, so instead of allocating new list every frame with TempJob allocator I can instead allocate list with Persistent and then clear it every frame + reset capacity if i see exceed. However allocating persistent list is much slower then TempJob, also TempJob list will have better cache coherence.
Is there any theoretical reasons to pick one or another OR should I just look at actual performance and compare solutions? (I know, I should do that no matter what question is, but just want to research it a bit, because code a little complex at a time)
Well, profiling is always what should inform this kind of decision - Also, while you can use TempJob, you also have the option to use state.WorldUpdateAllocator instead, which does double buffering, writing to one buffer in one frame, the other in the next, third frame will then dispose the first and so on, it's pretty neat! ๐ (tho I reckon for your usecase that the Persistent is probably the more qoute on quote "correct solution" solution, as it will probably stabilize into the correct allocation size and then not cause more heap allocs.. Clearing should only set the length of the list to zero, thus overriding the memory, much more effecient than a re-alloc)
That's a known issue and has been fixed in master SystemAPI.GetBuffer is supposed to be ReadWrite for now :3
๐ I see. Make sure it will available at next Entities release. Btw I guess it's even better to provide read only and read & write SystemAPI.GetBuffer? Something like SystemAPI.GetBuffer<xxx>(true) to enable read & write. The default SystemAPI.GetBuffer<xxx>() will be read only.
Well, the rest of our api for pointers (handles, lookups, buffers) has a parameter isReadOnly, so for the sake of consistency that's what we stick to :3 Also notice how EntityManager.GetBuffer has a isReadOnly much better to be consistent in this case :3
Oh yeah. Actually what I mean is just add parameter isReadOnly into SystemAPI.GetBuffer
that's the plan, but unsure if it'll make it into 1.0 so you might have to do this for now :3
var lookup = SystemAPI.GetBufferLookup<MyComp>(isReadOnly: true);
var buffer = lookup[e];
@proud jackal ๐ง Btw can u try to push dots addressables feature available at future Entities exp. release as early as possible before 2023. Really want to test it at exp. release and not waiting until pre-release
seems entities and physics exp 12 is out and for graphics exp 14
๐ Ya but sadly entities exp 12 just almost no changes that only added few line of codes tat I dunno wat it's for
Hello people, I am going through Unity Physics. Trying to get this sample code to work: https://docs.unity3d.com/Packages/com.unity.physics@1.0/manual/simulation_results.html
This part is not compiling for me .Schedule(SystemAPI.GetSingleton<SimulationSingleton>()); I am getting: error CS1503: Argument 2: cannot convert from 'Unity.Physics.SimulationSingleton' to 'Unity.Jobs.JobHandle'
How should I schedule a ICollisionEventsJob job?
Did they at least allow you to initially disable an enableable component?
Looks like a package dependencies edit
it works with a bakingsystem and closing the subscene
nice! good job
You need to move the get singletons to a local var
And then add dependencies.
I do not understand how this will make a difference.
I had some issues with code gen and inline system api. Otherwise, just add state.dependency to the job
I am getting InvalidOperationException: Expected simulation type: UnityPhysics, current simulation type is: NoPhysics on play. How do I set simulation type?
hmm. i cannot reuse a subscene inside other scenes? if i drag it into another scene it is only recognized as a normal scene and baking isnt happening.
Do you have a physics step component anywhere in you hierarchy?
Has there been any investigation either on your side or wider unity dots development to setting the mandatory buffers internal capacity to 0? Like linked entity buffer and physics collision pair.
The mere existence of these buffers, used or not, halves chunk capacity from a reasonable 40 to 50 down to 20. And most of the time they're unused.
No, I do not. From docs it seemed that is not required but optional.
Do I need it?
I just added it and does not seem to make any difference
Does anyone know why LocalToWorldTransform has somehow disappeared? After updating to latest entities package it disappeared.
Using unity physics and / or netcode disables transform v2
Translation / Rotation components separate is transform V1. Combined LocalToWorldTransform is transform V2. Let me find the link.
I tried using aspect but code becomes not burstable
How do I set position of entity in burstable code?
You should be able to use aspects in burst.
Otherwise just set Translation.Value.xyz = float3 position
InvalidOperationException: The previously scheduled job NativeStream:ConstructJob writes to the Unity.Collections.NativeStream ConstructJob.Container. You must call JobHandle.Complete() on the job NativeStream:ConstructJob, before you can read from the Unity.Collections.NativeStream safely. What is unity trying to tell me?
I am using exactly zero jobs in my code.
They should be, could you post the snippet that wasn't? ๐
Btw will next entities release coming very soon with this fix included?
Next entities release is probably preview build, and IIRC in december to early 2023 if everything's still on track.
Internal capacity 0 would mean every single buffer needs to do a separate allocation any time you add a single element to it. We did measure and conclude that the extra cache miss you get on every single access from doing that was a significant performance hit when we initially implemented buffers iirc. LinkedEntityGroup is guaranteed to have at least 1-2 items in it so 0 seems like the wrong default for that one specifically. I am not aware of any additional investigations since then, but we have done passes on the netcode side to improve the default capacities of many buffers based on expected use-cases.
The LEG in particular is one of the biggest offenders we often point to in this channel. It's used only on entity destruction, which is a one time main thread structural change, yet requires default 8 capacity in the chunk.
I cant find @viral sonnet 's charts but there was a significant performance loss in chunk iterations from low chunk capacity due to inclusion of large buffer quantities.
The best of both options would be making the internal buffer capacity not hardcoded but I dont know how much code that will require.
My charts were even worse on my extreme stat example
30% reduced fps with leg
And 1.2gb extra memory (this is simply not having component not moving it out of chunk which would not help memory)
I'll take the cache miss
I think it's more important though to just not add leg when it's not needed
It's added to all prefabs by default even with no hierarchy
If there is no hierarchy leg is not required
And just avoid whole issue
LinkedEntityGroup is also used in the most performance critical jobs in netcode (serialization and ghost update) for all ghost with more than 1 entity. But I am not aware of any optimization efforts of the internal capacity for it. Is there already a bug/feature request filed for optimizing it? If not getting that would be great to have
Yea, I have a startup system purging all instances of LEG with one element.
I think Tertle said it best, make it optional. If we have a hierarchy we need to set up, let us do it manually at baking. Or have it detect at the end of prefab baking if there's no hierarchy (1 element in the buffer), remove it.
ok so the issue is this
in IBaker when you call GetEntity(prefab) it will always add LinkedEntityGroup to this prefab regardless if there is a hierarchy
var buffer = _EntityManager.AddBuffer<LinkedEntityGroupBakingData>(entity);
link 824 BakedEntityData.cs
so all prefabs without a hierarchy have a giant buffer added to the archetype that does nothing significantly limiting entities per chunk
to fix this, I have a script that can simply remove LEG on entities with 1 or less elements in the LEG during conversion (1 being itself since it's always added at element 0)
[WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)]
public partial struct RemoveLinkedEntityGroupSystem : ISystem
{
/// <inheritdoc/>
public void OnCreate(ref SystemState state) { }
/// <inheritdoc/>
public void OnDestroy(ref SystemState state) { }
/// <inheritdoc/>
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(state.WorldUpdateAllocator);
foreach (var (linkedEntityGroupBaking, additionalEntitiesBakingData, entity) in SystemAPI
.Query<DynamicBuffer<LinkedEntityGroupBakingData>, DynamicBuffer<AdditionalEntitiesBakingData>>()
.WithEntityAccess()
.WithEntityQueryOptions(EntityQueryOptions.IncludePrefab | EntityQueryOptions.IncludeDisabledEntities))
{
if (linkedEntityGroupBaking.Length > 1 || additionalEntitiesBakingData.Length > 0)
{
continue;
}
ecb.RemoveComponent<LinkedEntityGroupBakingData>(entity);
}
ecb.Playback(state.EntityManager);
}
}```
i would just like to not have to hack this in myself and instead have LinkedEntityGroupBaking.AddLinkedEntityGroupBakingJob handle it by just not adding the buffer if there is no reason to
this is my 0.51 LEG difference
6.26ms -> 4.03ms
now this example isn't as possible anymore because we are 128 entity capped now
but it shows the difference chunk capacity can make
I see, so instead of using a Baker implementation, write a BakerSystem which can access EntityManagerโs enable disable component?
It's interesting internal benchmarks have the cache miss on buffers being a problem.
We did a bunch of testing on this at work on our project last year and concluded we could not find a case where the performance benefit from increase in entities per chunk did not outweigh the cache miss and added a blanket rule of 0 capacity buffers in the project.
(this is an old project so doesn't use conversion and therefore doesn't get LEG however it uses a lot of buffers)
Do we need to open a bug report with test repo and benchmark reports to see if we can get the default IBC to 0?
๐ฅฒ But currently we only have max 16kb per chunk. So dun have luxury to put some many buffers inside chunk then u start to move it to child entity and then affect performance
Alright, so I can't get layers to mean anything at all in 2D Entities.Graphics rendering with a Orthographic camera. The only thing that appears to make a difference is the material's shader "Sorting Priority". Is this normal? Is there a way to access this property during runtime?
Are you rendering sprites?
If you're rendering quads, the Z position, or whatever is the depth axis, works fine for layering.
I am just using RenderMeshUtility.AddComponents directly on an entity. No quads, no conversion.
It works on perspective camera (z that is)
sprite renderer onto render mesh util?
Because I've been using hybrid and hybrid is borked in build. If sprite renderer can be attached to using RMU, that's big.
Gotta rewrite a lot of stuff if true
Ah wait, just meshes. I think.
Just mesh and material
I am only doing texture because everything else gives the SRP batcher error?
Unless something changed
URP/Unlit
The "Sorting Priority" is the only thing that makes any consistent difference in layers
Unity still does Z ordering even in orthographic mode. Have you tried moving the z axis of the objects?
Yeah, and thats what I was using prior to 1.0 and the updated entities.graphics
And it stopped working?
Yeah
In edit I can see the objects moving, and it is in front of the other object but still rendering behind
So I know Z is working
huh.
And thats z neg or positive either direction in edit, you can rotate like 3D, its still rendering behind
I thought it's just 128 entities limit per chunk so u still can have insane amount of entities? Just u will have a lot of more chunks
Its frustrating because I am wasting time not knowing if its something wrong with my logic or something unintended with the packages. I understand that they want us to use conversion and 3d is priority but it feels backwards to me. I do everything procedurally, so should I still be turning everything into a GO and then baking into entity?
Yes and that's the problem
The speed up was going from 73 to 232 entities per chunk
All my procedural entities are baked. I instantiate the baked prefab then set the procedural data.
๐ฅฒ Oh u mean it will slow down the performance a lot because of 128 entities per chunk limit?
yeah. this is not an issue for most users but i have some extreme performance libraries, which while was offset a bit by optimizations in 1.0, were still hit pretty bad
0.51 - 2.05ms
0.51 128 Limit - 4.75ms
1.0 - 4.34ms
i'm in the process of reworking library to utilize the empty chunk space that has been forced on me so long term it will probably not be a big difference. it's just the library was very specifically optimized around maximum entities/chunk.
โค๏ธ reflection and UI toolkit. Replaced the filter button with custom filter options.
source here if anyone was interested in some filter options for hierarchy window
Wow so can do all the customization without modify entities source?
yep, was pretty easy (UI toolkit is great for this)
i have a rule to try never to modify packages because it's too painful to maintain
i'd rather just give myself internal access and/or use some reflection
i just used reflection to remove the existing event subscription to the add filter button then added my own subscription for my new popup
and subscribed to the same search event that the default search uses and just updated the query after it was created
(you can see this in the source)
Hey @gusty comet , first of all, thanks for engaging on this topic with us. I've written most of what I wanted to say on this topic in this thread: https://forum.unity.com/threads/hierarchy-data-as-core-feature.1350353/#post-8526671 maybe you can get some stone rolling on this. My proposal is to either make hierarchies a very performant core feature or at least make the internal buffer capacity something we can change via config in the editor. I prefer pretty much any solution that is not a hardcoded internal buffer capacity. And this topic goes way beyond LinkedEntityGroup and the mentioned PhysicsColliderKeyEntityPair buffer but every IBufferElementData that is used in a package so I hope we can find a good solution for it.
https://github.com/tertle/com.bovinelabs.essentials
https://openupm.com/packages/com.bovinelabs.essentials.html
just released a tiny package with what I consider to be mandatory features for entities that require no changes from the user
these were previously part of my core library but not everyone wants a full library (even non-destructive)
- my physics collider inspector
- the hierarchy filter i just wrote
- remove LEG from prefabs that don't utilize it
that's it (for now)
thanks for putting this together. i consider everything essential
foreach with SystemAPI.Query is not able to call EntityManager.AddComponent. is our only option now to use ECB?
it'd be nice if it had a WIthStructuralChange option
yeah I think Dani said that ECB and manual playback is the best option for main thread idiomatic foreach
but performance wise yeah you probably want to use ecb anyway
instead of having to copy the data before iterating
alright, the old error msg still pops up "InvalidOperationException: Structural changes are not allowed during Entities.ForEach. Please use EntityCommandBuffer or WithStructuralChanges instead." was wondering if i was missing some kind of structuralChanges option
oh, i need the correct entity when i instantiate (it's a spawner system) because i keep an id lookup around. the deferred nature of commandBuffer.Instantiate strikes again
well i can make another loop after the playback
still not cool ๐
can't you just write it via the command buffer?
or are you storing this in a native container or something
it's stored in a NativeHashMap
i'm not really getting why i can't make structuralChanges in a mainthread foreach
EntityManager.RemoveComponet<Reference>(Reference.Entity);```
what if Reference.Entity was in the query
there's a reason WithStructuralChanges().Run() is required vs WithoutBurst().Run()
it has to make a defensive copy
that's a problem of the QueryEnumerable and enumeration. hm, on that note it should be possible to just cache those
if we can get a fully copy of the query this should work
but the chunk you are currently iterating
can change by an add/remove/create/destroy
the pointer is no longer valid
i get that - but the solution is not to disable the possibility because some code wouldn't work.
i read that EM structural changes are now more relaxed in foreach, wonder what's that about then
well the easy solution is to just add a WithStructuralChange option imo
what should really be prevented is making structural changes which include query parameters
its' not even query params
and sure, it should just do what WithStructuralChanges does ๐
that's what i meant with caching the enumeration
basically basically query.ToEntityArray() then GetComponent on each iteration
it's pretty poor performance and should not be default imo
for now i just stick to Entities.ForEach until we have that option. not worrying too much about performance, i have to do this because of hybrid so performance is already out the window ๐
Unity.Entities.InternalCompilerInterface.UnsafeCreateGatherEntitiesResult(ref query, out var gatherEntitiesResult);
var translationTypeIndex = Unity.Entities.TypeManager.GetTypeIndex<Unity.Translation>();
var rotationTypeIndex = Unity.Entities.TypeManager.GetTypeIndex<Unity.Rotation>();
try
{
int entityCount = gatherEntitiesResult.EntityCount;
for (int entityIndex = 0; entityIndex != entityCount; entityIndex++)
{
var entity = Unity.Entities.InternalCompilerInterface.UnsafeGetEntityFromGatheredEntities(ref gatherEntitiesResult, entityIndex);
if (mask.Matches(entity))
{
var translation = Unity.Entities.InternalCompilerInterface.GetComponentData<Unity.Translation>(__this.EntityManager, entity, translationTypeIndex, out var originalTranslation);
var rotation = Unity.Entities.InternalCompilerInterface.GetComponentData<Unity.Rotation>(__this.EntityManager, entity, rotationTypeIndex, out var originalRotation);
__this.TestSystem_LambdaJob_0_LambdaBody(entity, ref translation, ref rotation);
Unity.Entities.InternalCompilerInterface.WriteComponentData<Unity.Translation>(__this.EntityManager, entity, translationTypeIndex, ref translation, ref originalTranslation);
Unity.Entities.InternalCompilerInterface.WriteComponentData<Unity.Rotationt>(__this.EntityManager, entity, rotationTypeIndex, ref rotation, ref originalRotation);
}
}
}```
is what WithStructral changes does if you're interested
gets all entities
then check if each exists
and does a GetComponent
hm, i don't see much way to tidy this up in a SystemAPI.Query
Said relaxation is about the fact that it is now possible to use EntityManager.CreateEntity, EntityManager.CreateArchetype, and EntityManager.Instantiate, as long as it is not partaking in the archetypes you're currently itterating over ๐
I just foreach using EntityManager directly.
b13 does not fix asset importer problem, sad
will that relaxation be possible for EntityManager.AddComponent too? For example, instantiate and then add some comp based on a condition.
Does anyone know if kinematic - kinematic collisions raise collision events?
Also, does anyone know how to open this tab:
its been a while but i think so
if they're marked to
Marked for "Collide"
marked to raise collision events
Ugh, Im trying to make players kinematic but still collide with walls. Unfortunately, there's no kinematic to kinematic collisions. Collision events sure, but they're not stopping at static walls.
but ive just realized you said 2 kinematics, not kinematic/colliderso yeah probably not
Box2D kinematic colliders will stop when they move against static or other kinematics if an option is toggled. Shame dots physics doesnt have the same.
The kinematic wont push other kinematics. It just stops like it hit a wall.
dynamic - dynamic hits like pool balls, dynamic - kinematic / static hits like a wall, normal kinematic / static - kinematic / static hits nothing.
Box2D kinematic - kinematic / static shifts kinematic collisions to the second version from the first.
And I think kinematic - dynamic hits like pool balls. Been a while since I tested it
And of course 2D has proper continuous collision detection.
Also side note, during today's Q&A, the multiplayer guys said that, if they remembered correctly, havoc physics is fully compatible with netcode. Rollback and everything.
Even if it's not stateless apparently, it can just be used as a direct upgrade with full support with prediction.
They have tests to ensure deterministic end to end physics simulation and havoc passed. So maybe. We'll have to see in december or, more likely, next year.
@rotund token I'm using your strip LEG at baking system instead of mine during runtime as it makes more sense. Yet in this subscene (baked editor, not in playmode), a size 1 LEG still exists on this prefab. Is this correct?
Huh, I think ghost type component forces existence of LEG.
additionalEntitiesBakingData.Length > 0. Removing this condition removes the LEG but breaks the GhostTypeComponent above it.
and that is if there is a BakingOnlyEntity
probably good i'm not removing it then ๐
netcode is probably adding a BakingOnlyEntity
Not a baking only entity, this is just a runtime entity
yes but i mean during baking
{
var leg = legBuffer[i];
Commands.AddBuffer<LinkedEntityGroup>(unfilteredChunkIndex, entities[i]);
for (var j = 0; j < leg.Length; j++)
{
var entity = leg[j].Value;
// Only append if not BakeOnlyEntity
if (NoBakeOnlyMask.MatchesIgnoreFilter(entity))
{
Commands.AppendToBuffer(unfilteredChunkIndex, entities[i], new LinkedEntityGroup() {Value = entity});
}
if (HasAdditionalEntityMask.MatchesIgnoreFilter(entity))
{
var additionalEntities = AdditionalEntities[entity];
for (var k = 0; k < additionalEntities.Length; k++)
{
if (NoBakeOnlyMask.MatchesIgnoreFilter(additionalEntities[k].Value))
{
Commands.AppendToBuffer(unfilteredChunkIndex, entities[i], new LinkedEntityGroup() {Value = additionalEntities[k].Value});
}
}
}
}
}```
this is the code that adds elements to the LinkedEntityGroup
if (NoBakeOnlyMask.MatchesIgnoreFilter(additionalEntities[k].Value))
notice this line
on my stripping is this is false, i would still allow the LEG to be added
but if false in LinkedEntityGroupBaking it would not add it to the LEG
this means if something adds an additional entity to additionalEntitiesBakingData that has the BakingOnlyEntity component
it will still add the LEG but it'll be 1 length when baking is done
i haven't played with netcode enough since 1.0 to see what's going on though
i was conservative stripping LEG to avoid breaking cases like this (luckily so I guess)
I guess I gotta go back to my runtime stripping. I think it was working.
the edge cases are a bit annoying. if there's an additional entity that is not referenced on the main entity, LEG can be removed.
i guess that's your case as i see no references
It should actually have some. I've used GetEntity(GameObject prefab) but none of them are being added
if you have a reference and strip LEG, the instantiation will be buggy as the reference will point to a prefab entity instead
that's what i had yesterday
i mean references that are created in a baker via CreateAdditional or ECB
just references seem fine
i wish i could get it working after LEG was added
like my avatar create a stat entity which the avatar has a reference to. that kind
There's suppose to be an LEG
yeah i think finding out how to do that is key to solving this once and for all ๐
or someone at unity could listen - i mean we have a strict don't edit packages policy around here ๐
i remove it... but it still appears at runtime
It's added to the reference...
and the one time I want an LEG, it doesnt appear
that if statement returns false. None of those are true.
prefab and baking is borked. That I at least know from all of this.
is the IsPrefab method false?
Actually no, it's only used for weak reference resolution
there's no leg in this, hrm
Will setting a ghost component to client only be bad? What if the client memory edits the values in the component? Is there no server verification of the values in client only ghost components?
Although if they cheat engine the component, they might as well decompile the engine, edit the code to remove the requirements for light rendering, then recompile...
i'm just thinking about what tim said, that leg is used in the most critical paths of netcode. what are these paths?
Actually huh, i re-enabled my leg remover system, cleaned up some queries and bugs (replaced everything with a systemapi):
Apparently some netcode systems assume it's existence and dont check
Baker is just so bug free
Unity, what do you mean this needs to be system filtered:
ah must be the GhostChunkSerializer
so i used to do this way
remove it on all the prefabs as well, not just things you instantiate, and i believe it should work (though maybe behaviour broke in 1.0?)
wth, 3rd time and it just works fine? >_>
@rotund token thanks for the essentials. i love it
@rotund token not sure if its possible but i would have a feature request for it right away ๐
something like !c:Component that acts as a none filter
it's possible but i was trying to avoid rewriting the whole interpretation stuff myself ^_^'
it'd probably be something like
n:Component
though
much easier
i see. lets just wait for official support then ๐
I looked into your script and i wouldnt know how to write that myself. Im not very experienced with unities new UI stuff
filterField has a private field HierarchyQueryBuilder.Result
which has the public field string Filter;
so you could parse it in there this way
@$"\b(?<token>[nN]:)\s*(?<componentType>(\S)*)",
RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture);```
filter the n: components with this i think
(i barely understand regex, this is just unitys version with the cC to a nN)
then call
ComponentTypeCache.GetExactMatchingTypes(matchGroup.Value);
on the result
then add it to the None part of the query
and there we have it, kind of done it and now i need to add it
๐
xD
Main issue is it wouldn't auto complete with the popup menu
that wouldnt be too bad for a start.
we just need to make enough noise so they add it as a core feature ๐
i remember reading something about a new way to add a component to all linkedEntities.
how do i do it? and i suppose its only possible at runtime?
my favourite feature of 1.0!
ecb can do it
ECB.SetComponentForLinkedEntityGroup
though this is not adding
this is setting components on a hierarchy without knowing if they exist
i guess what you want is
AddComponentForLinkedEntityGroup
does that have an override for linkedentitygroups 0.0
it only works on LEG
oh lol you edited it ๐
yeah copy/pasted wrong thing ๐
its strange that entitymanager doesnt have it
because you dont need it
you already have access on EM to LEG
this lets you set data in a hierarchy of an instantiate
which was not possible before
because the hierarchy didn't exist until the ECB played back
but it's cool because you can just set XYZ components without knowing if it's required
imagine an AI hierarchy where you can inject SpawnTime/etc on just the entities that need it
only if your utility needs the data will it get set
its insanely useful. ill use it for abilities. each abilityuser has its own prototypeinstance of an ability. the abilityhierarchy needs to know the user. so now i can just set the user on the whole hierarchy.
yep!
So in this case i really need the ECB.SetComponentForLinkedEntityGroup. that makes it way easier to bake correctly from the getgo
i haven't actually used it but i've been thinking about usages for quite a while