#archived-dots
1 messages ยท Page 184 of 1
ok, i try to set the stuff within the job to Allocator.TempJob again
If I want to use dots just for access to Havok Physics. What is the minimum amount of dots integration I need to do. i.e. do I need to use the Hybrid Renderer? Or can I use monobehaviour for everything per normal? What about multiplayer (plan to use MLAPI).
@valid haven I believe Havok is almost exlusive for ECS, (don't @ me on that) although i myself haven't played around with it coz I don't need it.
But what I can say about mixing mono + ecs is just dont.
They can't interact with each other.
Think of ECS Unity as another game engine in the same interface as MonoUnity.
it stores all the vertices that where already calculated before in x, y and z-directions - to get fast shared vertices with marching cubes
I thought one of the promises of DOTs/ECS was that you could pick and choose where you wanted to use it?
oh! Allocator.Temp seems to work
you can communicate between them.. it's just slow and ugly
I hope it can last long enough (with Temp)!
I thought one of the promises of DOTs/ECS was that you could pick and choose where you wanted to use it?
@valid haven I never heard of that.
but if you're talking about the Job System + it's accompanying burst compiler, yes you can use that in mono
But partly ECS + partly Mono is a huge no, in my exp
that may have been my misunderstanding. So if I use one of the new physics systems and/or the entities package I am all in.
ok, will try to set everything inside to Allocator.Temp and then no Dispose in the end?
basically. you have to be all in, whn using the new physics system/s
you could use hybrid objects but i don't see what the point would be
you'd likely lose any performance benefits
It's also a pain in the ass to maintain too
yeah
well there are certain features on the asset store that I am interested in, like the Easy Build System.
Also I had thought some funcitonality is still only to be had with monobehaviors, i.e. looking at rendering for example I note quite a few HDRP features are not yet in for DOTs hybrid render.
depends entirely on the asset.. but you usually build things with monobehaviours anyway
so that one would likely work fine
(you create authoring components that convert gameobjects into entities, because there's no real editor for setting up ECS entities directly)
ya that much I understood. Having not played with it much I am just uncertain how much pain I am in for so was hoping to dip the toe in first ๐
if it's just to do an expensive job in an existing game, you can still use a burst job
it runs now in editor too, but still an error (although drawing the mesh): InvalidOperationException: The native container may not be deallocated on a job. Use [DeallocateOnJobCompletionAttribute] to deallocate a native container safely on job completion.
I don't see, where I can add this anymore (see code above)
the more this kind of conversation of "can I mix ECS with Mono" the more I want Unity to just make an entirely new engine in a new exe file in a new GUI
@steady blaze only dispose the collections that you're creating within the job inside the job
i need vertices, triangles and uvs after the job
you have points.Dispose(); in your job
(except the ones you create inside the job)
so dispose at the end of execute, the vList, yBuffer and zBuffer?
well I guess my first step will be to see how hard it is to convert this Unity Ability System PrototypeProject into DOTs
Welcome to the Prototype Series - a group of videos that focuses on the creation of playable prototypes, showcasing how multiple features of Unity can be used to achieve game mechanics that can be used in real-world scenarios!
Is there some game mechanic that you would like u...
any idea how difficult this will be?
no, that just creates more errors
considering there's no animator or particles.. about 12/10
@steady blaze dispose them outside
leck - was that 12/10 to me? lol that seems a bit hard ๐
it would have to be hybrid really
unless you want to make your own particle/animation system
I thought we just said hybrid is a no-go?
it's a mess, yeah
and if you cannot do animations or particles in an ECS project then it seems ECS would be pretty worthless for creating a game at the moment...
so basically.. i wouldn't even try to make a game like that in dots
particles aren't too bad.. you can just spawn it and forget it
well that is a bummer. There is a havok feature I really want to exploit.
but if you need a gameobject (or multiple) to update every enemy.. you're unlikely to get much benefit from it
ok, from outside the job, assigning new nativecontainers it seems it has to be TempJob at least
I dont really care about that. I want to be able to leverege havok's double percision physics for a larger world without the nonsense.
i think there's a lot of capsules in dots games atm
the problem is, it does not tell me, which nativecontainer causes: InvalidOperationException: The native container may not be deallocated on a job. Use [DeallocateOnJobCompletionAttribute] to deallocate a native container safely on job completion.
ah, I have an idea
@valid haven well i guess you could try.. just install entities and havok, and add 'converttoentity' components to your stuff
but then you won't be able to do like Physics.Raycast, you'll have to interact with the ECS phyiscs stuff
hmmm ill play with it and see I guess.
hm, no made everything only worth
code is now like this, the method to create, schedule and complete job ```
NativeList<Vector3> jVertices = new NativeList<Vector3>(Allocator.Persistent);
NativeList<int> jTriangles = new NativeList<int>(Allocator.Persistent);
NativeList<Vector2> jUVs = new NativeList<Vector2>(Allocator.Persistent);
var terraGen = new TerrainGenerationJob()
{
areaSize = areaSize,
isoLevel = isoLevel,
voxelWeight = new NativeArray<float>(voxelWeight, Allocator.TempJob),
points = points.ToNativeArray(Allocator.TempJob),
vertices = jVertices,
triangles = jTriangles,
uvs = jUVs
};
var jobHandle = terraGen.Schedule();
jobHandle.Complete();
mesh.vertices = jVertices.ToArray();
mesh.uv = jUVs.ToArray();
mesh.triangles = jTriangles.ToArray();
mesh.RecalculateNormals();
meshFilter.mesh = mesh;
meshCollider.sharedMesh = mesh;
jVertices.Clear();
jTriangles.Clear();
jUVs.Clear();
jVertices.Dispose();
jTriangles.Dispose();
jUVs.Dispose();```
Job itself: ```
public struct TerrainGenerationJob : IJob
{
// Input
public int3 areaSize;
public float isoLevel;
[DeallocateOnJobCompletion]
public NativeArray<float> voxelWeight;
[DeallocateOnJobCompletion]
public NativeArray<Vector3> points;
// Output
public NativeList<Vector3> vertices;
public NativeList<int> triangles;
public NativeList<Vector2> uvs;
public Vector3 interpolateVerts(int p1, int p2, float value0, float value1)
{
float mu = 0.5f;
mu = (isoLevel - value0) / (value1 - value0);
return Vector3.Lerp(points[p1], points[p2], mu);
}
public void Execute ()
{
int areaSizeXY = areaSize.x * areaSize.y;
Vector3 newVert;
NativeArray<int> vlist = new NativeArray<int>(12, Allocator.Temp);
Utils.VertexBuffer lastXBuffer = new Utils.VertexBuffer(-1);
NativeList<Utils.VertexBuffer> yBuffer = new NativeList<Utils.VertexBuffer>(Allocator.Temp);
NativeList<Utils.VertexBuffer> zBuffer = new NativeList<Utils.VertexBuffer>(Allocator.Temp);
// 271 lines of calculations
vlist.Dispose();
yBuffer.Dispose();
zBuffer.Dispose();
voxelWeight.Dispose();
points.Dispose();
}
}```
(moved the VertexBuffer back to Utils, as that does not change anything)
You're posting way too much stuff with no context. Simplify your problem.
If you can't figure it out from all that then create a smaller example
it now runs, draws the geometry, but still throws this error: InvalidOperationException: The native container may not be deallocated on a job.
Use [DeallocateOnJobCompletionAttribute] to deallocate a native container safely on job completion.
but there is nothing left for [DeallocateOnJobCompletion]
smaller examples work, but not the real interesting code - i mean, it works now, but not 100%
Also I don't think you should be disposing containers in a job
better outside then? all of them? somewhere i read, Allocator.Temp does not need a dispose? is this nonsense?
Containers allocated with Temp will auto dispose, you don't need to call dispose on them
ok thank you, then i can remove those
Maybe you know what the [DeallocateOnJobCompletion] exactly does?
In Unity go to Jobs->Leak Detection->Full Stack Traces
It should give you a better idea what isn't being disposed
It does what it says, it disposes the container when the job finishes
ok, so i could remove that too, i guess
I don't really use it anymore since the behaviour is inconsistent with different containers. Calling container.Dispose(jobHandle) does the same thing but works with any container
ahh, that fixed it! great!
aha ok, so you dispose with jobHandle? the thing is: I want to change how the job is generated, scheduled and finished
first, it should generate, fill in and schedule in Update (when needed), then in every lateUpdate check if jobHandle.isCompleted and only then access the data and assign the mesh, so it does not wait for it.
@zenith wyvern Thank you very much!
Maybe can you tell me one or two another things about the Jobs?
With container.Dispose(jobHandle) what does it different than i.e. myJob.NativeContainer.Dispose() ?
and second: When calling:
if (jobHandle.isCompleted) is it guaranteed that the jobHandle is not null?
A JobHandle is a struct
When you pass in the job handle to dispose it will dispose the container automatically once the job finishes
The docs do a decent job of explaining how the native containers work
ah ok, so it is similar to: [DeallocateOnJobCompletion] ? so like some kind of autodispose, but defined outside. but not really sure how to use it, hopefully i will find out. ๐
and it seems i need to set a bool (i.e. jobStarted) because (jobHandle.isCompleted) is true every frame, after the job has finished.
or can it be set to null maybe?
It's a struct, so no, it can't be set to null. I use a bool when I'm doing something like what you're doing
You could also use a nullable JobHandle ? handle if you really want
Hmmm. They updated ecs sample repo yesterday to entities 0.14
Gotta wonder this logic
Previous time they even pushed update only for older entities than one had been out for a while
Wonder whats going there, in past they just updated samples to current dots packages right after drop
What would they have even added new to the samples for .14. I feel like it doesn't really have much new that could be shown in samples
Didnt watch the commit content but even if there were some minor changes, it would be nice to just know that these are verifed against latest packages
I guess the example maintenance priority just dropped once Unity hid the dots packages
Would make sense anyway
That's a good thing I guess, more time to work on dots
if i just want to pass a float to read in a static function in a job, is it preferred to use in or ref or neither? (or it doesn't matter?)
if it tried to inline it, ref would be faster i imagine (because no copy would be needed)?
does anyone use entities and Sprite Renderer? when I try to use it, I get an error and it doesn't work
if i just want to pass a float to read in a static function in a job, is it preferred to use
inorrefor neither? (or it doesn't matter?)
@wet epoch for just to read I believeinis the best way to go.refmarks it as changed.inis for readonly
k i'll use in.. makes more sense anyway, thanks
i dont think Sprite Renderer is supported, you have to go with hybrid component
can someone read this for me?
the nativearray doesn't seem to want to transfer to the job.
https://pastebin.com/ZQLXycQu
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
that's the job
you getting an error?
https://pastebin.com/XEYq6hZv
that's the code where it is run
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
the error comes when i try to use the randomArray to generate a number
on lines 43 and 60
all the way up until the job is scheduled the array has the content
and after that i can't use breakpoints cause of jobs
what error?
Index out of range, or the native equivalent of it
i'll grab it now
IndexOutOfRangeException: Index 0 is out of range of '0' Length.
oh, thats interesting
its happening on line 44 now
hmm
genders[gender] out of range?
i'm not sure.. if you turn off burst i guess it should at least?
if not, .Run instead of schedule might let you
you could just check species before starting the job too
not sure if you can assert in jobs?
yep turning jobs off worked
i am an idiot ๐
i forgot to add a for loop elsewhere
thanks for the help lecks ๐
does anyone use entities and Sprite Renderer? when I try to use it, I get an error and it doesn't work
@odd ridge There's no conversion from mono sprite renderer to ecs sprite render. (unless yu're going project tiny, which I don't know)
You have to go hybrid on this one
np
@deft stump what do you mean by I have to go hybrid? I also have the hybrid renderer package
@odd ridge if something isn't supported by dots, you can make "hybrid" approach where you use ECS for things that are supported and use the old monobehaviour rendering for parts that are not supported
or whatever functionality you need from the "old" unity
meaning in this case, you'd have to sync the entities to gameobjects to move the gameobject based sprites
thanks
how do I change the framerate of a system? say if I want my system to run at exactly 60fps
@odd ridge I don't think you can artificially reduce the speed of a system
Unless there's a FixedUpdate() equivalent that I don't know of
@odd ridge you can take a look on how the FixedStepSimulationGroup updates, btw it runs at exactly 60fps by default
there is a utility function that you apply to a group to do that, just don't remember the exact name
hm, there is almost no difference in drawing the meshes in regular code than to Jobs.
I tested it, without Jobs and 4096 meshes it is about 9.8 seconds, with jobs about 9.3 seconds from start. Maybe most takes generation of Game Objects from Prefabs and noise-calculation.
But anyway I wonder, i though when starting 4096 IJobs that it would speed up things a little more.
use profiler to know what is taking longest
using burst on mesh generation should be big speedup
but ok, it is without burst, don't really know the restrictions of burst. someone said that using another struct (or list of structs) inside execute is the problem.
could use int4 instead, but then I have to assign the values manually each time.
it's just for testing performance difference
Like Scorr said if you really want to test it you should be profiling properly so you actually know what's taking the time instead of just guessing
normally it should be like 125 at start of app and then depending on player movement, most times i guess it will recreate about 25 new meshes, when moving over a border
can i find what is exactly allowed with burstcompile and what not somewhere?
see the burst docs
oh, damn can't use int4, as i would need an int5, lol
Is there already a way to get all newly created entities since the last frame ?
dont think so, would be kind of neat if there was
If you create them in a separate world then you can get them all in a list with MoveEntitiesFrom
Damn... thanks, last time i checked people told me to use state components, which worked... but those mostly require some sort of initial component to work...
faster and less effort to create them with a tag?
No i actually create them in the same world ^^
@stone osprey entitymanager.getcreatedanddestroyedentities
@hollow sorrel Ahhh... that sounds awesome ๐
@steady blaze structs are fine in burst, but yea you should really profile and check why even without burst its so slow
if you try to optimize without profiling youre just gambling
Hmmm... can anyone find the documentation of "GetCreatedAndDestroyedEntities" ?
plus all the usual things - safeties disabled if profiling, make sure burst has synchronous compilation enabled, don't think you'll be doing anything fast if you're converting at runtime etc @steady blaze
Probably im blind, but i cant find any documentation of this method
theres a lil bit of docs on it here https://docs.unity3d.com/Packages/com.unity.entities@0.14/api/Unity.Entities.EntityManager.html am on mobile so cant link method directly
Thanks, i probably looked at the wrong version ๐
Interessting... so you need to pass in a list of ints ?
Anyone used that method before ? Could need some help
I'm not sure but I think it's just saying you should start with an empty NativeList<int> and then make sure to use the same list for any subsequent calls to that function
@zenith wyvern Thanks, im gonna give that a try ๐
yea you have to keep track of state yourself, its not so much a 'created since last frame' but more of a diff list that comes down to same result
not sure how well it scales at high entity counts, dunno how they implemented it
... Is this really easier than just adding a tag to an archetype of the entities you're instantiating I wonder..
@amber flicker Not really... i already attach a "Identity" component to each archetype... but in case that someone forgets that one its probably cool to have an solution tracking all entities regardless of that tag
how will you know you're not accidentally processing some of their entities they're creating that they don't want you to touch? I'd handle it in conversion - don't rely on them adding a particular component, ensure that if your component is on there, on conversion it also adds the tag.
hm, it seems all is running on the same worker.
maybe i need another approach: instead of starting the same Job from each of the GOs when marked as "dirty", would it be better to use an IJobParallelFor from a parent object?
or will this be useless?
@amber flicker Thats also a good idea ๐ quick question... when does an entity query update ? Does it already update if we modify a entity... or at the end/start of the frame ?
the idea is the query itself doesn't ever update. When your job starts (e.g. OnUpdate) all entities are gathered into NativeArrays and that's what the .ForEach iterates over - I can recommend writing some IJobChunk's to better understasnd how it works under the hood
you will get a warning/error if you modify an array inside a lambda as you'd be invalidating the array created at the start of the job
to get around that, if you understand what you're doing you can e.g. allocate a temp array of the query results and iterate them
I don't suppose anyone knows if there's a way when using an entityquery of getting a specific one of those components when I already have the entity?
or you can do raw pointer access if youre a mad lad
@pliant pike you'll have to iterate over them one way or another.. i.e. a ForEach
thats not the case in ITriggerJobForEach though
theres a mapping from entitiy to component you can get for that
let me look that up...
jesus, why is this so hard to find
don't worry about it I'm going to use either Ijob or Ijobparrallelfor and get the entityquery and iterate through it, that should be way easier
thanks for trying though
no im finding this
its not about you anymore, Calabi ๐
found it in a commit of mine
GetComponentDataFromEntity<MyComp>()[entityId]
gets your component
ok thanks for that, I think GetComponent is the same as GetComponentdatafromentity though
huh, I would imagine GetComponent is using the entity manager though and therefor would be unusable in a job
I think the latter is allocating space for a reverse lookup on all of them
no, it's just masking a call to CDFE
it worked fine for me, I think it gets autoconverted
yeah no worries thanks for the help, its probably better if I do it all manually anyway
oh @pliant pike you edited your question ๐ - can't you just use CDFE?
or GetComponent as Gearless says
its always better to do it manually. Entities.ForEach is almost always the worst choice IMO. I only use that when Im trying to explicitly communicate how not involved the system is
I did use CDFE(ie GetComponent) I just get nativearray errors
and its I'm guessing it being random memory access its probably not the most efficient when I want to do it with a ton of entities
Gotta disagree - lambdas are great for most things. @pliant pike try and show some code with a specific error if you can - conceptually it should be fine.
One thing I can think of is you need to make sure you don't have the same component type as in or ref
lambdas are great when they arent rewritten under the hood. lambdas are grat because they are simple, but these arent true lambdas
Entities.WithAll<TestObjectAuthoring>().ForEach((Entity inty) =>
{
if (dudents.Length <= 0)
return;
for (int i = 0; i < dudents.Length; i++)
{
var otherdude = GetComponent<Translation>(dudents[i]);
var currentdude = GetComponent<Translation>(inty);
var currdistance = math.distance(currentdude.Value, otherdude.Value);
if (currdistance < 1)
{
//Debug.Log("The object is too damn close");
}
}
}).Run();```
theyre macros
that's the test job, if I try to run that using schedule or sheduleparallel I get nativearray errors
what exact error? I'm guessing you need to add .WithReadOnly(dudents) to your lambda maybe
I tried that it didn't work
I feel like the error must be the two GetComponents clashing somehow maybe
What's the error
InvalidOperationException: The previously scheduled job EnvironmentCollisionDetection:<>c__DisplayClass_OnUpdate_LambdaJob0 reads from the Unity.Collections.NativeArray`1[Unity.Entities.Entity] <>c__DisplayClass_OnUpdate_LambdaJob0.JobData.dudents. You must call JobHandle.Complete() on the job EnvironmentCollisionDetection:<>c__DisplayClass_OnUpdate_LambdaJob0, before you can deallocate the Unity.Collections.NativeArray`1[Unity.Entities.Entity] safely.
I get a 4 frames warning also
The code you posted is using Run so the error is from something else if it's a dependency problem
yeah the error is from using shedule
@pliant pike you're scheduling this job without depending on the EnvironmentCollisionDetection job I guess
Entities.WithReadOnly(dudents).WithAll<TestObjectAuthoring>().ForEach((Entity inty) =>
{
if (dudents.Length <= 0)
return;
for (int i = 0; i < dudents.Length; i++)
{
var toppy = GetComponent<Translation>(dudents[i]);
var currentdude = GetComponent<Translation>(inty);
var currdistance = math.distance(currentdude.Value, toppy.Value);
if (currdistance < 1)
{
//Debug.Log("The distance is too damn close");
}
}
}).Schedule();```
You're passing a native array around so you need to manually manage the job handles
Unity won't do it for you if you're passing in a collection
Dependency = Entities...... ).Schedule(Dependency); - for both this and the other job. If they're in different systems you'll also have to get the dependency from the other system
that's the only single job though
I think it's from disposing your container
there's no other systems that this depends on or anything
the whole system is just called EnvironmentCollisionDetection : Systembase
before you can deallocate the Unity.Collections.NativeArray1[Unity.Entities.Entity] safely.`
That's the important part
if I use tempjob allocator I don't need to manually dispose do I?
If a job uses a container, Unity needs to know that job is finished before it can safely dispose it. Meaning you need to call JobHandle.Complete or pass in the jobhandle to the container's Dispose method
Whether it's tempjob or persistent
but If I don't manually dispose then when closing the program I get a different error A Native Collection has not been disposed, resulting in a memory leak. Allocated from: Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions)
Yes like I said you need to dispose it you just need to make sure Unity knows the job is complete before you do
I remembered 
Show the code where you dispose your container
if I use tempjob allocator I don't need to manually dispose do I?
@pliant pike if you use Temp you don't need, TempJob you do need
Now just change it to dudents.Dispose(Dependency);
Do you need any help understanding what's going on @pliant pike ? Or does it make sense now?
I think I understand it(maybe not)
I just haven't seen it done like or needing that before
var container = new NativeArray<Entity>();
var job = new JobUsingContainer { Container = container }.Schedule();
container.Dispose(); // <- Dependency error. We're disposing the container before unity knows the job is complete
That's a condensed version of what was happening
Hopefully that makes a little more sense
If I passed in the handle to that dispose, then it would work
so Dependency is just a catch all sort of thing
It's just a job handle
SystemBase assigns system jobs to that job handle internally when you schedule them, unless you manually manage the job handles yourself
yeah I'm aware of how to do the dependecies manually and use the jobhandles etc
to be honest I thought it was all mostly automatic now
It is until you start using native containers
That's why I usually use dynamic buffers if I can get away with it. Then unity will do it all automatically
I see, I'll try and remember that, thanks
It seems my problem is that all IJobs get scheduled to just 1 worker.
The idea was to start one copy of the job from each instance of the GO, when marked dirty.
Could it help to use one IJobParallelFor called from a parent GO
Anyone an idea? ๐ก
Donโt want to try it, if it wonโt help anyway.
IJob is only single threaded
also more of them?
i think, it would be already fast enough to work without jobs, then maybe 1 or 2 dropped frames, when it needs to recreate scenery.
Of course nicer with
I have that strange problem again... i wrote a system and it does not show up, it wont get updated, even if i put [AlwaysUpdate] above it ๐ฎ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
This drives me crazy... any ideas ?
So it should help, if a change the pattern to have a NativeList of dirtyAreas in the parent object and then schedule 1 iJobParallelFor for them?
Hm, ok, guess I have to try. Need to set all properties needed for the job to public then, I guess.
But how to call results in the children-GOs?
Maybe I should concentrate on other aspects for now and try to do a better job system later.
on the other side I would like to get rid of unused code soon.
What could be an reason that my system does not show up and does not get executed ?
@stone osprey
possibility 1 - your query isnt getting any hits:
check the entities debugger, there should be an option that says "show inactive systems" then you should be able to find your system in the list and it will show you which entities are caught by the query, which in your case will be none
hm, on the other hand, when i just ensure somehow that it does not generate more then one mesh per frame, i should not need the jobs for mesh-generation, maybe for noise-generation
also i think it is a bit odd, that if you schedule multiple instances of the same the job, they will all run on the same worker thread.
btw. if anyone is interested, I found a jobified source-code of marching cubes, sadly it uses so many different scripts that I don't get how they work all together: https://github.com/Eldemarkki/Marching-Cubes-Terrain
@hollow sorrel in Update, i check if the Area (isDirty) and then initialise and schedule the job for each area GO
in lateUpdate i ask: if (jobStarted && terraGenJobHandle.IsCompleted)
like are you scheduling them with a dependency on eachother
they get started from each instance that needs to be drawn
are you combining them all to one jobhandle
don't think so
55 lines ok here?
{
if (isDirty)
{
startTime = Time.realtimeSinceStartup;
if (Utils.useJobs)
{
DrawCubesJob();
} else
{
DrawCubes();
};
isDirty = false;
}
}
void DrawCubesJob()
{
terraGenJob = new TerrainGenerationJob()
{
areaSize = areaSize,
isoLevel = isoLevel,
voxelWeight = new NativeArray<float>(voxelWeight, Allocator.TempJob),
points = points.ToNativeArray(Allocator.TempJob),
vertices = jVertices,
triangles = jTriangles,
uvs = jUVs
};
terraGenJobHandle = terraGenJob.Schedule();
jobStarted = true;
}
private void LateUpdate()
{
if (jobStarted && terraGenJobHandle.IsCompleted)
{
terraGenJobHandle.Complete();
mesh.SetVertices(jVertices.ToArray());
mesh.uv = jUVs.ToArray();
mesh.triangles = jTriangles.ToArray();
mesh.RecalculateNormals();
meshFilter.mesh = mesh;
meshCollider.sharedMesh = mesh;
jVertices.Clear();
jTriangles.Clear();
jUVs.Clear();
jobStarted = false;
}
}```
so you got multiple monobehaviours all starting seperate terragen jobs?
and they run on same thread?
that looks like there's only 1 job running
unless unity profiler is just combining them or something
can you debug.log JobsUtility.JobWorkerCount? prob not the issue since other worker threads show up but just in case
where to put that code best? in some other object's update or lateupdate?
ah ok
also gotta go for now sry lemme know how it goes
JobsWorkerCount: 7
oh ok. personally i have now idea, except to call an IJobParallelFor in the parent object and put all "dirty" Areas in a NativeList, but then I don't really know how the area-object can find out, when its index is done and access the resulting data.
i will work on other stuff meanwhile: next step: pooling the areas, depending on players position in the world.
ah - i think i just have to set a reference from the mesh to the NativeContainers before scheduling the job, then it should update it automatically
no? still have to set vertices & triangles when index is done โฆ hmm
var newWorld = new World("My New World");
var entityManager = newWorld.EntityManager;
newWorld.GetOrCreateSystem<MuhSystem>();
// ... do what u want
var playerLoop = PlayerLoop.GetCurrentPlayerLoop();
ScriptBehaviourUpdateOrder.AddWorldToPlayerLoop(newWorld, ref playerLoop);
if (ScriptBehaviourUpdateOrder.IsWorldInCurrentPlayerLoop(newWorld))
{
Debug.LogError("yes");
}
else
{
Debug.LogError("no");
}```
hey guys, this code is outputting "no"
what is the correct player loop object to pass to AddWorldToPlayerLoop?
Is there a limit of how much a buffer can "buffer" ?
is that not the right way to enable "normal" processing of a world?
if not, then how?
[DisableAutoCreation]
public class MuhSystem : ComponentSystem
{
protected override void OnUpdate()
{
Debug.LogError("boop");
}
}```
it might be, I'm a few versions out of date
ah
I'm not seeing the debug message in muhsystem
I want this system to run in my new world
not sure what I'm doing wrong ๐ฆ
or do you know how I can cause a world to process one step/frame/tick manually?
thanks. I can do that for now in a system I guess until I figure the playerloop thing out
all my other worlds is done from a singleton monobehaviour because the system setup threw some false memory leak messages before
yeah I've seen those :S
mostly been ignoring them
def not my code. hopefully they will fix
not sure if this is the same thing
w/e
I just realized my system isn't showing up in the entity debugger...
var newWorld = new World("My New World");
var entityManager = newWorld.EntityManager;
newWorld.GetOrCreateSystem<MuhSystem>();
newWorld.SetTime(new Unity.Core.TimeData(1.0 / 60.0, 1.0f / 60.0f));
newWorld.Update();
am I missing something?
(sorry, cat stepped on macro keys)
๐ฎ
MUH SYSTEM ๐คฃ
oh I get those confused sometimes
๐ฆ
If you looks at the docs for timedata, one is the step and the other is the absolute time, so if this is in a loop of some kind, it should increment the absolute time
So the system is never ran?
Sooo... how exactly do queries work ? When i log entities of my query every frame i actually see that there some entities in it... when i pass it to my command buffer for adding a component to them at the start of the next frame, it never happens. I assume that the command buffer uses the updated query and meanwhile something happened to my entities ?
Update should indeed run any and all systems in that world.
๐ฆ
@stone osprey What kind of query? If you make an EntityQueryDesc and save it, you should be able to "reuse" the query.
An EntityQuery, however, is to the best of my knowledge one insatnce of the results of an actual query
I tried this and it still doesn't update
var newWorld = new World("My New World");
var entityManager = newWorld.EntityManager;
newWorld.GetOrCreateSystem<MuhSystem>();
newWorld.SetTime(new Unity.Core.TimeData(1.0 / 60.0, 1.0f / 60.0f));
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();
newWorld.Update();```
I can resuse the query... the problem here is the following : "Get query entities, there multiple entities in it, pass that query to a command buffer -> command buffer ignores those because they dont fit to the query anymore"... is there some solution ? The problem here is that the ecb gets called at the start of the next frame and then... the entities changed and dont fit into the query anymore
@slim nebula try this?
const float tickLength = 1f/ 60;
var currentTime = 0;
void DoTick(){
newWorld.SetTime(new Unity.Core.TimeData(1f, currentTime));
newWorld.Update();
currentTime += tickLength;
}
DoTick();
DoTick();
yes. once I restart unity
TIL not to use while (true)
thanks for taking the time to help me
(unity still starting)
Oof, yeah while loops can be harsh
I pretty much always add a safeguard, even if I think the loop should always have an exit.
var maxIterations = 1000;
var iterationsRan = 0;
while(iterationsRan < maxIterations){
//stuff
iterationsRan++;
}
ok I tried cs double totalTime = 0; for (int i = 0; i < 2; ++i) { totalTime += 1.0 / 60.0; newWorld.SetTime(new Unity.Core.TimeData(totalTime, 1.0f / 60.0f)); newWorld.Update(); }
but now im tryin urs
no I'm still not seeing by debug.errorlog message in the console
That is functionally more or less the same. Pretty sure it should run the system at the first Update(); though, the second was just to be sure
[DisableAutoCreation]
public class MuhSystem : ComponentSystem
{
protected override void OnUpdate()
{
Debug.LogError("boop");
}
}```
beep boop ๐ค
Dunno.
@low tangle (who's DND) seems to have experience with this
Out of curiosity, does it work if you capture the reference to the system and Update() that directly?
yes
yes
hello june
I"m trying to make a world and run a system in it
I"m not sure what's going wrong
it's a very small amount of code
not sure if you might be able to help
Any idea why @slim nebula's code isn't working?
also, relevant docs:
https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/system_update_order.html#multiple-worlds
It does say this:
There is currently no way to manually update every system in a given World
But that seems to be not quite right...
Either way, one workaround could be to create a system group and place your systems in there for that world, and update the group - though that shouldn't be necessary!
it looks like if there's no query, it just skips Update()
calling update on the world updates all systems in it
Oh yeah, it could be some kinda culling causing it to not run...?
The part about custom bootstrap and creating worlds that way does sound potentially relevant, though (ref docs)
`[DisableAutoCreation] โ prevents the system from being created during default world initialization. You must explicitly create and update the system. However, you can add a system with this tag to a ComponentSystemGroupโs update list, and it will then be automatically updated just like the other systems in that list.
`
disable auto create disables update as well, unless you attach it to a group
how do I attach it to a group? how do I create a group? @low tangle
or should I go look that up sorry
groups are just systems
can I make my system a group then?
Groups should have the ComponentSystemBase base class, shouldn't they?
Make a "system" of that class, add it as usual, use group.AddSystemToUpdateList(). The docs actually talk about this kinda thing a bit in the custom bootstrap part under the multiple worlds header - there's also a section on system groups as well.
ok but. I dont want this group in my default world, so I would mark it as DisableAutoCreation too right?
is that going to cause a problem?
no
ok this is what I got now
uh
it's not workin
I dont see my group or my system in the entity debugger
Anyone know how performant this here is ? I cant simply pass the query, because those entities change till its used in the ecb
I see my entity tho
Any ideas on the code above ? Could this cause significant lag with large amounts ( 200 ) entities ?
Try. Profile it.
Always profile first. If, and only if you find it to be performing poorly should you worry about perf.
That or do the lazy route and just add a comment that it is a likely spot to be able to optimize, then forget about it until you potentialyl need to optimize things later.
I favor the latter, because it leads to faster development time and at least to me, less worry about the code because you're trying to go past "decent" or "good", and reach for the far off "great" and "perfect" (the latter of which is an oxymoron - the best code is no code, because only with no code can there be no perf impact, no running costs, and no bugs)
Alright, thanks ๐ I thought it caused my lag spikes... actually some monobehaviours are causing them... good to know that the manual ecb stuff isnt that bad either
I mean, you don't want to do stuff like that all over the place, but in one system, affecting 200 entities of presumably a few archetypes? Should be just fine
anyone knows, if it is possible to find out, which index of an IJobParallelFor isFinished?
So.. you want to find out, during the runtime which iterations have finished?
yes
That sounds... really sketchy. The whole thing, sure, but individual sub-jobs?
Why do you want this?
if not possible, then not possible, but it would be nicer if each object updates when it's calculations are finished, also it should be safe.
If you want each individual iteration to do work separately and then update something, it sounds like you want individual jobs for each of them
the thing is: i tried to start multiple instances of a regular IJob from multiple instances of a MonoBehaviour and they all seem to Execute on the same worker thread.
That sounds like a problem in how you run the jobs
I have not seen it, so sure
void Update()
{
if (isDirty)
{
startTime = Time.realtimeSinceStartup;
if (Utils.useJobs)
{
DrawCubesJob();
} else
{
DrawCubes();
};
isDirty = false;
}
}
void DrawCubesJob()
{
terraGenJob = new TerrainGenerationJob()
{
areaSize = voxelSize,
isoLevel = isoLevel,
voxelWeight = new NativeArray<float>(voxelWeight, Allocator.TempJob),
points = points.ToNativeArray(Allocator.TempJob),
vertices = jVertices,
triangles = jTriangles,
uvs = jUVs
};
terraGenJobHandle = terraGenJob.Schedule();
jobStarted = true;
}
private void LateUpdate()
{
if (jobStarted && terraGenJobHandle.IsCompleted)
{
terraGenJobHandle.Complete();
mesh.SetVertices(jVertices.ToArray());
mesh.uv = jUVs.ToArray();
mesh.triangles = jTriangles.ToArray();
mesh.RecalculateNormals();
meshFilter.mesh = mesh;
meshCollider.sharedMesh = mesh;
jVertices.Clear();
jTriangles.Clear();
jUVs.Clear();
jobStarted = false;
}
}```
Write like this to get C# highlighting:
```cs
(stuff)
```
Also, you can simplify away jobStarted by checking terraGenJobHandle == null, depending on what you prefer.
The code seems correct, though, not sure why it's not using multiple worker threads - I would assume maybe some config
i don't think jobhandles can be null since they're structs
Ah, of course
If they're structs then you need to check if they are default, but I think I would prefer a separate bool for it instead then.
forget it, i think i tried with the handle anyway
any idea, why they won't run in paralllel?
@low tangle (I hope you don't mind the ping. If so I will stop) what is the correct way to create the normal base system groups in a new world such that it will run the systems like the default world every frame?
yes, really seems to be some kind of config, as the noisegeneration IJobParallelFor can also be found in just one worker
If the parallel job only does one, it's definitely config
Check the project settings, I seem to recall there being options about jobs
is it possible to run a physX raycast from inside a job?
burst and jobs are two different things
jobs settings would be somewhere else
ohhhhh
i have no idea, where they can be found
if you look at the jobs tab
in the editor
up the top
is use jobs threads turned on?
where?
up the very top
woo I think I got it workin. thanks for the help guise
i am on mac and sorry don't know what you mean. and unity 2019.4
@slim nebula If you want the second world to run parallel (same timestep, and when the default world runs)... You probably need a singleton monobehavior that (possibly) kicks of making the world, but most definitely grabs a reference to it and runs update... in its own Update()
something like
//In singleton monobehavior
World MuhWorld;
//Up to you for where to actually run this
void InitializeWorld(){
MuhWorld = new World("Muh World");
var systemGroup = MuhWorld.GetOrCreateSystem<MuhSystemGroup>();
systemGroup.AddSystemToUpdateList(MuhSystem);
}
void Update(){
var time = new TimeData(time.Deltatime, time.Time);
MuWorld.SetTime(time);
MuhWorld.Update();
}
so there's a step missing
something needs to be done to add the group to the world update
@steady blaze @shy pilot Might be a window that needs to be opened? Sounds like it's in a non-default window
that part is unclear
I was able to get around it like this
var newWorld = new World("My New World");
var initializationSystemGroup = newWorld.GetOrCreateSystem<InitializationSystemGroup>();
var simulationSystemGroup = newWorld.GetOrCreateSystem<SimulationSystemGroup>();
var presentationSystemGroup = newWorld.GetOrCreateSystem<PresentationSystemGroup>();
ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(newWorld);```
AddWorldToCurrentPlayerLoop does the thing to add the groups to the world update
I'm not sure how to add custom groups to the world update
when my editor loads will send pic
but now I"m trying to load a subscene into a specific world. I'm not sure how to do that
@slim nebula Well, if you can use the default groups, then that should make it easier. Just plop MuhSystem into SimulationSystemGroup or something
Nope, haven't opened unity in a couple weeks
ah ok, that should be menu bar, but i only have burst there
hmm
There's also a thing
JobsUtility.JobWorkerCount = someInt;
but the screenshot of the profiler implies that the threads are there
they just aren't being used
is the job in question ijobparallelfor?
i tried to Debug.Log(JobsUtility.JobWorkerCount) and it says 7
If you do JobsUtility.JobWorkerCount you're gonna want to grab the current computer's core count somehow (pretty sure you can use some default thing in the System.Threading namespace for that...), and set the count to core count-1, and clamped to something sane like no more than 8 worker cores ( beyond that you get diminishing returns and the scheduler becomes the bottleneck)
Seems like it already does something like that, hmm
What if you download the Jobs package? that should give you the menu element, I think
if he's able to make jobs then surely its already there
No, you get the basic IJob at least built-in with no extra packages
oh ok, didn't know that
does anyone know if its possible to run a raycast with the GO physics engine from inside a job?
oh yes, it seems to activate it with the preview package, although i do not get the option in the menu and profiler is strange
Highly doubt it, and even if you could, it sounds very unsafe
I do believe there are some kinda raycast job thingies, but they're scheduled from the main thread
yeah
i've read about them
i guess i'll have to do something janky like clone the collider onto an entity
and raycast using Unity Physics
Sooo did any package updates drop so far?
really strange - it shows no only idle in the workers and seems to be even slower
maybe i have to restart everything
That sounds... not so good
Are you using physics, by any chance?
Only Unity DOTS package I know of that uses a second world
I don't think physics uses another world, netcode does use a custom bootstrap
Physics stores it's colliders and data inside a collection called PhysicsWorld
Oh, it's a fancy collection? I thought it was an actual world ๐
Well, I gotta get some sleep, good luck figuring it out
I am indeed using physics
so I have to modify the physics package code to get this working?
no references found. it's not in my code. therefore it must certainly be in package code right?
no unity packages that i know of use custom bootstrap
are you using netcode?
dunno about that one
really annoying, it seems i simply can not activate to use multiple threads:
@steady blaze what unity version are you using
2019.4f12
ah ok awesome thanks scorr
i dunno how you guys find this shit in the docs so quick. I do search online before I come here ๐ฆ thanks!
i guess setting jobthreads from that dropdown is only in 2020+, but it shouldn't really matter because all it does is set jobsutility.workerthreads which you confirmed is already set to 7 at start
so guessing that's not the issue
dunno what else could be tho, seems really weird
really strange, as the job from NoiseGenerator is an IJobParallelFor and i tried different batch counts
maybe it some strange limitation that it does not start with multithreading before the 1st frame is drawn or something like that?
really weird as at least the noise-job should run on multiple workers i guess
how do I tell SceneSystem not to load a scene in my new world?
it seems to be loading entities from my main scene into there which I dont want
reeee if I load an empty scene on my other world, it loads the empty scene on the default world
whyyyyyyyyyyyyy
never mind im dum
yeah I dunno how to get my other world to not load the default scene
any ideas?
ok, maybe it is really some kind of limitation that before the rendering starts (or first frame is drawn or whatever) unity schedules all jobs to one worker.
because when i don't set isDirty to false it redraws the meshes every frame (which does not make sense of course and produces errors), but schedules the jobs to different workers.
(also i think i know why it looks like one long job in the profiler: each time a new job gets started, the following one gets slower, because on the same worker, so after all are started it may show only the longest one.)
So i will simply ignore that for now and move on to pooling the areas and then see what happens if the players triggers generation of new areas.
and then i will see if it works as intended (and faster)
btw. for burst compile on the terrainJob it gives this error: Unexpected exception Burst.Compiler.IL.CompilerException: Error while verifying module: Invalid bitcast { i32*, i32 } bitcast ([3 x i32] [i32 0, i32 3, i32 8] to { i32*, i32 })
is there something special i need to do to get a command buffer to playback after a ijobparallelfor?
for some reason it just doesn't execute the structural changes
i can't even spawn entities anymore
here's the code EDIT: One sec i just gotta clean up some stuff
if this works i may just give up on jobs for this task ๐
it doesn't seem to be
anyone else getting index out of range errors with the new Entities and Physics update (0.16 and 0.5.1, respectively) when trying to raycast in a job? it worked fine before updating
Unity.Physics?
yeah
umm, no but i will run into that problem soon by the sounds of it ๐
with the new Entities and Physics update (0.16 and 0.5.1, respectively) ๐
is anyone at all here using pure ecs?
@craggy orbit where did you find these updates? not showing up for me
i thought they didn't have a pure ECS pipeline yet ๐ค
well
you gotta click the dropdown in package manager and scroll up
oh wow
is this not the correct way to instantiate an entity with pure?
ty
yeah
//Archetype
//NOTE: Does not include state components
EntityArchetype creatureArchetype = EntityManager.CreateArchetype(
typeof(Translation),
typeof(Rotation),
typeof(RenderMesh),
typeof(RenderBounds),
typeof(LocalToWorld),
typeof(SectorEntityComponent),
typeof(SpeciesIDComponent),
typeof(HealthComponent),
typeof(AgeComponent),
typeof(NutritionComponent),
typeof(ReproductionComponent)
);```
and then instantiate with this:
Entity creature = EntityManager.CreateEntity(creatureArchetype);
it's recommended to use gameobject-based prefabs. there's a lot of Hybrid Renderer components and it's hard to keep track of them all
when i do so the entity doesn't even spawn
like at all
nothing in the debugger
nothing anywhere ๐
did you try debug logging the result entity? it might be created then instantly destroyed by another system
nope, its getting created
but has the entity.null attribute
according to my breakpoints
well, it has entity.null
i'm just gonna switch to hybrid
oh
my
aaaaaaaah
@craggy orbit your hunch was 100% accurate
_<
there was a half written system i'd forgotten about
Lies. Updates dont exist until I see Olento post the patch notes
yeah patch notes are only local for some reason
"Root scene conversion" What the heck does that mean
maybe so you can treat your scene as a subscene instead of having a scene that's empty other than just holding subscenes if you go full dots
just guessing
Could be, in a Project Tiny post they were hinting at a better solution than the awkward subscenes-inside-scenes stuff you have to do now
Add `IFixedRateManager` interface for fixed-timestep implementations.
ooooo... so we add this interface in the system and we get FixedUpdate() equivalent method implemented
has anyone here used mathematics.random?
i was under the impression that nextint when called more than once would like, return a unique value
it does
if used in a job, you need to get it back out from the job and store it somewhere
Or provide a unique seed for every job
can you not run it more than once per job though?
i need to run it 10 or so times
from one job
doesn't .NextInt imply that you can run it repeatedly and get a new one
Yes. If I remember right you need to provide a large seed to get better variance early. I don't know much about RNG but that's what I was told
By large seed I mean just a bigger number
it's kinda weird but if you're accessing it from an array, you need to copy an instance and reassign that index of the array when you're done with it
It's a struct so all the rules of a struct will apply for it
so iirc you can't do like randomArray[index] multiple times and get different results. you have to do
Random randomAtIndex = randomArray[index];
//do whatever with randomAtIndex however many times
randomArray[index] = randomAtIndex;
thanks
oh, physics got only minor bump on new packages ๐
also.. they DID land this week so that one staff comment of these landing at the week of 27th was correct after all :p
Lies. Updates dont exist until I see Olento post the patch notes
@zenith wyvern I just woke up ๐
also.. latest package manager on alphas/betas is just so broken
it doesn't even give "there's an update" for half the packages, even it can still list them
it's not even about some packages being verified or have full release and others not as none of the dots packages beyond burst and math have that ๐
so basically, collections, dots editor, entities, hybrid renderer, jobs and unity physics packages got bump from ones I have installed atm
platforms got a bump the other day and burst updated a while ago as well but not on this bump
oh wait... I think I got the package manager logic here, it ONLY shows the upgrade icon for packages that I've manually installed... if it's a dependency that's currently automatically handled, it doesn't show that icon
yeah, I guess that makes sense now that I realize that, but I'd rather see some other way to communicate to me if some package is actually installed by dependency in the first place...
## [0.11.0 DOTS Editor] - 2020-10-06
### Added
* Added a new backend for inspecting an `Entity`. It is used by default when installing the `com.unity.dots.editor` package, but it can be turned on and off through the `DOTS Editor` preferences menu.
* Entities window: Added autocompletion for component type when filtering entities with `c:...`
### Changed
* Systems window: Now shows a message when no system match the requested search
* Systems Window: Now shows an error message when failing to resolve a component type name when typing `c:mycomponent`
* Updated package `com.unity.entities` to `0.16.0-preview.21`
* Updated package `com.unity.jobs` to `0.7.0-preview.17`
* Updated package `com.unity.properties` to `1.5.0-preview`
* Updated package `com.unity.properties.ui` to `1.5.0-preview`
* Updated package `com.unity.serialization` to `1.5.0-preview`
* Updated package `com.unity.burst` to `1.3.7`
### Fixed
* Entities Window: Fixed an issue where the search filter would not be applied after changing the selected world
* Entities Window: Improved error handling when incrementally updating the view model, fixing native memory leaks
* Entities Window: Now properly unsubscribes to selection change event
* Entities Window: Fixed a null reference issue when selecting an entity
* Systems Window: Fixed an issue where the details section contents keep changing while searching
* Systems Window: Fixed an issue where searching returns the wrong results
* Systems Window: Fixed an issue where the details section can sometimes hide the selected system
* Systems Window: Fixed an issue where deselecting a component would remove the substring from the entire search string ```
wonder if they forgot to update the date or if they've had this update just sitting there waiting for next round of updates for a month
## [0.14.0 Collections] - 2020-09-24
### Added
* `*UnsafeBitArray.Find` with pos/count search range arguments.
### Changed
* `UnsafeStream` block allocation performance has been improved by ~16% by appending to the start of the per-thread block lists rather than the end.
* Burst package updated to `1.3.7`
### Removed
* `FixedList*.InsertRange`, `FixedList*.RemoveRangeSwapBack`, `FixedList*.RemoveRange`, `NativeString*`, `NativeList.RemoveRangeSwapBack`, `NativeList.RemoveRange`, `UnsafeList.RemoveRangeSwapBack`, `UnsafeList.RemoveRange`, `FixedString*.Format`, `FixedString*.AppendFrom`, `NativeHashSet.TryAdd`, `UnsafeHashSet.TryAdd`.
* `[NativeContainerSupportsDeallocateOnJobCompletion]` attribute from `NativeReference` container. It didn't work properly. Users can use `Dispose(JobHandle)` method instead.
### Fixed
* `FixedList<T>` `Remove` and `RemoveSwapBack` extension methods were modifying copy, fixed by passing `this` by reference to modify actual container.
this has even older date
package did only get out today though, I did verify it from the package repo
## [0.5.1-preview.2 Unity Physics] - 2020-10-14
### Changes
* Dependencies
* Updated Burst from `1.3.2` to `1.3.7`
* Updated Mathematics from `1.1.0` to `1.2.1`
* Updated Collections from `0.11.0-preview.17` to `0.14.0-preview.16`
* Updated Entities from `0.13.0-preview.24` to `0.16.0-preview.21`
* Updated Jobs from `0.4.0-preview.18` to `0.7.0-preview.17`
* Run-Time API
* Added the `TerrainCollider.Filter` setter
* Removed the `CompoundCollider.Filter` setter as it was doing the wrong thing (composite collider filters should be the union of their children)
* Added `BuildPhysicsWorld.AddDependencyToComplete()` which takes a job dependency that the `BuildPhysicsWorld` system should complete immediately in its `OnUpdate()` call (before scheduling new jobs). The reason is that this system does reallocations in the `OnUpdate()` immediately (not in jobs), and any previous jobs that are being run before this system could rely on that data being reallocated. This way, these jobs can provide their dependency to `BuildPhysicsWorld` and make sure it will wait until they are finished before doing the reallocations.
* Added the option to provide a custom explosion filter in 'PhysicsVelocity.ApplyExplosionForce'.
* Authoring/Conversion API
* Run-Time Behavior
* Changed Graphical Interpolation default to simpler implementation that doesn't try and consider velocities
* `BuildPhysicsWorld.CreateMotions` now gives Kinematic bodies a zero Gravity Factor (i.e. they will not be affected by gravity)
* Setting the `Collider.Filter` is now allowed for Terrain colliders as well, as opposed to previously only working for Convex colliders
* Authoring/Conversion Behavior```
### Fixes
* Fixed the potential issues if more than one job implements IBodyPairsJob.
* DebugStream.DrawComponent now cleans up its associated GameObject
* Fixed a bug in 'PhysicsVelocity.ApplyExplosionForce' where the provided collider's collision filter could prevent the explosion from happening.
* Fixed a memory leak in the Collider debug display gizmo```
jobs package upgrade is marked just as packages bump
## [0.16.0 Entities] - 2020-09-24
### Added
* EntityManager method CreateEntity(EntityArchetype, int). Unlike existing overloads of CreateEntity, this new overload takes no Entity array and returns no Entity array, so it avoids waste and bother in cases where callers don't need the actual Entity values.
* Special handling for Cameras and Colliders in preparation for root scene conversion, though they are disabled by default still
* `World.MaximumDeltaTime` now controls the maximum deltaTime that is reported to a World.
* Exception's stacktrace are recorded in conversion logs.
* Add `IFixedRateManager` interface for fixed-timestep implementations. See `FixedRateUtils.cs` for reference implementations.
* Add `ComponentSystemGroup.FixedRateManager` property, to store the current active `IFixedRateManager` implementation.
* Added `SceneSystem.IsSectionLoaded` to enable querying if a specific section of a scene is loaded.
* `EntityQuery.SetOrderVersionFilter()` and `EntityQuery.AddOrderVersionFilter()` which can be used to filter the Order Version independently from the Changed Version of a chunk.
* DOTS naming standards to CONVENTIONS.md
* libcurl Stevedore artifact registration
* Mathematics tests are turned on in CI```
### Changed
* Improved performance of `EntityQuery.ToEntityArray()`
* Platform packages updated to `0.9.0-preview.9`
* Burst package updated to `1.3.7`
* Properties packages updated to `1.5.0-preview`
* The job safety system has be moved to NativeJobs as C++ code
* The UnsafeUtility memory allocators have been moved to NativeJobs
* improved performance of EntityQuery.CopyFromComponentDataArray
* changed chunk size from 16128 bytes (16 KB - 256 bytes) to exactly 16384 bytes (16 KB).
* `TypeManager.GetFieldInfo` now takes in a `Type` to return an `NativeArray<FieldInfo>`. The passed in type must be registered to have field information generated explicitly via the `[GenerateComponentFieldInfo]` assembly attribute.
* `IJobEntityBatch` and `IJobEntityBatchWithIndex` now quietly skip batches whose size is zero. This can happen legitimately if the requested `batchesPerChunk` value is higher than the entity count for a particular chunk.
*Removed deprecated `ArchetypeChunk.Locked()` method.
*Deprecated `ArchetypeChunk.BatchEntityCount` property. The `.Count` property should be used instead.
* Removed usage of TempAssetCache for some livelink cases. Now these files are under SceneDependencyCache instead, so there is only one magic directory to deal with until we can remove it completely in future Unity versions.
* Fixed Reduced overhead of `IJobEntityBatchWithIndex` prefiltering by up to 20% if `batchesPerChunk` is 1, or if `EntityQuery` filtering is disabled.
### Deprecated
* `FixedStepSimulationSystemGroup.MaximumDeltaTime` has been deprecated. The maximum delta time is now stored in `World.MaximumDeltaTime`. For better compatibility with UnityEngine, the new field applies to both the fixed-rate and variable-rate timesteps.
* `ComponentSystemGroup.UpdateCallback` is deprecated. Instead, the group calls the `ShouldGroupUpdate()` method on its `FixedRateManager` property (if non-null) to accomplish the same effect.
* `FixedRateUtils.EnableFixedRateCatchUp()`, `FixedRateUtils.EnableFixedRateSimple()`, and `FixedRateUtils.DisableFixedRate()`. These functions were used to set the deprecated `ComponentSystemGroup.UpdateCallback` field; instead, just set `ComponentSystemGroup.FixedRateManager` directly.
### Removed
* Old 2020.1 ifdef blocks in LiveLink scene culling code
* Deprecated legacy sort order code in ComponentSystemGroup was removed
### Fixed
* Removed GC-allocations in `SceneSystem` and `SceneSectionStreamingSystem` that were happening every frame
* Issue with invalid GUID in SubScene importer causing Player LiveLink to stall waiting for an asset it will never get
* Hybrid component transform syncing was not working when entity order changed
* Hybrid components being editable when in Preview Scenes (by selecting gizmos)
* Fixed an issue in 2020.2 which caused `NativeContainer` min-max ranges to be incorrectly patched when scheduling and `IJobChunk` or `IJobEntityBatch` with a "Single" or "Run" schedule call.
* Fields marked with `RestrictAuthoringInputTo` can now be set to `None` in the inspector
* The Entities package now uses a faster code path for `CreateArchetypeChunkArray()` more consistently.
* Retroactively added a changelog entry that notes a behavior change in `RemoveComponent(EntityQuery, ComponentTypes)`. See 'Change' entry under 0.14.0.
* Generic job reflection data across assemblies would sometimes not work
* Fixed HLOD component throwing out of bounds exception when setup incorrectly against LODGroup.
* Scene section meta data now works in standalone builds again
* Native memory leak in EditorSubSceneLiveLinkSystem when failing to apply patches
* Generic job registration is more robust when generic parameters
* LiveLink will not generate errors on scenes that have not yet loaded scene sections
* Corrected inverted test in `IJobEntityBatchWithIndex` if EntityQuery filtering is enabled.
* `EntityManger.AddComponent<T>(EntityQuery entityQuery)` and `EntityManger.AddComponentData<T>(EntityQuery entityQuery, NativeArray<T> componentArray)` is 2x faster.
* Reduced overhead of `IJobEntityBatch` execution by 5-10% if `batchesPerChunk` is 1.
Generic job registration is more robust when generic parameters wat
I guess I could still post netcode and animation ones as they got bumps too
## [0.5.0 Netcode] - 2020-10-01
### New features
* Added RpcSystem.DynamicAssemblyList which can be used to delay the checksums for RPCs and ghost components when the set of assemblies are different on the client and server.
* Added to RPC and Command the possiblity to send Entity reference from both client and server.
### Changes
* Change the system ordering to be compatible with latest physics. `NetworkTimeSystem` has moved to `ClientInitializationSystemGroup`. The SimulationSystemGroup runs `GhostSpawnSystemGroup` (client), `GhostReceiveSystemGroup` and `GhostSimulationSystemGroup` before `FixedStepSimulationSystemGroup` where physics is running. `RpcCommandRequestSystemGroup`, `RpcSystem` and `GhostSendSystem` (server) is running at the end of the frame, after all simulation code. Other systems has been moved into one of the groups.
* Created a new `GhostInputSystemGroup` where systems adding inputs to the input buffer should run.
### Upgrade guide
* The systems adding input to the `ICommandData` buffer needs to be moved to `GhostInputSystemGroup`
## [0.8.0-preview.3 Animation] - 2020-10-22
### Added
- Added PropertyDrawers for TransformBindingID and SkeletonBoneReference (which is now made public). Both make it possible to set bones from the Skeleton Asset using drag and drop or using the object picker. TransformBindingID is a path to a bone, and SkeletonBoneReference contains a reference to a Skeleton and a TransformBindingID, which represents a bone in the given Skeleton.
- Added SkeletonReferenceAttribute which can be used on TransformBindingID to associate it with a property returning, or a field containing a Skeleton.
- Added ShowFullPathAttribute which can be used on TransformBindingID and SkeletonBoneReference to show bone names as full paths instead of just the name of the bone itself.
- Added a debugger view for `Rig` IComponentData. This view will display the `BlobAssetReference<RigDefinition>` internal data in the debugger. For more advanced debugging you can also add the DEBUG_STRINGHASH to your project scripting symbols which can be added under `Project Settings/Player`. This optionnal symbol will keep the original string for all hashes, and use this information when the debugger need to display a StringHash. There are currently a few limitations with this system:
- Since it stores this information into a static class, every domain reload clears the dictionnary.
- It currently only works in editor mode.
## [0.8.0-preview.2 Animation] - 2020-10-05
### Changed
- Added SkeletonAuthoring asset that isolates the animation bindings declaration and authoring from the rig instance in scene. This is the first version of SkeletonAuthoring and this asset will continue to evolve as more workflows are developed around it.
- Added RigAuthoring that uses a SkeletonAuthoring instance to generate a RigDefinition.
... (package upgrades)
- Deprecated the property RigComponent in BoneRendererComponent. A reference to the RigComponent is not necessary anymore.
### Fixed
- Fixed bug when reading input port twist weights in the `TwistCorrectionNode`.
## [0.8.0-preview.1 Animation] - 2020-09-28
### Added
- Added `IDeclareCustomRigChannels` interface and `RigChannelCollector` helper to append custom rig channels at conversion time to a `RigDefinition`. In other words, any custom `GameObject` components implementing the `IDeclareCustomRigChannels` in a `RigComponent` hierarchy will be called during conversion to append custom channels.
### Changed
... (upgrades and renamed types)
## [0.10.0 Hybrid Renderer] - 2020-09-24
### Added
* Error message when trying to convert SkinnedMeshRenderer that is using a shader that does not support skinning.
### Removed
* HybridRendererSettings asset was removed since memory management for the hybrid renderer data buffer is now automatic.
### Fixed
* Fixed missing mesh breaking subscene conversion
* Fixed chunk render bounds getting stale when RenderMesh shared component is changed.
* Improved Hybrid V2 memory usage during GPU uploading.
* Chunk render bounds getting stale when RenderMesh shared component is changed.
* Reduced Hybrid V2 peak memory use when batches are deleted and created at the same time.```
Looks like Tiny updated too, no post about it yet though
I keep forgetting it exists
thanks for the update Olento !
thanks mainly to @hollow sorrel @tawdry tree and @zenith wyvern ? for the help with Job-System! (sorry if I forgot someone)
finally found the problem, why Burst did not work: The Triangle LookupTable was defined as a nested array like int[][]
as the Job did access it, burst did not seem to like that, so I changed it to a one dimensional array. So from: public static readonly int[][] TriTable = new int[][] { new int[] { }, new int[] { 0, 8, 3 }, new int[] { 0, 1, 9 }, new int[] { 1, 8, 3, 9, 8, 1 }, โฆ } to:
public static readonly int[] TriangleTable =
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
โฆ
}```
(ninja edited hybrid renderer changelog to <#archived-dots message>)
with a large number of areas it starts now a bit faster as without jobs (like with 4096 areas ~7 secs instead of ~9.5)
But I guess it is more a problem of the other stuff going on, like creating the GOs, the Noise is also not fully job-ready, etc.
Also it seems that at Application Start Unity is not able to schedule the Jobs very well.
Well.... time to get hyped about the next dots update ๐
yeah this didn't really bring much new functionality
for my use cases, it's mainly that small fixed timestep tweak
2x improvement for AddComponentData is nice... but imo it's still bad enough you still often need semi-elaborate archetype caching strategies to avoid it. Really disappointing Jobs got no update at all I thought.
also.. latest package manager on alphas/betas is just so broken
@dull copper do you have a bug where if the package manager get's stuck in "Resolving Packages" for 2 mins, it just fails?
I'm getting these with the current packages: ArgumentException: UnityEditor.Experimental.TerrainAPI.PaintHeightTool and UnityEditor.Experimental.TerrainAPI.PaintHeightTool have a conflict in the stable type hash. Use the [TypeVersion(...)] attribute to force a different stable type hash for one of them. Unity.Entities.TypeManager.AddTypeInfoToTables (System.Type type, Unity.Entities.TypeManager+TypeInfo typeInfo, System.String typeName) (at Library/PackageCache/com.unity.entities@0.16.0-preview.21/Unity.Entities/Types/TypeManager.cs:392)
UnityEditor.Experimental.TerrainAPI.PaintHeightTool vs UnityEditor.Experimental.TerrainAPI.PaintHeightTool ๐ค
it's literally the same thing
I do have terrain tools package here too which could be what triggers this
smooth upgrade for me
yeah it did work for my other project where I just upgraded the dots packages but didn't have any terrain stuff
it's just.. that error message is nonesense
it wants me to put different hash for other but it literally lists the same thing twice
maybe also interesting: with a "normal" number of Areas at start (like 5x5x5) it schedules all Jobs to one worker.
Only with a bigger number, so that generation spans over a few frames it starts to assign to different workers.
I guess that's why it is only a little faster with lots of objects. But yeah, hope it will behave different when generating terrain while the game is running (As at Start Jobs don't really seem to speed things up)
there probably isn't any setting to make this faster?
burst background compilation doesn't seem to be particularly multithreaded
@dull copper maybe synchronous compilation could help?
have no idea, but sounds like it could be that option
doesnt that just force the compilation before you can play in editor?
as another note, I find current Burst AOT defaults super weird for 64bit builds:
almost everyone got SSE4 capable system and only minority can do AVX2
if I had to omit something from that list it would be AVX2 and just enable all the rest
AVX vs AVX2 gains aren't that noticeable even
Ok, seems to be so, finally found a better description about the options in the menu.
Welp I'm also getting the terrain tools errors
hopefully unity would update the terrain tools package
it's coming from that package yes
I tried removing it and the error was gone
I don't think it stops from using any of these but you get those 6 errors every time you start the editor again, you can clear them
nothing like the smell of fresh packages in the morning ๐
Or each time the editor builds.
Also, Package Manager is broken from 2020.2.0b8 and above.
I dunno why.
I'm stuck in b7 for nowbut I see a fix in review already so ๐ค on b10
im stuck on b1 ๐ personally until at least ui toolkit is fixed
bit off topic here but is there any trivial way to animate ui elements at runtime yet?
I'm aware that the current roadmap says ui anims will come in 2021.2
but they've been saying a lot of things in past, there's like no way I'd believe that target will hold
thought there was some experimental stuff in the latest versions
havent personally used it though
My coming lib will do it with Timeline & code but couldn't you use an existing main-thread tween lib to do it?
I dunno, hence asking ๐
I haven't really used UI toolkit at all in my own projects as it's been just too raw
if you can move the elements via code now, even that's something
it's just, I have no idea what they expose atm
https://github.com/Unity-Technologies/UIToolkitUnityRoyaleRuntimeDemo/search?q=experimental some instances of the experimental stuff in use
thanks, I'll check it out
I'd really want to avoid the ugui at all cost but worried about some pretty basic functionality missing on new ui's runtime
I'm ok if you can code / hack around it to make things move around etc
were there updated dots animation samples? the main dots animation repo seems unchanged but was wondering if i missed something
does it ship examples are part of the package?
dots or uitoolkit?
(anim package you were asking about)
well ui toolkit has examples as an importable mini package
yeah I've seen those ๐
ah ill have to check but somehow doubting that
altho I didn't quite understand the ui toolkits runtime samples
why didn't they put like actual sample scene for that there
I totally felt like I missed something there
agreed some of those examples seem a bit abstract in nature, the repo feels more understandable and the builtin examples seem to have more advanced use cases
ah, got the demo open, yeah this definitely has dynamic elements ๐
Hello ! I am testing very simple Dots stuff, but I came into something curious: using ScheduleParallel() is slower than using Run()... Could someone help me understand why?
The ScheduleParallel code ~0.04ms: https://hatebin.com/aijhawcfqi
The Run code ~0.01ms: https://hatebin.com/eisftvqddh
that's an easy one - it's expensive to schedule work to run across different threads (I haven't looked at your code)
supposedly they're working on optimising the scheduling but we've yet to see any improvements
Ohhhh ok! So unless the jobs are huge, it is not "worth it" to schedule it?
correct - also by default the more cores/threads you have, the slower it becomes
Understood, thank you!
Also, do you know if SystemBase.Dependency is automatically .Complete() at the end of the processing ?
I believe .Complete() may be called on all jobhandles at the end of a frame - the Complete call causes a sync point and ensures no further work is done or jobs scheduled until the current work (jobs across threads) is complete. Not sure if that helps
Yes, it makes sense, thanks once again!
late reply to entities update but yea seems like not much changed for me either which is unfortunate
however they updated packages at same time now which is good
just want some animation samples updates, why is this so hard to get
im getting a new error with the package updates today that i wasn't getting before. tracing it back it seems to happen in spots that i do a raycast inside a job, but the bit that throws the error is some internal physics stuff (Broadphase.cs).
"ReadWriteBuffers are restricted to only read & write the element at the job index. You can use double buffering strategies to avoid race conditions due to reading & writing in parallel to the same elements from a job."
im guessing it's something on Unity's end. would it make sense to downgrade Physics to 0.5 or....?
hmmmm never mind seems it's not directly correlating to the Physics update
Is it mandatory to use .Complete() in a JobHandle after use .Schedule() in a IJob or I', allowed to just fire and forget?
dont need to complete unless you need the results
@craggy orbit mightve been something where although it worked prior, it technically shouldnt have or at least not according to best practises and they only just introduced a proper error for it
dont need to complete unless you need the results
@safe lintel I need the results, thought I don't want to store theJobHandle. I mean, the job itself will store its result in a shared array. Will the job be executed even if I never call.Complete()?
yikes. ok, thanks
yes the job will be executed, even if you dont use Complete(), as long as you are scheduling
but if you need to complete, use it
yes the job will be executed, even if you dont use Complete(), as long as you are scheduling
@safe lintel So.Complete()is not compulsory for the job to be executed if I can check its completition in another way?
there's .IsCompeleted.
you can use that to check if the job has completed
But I don't want to store the JobHandle
Don't @ me, but I believe you need to clear the job anyway or the thread will continue to run even if the intended operation is "done" in a way.
And with TempJob's lifetime, it'll get leaked while the thread is running
so either way, you need the JobHandle
Don't @ me, means "don't quote me on this".
I had a similar problem when I didn't .Complete() the job and just disposed the native container.
errors out telling me that I shouldn't even though the operation is done.
That lead me to believe that the thread is still running even when IsCompleted = true.
So .Complete() is needed to safely stop the Job from running and Dipose the native container
ohh, ok
For everybody that helped me sort out Jobs problems, thanks again and yes! ๐ After I finished terrain-generation (Instantiate) and destruction (Destroy) based on Player position (guess it's pooling) the Jobs then finally run in parallel! (in contrast to the behaviour at Application Start, where they all run on one worker - I guess this is because unity needs to do other stuff at Start)
it is about 15ms now for generation of 25 meshes using Jobs and about 37ms without Jobs ๐
so it seems to be much faster to add a new component to an entity than it is change the value on one:
where test 1 is eM.AddComponent<TestTag>(entities[0]); and test 2 eM.SetComponentData<TestTag2>(entities[0], new TestTag { Value = 1 });
though sometimes it seems to about be the same for some reason
how many entities are you testing it on?
the above is so terrible for so many reasons ๐ฌ ... sorry ๐ฅด
@olive kite are you testing AddComponent on the same entity over and over? Because AddComponent returns early if the entity already has the component (and doesn't actually set the value)
Just to add (I said the above so people wouldn't suddenly worry about using SetComponentData) - SetComponentData (in my experience) is more like one or two orders of magnitude faster than AddComponent. Your last two tests in the above also show the same time - no idea what you're really measuring, whether you've done it attached to a build, allowed for warm-up etc etc.
Not to mention that AddComponent causes a sync point, while SetComponent does not
ok thanks, that is really good to know about the sync point. I am using AddComponent on the same entity but with a different component.
@amber flicker they were the same test1 (add component) and test2 (set component) running in OnUpdate() once per frame. maybe it is too small of a sample size though at 100
@steady blaze nice, glad it works now and seems like good speedup for just jobified
next step is trying to make it work in burst :p
@hollow sorrel already runs with burst. the problem was that the Triangle LookUpTable (which is accessed from the Job) was a nested array like: public static readonly int[][] TriTable = new int[][]
switched to a regular 1d array, now it works
oh? as in youre still using a c# [] array?
wouldnt think that works with burst or jobs even
with a sight distance of 3 (so 7x7x7 areas active) there are noticabe framedrops without jobs
the lookup tables are external, access from job works (also with burst). could they be a persistent nativeArray, also static and readonly?
You can use managed arrays if they're static and readonly, yeah
i did it that way, because the (jobified) open source marching project does it the same way
ah
wow you can use static values in burst?
thought it needed some special stuff for that
neat
yes, i think they have to be readonly
or const
could it speed things up with lookuptables beeing a nativearray?
I'm not sure
ok, I'll leave it, like it is for now. next step would be some better noise, with more settings, a seed, octaves and better results of course.
Of course I will try to do that with jobs too.
maybe have a regular loop for the octaves and always have the most inside loop (setting values to the voxels and iterating through one area) as an IJobParallelFor
๐ฅณ ๐ animation samples updated ๐ฅณ ๐ ๐ ๐ฆฎ
well the samples work
hdrp has the most advanced examples it seems https://github.com/Unity-Technologies/Unity.Animation.Samples/tree/master/UnityAnimationHDRPExamples list
I think at a glance it looks like a good amount of functionality, but like almost zero editor tooling
I also feel that its further along than they are letting on regarding package is highly experimental imo no more so than any of the other entities packages even way back, but the blocker for me until now is that the samples just werent updated at all(entities has always been updated in tandem with samples) so for a year or so couldnt really follow along with it and develop any understanding as the package kept changing.
- also the (dots) anim team for whatever reason is far less active on the forums so communication is difficult,
- far less people using it unlike main entities package in the early days,
- also only forum for communication also houses discussion on regular animation stuff, kinematica and the new rigging package,
all these things make learning dots animation almost impossible for a layperson like me
This is an odd question, but, ยฟIs possible to fake a JobHandle?
For example, you can create an aritificial Task by using TaskCompletitionSource.
Is possible to do that with a JobHandle.
Sorry I just need to vent a little, the new change in the package removing visibility is complete bs, like why would you do it in the first place? Not only that, some of the packages that are still there DEPEND on the packages now invisible
Entities are now invisible in the package manager......
Or this one, depending on Collections, Entities and unity Physics which are all unavailable in package manager
Yeah, I agree @sour sorrel I thought that was a little strange to take out as well
@sour sorrel they did say the reason for it being hidden is so they could make a new category for alpha/experimental packages.
dunno when is that.
and, I agree, I don't know how this idea of hiding the packages instead of just doing the re-categorization anyway would help with people installing stuff that are experimental and then later on get complained on.
the same thing would happen anyway regardless if they were re-categorized or not
is there a way to call Complete() on all jobs updating in a particular ComponentSystemGroup?
I can't find a way. The jobs could be combined manually in a combinedependencies but i assume that's exactly what you are trying not to do.
Are there any Unity Physics experts around that can help me with this question? https://forum.unity.com/threads/unity-physics-parenting-help.997754/
whats the actual question, how to parent things using physics? also the last part can happen but i have to assume that manually doing conversion(or creation) of a collider at runtime wont give optimal performance at all
hello! If lets say in a system I create 100 entities using a commandbuffer and an archetype and initialize one of their component with a value increasing each spawn (0,1,2...99), if after that I do an Entities.ForEach, can I be sure the order will be the same? Will the first entity in the forEach have the value 0, etc...? Or it'll be random ?
I guess yes if I use .Run() but no if I ScheduleParallel
Looks like the creation order is the same as the entityInQueryIndex using Run(), Schedule() and ScheduleParallel
does anyone here know how to use Unity.Mathematics.Random from the main thread in a system?
how do I deallocate a native array on job completion when using Foreach().Schedule() ?
WithDeallocateOnJobCompletion or pass the job handle from the foreach (aka Dependency) into your container's Dispose method
thanks!
is there a way to have jobs only use worker threads and leave the render thread alone?
I have a costly job which makes my render thread stutter and lag, I want it to be offloaded to secondary threads so that the render thread isn't blocked
also, is there a OnStart() for jobs? what if I want to allocate a NativeArray only once at the beginning?
I think you're referring to systems.
best way I can think off is allocating it on OnCreate()
yes I was referring to systems, thank you
Has anyone experienced any issues with raycasts since the latest update? I am getting errors when using raycast inside of .foreach
IndexOutOfRangeException: Index 3 is out of restricted IJobParallelFor range [0...0] in ReadWriteBuffer. but there is only 1 index in the list. Works fine without parallel for now
My Entities have an IBufferElementData with references to other entities
How do I do that from an authoring perspective?
I.e. how can I make s.t. I create gameobjects in the editor, then have them reference each other and then convert that to entities referencing each other?
My problem is that in the Convert function I only have access to the other GameObjects, not the their entity representation
Does anybody know how to create your own entity command buffer?
@junior fjord The GameObjectConversionSystem which is passed into the Convert method has a method called GetPrimaryEntity which returns the entity representation of the component that you pass in as a parameter
@north bay thank you
How would I mark a gameobject in a subscene to not be converted?
And do the parenting-child relations of gameobjects in the subscene have any influence in the ecs?
@junior fjord I think there's a Convert To Entity (stop) component or smth that you can add to your gameobjects but I can't say how well it works - in particular, it stops converting at that point so it's children would also not be converted.
Ah ok but what is the supposed way to group gameobjects in the subscene then? Just for visual effects
I guess I probably wouldn't put them in the subscene to begin with? Don't think there's one great answer to this though.
Ok, then maybe I am understanding the subscene workflow wrong. I understood it this way: Instead of having GO with ConvertToEntity I put everything in a subscene in the edtior and serialize it to disc -> faster startup time
many years away from that unless you only have very simple stuff in subscenes
oh ok, then I will stop going into subscenes, thank you
what are the subscene usecases today?
This is just my opinion but I think it's far away from being a smooth experience. They're currently working on converting 'root' scenes whatever that means and a different prefab workflow. Stuff that's e.g. monobehaviour won't serialize or load any quicker if it's put in a subscene - only the stuff that's converted will be faster. So whether e.g. a ParticleSystem lives inside or outside a subscene I believe it won't be any quicker to load as it still needs to be deserialized. Same for e.g. Animators.
Main use-case atm I'd say is for e.g. putting a bunch of meshes in a subscene - this can make up a lot of the heavier content and load directly into ram basically.
Rather than trying to get your existing projects and hierarchies working in a subscene, I'd advise stripping out what can be converted (and putting just those parts in subscenes) and then focus on the interfaces between entities & GOs. Kind of vague and (to reiterate, just my opinion).
Ok, but putting all the GO that have a ConvertToEntity Component with ConvertAndDestroy activated into a subscene is a good idea then, isn't it?
if you want/need to go fast, yes. Though with everything you do that to, you add additional complexity in the interface part.
Ok, thank you for the explanation
I think I am fine with converttoentity for now then
Imo that's fine for now. If you have big self-contained sections that can almost all be converted, subscenes are worth considering. If you heavily mixed content (e.g. Animators, UI, Unity events, pfx etc ) then I think it's very painful right now (and so probably not worth it).
Do I understand it right that I need an authoring and a ConvertToEntityComponent?
How would I hinder the entity to have the converted "Transform" Components (Scale, Position etc)
Yes, an authoring component won't convert an entity by itself. You can't yet convert a GameObject without the Transform components. The best you can do is write a conversion script that either creates an additional entity or removes those components afterwards. I think they plan on improving this one day.
I thought if you added the StaticOptimizeEntity component (it's a monobehaviour) it would prevent transform stuff from being added during conversion
Could be remembering wrong
is there a way to limit the number of threads ECS can use? I want to have ECS use all threads except the render thread
oh I think @zenith wyvern could be right about that ... ๐
@odd ridge you can set max number of workers - I could be wrong but I thought the render thread was separate anyway? It appears to have it's own thread in the profiler.
@wraith bronze the entities docs have info on how to do that
@amber flicker oh sorry, I used the wrong wordings. I want the render thread to have a dedicated CPU core so to not lock the framerate. I will try what you said
iirc StaticOptimizeEntity only adds a localtoworld, not translation rotation scale
@odd ridge I don't think that's possible but I could be wrong. Nevertheless, I'm not sure how it relates to not locking the framerate.
@amber flicker with a heavy ECS load that spreads on all cores, the render thread is waiting on queues which hurts the framerate
My expectation is that the render thread is waiting on the main thread for reasons. My guess is by having less workers it will be slower overall. I could be wrong.
@wraith bronze the entities docs have info on how to do that
@safe lintel I only found this page, which not does tell you how you create your own https://docs.unity3d.com/Packages/com.unity.entities@0.14/manual/entity_command_buffer.html
i've been looking online quite extensively but can't find any info on it
or I am just too dumb to find it ๐
if you could point to a resource explaining how to implement my own custom entity command buffer, would be greatly appreciated
currently doing this
[ExecuteAlways]
[UpdateInGroup(typeof(ServerActiveSimulationSystemGroup), OrderFirst = true)]
public class BeginServerSimulationEntityCommandBufferSystem : EntityCommandBufferSystem { }
but throws memory leak warnings whenever I queue commands in here
Unsure if you need ExecuteAlways. Also fyi OrderFirst = true may not be working - there was a recent thing on the forums about this. Unsure if it's fixed in entities 0.16. Otherwise that looks basically ok to me. Your errors may be related to what you're trying to do with it in the system?
errors go away when replacing it with another default ecb
are you playing back the buffer immediately using .run because you might need to dispose of the buffer
you mean this right? entityCommandBufferSystem.AddJobHandleForProducer(Dependency);
is there a way to run code after the authoring is done but before the systems run?
I am doing this at the end of my systems when I have added commands to it
ah nevermind i dont think what i said applies in this instance
whats the memory leak warning and the code where you use the commandbuffer?
Internal: JobTempAlloc has allocations that are more than 4 frames old - this is not allowed and likely a leak
@junior fjord fyi you can run conversion scripts in one of three phases (before, during & after conversion)
Internal: deleting an allocation that is older than its permitted lifetime of 4 frames (age = 15)
my guess is this has little to do with the buffer and that the reason the warning goes away is a timing issue.
ah ok. I want to run some code after the conversion is done (the entities exist now), but before the main game starts (the systems)
actually calling ecb.Dispose(); fixes the memory leak warnings
I never had to do this before whenever using a default ecb
how are you using it? afaik thats only when you create a buffer that isnt connected to a particular system
@junior fjord I assume you want to do this at edit-time rather than runtime? If so you can use GetPrimaryEntity(someGameObject) to get another gameobject's converted entity and/or you can have your conversion script run in the after phase I guess.
No, I want to do it at run-time. Basically I want to first create all the entities with their components (have done that part) and afterwards run some more scripts that do some work on the already created entities
I was not able to find a good representation on what is executed in what order at startup
Are the MB startup functions executed after the conversion is done or before?
I'd advise against trying to plan around the ordering of MB's & systems at start-up - I believe it changes in editor, when a subscene is open or not and in builds too. What is the actual problem you're trying to solve if you don't mind me asking? Everything that can be done at edit-time is generally a good idea to do. If systems require your entities to be in a specific state, just e.g. add a tag that they require and add it at the first frame after initialization.
how are you using it? afaik thats only when you create a buffer that isnt connected to a particular system
@safe lintel I made a quick test script:
[ServerWorld]
[UpdateInGroup(typeof(ServerActiveSimulationSystemGroup))]
[DisableAutoCreation]
public class NpcDeathServerSystem : SystemBase
{
private BeginServerSimulationEntityCommandBufferSystem entityCommandBufferSystem;
protected override void OnCreate()
{
base.OnCreate();
entityCommandBufferSystem = World.GetOrCreateSystem<BeginServerSimulationEntityCommandBufferSystem>();
}
protected override void OnUpdate()
{
var beginSimEcb = entityCommandBufferSystem.CreateCommandBuffer();
Entities.ForEach((
in Entity entity,
in NpcDeathComponent npcDeathComponent,
in HealthComponent healthComponent) =>
{
beginSimEcb.DestroyEntity(entity);
}).Run();
entityCommandBufferSystem.AddJobHandleForProducer(Dependency);
}
}
basicly anything that I add to this buffer doesn't happen, and unity throws memory leak warnings
I feel like I am missing a step
do I need to manually execute the commands in the buffer or anything?
(ignore the DisableAutoCreation attribute, the system is being created from somewhere else)
I am using DOTSNET for networking, but I don't think that should influence how a new ecb works.
I can't see anything obviously wrong with that as is ๐ค - so you add beginSimEcb.Dispose(); in the update and no warnings?
No that was a mistake actually, it still throws warnings
yep looks like it should work? if it can be extracted into a repro project, id bug report
yea... in that case I'm still suspicious it's a timing issue.
wait if you use schedule does it also give a warning?
oh good point
if you are running then i dont think you need that ecbsystem
It can still be useful to prevent structural changes in the middle of your update
I'd advise against trying to plan around the ordering of MB's & systems at start-up - I believe it changes in editor, when a subscene is open or not and in builds too. What is the actual problem you're trying to solve if you don't mind me asking? Everything that can be done at edit-time is generally a good idea to do. If systems require your entities to be in a specific state, just e.g. add a tag that they require and add it at the first frame after initialization.
@amber flicker I am simulating a small economy basically. I have sectors, which I create in the Editor. Now after I start the game, I want to create "Companies" (that belong to sectors). Basically I use the sector-entities as "configuration templates" and randomness to create some companies.
This step of creating the companies needs to be done after the conversion is done (The Sector Entities are created) but before the game actually starts
Actually it just needs to be done after the sector entities are created and their components are set, thats it (I need to access the components of the sector entities)
no you dont need to create the ecb from a system, you can create an ecb like
var ecb = new EntityCommandBuffer(Allocator.Temp)
and then dispose right after running
ecb.Dispose();
the reason why I want to use a ecb is because other commands like removing/adding components are also stored in a end simulation ecb, so if I immediatly destroy the entities here and now I get errors when the end simulation ecb plays that the entity doesn't exist
Nothing is jumping out that seems like it would cause an error from just the code you posted. Are you 100% sure this is the source of your error?
(aside, I think if you use Allocator.Temp you don't need .dispose)
so my approach is to add/remove components in end sim, and destroy entities in begin sim
@wraith bronze if you use .Schedule instead of .Run does it also give the warning?
but since everything is running in serveractivesimulation, i need a custom ecb
@wraith bronze if you use .Schedule instead of .Run does it also give the warning?
@safe lintel yes, I am trying ScheduleParallel now
In particular I'm wondering if AddJobHandleForProducer is doing anything with .Run()?
tbh I also don't know
wonder if its a netcode issue, but im too lazy to test this out
yea if the way I am creating my ecb is correct, i think it's dotsnet complicating things
I think entityCommandBufferSystem.AddJobHandleForProducer(Dependency); isn't actually adding a JobHandle. Curious if Dependency = Entites.For..... ).Schedule(Dependency); beforehand makes a difference
it still gives me warnings if I try that
๐ then I'd try and repro this in a new project - feels like something else is going on
anyway thanks guys for helping! atleast I know a little more about what might be the issue ๐
Hey, I'm getting this error when running a job:
InvalidOperationException: The previously scheduled job WorldGrid:UpdateChunkJob writes to the Unity.Collections.NativeArray`1[Cell] UpdateChunkJob.chunkWithNeighbors.NorthEast.cells. You are trying to schedule a new job WorldGrid:UpdateChunkJob, which writes to the same Unity.Collections.NativeArray`1[Cell] (via UpdateChunkJob.chunkWithNeighbors.SouthEast.cells). To guarantee safety, you must include WorldGrid:UpdateChunkJob as a dependency of the newly scheduled job.
Is it possible to just ignore that error somehow? I can guarantee myself It's thread safe
๐ perfect, thanks!
Do we have any recent info on Navmesh implementation for DOTS?
"Hi, I don't have any news. It's still too early to talk about a preview package."
posted by an employee https://forum.unity.com/threads/dots-navigation.758690/ ๐
I'm trying to get a flow field path finding system to work in dots
Imagine I want to do some calculations on 10 000 entities but only on specific condition (if, for example, the player clic a button), is it "the correct way" to add a component tag to those entities that will then be used by a entities.foreach loop, or is it too heavy ?
how often is it done, imo if its many times every other frame just having a bool thats enabled/disabled will be better than adding/removing tags. but if the frequency isnt that great, tags might make more sense
Does the condition affect all entities or only a subset?
Or put differently, which entities are affected by the click?
All of them? A certain number? Previously selected entities?
If it affects all entities, you should use a singleton entity with the state, or (more dirty, but simpler) put it directly on the system.
If it affects only a subset, it depends on how the subset is selected. For example, can an entity move from a subset to a different one?
It can be every 1-10 seconds so not something happening frequently frame-wise. And yes it affects every entity (its a grid, with 10k entity each representing a cell, all changes affect all cells), but I feel like adding/removing a tag will be more expensive than just iterating through a DynamicBuffer linked to a singleton for example. What do you think ?
Man, i just updated entities/etc.. and getting these kind of exceptions all over the place: ArgumentException: Index 2 is out of restricted IJobParallelFor range [11...11] in NativeStream.
Some of which I can understand why they would be an exception and require a NativeDisableParallelForRestriction some I really don't understand.
Like I have a NativeStream.Writer iniside a IJobChunk and I call MyWriter.BeginForEachIndex(chunkIndex); and that blows up with such an exception...
@proper silo actually what hodhandr said, if its a click or something I would get the input data on the mainthread and use that as a field in the job and then drive logic from there
i see, will try, thanks !
with latest dots packages, I now get this on each project startup
I thought the point was to cache these, but now it's doing even more work
I haven't checked if this is alpha release issue or issue with Burst 1.4 preview
hmmm, package manager also only show 1.4.0-pre.1 for me but 1.4.1 is actually out already ๐
(still happens with Burst 1.4.1 release)
I've got a few silly questions perhaps, but as a non-programmer Dots is a bit of a black box.
Currently using 2D render pipeline to make a game that needs to run in browser.
- Dots / project tiny is still webgl right?
- Can we use dots/ecs with the 2d render pipeline and all the new stuff like 2d lighs?
- Can we use some dots / ecs code in an existing project. (to optimise cpu load)
@waxen glade
- ) I believe there is webgl support.
2.) I'm not sure with project tiny, but with DOTS its currently not supported.
3.) no. dots/ecs stuff is a pain to interact with mono. you're better off really, choosing one or the other.
Thanks!
whats the actual question, how to parent things using physics? also the last part can happen but i have to assume that manually doing conversion(or creation) of a collider at runtime wont give optimal performance at all
@safe lintel
Sorry for the late reply.
I'd build the privatives ahead of time as prefabs / ghosts, so they should be converted with the meshes fine.
Assembling an object out of those primitives and parenting them at runtime is the question.
at this point, I'm just going to try it and see what happens.
the DOTS way
i can see two simple solutions: copy the "parent" transforms to whatever translation/rotation you want as a child(i do this for my ragdoll stuff), or use a stiff/fixed joint
but I think the former might lag a tiny bit because its like a late update, i think plugging it directly into the physics sim would make it more accurate but I dont know how to do this
I wonder if Unity.Mathematics is faster than the older Mathf if you use it only in main thread?
someone checked and I think on average it is like 10% faster or something
Ok, thx
Along with Unity 2019.1 and Burst, the Unity.Mathematics package is now out of Preview. It offers alternatives to longstanding core types in Unity such as Vector3, Matrix4x4, and Quaternion. Today weโll see how switching to these types can improve performance in Burst-compiled...
so.. anyone had a chance to test out those animation samples? feels like im still at square one for understanding them(cant get rootmotion to work on a simple clip player)
I want to make my entity 'walk' on top of the terrain. how do I read the height of the terrain from inside an ecs job?
Is there a dots equivalent to Physics.CheckSphere as I can only find examples for cast sphere?
I guess that would work but I would think that it produces a lot of unnecessary overhead
ye, probably...
Depends on the internal narrow phase implementation.
As far as I know, it uses GJK
Static Sphere-box and sphere-sphere can be made faster than GJK equivalents I think...
just found that maybe a PointDistanceQuery with the maxdistance of the sphere radius might work
But in the general case GJK is really good anyway.
Ill keep it in mind as a fallback then
AI... lets say we want to let our mob-entity be controlled by some sort of stupid game ai. Normally those ai implementations use state machines... how do we implement ais in an ecs environment ?
if you want to make ai in ecs, it depends what kind of ai you want to use
if you are asking how to implement state machine ai in ecs, you can use tags to make a state machine
changing the tag would be the equivalent of changing an enum value for a switch in a state machine
Just a pretty stupid one... it should wait till a player is nearby and then follow him for attacking ^^ Most statemachines i saw are scripts on their own... but thats not possible in an ecs environment, components shouldnt contain methods ( pure ecs )
