#archived-dots
1 messages ยท Page 115 of 1
Okay, but you still haven't answered my question of why you can't just convert the gameobject as you enter the game
I mean, just a prefab reference
i think converting something during gameplay is against conversion workflow๐ค
Yeah, that's what I've been saying
you can convert everything you need at "build" time to subscenes
Look at the samples with the rotating cube, they have some conversion examples
I think you linked to the wrong time ๐
just start from beginning๐
and codemonkey made good video about subscenes i think๐ค
do I understand it right that the system run after system just makes the systems run after each other but not the scheduled jobs?
and is this the right way if I want the job of System B to run after System A?
System A
inputDeps = Dependency
systemADeps= Entities....Schedule(inputDeps)
//somehow pass systemADepsto systemB
System B
inputDeps = Dependency
deps = JobHandle.CombineDependencies(inputDeps, systemADeps);
outDeps = Entities...Schedule(deps)
Dependency = outDeps
//somehow pass systemADepsto systemB this thing is automatic
Dependency thing is passed between systems
and there is default sync points like Begin-End SimulationEntityCommandBuffer
Unity's ECS system will basically make one long chain of dependencies that they handle, and are passed between all your systems. This way, it can handle how the jobs will be scheduled automatically, and that the jobs that use the same components will be run in the same order the systems are run in. So essentially there are 2 timelines, one with your systems and one with your jobs. In simple cases, the jobs will have a 1:1 timeline to the systems, but in more complex cases, some jobs are not dependent on each other, so they can be run in whatever order. But if they depend on each other, then as long as your systems schedule them in the right order, the job system will take care that the jobs are scheduled in the same order. Now, they can run whenever they can, but it will be guaranteed to be in the same order
I've tried sort of visualizing it here
System1 produces job1 etc
As you can see, Job2 and Job3 will run at any point after Job1 have run, in any order, as they do not depend on each other
But Job4 depends on both, as they writes to the same components
ok thanks very much
and thanks for the nice graphic
not that I currently need it but in case they would not access the same components, how would I make the jobs run in the right order?
Well if they don't access the same component, then there's no need for them to run in the same order, that's the beauty of it. It will run when there's resources available
haha sorry didn't want to react with a knife
๐
yeah but say they would access some other ressource like nativearray
and I would want it to happen in the right order allthough they access different components
In that case it's not just a matter of ordering. You need to explicitly include the first systems job handle with JobHandle.CombineDependency
Unity only handles component dependencies for you
Otherwise you need to handle dependencies yourself or the safety system will throw exceptions
Exactly, that's where you gotta handle them yourself, by at least chaining the dependencies or combining them, since NativeArrays are 100% managed by you as a developer
(except the safety system)
@zenith wyvern did I do it right in my above example? wait I'll quote it again
But if you just set up the dependencies correctly, then the job system will take care to run them in the order, and they will be dependent on each other
and is this the right way if I want the job of System B to run after System A?
System A inputDeps = Dependency systemADeps= Entities....Schedule(inputDeps) //somehow pass systemADepsto systemB System B inputDeps = Dependency deps = JobHandle.CombineDependencies(inputDeps, systemADeps); outDeps = Entities...Schedule(deps) Dependency = outDeps
@junior fjord
like this?
JobHandle.CombineDependencies(inputDeps, systemADeps); this is unnecessary ๐ค
Since you're already passing the inputDeps to the .Schedule() function, then they're already combined
That's the right way to handle the dependency in the case that System A and System B are both accessing the same native container
And those will also be passed automatically by JobComponentSystem between your systems
but how does it know then that I want SystemB to wait on SystemA?
What I am doing is this: I want to create a texture every frame. Since I cannot use Color or Texture2D in the scheduleparallel, I do everything with nativearrays in SystemA
SystemB should run afterwards on the main thread and basically convert stuff from the nativearray things into Texture2D etc
Then you need to add the [UpdateAfter] attribute on SystemB
but SystemB actually only needs the nativearrays, it doesn't even need any entities hmm
SystemA
inputDeps = Dependency
//your work here
Dependency = inputDeps
SystemB
inputDeps = Dependency
//your work here
Dependency = inputDeps```
but isn't that the same as just doing nothing?
WIth the code as is, yes
How does SystemB now know to wait on SystemA if they don't access the same components (or SystemB does not access any components at all actually)
You can use Color in a job. If you wanted Unity to handle the dependencies for you you could convert your texture to an array of color, push that into a dynamic buffer and work with that inside a job. In another job you can query the buffer, get your color data and do what you want with it, including pushing it back into a texture
Dependency from systemA is passed to systemB
this SystemBase stuff is confusing ๐
@zenith wyvern but how would I do it if I don't want unity to handle the dependencies, somehow I just don't get it
how do I explicitely tell systemB to wait on the main thread until the job of systemA is done, even if they don't access the same components
You would do it with the code you posted above. Include the final job handle of SystemA in the SystemB. Unity will run SystemA jobs. When those jobs are complete, Unity will run SystemB jobs
ah ok, so the combineHandle thing I did was not unnecessary?
ok great if it is like that then I think I kind of got it
If both systems are accessing data that is not being handles by Unity, then yes CombineHandle is necessary
Isn't that what's happening when you pass in the JobHandle to the .Schedule() parameter?
That was at least my understanding
That the new JobHandle you get out of it is the chained dependency
is it a good way to pass systemA deps to SystemB by just setting the JobHandle as a static variable of SystemA?
why do you need to manually pass dependency?
It doesn't need to be static, you could just make it a public variable and access it with World.GetOrCreateSystem<SystemA>.FinalJobHandle
because both access the same nativearray but not the same components
ok perfect thats even better right
thanks
scheduler handles native array thing
Your way of doing this seems overy complicated
inputDeps = Dependency;
NativeArray b;
jhA = new JobA{Acces a}.Schedule(inputDeps);
jhB = new JobB{Acces a}.Schedule(jhA)
Dependency = jhB ```
SarkToday at 16:42
You can use Color in a job. If you wanted Unity to handle the dependencies for you you could convert your texture to an array of color, push that into a dynamic buffer and work with that inside a job. In another job you can query the buffer, get your color data and do what you want with it, including pushing it back into a texture
@warped trail We're talking about separate systems
SystemA
Write to Global NativeArray
SystemB
Read from Global NativeArray
That code results in a safety system exception unless you manually handle the job handle like we're talking about.
I also just read that I can access a textures Color array as nativearray, which makes my problem even easier I think
now all I need to do is execute a tiny amount of code (texture.apply()) after SystemA is done, do I still need to setup a SystemB for that?
SystemA
NativeArray b;
inputDeps = Dependency;
jhA = new JobA{write to a}.Schedule(inputDeps);
jhB = new JobB{write to a}.Schedule(jhA)
Dependency = jhB
SystemB
inputDeps = Dependency;
jhA = new JobA{read from a}.Schedule(inputDeps);
jhB = new JobB{read from a}.Schedule(jhA)
Dependency = jhB```
You know, you could probably chain job them in a single system, 1st job would run with scheduleParallel and 2nd job with Run ๐ค
trying to handle dependency through systems doesnt sound like a common approach
I don't create any unwanted sideeffect with everything waiting for that system then?
it seems as if that would mean that as soon that the system is executed, the job has to be executed too and unity could not actually manage parallel running?
but maybe I should just get going and worry later ๐
i mean.. if you are writing to a native array in Job A, and want to read it in Job B, for a correct behaviour Job B needs to wait for Job A to finish first, otherwise there will be race condition
so that means Job B has to depend on Job A, which is what job chaining means, which can be easily done in a system
you are doing that by passing jobhandle from JobA to JobB
yes
The parallelism doesn't come in this sort of system, as you will always have dependencies. It really begins once you have more than 1 "task" to do, and you have multiple systems that each handle different things.
So talking about it in a simple case like this doesn't make much sense
this discussion made me wonder about something tho, what if we use a global native array for System A and System B, will Unity be able to recongize them schedule it properly ๐ค
@opaque ledge The answer was just posted before you asked your question ๐
oh ๐
@zenith wyvern What if you pass in Dependencies in SystemB's .Schedule()?
so this code gives an error ?
@zenith wyvern And say Dependencies is equal to that
You mean the Dependency property?
Yes
Unity is literally already doing that automatically. It's the whole point of hiding the job handle
Hm okay, so the way to fix this would be to have SystemA's jobhandle be accessible, and then get that in SystemB?
In SystemBase Job.WithCode(()=>{}).Schedule is functionally equivalent to Dependency = Job.WithCode(()=>{}).Schedule(Dependency)
Yes exactly
Hm, okay. But I guess that's just one of the limitations of working with global arrays then
Or at least multi-system arrays
Yes, and it can quickly get out of control. Much more preferable to write your data into components or buffers and read it by querying for that instead
That way Unity handles the dependencies for you
Yeah, that was my thought as well. Then you also have the automatic dependency handling
๐
What happens if you write that array to a shared static instead ๐ค
Hmm, I'm not sure. I've never used SharedStatic before
Shared Static to access static mutable data from both C# and HPC#
@zenith wyvern if all I want to do is to execute some small code on the main thread after SystemA is done, is it still the best way to do two different Systems and work as above? (either with explicity dependence management or by using some component for example a dynamicbuffer to let unity do it)
@junior fjord I think so yes. It's kind of annoying but it's your only option other than manually forcing the job to complete
If you want to do it on the main thread though I think you would actually have to manually force it to complete first
no actually does not have to be main thread, I just have to be able to use a Texture2D and do tex.apply()
after I changed the texture2D.GetRawData in SystemA I need to do tex.apply() somewhere, I don't think it has to be main thread (or does it since it uploads to GPU?)
go with Schedule, if tex.apply gives you an error go with Run ๐
It probably does need to be main thread. I think if you want to force something to run on the main thread after a job you have to change your strategy a bit. You can't "Schedule" main thread to run after a job, you need to do
if( jobHandle.IsComplete )
{
jobHandle.Complete(); // Must be called manually when the job is done
// Do the work meant to happen after the job is complete
}
You can do that wherever you want, but yeah
That's what I do in my rendering system when I need to upload my mesh data. You basically need to think about where your sync point needs to happen and force it yourself
I could just use one of the existing sync points I guess
all my systems run in the simulationGroup and the texture thing just needs to happen afterwards
Could do, you can schedule your job early in the frame and force the sync point just before rendering.
This thing is confusing to me. So if you schedule this jobs inside one system everything ok, but not ok if this job are scheduled in different systems๐
so dependencies are passed between system with some magic?
or is it because nativearray is not inside system?
Basically Unity tracks how systems are accessing components/entities and figures out dependencies for you. It doesn't track when systems are accessing anything else, so you need to account for those cases yourself
If you forget about systems for a second and think about the code I posted but replace the systems with manually running two jobs in sequence, it would have the same result (dependency system exception) unless you completed the first job first, or included it as a dependency of the second job.
https://pastebin.com/8CY6zLnW this runs perfectly fine๐ค
Because you're including the dependency in the read job
If you do the same code but don't include the dependency in the second job (which is basically what my code was doing but via systems) then you get the dependency error
but shouldn't all dependencies from previous system be in Dependencies?
No, from Unity's perspective the two systems are not connected in any way
If SystemA was writing to a component and SystemB was reading from that component type, then Unity understands there's a connection and automatically sets the dependencies accordingly
i thought that Dependency from one system is passed to another๐
Only if they're writing to components/entities and then reading components/entities via queries
how does unity actually know which components are written/read before executing the systems?
You'd have to dig in to the source to figure that out
so in the end this Dependency is not long continuous chain of scheduled jobs๐
No, otherwise there would be no concurrency
The safety system needs to know what's being accessed where so it can schedule jobs in parallel accordingly
@zenith wyvern going down that road is always the best way to waste time I should spend on programming my game ๐
where do you guys dispose the nativearrays on application quit? I tried doing it in a monobehaviour in OnApplicationQuit but that gives me warnings since it disposes before some jobs are completed
you can .Dispose(JobHandle)
how do I get a JobHandle that contains all currently running jobs? I just want to dispose everything when I quit the application
you can do that by overriding OnDestroy in your system's class
I don't know if there is such a thing. What drUiD posted is normally how you do it, you pass in the final job handle that uses the container to Dispose
So in the last system to use it you can just do Dispose(Dependency) in OnDestroy
ah ok now I understand how it is meant, thanks
at least now i understand why it is not so convenient to work with physics stuff ๐
why? ๐
I have the luck that my game is actually 2d only with 3d models (top down), so I hope to circumvent having to read through physics
They use native array a lot๐
now i wonder if physics and future systems will ever be easy to use or there will be a couple small windows between a lot of closed systems where you would be able to do your regular ECS stuff ๐
Yeah I'm really curious how they end up handling physics. The FinalJobHandle and passing around systems stuff feels so awkward, but maybe that's just how you have to do it
does anyone know why this here: https://pastebin.com/FBuzP2Z1
gives me InvalidOperationException: <>c__DisplayClass_CalculateNeighborHoodWaterInflow_ForEach.Data.cdGroundHumidity is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type. ?
I marked it as readonly and only write to the entity I am currently using
i think public ComponentDataFromEntity<GroundHumidity> GroundHumidityFromEntity; this is unnecessary ๐ค
oh yeah it is, it is just something that I tried before and did not work
thanks
but I think it is unrelated to the error
Regarding the error you need to pass read only containers to a Foreach with WithReadOnly(container)
HOLY DOTS HYBRID RENDERER BATCHING BATMAN!!!
Ok the performance ceiling is ridiculously high. I need to increase my scope by a magnitude of 10. Scope creep? Scope avalanche!
@warm panther Pretty insane, and that's not even with HRv2
speaking of hybrid ECS-- is the relationship between GO Update() timing and the job system(s) documented anywhere? I want to park things in a chunk archetype buffer and read them in a GO's Update() but need to ensure write visibility
(for VFX pooling)
@warm panther Pretty insane, and that's not even with HRv2
@bright sentinel Yeah I am pretty happy. (and yes shared component data makes soooo much sense to me now ^^) Also, Dots physics is a beast.
@sour ravine All it says in the docs are
SimulationSystemGroup (updated at the end of the Update phase of the player loop)
if only stacking was a thing ๐
You can always go check the source
I'm making a space game, most areas are extremely sparse. But... this is my current performance sandbox, that's 3 models, 400 vessels total, being pulled into a singularity at the origin. Even when they start forming a very compact ball, it stays at 30 fps in the editor.
because thats absolute perfect use case for the current ECS renderer
I can't believe it's not Homeworld 3 4
rendering many of the same meshes is where it excels at
^^
it was made for megacity, which is like 10-20 assets multiplied by 10000
Isn't the "Saved by batching" there referring to the SRP batcher?
the srp batcher is really cool
Well it's SRP with hybrid renderer, so it lays out the data correctly for the SRP batcher to do its thing.
I'm pretty happy with where things are going.,
I'll be happy when we get per instance data in URP
on my potato pc with havok at 48hz i can run at 60+ fps 5-6k colliders@warm panther ๐
@bright sentinel most of the documentation seems to be referencing JCS OnUpdate() and not the MonoBehaviour ๐
you can look at full playerloop in EntityDebugger
I think they are more interested in where that loop is called in the grander picture of Unity
i think there is everything๐ค
No, because it doesn't tell you where in the Unity main loop the ECS systems are called from
Does Fixed Timestep have any impact on Unity Physics?
No unfortunately Physics are currently frame dependent
i may be wrong, but i think this is exactly what ShowFullPlayerLoop do๐ค
I'll have to check that out
@warm panther you have to force Physics to update in fixed timesteps yourself๐
I actually prefer variable timesteps at this time.
Though I wonder how I would simulate multiple physics worlds.
That kinda works well with Scenes, but I am porting my stuff over to ECS
Omg the full player loop is really damn useful, thanks. Never saw that before
That should be more accessible in standard Unity ๐
And then the main problem I'll see is moving entities between words, and tying entities with RenderMeshes to entities with Translations in other Worlds.
I'm a bit confused though, if physics are tied to framerate, how are you supposed to do anything useful with it?
Haha oh dear
you have to set fixedDeltaTime to target fps
(I'm a bit of a frame rate snob, tbh)
@warped trail Isn't it supposed to be the other way around?
#if !UNITY_DOTSPLAYER
float timeStep = UnityEngine.Time.fixedDeltaTime;
#else
float timeStep = Time.DeltaTime;
#endif
``` this is from stepPhysicsWorld
shriek
what's UNITY_DOTSPLAYER supposed to mean
UNITY_DOTSPLAYER: Standalone DOTS (vs hybrid DOTS) - for example, if you use UnityEngine, you want #if !UNITY_DOTSPLAYER
I think the only support for that currently is Tiny
it is DOTS.Runtime
i think it is basically another engine๐
The only thing I really miss with ECS right now is being able to properly select and inspect/modify objects in scene view in play mode. I hope there's some kind of API to select the entity automatically in the entity debugger at least.
I'm looking into the mouse picker from the samples
@warm panther You can still change the original gameobject when you have LiveLink set to editing mode
That will then propagate to the entity
Via livelink
Hey is what I'm saying correct?
An archetype is a set of components, archetypes are stored in the same chunk.
A chunk is a continious line of Data in memory
Removing one element(one instance of an archetype) leaves behind an empty field in the chunk
@warm panther Well it should already be there, since you just need the scene view/inspector and game view
So does livelink work with prefab stages?
those contain the most things I'd like to tweak
@formal scaffold Not quite, but close. An archetype is a set of component. Each chunk can only have 1 archetype, but there can be multiple chunks with the same archetype. This is because chunks is a block of memory of max 16kb, so archetypes can be spread over multiple chunks.
Not exactly sure what happens when you remove it though
@warm panther What do you mean "prefab stages"?
Thanks for the input ๐
Who decided to make a chunk 16kb? Is there some sort of rule? Is it CPU dependend because of cache lines? If I only have entities with the Translation component this should mean my implicit archetype is only Translation. Looking up floats, they seems to be using 4bytes, so Translation uses 12bytes.
12bytes for a 16kb chunk seems like a huge waste. Or do I understand this wrong?
@bright sentinel I mean when I edit stuff in Prefab mode, and have livelink on, does that transfer, especially when these prefabs aren't in any of the scenes or subscenes directly, but used through IDeclareReferencedPrefabs
That would massively rock.
Ah, then no, unfortunately not right now
Ok.
I'll try out livelink in my next session, I'll research how to roll my own PhysicsWorlds now.
@formal scaffold If your archetype is 12 bytes, then your chunk would contain 16k/12=1365 components
@formal scaffold chunk i like a pool of objects, creating an entity is basically just setting the values in one of chunk's field
not a pool, more like array i think๐ค
Starting to understand this ๐ง good good
Maybe its because of size of L1 cache ? they have low amount of memory, like 16kb, 32kb etc
so if Unity is able to put whole chunk in L1 Cache...
Definitely something to do with cache size
yeah I do not believe the 16kb size is magic in of itself
most caches/page sizes tend to be integer multiples of that, so every invalidation can (in theory) get your money's worth
pardon the bad pun
l1 caches tend to be 32k, i think 16k on phones
memory pages are 4k at minimum/default size
its kinda arbitrary, really
they said they wanted to eventually have a smaller chunk size, for when you only have like a couple of entities
Question - is it generally acceptable to add or remove systems at runtime?
(occasionally - e.g. once every couple of seconds)
likely no, if only because EQ's are usually a better tool for that kind of thing
EQs are innately data-based
as in, looking INTO a component's fields, not just at the presence thereof
What Are You Doing, Really
chunk data might also be more appropriate
change tagging, too
if you want to separate entities to different chunks based on value of component, thenSharedComponentData may help you
I'm trying to figure out a way to run multiple Unity Physics simulations in parallel, and to "move" entities between them. I don't think creating a whole new World makes a lot of sense, but seeing how the unity physics systems are built, these should be customizable enough - if I figure out an efficient way to query for those entities.
The number of potential physics worlds is unfortunately unknown, probably will cap it at < 100. The worlds are generally very sparse (space game) but I'd like to simulate as many as feasible at the same time.
sharedcomponentdata!!!
Thanks.
That's the solution.
(or a start ^^)
if you're trying to do a bunch of independent physics sims it almost sounds like you want to skip the shared collision element entirely
what do you mean?
I'm not sure, that's what I'm asking about.
if you want everything to not interact with other things, why not skip all the maintenance associated with creating bounding hierarchies, etc. and just use 'dumb' custom physics components
maybe recycling some of the Unity Physics spring integrators or whatnot
I want everything to interact with things in its own frame of reference. (I'm building a floating origin system around this, so think of it like an "arena" you can pop into and have a physical manifestation in). My initial approach with collision groups (in DOTS) and layers (in classic Unity) didn't work well enough, because I have 3 or 4 types of interactions/layers. What did work was using normal Scenes with their own worlds in standard Unity, but ECS lends itself very much to my game idea, and also it is a learning and passion project ๐
using Unity.Entities;
namespace Jovian.Components
{
public struct Instance : ISharedComponentData
{
public int Value;
}
}```
I guess it'll be something like this.
And my own version of BuildPhysicsWorld : JobComponentSystem etc.
transforms fundamentally already do this
I'd say that seems like a case for worlds, but I haven't really worked with them
How?
I mean how do transforms prevent two objects in the same location from colliding ๐
they don't, just depending on your needs you already have 'local' coordinate systems
and unless you write double-precision variants I'm not sure what re-implementing the Unity system accomplishes for composition
Not for physics, and I know what you mean but I want a pretty large world (real life scale Jupiter system), meaning I built a floating origin system that I'm trying to bring over and scale to work with ECS.
I only need double precision for bookkeeping, I am totally fine with confining everything to a 100x100x100 units cube for actual gameplay.
I wonder whether changing sharedcomponentdata doesn't thrash a lot of the chunks.
it will, it's a full entity copy on change
it changes RARELY; but not that rarely.
not necessarily, no
I'm used to coding with the Entitas ECS, there you express a lot of logic by adding and removing components.
adding and removing arbitrary component types (this is not the same as setting component data) is not considered a 'happy path' in Unity
Hmm
it's a structural change
Good to know.
you change the chunk the entity lives in, which you implement by copying the component data
So I guess I need to express a "null" state in components like targeting data, waypoint data, etc.
if they're light components then no sweat
it might be viable
this is just the Mike Acton thinking about data
I'd say the sharedcomponentdata for which "instance" an entity is physically in changes maybe once every few minutes, per primary entity. But there are probably around 500 of those. Still, I don't think the computer should even break a sweat.
I agree it makes sense in the Unity ECS for physics to work in the chunk level, which you can do via shared components
I think I need to have them on a lot of secondary entities though, because I would use the same system to cull renderers when there is no observer in the respective instance. (by disabling the RenderMesh-holding entities entirely)
The nice part is...
(or I should probably write my own rendering system but I'd hate to do that at this stage - going the easier way and I still have a lot to figure out about how I translate my physics solution into DOTS)
I wish there was a good way to disable RenderMeshes. Maybe copy them into a holding component. But that's potentially hundreds of SharedComponentData changes at once then.
the rendering part seems like a good fit for BatchRendererGroup but that's intended for MonoBehaviour usage
can I set components like this
compA.propertyX = 4?
I vaguely remember something like you should make a copy and then reasign the whole component, i.e.
compA = new compA {propertyX = 4}
I'll look into splitting my entities with a sharedcomponentdata for now, and sort out the queries for that.
but that was a long time ago and I am not sure if I remember right
@junior fjord no, you must reassign the whole thing (this makes more sense when you understand EntityCommandBuffer and archetype changes)
ok so like I did in the second line?
ref stuff excepted in specific jobs
No you can assign it directly if it's by ref
^^ (so, to be fair, It Depends)
Well if you're going to be changing the value, why wouldn't you do it by ref anyways?
ComponentDataByEntity<> is by value iirc
Ah that's fair
buffer stuff is also pretty much always by value too
Basically yes
and ComponentDataByEntity makes a copy?
yep
ok thanks
pointers actually do exist in C# but that's a topic
ref is not exactly a pointer in the same way an object reference is not exactly a pointer but it gets the idea across
ah no, its by ref, you can modify them
yeah I think I understand how a ref works
basically a pointer with the everything hidden away and you cannot reassing the pointer variable itself?
can I somehow step through my game frame by frame?
@junior fjord You can use a debugger with a breakpoint, which you know will only run once per frame (e.g. start of any system OnUpdate). You can then just continue playing it every frame
Or you can do that
The button next to the pause button is a frame step ๐
@warped trail thanks man never used that button ๐
thats perfect
@bright sentinel yeah but somehow if I use the Rider debugger unity always freezes
I've never used it either, for 8 years of Unity use ๐
Ah yeah, that's a limitation of the debugger unfortunately, because it's the same loop that the editor uses
So you can't really use it if it's frozen by the debugger ๐
but be carefull it may step with Maximum Allowed Timestep
yeah I cannot see the mesh drawn which is what I want to see
when using rider
@warped trail good to know but I actually need to step frame by frame since the water flow simulation I do does not use a timestep
I want the water to instantly equilibriate so I did not multiply with dt
@junior fjord You could try to manually use Debug.Break() at the end of the frame instead, maybe using some hotkey or something
And then everytime you wanted to continue, you just unpause, and your code should then pause again at the right moment
If you place this in a System that updates at the very end of the presentationgroup, it should work
Or maybe even somewhere later
Not sure if that will solve it though
I think the stepper button is perfect for now
does anyone have an idea why this:
var random = new Random(seed);
Debug.Log("Using seed " + seed);
Debug.Log("First random int is " + random.NextInt(100));
gives me different seeds but always First random int is 0?
you need to give it BIG seed ๐
I'd just use the current UNIX time
That way you will 99.99999% guarantee it's a new seed for everyone
And 100% if it's the same user
Unless he somehow plays a game and restarts all within 1 second
And plays long enough to notice that it will be the same.. ๐
no this should not depend on the size of the seed
I want to keep the seed fixed while developing that is not the problem, but the first random integer should not always be 100
You can give current time as seed
or call UnityEngine.Random when you are constructing Mathematics.Random
@warped trail you are right, a big random seed gives different result
this is not how I remember that random number generators should work ๐
thanks
hello. I was wondering if someone might help explain something to me. I'm getting this error in my project but it's also in the DOTSSample:
is there a different/better/proper way to do the "convert to client server entity" script for a subscene?
or does it indeed do nothing even in this case here and maybe the DOTSSample isn't updated?
or what's going on here?
sorry I'm very new to this and I"m just trying to wrap my head around the basics here
It's a good question I'd also like to know the answer to. SubScenes seem to be the way forward for conversion, but I'm not sure how that will be handled with NetCode, as they have their own conversion flow.
But since you're in the DOTSSample, is that how they do it? Or is that something you tried to do yourself?
Because if that's how they do it, then I guess that's the way to do it..
kk
I havn not quite put it togeather
I guess I"m trying to put it togeather myself now
not seeing any issue so far but, was maybe trying to skip some self science
the client to server script seems to only convert if on either server or client as selected
I dunno
I was just asking whether that is how you downloaded the project, or if you added the ConvertToClientServerEntity component yourself?
I guess I can run the sample and see if it creates entities on the server
nah that was in there
I changed nothing
should be vanilla DOTSSample from like a week or two ago tho :S
oof it wont run ๐ฆ
I guess the unity upgrade broke it
Ah yeah, you gotta stick to what they say to use ๐
Huh?
im tryin to figure out if it's creating entities on the server
I guess it shouldn't because it's set to client
I dunno like... gamemode exists as an entity in both the server and the client world
maybe there's a different gamemode elsewhere in this scene that goes on the server
I'm going to try it with a simple project instead of trying to figure this out. too many moving parts in DOTSSample
thanks though
ok I mean you're right Bmandk. The way the DOTSSample has it works. I mimic the same thing with a cube. When I set to server, I get that error up top but it does make it not get created on the client so yeah
seems like a display but but it's not breaking the script. it does indeed run the one on the gameobject
I wonder, is there some way to change the "convert to entity" script used on a specific subscene or something?
lol ok removing the convert to entity script from DOTSSample results in everything working just fine XD
it seems the server-only entities are created programatically so this script isn't used for any server-only stuff in this sample
I get the top error if I try to put the ghost collection into a subscene, and I get the bottom warning if I try to put the ghost authoring prefab into a subscene. The DOTSSample doesn't have this issue but I can't figure out why. I'm curious why this is?
moving everything into the main scene works fine
tbh it doesn't seem like NetCode is quite ready for SubScenes yet
Which would kinda suck
I was actually planning to do all this testing tomorrow, but nice to know what to look out for ๐
aight well im just starting out so I can just make my stuff inside my main scene for now until things are ironed out hehe
how do i create my own barrier system ๐ค
is it depracted, every link i found is dead links
should i just create normal command buffer and just run on the entity manager after job finish ๐ค
Got it, gotta inherit from EntityCommandBufferSystem, idk why but system didnt initialize so i had to do GetOrCreateSystem in order to retrieve it
@opaque ledge on the forum people are saying that the field Dependency won't carry external dependencies over the next system, which was my understanding as well initially. I will need to do some serious test for this
@scarlet inlet Note, the JobHandle only includes dependences for component data, not native containers. If you have a system or job that reads data in a native container populated by another system or job, you must manage the dependency manually. this is from ecs documentation๐
link please?
and what manage dependency manually actually mean? Like passing myself the jobhandle between systems?
yes
also I don't think that sentence in the documentation is correct
they didn't mean JobHandle, they meant the actual Dependency field, right?
the JobHandle can carry other dependencies
I know but reading it like that it looks like I can't ever using whatever JobHandle to carry other dependencies
Note, the JobHandle Dependency field only includes dependences for component data, not native containers. If you have a system or job that reads data in a native container populated by another system or job, you must manage the dependency manually.
they should have phrased like that right?
Anyway I am glad I have the final answer
thats why physics systems have this FinalJobHandles
that was my understanding as well
Hello, I have a question that if I add dynamicBuffer to an entity which already has a dynamicBuffer, what would happen? Would it just override the data of the exists one?
Is this meaning that I don't need to worry about that an entity whether has this type of dynamic buffer before I add? What about the API SetBuffer? what is the difference between AddBuffer?
SetBuffer is explicity for overriding, it will give you an error if that component doesnt exist, AddBuffer simply adds the component if it doesnt exist, if it exist then overrides it
shoot^^
If I new a NativeArray ArrayA and use a temp NativeArray ArrayB to equal ArrayA . Then I dispose ArrayB. Will the data of ArrayA still exists?
no, they will point the same native array, if you dispose one, you dispose the other
I see. So I don't need to dispose the tempArray if I want original array still exists. Is that right?
Yeah
Ok, Thank you.๐
Although, you do probably want to dispose of it somewhere ๐. Usually in OnDestroy.
So, Dependency thing is not carrying info about nativearrays does that mean that i can't use physics query outside of BuildPhysicsWorld-EndFramePhysicsSystem window?๐ค
Although, you do probably want to dispose of it somewhere ๐. Usually in OnDestroy.
@amber flicker Yeah, done already ๐
probably Druid
everything is alright you can use them outside that window๐
ParallelFor jobs can be only scheduled on Main Thread?
aren't they?
Can I schedule a parallelFor job to create multiple IJob?
Another question is whether is Entities.ForEach a parallelFor job?
IJobParallelFor jobs don't run on the main thread unless you call them with .Run
Can I schedule a parallelFor job to create multiple IJob?
@south falcon
https://docs.unity3d.com/Packages/com.unity.jobs@0.2/manual/scheduling_a_job_from_a_job.html
IJobParallelFor jobs don't run on the main thread unless you call them with .Run
@zenith wyvern Thank you. Is parallelFor job only created on main thread?
Read the links
ok, thank you
public class BadTests : MonoBehaviour
{
public GameObject prefabGO;
// Start is called before the first frame update
GameObjectConversionSettings settings;
Entity prefabEntity;
EntityManager entityManager;
void Start()
{
// Create entity prefab from the game object hierarchy once
settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, new BlobAssetStore()); // error here if i use null instead of new BlobAssetStore, i don't know why?
prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(prefabGO, settings);
entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
int CountX = 100;
int CountY = 100;
for (var x = 0; x < CountX; x++)
{
for (var y = 0; y < CountY; y++)
{
// Efficiently instantiate a bunch of entities from the already converted entity prefab
var instance = entityManager.Instantiate(prefabEntity);
Debug.Log(x + ", " + y);
// Place the instantiated entity in a grid with some noise
var position = (new float3(x * 1.3F, y * 1.3F, 0.0F));
entityManager.SetComponentData(instance, new Translation { Value = position }); // positions are not set
}
}
}
}```
"Prefab" only has mesh renderer + filter
This code is almost the same as the example entity instantiation code
My instantiated entities always end up having same pos in my screen at 0,0,0
But in entity debugger, i see their transforms having different values?
What is going on you think?
translation is changing but LocalToWorld is not?
give me a sec, i broke something
translation is applied to LocalToWorld in TRSToLocalToWorldSystem which updated in SimulationSystemGroup
try setting LocalToWorld in your script
yeah, that works
interesting
what's the purpose of Translation and rotation component then?
Are they supposed to be their parent's transform info?
Translation is just for translating in local space?
Like a tag* component?
it is more convenient and performant to work with float3 and quaternion than with 3 float4x4 matrices ๐
hmm
i would expect a 4x4 transform matrix and some extension methods to access it as quaternion rot, translate vec and scale vec
so this is just duplicate info
i think you can do this if you want๐คทโโ๏ธ
yeah thats what i'll do
oh, but physics use translation and rotation components, not LocalToWorld๐ฌ
I'd recommend working with Translation, Rotation & Scale when possible and understand the sequencing/timing of when they're resolved to LTW - otherwise at some point you may find your LTW just gets overridden by something else
Does that AddComponent override the data in the entity which already has the same type of componentData?
Yes
For me setting Translation directly works, i never had to work with LocalToWorld for spawning position ๐ค
and you never experienced instantiated object at world origin for 1 frame?๐
i used to, but i am using BeginSim command buffer for that now, i think problem is gone after that ๐ค
you just have to make sure your systems run before unitys group that updates the transforms. [UpdateBefore(typeof(TransformSystemGroup))]
it would be nice if unitys group sorting took this into account automatically, cause right now pretty much everyone hits the issue at some point
@mint iron i watched the video you sent the other day, and i wanted to conduct an experiment for false sharing
i wrote this test code:
public struct TestIncrementStruct : IBufferElementData
{
public int Value;
}
if (UnityEngine.Input.GetKeyDown(UnityEngine.KeyCode.D)) useOptimized = !useOptimized;
if (useOptimized)
{
Entities.ForEach((ref DynamicBuffer<TestIncrementStruct> test) => {
var array1 = test.ToNativeArray(Allocator.Temp);
var intArray1 = array1.Reinterpret<int>();
for (int i = 0; i < intArray1.Length; i++)
{
intArray1[i]++;
}
test.Clear();
test.AddRange(array1);
}).WithoutBurst().Schedule();
}
else
{
Entities.ForEach((ref DynamicBuffer<TestIncrementStruct> test) => {
var intArray1 = test.Reinterpret<int>();
for (int i = 0; i < intArray1.Length; i++)
{
intArray1[i]++;
}
}).WithoutBurst().Schedule();
}```
Why is the VS Code 1.1.4 plugin still an option when it doesn't work generate projects correctly? No namespaces for any of the new DOTS plugins.
when optimized its like 15 ms(on 500k array size) when its not its taking 130 ms ๐
ofc this probably wont apply to any real life situation but it is nice knowing this
tho i guess Burst already takes cares of the stuff for us but still, kinda amazing to see
Even in Burst it affects, for 10m size, in unoptimized its 2-3 ms, in optimized its 0.04 ๐
Hello again, I want to throw an exception if a JobHandle is default(JobHandle) or equal to another JobHandle
is the only way to do so checking if two jobhandles have the same bits?
because == doesn't work
Hmm I'm wondering if they an implementation of .Equals(JobHandle other)
i never tried but perhaps you can wrap it to a struct and give each struct a unique id
not according to here
Yeah that's no good ๐ค
Need to leave, I'll try to find a solution tomorrow
Can i debug and detect some "probably infinite loop" in my ecs stuff?
I think there is an infinite loop occuring in my simulation system group
(i have some other systems added to that group as well)
Could i have created a deadlock in dependencies?
I barely touched the system group:(
The system dependencies will error if you have a cycle
Oh god , my stack tracer is tracing some serious stack
I'm glad this isn't such a thing then
and it's afaik impossible to create a cycle of jobs given the current API
Yeah, as long as your JobDebugger is enabled
but not sure what happens if you have an infinite loop in inside of your job
it will wait forever on Complete()
I found out that i was forcing the SimulationSystemGroup to update 3k times
by luck
but hm
I breakpoint the loop that's causing it but it doesn't stop at the breakpoint
you can do Debug.Log in all of your jobs and just observe before crash, its a poor man's way tho ๐
but i guess you manually update your systems yes ? maybe there is a problem in your logic
I'll just randomly breakpoint simulation system group stuff i guess
yeah i do manually update my simualtion system group + a couple systems in that group
I can stop the debugger and switch between threads
But i can't see stack trace in any of them
Hmm, i can actually see some
I need to see the main thread though (only that one will make sense to me)
I breakpoint the loop that's causing it but it doesn't stop at the breakpoint
made sure burst is turned off and job debugger is on?
how do i use a NativeMultiHashMap exactly?
doin something like this throws this error : ```ArgumentException: Unity.Collections.NativeArray1[System.Int32] used in native collection is not blittable, not primitive, or contains a type tagged as NativeContainer Unity.Collections.CollectionHelper.CheckIsUnmanaged[T] () (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/CollectionHelper.cs:124) Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData.IsBlittableAndThrow[TKey,TValue] () (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:72) Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData.AllocateHashMap[TKey,TValue] (System.Int32 length, System.Int32 bucketLength, Unity.Collections.Allocator label, Unity.Collections.LowLevel.Unsafe.UnsafeHashMapData*& outBuf) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:80) Unity.Collections.LowLevel.Unsafe.UnsafeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/UnsafeHashMap.cs:1097)
Unity.Collections.NativeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator, System.Int32 disposeSentinelStackDepth) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/NativeHashMap.cs:499) Unity.Collections.NativeMultiHashMap2[TKey,TValue]..ctor (System.Int32 capacity, Unity.Collections.Allocator allocator) (at Library/PackageCache/com.unity.collections@0.5.2-preview.8/Unity.Collections/NativeHashMap.cs:493)
Sense.MotionEngine.MotionEngine..ctor (Sense.MotionEngine.MotionEngine+Configuration configuration) (at Assets/Sense/Motion Engine/Common/MotionEngine.cs:64)
MotionEngineManager.Awake () (at Assets/Sense/Motion Engine/Common/MotionEngineManager.cs:30)
can't put NativeArray into a NativeHashmap
all the Native* collections are not blittable
Burst is off but it's still creating worker threads
Maybe there's a way to have ecs work on a single thread for debug purposes.
I'll have to look at it tomorrow
@xzjv#1282
@worldly pulsar https://stackoverflow.com/questions/52460051/unity-job-system-and-multi-dimensional-arrays
i got it off here , no clue still how is NativeMultiHaspMap is supposed to work
how do i add multiple values to a single key?
referred to this , still don't see any method that specifically adds new values to an existing key
all i want is an array of array sort of native container
after some research , i was lead to NativeMultihashmap
@naive parrot I haven't worked with NativeMultiHashMap, but considering that there is nothing named NativeHashMap, I'm assuming the NativeMultiHashMap is just like a normal hashmap
Oh wait
The search is just broken
Oops
there is a NativeHashMap
yayaya
will take a look
in NativeMultiHashMap you can do:
hashmap.Add(1, 1);
hashmap.Add(1, 2);
and there will be 2 records in it for the key 1. Normal hashmaps are 1 key - 1 value. Haven't used it since forever tho so don't remember the API.
Keep in mind NMHM is slow as hell if you abuse it. Check the boids sample to see a good example of how to use it with jobs
Ah, so it's basically a way to store lists in a hashmap
I'm not sure if the order is guaranteed
@worldly pulsar thats exactly what i am looking for but maybe i am stupid but the doc here says something weird for Add method or am i reading it wrong : https://docs.unity3d.com/Packages/com.unity.collections@0.5/api/Unity.Collections.NativeMultiHashMap-2.html
"Add an element with the specified key and value into the container. If the key already exist an ArgumentException will be thrown."
If the key already exist an ArgumentException will be thrown.???
Uh, was there another method for adding more values at the same key? Again, haven't used it for ages.
Square bracket operator
https://youtu.be/p65Yt20pw0g?t=2323 this is explanation how they read NativeMultihashMap in parallel
thanks , checking
i was wondering if there jobs friendly animationcurve or something that can be evaluated inside jobs
have checked this thread but nothing concrete
additionally am not working with ECS , only Jobs, so the BlobArray being mentioned there is probably not applicable either
https://github.com/leonardo-montes/Unity-ECS-Job-System-SPH/blob/master/Assets/Job System/SPHSystem.cs and there is another example how you can use NativeMultihashMap ๐
Heh, I just spent 20min figuring out why in the piece of code @opaque ledge posted here:
https://discordapp.com/channels/489222168727519232/497874303463850004/684092062445862912
it is 3x faster to alloc a new array, memcpy the buffer into it, work on the copy, and then memcpy back into the buffer...
Answer - because writing to a dynamic buffer is way slower than writing to a NativeArray due to the "are we in chunk" check.
i'm testing this code right now, and i'm not getting this results๐
I'm testing with Burst and Run()
maybe because im doing it with testrunner๐ค
class TestSystem2 : SystemBase
{
protected override void OnUpdate()
{
Entities.ForEach((DynamicBuffer<TestIncrementStruct> test) =>
{
var intArray1 = test.AsNativeArray().Reinterpret<int>();
int len = intArray1.Length;
for (int i = 0; i < len; i++)
{
intArray1[i] = intArray1[i] + 1;
}
}).Run();
}
}
class TestSystem3 : SystemBase
{
protected override void OnUpdate()
{
Entities.ForEach((DynamicBuffer<TestIncrementStruct> test) =>
{
var intArray1 = test.Reinterpret<int>();
int len = intArray1.Length;
for (int i = 0; i < len; i++)
{
intArray1[i] = intArray1[i] + 1;
}
}).Run();
}
}
Test3 runs in 22ms, Test2 in <5ms
its better to do AsNativeArray then ? @worldly pulsar when working on dynamic buffer ?
@zenith wyvern in what way NMHM is slow exactly ?
It's anecdotal but it was my experience that NMHM operations just didn't scale well. I can't explain why because I didn't perform extensive profiling but I've heard similar from other people who use it. As far as I know NativeStream is much faster, but a bit more complicated to use
Hmm i see
Heh, I just spent 20min figuring out why in the piece of code @opaque ledge posted here:
https://discordapp.com/channels/489222168727519232/497874303463850004/684092062445862912
it is 3x faster to alloc a new array, memcpy the buffer into it, work on the copy, and then memcpy back into the buffer...
Answer - because writing to a dynamic buffer is way slower than writing to a NativeArray due to the "are we in chunk" check.
@worldly pulsar
Can you do buffer.AsNativeArray() to get by the check?
There is a test if the "out of chunk" ptr is not null, and Burst compiles it to a cmov instruction which kills performance when the inner loop is heavy on DynamicBuffer writes. So yeah, I'd say pretty much always use .AsNativeArray() for DynamicBuffers
Good to know
are you using a lot of elements in this buffer?๐ค
yeah, 100 buffers of 100k ints each
for a lot of very small DynBuffers the difference will probably be overshadowed by the entity iteration overhead (in this very trivial example)
yep, 10 element buffers are pretty much the same speed, but at 100 ints/buffer there is already a 3x difference
thats super interesting guys, i wouldn't have thought dynamic buffers so much slower.
hmm what if you use a readonly ptr ๐ค
I wonder how much of an impact it would have ๐ค
the loop generated for native array is about as fast as it can get:
.LBB1_12:
inc dword ptr [rax]
add rax, 4
dec rcx
jne .LBB1_12
(without integer simd which Burst doesn't do right now)
what about if you stackalloc instead of temp nativearray
but why would you alloc anything? AsNativeArray doesn't alloc, it just turns a DynamicBuffer into a NativeArray (essentially a pointer wrapper)
AsNativeArray isn't causing any overhead
There's no reason not to do it since native arrays are super fast
var tempArr = test.AsNativeArray();
var len = tempArr.Length;
var A = new int4(0);
for (int i = 0; i < len; i += 4)
{
A = tempArr.ReinterpretLoad<int4>(i);
A++;
tempArr.ReinterpretStore<int4>(i, A);
}``` is this a valid code?๐
ahh, i was looking at the ToNativeArray one
Hey I'm trying to understand how archetypes are formed. And I understand the basics of it. But reading through this article
https://blogs.unity3d.com/2019/11/27/creating-a-third-person-zombie-shooter-with-dots/
the following line implies that you can create an archetype and add more components to it.
"The project uses prefabs for defining archetypes since there are more components needed for the enemies and some of them need references to GameObjects"
But won't adding components to an Entity change the archetype of that entity? Also the thing about defining archetypes with prefabs. A prefab uses a set of components and therefore defines an archetype. Or do they mean that during instantiation the EntityManager implicitly creates an archetype for them and therefore the prefab defines the archetype ๐ค
An archetype is just a set of component types. If you create two separate archetypes but both have the same set of component types, they are equal
So yeah, if you add a component to an entity it changes it's archetype, period
in you case of adding a component to an entity. they find/create an archetype with the new set of components, and copy the entity, and every component it has >> to the new archetype.
if you create archetype, does it automatically preallocate chunk, or chunks are allocated the moment you create entity of this archetype?
Mhm so in this case they use a prefab so they can store references better thats all they are saying with that line. And that the prefab they created defines the archetype for them. Meaning they don't explicitly create the archetype in code, they just instantiate their prefab.
Only when you create the entity as far as I know
Sorry language is not my strong point. I struggle all the time with what seems basic understanding of sentences
by creating first entity you basically create whole chunk?๐ค
You got it right Swift, they're basically just describing what the conversion system is now with [GenerateAuthoringComponent]. The conversion system wasn't around when that was written
Or if it was they should have been using it because it's exactly what they're describing
@warped trail Yes as far as I know that's how it works
Okay nice good point to go to sleep thanks ๐
this things doesn't have overhead too ReinterpretLoad<T>() ReinterpretStore<T>()?๐ค
@warped trail yes, if an entity exists a chunk has to exist to contain it ๐ they keep around empty chunks that were previously allocated so if you had no entities they would re-use an inactive/empty chunk first rather than allocating a new one.
thats quite a difference
What are you comparing?
test system2 and testsystem3 are the ones u posted
hmm, how many buffers/elements per buffer?
mmm, maybe my test is bad.
class TestSystem1 : SystemBase
{
protected override void OnCreate()
{
var arc = EntityManager.CreateArchetype(ComponentType.ReadWrite<TestIncrementStruct>());
var entities = new NativeArray<Entity>(1000, Allocator.Persistent);
EntityManager.CreateEntity(arc, entities);
}
protected override void OnUpdate() { }
}```
So your buffers are empty?
yeah
this is my results 100 entity with 102400 buffers๐
For 100k 1 elem buffers I get ~20% overhead from the .AsNativeArray() version, compared to ~300% overhead of writing to DynBuffer for 100 element/buffer.
Both of these would probably be small compared to whatever work the job was actually doing in a real world case.
Can anyone tell me why the name of a gameobject is retained and applied to its entity counterpart when I use ConvertToEntity, but not when I use subscenes?
Even when I try to force it with this component: ```using UnityEngine;
using Unity.Entities;
public class NameAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
dstManager.SetName(entity, gameObject.name);
}
}```
Can i call .Compete() on simation system groups update()?
I am the one who calls the update
I mean, can i wait for it to finish in monobehaviour?
Hello, quick question, why the scale struct has only float value param? How do you manage to scale X and Y differently (with an AddComponentData) ?
There is a NonUniformScale component
@solar spire that's perfect, thanks
## [Burst 1.3.0-preview.4] - 2020-03-02
### Added
- Debug information for types
- Debug information for local variables
- Debug information for function parameters
- Support for `fixed` statements. These are useful when interacting with `fixed` buffers in structs, to get at the pointer data underneath.
- A fast-math optimization for comparisons that benefits the [BurstBenchmarks](https://github.com/nxrighthere/BurstBenchmarks) that [nxrightthere](https://forum.unity.com/members/nxrighthere.568489/) has put together.
- DOTS Runtime Jobs will now generate both `MarshalToBurst` and `MarshalFromBurst` functions when job structs in .Net builds are not blittable.
- DOTS Runtime Job Marshalling generation is now controllable via the commandline switch `--generate-job-marshalling-methods`.
### Removed
### Changed
- Made it clear that the Burst aliasing intrinsics are tied to optimizations being enabled for a compilation.
- Restore unwind information for all builds
- Print a info message if compiling a function pointer with missing MonoPInvokeCallback attribute (this can lead to runtime issues on IL2CPP with Burst disabled). The message will be converted to a warning in future releases
### Fixed
- Fixed an issue where DOTS Runtime generated job marshalling functiosn may throw a `FieldAccessException` when scheduling private and internal job structs.
- Fix a bug that prevented entry point method names (and their declaring type names) from having a leading underscore
- vector/array/pointer debug data now utilizes the correct size information
- DOTS Runtime will now only generate job marshaling functions on Windows, as all other platforms rely on Mono which does not require job marshalling.
- `ldobj` / `stobj` of large structs being copied to stack-allocated variables could cause compile-time explosions that appeared to the user like the compiler had hung. Worked around these by turning them into memcpy's underneath in LLVM.
- Don't always use latest tool chain on certain platforms.
- Fix a crash when compiling job or function pointer that was previously cached, then unloaded, then reloaded
- Fixed compiler error in array element access when index type is not `Int32`
- Fix `set1_xxx` style x86 intrinsics generated compile time errors
### Known Issues
- Native debugger feature is only available on windows host platform at the moment.```
heh, that last change for printing info messages about mono invoke now spams console full with latest entities package
DOTS Runtime Jobs will now generate both 'MarshalToBurst' and 'MarshalFromBurst' functions when job structs in .Net builds are not blittable
Any info on what those are?
## [Entities 0.7.0] - 2020-03-03
### Added
* Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class. These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
* `SubScene` support for hybrid components, allowing Editor LiveLink (Player LiveLink is not supported yet).
### Changed
* Fixed an issue where shared component filtering could be broken until the shared component data is manually set/added when using a deserialized world.
* Users can control the update behaviour of a `ComponentSystemGroup` via an update callback. See the documentation for `ComponentSystemGroup.UpdateCallback`, as well as examples in `FixedRateUtils`.
* `IDisposable` and `ICloneable` are now supported on managed components.
* `World` now exposes a `Flags` field allowing the editor to improve how it filters world to show in various tooling windows.
* `World.Systems` is now a read only collection that does not allocate managed memory while being iterated over.
* Updated package `com.unity.platforms` to version `0.2.1-preview.4`.
### Deprecated
* Property `World.AllWorlds` is now replaced by `World.All` which now returns a read only collection that does not allocate managed memory while being iterated over.
### Removed
* Removed expired API `implicit operator GameObjectConversionSettings(World)`
* Removed expired API `implicit operator GameObjectConversionSettings(Hash128)`
* Removed expired API `implicit operator GameObjectConversionSettings(UnityEditor.GUID)`
* Removed expired API `TimeData.deltaTime`
* Removed expired API `TimeData.time`
* Removed expired API `TimeData.timeSinceLevelLoad`
* Removed expired API `TimeData.captureFramerate`
* Removed expired API `TimeData.fixedTime`
* Removed expired API `TimeData.frameCount`
* Removed expired API `TimeData.timeScale`
* Removed expired API `TimeData.unscaledTime`
* Removed expired API `TimeData.captureDeltaTime`
* Removed expired API `TimeData.fixedUnscaledTime`
* Removed expired API `TimeData.maximumDeltaTime`
* Removed expired API `TimeData.realtimeSinceStartup`
* Removed expired API `TimeData.renderedFrameCount`
* Removed expired API `TimeData.smoothDeltaTime`
* Removed expired API `TimeData.unscaledDeltaTime`
* Removed expired API `TimeData.fixedUnscaledDeltaTime`
* Removed expired API `TimeData.maximumParticleDeltaTime`
* Removed expired API `TimeData.inFixedTimeStep`
* Removed expired API `ComponentSystemBase.OnCreateManager()`
* Removed expired API `ComponentSystemBase.OnDestroyManager()`
* Removed expired API `ConverterVersionAttribute(int)`
### Fixed
* Non-moving children in transform hierarchies no longer trigger transform system updates.
* Fixed a bug where dynamic buffer components would sometimes leak during live link.
* Fixed crash that would occur if only method in a module was generated from a `[GenerateAuthoringComponent]` type.
* `Entities.ForEach` now throws a correct error message when it is used with a delegate stored in a variable, field or returned from a method.
* Fix IL2CPP compilation error with `Entities.ForEach` that uses a tag component and `WithStructuralChanges`.
* `Entities.ForEach` now marshals lambda parameters for DOTS Runtime when the lambda is burst compiled and has collection checks enabled. Previously using `EntityCommandBuffer` or other types with a `DisposeSentinel` field as part of your lambda function (when using DOTS Runtime) may have resulted in memory access violation.
* Throw correct error message if accessing `ToComponentDataArrayAsync` `CopyFromComponentDataArray` or `CopyFromComponentDataArrayAsync` from an unrelated query.
hybrid update is just dependency upgrade
## [Collections 0.6.0] - 2020-03-03
### Added
* Added ability to dispose `UnsafeAppendBuffer` from a `DisposeJob`.
### Changed
* `UnsafeAppendBuffer` field `Size` renamed to `Length`.
* Removed `[BurstDiscard]` from all validation check functions. Validation will
be present in code compiled with Burst.
### Removed
* Removed expired overloads for `NativeStream.ScheduleConstruct` without explicit allocators.
### Fixed
* Fixed `UnsafeBitArray` out-of-bounds access.
ah cool - thanks for posting this @dull copper
## [Jobs 0.2.6] - 2020-03-03
### Changed
* Updated dependencies of this package.
* Maintain JobsDebugger menu item value between sessions.
np
So much stuff I still don't understand ๐ง gotta keep learning
Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class. These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
Interesting
yeah was about to say
I love these save-us-from-the-boilerplate changes
I hope we get something like that for command buffers too
getting bunch of these now even with the latest drop:
The method `Void RunWithoutJobSystem(Unity.Entities.ArchetypeChunkIterator*, Void*)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
it's from the burst change
yep
i wonder if accessing same component type from GetComponent and ForEach still gives an alias error ๐ค
* Added `HasComponent`/`GetComponent`/`SetComponent` methods that streamline access to components through entities when using the `SystemBase` class. These methods call through to `EntityManager` methods when in OnUpdate code and codegen access through `ComponentDataFromEntity` when inside of `Entities.ForEach`.
* `SubScene` support for hybrid components, allowing Editor LiveLink (Player LiveLink is not supported yet).
first one is absolutely huge
second one what exactly is it about?
like you can edit entities in the editor at last?
Is this type of query still being used ```cs
var query = new EntityQueryDesc
{
All = new[]{
typeof(Transform),
ComponentType.ReadOnly<Velocity>()
},
};
Or did Entities.ForEach replace it? Or am I missunderstanding how Job's work?
ForEach generates it's own query, but there are still plenty of reasons you might need to create your own query manually
Such as? If I need it twice maybe?
Like if you have a system that you only want to run when a certain component exists. You create a query for that component and pass it to RequireForUpdate in OnCreate
Or if you need to access any component or entity that's not a part of the entities you're querying in your ForEach
Or a million other reasons I'm sure
Is OnCreate being called every frame if the System is not yet running? I know It's called once upon creation and after that OnUpdate() every frame
Hmm, probably not, it only called once when its created, and perhaps multiple time for each creating for a world
Oh really? Just a few hours ago it was still at 0.1 was it not? I was reading through it during break at work
No, 0.1 was like last year. It's been updates almost monthly. Unfortunately google always points to the old version.
i can update systemgroups in fixed steps without editing package code๐ฅณ
Gosh really ๐ at least I still learned alot, been reading 0.1
https://docs.unity3d.com/Packages/com.unity.entities@latest Always points to the latest version
now i wonder when we will see new entity debugger?๐ค
Finally a nice page for SystemBase https://docs.unity3d.com/Packages/com.unity.entities@0.7/manual/ecs_creating_systems.html
@formal scaffold these are also in the pinned message on this channel
Is it possible to rotate an entity without a Rotation component? Trying to understand the zombie shooter with DOTS video on youtube. They use a single float for the rotation of their Zombies plus two floats for the position. But how does Unity know how to rotate the Zombie with just this one float? Don't you need a Rotation component for that?
maybe they use custom transform system?
maybe they are rotating only 1 axis ?
[WriteGroup(typeof(LocalToWorld))]
struct PositionAndRotation: IComponentData
{
public float2 Position;
public float Rotation;
}``` this and some simple system is everything you need basically ๐ค
Yes they do since they program a 2D game so one float is only being changed. But so far I have been rotating my Rotation component all the time
thats what they are doing as well probably
In order to rotate I need a LTW on my Entity?
LTW is for rendering system
i think you still need LTW ๐ค
Anyone got these errors after upgrading to Entities 0.7 ?
TRSSystem in simple case is doing this cs localToWorld = new LocalToWorld { Value = float4x4.TRS(translation.Value, rotation.Value, scale.Value) }
you can overwrite TRSSystem if you don't need float3 for position and quaternion for rotation
Let's say I do that won't I have to change the rendering system aswell? What you said earlier seems to imply that the rendering system relies on LTW
if you don't need scale you basically need translation and rotation matrix, i think๐ค
yes Hybrid Renderer relies on LTW
it does not matter how you will get this LTW๐
LTW is 4x4 matrix
I get it now.
- Use custom position + rotation and use Systems to work with those
- Overwrite TRSToLocalToWorldSystem to use my custom position + rotation to create a LTW
not create, but write to LTW
in simple naive approach you just create translation and rotation matricies, multiply them and write result to LTW
cos, sin and one 4x4 matrix multiplication๐
LTW fields are ReadOnly tho.
Can't I just set the values? I have them already. Something like LTW.Rotation = quaternion(...)
Can anyone tell me why the name of a gameobject is retained and applied to its entity counterpart when I use ConvertToEntity, but not when I use subscenes?
Re: Entity Conversions, I have an entity that changes materials based on a sharedcomponentdata (basically which faction they belong to); where do I start setting this up in IConvertGameObjectToEntity (or elsewhere) for a prefab Archetype that can then be used by spawners?
The materials are set on renderers in various child objects, so it's probably not trivial to set it again easily after conversion.
var renderMesh= EntityManager.GetSharedComponentData<RenderMesh>(entity);
renderMesh.material = material;
EntityManager.SetSharedComponent<RenderMesh>(entity,renderMesh);```
you have to do this on main thread
Yeahhh that's what I'm doing right now. But...
i think there is something with MaterialPropertyBlock in HDRP, but im not using HDRP๐คทโโ๏ธ
This is what my prefab is actually shaped like. Meaning all those renderers need their materials changed.
(admittedly this is one of the larger ships but it's not uncommon to have ~20 turrets etc)
I'm thinking giving each of these an allegiance field as well, meaning their renderers will just figure it out at runtime. It would also help with simplifying damage attribution.
The thing isn't per se setting these in Convert(), the thing is setting these in or after
(Entity entity, ref Spawner spawner, ref Translation translation, ref Rotation rotation) =>
{
while (spawner.timer <= 0)
{
spawner.count--;
spawner.timer += spawner.seconds;
var e = buf.Instantiate(spawner.prefab);
buf.SetComponent(e, new Translation {Value = translation.Value + (float3) Random.insideUnitSphere * spawner.radius});
if (spawner.count <= 0)
{
buf.DestroyEntity(entity);
return;
}
}
spawner.timer -= dt;
});
Because I basically never place any of these by hand, anywhere. ๐
(spawner.prefab is type Entity)
Problem is, that entity is the representation of what the Battleship prefab was. IDeclareReferencedPrefabs
It doesn't "know" much about its ability to change colors or materials, and even if it did, it would have to agree on at least one right there.
(out of ~5 to 8 material variants, spread across 2 materials per vessel)
I'll look into what ConversionSystem has to offer me.
Problem is, conversion happens once for each spawner. Since they refer the same prefab, that gets frozen in whatever state it was converted into.
Has anyone tried FixedRateUtils?
Can i not have rotations constraints in inspector with dots?
In physics bodies
i'm afraid you have to use joints for that๐
hmm
my name is bargos, welcome to jackass
https://gfycat.com/tenderdimpledcorydorascatfish
Didn't understand what was going on until i put some some renderers on my characters' physics capsules lmao
Huh.
/// Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
/// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
So how would rendermesh work then? OR anything, really.
I smell pointers.
Those are blittable ๐
void pointers, preferrably. always void pointers.
perhaps they will make ECS version of material ?
Unity.Jobs.LowLevel.Unsafe.JobsUtility.CreateJobReflectionData (System.Type type, Unity.Jobs.LowLevel.Unsafe.JobType jobType, System.Object managedJobFunction0, System.Object managedJobFunction1, System.Object managedJobFunction2) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Jobs.IJobParallelForExtensions+ParallelForJobStruct`1[T].Initialize () (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Unity.Jobs.IJobParallelForExtensions.Run[T] (T jobData, System.Int32 arrayLength) (at <94c5f4c38cdc42d2b006f8badef04394>:0)
Sense.MotionEngine.MotionEngine.Update () (at Assets/Sense/Motion Engine/Common/MotionEngine.cs:175)
MotionEngineManager.Update () (at Assets/Sense/Motion Engine/Common/MotionEngineManager.cs:58)```
getting this trying to write to a [WriteOnly] NativeList in IJobParallelFor
was checking how to do concurrent write with NativeQueue , NativeHashMap to no resolve
not sure how to use .Concurrent variants or the ParallelWriter
any hints?
/// Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
/// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
@warm panther
Where did you see this? Considering the hybrid renderer uses SCD with Meshes and Materials I'm not sure how that would work
maybe a comment in the source code?
@naive parrot Pass the list to the job as a NativeArray
Bull.
I forgot where I copied this from, but it was from Entities 0.6.0
As in, clicking into the decompiled source
literally the generated doc for ISharedComponentData
Huh. I'm trying to think of what the implications of that are. I guess pointers like you say, with some kind of safety wrapper
IComponentData.cs
// [TODO: Document shared components with Jobs...]
/// <summary>
/// An interface for a component type whose value is shared by all entities in the same chunk.
/// </summary>
/// <remarks>ISharedComponentData implementations are subject to the same constraints as
/// <see cref="IComponentData"/>.
///
/// ISharedComponent implementations must implement <see cref="IEquatable{T}"/> and <see cref="Object.GetHashCode"/>.
///
/// *Note:* Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to
/// restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
///
/// When you add a shared component to an <see cref="EntityArchetype"/>, ECS stores entities assigned the same
/// values of that shared component in the same chunks. Thus, shared components further categorize entities within
/// the same archetype. Use shared components when many entities share the same data values and it is more efficient
/// to process all the entities of a given value together. For example, the `RenderMesh` shared component (in the
/// Hybrid.Rendering package) defines a set of fields whose values can be shared by many 3D objects. Since all the
/// entities with the same values for the RenderMesh fields are stored in the same chunks, the renderer can
/// efficiently batch the draw calls for those entities based on the shared values.
/// You must set the value of a shared component on the main thread using either the <see cref="EntityManager"/>
/// or an <see cref="EntityCommandBuffer"/>. When you change a shared component value, the affected entity is
/// moved to a different chunk. If a chunk already exists with the same values, and has enough room, the entity is moved
/// to that chunk. Otherwise, a new chunk is allocated. Changing a shared component value is a structural change that
/// potentially creates a sync-point in your application.
///
/// You can find entities with a particular type of shared component using either <see cref="EntityQuery"/> or
/// <see cref="EntityQueryBuilder"/> in the same way you select entities with specific types of <see cref="IComponentData"/>.
/// You can also filter an entity query to select only entities with a specific shared component value using
/// <see cref="EntityQuery.SetSharedComponentFilter{SharedComponent1}"/>. You can filter based on two different shared components.
/// (EntityQueryBuilder does not support filtering queries by shared component value.)
///
/// Avoid too many shared components and values on the same archetype. Since each combination of values, whether in the
/// same component type or in different shared components, is stored in different chunks, too many combinations can
/// lead to poor chunk utilization. Use the Entity Debugger window in the Unity Editor
/// (menu: *Window* > *Analysis* > *Entity Debugger*) to monitor chunk utilization.
///
/// See [Shared Component Data](xref:ecs-shared-component-data) for additional information.
/// </remarks>
public interface ISharedComponentData
{
}
Of course that might be out of date.
It would sure be nice if we got those comments through the IDE
Yeh
The 0.7 docs say the same thing
i guess there is bug in FixedRateUtils or i'm using it in the wrong way ๐
hmm if they change ISCD to blittable types only
is a difference between ISCD and chunk component datas ๐ค
I suppose ISCD allows you to do filtering that you may not have in chunk component datas
hmmm the new burst / entities package doesn't like Unity Physics that much.
(0,0): Burst error BC1040: Loading from a non-readonly static field `Unity.Collections.LowLevel.Unsafe.UnsafeUtility.IsUnmanagedCache`1<int>.value` is not supported
Actually the package isn't updating properly
I'll investigate
Certainly doesn't crash less ^^
for me, it says its from JobParallelDefer from jobs package
it doesnt do anything harmful tho it as far as i can tell
everything fine in my project๐ค
@zenith wyvern thanx , that worked!
@round summit nice feature
they're all in their own canoe
all you need now is add some waterfalls
Trying burst 1.2.3 instead of 1.3.0 preview now...
Same
Omg the 2020.1 UI scaling feature โค๏ธ
I can finally read shit in the entity debugger
But my 3440x1440 screen isn't big enough.
Are you folks seeing as many crashes with burst as I am?
now you can have properly scaled crash screen ๐
jokes aside, there are some cases that simply crashes me some random some not
I'm not doing anything complicated, but seems to be stable for me
had one system that started erroring about the way I was using an ecb
InvalidOperationException: TurnJob.Data.cmdBuffer is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
You need to use a ConcurrentCommandBuffer in a parallel job https://docs.unity3d.com/Packages/com.unity.entities@0.7/api/Unity.Entities.EntityCommandBuffer.html#Unity_Entities_EntityCommandBuffer_ToConcurrent
@warm panther I can easily crash the editor with too many debug logs in a job, even with burst disabled and independent of project/machine - donโt know if anyone else has experienced the same?
Is this the channel to ask questions about C# Jobs?
Yes
I know this is super vague, but I'm trying to use NetCode with owner prediction on a cube and my cube is twitching. I'm modifying the physics velocity on it based on user input. Looking at the translation in ServerWorld shows the Translation is constant, but on the client the translation twitches a bit. changing from prediction to interpolation removes the twitching but obviously introduces latency. The twitching also occurs when there is no user input. What could be the culprit here? Where can I start looking?
maybe there's something else I should be modifying instead of PhysicsVelocity?
seems to be twitching forward in the direction of movement. increasing the send/recv delay amplifies the distance that it twitches
EntityManager.AddComponent<Constraint>(rb.entity); // no errors here?
Constraint constraint = new Constraint();
constraint.ConstrainedAxes = new bool3(x, y, z);
constraint.Type = ConstraintType.Angular;
EntityManager.SetComponentData(rb.entity, constraint); // error this line
Doesn't let me set constraint because Constraint is not IComponentData
How can i constraint the rigidbody?
better look at UnityPhysicsSamples๐ค
So i have this system that does 32 byte allocation every frame, but i couldnt find the reason why
.WithName()?๐ค
nah, i just added that 2 mins ago ๐
im going to try commenting out my code i think
have you profiled it in standalone build?
no, i have a potat pc that would take too much time ๐
i have no idea than๐
If you enable deep profiling you can drill down to the actual allocating function
If you're in the editor it's probably disposesentinel
Yep it was from dispose sentinel, thank you
new tiny packages now too
Quick guide and some additional notes on the new native debugging support for Burst. Available from package version 1.3.0-preview.4. Timestamps are below for convenience.
Timestamps:
[0:13] Quick guide to debugging
[1:29] Current Limitations
[1:33] Threaded Debuggin...
is there some kind of debugger or trace logging that I can enable specifically for debugging NetCode prediction?
is there any reference about ai in dots?. or anyone already tried ai planner with dots?
isn't ai planner done in ecs?
like the actual core of it?
I haven't really looked more into it
I know ml agents is going to get dots support later on but it's not in their short term (3mo) roadmap
i think you have to go hybrid
i wanted to try but yeah, so i am doing my own AI right now
AI Planner isn't dots yet
"Currently, we don't support a pure DOTS solution, though it is on our pre-GDC roadmap. First, we need to move the game state data to ECS, then we'll need to build component systems to manage plan and action execution. It's going to be quite an undertaking, but we have a concrete idea of how this will look. We're just going to need the time to build it. "
I didn't suggest it was, I just remembered it's core was done in ECS ๐ pretty much all the interfacing is still done through MB's
it currently depends on Entities 0.4
stuff like this will give you a dependency hell as you always have to upgrade packages yourself which Unity doesn't keep up-to-date
and you can't like mix older entities for one package and newer for some other ๐
what does "MB" mean in this context?
monobehaviour
my noob is showing
lol
So, i want to have ecs rigidbodies in my world (not parented to anything)
I want to be able to set their velocities, positions, rotations
From which conponent data i should modify these?
I changed transform related stuff in: LocalToWorld component data
I changed velocity here: PhysicsVelocity component data
And this is what i got
So it's completely broken
imo, to change rotation and position change Rotation and Translation components, dont deal with LTW
physics is using translation and rotation, ltw is basically for rendering๐ค
I see
physics writes to translation ant rotation components in ExportPhysicsWorld
Here i use : Translation, Rotation, PhysicsVelocity
TRSSystem takes translation and rotation and applies them to 4x4 matrix
I shoot arrow downwards, arrows hits and applies some force to capsule
Capsule gains some velocity
But that velocity seems to be in local space
Because my character drifts backwards relative to it's own space
Why do you think that's happening?
Could it be my fault?
no, don't say things like that. you're perfect.
are your capsules rigid bodies?
What is it you are expecting exactly ?
yes
I am costantly lerping velocity to zero with this interface:
public Vector3 Velocity {
get
{
return entityManager.GetComponentData<PhysicsVelocity>(entity).Linear;
}
set
{
PhysicsVelocity setVelocity = GetOrAddEntityComponent<PhysicsVelocity>();
setVelocity.Linear = value;
entityManager.SetComponentData(entity, setVelocity);
}
}
unity physics does not support stacking, in my projects rigid bodies are always drifting ๐
creating arrows too close to capsule, colliders fighting?
Arrow should not have effect anymore after collision is ended i belive, no?
Can't tell by gif if the arrow collision is having a continued effect ๐คทโโ๏ธ
is there continued velocity long after firing one arrow?
No, it's just a collision, arrow has no logic at all
It's not supposed to affect any longer after collision is done with
right, but that collision imparts an initial velocity to the player, no? if you don't want, you'd need to make sure the position you spawn the arrow didn't cause the colliders of both objects to intersect
maybe its about mass and Friction ?
Behaviour is like this:
If a collision applies force on my character,
My character seem to have that force saved and added back every frame from now on
And the force is cleared after it has moved the character
to be added back again the next frame
(It's not force though it's just PhysicsVelocity.Linear set)
Does that make sense?
well collision doesnt happen in 1 frame i think, so your collision job might be called multiple times
so it IS having a continued effect? I was asking because the gif seems to show it not
yeah, I'd say there is either another system writing to velocity or what curly said
There seems to be a constant velocity on character's local backwards axis yes
After the arrow has touched
Situation is the same after i collide with a different character too
both character sway in collision normal continiously (with constant speed) after
even though their velocities are lerped to 0 every frame
perhaps the lerping of the velocity to 0 is never letting the job reach its goal and finish?
hard to say for sure without the system code
My code is all in mono, i tried to port ecs physics into mono
It's basicly like this:
loop:
MyMonoStuffUpdate()
SystemSimulationGroup.Update()
i set PhysicsVelocity of white cube to zero every update
Hmm.
It gains speed for one frame, get's to apply it, then you set its velocity to zero and the cycle repeats
Probably this is happening?
I think thats normal?
probably yes, before simulation velocity is zero, simulations advances and cube gains little velocity
imo ? just put a Debug.Log for every possible situation, after that just check logs, thats how i find most of my errors
might need to [UpdateAfter]/[UpdateBefore] some system to make sure you apply velocity at right time?
before velocity is applied to LTW
I apply velocity in mono
SystemGroupUpdate
I apply velocity in mono
SystemGroupUpdate
I apply velocity in mono
.
.
Goes like this
velocity is applied to translation
its "SimulationSystemGroup"
I apply velocity in mono
SystemGroupUpdate
GetVelocity, translation - velocity
```๐
heh
you have to revert any undesired change in translation after simulation๐
MonoUpdate():
I read velocity
I lerp velocity to zero
I set velocity back
SimulationSystemGroup.Update()
repeat
This is what i do
lerp happens over many frames though?
your body gets velocity in simulation and translation+Velocity
one frame of mono = one frame of ecs physics
public void UpdateScene()
{
SimpleECSPhysics simpleECSPhysics = World.DefaultGameObjectInjectionWorld.GetOrCreateSystem<SimpleECSPhysics>();
simpleECSPhysics.Simulate();
for(int i = 0; i < syncedObjects.Length; i++)
{
SyncedObject syncedObject = syncedObjects[i];
if (syncedObject != null)
{
syncedObject.SyncedUpdate(sceneTime);
}
}
sceneTime += 1;
}
simpleECSPhysics calls the simulation system group's update
it Simulate()
it is not enough to set Velocity to zero before simulation๐ง
It's before the build physics world?
Or after export physics world
Depends of how you look at it
you have body with zero velocity and there is gravitational force, what will happen with this body after 0.02 seconds?
it will move
hmm, but whats at the place of gravitational force in my case?
I don't think that arrow still applies collision force?
Let me check what PhyscisVelocity says in entity debugger
After the arrow and befroe
and by just moving around
All right i found it
ECS physics is perfectly fine and not weird at all
Problem was just my incompetence
blink twice if a Unity Evangelist is making you say these things
Did i mention i was setting the rotation of my character every frame?
Well, i was doing that and not setting the angular velocity to zero as well
So it's always in rotating state in buildphysics world
and its reset every frame
This was my character pretty much
Except the paddle is my character's capsule you know
And it starts rotating after hit by something (to be never stopped )
I might've wasted your time, sorry
sounds like a quite an adventure ๐ gl out there
Seeing a lot of these after upgrading to Burst 1.3, even though I'm not building for IL2CPP:
The method `Int32 BeginSendMessage(Unity.Networking.Transport.NetworkInterfaceSendHandle ByRef, IntPtr)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
@remote coyote I think Networking is deprecated, so not sure it's compatible with Burst
This is Netcode, which is only Entities 0.6 compatible. I "could" wait for them on their next update, but took like 3 months last time ๐
my tests are still passing after updating the DOTS packages though
theres a post about that on the forums
Oh, got confused, my bad
its a temp workaround by the burst team
guessing so
i took a 3 month hiatus from coding, were there any big updates to DOTS that i should research?
just read the changelog for any package you update, in all honesty I dont think too much has changed but it also depends if you were current 3 months ago. SystemBase does replace ComponentSystem and JobComponentSystem and has a slightly different way of handling dependencies but the samples repo has examples
alright thank you!
I'm very confused. Is it possible for physics to be predicted with NetCode? or is NetCode prediction only meant for ComponentSystems I make myself (using GhostPredictionSystemGroup/PredictedGhostComponent)?
like for each prediction tick, the input Translation is the same. Then it gets new data from the server, the first prediction tick is moved compared to the server data, then it continues predicting ticks until the target and they are all the same Translation as the first predicted tick
How can I get the physics simulation to happen for every predicted tick? And if I do that, how would I prevent the physics simulation for the !GhostPredictionSystemGroup.ShouldPredict scenario?
or is the whole system just not meant for this?
๐ฉ
is there a better place I can ask these questions?
well it might be late for some of the people who know better ๐
but forums probably even better place to ask, many experts there
ok thanks
You're right Simoyd, no physics prediction yet.
"Added integration with UnityPhysics, including the lag compensation from DotsSample. To use it you must have the UnityPhysics added to your project." That's the only info in the logs, doesn't say anything about the rest though