#archived-dots
1 messages Β· Page 51 of 1
I've been having similar crashes, rarely hard though. Most are asset database dying and corrupting headers
notice the odd times? outside office hours
my 0.51 project rarely crashes at work
soon as i finish (or before work) and work in 1.0/2022
crash city
I don't know what they're doing with the baker but it's buggy as fuck
GOCS may be slow and clunky but it worked flawlessly
at least half of these seem to be in assetimporter
bakers aren't even that fast
good lord tertle, you have the patience of a saint
anyway, get rid of f1. crashes will be much less
you say that, but i may have had less crashes in f1
i can see from my crash logs there has been no difference
where are you getting them mostly? domain reloads?
nearly always asset related
i should just go back to working on effects library this nearly never crashes
because there are no assets
it's all virtual
mh, i guess that's the reason why i'm not having crashes. also no assets other than those that existed for years
i can see big gaps where i dont crash for a few days
and i load up git history and thats me working in effects
or updating core library etc
projects with no asset conversion
soon as i touch something with a lot of assets, instability
you've seen this from megacity!
why TIF?
lighting is really not great in megacity. everything that's in shadow is totally flat looking (oh and another crash, this time in editor)
oh a new one 32 GB are not enough π¦
This is the first line of the definition of Baking in the unity 1.0.0-pre docs "Baking provides a system for transforming GameObject data in the Editor (authoring data) to Entities written to Entity Scenes (runtime data)." What in the sam hill is that saying?
i also had a bit of hope that megacity would see a bit of an update. it's been 3 years and it looks identical. that said, it didn't look that great to begin with mainly because of lighting and view distance. there's really no wow effect here sadly π¦
and to not sound too negative about megacity. in the previous version i had to disable shadows because it was so expensive. now that's really fast.
did anyone open up a subscene and moved something around? that's happening at like 1 fps. opened up Section_00 and moved Wall_Section_00 around.
The incremental baking is really chugging when you try to do something in mega
hm, why would it bake constantly?
Lighting working in the first place is magical. Given the millions of vertices.
Moving things around in editor actually refreshes the values every frame. Which is why changing a value using a [Range] of a baked GO lags the editor. It baking every frame.
most of the vertices budget is achieved through instancing. it's really not that impressive imo
If you need to change something, type the value in directly. It'll still bake on every key stroke but that's far less than on every vector mouse movement.
hm, that constant baking feels like a design mistake.
be done, save -> bake
we can turn that off, right?
Yeah. Disabling the live baker should be an option. Type internal into the editor version window
Then instead of enabling live baking, disable it. That should (should) disable baking until you press play
ok, i hope unity realises that this live baking isn't working out.
The true awe inspiring feat is if they can enable raytracing.
that scene raytraced could be pretty cool
(just before crashing i took the screenshot) - i feel like this should go on for about 4 times. that would wow me π
but i'm probably unfair here. the scene is REALLY dense with detail
The LOD manager for megacity is a bit jank right now. So maybe
anyway, i appreciate such a vertical scene. more horizontal would have been still better
especially because it's more realistic for a game scenario and there are new challenges
loading a subscene is freaking fast. that's for sure
And far more traffic. At least the video I saw of it on the forums had the scene very empty. Or at least only a handful of cars
yeah, overall it's quite a shame they didn't make it more in a blade runner style. the skybox is bland AF
TBF, I think it's only 1 guy. Maybe a team of 2.
i'm pretty sure more than 2 were working initially on the scene. the scene is the same as it was in 2019
there was a video about the art of megacity back then. if it was really just 1-2 devs it's very impressive
Oh yea, the initial megacity definitely had an entire small studio behind it. Maintaining it for 1.0 is, my guess, a lot smaller
i haven't been judging it by the slightly dated visuals, but instead by the draw calls / verts i'm able to render
and better yet, how many are hidden
the reduced draw calls and how fast it processes a frame on the cpu is certainly an impressive feat. with the heavy use of instancing, the amount of verts don't say much though. there's a lot of repetition.
5,000 draw calls is still a lot
that's pretty cool
not that many batches though
a shadow cascade renders in around the same amount of batches (~25)
i hope i don't make the wrong assessment but that's my main point here: there's hardly any variation and not really representive of any real game world. the batches count in the stats window seems like total bogus.
most games struggle with too much unique graphic prefabs and there's really no good benchmark for this
if i see anything on the scale of AC valhalla from any studio i'll shut up π
but 80mb of mesh data impresses me just as much as the infinite detail demo that was floating around several yeara ago
time will tell how good and far this can be pushed
You can achieve variations through tricks
Random colors
For example
Or batched material that can switch texture by index
that live baking is awful on my pc in megacity
Question for the netcode folks because I'm too lazy to test myself, can I delete prespawned ghosts and then unload the scene they're a part of?
And question for dots in general, how do I save changes to subscenes that occurred at runtime so that if I reload that subscene, those changes get reapplied.
Also for netcode: how do I sync physics body and mesh changes?
Hellu, I'm trying to generate a bunch of meshes through the job system and the new advanced mesh api. I got the whole system working with a single mesh data extracted from Mesh.AllocateWritableMeshData(1), which is pretty nice. Now I wanted to generate multiple of those, so my plan was to change that 1, to let's say 10, create a single jobhandle for each of the items on the array, and then via JobHandle.CompleteAll or JobHandle.CombineDependancies(thearray).Complete() run each of the jobs
However, im getting an error like this, and I don't quite understand, how is that possible, the error comes from assigning data to the meshdata of the job
Are each of those meshdata not independent from each other? (so that modifying one doesn't affect the others), or must it be done another way? (instead of passing the mesh data to the job, pass the mesh data array as a whole)
As for reference
annoying that there is no OverlapBox or OverlapSphere in unity.physics, only OverlapAabb
There are collider casts
yeah but i think it means i have to manually build and store a collider, just to do a ColliderCast
unless i'm being an idiot and missing something in the api
Yea... it's annoying
some of the colliders have this stuff, but i'm not even sure why/what..
To be honest, I don't know if those work
say i wanted to do simple overlap box regularly, using different sizes.. i'd have to create a box collider each time for that? i must be missing something here
sorry to derail - hopefully someone can help with that
No worries, and thanks βΊοΈ
OverlapSphere and OverlapBox are in PhysicsWorld and do not require a collider
damnit i've literally just seen this - thanks!
should be clearer in the docs, i literally searched the whole package in vs and still couldn't find that
just happened to see this in the forum:
I looked through the physics documentation and saw something that I did not notice before
and now I'm wondering how to use it
What do you mean?
As far as I understand you can use collision queries api directly, without actual physics simulation or something...
... to all the underlying query algorithms ...
You can use the algorithms without using their implementation of the state system that makes them actually do something
(Collision / Physics World)
That's why the bit about ... directly if desired without allocating memory...
is there
Basically it's written in a way that lets you reuse their algorithms to write your own implementation of a physics system if you want
Any idea what's up with this? [Worker0] 2 entities in the scene 'ClientAndServer' had no SceneSection and as a result were not serialized at all.
buggy baker. You can ignore that warning
I feel like sometimes something breaks with netcode prediction.
Everything worked, and then suddenly the delta time in the prediction loop isn't correct anymore for some reason. Then I stashed, it worked again, popped the stash, and it worked again...
And when this behaviour pops up, it always runs faster on the client than it should
Overlap Sphere is just distance check which is supported
yeah I'm pretty sure I used that
Also there is overlap box
OverlapBox(float3, quaternion, float3, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)
And capsule
And they even added sphere even though it's a duplicate
OverlapSphere(float3, Single, ref NativeList<DistanceHit>, CollisionFilter, QueryInteraction)
yeah i just hadn't spotted these methods in World.. it's specifically OverlapBox i wanted just for a simple oriented box check
I can't decide if I should flatten my graph for runtime execution or if I should keep node state for things like sequencer or repeat nodes...
Is there a way I can only get the entities with a specific component that is disabled in my IJobEntity Execute method?
You want a specific component to be disabled?
(and for it to skip entities with that component enabled?)
I already have it disabled. I just want a system to only find the disabled ones, in contrast to the enabled ones
Yes, that's what I meant
Yee
I would use an IJobChunk and disable enable-filtering
then check if the component is enabled, and if it is, skip the entity
ah alright, thanks
Is a workflow of enabling and disabling components often a reasonable approach in general?
In contrast to using tag components etc
Depends on what you are doing
It doesn't require a structural change, while tag components do
Indeed
In general if you often change the enabled / disabled state use an enabled component, if it's very rarely use a tag
The advantage of tags with rare changes is you have better chunk utilization
Since the disabled entities still reside in the chunk
Right
Very new to ecs, and have done OOP my entire life, so I'm testing about and thinking about what system should be responsible for what etc
It's interesting though
Are there any approaches to running jobs or update components on Entities that resides on another Entity's buffer?
Like operating on the components for each Entity in the Child buffer for a parent as an example
Sure, just get the buffer and iterate over the entities in it. If you want to do it in parallel you will have to chain jobs since the lookups don't allow parallel access
(unless you disable safety and are very careful)
I see I see
this should be easier next release (or at least soon~) as i think a filter will come for them specifically
Hrm, NativeArray.Length prompts float vectorization yet DynamicBuffer.Length doesn't????
use asNativeArray with a DB and it should
i think the reason is that it's not clear whete the starting pointer is on a DB. it first has to evaluate that
see getPointer method
Burst doesnt recognize this for loop as a memcpy operation. Annoying.
Isn't there a native array.copyfrom method you can use
am I failing to find it or are there zero mentions of companion objects in the entities docs?
wouldn't surprise me if there was no mention of it
It's been purged. It's one of my questions I want answered on the 8th
Using an intermediate var improves unrolling?
We have always been at war with companion objects
Burst should recognize that nothing aliases, or at least nothing on both sides of the equal sign.
Ya know, unironically it really seems like it.
It is a var already...
Sorry, that was a too-flip response to the term "purged," it brought images of 1984 to me. I look forward to hearing more about it on the 8th.
I'm not sure how good the analysis is that m_Length won't change in the scope of the loop
I guess some micro-optimizations then.
Burst in my experience seems really good at recognizing things that happen with NAs and only NAs. It's these dynamic buffers that are so problematic.
Not immediately returning the length.
I dont know if jetbrains decompiler can show attributes though
I dont think NAs throw with 0 sized initialization? Maybe? Never tried it.
{
get
{
#if ENABLE_UNITY_COLLECTIONS_CHECKS
AtomicSafetyHandle.CheckReadAndThrow(m_Safety);
#endif
return CollectionHelper.AssumePositive(m_ListData->Length);
}
for example native list
You can have a 0 sized NA.
but i feel like this would be handled for NA
well of course
Assume positive returns >= 0. I'm assuming >= 1.
i know
how are you telling burst this?
Just initializing all the pointers from NAs. Burst states that the compiler recognizes NoAliasing if the pointers originate from NAs IIRC.
they look like they're initializing from dynamic buffers converted to native arrays
8th?
Yea, and then the pointers come from the NA. I'll stick the for loop into a static method to make sure.
DOTS QnA
Where?
Here
Forums.
Found it, thanks.
Yea, it might have something to do with aliasing.
Just stuck [NoAlias] everywhere and it 4x unrolled.
was literally about to suggest you to do this
because i just tested it myself with NoAlias
I wish more of unity objects had native array access points.
I think wrapping length of a dynamic buffer in a local var results in burst recognizing loop unrolling without need to cast the DB as a NA.
This does result in a 4x float unroll.
I wonder what is the maximum number of properties allowed in a IJE?
But yea, I think this is where I start using aspects to wrap all the Atm buffers...
@rotund token Have you done any benchmarks on seeing if either of these methods are faster?
The former reuses the boolean condition and burst compiles it into a VP operation but just 1 op per packed float. The latter unrolls into 4x VP comparison operations but requires recomputing the boolean check again and again.
WallCheckOdd()
WallCheck()
i find my intuition always wrong on similar stuff -_-
I trust yours more than mine
Im leaning towards WallCheck() for 128 byte cache line wide operations vs just 32 byte per packed operation.
This is the oddest comparison check I've ever seen. No clue what burst is doing here. The previous samples were when Flags was a byte, this is Flags as an int.
Tertle, if you're up for more benchmarking...
Flags as a byte results in identical burst as if Flags was a bool so I'm assuming that the 2nd burst sample from above with a byte is faster than the 3rd using an int.
eww new discord font
and back to old font. Better Discord is great π
dummy question time:
i'd like to get an array of values for a specific key from a nativemultihashmap
so that i can use indexing on it to query values ( rather than using the enumerator )
the problem is nativemultihashmap only has a method to return the entire value array for all keys
and i'm not sure how to get a start index on that array for the specific key
is there some way to just get a nativearray of the values for a specific key?
Should I process NativeArray.Copy in parallel? Is there any performance gain?
i think conceptually i'm looking at NMHM the wrong way and can't expect to be able to retrieve an 'array of values for a specific key'.. because the order of values for a specific key is i think not guaranteed right, it's just one long array of key-value pairs that happens to allow multiple of the same key.
so i can't think of it in terms of being a 'dict of arrays', because it's not that
I've been thinking about this over the weekend a bit and I'm not sure I follow. Do you mean that you store these containers in components? If so is that allowed, I thought you couldnt put native collections in components?
Or do you have some global state thing? If you wouldn't mind could you provide a very small example? π Trying to implement a similar system but getting stuck on where to store these containers to manage dependencies
sure, i got to watch the kid for a bit. afterwards i can show you how it's done. and yeah, nativecontainers are allowed now in IComps since managed DisposedSentinel is gone.
not a nativearray but an enumerator. GetValuesForKey or something it's called
it's not stored in sequence so NA is only possible with copying
Oh that explains a lot, I'm still on 0.51 so was confused how you managed to put containers in components, but I defo need to read up on 1.0 changes.
the same concept works with icomp class
Can someone explain this bug?
It works fine without burst, doesn't like it when I enable burst compilation
dang woke up all excitied for the dev day q&a and then saw it wasnt today π’
Is there a specific question you're looking to ask?
I have a few, also hoping to see other answers to questions that I hadnt thought of
When is it?
The 8th
nice
Here's my setup:
I have a write system that has a disabled OnUpdate, running in an Initializatio group
public partial struct SpellCastSystem_CreateWriteStream : ISystem```
In there I have structs that hold NativeContainers that are accessed from other systems for reading and writing
```public struct SpellJobData : IComponentData
{
public ParallelList<CreateSpellData> createSpellsParallelList_SpellCastJob;
public ParallelList<CombatEvent> combatValueParallelList_SpellCastJob;
public ParallelList<ThreatEvent> threatValueParallelList_SpellCastJob;
public ParallelList<DelayedSpell> createDelayedSpellsParallelList;
public void Clear()
{
createSpellsParallelList_SpellCastJob.Clear();
createDelayedSpellsParallelList.Clear();
combatValueParallelList_SpellCastJob.Clear();
threatValueParallelList_SpellCastJob.Clear();
}
public void Dispose()
{
createSpellsParallelList_SpellCastJob.Dispose();
createDelayedSpellsParallelList.Dispose();
combatValueParallelList_SpellCastJob.Dispose();
threatValueParallelList_SpellCastJob.Dispose();
}
}```
(just change struct to class in 0.51)
OnCreate handles allocation and OnDestroy just Disposes.
The struct is then added to the system entity via
state.EntityManager.AddComponentData(state.SystemHandle, spellJobData);
(Not available in 0.51, just create an entity yourself instead)
Now the important part:
Set the singleton dependency of read and write in OnCreate of a system. That makes sure the system has the right dependencies. Works for read and write.
For example:
SystemAPI.GetSingletonRW<SpellCastSystem_CreateWriteStream.SpellJobData>();
(SystemAPI doesn't exist in 0.51, GetSingletonRW works just as well)
In OnUpdate just get the singleton then:
var spellJobData = SystemAPI.GetSingleton<SpellCastSystem_CreateWriteStream.SpellJobData>();
Then the different containers can be used for jobs.
to get managed IComps use the extension method for it, which you can access via this.GetSingleton
Thanks a lot for the write up! I'll be sure to dig in to this in the coming days, is it OK if I poke you in this channel in case any questions arise? π
yeah sure
Does anyone have an example of using the advanced mesh api in a more complex way than what the docu does? Trying to modify multiple meshdata in a job, where the parallization is achived per vertex instead of per mesh.
https://pastebin.com/nfAWQb2i Is this how one should handle singletons with dependencies? Or is there some smarter way?
How can I get NativeArray<TComponent> from EntityQuery without generic parameters?
What do you want to get? if you wanna use dynamic component you need IJobChunk and chunk.GetDynamic
In general I want to get whole component data array and copy it as is to ComputeBuffer. So if I know <T> I can do EntityQuery.ToComponentDataArray[Async](Allocator, out JobHandle).
And it seems there is no overload for non-generic (ComponentType based) method.
I seek for such method overload because every time we use generic methods with EntityManager/EntityQuery it creates ComponentType inside. But I already have one, and I don't want to rewrite whole code hierarchy or rewrites dots source
Yeah in this case you need access to the Chunk to pull out NativeArray<byte> of your components. I suppose you can do it using manual chunk iteration directly in OnUpdate, but here's how you would do it in a job:
protected override void OnUpdate()
{
var copyJob = new CopyJob
{
Dynamic = GetDynamicComponentTypeHandle(ComponentType.ReadOnly(123)),
};
copyJob.Schedule(default);
}
public partial struct CopyJob : IJobChunk
{
public DynamicComponentTypeHandle Dynamic;
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
{
var byteArray = chunk.GetDynamicComponentDataArrayReinterpret<byte>(Dynamic, 456);
//Do whatever
}
}
yeah I Know, I have the same implementation. But want to get rid of this, because to parallel copy from chunks to array we need firstEntityIndex which no longer exists in 1.0 and kinda expensive to calc
Does a documentation about the new transform system exist somewhere? If so, where might one find that?
Maybe you could get around that by just query.CreateArchetypeChunkArray[Async]() and do it on the main thread in OnUpdate? I'm not entierly sure though..
Well, while data stored in chunk there is no way how it can be actually avoid chunk iteration, so copying would happen per-chunk
Just read through the Manual of the new Entities 1.00-pre.15.
Is the Content Management (https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/content-management.html) the actual addressables for entities implementation?
Because it seems to exclusively load managed objects π¬
apparently it is. but i haven't seen it in action nor had time to learn it
what happened with NativeParallelMultiHashMap in 1.0? Can't find in changelog or in upgrade guide?
it just NativeMultiHashMap π
I too was expecting for something that would also deal with entity prefabs
Subscenes?
that's what it got renamed to
Heya!
So, I'm really just curious, how much processing are you doing per single vert?
I'm having trouble imagining a compute scenario that justifies paralleling at the vertex level vs mesh
It can load subscenes I think
I'm calculating around 7-8 diferent unique noise functions at each vert. The thing is that the process is a sequential process of 10-12 parallelized jobs, working at each vertex. Before i was doing plain c# and had a sequential process that did the same at each vertx, it took aprox like 8-9 seconds. After parallelization per vertex, it takes around 0.1 seconds
In theory I should be able to do it per mesh, but that means rewriting everything
And now everything is parallelized, per mesh and per vertex, so i think it's the way to go
Well, there you go, now that's a compute scenario
I mean, it sounds like your doing it right, what specific issue are you running into?
How to call the native list method not the IEnumerable one?
IndexOf
It says there is a box allocation because of conversion between NativeList and IEnumerable
I was before, getting some weird bugs that didn't allow me to make it work, index out of range, and mainly buffer issues. My next issue is making the code work outside the main thread. One chunk takes 0.1s so it actually stops the main thread when generating a bunch. Gotta look into how to call the complete outside the main thread
But i think i cant do it because the advanced mesh api requires to be called from the main thread
Try
(NativeList<Whatever>)item.IndexOf
iirc, pretty sure only the initial creation and then application of the meshdata needs to be called from the main thread, but my initial recommendation would be to use the complete flag; Instead of waiting on the main thread for the complete, check the jobs '.Complete' property every frame until its done, then do processing on the stored data
You don't actually have to call .Complete on jobs to finish them, scheduling is enough to get them run, calling .Complete is just a way to force the main thread to halt until the jobs done
^? : )
items is NativeList itself!
public static int IndexOf<T, U>(this NativeList<T> list, U value) where T : unmanaged, IEquatable<U>
{
return IndexOf<T, U>(list.GetUnsafeReadOnlyPtr(), list.Length, value);
}
Generic with T and U !
items.IndexOf<TSource,TSource>(item)
WTH
Now, it works
I see, thanks! Will do it that way then
Can I rely on the backing field of an auto property to be at the field offset the auto property is at in the struct in a burst context?
Maybe?
Or should I explicitly define the property with e.g. a private struct field
I would recommend that.
FieldOffset does nothing if I don't set the structlayout to explicit right?
This attribute is used when System.Runtime.InteropServices.StructLayoutAttribute, with LayoutKind.Explicit passed to its constructor, is applied to a class or structure to specify the offset of each non- static or constant member within the unmanaged representation of that class or structure.
So yea, without Explicit, it does nothing.
I mean, you can try it and see if it works
Someone over in the C# discord said it might not work on mono
I just use direct fields every time and skip any ambiguity or C# managed nonsense but if it works, go ahead.
Not sure how burst handles this
i believe so but yeah i would be explicit on the backing field if ordering matters
Yeah I think I'll just do it manually to be safe
Huh, how do I have an aspect with dynamic buffers? Just not possible?
Oh wait, i just dont use refRX
Does com.unity.entities.graphics not exist anymore? Trying to get DOTS set up after a long hiatus and I'm just at a loss for how to properly set up the project. I'm getting "unable to find package with that name"
"com.unity.entities.graphics": "1.0.0-pre.15",
Are you on 2022.2 F1?
...I've managed to launch the project in 2021.3 despite freshly installing 2022.2 for this purpose
thanks π
NativeList has ElementAt
oh you need an element, nvm then π
i think IndexOf just does a for loop, might put it in a hashmap when it's called in a hot path
IndexOf Yes fast for loop
First, NativeList then test HashMap π
Another big problem for me is code duplication when I use job system.
I cannot use Delegates (Func/Action), interface, inheritance :/
For example my path finding template is similar but with different delegate (func arguments) for weight calculation, obstacle check, target check, node extension, etc.
In OOP approach, I can send Func arguments with different implementation to that FindPath method
PathResult result1 = FindPath(...,CalculateWeight,CheckTarget,CheckObstacle);
PathResult result2 = FindPath(...,CalculateWeight2,CheckTarget2,CheckObstacle2);
There are plenty of different ways to handle this in dots
You can literally pass function pointers if you want the same workflow, though they aren't going to be as efficient for small delegates
Probably better to use helper structs and interfaces
Send refs to structs?!
FunctionPointer<MyDelegate>
I am noob in dots, thanks. Yes, as you mentioned it is not efficient
it's not inefficient
well it can be
it has the overhead of a native call
so if it's something like
[MonoPInvokeCallback(typeof(Process2FloatsDelegate))]
public static float MultiplyFloat(float a, float b) => a * b;```
then yeah it's not going to be that efficient
but if you have a bunch of logic in there it's not really an issue
anyway an alternative is just make it generic/interfaces
To have less changes, I test FunctionPointer first, Cool and then if it is not desirable, change my way
where TW : unmanaged, ICalculateWeight
where TT : unmanaged, ICheckTarget
where TO : unmanaged, ICheckObstacle```
In these methods, there are bunch of conditions to check if the current node is target or obstacle
{
float Calculate(int x, int y, int z);
}
public interface ICheckTarget
{
bool Execute(Entity target);
}
public interface ICheckObstacle
{
bool Execute(Entity obstacle);
}```
you can put anything you want in there
Some conditions require scriptable objects stats.
I think switching to Job system can propagate changes in my entire codes
well obviously you can't* read SO directly
Yes, should assign required data to somehting like NativeArray ,...
Wait, are arbitrary struct methods accessible in burst compiled job code?
I thought only static function calls were allowed, which is how Native* types got around that,
Not sure what you mean?
Like, I thought you couldn't use actual real instance methods from an interface struct in burst (because the arbitrary code that could be run and burst being all pre-compiled look ahead optimization stuff).
The predefined native types have static extension methods for sugaring, but arbitrary non-static methods on structs was a no-go
As long as a method does not require data outside what is provided in the job, anything goes.
You can even have managed classes sent into a (non-bursted) job using a GC pointer.
Oh jeez, I've been spinning my wheels diving into the abyss because I misunderstood this
(technically you can even call managed class methods inside burst if you want to get real dirty)
I mean, Debug.Log is a classic example.
you can do a lot with
Marshal.GetFunctionPointerForDelegate
but not something you should be doing anyway
I was so deep with blinders on, I was trying to get source generators to work so I could create a switch that linked fixed length strings to static methods on particular structs, all sorts of overcomplex, glad I saw gladiators question, thanks for all the info on this
I'm getting so many burst corruptions and crashes atm
This Exception was thrown from a function compiled with Burst, which has limited exception support.
0x00007ff7026706fd (Unity) burst_signal_handler
0x00007ff809428b4c (ntdll) RtlDeleteAce
0x00007ff8094012c6 (ntdll) RtlRaiseException
0x00007ff809450f4e (ntdll) KiUserExceptionDispatcher
0x00007fff921e84cf (9c33427477f2fcf9f52aa87bcd77068) Unity.Physics.Systems.CreateJacobiansSystem::Unity.Physics.Systems.CreateJacobiansSystem.OnUpdate (at I:/Documents/BovineLabs/com.bovinelabs.shattered/Library/PackageCache/com.unity.physics@1.0.0-pre.15/Unity.Physics/ECS/Base/Systems/UnityPhysicsSimulationSystems.cs:271)```
basically this, but for every system. turning burst off, no errors. clearing library, no more burst nulls
all my function pointers corrupt randomly
maybe related to this changelog
With the relaxation in Unity 2022.2 or newer that we can call CompileFunctionPointer from a background thread, we now use this mechanism in Burst to handle Direct Call methods, resulting in a cost saving during Domain Reload.
I have no actual idea, but my instinct says its some failure to refresh/update/clear some stored pointer-map, maybe a race condition or write failure in the thread to main memory?
Ok, I'm running into type constraint issues, might as well get outside opinions about how to do this before I go down another rabbit-hole;
I'm trying to create some sort of <Identifier, BucketOfCode> map that basically creates an entity with a specific archetype given a specific user-input identifier, be it a string, number, whatever
The problem is I want it to be job system / ecb accessible, and while writing no-local-side-effect methods is fine, I'm having trouble actually creating the data-representation that satisfies the job system type constraints, if its even possible.
how many combinations of user inputs are there
and id + a hashmap of named float values that represents settings for the archetypes components,
my goal was to have a interface or something that essentially took the proper data in and applied all the proper ecs components and settings from the named float map, for the matching identifier
So like, if I had a string id of "common.box" and a settings map of {"a":1.0}, the creation map would grab the logic for the matching identifier, which would do something like entity->addComponent(CommonBox {a = settingsMap["a"] })
If that makes sense
i'm just trying to figure out if you had a fixed set of user created stuff
but it doesn't sound like you do
does idiomatic foreach only executes on main thread?
yes
so if I want to use ISystem in 1.0 the closest API for Entities.ForEach is IJobEntity?
Yeah, not really an upper limit (beyond data limits), though the valid identifiers for the matching ecs components are fixed at compile time, its essentially creating and assigning the right components and data to a series of newly created entities based on data from something like a validated json or xml file,
you should use IJE for like 90% of your work imo
oh, ok, thank you π just want to keep up with latest things
i wish for the love of god unity would fix the damn search function on both A) the package docs and B) the forums
it's like being back in 1998
What is google?
IJE and IJobChunk are not that far apart as they once were. (still prefering IJC)
doesn't return everything on the forums generally
I wish we didnt have package docs split into a million different places. old unity manual was so much better than having to type in com.unity.xpackageblahblahblah
also package doc format still doesnt read as well as the old docs imo
searching something in package docs works for me maybe 50% of the time, half the time it's just blank
yeah that too unfortunately
The search in package docs really needs to be by content and not by section title. Burst is pretty bad in that regard (along with missing docs in the first place)
kindof crucial if they want adoption, devs can hit the ground running and not have to hunt down basic info
Burst actually lost the docs for valuetuple support. Burst still does support it but you'll need to go back to 1.5 docs to find out the limitations
Does burst build a jump table for a pattern matched enum?
Yes? I did do a test with a switch statement and int value and the burst looked like a jump table.
Did you test with a pattern matched switch?
I don't know if they are handled differently π€·ββοΈ
And I can't find anything in the docs
It's something ya gonna have to code and then inspect. Let me find my old switch statement
This compiled into something that resembles a jump table. It was noticeably different from a if else branch.
As for pattern matching? Maybe not. The enum itself was a bitflag table.
I'm not an assembly guru, but this seems too short
for this
(at least it doesn't look like an if else branching scheme)
Yea. Try and see if you can find where the Execute compiled at.
Is there no way to search? 
At the bottom of the inspector, there's a search bar
press enter to move through the matched keywords
Are you on burst 1.6?
1.7.4
At the very bottom
I don't have that π¬
I think the search actually came 1.8... It was decently recent.
What version are you on?
1.8.2
Guess I'll update π€·ββοΈ
burst has been stable so far for updating
TBH, burst has never crashed on me. It's always whatever they're doing in DOTS land.
There was a pretty serious bug in 1.8.0 iirc where the burst cache sometimes didn't refresh correctly
True, that was also 1.7.1. Very annoying
The reason I was asking is because I am probably going to end up with a lot of cases in that switch statement, and wanted to know if that could be an issue
I think an enum switch statement is fine in burst. There is a definite jump table even with non-sequential values.
I also always make sure to write all of the other code so slow that these tiny optimizations would never matter in the first place 
Learning the little optimization tips here and there and it'll all add up in the end.
It's just a hobby for me so it's more about understanding, but you're right π
I've been stuck doing the same project for years now. Hobbies are fun. Doing this as a job would be hellish.
Yeah that's kind of the fear I have. I love games, but I also love working on my own stuff π€·ββοΈ
Maybe one day after I've rebooted the same project for the 50th time 
I got more before I transferred to github.
Because I dont know how to continue a git repo after switching primary folders...
Do you use entity names?
Yea. I think it's a toggle. I want it turned on so that entities aren't just Entity(21213,321)
I used to name them a long time ago, but there was an issue where the naming function wasn't allowed in a build
Just for now, I need to make sure my buffer generated properly.
Oh yea, it's not allowed in build but I need to check in editor.
Is there a toggle or something now? It doesn't even show the name for me if the entity is derived from a prefab entity
And the text is supposed to replace the Entity(Index,Version) drawer wherever that appears or what?
yea
I've had this happen too
I noticed that this coincides with the prediction breaking, I just missed the error message yesterday
Hrm, prediction breaking. You mean when objects start vibrating?
I thought it was just havok (because despite having the package, I forgot to enable it...)
No, I think it just stops syncing the data back to the client, and since I use delta time in my prediction loop the client starts running "too fast" since it's not getting the old elapsed time from the synchronized buffer
ah, no clue then
Yea, now that i zoomed way in to verify sliding, havok vibrates a lot more when moving physical objects. It can function with netcode but definitely not the best with it sadly
I still use character controllers with everything since I don't want to deal with physics π
luckily my project is 2D, so it's mostly very simple
I'm 2d top down but I need physics as everything is rigidbody...
Are you using the dots controller?
I looked at it a bit, but it was way too overkill for what I'm doing, so I kind of hamfisted together my own
It works pretty well now, but I had no idea what I was doing so it was mostly trying stuff out until it works
Yea. I hacked together my own controller using a dynamic and a slightly smaller kinematic body to prevent players from directly pushing players (really jank over netcode) but it doesnt work if a player uses another object in between to push.
Yeah I don't have any of those physics interactions, that's why my controller is really simple. You can't push stuff at all
I was thinking about using the dots controller but yea, it was completely overkill. My camera just follows the XY position, none of that orbiting stuff.
The only reason I really went for a character controller is back then netcode had no support for physics at all, if it did I might have tried getting physics to work
I want to use it since it mentions that the player it purely kinematic but can respond to dynamic bodies allowing a player to not get pushed by anything but still get blocked by walls but it's just too big.
Yeah I basically just have kinematic bodies
My collision cases are also relatively simple, since I usually have walls at right angles
Can your kinematics hit other kinematics? 3D kinematic just results in them phasing through each other
You mean like two players walking into each other?
yea
It will be like hitting a wall. I've not tested it much, but I think that's how it works since I had an issue when benchmarking my pathfinding where some actors would get stuck because two actors would walk along a path in opposite directions and "meet" in the middle, and then just keep walking against each other
Huh, are you using dots physics?
Yeah
(the non-havok version)
This is what happens if you walk against another actor
I will need to do some tests again because when I tried kinematic - kinematic, it just phased through
Huh, mine phases through. What are you setting to move?
What do you mean?
I only use dots physics for collisions, the entire decollision stuff I wrote myself (thats the hacky bit I mentioned earlier)
ah
Like I said, I went this route because back then netcode had 0 support for any kind of physics stuff
Might be tricky to add more interactive stuff like pushing, but I can live without it for now
A lot of my collision cases are also relatively simple, for example walls are often at right angles locked to a grid
Mine's gridded as well. Although i'm just using a static cube for every tile.
I'm basically doing the same, since ECS has no support for tilemap collision of any sort. So all collidable objects are ghosts synced by the server
Yea, just a entity per tile. It's annoying but seems to function well enough. The alternative was a mesh generate from the tilemap then setting it as a plane collider. It worked actually but runtime adding and removing tiles would be a pain.
I need the entities anyway since e.g. building walls can have HP and be destroyed, so it works well enough for me
This is maybe the one occasion where I do recognize that making colliders a blob asset is logical.
I thought they even have the option to make them unique now?
I set the collider for non-actor entities dynamically at run time, so I haven't looked at the authoring for physics shape in some time, but I remember seeing that there
Although I guess it's still stored in a blob
But at least it's easier to modify if you need it π€·ββοΈ
Yea, it's just a unique blob asset
I'm off to sleep π have a good one
Does anyone know how to get a RO dynamic buffer in an aspect?
Ah, using the [ReadOnly]
Is there a go-to workaround for the lack of skinned mesh animation in DOTS right now? I tried following the steps here and I'm still getting the error that the shader doesn't support skinning. https://docs.unity3d.com/Packages/com.unity.entities.graphics@1.0/manual/mesh_deformations.html
nothing official
what shader did you use? shadergraph should support a skinning node cant remember the name, for a custom shader essentially need a skinmatrices buffer for any custom shader to work and skinning function
I tried making a URP shadergraph shader and adding the Compute Deformation and Linear Blend Skinning nodes. Neither seemed to work.
I don't necessarily mind writing a custom solution. But gameobject proxies are a non-starter for performance reasons, and I'm not entirely sure where to even start otherwise.
there should be a deformable skinned mesh with that, but are you looking for animations to be played and a converted animator?
Yeah animations are all I'm needing out of it. Don't even necessarily need an animator controller on them if I can manually push updates instead.
best bet is a 3rd party solution, theres a post on the dots animation forums about community efforts
basically all that happens currently is a skinned mesh that is rendered in dots, but nothing else. you would have to manipulate the various buffers yourself to make anything move.
Would be nice to avoid that rabbit hole, but I am curious about whether the granular control over that system could allow for some extra optimization.
Outside of writing your own solution and using GOs there's this: https://github.com/Dreaming381/Kinemation-Skinning-Prototype (but it's not updated to 1.0 yet)
man I dont get it. spent a number of days getting terrain to render while subscenes were open(either through meshes or custom shader work or duplicating the gameobject) and for some reason they are visible in subscenes now after some inexplicable change
live conversion should be on to my knowledge
oh right, kinemation is in the framework
Is your scene state in authoring mode?
In the preferences near where you can clear entity cache, there should be a toggle between runtime and authoring scene mode.
oh you're right. I really dislike these things being placed in more obscure places
Does anyone know how to find an entity in selection.activeObject
In version 0.51, I saw that the api could use the EntitySelectionProxy, but 1.0 had been made private
And Selection.activeObject as EntitySelectionProxy is not valid
private or internal?
Even if that's the case Selection.activeObject as EntitySelectionProxy is not valid
i try use .asmref by
Unity.Entities.Editor
asmref should work fine for this
i'm not exactly sure why they made this internal, it limits 3rd party debugging tools
Yes, it limits third parties
After my tests, Even with the EntitySelectionProxy, when you click on entities Hierarchy instead of system and obj Selection.activeObject as EntitySelectionProxy Still invalid
And confused why do they need to display system
just making certain noise.snoise() returns a number between 0 and 1 right?
Hi guys, when I use a container with type NativeHashMap<FixedString64Bytes, NativeArray<Entity>> in Entity.Foreach().WithReadOnly(container ).ScheduleParallel. It throw this error
InvalidOperationException: The Unity.Collections.NativeHashMap`2[Unity.Collections.FixedString64Bytes,Unity.Collections.NativeArray`1[Unity.Entities.Entity]] AbilityPoolManagerSystem_69C715D_LambdaJob_0_Job.JobData.abilityNameToLevelPrefabs can not be accessed. Nested native containers are illegal in jobs.
Anyone know what does this mean and how to fix it? Thank a lot
one more strange thing, I already used this container NativeParallelHashMap<Entity, NativeHashMap<FixedString64Bytes, ModifierDataAggregator>> in ISystem combine with IJobEntity, it's working well
the error seems pretty straight forward
nest native containers are not allowed
you're putting a native array inside a native hash map which is not allowede
however good news for you is there is a NativeMultiHashMap
which serves this purpose, 1 key many values
(could be called NativeMultiParallelHashMap depending on your version)
thank, but I'm still confuse that I already use nest native container in ISystem and IJobEntity, it still work well
here is demo
ok from testing it seems it might give a number between -1 and 1, is this correct?
-1 to 1 is pretty common for noise generators
ok thanks!
Sometimes they'll slightly exceed this though depending on generator
ah fascinating, thanks!
is it possible to use ISystem with injected EndSimuldationCommandBufferSystem?
Hello everyone,
can somebody help us with that problem? We discovered a lot of crashes on Android devices with that Backtrace:
pid: 0, tid: 0 >>> com.x.y <<<
backtrace:
#00 pc 0x000000000014bc24 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/lib_burst_generated.so (Unity.Entities.ChunkIterationUtility._mono_to_burst_RebuildChunkListCache+66)
#01 pc 0x000000000014bbdd /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/lib_burst_generated.so (e3caa53b77215624d27495c08356903b+4)
#02 pc 0x00000000035a13c0 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/libil2cpp.so (EntityQueryData_GetMatchingChunkCache_mE98F4FC1F9B2C7729C2AA005F3B2BFA5DE77BA95)
#03 pc 0x00000000036125e4 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/libil2cpp.so (EntityQuery_get_IsEmptyIgnoreFilter_m628A520DC22266879360F1FA17B36ACFFD14CDE6)
#04 pc 0x00000000035bc120 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/libil2cpp.so (SystemState_ShouldRunSystem_m39E8A42D74D2EAD90C3B100E6BFC971282A58D82)
#05 pc 0x00000000035bb728 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/libil2cpp.so (SystemBase_Update_m795994EE60C054DFA78C313A60ED025B2668C9B4)
#06 pc 0x00000000015293d8 /data/app/owUsh5iYJ-TixM9pCZZB3Q==/com.x.y-RklAZwOgND4TL3mbHgNN-w==/lib/arm/libil2cpp.so (ComponentSystemGroup_UpdateAllSystems_m78B1AA9EAF07133497E9BA556B592AC93935441C)
...
Any ideas what we could do wrong? It comes from the main loop.
are you on 0.51 or 1.0?
in 1.0 yes
you just grab the singleton
my best guess is a corrupted entity world
usually safety stops this but in builds it's turned off so this is the weird type of errors you usually see
1.0
99% of the time it's either an ECB like, SetCompoennt when an entity doesn't have a component or ComponentFromEntity on an entity that doesn't exist
you really need to get your hands on a dmp though
i believe backtrace can upload you these
but it's still hard to narrow down from this unfortunately
as the issue is most likely deferred from previous system
I was wondering the most because it came from ShouldRunSystem so from the update loop.
what singleton?
var commandBufferSystem = SystemAPI.GetSingleton<EndSimulationEntityCommandBufferSystem.Singleton>();
var commandBuffer = commandBufferSystem.CreateCommandBuffer(state.WorldUnmanaged).AsParallelWriter();
you also don't need the old AddHandleForProducer if you use the singleton, safety is handled by dependency system
π€© so many new things
does it mean that every system has an entity now?
every system has an entity
but ECBS systems don't use the actual system entity
they create a new one for this singleton
π€·ββοΈ
(let me just 100% check this, it was the case in the exp and i'm pretty sure still in the pre. though i bought this up and they said yeah it probably should use the system entity)
90% of systems have no components on their entity
so it's all the same chunk
how then GetSingleton<TSystem> works?
singleton is unique to command buffers
they are just components that exist within the command bfufer systems
systems don't have their own singletons by default
singleton is just the name of the IComponentData
and it's stored within the ECBS so it appears as ECBS.Singleton
should I get this singleton in OnUpdate or OnCreate? Seems like in OnUpdate?
good new code-gen magic, but now I'm unsure in every place how things will behave π
SystemAPI.GetSingleton in update is standard
Sounds like updating from 0.51. to 1.0 is fun π¦
the upgrade is not that fun
yeah so it's basically doing a query iteration to check if there are any chunks
but something has written past where it should
and corrupted a chunk
it is fun, pls don't be afraid of it, it has tones of potential
Is anybody here using VFX graph with Entities? If so how do you mange your VFX effects from systems?
it looks much better now. BTW why EndSimECBSystem uses custom singleton struct?
What do you mean sorry?
I am currently using a system with a NativeQueue of VFXCommands which works well for triggering one of effects with an expiration time from any system in parallel. But I havent figured out a good way to handle effects that should be started and stopped manually yet
I wanted to ask why EndSimulationEntityCommandBufferSystem implements it's own Singleton struct. But looking closely I understand that it is just a component to work with system state data without accessing system instance itself as mentioned here https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/systems-data.html. I'm wondering how can utilize this new API
Hi. I'm working in 0.51 and having an issue with getting a DynamicBuffer from a component on an entity and passing it on to a job that's querying on other components. But when I try to access the buffer in that job, I get an error saying [job].JobData.[buffer] has been deallocated.
Any idea how I can solve this? It's for an exam project π
Hello ^^
We are working on an exam project with DOTS and we are having difficulty reseting the scene we are doing this right now:
DefaultWorldInitialization.Initialize("Default World", false);
SceneManager.LoadScene("DOTS Tornado", LoadSceneMode.Single);
World.GetExistingSystem<TornadoSystem>().Enabled = false;
World.GetExistingSystem<ParticleSystem>().Enabled = false;
World.GetExistingSystem<ConstructionSystem>().Enabled = false;
World.GetExistingSystem<BuildingSystem>().Enabled = false;
World.GetExistingSystem<UpdateCameraSystem>().Enabled = false;
In addition, Is there a way to maybe reset only the subscene?
How can I use an Animation Curve inside a job?
Can you post code of your job?
[BurstCompile]
public partial struct PlayerDirectionJob : IJobEntity
{
public float3 hitPos;
public int col;
public int row;
public ComponentDataFromEntity<NonUniformScale> nonuniforms;
public DynamicBuffer<BoxesComponent> boxes;
public void Execute(in Player player)
{
// Find closest box coords in hitPos direction
int gridX = (int)math.round(hitPos.x);
int gridY = (int)math.round(hitPos.z);
int boxIndex = col * gridX + gridY;
if (boxIndex >= boxes.Length) return; // Just testing, ensuring that we don't attempt a non-working index
// return;
// Use box coords as index into buffer
BoxesComponent box = boxes[boxIndex];
Entity boxEntity = box.entity;
// Use calculations from original code for height value of parabola and the parabola parameters
NonUniformScale boxScale = nonuniforms[boxEntity];
// boxTranslation.y; // use for height calculations of parabola, see original code in Player
// Set parabola params...
}
}
Sadly you cannot as its a managed type. You can convert it into a custom type. E.g. a buffer of keyframes. I think either CodeMokey or TurboMakesGames made a video about that topic
It is far from perfect but might be good enough for some use cases
I'm pretty sure its because of structural changes like it says at the bottom of this page https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-buffer-introducing.html
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/dynamic_buffers.html
You have BufferFromEntity
Occupied right now so I cant test it but maybe my group can. Thanks!
I tried to sample it into a native array of floats, and altough it works, I have the problem that sometimes it's being read by two jobs at the same time and throws an error
You should sample it during conversion. You could put it into a Buffer for example. So your systems would be able to read it in parallel
Could you explain/link me to somewhere where it explains how to do that?
Im trying to do it with blob data and such
blob data works
Im still getting errors like this
System.IndexOutOfRangeException: Index {0} is out of range Length {1}
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffcef9f5c48 (6a63da8ee91863ab52920bba7815e94) [Blobs.cs:780] Unity.Entities.BlobArray`1<System.Single>::Unity.Entities.BlobArray`1<float>.AssertIndexInRange
0x00007ffcef9f5c77 (6a63da8ee91863ab52920bba7815e94) [Blobs.cs:796] Unity.Entities.BlobArray`1<System.Single>::Unity.Entities.BlobArray`1<float>.get_Item
Not sure why tho
https://pastebin.com/nfAWQb2i How do people handle singletons with dependencies? Is there some better way than this?^^
How can I make what blob data does, without importing the DOTS package?
There's no way to do that with native arrays?
But then, if i make a native array of wathever i want, it cannot be read at the same time from multiple jobs
it can
attach [ReadOnly] attribute to field inside job
so safety don't swear on you
Im getting errors like the one shown before, but with native array
It says that it cannot get read access to the native array
no erorrs/no code = no help
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffd18ca5c93 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.FailOutOfRangeError
0x00007ffd18ca5bda (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.CheckElementReadAccess
0x00007ffd18ca5cd8 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.get_Item
The error is this one
The code could be simplified as
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Sample4 GetFractalNoise<N>(float4x3 position, int seed, float4 persistance, Settings settings, SampledAnimationCurve curve) where N : struct, INoise{
...
Sample4 value = Sample4.Remap(curve.EvaluateLerp(sum/amplitudeSum), ...);
return value;
}
where
public struct SampledAnimationCurve : IDisposable
{
public NativeArray<float> FunctionModifier;
/// <param name="samples">Must be 2 or higher</param>
public SampledAnimationCurve(AnimationCurve ac, int samples)
{
...
}
public void Dispose()
{
FunctionModifier.Dispose();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Sample4 EvaluateLerp(Sample4 time){
int len = FunctionModifier.Length - 1;
float4 floatIndex = math.clamp(time.v,0f,1f)*len;
int4 floorIndex = (int4)math.floor(floatIndex);
int4 ceilIndex = math.min(floorIndex+1,len);
float4 lowerValue;
lowerValue.x = FunctionModifier[floorIndex.x];
lowerValue.y = FunctionModifier[floorIndex.y];
lowerValue.z = FunctionModifier[floorIndex.z];
lowerValue.w = FunctionModifier[floorIndex.w];
...
return new Sample4{
v = math.lerp(lowerValue, higherValue, math.frac(floatIndex)),
...
};
}
}
.
does it happen without burst?
nope
Not sure if im missing an attribute somewhere or what
no idea then, try to report a bug
Would probably try check with some returns if its the NativeArray is not being initialized correctly (yet)?, or pintpoint on what line its breaking at if the error is deterministic
The native array is there, and it's initialized way before any job is called, and removed after all the jobs are called
Let me check however, just in case
It happens randomly, can't be sure why
Try test it manually with the extreme values for 1 sized arrays if you haven't already, otherwise no idea π€·
I tried that too, and I feel like the problem comes when accessing the array at the same time with two jobs. The thing is I'm not sure how can I make it accessible everywhere always, being readable
you have to run in debug mode
so that you have real stacks
that's not how it works
That was with debug mode enabled
what the advantages of using WeakObjectReference<TUnityObject> instead of just using managed IComponentData except that 1st can be used in unmanaged data?
Ha, wonder why people don't realize this.
Debug as in turn off Burst to make the errors actually show the correct string interpolation
Errors don't appear without burst
That means you might have a race condition.
From what I can tell during baking, pretty much that.
How is it possible? There's no writing at all to the array. Its created once, and set to read only
Actually, the error with native array is
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffd18ca5c93 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.FailOutOfRangeError
0x00007ffd18ca5bda (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.CheckElementReadAccess
0x00007ffd18ca5cd8 (1559e67c07d3fa3f234957e8a168a8e) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.get_Item
But with burst doesn't appear
it basically means it doesn't exist at the time its' being read or isn't being allocated properly
keep in mind burst runs faster. probably a timing problem as KornFlaks said
Mm, it's allocated persistent, and created before jobs are scheduled. Is then disposed after objects are completed
Im starting to think it's a unity issue rather than on my code
Doesn't it mean that the current thread doesn't have access to that sector of the array?
I don't think its that specific
jobs can run when you least expect them or can have strange behaviour sometimes Onstartrunning() can run more than once a frame
I don't know maybe they've changed that or fixed that stuff now though
Mmmm, then I don't get it, the object is created before any job is scheduled, and disposed after all the jobs are completed
are you sure, and how exactly are you allocating it, what about the source of data that is being allocated to that nativearray
show how you create job
private void Update() {
UpdateVisibleChunks();
}
void UpdateVisibleChunks()
{
...
ScheduleJobs();
WaitForChunksToFinish();
}
public void ScheduleJobs()
{
if(newChunks.Count > 0)
{
...
SampledCurves curves = new SampledCurves(WorldSettings);
...
NativeArray<JobHandle> MeshList = new NativeArray<JobHandle>(newChunks.Count, Allocator.Persistent);
NativeArray<JobHandle> ListsOfJobs = new NativeArray<JobHandle>(newChunks.Count, Allocator.Persistent);
...
JobHandle FinalJob = JobHandle.CombineDependencies(ListsOfJobs);
GenerationCalls.Add(new GenerationCall{
...
curves = curves,
});
}
newChunks.Clear();
}
public void WaitForChunksToFinish()
{
if(GenerationCalls.Count > 0)
{
for(int i = GenerationCalls.Count-1; i >= 0; i--)
{
if(GenerationCalls[i].Job.IsCompleted)
{
GenerationCall call = GenerationCalls[i];
call.Job.Complete();
Mesh.ApplyAndDisposeWritableMeshData(call.meshDataArray, call.targetMeshes);
...
call.curves.Dispose();
GenerationCalls.RemoveAt(i);
}
}
}
}
This is the basic structure
Where
public struct SampledCurves: IDisposable{
public SampledAnimationCurve ElevationCurve;
...
public SampledCurves(WorldSettings_SO WorldSettings_SO)
{
//Generate all settings
ElevationCurve = new SampledAnimationCurve(WorldSettings_SO.ElevationMap.FunctionModifier, 255);
...
}
public void Dispose()
{
ElevationCurve.Dispose();
...
}
}
And
public struct SampledAnimationCurve : IDisposable
{
NativeArray<float> FunctionModifier;
/// <param name="samples">Must be 2 or higher</param>
public SampledAnimationCurve(AnimationCurve ac, int samples)
{
FunctionModifier = new NativeArray<float>(samples, Allocator.Persistent);
float timeFrom = ac.keys[0].time;
float timeTo = ac.keys[ac.keys.Length - 1].time;
float timeStep = (timeTo - timeFrom) / (samples - 1);
for(int i = 0; i<samples; i++)
FunctionModifier[i] = ac.Evaluate(timeFrom + (i * timeStep));
}
public void Dispose()
{
FunctionModifier.Dispose();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Sample4 EvaluateLerp(Sample4 time){
int len = FunctionModifier.Length - 1;
float4 floatIndex = math.clamp(time.v,0f,1f)*len;
int4 floorIndex = (int4)math.floor(floatIndex);
int4 ceilIndex = math.min(floorIndex+1,len);
float4 lowerValue;
lowerValue.x = FunctionModifier[floorIndex.x];
lowerValue.y = FunctionModifier[floorIndex.y];
lowerValue.z = FunctionModifier[floorIndex.z];
lowerValue.w = FunctionModifier[floorIndex.w];
float4 higherValue;
higherValue.x = FunctionModifier[ceilIndex.x];
higherValue.y = FunctionModifier[ceilIndex.y];
higherValue.z = FunctionModifier[ceilIndex.z];
higherValue.w = FunctionModifier[ceilIndex.w];
return new Sample4{
v = math.lerp(lowerValue, higherValue, math.frac(floatIndex)),
dx = time.dx,
dy = time.dy,
dz = time.dz,
};
}
}
WorldSettings_SO.ElevationMap.FunctionModifier is an animation curve
To just go further, the sampled curve is used like:
JobHandle WorldWithFlatens = DisplacePersistance.jobs[(int)elevationSettings.noiseType](vertices,persistance, elevation,
elevationSettings, sampledCurves.ElevationCurve,
offset,generationSettings, Persistance);
So that
[BurstCompile(FloatPrecision.Standard, FloatMode.Fast, CompileSynchronously = true)]
public struct DisplacePersistance<N>: IJobParallelFor where N: struct, INoise {
...
[ReadOnly] SampledAnimationCurve outputAnimationCurve;
float2 offset;
int seed;
public void Execute (int i) {
...
Sample4 noise = GetFractalNoise<N>(..., outputAnimationCurve);
outputNoise[i] = noise;
}
public static JobHandle Schedule (..., SampledAnimationCurve outputAnimationCurve,...
) => new DisplacePersistance<N>() {
...,
outputAnimationCurve = outputAnimationCurve,
}.Schedule(vertices.Length, generalSettings.Resolution, dependency);
}
and then like this
There should be all the code that makes use of the object, through the whole hierarchy
I meant, show actual job constructor
how you do it
What do you mean, it's this
In coordination of this
I set ListOfJobs[x] = to a job like this, but that one has multiple dependancies
why do you obtain job from somewhere?
this could be the reason
why smth is invalid
job is a struct, just value. As it gets scheduled, it won't ever get updated by job system
Since the job is made of multiple steps, it's easier to have a class containing the whole process and fields there. I then can create multiple instances of that class and schedule multiple jobs.
And the job is being obtained as a delegate, so actually what DisplacePersistance.jobs is returning is just the delegate of Schedule of a job
π₯΄
Basically, it's calling a static Schedule and returning a jobhandle
JobHandle = Scheduled job
this is rather confusing tbh
why can't you just return job struct instead?
and avoid this overcomplicated solution with delegate
yeah, get rid of the MonoBehaviour
and stick to a system + job chain
is the actual error happening in Mesh.ApplyAndDisposeWritableMeshData?
is AnimationCurve the unityengine managed version?
also I agree, its quite a rabbit hole to try to follow how that all fits together
May i ask a little question on why/how SystemHandle can be converted into Entity
coz i can pass a SystemHandle param on method like
SystemAPI.GetComponent<ComponentData>(SystemHandle _systemHandle)
while it is supposed to pass an Entity param to GetComponent<T>(var param)
easiest to answer when looking at code /// <summary> /// An identifier representing a system instance in a particular world. /// </summary> [StructLayout(LayoutKind.Sequential)] [DebuggerTypeProxy(typeof(SystemDebugView))] public struct SystemHandle : IEquatable<SystemHandle>, IComparable<SystemHandle> { internal Entity m_Entity;
SystemHandle just calls GetComponent(handle.m_Entity) internally
and every system has a SystemHandle now because every system has its own entity that you can add components to
(visible in entities hierarchy)
Nop
It's returning job struct already scheduled
It's needed for the modularity that I have rn, it allows me to be able to call different versions of the same job without hardcoding, which is really useful since im constantly tweaking parts of it through Scriptable Object
There's only one MonoBehaviour and is the one that starts the whole chain of jobs and deals with the end results. I'm not using Dots per se, just Burst and Jobs, and that is the plan. I haven't found yet a reason to go full into dots for my current needs
The error happens at Evaluate Lerp
how can i access to that? i only got this one with "go to definition" on VScode
Thank you for explaining. It really helps
Ha, they fixed the memcpystride documentation
On a side note, has anyone managed to get BurstDiscard to work when calculating a returned value using managed objects?
What are you expecting to happen there?
In burst that method just won't exist
It's not going to just switch to mono and execute it or something
Is using Vector3/Vector3Int OK in terms of performance in jobs?
or I should use something like int3, float3?
Ideally use the types from the mathematics package as burst has optimizations for them
@safe lintel thanks and what about defining static readonly fields in struct (jobs)?
public struct A{
public static readonly NativeArray<Vector3Int>.ReadOnly MainDirections;
//...
}
I would like to use them outside
Adding readonly can affect performance?
sad, i misunderstood what burstdiscard did
You can but burst provided stucts allow for more complex math.
Pretty sure this ain't going to with for you
Static readonly [] is supported in burst though
No, I do not need complex math, only about performance
Behold, my incredibly overengineered and hyper optimized way to calculate within circular range boolean.
Is it worth changing all my vector3int fields?
Generally, yes.
OK, thanks. It is weird, it does not have utility static fields for directions :/
You have to use the math (note the lowercase) static class functions.
There is 'math', yes thanks. I am really noob in this env, π I know
int3 right =(int3) math.right();
math.right() is just a constant
I mean create it but it is value types, so it is OK
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float3 right() { return new float3(1.0f, 0.0f, 0.0f); }
Huh, didnt realize this was a thing.
there's this whole animation prediction loop for ghosts as far as i can tell
completely undocumented
except the scripting api
It's fully hybrid, relying on a companion GO, so ewww.
There are repos out there that attempt to do vertex transformations using a dynamic buffer but yea, unfortunately
yeah but these are only good for single loops
they don't really do blending between animations etc
they're great for static details in world that need animations
True. I am very interested in seeing how unity does this when they release the dots version...
GhostPresentationGameObjectAuthoring
GhostPresentationGameObjectSystem
full hybrid system here
works very similar to my hybrid system
That looks just like companion GO transform system..
https://docs.unity3d.com/ScriptReference/Object-hideFlags.html Yea, seems like instantiating these dont set the hide flags.
yeah i actually have a toggle for these for my camera/cinemachine baking
UnityEngine.HideFlags.NotEditable |
UnityEngine.HideFlags.DontSaveInBuild |
UnityEngine.HideFlags.DontSaveInEditor |
UnityEngine.HideFlags.DontUnloadUnusedAsset;
public static HideFlags HideFlags { get; set; } = HideFlagsDefaults;```
{
var flags = CinemachineCreationSystem.HideFlagsDefaults & (ShowCameraGameObjects
? ~HideFlags.HideInHierarchy
: CinemachineCreationSystem.HideFlagsDefaults);
CinemachineCreationSystem.HideFlags = flags;
var queryBuilder = new EntityQueryBuilder(Allocator.Temp).WithAll<Transform>().WithAny<CinemachineVirtualCamera>();
foreach (var w in World.All)
{
if (w.GetExistingSystem<CinemachineCreationSystem>() == SystemHandle.Null)
{
continue;
}
var query = w.EntityManager.CreateEntityQuery(queryBuilder);
foreach (var entity in query.ToEntityArray(Allocator.Temp))
{
w.EntityManager.GetComponentObject<Transform>(entity).hideFlags = flags;
}
}
}```
that toggles their visibility so i can debug stuff when needed
i was about to merge and add the same toggle to my hybrid stuff
it's very useful though because 99% of time i want them hidden unless i'm debugging something
Yea. Would be nice if companions had the same toggle.
Well, it's only 2 clicks instead of 1 to get to the CGO but still.
True. Companion workflow is just ugh
How can I define an efficient empty NativeArray like Array.Empty?
var nativeArray = default;
var nativeArray = new NativeArray<int3>();
var nativeArray = new NativeArray<int3>(Array.Empty<>(),Allocator.TempJob);
var nativeArray = new NativeArray<int3>(Array.Empty<>(),Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
var nativeArray = new NativeArray<int3>(0, Allocator.TempJob);
is more efficient than Array.Empty
but it kind of depends
if you need to pass it to a job
then just make a 0 size array
Is new NativeArray<int3>() wrong?
or default?
It causes Allocator set to invalid (0)
default is fine if you aren't passing it into a job
and just read length field to check for 0 length
before accessing
What are you trying to do with a 0 sized array?
what actually happens to runtime authoring gameobjects visiblity in a scene with an open subscene and the Scene view mode is set to Runtime Data? how does unity actually hide the visibility?
When set to runtime data, it'll attempt to render the scene using the live baked entity components instead of the gameobjects.
In some situations, there is no path
I want to return an empty one
Is NativeArrayOptions.UninitializedMemory wrong to replace it with the default value Clear?
var nativeArray = new NativeArray<int3>(0,Allocator.TempJob, NativeArrayOptions.UninitializedMemory);
If it's 0 sized, you wont need uninitialized as it wont reserve any memory for the array.
do you know how/where this is done though? I mean I get that rendering takes place with the entities graphics renderer but just not the how gameobjects arent rendered for that scene
if gameobjects when converted do not have a purely entity component representation, it wont be rendered because companion GOs are not rendered in runtime scene view but are during playmode.
"because companion GOs are not rendered in runtime scene view" but this part, how is this done? are we even on the same page because these arent "companion" gameobjects per se, they are the authoring gameobjects which dont exist during standalone, and exist in a inbetween place during various editor modes
Now this is what I think happens from my very brief code dive. If authoring game view is enabled, the standard monobehavior update loop in editor mode occurs, resulting in monobehaviors (i.e. renderers) experiencing OnUpdate() and thus rendering. If runtime game view is set, then that monobehavior loop is disabled in favor of the entities.graphics DOTS update which will then use the baked entities and their data to render.
oh boy, messing around with the subscribing of internal update events doesnt sound fun
It takes a brave coder to do so. Good luck.
I tried making sprite renderer companion GOs (since they're standard MB renderers) work when the subscenes are closed and yeaaaa, I'm not that good.
I have a static utility class with Vector3Int called VoxelUtility. It contains bunch of methods like Calculate specific Distance, Convert spaces, Calculate chunks, etc.
I would like to have it for both Vector3Int and int3 :/
If you're willing to use pointers, just use a void* input and cast either to int3.
I think now, after adding job system for some sections of my game, I should convert all Vector3Int to int3 and it will be OK
If in some situations, I need Vector3Int, I can convert it
For example here,
var point = hitInfo.point + 0.01f * ray.direction; //point is vector3, convert it to float3 and call that method
var voxelIndex = VoxelUtility.WorldPointToLocalVoxelIndex(point, worldSetting.Origin,
worldSetting.VoxelSize, worldSetting.ChunkSize);
I call it in many places in jobs and outside job.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3Int WorldPointToLocalVoxelIndex(Vector3 worldPos, Vector3 origin, Vector3 voxelSize,
int chunkSize)
after 10mins of trying to find it in the code, giving up. i guess ill continue to toggle LiveConversionEditorSettings.LiveConversionEnabled instead
int3 == int3 returns bool3 :/ So, I have to use Equals. Love Rider decompiler, help me a lot
yep equals or math.all()
I swear to god...
Today on "I don't math", I find myself looking up the distance formula between 2 points...
Do we now have to specify with WorldSystemFilters for systems in groups instead of just relying on the groups specification?
me
afaik it depends on whether or not the group is in the world
e.g. adding a system to PresentationSystemGroup won't add it to the server in netcode since the server doesn't even have that group, even without specifying a WorldSystemFilter
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
public class ServerSpawnSystemGroup : ComponentSystemGroup
{
}
[UpdateInGroup(typeof(ServerSpawnSystemGroup))]
public partial class ClientSpawnSystem : SystemBase
{
...
}
This threw me warnings
What's the warning?
A system ClientSpawnSystem could not be added to group ServerSpawnSystemGroup, because the group was not created. Fix these errors before continuing. The system will not be added to any group and thus not update.
You also need [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)] on ClientSpawnSystem
Systems will not inherit world filters using update in group sadly.
This is what my original question was if this is now a necessity.
Well, you wouldn't need [WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)] with a system in PresentationSystemGroup.
Systems updating in PSG do inherit the client world filter but that I think is the only case.
I guess I just always assumed it would work π€·ββοΈ
Should you not use WorldSystemFilterFlags.Presentation there anyway now? π
I don't want the system in the default world presentation group
It's the "gameplay" player camera system
there is a second field in WorldSystemFilter to choose the default group
Ok, so think I found it. It's a second parameter of the filter aka [WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation, WorldSystemFilterFlags.ServerSimulation)]
^
where is the dots q&a thing announced?
ahh thanks.. so it's only visible here:
?
?
No, the forum category right next to the arrow...
haha damn.. why in the hell could i just not see that π
i think the unity forum just annoys me by default ( ux not the content )
Yeah it's kind of a sleeper this go around
i think that's fair enough tbh, really positive that it's happening in any case
What do you mean? There are a dozen of us in this channel. DOZEN.
Hey! Does anyone know if using dots can solve the problem with jittering when far away from the origin?
Also does anyone know if the physics engines use double precision? Either havok or the other? Because this is also crucial
Afaik the problem is in gameobject, transform has a 32 bit float for each axis, but with dots can't we make it a double?
there's no out of the box solution, it's a problem we're aware of though
it's more feasible to replace the transform system with v2 although for my money I wouldn't just leap to 64 bit precision components, it's not the most robust solution and is a pretty heavy performance tax
Im not familiar with that, what is v2?
Transform System V2
Ive been trying for a few hours now but apparently compute and graphics buffers can not be used inside a managed component data in build.
Well, nothing I'm doing is fixing this error, I'm gonna leave it here in case someone else stumbles upon it as well:
ArgumentException: Cannot find TypeIndex for type hash 9863318080490280432. Check in the debug file ExportedTypes.log of your project Logs folder (<projectName>/Logs)
Where that type hash is just a managed component data containing a single ComputeBuffer:```csharp
public class LightBuffer : IComponentData, IDisposable
{
public ComputeBuffer Value;
public void Dispose()
{
Value?.Dispose();
}
}``` It works in editor, but not in build.
is this a mono or il2cpp build
sounds like it's generating a different stable hash in editor/build?
i don't recall how managed components generate their stable hash
Mono.
i would have assumed the same way as unmanaged
A compute / graphics buffer is a intptr and a AtomicSafetyHandle. Both of which are structs but I dont know if that does anything.
Sorry to bother you but do you happen to know how to find it? Google shows exactly zero results for this
Edit: exact query actually shows 3 results, but no link to it
Edit2: And this https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/transform_system.html is still single precision
try add this
[ForcedMemoryOrdering(9863318080490280432)]
ughhhhh, scene header corrupted again. it's getting more frequent for some odd reason
I dont know if this matters but every time I delete library and reimport, the type hash changes.
ahhh
stable hash?
or type index?
stable hash should not change
unless you make changes to component
oh interesting
ok doesn't work on class
type hash is the stable type hash
yeah that shouldn't change
that's weird
though again not sure how managed ones are generated i need to look
but it seems to be the problem that it isn't stable
Also, is there a way to force create a new entity query using the same types as another one but without a change filter?
Ugh, i'll just use a tag component.
use entitymanager create on the second one
Do I need to dispose of it when everything gets destroyed?
it will be disposed when the world disposes
Alright
Sorry it's me again our crashing problem.
Now we have a crash at this line --> Unity.Entities.ArchetypeListMap.Add(Unity.Entities.ArchetypeListMap* this, Unity.Entities.Archetype* archetype)
Can we even influence that?
(Unity.Entities.ArchetypeListMap.Add(Unity.Entities.ArchetypeListMap* this, Unity.Entities.Archetype* archetype) -> void_2e84ca6994a85ec51b0f713f958f6ce4 from Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null+56
Unity.Entities.ArchetypeListMap.Resize(Unity.Entities.ArchetypeListMap* this, int size) -> void_2e84ca6994a85ec51b0f713f958f6ce4 from Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null+124
Unity.Entities.EntityComponentStore.CreateArchetype(Unity.Entities.EntityComponentStore* this, Unity.Entities.ComponentTypeInArchetype* types, int count) -> Unity.Entities.Archetype*_2e84ca6994a85ec51b0f713f958f6ce4 from Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null+2168
Unity.Entities.EntityComponentStore.GetOrCreateArchetype(Unity.Entities.EntityComponentStore* this, Unity.Entities.ComponentTypeInArchetype* inTypesSorted, int count) -> Unity.Entities.Archetype*_2e84ca6994a85ec51b0f713f958f6ce4 from Unity.Entities, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null+46
I believe I've saw somewhere BakingType attribute. I guess this attribute mark type which shouldn't be accounted by runtime TypeManager or something to tell Entities that particular type is for baking world only. Though where can I read about this attribute?
Can't find it in docs / changelog / upgrade guide
there's also TemporaryBakingTypeAttribute which is often more useful
/// Attribute that indicates that the component should be removed at the end of each baking iteration.
/// </summary>
/// <remarks>
/// Components decorated with the [TemporaryBakingType] attribute are stripped
/// after each baking iteration, so you can use them in baking systems
/// to identify entities that a baker has modified during the current baking iteration.
///
/// Components with the [TemporaryBakingType] attribute are not exported in the runtime data.
/// </remarks>
/// <seealso cref="BakingTypeAttribute"/>
public class TemporaryBakingTypeAttribute : Attribute```
/// Attribute that indicates that a component should persist in the baking world, but shouldn't be exported with the runtime data.
/// </summary>
/// <remarks>
/// During incremental baking, components with the [BakingType] attribute persist in the baking world.
/// This allows baking systems to process entities which haven't been modified during the current baking iteration,
/// but which are dependencies to the final result of the baking.
///
/// Components with the [BakingType] attribute are not exported in the runtime data.
/// </remarks>
/// <seealso cref="TemporaryBakingTypeAttribute"/>
public class BakingTypeAttribute : Attribute```
can't catch difference
oh ok, difference is in where/when baking comp should be removed. BTW what is baking iteration? How they can be controlled?
The current way of how exclude default transform components after conversion is just remove them in custom baking sys?
how can I add component as chunk component in baker?
How exactly do archetypes/chunks increase their memory capacity when entities are becoming too large ?
And when does this happen ?
Do they always ensure that atleast like 100 entities fit into one chunk ? Or do they just step up from 16KB to like 32KB and then 64KB ?
Cant find anything about that, but i heard like a dozend times that chunks incrase capacity for big entities
Can anyone give me some info about the costs of casting a collider in ecs physics vs adding it to physics world and handling events?
The docs suggest casting is expensive, but compared to what?
How do you organize code for your NetCode projects?
Looking for some design advice here: Say I have a generic Health component and I can put this on random entities, Characters, props, doors etc. How should I handle the special cases where specific things "die"? I.E a character has to play a death animation, the door has to swap model to a broken one, props might just disappear but spawn some "explosion" particle effect.
Would I handle all of these in a single system as multiple different jobs running on different components/aspects? So maybe I end up with 10-20+ jobs in that system, depending on how many different 'things' can die in special ways? Or do I make a system for each type?
There like dozends way to realize this... one way i usually go is :
Entiy{ Health, OnDeathSpawnExplosion(...) }, Entity{ Health, OnDeathPlayAnimation(...) } etc...
Therefore you can write multiple specialised systems handling such cases.
Like
Entities.ForEach((in Entity entity, ref OnDeathPlayAnimation odpa, ref AnimationController ac) => {
ac.SetTrigger(odpa.Trigger);
// Some other stuff, its just pseudocode
});
Does anyone know if theres a math function for mathf.approximately?
(double) Mathf.Abs(b - a) < (double) Mathf.Max(1E-06f * Mathf.Max(Mathf.Abs(a), Mathf.Abs(b)), Mathf.Epsilon * 8f); You can code ya own version but yea, it doesnt look very optimized.
I just do math.abs(a-b) < 0.01
yeah I did try looking through the massive list, I guess the manual way is the best way, thanks a lot
Is dots enviroment going to work on unity 2021.3.11f1 ?
Im facing some new editor errors after importing com.unity.entities here:
Library\PackageCache\com.unity.collections@2.1.0-exp.4\Unity.Collections\NativeParallelHashMap.cs(111,36): error CS0117: 'AtomicSafetyHandle' does not contain a definition for 'SetNestedContainer'
Assuming you don't destroy your entity when health is <0 how would you track the "animation has been played" or "effect has been played" state in this example? I was thinking by adding a component, but that wouldnt really scale since each OnDeath type would need their own "it has been done"-component
You could simply fire an event "outside" the ecs ^^ Tag components are not such a good idea since structural changes
No. For DOTS 1.0, you must use 2022.2
If you want to remain on 2021 LTS, you must use Entities 0.51
Also, DOTS Q&A is open, write your questions on the forums!
It is on 0.51 actually π€ what could it be?
Did you restart the editor?
Yes it even suggests to enter on safe mode
Actually i made it to work properly on unity 2022.2.0b8 although this unity version crashes on ubuntu when i try to enter or download a project from the cloud so im trying to change the version to manage to use dots on ubunto
Maybe I'll try 2022.2.0b16 beta on ubuntu and see if it works
Ouch, linux development. Dots is extremely experimental and unstable even on a windows environment. So unless you want to try 0.17 DOTS, you might be out of luck.
Use 2022.2 F1
unityhub://2022.2.0f1/1c1f8590be28
ill give it a shot! How do i use the address to install it?
Just plug that into a browser and it should prompt you to open unity hub. It'll then open up the standard download and install overlay for 2022.2 F1 (which is currently hidden to the public which is why you need to do it manually)
Let me try it! Thank you!
Oh I meant more like how can I make sure this system wont run again the next frame? Since health is still <0. That's why I mentioned the comp, since they you could do WithNone<AnimationWasPlayed> or similar. But since structural changes suck it's not a good idea
Its not working by putting that on the browser. Am i missing some characteres like https:// or something?
It workes on windows though
Use the third link from the top, the Linux Download Assistant
oh wait it worked just ook more time than windows. thank you ill try installing this version of unity
Ah thats what you meant... hmmm... probably i would simply have a bool somewhere which is then activated. No structural changes and it will only "run" once
You can also just toggle Enabled on it
Thanks for both suggestions, still on 0.51 so will go with bool approach, but for 1.0 I'll be using enabled π
I've only worked in 0.51 so far - a new course started this semester, currently working on exam project - and we were advised to either use a tag or toggle enabled. By some of the guys from the DOTS team π
I'm interested in an answer to this question as well. Looking at your code, I'm not sure exactly what you're trying to accomplish, though? Is this singleton going to be accessed from other systems?
Yes there is another system that updates the singletons value
Are you manually setting up the job dependencies for that one as well?
I suppose what I don't really understand is how the call to singletonArray (using ToComponentDataListAsync) changes the dependencies versus just using SystemAPI.GetSingleton.
https://pastebin.com/ei0AUnXz This is the whole test.
https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-singleton.html
However, singleton API calls don't ensure that running jobs are completed first.
I remember hearing that Ixion used DOTS in their game; it just released today.
Are you just worried about the singleton creation, then? And making sure it happens before the usage in System C?
https://pastebin.com/gsffp83C If I change it to use GetSingleton I get
Ah, I understand now.
Did you consider doing what it suggests in the documentation? Using https://docs.unity3d.com/Packages/com.unity.entities@1.0/api/Unity.Entities.EntityManager.CompleteDependencyBeforeRW.html
Or are you wondering about the "restructure the data dependencies" part?
Isn't this creating a sync point?
Yes, I believe so.
In my case, I think I've resigned to just doing all the singleton modifications in a separate system group and just accepting the sync point. I'd assume you can manually configure the dependencies, but I don't really know how. And my use-case is a library so I don't want to force people to have to deal with that.
Did you try manually setting up the dependencies?
Not sure what this means tbh^^
I think the main problem here is that the automatic dependency management doesn't really work with singletons. Since they're obviously a separate entity. I could be totally wrong about that, I'm just not that familiar with the automatic dependency management.
Well, you'd have to sort out which jobs are reading the singletons, and which are reading/writing them. And then just order the dependencies appropriately. If you kicked off all the jobs in one system, maybe it would be obvious how that would be done?
Dont forget everyone to post DOTS questions to the unity devs here: https://forum.unity.com/forums/dots-dev-blitz-day-2022-q-a.840/
To put that another way that might be clearer - Just merge Systems A, B, C into one SuperSystem. And you can see how you could just set up the job dependency on each job so they happen in the right order. No sync point.
I assume doing that is possible between separate systems. I just don't know how.
Yeah I understand. But it would mean all systems that use the singleton would need manual dependency on those that change it no?
Yes, correct.
Which is, I think, a bit of a gap in the automatic dependency management system.
https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/components-singleton.html mentions you can "restructure the data dependencies" but I don't know what that means.
To elaborate on that, "data dependencies" presumably means component dependencies. And thus, the automatic component dependency management system. But that system does not operate on the most common use-case for singletons where you pull a singleton into the job's context while the job is operating on another entity type (like you have in System C), AFAIK. If you're only using the singleton component in queries directly on the singleton component, then you don't need to restructure anything. It just works normally. So I think the documentation is just inaccurate.
I think it might mean "restructure the job dependencies manually", which is what I suggested.
Is it only IJobChunk that supports generic?
Anything except IJobEntity should be fine for generics
It's just code gen doesn't handle generics well
Thanks, IJobEntity would be nice though x)
one of my questions for the Q&A was going to be if there is a roadmap for physics - is there already an existing roadmap somewhere for unity physics i can look at?
thanks yeah i've seen this, there's not really much on specifics
i guess i'll ask the question
Is it possible for a race condition to appear on readonly lists?
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffcf5805db3 (6cc6969db45f06c2133de7c391f7015) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.FailOutOfRangeError
0x00007ffcf5805cfa (6cc6969db45f06c2133de7c391f7015) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.CheckElementReadAccess
0x00007ffcf5805df8 (6cc6969db45f06c2133de7c391f7015) [unknown:0] Unity.Collections.NativeArray`1<System.Single>::Unity.Collections.NativeArray`1<float>.get_Item
0x00007ffcf5804e31 (6cc6969db45f06c2133de7c391f7015) [SampledAnimationCurve.cs:57] SampledAnimationCurve::SampledAnimationCurve.getValue
0x00007ffcf5804ab8 (6cc6969db45f06c2133de7c391f7015) [SampledAnimationCurve.cs:38] SampledAnimationCurve::SampledAnimationCurve.EvaluateLerp
0x00007ffcf580d6ba (6cc6969db45f06c2133de7c391f7015) [Noise.Job.cs:44] Noise.GetFractalNoise<Noise.Perlin2D`1<Noise.Perlin>>
0x00007ffcf5827aff (6cc6969db45f06c2133de7c391f7015) [DisplacePersistance.cs:32] DisplacePersistance`1<Noise/Perlin2D`1<Noise/Perlin>>::DisplacePersistance`1<Noise.Perlin2D`1<Noise.Perlin>>.Execute
0x00007ffcf5827c65 (6cc6969db45f06c2133de7c391f7015) [unknown:0] Unity.Jobs.IJobParallelForExtensions.ParallelForJobStruct`1<DisplacePersistance`1<Noise.Perlin2D`1<Noise.Perlin>>>.Execute(ref DisplacePersistance`1<Noise.Perlin2D`1<Noise.Perlin>> jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) -> void_b35d890588629bdec7fa050c06b58eee from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
0x00007ffcf5827606 (6cc6969db45f06c2133de7c391f7015) 3abde48db1478a857c1e18670cc1cb18
I'm still trying to fix this issue, that appears only when burst is enabled
If someone understands it and can pinpoint what's happening would be really cool
System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length. Seems simple enough, you're overrunning your buffers. Check where you increment any counters or indices and see if the numbers add up right.
Could you explain further what you mean by overrunning your buffers?