#archived-dots

1 messages · Page 14 of 1

errant hawk
#

Granted, you dont need to control every system, just the ones that you can manage and are order-dependent

#

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

rustic rain
#

but it's already exist

#

literally

#

systems

#

folder

#

Window->DOTS-Systems

errant hawk
#

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.

rustic rain
#

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

drowsy pagoda
#

Is there an equivalent to System.Guid.NewGuid() that is safe in background jobs?

drowsy pagoda
#

oops, I forgot to add that it needs to be burst compatible.

errant hawk
#

this is what burst seems to have compiled the Guid.NewGuid() to

drowsy pagoda
errant hawk
#

Guid is a struct, so it is burst/job friendly

#

no need to convert it to a fixed string

drowsy pagoda
#

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.

errant hawk
#

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

drowsy pagoda
#

🤔 alright, I'll check it out. Thanks.

errant hawk
#

yeah np

errant hawk
#

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

rotund token
#

InverseMass = math.rcp(mass),
InverseInertia = math.rcp(massProperties.MassDistribution.InertiaTensor * mass),

#

mass is the value from the authoring

#

it's stored inverted

#

on PhysicsMass

opal lynx
#

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();

    }
}
rotund token
#

create an entity with DestroyData on it?

#

if a system has a query, it won't update unless 1 of the queries has entities

opal lynx
#

@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

opal lynx
#

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..

rotund token
#

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

opal lynx
#

sorry I said wrong

"only works after hit play"
-> only works right after hit play (maybe only 1 frame).... and doesn't work

rotund token
#

something is wrong with your world/setup then

opal lynx
#

what's the order between monobehaviour's update and ecs's onUpdate?

rotund token
#

i believe monobehaviours update happens first

#

i'd have to load up work project

#

i have no monobehaviour updates in my project to compare

opal lynx
#

@rotund token I see thanks a lot

rustic rain
#

hmm

#

is conditional dll is a thing?

#

I think so

rotund token
#

In unity? Yes

rustic rain
#

I figured I could split my publicized dll into one with runtime code and one with conditional code

rotund token
#

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

rustic rain
#

1 for runtime, no conditionals

#

1 for editor

#

all conditionals

rotund token
rustic rain
#

sucks to be me

#

I guess

rotund token
#

You should be having different dlls for development and release as well

viral sonnet
#

@rustic rain at which point do you consider this a bad idea?

rustic rain
#

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

devout prairie
#

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

devout prairie
rotund token
#

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

devout prairie
#

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

rotund token
#

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);
        }
devout prairie
#

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

rotund token
#

because you used ClosestHitCollector

#

it only stores 1 element

#

it doesn't need to allocate anything

devout prairie
#

well that's what i thought yeh

#

it's literally just checking against the closest hit, for each hit

#

then returning whichever one

rotund token
#

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

devout prairie
#

ah so hits are in order of closest to furthest?

rotund token
#

furthest to closest i think

#

but yeah check that

#

it's a useful property though to use

devout prairie
#

huh, i didn't realize that

rotund token
#

just break point on an overlapsphere

#

and look at the list

#

should see the order

devout prairie
#

so i don't need to distance check then in any case

rotund token
#

yeah sure

#

it's just a useful property

#

often avoids you needing to sort

devout prairie
#

so i wonder if the get first collector always returns the furthest ( or closest )

devout prairie
#

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

rotund token
#

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

devout prairie
#

well you see:

#

OverlapSphere is passing radius as MaxFraction in AllHitsCollector right

rotund token
#

i don't think it should be

#

have you confirmed that?

devout prairie
#

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

devout prairie
rotund token
#

oh

#

that's all hits collider but yes that is weird

devout prairie
#

yeah

rotund token
#
        {
            var collector = new AllHitsCollector<RaycastHit>(1.0f, ref allHits);
            return target.CastRay(input, ref collector);
        }```
#

the raycast versions definitely use 1

devout prairie
#

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

rotund token
#

yeah can confirm this result

#

so overlaps aren't passing a fraction

#

they pass distance

devout prairie
#

it would seem so

rotund token
#

it's definitely not a fraction

devout prairie
#

but as i say, distance isn't being adhered to from what i can tell, unless it's expecting a square or something

rotund token
#

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

devout prairie
#

i thought fraction would be like:

#

(hitposition - spherecenter) / maxdist

rotund token
#

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

devout prairie
#

i'm pretty sure i was getting hits at distance 29 etc when using 25 radius

rotund token
#

because the center is outside

devout prairie
#

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

rotund token
devout prairie
#

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

rotund token
#

but yeah going to make a note for myself

#

about that fraction/radius

#

that's... annoying

devout prairie
#

however passing a ClosestHitCollector is obviously using a similar fraction approach to SphereCast

#

it is

errant hawk
#

anyone else notice LocalToWorld.Up is not normalized? its always maxing out at 0.1f instead of normalized 1.0f for each vector component.

devout prairie
errant hawk
#

yeah scale is 0.1 on the y-axis

#

hmm perhaps scale does modify it

devout prairie
#

scale must be baked into magnitude on the 4x4 matrix then

errant hawk
#

yeah makes sense

devout prairie
#

afaik it does compensate for skew etc with non-uniform scale

errant hawk
rotund token
#

for performance all the math operations expect no scale

#

so if you have scale, you need to remove it from the matrix first

errant hawk
rotund token
#

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)

errant hawk
#

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.

rotund token
#

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

errant hawk
#

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

rotund token
#

(oh i was meaning entities 1.0 but yes in general it's advised to keep scale at 1 where possible)

errant hawk
rotund token
#

i'd say one of the major influences of aspects is making transform operations easier

errant hawk
#

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)

errant hawk
#

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) ?

rotund token
#

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

errant hawk
rotund token
#

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

errant hawk
#

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)

errant hawk
viral sonnet
#

the source code is a lot better documented. if you need info, read that instead of the docs. they are really bare bones

little crystal
#

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

rotund token
#

PhysicsShape is just an authoring component

#

it doesn't exist once you convert to entity

#

is this just for some editor code or something?

little crystal
#

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

little crystal
rotund token
#

it sets up PhysicsCollider

#

part of the physics world

#

are you looking to query just this collider

#

or just the physics world in general?

little crystal
#

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?

rotund token
#

these are cast examples

#

but you can do overlay spheres etc as well

dense crypt
#

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.

late mural
#

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)

rotund token
#

particles are probably always going to be better

late mural
#

ok, thanks a ton!

rotund token
#

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

late mural
#

oh ok that will be very useful then considering how im interopping with nvidia flex, which is a c++ dll

hollow jolt
#

which one would that be ?

rustic rain
rotund token
#

my question is why convert?

#

why not just use the array as a NativeArray?

rustic rain
rotund token
#

    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();
rotund token
#

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

rustic rain
#

wait what

#

didn't know this is a thing

errant hawk
uncut rover
#

I don't think there is any copy here. just pointing to the pinned memory location

errant hawk
#

block copy is also really slow IIRC... my unmanaged converter was like 100x faster or something (it's late I might be wrong 😅 )

rotund token
#

yeah there's no copy here

#

that's the point, you're just writing directly to the array

errant hawk
#

oh yeah true, no copy just pinning object and getting the data directly

rustic rain
#

handle is for locking managed object into memory like fixed operator?

errant hawk
#

it's late xD

rotund token
#

yeah

rustic rain
#

interesting

#

gotta make some extension method for it

hollow jolt
#

there was some unsafe utility methods i seen a year or two ago

#

that would convert vec3[] to NativeArray<float3>

rustic rain
#

direct writing to same array as native

hollow jolt
#

ah damn that's some good stuff

rustic rain
#
        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

errant hawk
rustic rain
#

it's also a null check, huh

rustic rain
#

handle is in out

#

so user calls it himself

hollow jolt
#

do i need to dispose nativeArray or is handle.Free is all that's needed ?

errant hawk
#

idk if you even need the handle becuase now it is unmanaged memory. Calling .Dispose on the NA should work fine

rustic rain
#

you don't get handle

devout prairie
#

is there no equivalent for entityQuery.ToComponentDataArray<>() to return dynamic buffers?

rustic rain
#

huh

devout prairie
#

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

rustic rain
#

I mean

#

nothing stops you from doing it manually

#

if you look at how Unity does it

#

with normal components

devout prairie
#

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

remote crater
#

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?

rustic rain
#

set requires it to exist

#

basically addcomponent data can do structural change

#

set can't

remote crater
#

TYTY

remote crater
#

Is it possible to scale an entity yet?

rustic rain
#

Scale has been a thing for a while

pliant pike
#

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.

rustic rain
#

you should probably look up HR manual

remote crater
rustic rain
pliant pike
#

yeah I guess I forgot it doesn't really work with skinned mesh's and that sort of thing thanks

rustic rain
#

or NonUniformScale

#

or

#

CompositeScale

rustic rain
#

about skinned meshes

#

you sure?

pliant pike
#

well I guess its just finicky

#

I'll just stick to mesh's without bones for the time being

remote crater
#

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

rustic rain
#

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

rustic rain
#

but that rather would be buffer accessor data array

#

which you probably can wrap in some nice fashion like CDFE

#

with [int] getter

rustic rain
#
#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?

rotund token
#

For entities? yes

#

. Net4 is not supported

rustic rain
#

Oof

#

I'd expect smth that is so reliant on c# would support higher version

viral sonnet
#

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

rustic rain
#

Yeah, that's because of their own mono fork

viral sonnet
#

exactly, they just adhere to the standard but have added lots of features

rustic rain
#

I want c# 10.0 so hard

rotund token
#

.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+

viral sonnet
#

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

rotund token
#

yes

#

be nice when we're close to parity

viral sonnet
#

man i hope we get 1.0 preview in the next few weeks

#

can't be that far off now 😄

rotund token
#

if you say that every week

#

it will eventually be true

viral sonnet
#

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

rotund token
#

fun fact

#

netcode etc does as well

#

and 0.60 is their current internal version

robust scaffold
rotund token
#

random programmer probably doesn't know latest is a thing!

errant hawk
rustic rain
#

use DisableRendering component

graceful herald
#

god damnit everything. Why does google and unity return nothing except when specifically searching "DisableRendering". I searched for hours. Oh well. Thanks.

rustic rain
#

yeah, just assign layer to gameobject before conversion

graceful herald
#

Well yea. But I was referring to runtime.

rustic rain
#

it contains layer value

rustic rain
#

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

viral sonnet
#

i think that's the way for FSM. philsa did aomething similar for his polymorohic structs. source is available

rustic rain
#

I'v seen polymorphic

#

that's not it

#

I talk here about extension similiar to IJobEntity

viral sonnet
#

that's why i said similar. he wrote it for usage in FSM.

rustic rain
#

you write job, execute method with params

viral sonnet
#

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

rustic rain
#

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

viral sonnet
#

you'd need to write the struct and the method, then generate code from it

rustic rain
#

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

remote crater
#

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?

rustic rain
errant hawk
#

How would I go about stripping scale from a float4x4 ?

rotund token
#

when i have a question, i google my past self 😄

#

i figured it out a few years ago it seems

errant hawk
#

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

rotund token
#

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

errant hawk
#

there really needs to be a Scale property on LocalToWorld

viral sonnet
#

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?

errant hawk
viral sonnet
#

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?

rotund token
#

yeah buffers aren't refreshed in inspector

#

i believe values update but size/elements don't

viral sonnet
#

oh is that normal behaviour or something I've broken?

rotund token
#

i believe that's normal

#

unfortunately

viral sonnet
#

never noticed. quite lame. but thanks

rotund token
#

it may have broken at some point i'm not certain

#

it is annoying though

viral sonnet
#

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

austere pebble
#

Its any good template/video about netcode + ECS with unity version 2021+

viral sonnet
#

hah, wanted to post the same link. it doesn't get any better than this

safe lintel
#

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

austere pebble
#

these examples currently its just pain

errant hawk
# rotund token i believe that's normal

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.

rotund token
#

yes it's definitely a bug

#

i just mean the behaviour is normal, as in he hasn't broken it himself

errant hawk
#

@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();
        }
remote crater
#

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.

viral sonnet
#

guess i'm lucky, i don't experience any crashes ^^

errant hawk
rotund token
#

do you think it's crashing because you have 2 copies open 🤔

viral sonnet
#

wouldn't that be funny 😂

errant hawk
#

Probably would be a reason why lmao

austere pebble
#

seems like gamesettingscomponent got removed also with ForEach not returning void?

rotund token
#

GameSettingsComponent is not part of unity

#

it's your code

austere pebble
#

mhm

#

then I just blind and I skipped some part in tutorial

errant hawk
austere pebble
#

Maybe I have other problem than this

viral sonnet
#

it does for .Run and afaik when no dependency is used

errant hawk
#

but yes Run(), and Schedule() or ScheduleParallel() without a dependency return void

errant hawk
#

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.'

rotund token
#

IJobEntity?

#

yeah it's annoying

#

you can add a structlayout tag to it if you want to hide warning

errant hawk
#

I just told VS to suppress the warning to none.. Any benefit of using the layout attribute in this case?

rotund token
#

nah

#

i dont really use this job type anymore so i haven't noticed the issue recently enough to find best solution

rotund token
#

i pretty much only use IJobEntityBatch

errant hawk
rotund token
#

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

errant hawk
rotund token
#

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

errant hawk
#

ah alright... first time hearing about filters

rotund token
#

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

errant hawk
# rotund token though i think you should avoid them on queries and instead do them in a job

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.

rotund token
#

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

errant hawk
#

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

rotund token
#

yep

#

that's the one

rotund token
#

batchInChunk.GetComponentDataPtrRO()

errant hawk
rotund token
#

won't trigger filter but you can write to it

#

so what i did was get the ro ptr

#

and write to it

errant hawk
rotund token
#

then do memcmp on the old/new data

#

if it's changed i manually trigger filter

#

(wrote an extension)

errant hawk
#

so performance for you is now a lot better because of filters?

#

2ms vs what?

rotund token
#

that trick optimized a job from 16ms to 2ms with 100m entities

errant hawk
#

so 60FPS to 500FPS

rotund token
#

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

errant hawk
#

neat

rotund token
#

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

viral sonnet
#

yes! preach change filters. the best feature hardly anyone knows how to use correctly

rotund token
#

my strategy for spreading the gospel is to just tell enzi then he tells everyone else

errant hawk
errant hawk
#

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

viral sonnet
#

🤣 the trickle down information exchange

rotund token
#

there's a features in 1.0 i really need, hurry up unity

errant hawk
viral sonnet
#

i expect a lot of frustration and crying once 1.0 hits

errant hawk
errant hawk
viral sonnet
#

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

errant hawk
rotund token
errant hawk
rotund token
#

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

viral sonnet
#

aspects still seem so superfluous to me.

rotund token
#

try do transform operations with a hierarchy

errant hawk
rotund token
#

like, you can't use translation that's local space in a hierarchy

#

got to use localtoworld

errant hawk
#

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

remote crater
errant hawk
viral sonnet
#

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

errant hawk
#

yeah that too. It's a shame, because open-world, and large scale universes are a big market

rotund token
#

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

errant hawk
viral sonnet
#

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

errant hawk
#

When I first heard about ECS my reaction was "why wasn't this considered sooner..." doggokek

viral sonnet
#

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

errant hawk
viral sonnet
#

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#

errant hawk
viral sonnet
#

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

errant hawk
#

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"

viral sonnet
#

i used c++ in the past 5 years for ML and now i do ML exclusively in python lol

errant hawk
#

complexity != functionality

#

C++ IMO is over-saturated with complexity

viral sonnet
#

yep, JS is shit. most browser tech is

errant hawk
#

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

viral sonnet
#

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

errant hawk
#

unity?

viral sonnet
#

nah MS

errant hawk
#

oh you mean naming convention?

viral sonnet
#

i'll still call it .net core 😄

errant hawk
#

sounds cooler too doggokek

viral sonnet
#

right!

#

the stuff out of web tech is so cringe. like node.js ... good lord

errant hawk
#

ah ok going from .NET Framework to .NET core to just .NET

errant hawk
#

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)

viral sonnet
#

yep, already said today (or yesterday?) really looking forward to .net core in unity

#

time for bed now. good night all o/

errant hawk
errant hawk
remote crater
#

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.

austere pebble
#

ahh yes

rustic rain
#

leaking, hehe

austere pebble
#

Always when I tried ECS that thing happens

#

just spam

rustic rain
#

that means you are leaking memory

#

you didn't dispose of some native collection probably

full epoch
# austere pebble ahh yes

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/

austere pebble
#

vsync enabled, free aspect and same thing

glacial hazel
#

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> ?

full epoch
austere pebble
#

no

rustic rain
#
        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

rustic rain
glacial hazel
rustic rain
#

Free lets GC to defragment this array

#

so the moment it does it - native array is pointing to invalid part of memory

full epoch
#

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

glacial hazel
#

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)

rustic rain
#

oh, if you are converting between 2 different sizes

#

then yeah

glacial hazel
#
Thanks!
full epoch
olive kite
#

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.

olive kite
rustic rain
#

install either 1.7.3 or new 1.8 preview

#

they fixed some cache problem

#

which triggered your issue

olive kite
#

oh ok, thanks a bunch

olive kite
rustic rain
#

what IDE do you use?

olive kite
#

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

rustic rain
#

have you tried cleaning cache?

olive kite
#

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?

viral sonnet
#

anyone familiar with this? why does it run every frame?

robust scaffold
#

Turn it off under DOTS tab up near Jobs.

viral sonnet
#

i haven't selected anything . turned it off now "Live conversion enabled" - still there

robust scaffold
viral sonnet
#

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

forest fractal
#

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

viral sonnet
#

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.

forest fractal
#

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 👍

viral sonnet
#

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

forest fractal
errant hawk
#

@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.

viral sonnet
#

oh that's a very old doc btw

#

we are at 0.51

forest fractal
#

yeah, I noticed soon after

#

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

viral sonnet
errant hawk
forest fractal
#

I see where my thought process was wrong though, thanks for the help 👍

#

Haven't had much exposure to ECS's before

viral sonnet
#

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

errant hawk
viral sonnet
#

i think 3-4 years is a long enough exposure 😅

forest fractal
#

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

viral sonnet
#

you mean bevvy?

forest fractal
#

and legion before it

errant hawk
forest fractal
#

from amethyst engine iirc

viral sonnet
#

there are already games released with entities. it's not that experimental for a very long time

errant hawk
viral sonnet
#

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

errant hawk
viral sonnet
#

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

errant hawk
viral sonnet
#

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

errant hawk
#

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

rotund token
#

i dont find audio to be that critical

viral sonnet
#

because we all use fmod? 🙂

rotund token
#

pretty much

viral sonnet
#

my wrong spawn offsets made it look weird ... 😄

viral sonnet
#

hm, i need an inspector for a dynamicbuffer and not its elements

#

would Inspector<DynamicBuffer<T>> work?

rotund token
#

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

viral sonnet
#

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

rotund token
#

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

viral sonnet
#

well, i got it working. i see no way of doing a "proper" solution unless unit enables us to add our own types

rotund token
#

i just thought of a hack

viral sonnet
#

simple checkbox on authoring that adds debugging capabilities. i think that's nice enough

rotund token
#

make it inherit IComponentData as well

#

😄

viral sonnet
#

on the IBufferElementData? i don't think this would even work.

rotund token
#

sadface

viral sonnet
#

what's so gross about a debug comp? it's not that you need to see the values all the time

rotund token
#

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

viral sonnet
#

yeah that's why i have an authoring flag

rotund token
#

what do you mean by that?

viral sonnet
rotund token
#

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

viral sonnet
#

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

rotund token
#

i simply had a component that was only existed in editor for debugging

viral sonnet
#

and just that broke the build? wow. i can test this later down the line what an editor directive would do

rotund token
#

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

viral sonnet
#

yeah makes sense. i never investigated at which point subscenes are serialized. i expected them to be serialized at build stage

rotund token
#

yeah i believe you could build it fine if properly stripped

viral sonnet
#

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

rustic rain
#

hmmm

#

is it possible to make DynamicBuffer parallel safe?

rotund token
#

if you're not resizing it probably

#

just same as nativelist parallel writer

#

you'd have no safety to ensure this though

rustic rain
errant hawk
rustic rain
#

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

errant hawk
rustic rain
#

because you don't know how many commands you'll write to buffer

#

could be 0, could be thousands

errant hawk
rustic rain
#

I assume

#

dynamic buffer without capacity limit

#

is just UnsafeList

#

but I'm not sure whether it supports parallel writing

remote crater
#

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

errant hawk
rustic rain
remote crater
remote crater
remote crater
rustic rain
#

math is the only thing that DOTS has built in xD

#

btw

#

it has

#

distance

#

math.distance

remote crater
#

Thats kinda what I wanted.

rustic rain
#

for fastest

#

use distance squared

errant hawk
rustic rain
#

square roots are expensive

remote crater
rustic rain
#

not sure

#

whether comparing it with squared radius is correct though

remote crater
#

This isn't even something I need to maximize around, I become a perfectionist dork at a certain point.,

errant hawk
remote crater
errant hawk
#

wait no

#

that's just for floats

remote crater
#

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!

errant hawk
#

Ah yeah, it's lengthsq(y - x) which is math.distancesq

#

god it's too late for this lmao

remote crater
errant hawk
#

That way you're not checking against hundreds of thousands of entities every update

remote crater
#

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

remote crater
#

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

errant hawk
remote crater
#

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

remote crater
errant hawk
remote crater
#

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...

▶ Play video
errant hawk
remote crater
#

I can figure the query, but what about .foreaches? Maybe have a component that designates each sector?

remote crater
#

it'd be pretty ghetto code to have a componentdata type for every single sector of about 20,000 sectors

errant hawk
remote crater
#

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.

errant hawk
remote crater
#

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

errant hawk
#

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)

remote crater
#

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

rotund token
rustic rain
rotund token
#

Yes

rustic rain
#

huh, all right

rotund token
#

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

errant hawk
errant hawk
rotund token
#

Phone auto correct

fallow thicket
rotund token
#

Why do you think it is?

gusty comet
errant hawk
rotund token
viral sonnet
#

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.

rustic rain
#

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

pliant pike
rustic rain
#

what is TF?

#

bruuuuh, I am so tempted to harmony patch TypeManager

#

xD

#

an ability to register generics through reflection

#

is a must

rustic rain
#

huh

#

modifying assembly

#

through reflection

#

bruh

#

assembly is abstract

#

and it has no fields -_-

devout prairie
#

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?

rustic rain
devout prairie
rustic rain
#
                #if UNITY_EDITOR
                Unity.Entities.Editor.EntitySelectionProxy.SelectEntity(state.World, selection.mainEntity);
                #endif
devout prairie
#

ahhhhh

#

how'd you find that little gem

#

ah! it was right there

#

works beautifully, thanks for that @rustic rain

rustic rain
devout prairie
glacial hazel
#

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

rustic rain
#

oh wait

#

nvm

#

I don't think that would work

glacial hazel
#

I think I tried that but it doesn't let me create native arrays in other threads

#

Yeah

rustic rain
#

I wanted to suggest icnreasing capacity with async method

#

hm

#

doesn't it have jobified allocation?

glacial hazel
#

Currently it's persistent allocation

#

Since things take so long

rustic rain
#

wait

#

try

glacial hazel
#

Is that what you mean?

rustic rain
#

try creating it without clearing memory

#

that might be way faster

glacial hazel
#

How is that?

#

xD

rustic rain
#

it won't clean memory to zeros

#

while allocating

glacial hazel
#

How do you create it without clearing memory?

rustic rain
#

it's parameter

glacial hazel
#

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

rustic rain
#

why not just use native collection in the first place?

glacial hazel
#

Yeah my context is that I'm doing massive hacks, just to try to serialize native arrays

rustic rain
#

serialize huh

glacial hazel
#

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

rustic rain
#

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

glacial hazel
#

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!

viral sonnet
#

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

rotund token
#

Project day 🥳

#

What problem to tackle today

viral sonnet
#

is that celebration worthy?

rustic rain
#

interesting stuff is in manual

#

very interesting

rotund token
#

i get a project day once every 2 weeks

#

best day of the fortnight

viral sonnet
#

so a day where you can do whatever your want at work?

rotund token
#

i get every second friday off

#

which is project day!

viral sonnet
#

ah 😄

#

so what's on the menu?

rotund token
#

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

viral sonnet
#

hm, CC is a big one 😄

rotund token
#

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