#archived-dots
1 messages · Page 14 of 1
just saying a system tree that shows you the order and groups of systems would be a lot easier to visualize the system execution order
yeah but you either have to be in play mode to see your systems
or edit mode to see editor systems
I am specifically talking about just a system tree to visualize execution order outside of play mode.
eh, don't see how PlayMode is a trouble xD
especially considering there's an actual difference between play and non-play mode with systems
Is there an equivalent to System.Guid.NewGuid() that is safe in background jobs?
It's already thread-safe
oops, I forgot to add that it needs to be burst compatible.
I managed to get it to burst compile by including a copy of the bcrypt.dll (which is in System32) in the Assets/Resources/Scripts (or wherever your scripts are) folder
this is what burst seems to have compiled the Guid.NewGuid() to
Wow really just slap new FixedString64Bytes(System.Guid.NewGuid().ToString()); and no problems? I remember using ToString method inside any burstable, schedule (single or parallel) threw fits about it.
are you doing that outside the job? It doesn't make much sense to call NewGuid and then ToString() right after in a job
Guid is a struct, so it is burst/job friendly
no need to convert it to a fixed string
I have a condition inside a job that will need new guids. Currently implementing a pre-generated guid pool and using a nativearray<fixedstring> type deal.
well, you can do what I suggested as it seems to work fine
for whatever reason unity fails to load the bcrypt.dll
so just including it in your project forces unity to include it
🤔 alright, I'll check it out. Thanks.
yeah np
I cant seem to find the mass field on the PhysicsMass component. Is there an extension method or something Im missing? I set the mass of an entity to 1000, but it can be adjusted and I would like to reflect the changes correctly
InverseMass = math.rcp(mass),
InverseInertia = math.rcp(massProperties.MassDistribution.InertiaTensor * mass),
mass is the value from the authoring
it's stored inverted
on PhysicsMass
I have a very simple
public partial class DestroySystem : SystemBase
it's OnCreate works that's fine
I checked with
Debug.Log("DestroySystem OnCreate");
but it's OnUpdate never runs
how can I make it works??
... the entire codes are
public partial class DestroySystem : SystemBase
{
protected override void OnCreate()
{
Debug.Log("DestroySystem OnCreate");
}
protected override void OnUpdate()
{
Debug.Log("DestroySystem OnUpdate");
Entities
.WithoutBurst()
.WithStructuralChanges()
.ForEach((ref Entity entity, in DestroyData destroyData) =>
{
EntityManager.DestroyEntity(entity);
}).Run();
}
}
create an entity with DestroyData on it?
if a system has a query, it won't update unless 1 of the queries has entities
@rotund token Thank you for your reply
but it doesn't even update when an entity has DestroyData
and also like you said if I commentize the foreach lines
then OnUpdates works fine after hit play
so..
adding tag [AlwaysUpdateSystem] on to the system fixed it
but the EntityManager.DestroyEntity(entity);
only works after hit play
and never works even when an entity created with DestroyData component..
yes because if it wasn't working before
it won't work now - it means no entity is in your query
you don't need [AlwaysUpdateSystem]
this just implies something is wrong
only works after hit play
systems don't exist outside of play mode
unless you specifically tell them to exist in editor world
sorry I said wrong
"only works after hit play"
-> only works right after hit play (maybe only 1 frame).... and doesn't work
something is wrong with your world/setup then
I see...
what's the order between monobehaviour's update and ecs's onUpdate?
i believe monobehaviours update happens first
i'd have to load up work project
i have no monobehaviour updates in my project to compare
@rotund token I see thanks a lot
In unity? Yes
I figured I could split my publicized dll into one with runtime code and one with conditional code
You probably need like 50 variations
If you want to make it universal
I can think of at least 7 conditions in entities
Which I think is actually 1000s of combinations in theory
just 2
1 for runtime, no conditionals
1 for editor
all conditionals
What if you want to enable dots debugging in builds
You should be having different dlls for development and release as well
@rustic rain at which point do you consider this a bad idea?
at a point it can't build
allthough maybe potentially there is a way to mark method to be stripped
before it causes compilation error
anybody explain why OverlapSphereCustom doesn't seem to work as expected with a closest hit collector like this:
if (world.OverlapSphereCustom(t.Value, radius, ref closestHit, filter))```
it seems to return a hit when they are within one unit of distance ( ignoring radius )
without specifying the fraction it returns nothing ever, but the docs mention that overlap queries don't use the fraction anyway
ever solve your issue?
no i just reverted to doing a distance check on NativeList<DistanceHit>
it definitely needs the fraction to not be 0
apart from that i'm not sure what's up
i don't recall having issue with overlap spheres
i think possibly a bug tbh
overlapsphere itself is fine, it works with just the NativeList
but passing the ClosestHitCollector in via OverlapSphereCustom seems to not work as expected
oddly, i tried setting maxfraction to the radius
and it seemed to work, but not 'within' the radius
overlap sphere
literally just uses overlapspherecustom
where T : struct, ICollidable
{
var collector = new AllHitsCollector<DistanceHit>(radius, ref outHits);
return target.OverlapSphereCustom(position, radius, ref collector, filter, queryInteraction);
}
yeah
lemme just double check actually, i kindof wondered why using ClosestHitCollector didn't require an allocator etc, maybe i was using it wrong
whereas in the code you've just posted, obviously it passes the allocated nativelist into the allocator
because you used ClosestHitCollector
it only stores 1 element
it doesn't need to allocate anything
well that's what i thought yeh
it's literally just checking against the closest hit, for each hit
then returning whichever one
it doesn't compare hits
at all
it relies on the physics world property of hits always returning in order
{
Assert.IsTrue(hit.Fraction <= MaxFraction);
MaxFraction = hit.Fraction;
m_ClosestHit = hit;
NumHits = 1;
return true;
}```
is all ClosestHitCollector does
ah so hits are in order of closest to furthest?
furthest to closest i think
but yeah check that
it's a useful property though to use
huh, i didn't realize that
so i don't need to distance check then in any case
so i wonder if the get first collector always returns the furthest ( or closest )
so OverlapSphere is passing the 'radius' into the MaxFraction argument of the AllHitsCollector
i assumed fraction to be a 0-1 value
as mentioned, earlier i tried it like this:
if (world.OverlapSphereCustom(t.Value, radius, ref closestHit, filter))```
which technically should do the job, based on what OverlapSphere is doing with AllHitsCollector
but passing a radius of 25 for example, i was getting hits outwith that radius
maybe i've made some mistake, but it's working ok using the same radius in just a simple OverlapSphere
i'll need to double check i think
you can clearly see Fraction is only used in the assert
are you saying fraction isn't 0-1 being passed in?
because as far as i'm aware it shoul dbe
and if it wasn't you'd be getting exceptions
oh wait this method won't assert in burst
turn off burst and test
well you see:
OverlapSphere is passing radius as MaxFraction in AllHitsCollector right
my understanding was Fraction was a 0-1 value, representing maybe from zero to the max distance of the cast
so if the distance of the cast was 30 then fraction 0.5 would be 15 distance
it's the code you shared, what OverlapSphere is doing
yeah
{
var collector = new AllHitsCollector<RaycastHit>(1.0f, ref allHits);
return target.CastRay(input, ref collector);
}```
the raycast versions definitely use 1
and as i say, if i replicate that, but with ClosestHitCollector, and pass in my radius as the MaxFactor, i get hits outwith the radius
yeah can confirm this result
so overlaps aren't passing a fraction
they pass distance
it would seem so
but as i say, distance isn't being adhered to from what i can tell, unless it's expecting a square or something
my maxfracture value is right
translation - sphere center = fraction
it's not hit distance
it's center distance
hit point
position is at 0,0,0
overlap center at
which is 3.333787 away == maxfraction
definitely not using hit position
at the very least i think it should be distance / radius
whether it should be hit position or not i'm not sure
but the beauty of a collector
you can write your own
i'm pretty sure i was getting hits at distance 29 etc when using 25 radius
because the center is outside
ahhhh wait
yeah
i think that's it
it's behaving differently from just OverlapSphere then, and not as expected
initially i thought, i'll just do a spherecast, with a distance of zero
but realised it was returning positions on the edge of the sphere i think
so i then noticed that OverlapSphere was an option, which worked as expected
but yeah going to make a note for myself
about that fraction/radius
that's... annoying
however passing a ClosestHitCollector is obviously using a similar fraction approach to SphereCast
it is
anyone else notice LocalToWorld.Up is not normalized? its always maxing out at 0.1f instead of normalized 1.0f for each vector component.
is maybe your scale not 1? not sure if that affects ltw
scale must be baked into magnitude on the 4x4 matrix then
yeah makes sense
afaik it does compensate for skew etc with non-uniform scale
tbh it's a good thing because it's uniform with the underlying entity's matrix
for performance all the math operations expect no scale
so if you have scale, you need to remove it from the matrix first
Is there any sources on how to do all this? I rarely work with matrix4x4 or float4x4 until I started working in ECS. The docs describe methods, but not what should be used
sorry was busy
scale is just a multi on the matrix
var scale= float4x4.Scale(new float3(2,2,2);
var localToWorld = math.mul(new float4x4(rotation, translation), scale)
ah yeah makes sense
Also, I don't have to do anything special when working with similar components like LocalToWorld ? currently im doing math.transform(local.Value, point) to convert a point from local to world space.
i think that should be fine
but if you do something like
{
return new float3(m.c3.x, m.c3.y, m.c3.z);
}
quaternion GetRotation(float4x4 m)
{
return new quaternion(m);
}
on the matrix it will be wrong if it has scale
transform operations should be a lot easier to work with in 1.0 and aspects
yeah scale normally doesn't get changed in any game other-than for basic stuff like rocks, logs, or other static items
It will "work" but it's best to keep scale at 1.0 like you said
(oh i was meaning entities 1.0 but yes in general it's advised to keep scale at 1 where possible)
How do you know it will be easier in entities 1.0?
i'd say one of the major influences of aspects is making transform operations easier
Im currently making helper functions exactly for that reason. Trying to keep it in-line with Transform naming convention. For example:
public static float3 TransformPoint (this LocalToWorld local, float3 point) => math.transform(local.Value, point);
however, I think the above method is actually Transform.TransformVector since the scale is not stripped from the float4x4 matrix.
(docs say TransformVector is affected by scale, while TransformPoint is not)
Reading the docs rn and came across: ISystemStateComponentData
Is it basically a persistent component that will not be removed without explicitly removing the component during DestroyEntity ? Docs claim a common use case is for cleanup. How does it differ from just using a normal IComponentData component that is for the same use-case (cleanup) ?
if you call Delete(entity)
there is no IComponentData left to help you clenaup
the entity is gone
if you call Delete(entity) on an entity with SystemStates the entity will not actually be deleted until all system states are removed
All other components are removed though
so the basically pattern is
struct Component1 : IComponentData
struct Component2 : ISystemStateComponentData
// New Entity Setup
Entities.WIthNone<Component2>().ForEach((Entity entity, in Component1 comp) => // ecb.AddComponent2
// Destroyed Entity Cleanup
Entities.WIthNone<Component1>().ForEach((Entity entity, in Component2 comp) => // ecb.RemoveComponent2
the one gotcha with system states is they can't be serialized
if you Instantiate, Copy across worlds, store in subscene etc
the component will not be copied
Ah alright I see. For example, it's best used for components that have NativeArray<T>s that need to be disposed?
there's no real good way of dealing with that
because if you shut down the world they'll all leak since your job won't have a chance to run to dispose them
but yes in theory that type of thing
Really just needs to be some sort of OnDestroy for components (regardless of if a world is shutting down or not, it will always be called)
Either that's a feature that hasn't been added yet, or unity forgot to document it (like a lot of other things 😅 )
the source code is a lot better documented. if you need info, read that instead of the docs. they are really bare bones
Hi guys is there a way to query a physics shape in C#? Something like unreal engines, GetAllOverlappingActors() function.
I have this code but I can't find any functions that would let me query the overlapping gameobjects
PhysicsShape is just an authoring component
it doesn't exist once you convert to entity
is this just for some editor code or something?
No this is a normal C# script to spawn gameobjects. nothing to do with the editor.
I am not using entities though. just trying to use the DOTS physics. Is that not possible
Is there a way to query the component, I can't find any documentation online either.
it sets up PhysicsCollider
part of the physics world
are you looking to query just this collider
or just the physics world in general?
I just need to query this collider
So physics world consists of all the physics colliders I set in the editor?
and to access this particular collider, I first need to query the physics world?
How can I check if an EntityQuery is initialized/valid?
I'm making an editor tool that's only supposed to run a query when in-game and SceneView is focused, so I can't pre-initialize a query until the game is actually running and SceneView is in focus.
im doing some fluid physics stuff and need a computationally cheap way of rendering my particles, im wondering whether entities or unity's particle system would be better for this? (in future i may be using something like metaballs, but for now im happy to just render the fluid particles as spheres)
particles are probably always going to be better
ok, thanks a ton!
if you didn't say physics i would suggest looking at vfxgraph
side note, particle system supports getting particle data in native arrays and manipulating
oh ok that will be very useful then considering how im interopping with nvidia flex, which is a c++ dll
which one would that be ?
some batched copy or memcpy
potentially, some unity objects don't accept NativeArray
var handle = GCHandle.Alloc(vector3Array, GCHandleType.Pinned);
var addr = handle.AddrOfPinnedObject();
var nativeArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<float3>((void*)addr, vector3Array.Length, Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref nativeArray, AtomicSafetyHandle.Create());
#endif
// use nativeArray, when done call
handle.Free();
i'm saying use an array
and simply reinterpret it as a native array
so you can write to it directly in a job/burst/whatever
no need to double memcpy etc
It's effectively a block copy but for NativeArrays
I don't think there is any copy here. just pointing to the pinned memory location
block copy is also really slow IIRC... my unmanaged converter was like 100x faster or something (it's late I might be wrong 😅 )
yeah there's no copy here
that's the point, you're just writing directly to the array
oh yeah true, no copy just pinning object and getting the data directly
handle is for locking managed object into memory like fixed operator?
it's late xD
yeah
there was some unsafe utility methods i seen a year or two ago
that would convert vec3[] to NativeArray<float3>
ah found it #archived-dots message
tertle just gave you a way to do it without any copies
direct writing to same array as native
ah damn that's some good stuff
public static unsafe NativeArray<T> ReinterpretAsNativeArray<T>(this Array array, out GCHandle handle)
where T : unmanaged
{
handle = GCHandle.Alloc(array, GCHandleType.Pinned);
var ptr = handle.AddrOfPinnedObject();
var nativeArray =
NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>((void*)ptr,
array.Length,
Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref nativeArray, AtomicSafetyHandle.Create());
#endif
return nativeArray;
}
poggie woggie stuff
You can use UnsafeUtility.PinGCArrayAndGetDataAddress to simplify thing a little bit
it's also a null check, huh
no handle.Free(); ?
this is utility method
handle is in out
so user calls it himself
do i need to dispose nativeArray or is handle.Free is all that's needed ?
nah, it doesn't work
idk if you even need the handle becuase now it is unmanaged memory. Calling .Dispose on the NA should work fine
you don't get handle
you need handle to unpin it
is there no equivalent for entityQuery.ToComponentDataArray<>() to return dynamic buffers?
huh
like i can use myQuery.ToComponentDataArray<MyDataComponent>() to return an array of those components
i take it that it's not possible to return an array of dynamic buffers in a similar way
I mean
nothing stops you from doing it manually
if you look at how Unity does it
with normal components
what this?
to be honest i was hoping someone would just say 'yeah' or 'no' haha 🙂
it's not a huge deal, was just curious
at the moment what i'm doing is on the main thread, returning a ToEntityArray from my query, then using it to iterate through a BufferFromEntity
just seemed a little contrived for what it was
probably less overhead as i'm not copying a bunch of buffers to an array in any case, but in this case there's not many
I'm dumb. I forget how to disable a PhysicsBody or PhysicsShape in runtime. I want to ignore collisions.
This isn't working: ecb.RemoveComponent<physicsBody or PhysicsShape>(e); //PhysicsBody or Shape ain't considered components I guess.
I finally have a place to code at again, life is a challenge to even have a roof above your head sometimes
Question 1) How do you disable Collison
Question 2) How do you set a componentdata if it already exists and if it doesn't exist addcomponentdata?
addComponentData adds it even if it doesn't exist
set requires it to exist
basically addcomponent data can do structural change
set can't
TYTY
Is it possible to scale an entity yet?
Scale has been a thing for a while
I don't suppose anyone knows what to do about this error when converting a mesh into an entity Shader [Universal Render Pipeline/Lit] on [R Calf] does not support skinning. This can result in incorrect rendering. Please see documentation for Linear Blend Skinning Node and Compute Deformation Node in Shader Graph.
if you have skinned mesh
you should probably look up HR manual
TY looks like it's in LocaltoWorld
it's Scale
yeah I guess I forgot it doesn't really work with skinned mesh's and that sort of thing thanks
I'v seen some tutorial parts
about skinned meshes
you sure?
well I guess its just finicky
I'll just stick to mesh's without bones for the time being
Scale worked like a charm, now when I pick up items in my MMO, they tween up to the left in addition to a chat box message, that part seems superior to WOW already.
I think in WOW, you already had a visual of what you grabbed, but in my game with tractor beams snagging everything around you, it helps to have a visual
Interesting
byte* ptr = (chunkComponentTypeHandle.IsReadOnly)
? ChunkDataUtility.GetComponentDataRO(m_Chunk, 0, typeIndexInArchetype)
: ChunkDataUtility.GetComponentDataRW(m_Chunk, 0, typeIndexInArchetype, chunkComponentTypeHandle.GlobalSystemVersion);
var archetype = m_Chunk->Archetype;
var length = Count;
var batchStartOffset = m_BatchStartEntityIndex * archetype->SizeOfs[typeIndexInArchetype];
var result = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>(ptr + batchStartOffset, length, Allocator.None);
looking at how chunks memory is done
looks like per each archetype, there's unique memory layout
very interesting
btw, this is pretty much how you can create your buffer data array manually
but that rather would be buffer accessor data array
which you probably can wrap in some nice fashion like CDFE
with [int] getter
#if !NET_STANDARD_2_0 && !NET_DOTS
#warning Project is expected to have API Compatibility Level set to .NET Standard 2.0
#endif
hmmmm
is that a thing?
I should stick to 2.0?
do you need .net4 because .net2 is perfectly fine. it's not even comparable with microsofts .net2. it's weird tbh as you have a lot of new features also in .net2
Yeah, that's because of their own mono fork
exactly, they just adhere to the standard but have added lots of features
I want c# 10.0 so hard
.net standard 2.1 is mostly ahead of .net4
dont get confused by the numbers
.net 2.0 is roughly equiv to .net frame 4.6-4.8
.net 2.1 has no rough equiv in framework
unless you need some very specific, probably windows only api, then you should not be using .net framework 4 in unity
at least in 2021+
looking forward when .net core is a thing in unity
that brought a lot of changes and improvements.
downside, some of them so big that unity can't just upgrade 😄
the biggest change is probably domain reload
also .net core is fast! behind burst but not by much
noice! and then i'll say, CALLED IT!
no, i say that mostly because of the preparations done. sure, couldn't mean anything but i'm optimistic
if not, max 3 months
fun fact
points to https://docs.unity3d.com/Packages/com.unity.physics@0.60/index.html which doesn't exist
netcode etc does as well
and 0.60 is their current internal version
All of their latest entity package links point to 0.60 versions. It's so annoying. I know to manually edit the hyperlink to say 0.51 but will the random programmer know? Probably not.
random programmer probably doesn't know latest is a thing!
One of my packages upgraded to 0.60 and back to 0.51.1 once... was really weird
use DisableRendering component
god damnit everything. Why does google and unity return nothing except when specifically searching "DisableRendering". I searched for hours. Oh well. Thanks.
yeah, just assign layer to gameobject before conversion
Well yea. But I was referring to runtime.
in runtime you will need to change RenderMesh component
it contains layer value
I just had a genius idea for ECS
what if make codegen that will let you build state machine jobs
so you write async code in a normal async fashion with all burst/ecs constraints regarding types and etc
and codegen generates a whole job + component with all required fields for such async code running
kek
i think that's the way for FSM. philsa did aomething similar for his polymorohic structs. source is available
I'v seen polymorphic
that's not it
I talk here about extension similiar to IJobEntity
that's why i said similar. he wrote it for usage in FSM.
you write job, execute method with params
i just don't see the point much to generate a whole job. way too restrictive
generating a layout for the job though to reduce the boilerplate would be cool
i dunno, maybe it has some merit. could turn out great
the reason for job is because there is no other way simply
you can only iterate it with normal system
and by having component - probably the best option
potentially maybe you can simply generate struct
with input method of DoUpdate()
yeah, that sounds like a solution
but that would mean you'll have troubles using it, since it's generated code
you'd need to write the struct and the method, then generate code from it
yeah, I meant end result
what would it be
in my opinion best solution - generate ready system with job iteration
but if it's Unity which would do it (and I highly doubt they ever will), it can probably be generated into Job
Dots physics collisions is weird... If a bunch of clumped physics collisions happens, the game freezes sometimes like a random wandering walk is happening to free em.
Is there a way to mitigate this?
build it without checks, should probably help with lags
How would I go about stripping scale from a float4x4 ?
when i have a question, i google my past self 😄
i figured it out a few years ago it seems
I actually figured it out looking at the TRS function lol
float3x3 r = float3x3(rotation);
return float4x4( float4(r.c0 * scale.x, 0.0f),
float4(r.c1 * scale.y, 0.0f),
float4(r.c2 * scale.z, 0.0f),
float4(translation, 1.0f));
just divide, or use TRS
yeah what i posted is basically how to get scale
then just invert the multiplication
oh the actual code is a few posts above
{
var scale = localToWorld.Value.GetScale();
var inverted = scale.Invert();
var value = localToWorld.Value.ScaleBy(inverted); // remove the scale
return new quaternion(value);
}```
what i linked is just the the extensions this method uses
there really needs to be a Scale property on LocalToWorld
are buffers that are inspected usually refreshed? i have to deselect and select the entity to get the current values. i'm pretty sure the refreshing worked at some point. maybe my custom inspectors break the behaviour. any ideas?
They refresh for me. It's likely you're not updating the inspector correctly
yeah thanks. i never implemented this in my inspectors. thought i didn't need it 😄 it seems to break refreshing of the default inspectors too so that wasn't a good idea
hm, no idea how to do it. @rotund token you talked about this at some point. how are you updating your custom inspectors?
yeah buffers aren't refreshed in inspector
i believe values update but size/elements don't
oh is that normal behaviour or something I've broken?
never noticed. quite lame. but thanks
didn't have much time for coding the past few days. I've finished the generic stat data type now. removing took me the longest time. that was tricky
Its any good template/video about netcode + ECS with unity version 2021+
only tutorial i know thats half decent
hah, wanted to post the same link. it doesn't get any better than this
I wonder just how good documentation/examples will be with 1.0
they've repeated a number of times it was one of the weak points they identified with the preview of dots so far
these examples currently its just pain
It's actually a bug. The entity count increases, but the element does not appear/refresh UNLESS you either manually refresh the inspector (selecting something else and back) or by clicking on + Add Element. Also, element value(s) update correctly.
yes it's definitely a bug
i just mean the behaviour is normal, as in he hasn't broken it himself
@rotund token @viral sonnet Here's the current behaviour. Everything works other-than new entities appearing
Here's the SystemBase used:
static int c = 0;
protected override void OnUpdate () {
bool onAdd = Input.GetKeyDown(KeyCode.Space);
bool onRemove = Input.GetKeyDown(KeyCode.LeftControl);
bool onIncrement = Input.GetKeyDown(KeyCode.W);
bool onDecrement = Input.GetKeyDown(KeyCode.S);
Entities.ForEach((ref DynamicBuffer<IntBuffer> buffer) => {
if (onAdd) buffer.Add(new IntBuffer { Value = c++ });
if (onRemove && buffer.Length > 0) buffer.RemoveAt(buffer.Length - 1);
if (buffer.Length == 0) return;
if (onIncrement) buffer.ElementAt(0).Value++;
if (onDecrement) buffer.ElementAt(0).Value--;
}).Schedule();
}
What does "build it without checks" mean?
integrity checks?
I think so, thank you.
It crashed my library to uncheck that so I am rebuilding my library for the next half hour
I think it will be worth tho
This is why I have two copies of my project open always, when one crashes I work on the other, almost always one crashed, lol
If you experience this too, key is making one project light mode the other dark.
Its funny, I work in two different places on the projects like I'm two different developers collaberating
Can't work on same section since the temporary changes wack each other.
guess i'm lucky, i don't experience any crashes ^^
That is a horrible work pattern. Use version control and create branched for big changes
do you think it's crashing because you have 2 copies open 🤔
wouldn't that be funny 😂
seems like gamesettingscomponent got removed also with ForEach not returning void?
Entities.ForEach does not return void
it does for .Run and afaik when no dependency is used
Context is based off of the error he is getting. the .Schedule() is throwing an error
but yes Run(), and Schedule() or ScheduleParallel() without a dependency return void
So I get this warning, and I'm assuming I can just ignore it right?
There is no defined ordering between fields in multiple declarations of partial struct 'WheelColliderJob'. To specify an ordering, all instance fields must be in the same declaration.' was programmatically suppressed by a DiagnosticSuppressor with suppression ID 'SPDC0282' and justification 'Some DOTS types utilize codegen requiring the type to be partial.'
IJobEntity?
yeah it's annoying
you can add a structlayout tag to it if you want to hide warning
I just told VS to suppress the warning to none.. Any benefit of using the layout attribute in this case?
nah
i dont really use this job type anymore so i haven't noticed the issue recently enough to find best solution
What do you use now?
i pretty much only use IJobEntityBatch
What do you do differently than the source generator for IJobEntity ? To me, the generated code looks pretty decent
there are a lot of optimizations you can do
store temp data per thread
change filters
memcmp on a whole chunk to detect any changes efficiently
change filters definitely the #1 though
Filters?
change filters tell you if any component in the chunk may have changed value snice the last time the job run
lets you early out if there's no changes
also order filter to detect when new entity added/removed
ah alright... first time hearing about filters
my favourite feature
though i think you should avoid them on queries and instead do them in a job
as it causes a mini sync point
Ah ok so this video explains the same thing: https://www.youtube.com/watch?v=M3o9yOSTdrQ (1:30 for explanation). So any IJobEntity that uses ref will effectively mark that chunk as written to, wasting performance for any future jobs that need to reflect if it actually changed at all. This is regardless if the value is changed because it technically was changed since it is value-type passed as ref, and there's no performant way to determine if it was changed or not.
yes
if you want to use change filters you have to be very particular about how you code
it is a bit of a pain
and for most users not required
but if you want huge scaling performance then it's how you can do it
i.e. i was testing my effect system at 100,000,000 effects on 10,000,000 targets
and the overhead was under 2ms
optimizing this was what really enforced my belief in them
but i had to come up with a bunch of tricky (hacky) was to avoid triggering the filters
In your IJobEntityBatch how do you access the actual filter logic to determine if it changed or not?
because so far only queries show results regarding their usage
oh wait
I think I found something:
Are those and similar what you use?
Also, I think unity might expand on the functionality of filters. ie add the ability to write data but not trigger filters
you can already do this in IJobEntityBatch
batchInChunk.GetComponentDataPtrRO()
you said you needed to do some hacky stuff to avoid triggering them?
won't trigger filter but you can write to it
so what i did was get the ro ptr
and write to it

then do memcmp on the old/new data
if it's changed i manually trigger filter
(wrote an extension)
that trick optimized a job from 16ms to 2ms with 100m entities
i developed that trick for a timer component
timer.value = math.max(0, timer.value - dt)
would always trigger a change filter
but if they're all 0
nothing has changed
neat
generally you'd use a component for state etc
which is fine for nearly all use cases
but i was trying to right this with completely static archetypes
as it makes saving, networking etc much simpler
yes! preach change filters. the best feature hardly anyone knows how to use correctly
my strategy for spreading the gospel is to just tell enzi then he tells everyone else
statemachines are something I really like to work with in OOP, but structs make it difficult to infer logic from types since there's no inheritance at play
lmao 
once 1.0 a LOT more people will jump ship to ECS since mono/OOP kinda sucks after getting used to this design flow now
ngl a lot of shit is easier to understand using entities over MonoBehaviours
🤣 the trickle down information exchange
there's a features in 1.0 i really need, hurry up unity
Part of the reason I really like working in Burst/Jobs so much is for that extra level of "focus"
i expect a lot of frustration and crying once 1.0 hits
meh, that will pass once some content creators release some videos/guides about ECS
Anything specific?
most content creators will have a hard time with entities. suddenly a half assed solution won't work out. i expect a lot of abuses and event systems
teaching totally wrong stuff
yeah... as for the "right" way it wont end well for some people.
well 2 things. i really want aspects though i'm scared how they'll work in ijobentitybatch
aspects.. I dont recall what those do again. I did hear about them, but it was a while ago
https://portal.productboard.com/wkjyyxmtns7dipwofp19pj8r/c/1157-adaptive-game-architecture?utm_medium=social&utm_source=portal_share
small snippet here though i think they had a bit more info in a talk at gdc
but it's not a lot of info about it
but basically think, structs that encapsulate multiple components and then provide logic that uses all of them
think, a transform
(i'm hoping)
so all the parent, child, rotation, scale, position, etc info can be grouped into an aspect
then it should hopefully provide as easy to use operations as gameobject transforms
aspects still seem so superfluous to me.
try do transform operations with a hierarchy
oh shit yeah now I remember... kind of haha. But yeah, holy shit this will be the #1 go-to for a lot of reasons, especially during prototyping
like, you can't use translation that's local space in a hierarchy
got to use localtoworld
ECS is the future
lmao
why this wasn't the go-to from the start kinda baffles me
like, yeah you may need to do a little extra work to get things rolling
but once the foundation is setup, things get easier
also, a single SystemBase for 1000s of entities is SO MUCH easier than having to apply changes to an array/List of MonoBehaviours
Uh, parallel processing, we've had since the 90s, but the speed of computing was faster than the mind games to learn this.
I mean, the processing potential still is faster then the mind games today. What I ment was in regards to unity going with mono, or at least implement ECS sooner. My guess is Source Generators being a pretty big aspect of their design pattern
I'd say focus just shifted. performance was never that important for unity
SoA is as old as programming. but we never had the ram nor processing power to do the crazy things we are able go now
yeah that too. It's a shame, because open-world, and large scale universes are a big market
i think it's a bit more than that
the entire industry has been shifting from around 2015 towards ecs
unity just on the bandwagon
not saying companies havent been using ecs before this, just the entire industry has started shifting
yeah I noticed that too. Unity is doing pretty good as far as progress goes within the last 2 years or so regarding ECS
first time i heard about ecs was in overwatch. before that it was just a database thing
oop just didn't cut it anymore with the amount of people working on projects and the expectations of players and massive simulated worlds
When I first heard about ECS my reaction was "why wasn't this considered sooner..." 
you could look at c# and question why some things haven't been done sooner 🙂
and then i say again, the focus just wasn't on performance but that it works and is easy
I suppose, but like what @rotund token said the entire industry is shifting, C# as well. C# devs have made a lot of good changes in the past few years
now we have all gone pretty much back to c-style. which is funny to me 😄
glad this, make it as easy as possible but neglect the hardcore programmers era is over in c#
It honestly never should have changed. How processors work is linear... C is linear... ECS is linear... OOP is... messy 
leave it to MS to fk things up haha
i still say they did a fantastic job with c#
but our timeline could have been a lot less, lets say, convoluted
yeah C# is my go-to language... and I dont feel like learning anything else other-than C
I learned JS initially, and when I switched to C# I was like: "wow, javascript is shit"
i used c++ in the past 5 years for ML and now i do ML exclusively in python lol
yep, JS is shit. most browser tech is
why there is no industry standard to just use a single language with an open source API for all browsers to use makes me sad
part of the reason why im totally on board .NET/standard getting scrapped and being just Core in the end
makes application compatibility across platforms a lot simpler
instead of one framework having specific aspects to that only work with x platform
being able to deploy .net core on linux is 👌
it's just .net 5/6 now btw. they dropped the core part for some reason
unity?
nah MS
oh you mean naming convention?
i'll still call it .net core 😄
sounds cooler too 
ah ok going from .NET Framework to .NET core to just .NET
so many memes about all the garbage web devs have to go through just to display a single pixel on a web browser 
anyhow, the push for unity to move everything to .NET (Core) is def going to improve the odds of ECS becoming far more mainstream. Also, that means Mono will finally die off (finally)
yep, already said today (or yesterday?) really looking forward to .net core in unity
time for bed now. good night all o/
part of it is already here. C# 9.0 in unity 2021+... I remember being stuck on C# 7.0 for a good 2 years while C# was already C# 9.0 at the time lmao
gn 
The question is like saying,"Why haven't we always had cell phones. They'd have been useful as soon as we got electricity."
The reason is the increasing usefulness of ECS as multicores happen. We capped clock speed in 2003, but hardware still was able to get efficiencies + video cards.
For a while, first 2-4 cores helped run side processes in windows and such.
But as we get 8-12 cores, its on. Also in the future we'll prolly get 74/128/256 cores
The time for DOTS/ECS is now because its the right time for it.
ahh yes
leaking, hehe
that means you are leaking memory
you didn't dispose of some native collection probably
I had similar problem - each time i added/changed code in vs 2022 and then started my game i got the same error - i use dots physics btw - and later i found forum post that explains reasons behind the problem - and there was suggested an easy solution to turn on Vsync(game / free aspect / vsync (game view only)) and then those warnings disappeared - forum thread : https://forum.unity.com/threads/dots-multiplayer-and-deleting-an-allocation-that-is-older-than-its-permitted-lifetime-of-4-frames.760391/
vsync enabled, free aspect and same thing
Is there a way to to cast or reinterpret a byte[] to NativeArray<int> without copying memory? Just reading the same memory location in where the byte array is, but as a NativeArray<int> ?
Did you try to build the game - in one post user wrote that after he did the build warnings stopped to show?
no
there is
public static unsafe NativeArray<T> ReinterpretAsNativeArray<T>(this Array array, out GCHandle handle)
where T : unmanaged
{
handle = GCHandle.Alloc(array, GCHandleType.Pinned);
var ptr = handle.AddrOfPinnedObject();
var nativeArray =
NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>((void*)ptr,
array.Length,
Allocator.None);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
NativeArrayUnsafeUtility.SetAtomicSafetyHandle(ref nativeArray, AtomicSafetyHandle.Create());
#endif
return nativeArray;
}
You will need to .Free() handle after you're done
Wow thank you!!. I should call the .Free() after I'm done using the NativeArray or could I call it just after that method?
no you can't call it before you are done
Free lets GC to defragment this array
so the moment it does it - native array is pointing to invalid part of memory
My problems with that warning spam started when by accident I pressed ctrl - b in vs 2022 and vs started to build app but tbh not sure if this makes any sense or is it somehow related lol
Ah ok, many thanks!
Also it seems that the ConvertExistingDataToNativeArray<T>() method receives the length of the native array as input, so it would be something like :
var nativeArrayLength = array.Length/ UnsafeUtility.SizeOf<T>();
var nativeArray = NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray<T>((void*)ptr, nativeArrayLength, Allocator.None);
Instead of just array.Length
(Not sure how you did it to write as code here on discord)
Thanks!
in case u haven't done new dots build before go to ecs manual there is explained how to do this(it's important to add scene list component) : https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/ecs_building_projects.html also moetsi tutorial : https://dots-tutorial.moetsi.com/unity-ecs/publish-builds-in-unity-ecs also u must add com.unity.platforms package
What triggers the generated code to generate (temp/Generated Code)? I delete it and recompile but it doesn't get generated. Also tried toggling the "add missing partial keyword" setting in the menu.
what is your burst version?
Version 1.6.6
install either 1.7.3 or new 1.8 preview
they fixed some cache problem
which triggered your issue
oh ok, thanks a bunch
Updated to 1.7.3 but same result, nothing generated and I end up getting the error regarding codegen nothing working properly
what IDE do you use?
Exception: This method should have been replaced by codegen
LambdaForEachDescriptionConstructionMethods.ThrowCodeGenException[TDescription] () (at Library/PackageCache/com.unity.entities@0.51.1-preview.21/Unity.Entities/CodeGeneratedJobForEach/LambdaJobDescription.cs:149)
Rider
have you tried cleaning cache?
not since updating to 1.7.3, i'll try now
same. made sure I was on latest versions, reset cache
What normally triggers the process? I guess I don't understand the process well enough. When a new script is created and [GenerateAuthoringComponent] is used, is it generated on compile of the script?
compilation
anyone familiar with this? why does it run every frame?
Live conversion, it's when you have the inspector for the GO open and it runs to convert GO data to the target entity
Turn it off under DOTS tab up near Jobs.
i haven't selected anything . turned it off now "Live conversion enabled" - still there
Try to close the subscene in the GO hierarchy as well.
lot less now. still there though. eh, guess it doesn't get any better
weird i never noticed this
whole scene runs at 0.88ms so maybe that's why 0.35ms for the conversion are now sticking out 😄
as long as this is only in the editor i can live with it
would be still interested in what it's actually doing. 0.35 is a lot. but going into another rabbit hole. nah, i need to stay focused for once! haha
Starter learning dots today. Feels like a very basic question, but quoting docs "Unity ECS automatically discovers system classes in your project and instantiates them at runtime". Surely you don't want all your systems to run on all your scenes, so how do I filter which run on which scene?
Was looking at the samples and still can't figure out how they select which systems run on each sample scene
Feels like I'm missing something very obvious lol
systems run globally, they are not scene dependent. you can manually create/destroy them and disable automatic creation with the [DisableAutoCreation] tag. though i don't recommend that as i don't think that micro management is needed. systems are very lightweight. if you let them run on the right query, they don't run at all.
Ah, got it. I see why the samples append _samplename to the end of the components then, to allow each sample's systems to only run for that sample
Thanks 👍
can you link them, i don't remember that part
i think that's more of a naming thing. you can look at window->dots->systems to check which systems are actually loaded
https://docs.unity3d.com/Packages/com.unity.entities@0.9/manual/ecs_systems.html
Which if the first result to googling unity ecs select systems to run
@forest fractal Like enzi said. Also, if you need to run a specific system, you can attach a component to only the entities you want to modify (ie editor vs runtime/playmode.) You can of course use this method to tag all sorts of things, like: enemies, vehicles, items, players, etc.
yeah, I noticed soon after
https://docs.unity3d.com/Packages/com.unity.entities@0.51/manual/ecs_systems.html has the same info though
Might as well add, it also says You can view the system configuration using the Entity Debugger window (menu: Window > Analysis > Entity Debugger). which seems to be deprecated
which samples do you mean then?
@viral sonnet I think he means these https://github.com/Unity-Technologies/DOTS-training-samples
I see where my thought process was wrong though, thanks for the help 👍
Haven't had much exposure to ECS's before
ok just wanted to make sure. the _sampleName is just a naming thing. there's no actual logic behind it. at least not out of the box
No one has really. ECS is still in the process of becoming mainstream.
i think 3-4 years is a long enough exposure 😅
I've also seem some rust libraries make use of it for game development (although the gamedev scene for rust is tiny in comparison)
got me pretty interested
you mean bevvy?
and legion before it
ECS is just now hitting 1.0 soon. 3-4 years in experimental doesn't count

from amethyst engine iirc
there are already games released with entities. it's not that experimental for a very long time
yeah true... but in comparison there's just not even close to as many users as "normal" mono unity users
unity is just being very careful with their wording
and there never will be as much users for it for at least 4-5 years.
i reckon at least 60% will give up and go back to MB
yeah that seems like an appropriate timeframe. I do however, expect to popularity of ECS to skyrocket jump once 1.0 is official.
i don't want to be debbie downer here, but it won't. as long as audio, animations, particles, navmesh isn't rock solid implemented
and rendering. AFAIK there is no ECS camera
and we have zero clue about the timeframe of audio and animations which i consider most crucial.
i don't think there ever will be an ecs camera. it can be converted via hybrid
well, considering all their resources are poured into ECS and not exclusive modules suggests within a years time after 1.0 for 1 or 2 modules to be production ready
i dont find audio to be that critical
because we all use fmod? 🙂
pretty much
my wrong spawn offsets made it look weird ... 😄
hm, i need an inspector for a dynamicbuffer and not its elements
would Inspector<DynamicBuffer<T>> work?
you're shit out of luck
if you find a way to do this without editing package let me know
but as far as i can tell not possible
i wanted this to write a custom inspector for my DynamicHashMap
lol, damn. i'm in a similar spot again with my generic byte buffer
just tried, doesn't do anything
hm, i can hack it for my case at least as i can move the ptr around from the current byte i'm at. the UX is shit but at least i can see some values
ok, a debug IComp that has the pointer to the buffer header could be a solution
this is my pain
{
IComponentProperty CreateInstance(Type propertyType)
=> (IComponentProperty)Activator.CreateInstance(propertyType.MakeGenericType(typeof(TComponent)), TypeIndex, IsReadOnly);
var type = typeof(TComponent);
if (typeof(IComponentData).IsAssignableFrom(type))
{
if (TypeManager.IsChunkComponent(TypeIndex))
#if !UNITY_DISABLE_MANAGED_COMPONENTS
Property = CreateInstance(type.IsValueType
? typeof(StructChunkComponentProperty<>)
: typeof(ClassChunkComponentProperty<>));
#else
Property = CreateInstance(typeof(StructChunkComponentProperty<>));
#endif
#if !UNITY_DISABLE_MANAGED_COMPONENTS
else if (TypeManager.IsManagedComponent(TypeIndex))
Property = CreateInstance(typeof(ClassComponentProperty<>));
#endif
else
Property = CreateInstance(typeof(StructComponentProperty<>));
}
else if (typeof(ISharedComponentData).IsAssignableFrom(type))
Property = CreateInstance(typeof(SharedComponentProperty<>));
else if (typeof(IBufferElementData).IsAssignableFrom(type))
Property = CreateInstance(typeof(DynamicBufferProperty<>));
else if (typeof(UnityEngine.Object).IsAssignableFrom(type))
Property = CreateInstance(typeof(ManagedComponentProperty<>));
else
throw new InvalidOperationException();
}
}```
its basically this code here
unfortunately i see no easy way to insert my own type in here
well, i got it working. i see no way of doing a "proper" solution unless unit enables us to add our own types
i just thought of a hack
simple checkbox on authoring that adds debugging capabilities. i think that's nice enough
on the IBufferElementData? i don't think this would even work.
sadface
what's so gross about a debug comp? it's not that you need to see the values all the time
if you name it similar enough that when you search it appears it's fine
the problem is it could break subscenes
if it's an editor only component
so you'll have to add it at runtime
yeah that's why i have an authoring flag
what do you mean by that?
I actually dont know if this is still an issue i haven't tested in ages but way long ago changes to components in build vs editor broke subscenes
as they built with editor data
i suspect this might be fine now
what was your use case there? i never did that. i mean, this is really only an editor thing as i need to see the damn values and not convert bytes by hand lol
i simply had a component that was only existed in editor for debugging
and just that broke the build? wow. i can test this later down the line what an editor directive would do
well if the component is included in the subscene
but doesn't exist in a build
and you try to load the subscene
bad things going to happen
yeah makes sense. i never investigated at which point subscenes are serialized. i expected them to be serialized at build stage
yeah i believe you could build it fine if properly stripped
found an interesting edge case. the setup: a subscene GO that has a manual prefab comp and has an authoring element that creates an additional entity. the additional entity has a missing prefab comp then. when you instantiate the prefab the link to the additional entity doesn't get rewritten. it doesn't even get created
also interesting, when the additional entity has a prefab comp there doesn't need to be a LinkedEntityGroup for it to work
if you're not resizing it probably
just same as nativelist parallel writer
you'd have no safety to ensure this though
ah, that's the thing
A dynamic buffer is just a BufferHeader pointer. Same restrictions apply like using a NativeList. Unfortunately there is no parallel writer yet.
yeah, I get it
It's just that I want to try and expand idea about using DynamicBuffer on entity as EntityCommandBuffer
so not only buffer is accessible out of anywhere
but also ECB is fully burstable
from an ECB you want the ability to resize the buffer during playback?
I want a parallel safe native collection that is resizable, like ECB
because you don't know how many commands you'll write to buffer
could be 0, could be thousands
Yeah same. Also, looking at the source code it totally looks like it would be possible with DynamicBuffer or future similar types.
I assume
dynamic buffer without capacity limit
is just UnsafeList
but I'm not sure whether it supports parallel writing
I can do this, but I want to inquire: What is the most efficient way to determine if you're within "distance radius" of another object?
Doesn't have to be a perfect radius, I don't need square math, I can do x+y+z
In the mean time, you can create a mock ECB that uses interlocking to declare when a resize is happening, freeze when a thread is resizing the array/list, then append data.
wouldn't that be?
(posX - posY).magnitude < radius
Yah, I was just overthinking I spose. That was what I was gonna do.
Goodmorning
I was just making sure ECS/DOTS didn't have anything built in
math is the only thing that DOTS has built in xD
btw
it has
distance
math.distance
Cool, but I want it fast, so even the inbuilt math isn't as fast as addition. Great!
Thats kinda what I wanted.
yeah use math.distance for absolute distance, or math.distancesq for faster results against a squared radius
square roots are expensive
Yup! Double checkin. Good morning all. Happy devvin.
Good to know the exact commands, and both of those probably are more expensive than addition.
This isn't even something I need to maximize around, I become a perfectionist dork at a certain point.,
math.distancesq is just (y - x) * (y - x) where yx are your types (float)
Cost of multiplication is 4x that of addition/sub: https://stackoverflow.com/questions/39719364/what-is-the-computational-cost-of-floating-point-multiplication-vs-addition
You guys gave me waaaay more info that I needed, and I'm just being a computational dork in something that doesn't matter much.
God bless, have an awesome dev day!
Ah yeah, it's lengthsq(y - x) which is math.distancesq
god it's too late for this lmao
You're putting way to much effort into thinking, lolz. Just a fanciful q.
I seriously would not worry about the performance difference of float arithmetics. If performance is a concern, I would look at managing entities in a spatial tree that you can compute distance from.
That way you're not checking against hundreds of thousands of entities every update
You're 100% correct, I assumed that too. But did you ever start out on a whole new architecture and doubt yourself, but still want to dive into coding. You guys assured me I was taking the right decision... Morning stuff.
I'm adding a component in my game when you get close to space stations, you get a menuing window [Dock] [Hail] [Buy] [Sell] [Forge] [Rob] etc
A zone might have 1000-5000 stations tops, so I am not sure I even need a spacial tree
The spacial tree is MOST def the efficiency grabber tho, too early to remember that
is this single or multiplayer?
MMO actually I have research level code from 2003 that worked when I had an inhouse Tekkenlike mmo
This is a client side check so no big
yeah you're going to want a spatial tree of some kind. Not just for managing stations, but other ships in range, projectile targeting, etc. It's best to always have some performant tree of some kind to rely on when accessing a small section of data from a large dataset
Now we're talking!
Is there a built in DOTS.ECS spacial tree? I figure nothing outside of like 500/500/500 units could interact with each other
I am doing the frame shift every 5000, where the world moves around you due to 32 bit limitations
but an actual zone could be 500,000 to 5,000,000 or more I think... Haven't got there quite yet
You're going insanely above and beyond my original question.
The best method imo is some kind of node tree that can query chunks deterministically. I made a fully burstable octree that has on average 0.2ms execution time. Something similar can be used, because my octree is balanced for voxel generation reasons.
Code monkey has something: https://www.youtube.com/watch?v=hP4Vu6JbzSo
Let's make a Quadrant System in Unity ECS to solve problems related to Unit Positions like a Targeting System or Obstacle Avoidance.
✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=hP4Vu6JbzSo
Find Target in Unity ECS
https://www.youtube.com/watch?v=t11uB7Gl6m8
Find Target with ECS and the Unity Job System
http...
it's better than you coming back here pulling you hair out a month later rewriting everything 
I can figure the query, but what about .foreaches? Maybe have a component that designates each sector?
EXACTLY!
At least I can mitigate the refactor knowing about this.
it'd be pretty ghetto code to have a componentdata type for every single sector of about 20,000 sectors
yeah pretty much that, but more of a tree-type for even better performance. Research octrees for 3D or quadtrees for 2D
And I wouldn't trust the inner workings of dots to deal with 20,000 component datas. I'll find some way of tricking the .foreach
I've used spacial isolation since early 90s I believe, gotta isolate only stuff that matters.
you want dynamic/lazy loading of sectors/chunks. Minecraft can have near infinite worlds, but doesnt load everything.
In space, you might not be able to interact with something a few million km away, but you can see it
I want the entity in memory and rendering, but I update the network less often when it's far away.
Now I'm thinking when checking laser hits and such, that stuff will be crowding my .foreach
Oh I know
I'll just add one component
OutOfRelevantRange
and I can add/remove it
This is huuugely good stuff, I knew there was a reason I asked a dumb question earlier
I hate being satisfied with an answer, because now I feel like I accomplished something and want to slack off.
hha
just a quick tip: dont use Entities.ForEach for performant code. Use either IJobEntity or IJobEntityBatch (non-batch is easier as it uses codegen to help you out like ForEach)
Ah, my entities system is an amalgomation system that is ugly but works without conflict or crashes
Dude, this was awesome. Okay, take care, get some rest. Anyone who helps me, if I start making bank of millions/month like mmos do, find me and ask for some change.
lataz
Ecb is already fully bursted
they used function pointer?
Yes
huh, all right
playback has been bursted for years as long as you don't use a managed operation (shared component etc)
Ecb is so much faster than it was 3 years ago
Magnitudes
Last thing: https://www.youtube.com/watch?v=xqtwXD0lFTY Things that are far away, don't actually need to be loaded 😉
Phone auto correct
Do you think this game is made by dots? https://play.google.com/store/apps/details?id=com.dxx.firenow
Why do you think it is?
There’s a very big amount of Bots and all that stuff
I think it's not because ECS can handle way more than just a couple hundred AI. The AI also looks pretty simple too.
I'm not even sure it's made in unity
TF relased on Aug 9, 2022 and already over 1 million downloads. that must be some sick ass marketing. like, posting in different discord channels and asking useless automated questions. - who asks if it's made BY dots.
Is there a way to register component type manually?
through reflection
instead of RegisterGenericComponent
by the looks of it, no
unless I use hacks
like harmony
your probably right it could be a sneaky marketing tactic I was almost tempted to try it
what is TF?
bruuuuh, I am so tempted to harmony patch TypeManager
xD
an ability to register generics through reflection
is a must
huh
modifying assembly
through reflection
bruh
assembly is abstract
and it has no fields -_-
any way to select entitys in either scene or game view and have them be selected in the DOTS Hierarchy?
i do have a selection system for picking in game, maybe there's a way to send an editor event to the hierarchy window?
you'll need a whole system for that
is it possible to send events to the dots hierarchy window?
#if UNITY_EDITOR
Unity.Entities.Editor.EntitySelectionProxy.SelectEntity(state.World, selection.mainEntity);
#endif
ahhhhh
how'd you find that little gem
ah! it was right there
works beautifully, thanks for that @rustic rain
either tertle, or some repo on github enzi sent
slow motion high five dots crew
I need to allocate a huge amount of memory (1 GB), for a super big native array. If I just go with the standard new NativeArray<T>(length, Allocator); it hangs the app for more than a second, because it takes too long to allocate that much memory in one frame.
So my question is, is there a better way of allocating a lot of memory, not necessarily faster, but asynchronously or spread into more frames I guess
well, you can quite literally make an async method
oh wait
nvm
I don't think that would work
I think I tried that but it doesn't let me create native arrays in other threads
Yeah
I wanted to suggest icnreasing capacity with async method
hm
doesn't it have jobified allocation?
Is that what you mean?
How do you create it without clearing memory?
it's parameter
Ah I see, let me check
UninitializedMemory!
I'll try that
Wow yeah, it's extremely fast
It took just 1.4 ms
Hmm, and if I wanted to create a byte[], I guess with that I'm fecked
why not just use native collection in the first place?
Yeah my context is that I'm doing massive hacks, just to try to serialize native arrays
serialize huh
I mean they seem hack to me, just because I'm not super experienced with managing memory
So what I'm doing is creating a byte array (which is serializable)
Then reinterpreting that byte array as NativeArray, thanks to the method that you sent me the other day
And then serializing in a C# job system what I want to serialize to that NativeArray
And everything is working great, except one step now, which is when I create that byte array
And my goal is just not to stall or hang the app in the process
Hold on, I'll send a block of code to explain better
I get what you mean
but I don't think you can construct managed array without initialization
from what I found this feature was added only in .net 5
Hmm I see
I mean I don't need that necessarily
I just need to not to stall the app or main thread
Well anyways, I'll keep thinking about it, thank you very much for your help @rustic rain, you're the best!
what kind of data are you talking about? and where do you need it to go? i see much better ways than just allocating a big block
is that celebration worthy?
hell yeah
i get a project day once every 2 weeks
best day of the fortnight
so a day where you can do whatever your want at work?
character controller i think
i've been really interested in motion matching recently
and want to have a look at that
but i need a controller first
hm, CC is a big one 😄
i'm not going to make anything crazy
probably just base it off the physics sample one
i was having a quick look before work yesterday morning, setting up my data
got to have your classic gravity fields, etc
and then i was like, wait
make everything a stat!
i have a stat system, whole point is to use this for everything
so now gravity is a stat
which i think is awesome
i can just have an item now that changes your gravity
or create a trigger in world that changes it
no extra work
i'm loving the idea of just making everything a stat
or a skill could inverse a monsters gravity for a short while
so they float away