#archived-dots
1 messages ยท Page 121 of 1
@amber flicker nope, no need to copy
it just needs to remap entity IDs and a couple other things
merging worlds is much faster than you would think
nice
it just inserts the chunks on the other world archetypes
@zenith wyvern Sorry, you mentioned getting singleton data through entity query, i couldnt find the post but can you tell me about it again ? For my buffers i have to do it like this:
var allyThreatEntity = GetSingletonEntity<ThreatAllyMasterTable>();
var allyThreatBuffer = GetBufferFromEntity<ThreatAllyMasterTable>();
And inside job i do
var buffer = allyThreatBuffer[allyThreatEntity];
@vagrant surge what's the reason for using a separate world for conversion do you know?
because worlds dont need to sync multithreading beetween each other
so you can have a background job filling one background world, while stuff on the main world continues to render and calculate
ah I see, like the way adding an archetype would cause a structural change.. yea I think I understand ๐
its a great way to do background streaming
you have code adding entities from disk files into this staging world
and when ready, it swaps into main one
tho im not sure how exactly the entity remapping works
thats why i dont have that feature yet on my cpp ecs
makes sense - any thoughts on @bright sentinel 's question or knowledge of any api for timing how long a job takes across threads at runtime?
Ohh, so creating a new world would be another way of just running things in the background?
That would at least solve the same problem, just in a different way
@zenith wyvern Sorry, you mentioned getting singleton data through entity query, i couldnt find the post but can you tell me about it again ? For my buffers i have to do it like this:
var allyThreatEntity = GetSingletonEntity<ThreatAllyMasterTable>(); var allyThreatBuffer = GetBufferFromEntity<ThreatAllyMasterTable>();And inside job i do
var buffer = allyThreatBuffer[allyThreatEntity];
@opaque ledge
You just do exactly what you're doing but call GetSingleton through the query. Cache your query in OnCreate, then in OnUpdate you can do
var entity = query.GetSingletonEntity();
var buffer = EntityManager.GetBuffer(entity);
I'm not looking for how to implement a solution that splits a job into multiple frames, but a way to not block other vital parts of gameplay, which seems like worlds could solve
@bright sentinel yes
Then you can pass your buffer into your job
one problem with ECS is that changing entities has to be done at a sync point, singlethreaded
but...
ah okay cool, so i can get the buffer in OnUpdate and not inside Job right ?
As long as you declare the buffer as read-only in your query then your system will only access it as read only
if you have multiple worlds, they dont have to sync point beetween each other
so you can be adding entities on a background world without locking the main one
and then just lock once when merging
ah okay cool, so i can get the buffer in OnUpdate and not inside Job right ?
@opaque ledge
Yeah, you get it in OnUpdate and pass it into the job
Ahaa, that might be the key I'm missing here. Is there then any way to control how many resources each world gets?
ah damn, i am writing to my buffer, would that be a problem
ooh thats great, not getting the dynamic buffer inside job per entity will give me good performance boost already
No, you just have to run your job in a single thread, or disable parallel safety on your buffer
thank you ๐
ooh thats great, not getting the dynamic buffer inside job per entity will give me good performance boost already
@opaque ledge
Make sure you do buffer.AsArray().Reinterpret as well unless you actually need to resize it. Makes a huge difference to use it as a NativeArray
does Reinterpreting gives peformance boost ? i have 2 fields in my buffer so i cant use reinterpert, but i can make it to a single struct if it gives perf boost
Well no probably not, the important part is to use AsArray as long as you're not resizing
I'm not sure actually
If you're passing it directly into a job from the main thread though. As long as you're accessing it through the query first I think it would be fine
Yay its working ๐
This made me confused however, i guess using Entity manager to retrieve(read) values in OnUpdate doesnt introduce any problems
AsNativeArray do work in OnUpdate ๐
Why do you think it wouldn't? ๐ค
still trying to figure out a more optimal way to use NativeMultiHashMaps.. they seem really slow, or well you cant do it too often, as it did almost crash my computer
Because i am accessing some components inside main thread, i mean what happens if a job that manipulates the data that i am getting with Entity Manager ? i could be working on proper values or wrong values depending on if that job has completed or not which would break determinism
That's actually a really good question
i bet calling EntityManager.GetComponentData<T>() is finishing all jobs with write access to T ๐ค
Hmm, if you declare the buffer as read/write in the query, you might be right about that
Maybe always actually, I need to dig into the source code
You're right, damn. From EntityDataAccess.GetBuffer
if (m_IsMainThread)
DependencyManager->CompleteReadAndWriteDependency(typeIndex);
So even if you only access it as readonly it forces a sync point for that component
damn
That's unfortunate, I was using that pattern all over the place
aww
I guess the way you were doing it is right then Curly, pass in a BufferFromEntity to the job
If you want to avoid the forced sync point on the main thread at least
yeah but it doesnt force sync point for everything right ? it just forces a sync point that has that component, isnt that basically same with chaining jobs that read/write to that specific component ?
mainthread blocking?
I don't think just scheduling a job for a component forces a sync point on the spot though, I'm assuming unity chooses some time to do them all at once where it makes sense
i think someone has to test this tho, maybe having bunch of Sark's pattern can break performance, but not so much if its only a few
As said, this isn't a sync point
Hm, maybe it is actually
I'll go back to observing ๐
i mean doing the thing i was doing actually lowers the performance by a lot, i had a job that was running without burst and run that was handling UI rotation to look at camera, i was creating normal Quaternion to be able to use a Quaternion function inside UnityEngine, so i was simply creating Quaternion from quaternion inside the job, i took that to outside of the job and it went to 0.4 ms from 0.6 ms, so if that alone can make this much difference imagine accessing the same buffer for every entity on a job
Were you accessing it through the BFE every time though, or caching the buffer at the start of the job?
nah, i was talking about simple calculation, no BFE or CFE, i simply took the calculation of Quaternion from quaternion to outside of the job and thats it
Oh I see
what about .ToComponentDataArrayAsync?๐ค
I did the same thing for getting camera and player position/rotations, instead of doing CFE<Translation> and getting Tag Singleton and accessing it inside job, i made CameraPosition, PlayerPosition etc and get them once inside OnUpdate, which also made good performance boost.
that doesnt work with buffers unfortunately
fixedlist inside component instead of Buffer?๐
i have too many entities to put into 4k bytes ๐
your buffer is so big๐ฎ
All I know is sync points are bad - multiple sync points one after the other is definitely bad. Curlys way of passing in the BFE with the BufferEntity is the right approach I think. Hopefully we will get a "GetBuffer" equivalent to the "GetComponent" they added in 0.7 to make it less ugly
yeah, it does feel like right approach
but i will stick with Sark's pattern unless i have peformance issues one day ๐
how about making a job that retrieves these singleton buffer and put it into native array with AsNativeArray, and use that native array on 2nd job ๐ค
You would have to copy it to a NativeArray that you pass into the first job - which would need to be sized properly ahead of time...or use a list I guess. BufferFromEntity seems like a better alternative
well i mean, you can just do Schedule since its singleton anyway so you can use lists, and afaik AsNativeArray doesnt do any copying right ?
No but you can't get the buffer out of the first job when the first job queries for it
oh you cant ? why not
The only way to get data out of a job is to pass in an array you copy the data to.
Well anyway, i just saw poor performance from BFE so i am open to alternatives ๐
Alright so I have spaceships with a bunch of stuff on them. Both dynamic and static. I simulate a exterior collision box, which collides with other spaceships and the world. Then I simulate the interior collision of walls boxes, player characters etc inside the ship. Currently the structure is like this (indents are children of, and "old exterior" means that collider has been moved from this entity to another):
Spaceship with exterior collider
Spaceship empty (old exterior)
Spaceship Interior Collider
Spaceship Interior Visuals
Static object with interior collider
Static object empty (old interior)
Static object visuals
Dynamic object with interior collider
Dynamic object empty (old interor)
Dynamic object visuals
This setup previously had all child colliders (spaceship interior, static dynamic objects) operate in local space around (0,0,0) while the rendering followed the spaceship. This is not the case anymore. Since many static and dynamic objects are ghost entities I have basically two options.
-
Change to have the interior in world position; rework of some systems; most importantly; requires me to update all LocalToWorld of ghost entities that are children before running PhysicsUpdate, as their Translation might have changed from NetworkReceive.
-
Instead of parenting and moving colliders to main Static, Dynamic entity, only add them to the LinkedEntityGroup. After PhysicsUpdate we now manually have to update the localPosition of Dynamic entities to follow the dynamic collider(which is not parented but operate around 0,0,0 )
Anyone have suggestion of what approach I should go or see any flaw/suggestion of other solution I could go with?
tried remving the [NativeDisableParallelForRestriction] line but somehow this happens Index 1702528 is out of restricted IJobParallelFor range [3333...3333] in ReadWriteBuffer.
the array length isnt that big
@low tangle
do you mean the memory profiler? or is there some other feature that I"m missing?
Jobs->Leak Detection->Full stack traces
ok I've tried all 3 options (on/off/full). it doesn't appear to change the output at all
shows a stacktrace like this regardless of my selection, even if I select off
but I'm guessing this is where it detected the issue, not where the allocation happened. is that right?
i have no clue how to debug this
I've tried commenting out most of my code, it still happens
there's got to be some way to find the issue without reconstructing my project piece by piece
so,, does anyone know a alternative to NMHM?
@odd cipher what exactly is the problem you're trying to solve? Why does a TerrainSprite map to a color?
I'm not a developer of your game. I don't really know what a TerrainSprite is or why it maps to a color. Can you explain what it is and why it needs to do that? Are you doing a procedural terrain?
Yeah so, each TerrainSprite has a TerrainID which is what TerrainType it is refering to. such as (0 = Dirt, 1 = Water) for example. and a VariantID which is for the TerrainType's other sprites. and a bitMask from 0-256 for different combinations ```cs
public struct TerrainSprite : IEquatable<TerrainSprite> {
public int terrainID;
public int variantID;
public int bitMask;
public TerrainSprite(int _terrainID, int _variantID = 0, int _bitMask = 0) {
terrainID = _terrainID;
variantID = _variantID;
bitMask = _bitMask;
}
public bool Equals(TerrainSprite other) {
if (other.terrainID == terrainID && other.variantID == variantID && other.bitMask == bitMask) return true;
return false;
}
public override int GetHashCode() {
return 0;
}
}
an example would be colorTerrainTiles[new TerrainSprite(kvp.Key, 0, 2)] = loadedSprites[name + "_N"].texture.GetPixels32();
though this does become repetitive because essentially that line has to be done 256 times for each combination
I'm just asking what it is in the context of your game. What problem is TerrainSprite solving? Procedural terrain generation?
yeah, it picks the correct entry in the "colorTerrainTiles" NMHM, the problem is that getting the values from that NMHM is slow
which is why I was asking if there was any good ways to avoid using a NMHM in my case
Well your NMHM is readonly isn't it?
Yeah it is but that doesnt seem to help in any way
It does, your problem seems to be really easy solvable by nested arrays
For lookups
Or am i missing something?
nested ararys is what I pretty much want but it doesnt work with burst
I think thats what I need anyway
That's what i use
It doesn't provide any safety tho
alright, how do I get this install in my project? never done it like this before
and not sure how it works either
@north bay ?
You mind if i dm you?
yeah sure
@odd cipher If I understand the above correctly, you are using your terrainID, variantID and bitmask (?) as your hashcode, couldn't you just use them as indexes in a multidimensional array?
There's this old C++ trick where you'd have a single dimensional array and index it multidimensionally by indexing it like this: someArray[i*rowLength + j].
I think you should be able to do indexing like that in something like a dynamic buffer on an entity.
in the examples (for example the boids example), the components are often way bigger than I do them myself
I have very small components, like even sometimes I have one component float2 for location on map and another one for height
does this have any drawbacks? why do the examples use such big components?
for larger projects theres just no getting around using more complex components, it would actually be detrimental to try to split things up into very granular components if many tend to get used by the same systems
You should organize components into data where the system will almost always need all of the data in that component. For boids, it makes sense since you need quite a lot of data to describe a boid, while more isolated components (such as position) is usually needed in lots of different contexts
That's of course the ideal way, but as @safe lintel states, it's not always the most practical way
ah only 56 more ijobforeach's to switchover! ๐ฉ
ok so the only reason is that it is tiresome to write out all the components needed if you need a lot in more complex systems?
both a convenience thing and also running into the component limit when for example using the ForEach lambda
can get around with chunk iteration but you're already writing a fair bit of extra code
like in this entity(which has other components too) it can definitely be split up and I plan to do so but it would be too much to split into granular sub components and its mostly one or two systems that deal with all of it so I keep it all together
Hey, how do I have to understand the ```cs
RayFrom
and ```cs
RayTo
in the physics ShereCast example from the Unity docs? Does it cast the collider along that line and when it collides with something it stops immediately even if it doesnt reach the "Rayto" position?
@formal scaffold You can look at the Physics samples (the one called Queries) to see how they do it. As far as I know, inferred from the sample, RayFrom is the start position, and RayTo is the end position.
There are two overloaded methods for raycasting, one is that it will stop at the first collider hit and output that, and the other is that it will output all the coliders hit, without stopping.
reading at https://blogs.unity3d.com/2020/03/17/unity-2020-1-beta-is-now-available-for-feedback/, they mentioned profiler now has flow events that make it easier to see the code flow on jobs: https://docs.unity3d.com/2020.1/Documentation/Manual/ProfilerCPU.html#flow-events
That is so useful!!
Oh hey, if b1 is out that means we can finally actually use Hybrid v2 right?
rip
also apparently DX12 works on hybrid v2 already, it's just HDRP DX12 is super slow (which they will address on 2020.2)
the reason why it didn't render for me must have just been the missing implementation on engine side as I tested it on b1
even DX11 just rendered like half the meshes
same with their testprojects
but it all makes sense, since Unity staff said that b1 wouldn't yet render these right
And a webinar on April 20th, I wonder if that's meant to replace the stuff they were going to show at GDC
It felt like they were leading up to showing off all their dots progress
Is is possible to make SphereCast visible?
Something like Debug.DrawRay but as Sphere
mathematically it's a capsule
you can look at how they do debug drawing in physics package๐ค
can you do this from job?๐ค
the trick is using from DOTS, I know
you'd probably have to store position and radius in a debug component and read the component data from a MB
can you use Graphics API from Jobs?
i dont think so๐
these jobs sound worse the more I hear about them!
All work and 0 pay
My Player is on Layer 11, why is this CollisionFilter colliding with my Player?
var filter = new CollisionFilter() {
BelongsTo = 10u, // Belongs to Layer 1
CollidesWith = 100u, // Collides with Layer 2
GroupIndex = 0
};
@warped trail I think Topher mentioned Debug.DrawLine was going to be supported in jobs in 2020.1?
@formal scaffold Might be wrong here, but you're specifying it to belong to layer with bitmask of 10 in UINT => 1010 binary, and collide with 100 in UINT => 01100100 binary ?
Oh wait I havent thought about it being UINT ill test
I usually bitshift it 1U << layerindex
I think you want 0b10, 0b100, etc
May I ask a question about the new mathematics package here?
I found my problem, it was the Physics Shape, Collision Filter. It was set to "Belongs to: everything"
Then all of those work to set the filter:
100u, 1u << 2, 0b100
Those are all equivalent to Index 2
here is the thing...
the first block of code I'm using the old Mathf.Quaternion.LookRotation with (0,1,0) as forward and (0,1,0) as upwards. According to the documentation it should return Identity
"Returns identity if forward and upwards are colinear" <- from the docs
Then I'm multiplying that quaternion by the world axis to get a "local axis"
In the second block of code I'm using the new quaternion.LookRotatioSafe from the new Mathematics Package, with (0,1,0) as forward and (0,1,0) as upwards. Again according to the docs Identity should be returned.
"If the magnitude of either of the vectors is so extreme that the calculation cannot be carried out reliably or the vectors are collinear, the identity will be returned instead" <- from the docs.
Mathf.Quaternion.Identity is equals to math.quaternion.identity indeed , so... why Quaternion.LookRotation and quaternion.LookRotationSafe are returning different values?
@formal scaffold 100u is 0b1100100
@worldly pulsar 100u seems to point to index 2 aswell as 0b100
A collider set to index 1 wont trigger a collision
Oh I think I get it
it has bit 1 << 2 set, so it belongs to index 2, but it also belongs to 1 << 5 and 1 << 6
Yeah
(not sure if Unity.Physics allows objects to belong to more than 1 layer btw)
My wall can belong to 31 Indexes, not sure if it's the same as layers tho
I don't use Unity.Physics so not sure on terminology, just pointing out that 100u is decimal and not a bitmask ๐
@chilly halo you are 100% sure faceOffsetDirection is (0,1,0) in your second example? that quaternion is 90deg rotation
Is the same variable for both cases , but I will debug to be sure.
Yeah just getting really started with it myself ๐ It's quite overwhelming but cool
oh, the code is one screenshot, I thought you stitched it together from several :)
either way, the Unity.Mathematics code is correct (returns identity for (up, up)), and the old one return a rotation that moves Vec3.forward to Vec3.up.
Never ran into it myself, but my guess is that there is a special case in the UnityEngine.Quaternion version to pretend the second argument is not there when it's (0,1,0), since that's the default value of that parameter and Quaternion.LookRotation(Vector3.up) should return a 90 deg rotation around the X axis. There is a bunch of little traps like these in the old math library.
for comparison, Quaternion.LookRotation(Vector3.forward, Vector3.forward) correctly returns identity
So... the bug is with Vector3.up with Vector3.up?
uh, scratch that, Quaternion.LookRotation(new Vector3(1,1,1), new Vector3(1,1,1)); returns nonsense too
Huh...
so yeah, the "Returns identity if forward and upwards are colinear" part seems to be a lie ๐
If it were just a theorical question/problem I wouldnt mind.
but the issue here is that the rest of the code behaves totally different with one result or the other (as its expected).
So... how is half of the games out there even working? Why no one else are having issues with that "false" identity returned?
the "returns identity" case is essentially an invalid argument error, you are asking it to build a rotation that puts "forward" and "up" in the same direction
(more specifically: you are asking it to build a rotation that puts "forward" the way you say, and "up" on the plane formed by the 2 vectors given. If both vectors point the same way there are infinitely many such planes, and the problem is underspecified)
Yup , exactly.
And... the old Unity mathF namespace returns that place rotated 90` degrees because reasons.
Well , I will continue to update our codebase to the new math package.
At least Im not crazy ๐
Thanks Rett
oh my. I've been living like a fool for so long. I had no idea systems still ran on entities in expanded subscene. I am so happy and angry at myself. ๐คฆโโ๏ธ
Has anyone been able to set up dynamically created entities to work with the hybrid renderer?
Got it working, I forgot to set the material on my RenderMesh
What, if any, solutions to per-instance properties using the legacy pipeline with hybrid rendering do you guys use?
there is per instance support in hybrid renderer v2
but they are not officially released, it requires 2020 beta 3 and URP HDRP 9
otherwise there was a forum topic about it, someone made a custom solution, but i am not sure if its relevenant anymore
Cool, I'll see if I can find it.
you can also download master branch from SRP to activate hybrid renderer v2
Why does V2 require 2020 though?
no idea, its just the way it is i guess
2019 cycle features are locked already, last tech release has released
there will only be bugfixes and sdk updates from now on for the 2019.3 engine itself
2019 compatible packages can still evolve but not for things that require engine side changes
@gusty comet @opaque ledge do note that hybrid renderer v2 is purely for SRPs, it will not work on the built-in renderer
(like hybrid renderer v1 does)
many still use it
you can "blame" endless asset store offerings on that
only few asset store publishers support URP and HDRP
and ones that do are really pissed off about SRPs ๐
yo, i'm having a bad case of analysis paralysis, so give me some input here. coming from an "advanced beginner" level in regular unity, i started looking into dots and I wanna learn it cause i feel it'll be the way forward. however a lot of things still haven't clicked; anyway, i'm finding it hard to get started. What i want to work on is a vr shooter kind of situation, without lofty goals but just to prove a concept; it would be coop enabled so I'm also looking at the new networking stuff. I really want to use Ecs as much as possible even though i realize it'll be a struggle, cause I want to wrap my head around it, so i'd avoid hybrid solutions as much as possible. that said, i don't know where to start, lol. It's like every time i think of something i can thing of some prerequisite and i just keep going in circles
so i guess the question is "what do first"
and how to best compartmentalize my systems in a way that when i inevitably have to scrap a chunk of it, it won't have a huge impact on everything else (which i understand should be a core advantage of ecs in the first place)
Don't try to make a full game to start out with, and definitely not a networked game. Go through the examples in the pinned messages, particularly the github samples
oh no never a full game lol. whiteboxed and all that.
minimal gameplay
for networking, i feel like if i don't start out with that in mind it will be exponentially harder to shove it in later
The shooting aspect of the shooter would be a great place to start of you're trying to get familiar to ECS workflow. And no hybrid should be required for that part. That's where I would start.
Networking is still in its infancy in DOTS and very complicated. A good way to get discouraged.
imo
The simplest intro I saw is https://www.youtube.com/watch?v=P_-FoJuaYOI
Dive deep into the networked future of Unity using DOTS. Hear how we made the DOTS Sample a networked game, and what we learned on the way.
Speaker:
Tim Johansson - Unity
Learn more about the Data-Oriented Tech Stack (DOTS): https://on.unity.com/2lraugz
ok thanks for the help ๐
Any word on when Unity might do the online GDC talks that Riccitiello mentioned in his blog post?
lols
if I have joints in a dots subscene, they don't work unless I actually add convert to entity with convert and destroy option to the joints parent physics body
since it's in the dots scene as well and I have dots editor package, it claims that convert to entity script doesn't do anything
but if I remove it, it definitely breaks
having the extra script there keeps it functional
since the convert and destroy wiped the gameobject on dots subscene, it means I can't use the entity conversion preview while playing
as there's nothing to examine
subscenes are very mystical creatures ๐
so, no GDC talks from unity?
i was hyped to death from the "how to make an ECS" by mike acton
yeah same
it doesn't look good for epic's or unity's talks now
it's looking like Unity will do some of these along the spring now
super bummed tbh
was expecting them to prepare at least some package for GDC week
Yup I was really looking forward to the dots stuff from GDC. Rip in spaghetti
stupid basic question but how do you increment a variable in a job?
I have this in the Onupdate outside the job
var timeaccumalator = Time.DeltaTime / 20f;
var timedeelta = timeaccumalator;```
and this inside the job
placeonSpline.floatVal += timedeelta;```
but I'm just getting haywire random results
placeonSpline is component?
yeah its a component on entities
was there official word that the talks would be delayed or just speculation?
i think there is something that you are not showing us ๐
probably 
but in general that is a correct way to increment a float var on each entity?
var deltaTime = Time.DeltaTime
Entities.ForEach((ref PlaceonSpline placeonSpline)=>
{
placeonSpline.floatVal += deltaTime ;
})```
this should work
I do need the division part because that slow it done but that's basically what I've done ๐ค
the value needs to stay between 0 and 1 multiply would make it go over
in your case speed = 0.2f
.05 == 1/20
thats why I use math.saturate
after 20 seconds
hmm never used. weird it's called saturate instead of clamp. must be a shader thing
yeah that threw me off, never would have found it if not for someone here, thanks again, whoever that was
anyway I still get the same chaotic random output using multiplication ๐คท
what value is chaotic?
placeonspline
floatVal should increase by 0.05 per second๐ง
Entities.WithAll<TestMoveojbectTag>().ForEach((ref Translation moventy, ref tPlaceonSpline placeonSpline) =>
{
ref var booked = ref baked.BezzyGraphcomp.Value;
var Curvecount = (booked.Bezzypoint.Length - 1) / 3;
float3 Bezpoint1 = new float3();
float3 Bezpoint2 = new float3();
float3 Bezpoint3 = new float3();
float3 Bezpoint4 = new float3();
placeonSpline.floatVal += timedeelta;
Debug.Log("placeonspline" + placeonSpline.floatVal);
int i;
if (placeonSpline.floatVal >= 1f)
{
placeonSpline.floatVal = 1f;
i = booked.Bezzypoint.Length - 4;
}
else
{
placeonSpline.floatVal = math.saturate(placeonSpline.floatVal) * Curvecount;
i = (int)placeonSpline.floatVal;
placeonSpline.floatVal -= i;
i *= 3;
}
Bezpoint1 = booked.Bezzypoint[i];
Bezpoint2 = booked.Bezzypoint[i + 1];
Bezpoint3 = booked.Bezzypoint[i + 2];
Bezpoint4 = booked.Bezzypoint[i + 3];
placeonSpline.floatVal = math.saturate(placeonSpline.floatVal);
float oneminust = 1f - placeonSpline.floatVal;
float u = 1.0f - placeonSpline.floatVal;
var tt = placeonSpline.floatVal * placeonSpline.floatVal;
var uu = u * u;
var uuu = uu * u;
var ttt = tt * placeonSpline.floatVal;
float3 p = uuu * Bezpoint1;
p += 3 * uu * placeonSpline.floatVal * Bezpoint2;
p += 3 * u * tt * Bezpoint3;
p += ttt * Bezpoint4;
moventy.Value = p;
}).WithoutBurst().Run();```
the full job if anyone is curious and has a clue
my guess is placeonSpline.floatVal -= i;
hmm wouldnt the first branch of the if statement always run after the value reaches 1?
yeah thats when its finished, it basically moves an entity along a spline
should you reset the value to 0 in that branch?
not unless I want it to loop and go back to the start
so, floatVal starts from 0 and increases to 1 linearly?
yeah between 0 and 1 are all the values along the spline
yeah I was confused. thought you were resetting an offset every time you reach a point on the spline. got it now I think
then why don't you just lerp it?๐ค
it uses that to calculate the exact position using the other equations, dont ask me exactly how, I have no clue 
yeah, I agree. I think this is a lot of code to lerp a value from 0 to 1.
oh it is a curve, you can't just lerp it to move linearly๐
plus you're manually clamping (the max) once and using saturate in two other places. probably unnecessary
if you can figure out how to do it fewer code be my guest, but yeah its several bezier curve paths
yeah I've seen that thanks
that's the one I've mainly used though
{
float u = 1 - t;
float tt = t * t;
float uu = u * u;
float uuu = uu * u;
float ttt = tt * t;
Vector3 p = uuu * p0;
p += 3 * uu * t * p1;
p += 3 * u * tt * p2;
p += ttt * p3;
return p;
}```
it does work just not on multiple entities
you've tried just feeding a function like that with a linearly interpolated value and it doesn't work when doing multiple entities?
that's weird :\
I know, I don't know if its some bug I'm or I'm just not understanding how to increment component variables in jobs
Is PlaceOnSpline a ISharedComponentData?
nope public struct tPlaceonSpline : IComponentData { public float floatVal; } thats all it is
you are incrementing your floatVal and when it is 1 you want to move to next spline in array
no it basically divides it by all the sum of the splines or something so that 0 and 1 is across any number of arbitrary curves
b2 is out ๐ Soon hybrid renderer v2 shall be mine ๐
@pliant pike you are modifying floatVal, not just incrementing it and i think it is the source of your problem๐ค
@opaque ledge Btw regarding our discussion about passing in a dynamic buffer from another entity to a job for processing, I think it might be better to just use blob assets. At least in my case, since my buffer wouldn't be changing a lot
BlobArrays can also be nested
upgraded my project from 0.6 to 0.8 and now all my tests are going like twice as slow :S grrr. </whine>
Hmm anyone had issues with building out to android with the default gameobject injection world not initialized cause of a marshalling error? ๐ค
using a subscene?
@zenith wyvern yeah, that is not really good for me ๐ i am holding threat(aggro) table in that dynamic array so it will change all the time, as a side question, can you reconstruct a blob asset when you want to change it ? or does it function like a runtime static or something like that
Yeah you can recreate it whenever you want
But you have to manually update the references from the original to the new version
It's nice to just have static data you can store in components. Plus - nested arrays like I said, you can't do that with NativeArrays
FixedList ? ๐
i mean what is the difference between static data (blob asset) and changable data but you wont be changing it
There's no other way to store a reference to static data inside a component
Hello, I am wondering if I new a world, how can this world update with the default world?
Plus trying to store shared data in a dynamic buffer runs into sync point issues as we found out. With a blob asset there's no indirection or performance concerns, it's just a straight reference to your data
unless you have multiple threads hitting it with a write, then you'll get false sharing no?
Yeah but Sark, imo they should have buffer version of GetSingleton anyway, so you have 1 buffer accessed from the job, instead of accessing it on every single entity query
The safety system won't let you write to a buffer from multiple threads - unless you disable it. But there's no way to actually "share" the buffer directly with other jobs without forcing a sync point first. You would have to copy the buffer data out to a NativeContainer then pass that into the read jobs
Maybe your use case is good for static data, but what about mine ๐
I just want to read the buffer
seems like buffers get invalided if someone sneezes in the next room.
yeah tbh, thats the way to go, sure its unncessary copy operation but whatever, definitely will boost perf
so i guess i will be converting from Sark's pattern to that probably
Yeah I suppose there's a good reason they force you to do it that way, buffers get invalidated from any structural changes
not anytime soon tho, i have other things to do ๐
you could pass the ptr to the buffer and hope it wasn't touched ๐
Faith based coding
oops sorry just saw the msg @mint iron - no I'm not using subscenes atm
I'll see if I can grab the actual error message - I was combing through the forums last night to see if anyone else had a similar issue ๐ค
ahh yep, i just ask because, topher's answer is that runtime conversion is not supported anymore
yeah, im going to have to check it out too, ive avoided it becuase it seemed completely unnessesary and slow.
You can't create subscenes at runtime right?
Dont think so - since the goal is that they're serialized to a mem mapped file right?
ahead of time
It would be nice to have some mechanism to do that manually at runtime for loading/unloading procedural parts of the game
wait, so no more GameObjectConversationUtility ?
it seems still to be part of the plan, but you'll have to move things that need to be converted into a subscene.
wait, how am i suppose to convert my prefabs into entities then
or are we talking about when there will be a good/full DOTS editor support ?
You would use the normal prefab entity workflow like from the samples, then you Instantiate the prefab entity
So rather than creating a gameobject and converting it at runtime, you convert the gameobject prefab to an entity prefab during conversion and instantiate the entity prefab at runtime
ah okay, with IDeclaredPrefabReference and IConvertGameObjectToEntity interface then ?
Yeah
ah okay cool
The idea I guess being to literally have zero gameobjects at runtime
hmm I imagine conversion systems would remain the system functionality wise?
My assumption is they will work the same but we'll lose the ability to use them (or any kind of gameobject conversion) at runtime
Seems like that won't be happening any time soon though
oh, a new DOTS editor package
new Entity debuger? ๐
bring in the notes Olento ๐
on it ๐
lol
well... ouch
## [DOTS Editor 0.4.0] - 2020-03-17
[Changed]
* Updated package dependencies```
lol
lol, as Cassia would say, "You're making me nervious!"
they must have changed more tho
From the editor package?
ok, discord is acting up again
anyway, they fixed some of the warnings that came with newer entities using different world setup
Maybe changing the dependencies fixed those warning? ๐ค
pretty sure the issue was in the actual code using the deprecated world getter
If I create an entity at runtime using a commandbuffer, how do I handle attaching it to another entity for parenting/linkeentitygroup/etc? The entity returned from the command buffer is meaningless. Adding a "spawned" component or something similar seems annoying
yeah, in unity's own videos she said "you have to create a workaround" ๐
i probably would make a system state that indicates that specific entity has been created, and i put a entity field and put the parent in it when i create that entity, later on a system links it and removes the system state.
I guess I could spawn it with a "Disabled" component, then query for the disabled component in the linking system, so it gets ignored until I hook it up properly.
Still annoying
yep
hmm wondering if this works on a job ๐ค
var dummy = CmdBuffer.CreateEntity();
CmdBuffer.SetComponentData(entity, new SomeLinkedEntity { Value = dummy });
The entity returned from buffer.CreateEntity is meaningless outside that context
yeah exactly, dummy is 'undefined'
Yeah I figure lol
you have to put parent entity to child's component somehow and do the link 1 frame later
Its like one of those thoughts that came across recently: "I never tried it cause all my spawned entities that need to be linked use either the disabled component or some tag"
Yeah disabled seems like the right way to go, avoids having to add a tag specifically for this purpose too
hmmmm, bunch of things just broke on my dots project
I wonder if it's really about beta 2
because I reverted the dots editor back and it's still broken af
(just updated to 2020.1.0b2)
Are you using packages aside from Entities?
I also added netcode package just a moment ago, I'll try without
Isn't most of DOTS only battle proof with 2019.3?
Other packages aren't even close to staying up to date so they'll often include older packages as dependencies which causes everything to explode because apparently UPM wasn't designed with that in mind
it worked about the same on earlier ๐
but this could be on me too
I tried earlier to get the netcode's client interpolation to work
Client interpolation? What exactly do you mean by that?
Like we can't even use physics with 0.8 because physics is incompatible with the latest collections package which 0.8 relies on
basically trying to figure out FixedClientTickRate thing and the additional thing to interpolate it for rendering
Is that really true? Fairly certain I tested that earlier today
@dull copper Is the ghost interpolation not working for you?
when you run simulationgroup at fixed timesteps, it will be async to rendering
well, atm nothing works like I'd want to, even hybrid rendering broke ๐
I'll revert this soon to earlier state if I can't figure out what broke it
Is that really true? Fairly certain I tested that earlier today
@bright sentinel
Thygrr brought it up in this thread https://forum.unity.com/threads/dots-dependency-hell-was-entities-0-8-0-missing-class-propertyattribute.847255/#post-5602222
It may be a combination of latest hybrid renderer package, latest entities and physics
I can tell few things wrong there immediately
the person is using newer perf testing package which isn't compatible
most dependency hells are user generated by them overriding the dependencies
In his repro case he started on a fresh project
Yes, and it is also a known issue it seems
Or so he said
Which was actually with IL2CPP
And for the package resolving, that's also on the radar
oh, wonder if that's still broken on 2019.3
pretty sure I reported that being broken before
but it got fixed on some later version
Don't think it's completely fixed yet
At the very least UPM should let you know there's a package incompatability, that should have been the case way sooner
oh wait, I didn't report tht one, but I definitely had that before
Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Scenes.Hybrid\LiveLink\LiveLinkPlayerSystemGroup.cs(32,59): error CS0117: 'SceneSystem' does not contain a definition for 'GetBootStrapPath'
Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Scenes.Hybrid\LiveLink\LiveLinkPlayerSystemGroup.cs(53,48): error CS0103: The name 'bootstrapFilePath' does not exist in the current context
On a side note anyone ran into this seems like an issue on Android :/
I've been on mono builds for other reasons now, mainly to reduce the burst spam :p
hmmmm, getting rid of netcode package and clearing library fixed my dots project
can't tell which one it was
Probably the latter ๐
but all the sudden hybrid rendering works again and physics don't go through ground plane ๐
I wouldn't be surprised on either alternative, considering the experiences I've had on this
Also @zenith wyvern there's not much reason to import collections, jobs, burst if you're working with entities. Likewise there's also not a lot of reason to import entities if you're working with hybrid renderer, physics, netcode etc
@stable fog NativeArray's without safety checks I guess
But then you run into race conditions
I can see the case for not being worried about the specific version of things like collections or jobs, but if there's an incompatability between the latest physics, entities and renderer that seems like a bigger issue that's going to be hit by a lot of people new to ECS
I think current entities, physics and hybrid renderer do work together
Well as I said, it was working fine for me earlier today
but there are two newer packages that don't
@stable fog for 2-way sync the only thing I can think of is: split the job into before/after you need output from another job, then insert the dependency inbetween
for 1-way producer/consumer you can use e.g. NativeStream
you shouldn't update perf testing package or the serialization one to newer than mentioned on entities dependencies or it'll either break or throw bunch of warnings
I'm less thinking about whether or not it can be done, more about whether or not it should be done, or avoided
also, platforms package can't be newer than 0.2.1 ๐
so yeah, it's gettting tricky
platforms 0.2.2 will throw bunch of errors
You really should just go with the highest level packages that you need. Physics, Hybrid Renderer, NetCode, Editor basically for now
They should of course work together
But there's not much need to import deeper packages
As they'll get resolved automatically
(In most cases)
and if you do, it'll break
and based on todays experience, I'm not even sure if latest netcode is compatible ๐
Yup, just tried it. If you install entities, renderer, then physics, it breaks.
just update collections๐ค
It's understandable that there would be incompatabilities with all the different versions but UPM should warn you if you're trying to import a package that's going ot break an existing dependency.
You can't. Physics is incompatible with the latest collections.
But that's more a problem with the package manager than it is with the packages themselves ๐
these work for me: json "com.havok.physics": "0.2.0-preview", "com.unity.burst": "1.3.0-preview.7", "com.unity.collections": "0.7.0-preview.2", "com.unity.dots.editor": "0.4.0-preview", "com.unity.entities": "0.8.0-preview.8", "com.unity.physics": "0.3.0-preview.1", "com.unity.platforms": "0.2.1-preview.8", "com.unity.rendering.hybrid": "0.4.0-preview.8",
it works fine on my project๐ค
Yeah, that's my point. UPM is failing hard.
or just Unity
they should release all DOTS packages that have dependencies at once if they plan this to be nice for users
I bet they put more effort to that once these are out of preview though
Yeah, it's good to remember that this is essentially alpha/beta stuff
What the heck, @warped trail you're right. Why wouldn't UPM know to just keep the up to date collections package then instead of forcibly downgrading it and causing errors
i noticed that if you install entities, renderer, then physics it loads collections 0.5.x
just update collections to latest and everything works fine
btw, remember when I wrote earlier that I still need to add extra convert to entity script to DOTS subscene or physics joints will not attach... turned out that while that hack did work in the editor, it completely breaks in the build
moving things out of DOTS subscene makes everything fine and dandy again, even in build
it's just, DOTS editor doesn't do anything without subscenes
That reminds me, how do you handle NetCode stuff with subscenes? Currently they ask you to use a ConvertToClientServerEntity component outside a SubScene, but no references to subscenes in the docs
so, can't win in any case here
I'm not annoyed about the dependencies at all, but I'm super annoyed by the state of editor tooling and this conversion stuff
sometimes i have situations that subscene is loading previously saved data ๐
I think you need to use the explicit versioning thing if you're using subscenes don't you?
To force it to update the cache
im not talking about scripts
so if it works in the editor, it doesn't mean it will work in the build?
it definitely just worked for me in the editor but not in the build ๐
you put one set of objects to subscene, save it(State A). Open it, remove/add some objects, save it(State B) and than you close subscene it loads StateA, open it and it loads State B
I have a question. If a system add in both GroupA and GroupB. What would happened with this system if I create both GroupA and GroupB in current world? Would it log error? If this system already be created in current world, what would happened with this system once I disable GroupA or GroupB? Would this system also be disabled?
I think you gotta test that on your own ๐
But a world cannot have same system more than one so i am pretty sure it would log error about it
Thx๐
damn I'm still out of date
"com.unity.entities": "0.5.1-preview.11",```
feel like I just updated entities the other day
tried moving to 6 and my project blew up
and it will blow up again going to 0.8 ๐
Currently it seems like there are bi-weekly updates
Hey, has anyone used CapsuleGeometry from the Unity.Physics package? What are the Fields
public float3 Vertex0
public float3 Vertex1
doing?
one thing I'm really not liking about the new codegen lambdas is with il2cpp, if you do something not supported, theres no warnings, no info, and il2cpp will just complain about the next random cpp error from the actual malformed input
Hey, has anyone used CapsuleGeometry from the Unity.Physics package? What are the Fields
public float3 Vertex0 public float3 Vertex1doing?
@formal scaffold
https://forum.unity.com/threads/learning-resources.834172/#post-5513137
Thanks, so as I thought the height
Sorry for asking again but any way to make CapsuleGeometry or SphereGeomery visible? I am casting a Sphere- or CapsuleCollider but it's hard to see where it is actually being casted.
I get some wierd collisions that shouldn't happen and I can't pinpoint where my problem is
So i have a question, i have a weapon firing system from a spaceship, this system does 2 things:
- Checks if weapon is available to fire, Checks if there is a line of sight
- If above is true, it creates bullet entity, it calculates projectory, so basically weapon fires
So i wanted to ask how can i seperate these 2 systems, because generally speaking %95 of the time weapon wont be available to fire (be it weapon is on cooldown or target is not in sight) so that means my system will be wasted %95 of the time, i havent encountered any performance issues, not that i tested it extensively but i was wondering what kind of approach people would take, this is my system:
@formal scaffold there is a script called Physics Debug Display, put into somewhere and make sure its being converted to entity
i only used to see collideres, but i think it also draws collisions
means my system will be wasted %95 of the time
can you expand on what you mean by that?
I mean, my ship wont be firing %95 of the time, so 2nd part of the system is wasted
I want to seperate 1st and 2nd part so there wont be any waste
probably
oh, i mean you already have the script ๐
you dont have to download it
If it doesn't fire the bullet after the check what is being wasted?
Are you worried about pulling too many components at once? Because I'm not sure I see any big waste here
@zenith wyvern 2nd part of the system where bullet is created and given components.
@opaque ledge if you really want to separate the check, and only have the 2nd system run when it should actually fire, then you probably have to do some structural changes by adding a tag or something for the 2nd system to query. Another approach is to use a SharedComponent where you have a true and a false state, and you could filter based on that.
You mean you create a bullet even if the check fails?
no i dont, if check fails it wont create the bullet
Right, so if the code isn't running...what's being wasted?
Yeah, which is why I think your system is fine for now. Besides, it's not really a heavy system and something that can save you performance.
@zenith wyvern Job scheduling I guess
If you split it you have to schedule even more jobs
So what i am saying is, i am pulling 1-2 components to check, but 4-5 components to fire, so i am retrieving many components even tho those componenets wont be used %95 of the time
But maybe i am just nickpicking
The components shouldn't be loaded into the cache unless you actually read/write to them if that's what you worry about, the job just has to keep a few more pointers around
Yeah I'm not sure how much overhead you would save by not including a few components in your query
And as the wise words of someone on Discord, don't prematurely optimize ๐
If you wanted to separate them for the sake of readability that's one thing, but you shouldn't worry about the performance cost of that in particular
alright thanks^^ i was just worried about the random access
also remember your target device you want to aim for
i am converting some prefab colliders to shape right now, i can test after that and see how much that system takes
yeah its mobile
Besides, your system is already fetching other entities than the ones being queried, which is probably where you will see the biggest performance hit in terms of memory fetching at least.
well mobile has different processors amongst generations - so definitely you should define your scope -
typically, I test on Samsung S6, Pixel 1, IPhone 6S as my benchmark for lower bound phones
Hmm sadly the Physics Debug Display doesn't draw Colliders made with
Unity.Physics.SphereCollider.Create(...);
Maybe they are simply bugged
profile your damn systems at scale before you even think about making a complex job chained monster when you probably dont need it @opaque ledge
target is for 1000 of x, spawn that many with a benchmark and profile if it would be fast enough on your target machine, with target threads
if your operation only happens every once in awhile, pretty much anyway you do it will be fast enough
Generally I've heard some things about ECS not handling large amounts of systems well, so take that into consideration as well
๐
Do you guys know how to update the system which is manually created?
system.Update() ?
can it auto udpate??
Because I find out that there is no display on Entity Debugger of that system which is manually updating.
look at what the default world initialization code does, I don't remember the exact calls you have to make to insert it into the update loop
there's a filter button on the top of the entity debugger
Where is that talk about SIMD operations and JOBS?
This session addresses how we are expanding the scope of the Burst Compiler to enable even the most demanding, hand-coded engine and gameplay problems to be expressed in HPC# via direct CPU intrinsics. Andreas shares the reasoning and use cases; as well as discussing implement...
this one?
Ok, that system is running 0.07 ms on 1k entities lol
debugging seems to have changed with the latest beta, I have to go into debug mode and I get a ton of errors, when I just want to mark a break point ๐ค
looks like thats the one @coarse turtle thank you
can you even view componentdata on entities in VS studio code view?
@opaque ledge good job testing
Just spent 6 hours debugging only to find out it was the minor unity update from 2019.3.3f1 to .5f1 that caused il2cpp to start throwing the gibberish
Beta was giving me a weird error, when i opened debug mode that error would be gone and that system was working properly, but when i was off debug mode it came again, so i decided to downgrade to 2019.3 for now
also there is a burst debugging video if you havent watch already
tbh June, i thougth it would be like 1 ms D:
no idea why its 0.07
Job time can only be viewed in profiler
Timeline view
Click on the job after expanding job threads
It will tell the total time as well as the slice time you clicked on
oh, it was 0.07 on entity debugger, i will check profiler tomorrow
Ping me if you need some pictures on where to go and click
I'm heading to sleep now that the madness is over
is quaternion implemented differently than Quaternion?
I've been trying to implement a static extension method 'Angle' for quaternion to match the way Quaternion.Angle is implemented in UnityEngine, but I'm getting nonsense results
Debug.Log(string.Format("Mathmatics: {0}",QuaternionX.Angle(quaternion.Euler(float3.zero), quaternion.Euler(0f, 90f, 0f)))); //returns 116.6202
Debug.Log(string.Format("UnityEngine: {0}",Quaternion.Angle(Quaternion.Euler(Vector3.zero), Quaternion.Euler(0f, 90f, 0f)))); //returns 90
here's my extension:
using Unity.Mathematics;
public struct QuaternionX
{
public static float Angle(quaternion a, quaternion b)
{
float num = QuaternionX.Dot(a, b);
return QuaternionX.IsEqualUsingDot(num) ? 0.0f : (float)((double)math.acos(math.min(math.abs(num), 1f)) * 2.0 * 57.2957801818848);
}
public static float Dot(quaternion a, quaternion b)
{
return (float)((double)a.value.x * (double)b.value.x + (double)a.value.y * (double)b.value.y + (double)a.value.z * (double)b.value.z + (double)a.value.w * (double)b.value.w);
}
private static bool IsEqualUsingDot(float dot)
{
return (double)dot > 0.999998986721039;
}
}```
Why not use the methods in math.
math has an angle function?!๐ซ
Everything is built around static functions you pass onto, instead of treating the struct like a object
It's meant to mimic gpu shaders math
math does not have an angle function...
and wow is that documentation page horrible. so long it freezes every 2 seconds
Debug.Log(string.Format("Mathmatics: {0}",quaternion.EulerZXY(0f,0f,90f))); //Mathmatics: quaternion(0f, 0f, 0.8509035f, 0.525322f)
Debug.Log(string.Format("UnityEngine: {0}",Quaternion.Euler(0f,0f,90f))); //UnityEngine: (0.0, 0.0, 0.7, 0.7)
so that's neat
Why did you use ZXY instead of XYZ, like Quaternion.Euler takes?
Documentation states that Quaternion.Euler rotates in ZXY order
Quaternion.Euler takes the parameters in that order, but does not apply them that way
likewise, quaternion.EulerZXY just applies them in that order. not the order of parameters. both euler angles are 90 degrees rotations on the z axis.
โ ๏ธ
math.acos(math.min(math.abs(num), 1f)) * 2.0 * 57.2957801818848
are you sure about this math?
Debug.Log(string.Format("Mathmatics: {0}",quaternion.EulerZXY(0f,0f,math.radians(90f)))); //Mathmatics: quaternion(0f, 0f, 0.7071068f, 0.7071068f)
Debug.Log(string.Format("UnityEngine: {0}",Quaternion.Euler(0f,0f,90f))); //UnityEngine: (0.0, 0.0, 0.7, 0.7)
I'll take it. Thanks @indigo delta
Nice. Closer to the real value, on the first one
It should be sqrt(2)/2, or 1.414/2, or 0.707
@worldly pulsar Am I sure? No. But Unity seems to be ๐
Debug.Log($"UnityEngine: {Quaternion.Euler(0f, 0f, 90f).ToString("F7")}"); //UnityEngine: (0.0000000, 0.0000000, 0.7071068, 0.7071068)```
well look at that ๐
Ah, fun. Good to know there's not a significant digit loss that large in the stock math ;P
can't even complain about the documentation on that one. plainly says its in radians ๐คฆโโ๏ธ
Hmm I dont suppose there is a way to add materials to an entity within a subscene is there? ๐ค
aside from render mesh?
why isnt use burst jobs an option under jobs?
You set the BurstCompile attribute on the job struct instead
ah alright, thought burst somehow wasnt enabled this whole time
just had a look at what unity does with FixedRateUtils, which is used for making a systemgroup use fixed time step
they use World.PushTime and PopTime to set the deltatime used in the group
but they don't PopTime until the second time the group runs, so isn't this bugged? every group that updates after that will use the same elapsed+deltatime as that fixed time group
and there is no guarantee it even pops the correct time if a different system after that pushes theirs 
unless i am missing something
i guess there is bug in FixedRateUtils or i'm using it in the wrong way ๐
@warped trail
is this the same bug you encountered? (just searched fixedrateutils in this channel)
ahhh wait nvm
it just calls it twice in a row and pops the second time
damn i thought not being able to do time management was the only downside of using a systemgroup's updatecallback but seems that isn't the case
LinkedEntityGroup is supposed to make it so if you destroy the root, it destroys all the linked Entities. Is that right?
yes
@hollow sorrel I was setting this function callback in custom world bootstrap and it just stuck in infinite loop๐
var elapsedTime = group.World.Time.ElapsedTime; // elapsedTime = 0
if (m_LastFixedUpdateTime == 0.0) //true
m_LastFixedUpdateTime = elapsedTime - m_FixedTimeStep; // 0 - 0.02 = -0.02
if (elapsedTime - m_LastFixedUpdateTime >= m_FixedTimeStep)//0--0.02 >= 0.02
{
m_LastFixedUpdateTime += m_FixedTimeStep;// -0.02 + 0.02 = 0
m_FixedUpdateCount++;
}
else
{
m_DidPushTime = false;
return false;
}
return true;
how can this stuck in infinite loop, there is no loop in there
this part decides if you will update group one more time or not
and this is how systemgroup updates systemscs while (UpdateCallback(this)) { UpdateAllSystems(); }
hmm ok, you could debug.log to see where it goes infinite
is UpdateCallback that check function ?
but you are getting elapsed time on every check, i think you should minus m_FixedTimeStep from it if returns true, so lets say if elapsed time is 0.03, fixed time is 0.02, it will always return true because both will stay the same, right ?
ah actually nvm, you are updating last fixed update time
well, gl ๐
i am kinda glad i dont need to deal with any physics stuff, BARGOS is in a very wild ride because of it ๐
and elapsed time is not changing during your world update๐
Has anyone tried FixedRateUtils?
@warped trail yeah I was fiddling with it yesterday, it's where things started to break in all directions after I added netcode package (as only it has the interpolation code for client)
that last snippet worked for fixed timestepping
that being said, those netcode docs state you could just add that component to singleton entity and it should work(?)
@dull copper Actually now that I remember, NetCode has their own fixrate stuff
oh right
so it's not even same thing?
that snippet on the forums didn't even require netcode package
well, this explains why it broke when I mixed these two concepts ๐
I somehow assumed they both used same fixed timestepping code under the hood ๐
so, that's a good point@bright sentinel
Yeah, it would be nice to have some universal solution, but generally it feels like they are struggling with fixed timestep
I mean, Physics doesn't even have it yet ๐
i don't think that fixed time step functionality is Physics' problem๐ค
Well physics is the one in most need of it
netcode benefits from it as well, in fact it's mandatory there if they want deterministic netcode
you can't have determnism on any simulation if each client simulates things at different timesteps
(regardless if the simulation is physics based or not)
im just saying that the job of the physics is to simulate(float timestep)๐
Considering how new the fixed rate stuff is I'll bet it takes a bit to ripple out to physics / netcode
can't wait to test this ๐
niiiiice
soon ๐ b2 was released yesterday i think
this is the sort of thing that has a good chance of having insane perfs
by caching render commands on a perchunk-archetype basis, you can do tons of fun things
yeah delta memory upload is a super smart choice
unreal does it, but its individual per-object
thats awesome to hear
I like the sound of it all going from job threads directly to render thread to upload
thats actually similar to some of the things i do in my ecs experiments
in my ecs simulation, i dont have delta tracking, but not like it matters, as my entities are all moving
yeah makes sense
but when rendering, i grab a chunk, and memcopy it straight into gpu, and then render-instanced
how was the performance?
well, memcpy the matrices
yeah yeah, same thing
๐ฉ
render system not being the bottleneck
i actually havent tried to stress the rendering only
but my rendering is very simple. i only have instanced colored cubes
4x4 + color
1 byte per component on the color or 4
4
alpha?
uhm, would need to check
yes, even if dont use it. gotta pad to 4 after all
on the cpu side, this is faaaaaast, takes like 2 miliseconds to do the rendering on those 400k
80 bytes for 4x4+color
could be an stimate, yes
i pack them 500 at a time, to avoid having too many directx calls
Btw June i checked the profile, same with Entity Debugger, i checked with 2k entities, its 0.09 ms
im basically memcopying straight to buffers on uploads of 500 renderables at a time
yeah thats great
the 500 is because its what i calculated as the maximum size of uniform array
that makes sense
I just like to get an idea of how close to theoretical max we can get
v. 6.x (64 GT/s):
7.88 GB/s (x1)
128 GB/s (x16)
gonna make a build witthout profiler and send it, so you can run the thingy
specially now i did some experiments to tryhard even further
sure 
make sure you put the stats up somewhere, at least DT
gonna attempt to update to entities 7 or 8 today
did people have problems with 8?
better scroll up
@opaque ledge
if you click on the jobs down in the timeline, it tells you the total, which is sliced up by multiple instance (I have a quad core so 4)
roughly speaking, its not exactly always that
someone said 8 has problems with physics 0.3
thats what it was, thank you
have fun
let me know how it runs on your machine. When the max number of boids is reached, mine (ryzen) is at 20 ms
no problem with physics
this is a tech demo ive been using to develop my c++ ecs
its similar to the way unity ecs works
so i use it as a experiment to see what kind of things work on it, or not
@low tangle bit slower than mine
I could bump the oc back up to 5 but I dont usually run that for heat
which is 16 threads
you have similar numbers to me @hollow sorrel
am on i7 8700k
6/12
i use this (and others) to mostly see what works or doesnt with the ecs model unity has. Also how would stuff like job system work with it. im using a cpp task library + parallel stl
one thing i found, is that using "manual" chunk jobs to "merge" multiple systems into one can give good speed boosts
but mostly only when you start having to deal with huge counts of units
3900x
daymn
finally i found it ๐ it says 0.116ms, 8 instances
i probably should start to name my jobs, its all DisplayClass in here ๐
is that with a build attached to editor @opaque ledge ?
.WithName or something like that
0.116 ms for 2k ๐
thats quite nice
if its burst compiled with safety off it should be fine performance wise vrs built
there is one thing that worries me on unity ecs. Whats the overhead of having lots and lots of systems?
i am not sure what that means Timboc, i am testing on editor, not build if thats what you are asking
not much
on this sort of ecs, there is allways a small cost to scheduling jobs and preparing the list of archetypes to run
about ~5% difference I find depending on what you're doing (build vs editor all safety off)
I think with the 260 I have its like a baseline of .3ms / frame
which is pretty much nothing
maximum ive seen is one crazy guy on the Entitas github
he talked about having 3000 systems
god damn
for a mobile game
I bet he has hellish archetypes
but, those systems were almost all reactive systems, so they do nothing until stuff starts changing
he also commented 1500 components
they have fat components though
@opaque ledge if you do a build, you can enable Autoconnect Profiler - allows for profiling the build directly (there are some safety checks you can't disable in editor) - not a huge difference but generally good practice of profiling imo
so like the whole physics world is one etc
i know a spanish team who built a overwatch-style ecs for their engine and multiplayer mobiel game (call of duty type thing), and they had 50 systems and 30 components
looks like 350 components counting unity ones
ah i see, i probably will start doing that when project is at the end
this simulation i shared is 10 systems
not bad
my little ecs test with flecs and raylib was at like 8
but I was just trying to explore ergonomics more than performance
writing the code fast and easier trumps performance most of the time
i thought ecs would have you write more systems than you would monobehaviours but those numbers sound pretty low
well only because I keep ignoring how I would write it before
try to write it with the most minimal amount of logic and data to get the same result as before
how many components do your systems touch on average?
@hollow sorrel its a good idea to now have that many systems. In general you want systems to be small, but not too small
plz dont be like the github guy on 3000 systems
hahah
offhand I'm not sure
I'd estimate around 3 primary components, and 0-3 tags
most of those tags are just to get around how shit world management is
sounds about right
ServerOnly and ClientOnly
4690K I need to upgrade lol
intel stuck with quad cores for way too damn long
I know. def going ryzen if I upgrade soon.
I'm still bit bummed I didn't get the 16 core one
was going to but they kept postponing it and even 3900x stock was hard to find so just got one when local store had it on stock
we got the 32 (I think?) core threadripper for a render machine at work. It's insane.
3970x is probably the most useful TR out there
at least now cpu progress seems to be picking up again so if you wait shit will only get better
i feel like before ryzen the ~7 years before that haven't been worth upgrading
i had a friend run this thingy on a 32 core threadripper
i used a 2700k for like 7 years
@vagrant surge did you upgrade yours already?
memory on cpu when
is there a way to force a job to take more than 1 frame ? i am about to make a sphere collidercast on 1-2k entities and i am sure it will take some ms, so i was thinking if i could make it to work in 2 or more frames ?
you could split the task so it would alternate the frames
if you really need to, the system needs to hold onto a job handle and check complete
you would need to ship it into a "outside of main ecs" job
yeah, alternating is where its at
but you run into issues with sync points
at the moment on my experiment im simulating everything, but i did experfiments with only updating half the boids every frame
oh hmm, sounds like unncessary work
good ol index % 2
first try the naive case
well, if it can take more than one frame, it has to do the splitting internally anyway
(if such was supported out of the box)
yeah you could do a job chunk and alternate your updates
I'd love to have it supported out of the box too
@opaque ledge as your case is more like many entities doing the check, just split it, do half the entities every frame, or similar
use modulus operator for it
yeah well i was depening on Unity to do the splitting ๐
and manual chunk iteration
or skip chunks
i found that full chunks being split is not so good
yeah i was thinking about that vb, just do a modulo on entityInQueryIndex ?
unless you have a clear delimitation, like for example if i used it on red vs blue boids in my thing
yup
on the next frame, you do +1 to the index, so the modulo rolls
the branch predictor predicts the 50/50 split no issue
i did it on my simulation and it was basically a x2 speedup
and i am sure it will take some ms,
@opaque ledge you do need to measure first
you could also queue e.g. 200 entities to operate on per frame or something instead? Unless I'm missing something
pretty sure you can't do this for physics queries but if you have your own processing that doesn't need to finish on same frame, I think you could just offload it now to separate thread and run it with burst using function pointer thing
or does that require to be run from main? (I don't see reason for it to)
games can lag under heavy (for your game type) load of units, or props or players etc
Yeah sure June ๐ you are right
btw, there is a issue with the whole modulos on index thing
not everything has to be perfect performance
will test soon
when you move entities from place to place, its possible that a few entities dont update
I also feel that the brute force splitting is only way you can guarantee determinism if you need it
so you should only use the index modulo thing if your entities are static in their chunks
like, have to be able to do it the same way regardless the machine capability
altho one could force the determinism on that by various actions
how about using an ISCD to separate e.g. 2k entities into 4 chunks and work on one chunk per frame?
those entities has tag components to drive AI so they wont stay in the same chunk all the time
conceptually I mean - obviously those chunks could further fragment as they would usually - but your job filters on e.g. ISCD value = 1, then next frame ISCD value = 2
ah ofc^^
unless @vagrant surge or @dull copper think it's a bad idea for some reason? They're smarter than me ๐
@amber flicker fragmentation
that works if you can do something like my simulation, where you have very clearly defined "faction" boundaries anyway
but adding a new ISCD will fragment your chunks, and fragmentation is the #1 thing to worry on a archetype ecs
sure.. but as a trade-off... if we're talking an additional fragmentation e.g. every 500 or 1000 entities we're reaching how many would probably fit in a chunk anyway?
i still advise to avoid ISCD on nearly all cases unless you are really, really sure you want it
@amber flicker fragmentation accumulates real easy
other alternative is to track manually? NativeQueue or similar?
if you are completely sure that those entities are in the same archetype (they might not be!!) then its ok to use ISCD
@amber flicker add a component to add a unique index
or hell
use entity ID
and modulus operator
entity Id is a integer after all
mine was done with internal chunk index because i wanted a more predictable branch prediction, but you can use entity index too
@amber flicker I have literally no idea ๐
is there a difference between "ref DynamicBuffer<>" and "DynamicBuffer<>" in ForEach lambda ?
without ref or in you are passing components by value(from documentation)
yeah but i still can add to DynamicBuffer if i dont do ref
for (int i = 0; i < count; i++) // with ref
{
DynamicBuffer<TestBuffer> buffer = runtimes.runtime_buffer.For(i);
OriginalLambdaBody(ref buffer);
}
for (int i = 0; i < count; i++) // no ref
{
OriginalLambdaBody(runtimes.runtime_buffer.For(i));
}``` this is the difference
there is DOTS Compiler, you can look what code was generated by your lamda foreach
oh man
those color choices in the dots compiler window
i guess it was only made for dark theme
at least it is black text in 20.0b2, it was white and yellow at first๐
ah yea i'm still on 2019.3
is the intrinsics stuff available yet?
hmmmm, hybrid rendering v2 seems to work better on beta 2 already
at least it doesn't miss meshes anymore like it did on beta 1
miss meshes? ๐ฎ
if you tried new hybrid renderer on b1, it like rendered only 50% of the meshes/materials
but it was stated already by people building it that it will not render correctly before b3
DX12 didn't render anything on hybrid v2
now it works as well on beta 2
so some changed definitely made it to beta 2 already
it's possible this still misses some but it feels functional now already. I also briefly tested DXR but that's not working with this (but that was also expected to be missing as it didn't work on hybrid rendering v1 either)
So, now that we can't use IJobForEach I was wondering how am I supposed to pass ComponentDataFromEntity to the Update function?
Used to do it like this:
struct Job: IJobForEach<Type>
{
[ReadOnly] public ComponentDataFromEntity<Type> typeReference;
void Execute()...
}
protected override JobHandle OnUpdate(JobHandle inputDependencies)
{
var job = new Job()
{
typeReference= GetComponentDataFromEntity<Type>(true),
};
return job.Schedule(this, inputDependencies);
}
But now that we do the Entities.ForEach inside update I'm having trouble passing ComponentDataFromEntity
if you inherit from SystemBase you can use GetComponent/HasComponent/SetComponent functions directly inside your ForEach
if you still want to continue using GetComponenetDataFromEntity or Buffer version you can still do it, you simply do it in OnUpdate method and you will be able to catch them inside your lambda. However there are things to note, if you are only reading it you have to do .WithReadOnly(local_variable_name)
https://forum.unity.com/threads/entities-0-8-compile-error-in-android-platform.846583/
Found the temporary fix to my issue with Entities 0.8 if anyone needs it
Thank you, @opaque ledge . I'll try that
@dull copper do you happen to have a vr headset to test if it renders in that?
v1 does so I assume it will in v2
I can test but there is no official openvr plugin for new xr managent yet and they nuked the old plugin from 2020.1
so i tried to move a converted game object into a subscene, and my expectation was that it would be pre-converted and stored somewhere in that state. And so when i hit play that data would show up in my Default game world. But what im seeing looks like its created another World for the subscene and it remains isolated from my Defualt world. My default world systems are not able to find the entities that are in the SubScene. what am i missing here?
There is wip branch for 2020.1 compatible openvr tho
oh yeah totally forgot the plugin update
is there not one directly from the steamvr package now?
I have no idea if the steamvr has even worked on hdrp
I mean that asset store package now
I'm not really a vr dev but I do check these official systems occasionally
yeah no worries
I'll check into it soon as I need to see how close we are getting to being able to update my game to it
full ecs rendering is badly what I need to get going
@mint iron maybe prefab component is a culprit?๐ค
also pretty sure this won't work with new virtual texturing ๐
but I haven't really checked it yet
VT didn't play nicely with raytracing either
this is kinda big downside for all experimental stuff getting developed separately
there's no integration between these until they get fully released first
it kinda defeats the whole point
@mint iron I had a similar issue last night too ๐ฆ
I totally understand that experimental stuff gets developed in isolation
but it gets more painful when things stay in preview for years
@low tangle just tested VR mode, seems to work at first glance
I don't have full VR setup on this project, but it does render the both eyes on my dots project
awesome, thank you
a cube or any model being rendered doesn't look offset in the eyes right
there are ways of doing VT on rays, but its quite complicated
essentially you need to count how many rays are accessing a texture
tho
sampler feedback should make it a bit simpler
thats actually something I was working on in my path tracer
I was working on it one day when I watched a rage documentary
ok figured it out, turns out in a SubScene you can't just use the dstManager to create entities, they do show up in the SubScene world, but they're not tracked properly so they don't get injected into the DefaultWorld when the SubScene is loaded.....
did yall see the updates with xbox series x and ps5?
having an SSD that is so stupidly fast is going to be amazing with the ecs model unity uses
you will be able to load and unload chunks/subscenes crazy fast
@low tangle not sure what you mean by that but it's definitely rendering in stereo (different image per eye)
Uhm, it seems CopyTransformFromGameObject sets LocalToWorld only -> Translation is not updated and therefore the physics collider stays at the old place. It seems i need to replace CopyTransformFromGameObject with my own code, or is there something i missed?
oh cool - didn't know GameObjectConversionSystem had a method CreateAdditionalEntity ๐ thanks @digital scarab
that did the trick, thanks!
@low tangle its taking 220 ms on 400 entities ๐ฆ
I have a tilemap and each tile is an entity. I often need to check neighboring tiles
Will I have a possibility so arrange the Archetype chunks lateron s.t. tiles that are nearby in the gameworld are also in the same chunk?
is it good practice to maybe lateron sort the entities which some kind of sharedcomponent that gives them their approximate location, s.t. tiles in the same area of the map will also be in the same chunk?
I don't think you can modify or rely on the order of Entities. But there's a method EntityManager.LockChunkOrder()
but how are you supposed to do stuff like I described above then?
@silver dragon Def gonna need to make your own equivalent, I do it for translation and rotation for physics objects
I do stuff like water flow simulation for example (where I check the neighbors to see where water comes from)
One approach is to have an array loaded as a DynamicBuffer, then you can grab it, access it via normal 2D/3D indexing.
or you could keep it as an Entity per element, and maybe use a map for coords => Entity.
I have a array with 2d indexing for coords => entity
the only thing I am thinking about is memory locality
if entities that are nearby on map are also nearby in memory, then it won't be a problem, but if they are scattered everywhere, I will have a problem
because the lookup of the neighbors will always jump around in memory
If you want that then you shouldn't do one entity per tile since you can't control the order of entities in a chunk.
I'm doing a voxel thing right now, I use dynamic buffers of different types to represent sets of block data
@zenith wyvern so you have an entity for a chunk in the voxelworld?
Yup
with multiple dynamic buffers for the different data
An entity for the region, the region has a buffer of chunk entities. The chunk entities themselves have the buffers of block data
ok but then you always have exceptions on the border of the chunk where you need to check the neighboring chunk right?
So I have different levels of abstraction for whatever operation I need
ok but then you always have exceptions on the border of the chunk where you need to check the neighboring chunk right?
@junior fjord
Yes. You need mechanism to cross borders
if you need to check a neighboring voxel, to you always have something like if(voxelX == chunkWidth){ somehow find out where the neighbor is }?
But you get a nice ordered array of data within a single buffer
@junior fjord you can use nativemultyhashmap๐