#archived-dots

1 messages ยท Page 269 of 1

viral sonnet
#

do we care about the material though?

rotund token
#

1 mesh + X chunk transforms get passed to render batch

#

1 mesh happens to be 1 chunk

viral sonnet
#

yeah, I see. well, I rest my case ๐Ÿ™‚ I don't see much to improve here then

#

what kind of cpu timings are we talking about @rustic rain ?

rustic rain
#

Idk, I didn't profile it

#

I literally just managed to make it work xD

#

With bugs

viral sonnet
#

then don't optimize ๐Ÿ˜„

rustic rain
#

I never put it into update

#

Gotta try

viral sonnet
#

do you have a 2d or 3d game?

rustic rain
#

2d

#

But with 3d models

#

Can't afford sprites kek

viral sonnet
#

you probably have cell data already, right? you can hash the mouse position and build a lookup table to find the hovered cells. finding anything based on position will be useful for other things too

#

I'd only use this entity pick system in the editor.

rustic rain
#

No cell data

#

I work in coordinate space

viral sonnet
#

hm, well I don't know your game. can I imagine it like rimworld or something different?

rustic rain
#

Ever heard of space rangers?

#

I'm doing clone of it and ftl

viral sonnet
#

i haven't but a google search gave me an idea ๐Ÿ™‚

#

so if you're doing this I assume that you not use any physics or colliders?

rustic rain
#

Yep

#

That's why this entity picker is god save

viral sonnet
#

yeah, I see. just don't overdo it. having no spatial awareness makes a lot of things unnecessarily tricky

viral sonnet
#

OverlapSphere doesn't look too hot for 10k ๐Ÿคฃ

rotund token
#

is that all 1 thread?

#

if you only update half a frame

#

that's 15fps!

#

i do think based off what i know your requirements in general are this will probably not be fast enough ๐Ÿ˜„

viral sonnet
#

yeah, just a Run() to see how things go. I wonder how MMO servers do this stuff. they have so many entities on a server it's insane. could run on players instead of enemies but still

#

sad to see physics is *that *slow for that. :/

rotund token
#

they aren't triggering 10k creatures/frame

#

that said most mmos 95% of the creatures are asleep

#

usually they sleep like 50m from a player

viral sonnet
#

some form of spatial trigger has to wake them up

#

and yeah, I guess most of the stuff runs okay because it's just not happening that often

#

when the players actually do the overlap cast it'll be a lot less. still servers can have 7-10k players

#

I had high hopes I can just throw this feature in and be done with it ... lol fk

rotund token
#

that's multiple machines acting like 1 single server

viral sonnet
#

yeah true, what I'm even thinking ... haha

#

so I guess for the demo I'd have to put the overlap cast on the enemies and not on the casters, otherwise performance is down in the dumps

rotund token
#

you could optimise this a lot

#

if you have a bunch of things in an area

#

they dont all have to cast an overlap sphere

#

you can cast one and use the same result for all of them

viral sonnet
#

I'll certainly keep this in mind. Don't want to cheat too much as it would be unrealistic anyway to have casters all stacked up on a few positions ๐Ÿ™‚ but yeah, talking about unrealistic with my kind of numbers. I see the irony

#

physics doc doesn't even mention ITriggerEventsJob

viral sonnet
#

what's the correct way of converting? this messes up physic blobs ```BlobAssetStore blobAssetStore = new BlobAssetStore();
GameObjectConversionSettings settings = new GameObjectConversionSettings(World.DefaultGameObjectInjectionWorld, GameObjectConversionUtility.ConversionFlags.IsBuildingForPlayer , blobAssetStore);

        prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, settings);```
#

I don't know where to get the BlobAssetStore

rotund token
#

subscenes? ^_^"

viral sonnet
#

for hybrid, I now know that GameObjectConversionSystem holds a BlobAssetStore but GetExistingSystem returns null.

#

at least from the DefaultGameObjectInjectionWorld

#

I'm honestly surprised that the posted method doesn't screw up the blobs from the subscene. the problem started when I put a trigger on the hybrid spellcaster

#

triggers run even worse (as expected) also messes up physics time step and now I have 6 updates in 1 frame ...

#

option A) use sphere overlap cast b) build a specialized hashMap - I have to stop at one point with this madness haha, maybe now is a good time

rotund token
#

blob asset management is a bit of a pain and it's pretty complicated under the hood

#

if you dont care about maximum memory saving then just create, retain and disposing your own store is fine

solemn hollow
#

Is there a way to set EntityQueryOptions directly in an EntityQuery object or do i always have to work with EntityQueryDesc for that

#

I just want to include Disabled Entities in the query

rustic rain
#

welp, I checked

#

1 ms takes

#

for thousand of entities

#

to be constantly removed/added with components, kek

#

for sake of fail proof rendering disabling

solemn hollow
#

how is tertles suggestion not failproof though? whenever someone changes the room you add DisableRendering. whenever someone enters you remove it.
I would have thought your solution is MUCH faster actually than you profiled. there should be no memory copied around and most chunks shouldnt even change at all since most chunks are disabled anyways. the few chunks that need to be enabled again should just have their archetype adjusted and nothing more. not sure how this could take so long.

rustic rain
#

meanwhile fail proof is constantly checking for "dirty" entities

solemn hollow
#

Id probably try it with a reactive system. whenever an entity changes the room you do the checks

rustic rain
#

but it's not efficient

#

yeah

#

reactive system is best scenario

#

but here the problem

solemn hollow
#

i guess your problem is the SCD

rustic rain
#

it's Shared Component

#

xD

solemn hollow
#

just have another normal ICompData holding the room ID too and always write into both. then you can filter for changes on the normal one

rustic rain
#

I am working on it

#

first I want to make a difference between

#

Player view

#

and player entity

solemn hollow
#

for culling?

rustic rain
#

yeah, I guess you can call it culling

#

just need an ability to look into other rooms

#

at least for debugging purpose

rustic rain
solemn hollow
#

why would you need to write it through a buffer?

rustic rain
#

rn all actions I can do: are only through filter

#

so far it's enough, but can't wait for unmanaged shared comp

#

from Unity

solemn hollow
#

I dont get the problem. when an Entity leaves a room you write to SCD and ICD at the same time. Then a System with a ChangeFilter on the ICD picks up the change and sets your DisableRenderer.

rustic rain
solemn hollow
#

I really dont know what more to say to that.
You must have some Logic that changes the room right? Like a collision with a Stargate changes the RoomSCD. Whereever you write to RoomSCD you just also write into another IComponentData the same value. In your RoomDisableRendererSys you then Filter for changes on the IComponentData. So RoomDisableRendererSys only runs for chunks where an Entity changed the room. If nothing changes rooms it doesnt run at all.

rustic rain
#

hmm

#

version filter

#

I see

#

curious

#

Does Entity Manager support it though?

#

Since I don't want to run it through loop, I can literally just do it in EntityManager

solemn hollow
#

Its a Filter for a query. So if i understood your question right ofc you can use it with Entitymanger

rustic rain
#

ngl, your idea of doubling room component is great

#

now it also solves a question of how to acess data

#

for reading only

solemn hollow
#

yep

rustic rain
#

hmmm

#

any idea whether I can simply cast

#

my shared component to normal?

#
    public struct StarNormal : IComponentData
    {
        public int systemID;
    }

    public struct StarShared : ISharedComponentData
    {
        public int systemID;
    }
#

kinda like this (StarNormal) new StarShared();

#

doesn't really let me

viral sonnet
#

what a pain, I'm not able to remove the LinkedEntityGroup from a converted GO :/

#

usually removing works during Convert but for some reason for this case it doesn't

#

it's a prefab, if I put the prefab in a subscene LEG gets removed

solemn hollow
#

Huh. I never had the case that Subscene conversion did something diffrent to single conversion

#

LinkedEntityGroup is pretty much the last thing that happens in conversion right? are you maybe not removing it late enough?

viral sonnet
#

yeah, must be a order problem. hm, is there a post convert? I'm not aware of any

#

so where it's different is. prefab in subscene -> normal. same prefab referenced in spawner subscene GO -> LEG still there

solemn hollow
#

hmm. im guessing here. the diffrence could be that prefabs don't have an associated entity when conversion starts but get them later on when they are discovered via DeclareReferencedPrefabs. Maybe you somehow manage to delete LEG before those Prefabs are discovered?

solemn hollow
viral sonnet
#

I just found this, maybe it helps here

solemn hollow
#

I think LEG is done even after late conversion group. but im not sure. feels like i looked into it once but it was quite a while ago

#
static void FinishConvertIncremental(World conversionWorld, Conversion conversion)
        {
            using (s_UpdateConversionSystems.Auto())
            {
                conversionWorld.GetExistingSystem<GameObjectBeforeConversionGroup>().Update();
                conversionWorld.GetExistingSystem<GameObjectConversionGroup>().Update();
                conversionWorld.GetExistingSystem<GameObjectAfterConversionGroup>().Update();
            }

            using (s_GenerateLinkedEntityGroups.Auto())
                conversion.MappingSystem.GenerateLinkedEntityGroups();

#if !UNITY_DISABLE_MANAGED_COMPONENTS
            using (s_CreateCompanionGameObjects.Auto())
                conversion.MappingSystem.CreateCompanionGameObjects();
#endif

            conversionWorld.EntityManager.DestroyEntity(conversionWorld.EntityManager.UniversalQuery);
        }
viral sonnet
#

seems so, the test with GameObjectAfterConversionGroup didn't work. I just don't get it why it's working for a subscene GO. should be the same conversion process. I mean, not completely, as it's converted into a subscene

#

ah thanks, that confirms it

#

guess I have to unlink it then. major pain ... ๐Ÿ˜„

solemn hollow
#

why are they linked in the first place ๐Ÿ™‚

viral sonnet
#

I'm lazy and easier to setup ๐Ÿ˜„

#

technically they are linked. I just don't want a 144B LinkedEntityGroup in my archetype

solemn hollow
#

Well you could attach both objects to one empty GO and then in lateconversion delete that GO

#

then LEG wont be added ? might work

viral sonnet
#

that doesn't sound too bad actually

#

thanks, I'll try

#

the reason I'm doing this is to keep my main archetype free from any physics and collider stuff. main archetype is big enough as it is. I need some CDFE calls because of this but it's not too bad. at least, it's worth it to keep the archetype small

#

pointer to LTW is set once for the main entity so I even have access to translation, rotation without losing too much

solemn hollow
#

but that does mean that your entity with LTW may never change chunk?

#

im a bit confused

viral sonnet
#

pointers are set every frame to avoid that problem.

#

hm, when I destroy the entity the linked entity group entities are also destroyed, right? how would I just destroy the container?

solemn hollow
#

i hoped you can destroy the Entity in the DstWorld in conversion before LinkedEntityGroup is set up

viral sonnet
#

oh, right. well let's see

#

conversion mapping system errors out sadly: The entity does not exist

#

why are they adding something after post convert? WHO DOES THAT???

solemn hollow
#

hmm maybe the problem is that the ConversionEntity Exists and the DstEntity not

#

try what happens if you delete the gameobject in conversion

viral sonnet
#

it was worth a try, this is getting too hacky for my taste. I need to take a step back and reevaluate. I must be able to remove the comp at one point. and if all fails, I'll remove it in runtime for the created prefab

#

thanks for the help, I'm off now to a birthday party ๐Ÿ™‚

solemn hollow
viral sonnet
#

ah, good to know. thanks! ๐Ÿ™‚

hot basin
#

@rotund token in .50 samples (1.0+ collections) my code with IJobParallelForDefer works

#

so for now I think I need to switch to simple IJob waiting for 0.51

rotund token
#

Just avoid parallel native list until you upgrade

hot basin
#

but sadly I need it more than defered job ๐Ÿ˜„

rotund token
#

Be careful because it breaks in other situations as well

solemn hollow
hot basin
#

and can I add structs to the stream?

#

Never used stream

#

sorry

rustic rain
#

ok, it turns out that EntityManager add component through query is extremely fast and I can simply solve all my renendering through FixDirty

#

doing it every time I want, as long as it's not every frame xD

#

basically every time entity gets created/changes it's room

solemn hollow
# hot basin but will it work with `IJobParallelForDefer`?

i never used DeferJob sorry too ๐Ÿ™‚
i dont know what you are trying to solve. No idea if NativeStream makes sense for your problem. You need to know the size of the stream beforehand too but it wouldnt be a huge problem if you oversized it.

solemn hollow
#

look into the Tests for NativeStream. Gives you a basic idea on how to use them.

#

Tertle is probably the expert on NativeStream though given he has made a whole EventSystem based on it

#

I used it like 3 times.

rustic rain
#

hmm, I assume GameObjectConversionSystems are just like any other SystemBase exist in world?

#

I just want to create native array in it

#

and later access from other systems

solemn hollow
#

NativeStreamTests.cs in Collections

hot basin
solemn hollow
#

yes

hot basin
#

but I don't know it

#

so stream is wrong type for me

rustic rain
#

@hot basin do you have entities or not?

hot basin
#

I have

solemn hollow
#

cant you even guess an upper limit? what do you want to write into it?

hot basin
rustic rain
#

so, why can't you know upper limit?

hot basin
#

because it's bound to setup in editor

solemn hollow
#

but then you can infer from the setup how big it might get can u not?

solemn hollow
rustic rain
#

nnnah

#

I just figured I'd add another component

#

kek

#

prob not a better idea ngl xD

hot basin
#

I could multiply all the maxes

#

but why

rotund token
#

Native stream can resize in parallel

hot basin
#

width?

rotund token
#

Width

#

You don't specify capacity with native stream

#

You specify foreach count

solemn hollow
#

tertle to the rescue!

hot basin
#

yeah I figure that out

rotund token
#

Power went out at 7:30 last night, went to bed early to get up early. Got up at 4:50, internet went down at 4:59 with 7am+ eta

#

So annoying, so here I am

solemn hollow
#

oof

rotund token
#

Anyway if I was you krajca I'd just ditch parallel native list and just do ijob there and keep deferred job

#

Parallel native list really slow anyway and when you upgrade less code to write

solemn hollow
#

Oh man its slow? joachim said multiple times that hes impressed with nativestreams performance

rotund token
rotund token
#

Streams are fine

viral sonnet
rotund token
rotund token
viral sonnet
#

Eh, should just have a stage after adding the linked entity group

rotund token
#

Unity does not expect you to remove this because it breaks a lot of tooling

hot basin
#

so to read from stream I need to do the whole thing?

var reader = nativeStream.AsReader();
            for (int i = 0; i < nativeStream.ForEachCount; i++)
            {
                int count = reader.BeginForEachIndex(i);
                for (int j = 0; j < count; j++)
                {
                    var axis = reader.Read<Axis>();
                    Debug.Log($"{axis.input} | {axis.scale}");
                }
                
            }
viral sonnet
#

I'm already using CreateAdditonalEntity at conversion stage and that doesn't add a LinkedEntityGroup

rotund token
#

Now I do really wish this was a capacity of 0

rotund token
viral sonnet
#

I've only seen it for GOs that already have a hierarchy

#

yeah, checking myself now ๐Ÿ™‚

#

could be wrong

#

yeah, my AI entity was never linked

rotund token
#

The reason you pass in a component to create addition entity is to link it

#

Are you passing in null?

viral sonnet
#

var aiEntity = conversionSystem.CreateAdditionalEntity(this); in Convert

rotund token
#

Hmm no idea just booting up to confirm

viral sonnet
#

I've done this a few times now and previously I even built the LinkedEntityGroup myself because I needed it

viral sonnet
#

(other project)

rotund token
#

You seem to be right interesting

#

Now I need to figure out why this isn't working

#

Hmm because it's not coded to

#

You know what, that's annoying

solemn hollow
#

Can confirm. I dont get a LEG on createadditionalentity either

rotund token
#

Actually no looking at code it seems to imply it should

solemn hollow
#

This is super annoying together with the fact that you cant instanciate prefabs

hot basin
rotund token
#

You don't

#

Defer job is only for native list

#

You don't need it for native stream

hot basin
#

it's heavy to convert stream to an array?

rotund token
#

Hmm a little

#

If you use native stream to write best to just use it to read

#

Ok wtf am I missing, I can't even create a linked entity group atm

hot basin
rotund token
#

Sorry I don't follow

hot basin
#

yeah, maybe I care too much, but ParallelFor with an array will batch work in same sizes so it will be evenly distributed

#

and if I will do ParallelFor with native stream I need to bach it by foreach index

rotund token
#

Generally you'd make the width chunk index or something like that

#

Using entityInQueryIndex is pretty poor for native stream

solemn hollow
rotund token
#

At conversion

hot basin
rotund token
#

There are no linked entity groups in my subscene

rotund token
#

The main benefits of stream is lockless multi thread writing and ability to read in parallel without merging

#

But often you do need to read it in a single thread to use the data

hot basin
#

can I change data in native stream while reading it?

rotund token
#

What do you mean sorry? You want to write to it during reading?

hot basin
#

if I have list/array I can take element at index, change it and write it back

#

can I do something like that with native stream?

rotund token
#

You can only write to a native stream once

#

That said, if you wanted to get real dirty with pointers there nothing stopping you changing a value

viral sonnet
viral sonnet
#

with a nativelist that has nearly the same speed as a nativestream for parallel writing

#

blocks are allocated and reused for writing until there are none left

rotund token
#

yeah krajca problem isn't speed atm

#

it's the fact that nativelist parallel writer is broken in 0.17

#

and can't be used with deferred job

#

hence krajca is looking at alternatives

viral sonnet
#

oh damn :/

rotund token
#

(i got internet finally woo)

viral sonnet
#

I'm not sure if that's really helpful though, do you iterate 2 or more times over the stream?

hot basin
#

in the end it will be in 100 or even 1000

viral sonnet
#

oh, it's persistent?

hot basin
#

sadly no

#

it's an AI for units

#

so I don't know how many or which type of units there will be

rotund token
hot basin
#

so I dynamically gather all and calculate

viral sonnet
#

are you talking about elements in the stream?

hot basin
#

yes I do

viral sonnet
#

ah ok, I was asking how often you loop over the full stream because I was confused why you need to write back to the stream

hot basin
#

1 write, 1 calculation and 1 read an the end

viral sonnet
#

and the calculation needs the ref?

hot basin
#

yes or I would need to somehow connect stream element with an ID

#

a suppose I could make another stream

#

with ID + result

viral sonnet
#

if you read multiple times over the full stream I'd try to make a native array out of it. that way you can read faster and the worker threads are more balanced

hot basin
#

yeah it will be easier

viral sonnet
#

NativeStream has a quirk that sometimes worker threads do a lot more than others even when the write was totally balanced

#

never figured out why

hot basin
#

but I wanted to explore native stream here in the conversation as I never used them and they seems helpful

viral sonnet
#

NativeStreams are great ๐Ÿ™‚ I like DreamingImLatios UnsafeParallelBlockList a bit more though

#

it's not tied to a for each count

#

just the 128 worker count

#

as with everything, both have their pros and cons

hot basin
rotund token
#

thats basically what my event system uses, just a fixed nativestream with 128 wide

#

if you are less than 128 though it does add a bit of overhead vs a nativestream

viral sonnet
solemn hollow
#

@hot basin what kind of AI are you going for?

hot basin
#

IAUA - infinity axis utility ai

solemn hollow
#

nice soon all of us will have their own implementation of it xD

#

Mabye you dont want to write back to the stream after the calculation? Pretty sure you could reject alot of scores already and only fill a small list with the highest ones

hot basin
#

I gather all the axis and then I'm doing calculations

karmic basin
hot basin
#

all as from all ais

#

so I can't assume anything as I don't know relations while calculating

solemn hollow
#

Im not kidding. i bet there are atleast 10 dots implementations from ppl posting in the forums

#

okay i dont wanna go into details of UAI yet again but i wonder how you want to scale that up.

hot basin
#

what do you mean?

viral sonnet
#

unity physics is giving me nothing but trouble. no wonder some of you have written their own spatial query system

rotund token
#

well dreamings custom physics comes from a different reason

#

of him fundamentally hating unity physics

solemn hollow
rotund token
#

hvae you turned off physics integrity checks?

solemn hollow
#

yes

rotund token
#

hmm not sure

#

how many colliders?

solemn hollow
#

alot. but alot static

viral sonnet
#

250k! ๐Ÿ˜„ haha, then it starts the physics death spiral

solemn hollow
#

around 100 non static

rotund token
#

yeah i don't think you can have more than around 40k physics elements enzi

#

anyway just in case someone isn't aware what i mean by integrity checks

#

this nukes performance

solemn hollow
#

yes this brought physics down from 7 to 5 ms for me

viral sonnet
#

10k kinematic is 2ms for me

solemn hollow
#

wtf am i doing wrong then

#

well i need to get the framerate higher through other means first anyway

rotund token
#

i was simulating like 20k dynamics in less main thread time than 5ms im pretty sure

solemn hollow
#

one problem is that stepphysics runs multiple times.

#

atm game runs at 30 fps in editor so thats a problem...

#

hybrid stuff kills performance

viral sonnet
#

the dreaded physics death spiral

solemn hollow
#

yep

viral sonnet
#

really annoying, is there anything to turn off this behaviour?

solemn hollow
#

tertle suggested reducing the tickrate of physics

rotund token
#

welcome to fixed update life

#

you tell it to run 60 frames a second

#

it will run 60 frames a second ๐Ÿ˜„

solemn hollow
#

okay this is slightly off topic :
my artist was using 2D Animation Package to animate with inverse kinematics. now they run every frame and take 3.5ms... anyone dealt with this before? how to "bake" the Ik motion into the animation and not have it calculate at runtime

rotund token
#

at the very least in editor i usually drop tick rates to 30 for physics/netcode

#

because editor has a lot of overhead which can keep your fps low

solemn hollow
rotund token
#

i have noticed large chunks of editorupdates

#

not certain related to 0.50 or not though tbh

solemn hollow
#

well it would be about time

#

btw thx for the help with the EffectsSystem. It finally works after quite some trouble.

viral sonnet
#

is this normal for physics? so much idle time and only MT thread active

solemn hollow
#

looks like this for me too

#

i tried to schedule the heavy work before physics so it can fill in some gaps

viral sonnet
#

good idea, this gap sucks really hard

#

do you know what's going on there?

#

good thing I have system groups, now I can just move it in front of fixed update

solemn hollow
#

it seems like stepphysics is doing sth heavy on mainthread before it starts to schedule stuff. but i havent looked into it

viral sonnet
rotund token
#

this is all editor overhead btw

solemn hollow
#

oh god

rotund token
#
                m_RemainingBlocks = 0;
                m_Safety = stream.m_Safety;
                CollectionHelper.SetStaticSafetyId(ref m_Safety, ref s_staticSafetyId.Data, "Unity.Collections.NativeStream.Reader");
#endif```
#

if you run a build and profile it

#

that fixed string stuff goes away

viral sonnet
#

oh, cool!

solemn hollow
#

hmm i really need to profile in build soon... I was changing to Subscene conversion and alot of stuff broke.. so i couldnt build for like a month now

#

and my artist is still stuck on some conversion topics

viral sonnet
#

every system that doesn't run with burst runs like shit ... 18 enemies, 2.59ms for the HybridAnimationSystem

rotund token
#

what are you doing in that

viral sonnet
#

eh ๐Ÿ˜„ setting animator values all the time. pretty bad actually

rotund token
#

that said, usually those get a decent speed up if you build with il2cpp

#

at least if you have any logic in there

#

be nice when we can finally get away from this editor mono

viral sonnet
#

you mean when mono gets replaced with .net core?

rotund token
#

yeah

viral sonnet
#

that'll be huge. it's taking a loooong time sadly

#

i'm not much of a ms fan but their work on c# is solid

solemn hollow
#

nvm mine is probably equally slow. i just thought i write to 100 entities but i optimized it already

solemn hollow
viral sonnet
#

they have moved it so much. I don't know. 2022 or 2023 likely. 2023 is more likely I guess ๐Ÿ™‚

solemn hollow
#

2025 it is

viral sonnet
#

very naive and unoptimized ๐Ÿ˜„

#

more like a prototype if anything

#

I need to figure out how to best reduce the writes

solemn hollow
#

i love the early out for dead entities comment

viral sonnet
#

haha ๐Ÿ˜„

solemn hollow
#

mine looks exactly the same. when i said optimized i meant the number of entities i write to. not the code ๐Ÿ˜„

viral sonnet
#

I have a habit of even commenting really obvious early outs

solemn hollow
#

hmm my animwriter system takes 0.04 ms

#

just tested with 3 entities. ill test with more

hot basin
#

@viral sonnet going back to stream questions, I can't convert stream to array if I don't .Complete() previous job

viral sonnet
#

you should be able to convert it in a job with a handle

#

you'd have to get the nativearray back somehow. single sized native array with a void* maybe. I think there are better solutions

solemn hollow
#

So with 18 entities i got 0.1 ms

viral sonnet
#

lol damn ๐Ÿ˜„

#

anyone has this problem in a system? protected override void OnCreate() { physicsWorldSystem = World.GetExistingSystem<BuildPhysicsWorld>(); mainCamera = UnityEngine.Camera.main; mainCameraTransform = mainCamera.transform; } mainCamera is null in a build

#

maybe it runs too soon?

hot basin
#

Do you have camera with proper tag?

viral sonnet
#

yep, runs fine in editor

solemn hollow
#
public partial class AnimationWriterSys : SystemBase
{
    
    protected override void OnUpdate()
    {
        Entities
            .WithAny<SLOD0,ZombieTag>()
            .WithNone<DestroyReq>()
            .ForEach((in HybridArtChild hybridArtChild,
                in AnimationStateOutput animationState) =>
            {
                var animator = EntityManager.GetComponentObject<HybridArtManaged>(hybridArtChild.childEntity).animator;
                if (animator == null) return;

                switch (animationState.abilityAnimationState)
                {
                    case AbilityAnimationState.frontSwing:
                        animator.SetBool("isAttacking", true);
                        break;
                    ...//some cases
                    case AbilityAnimationState.ignore:
                        animator.SetBool("isAttacking", false);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }

                animator.SetBool("isEating", animationState.isEating);
                animator.SetBool("isInfecting", animationState.isInfecting);

                animator.SetInteger("abilityIndex", animationState.abilityAnimationIndex);

                if (animationState.isDying)
                {
                    animator.SetBool("isDying", true);
                }

                if (Vector3.SqrMagnitude(animationState.moveDirection) > 0.01f)
                {
                    animator.SetBool("isRunning", true);
                }
                else
                {
                    animator.SetBool("isRunning", false);
                }
            })
            .WithoutBurst().Run();
    }
}```
#

what is the diffrence that costs u so much performance?

viral sonnet
#

could be the triggers

rotund token
#

totally the getcomponents and maths

viral sonnet
#

also the local velocity transformation is expensive

rotund token
#

i really think in hybrid systems you should do nothing but write data

viral sonnet
#

true, the NHM lookup could also be slow without burst but I don't think it adds this much

#

hm, I realize now that it runs much more often but fails to get an animator

solemn hollow
#

i didnt expect the diffrence to be this grave. โค๏ธ burst

rotund token
#

i want to see the enzi 10x profile marker performance analysis of this job

#

because im curious

solemn hollow
#

๐Ÿ˜„. +1

#

did you guys already switch over to ISystems?

viral sonnet
#

it is indeed the NHM lookup. damn NativeContainers without burst are so slow. 0.043ms with 18 enemies. before I had 50k additional lookups

rustic rain
#

my pepe algorithm is slowing game down during fps drops

#
            if (StartStop)
            {
                double curTime = Time.ElapsedTime;
                if (curTime - _prevTime >= _interval)
                {
                    _prevTime = curTime;
                    base.OnUpdate();
                }
            }

pepe algorithm

#

kek

rotund token
solemn hollow
#

wasnt there a way to control updaterate of systemgroups? fixedratemanager or sth?

rotund token
#

yes

solemn hollow
rotund token
#

thats how fixed fixedupdatesystemworks

#

ratemanager i think it's now

hot basin
viral sonnet
#

my build had 2 errors. both are fixed and it's still crashing. meh

rotund token
#

๐Ÿคฃ

#

this is why i try to make a build every week or so

#

because tracking down build crashes can be a pain if it's been a long time

viral sonnet
#

it's crashing so hard I fear it might be something unsafe related. I don't get why editor is unaffected

rotund token
#

what does the dmp show

viral sonnet
#

phew, at least log is pretty good. I know where it happens

#

and it's never what you think it is: EntityQueryImpl_GetSingleton_TisHandleCombatEvents_Options from all the things possible. it's a damn singleton component. I think that wants to access before the subscene is loaded. that it ends in "Attempt to access invalid address." is pretty bonkers though

rotund token
#

just a note, subscene loading is async

viral sonnet
#

yep, had my pains with it in a netcode project ๐Ÿ˜„

rotund token
#

yeah i wrote a whole management thing for it

#

that lets me load a bunch of subscenes into a world before the world starts running

#

so i don't have to a million RequireSingletonForUpdate in my jobs

rustic rain
#

what is the difference between those?

viral sonnet
#

ah cool, it's manageable with 1 subscene but when you get more than that. eh, it has to be managed

rotund token
rustic rain
#

I'm looking for one that will smooth out ticks for target

rustic rain
#

I was trying to find it

misty wedge
#

Is EntityCommandBuffer.SetSharedComponent not allowed in a burst function?

rustic rain
#

no

#

Shared comps are managed only

#

rn

misty wedge
#

Bummer

viral sonnet
#

@rotund token got my build up. 1.9ms-2.2ms for the hybrid animation instead of 2.5ms in editor (mostly useless NHM lookups 50k)

rotund token
#

oh you're doing 50k lookups outside of burst?

#

haha - gl with that

viral sonnet
#

yeah, like I said, native containers outside of burst are really slow

#

i'll add some tag HasAnimator to reduce this ๐Ÿ™‚

rotund token
#

why don't you just attach the object to the entity

viral sonnet
#

too little experience with that. it doesn't change any archetype right?

rotund token
#

its 4 bytes from memory

#

so yes archetype will change

#

but all the animator ones will be grouped in the same chunk

#

but HasAnimator will also change the archetype

viral sonnet
#

true, I'll think about it some more. I don't want to make useless optimisations that don't make sense in practice. like, how many casters will actually have no animator?

#

code confused me how they save MBs. somewhere in an array and the index is saved. guess this will be the 4 bytes you mentioned

solemn hollow
#

why is having an extra archetype with no animator a performance concern?

viral sonnet
#

I don't want the data in the archetype, that is pretty much all my reasoning ๐Ÿ™‚ I just got it back to a 51 chunk capacity

radiant berry
#

What package do you need for animating a character in dots 0.5?
Or do you just need to use the standard animator still?

viral sonnet
#

standard animator

radiant berry
#

i saw a crowd demo with dots not sure if i should post link but i assume they also just used the standard animator?

viral sonnet
#

nah, there was an animation package once but it got dropped

#

at least dropped until 1.0 has released

radiant berry
#

yeah, i think i'll wait to experiment with the idea

viral sonnet
#

FixedString32Bytes is the smallest? ๐Ÿ˜ฆ

#

another useless thing in my chunk

#

Is data like EntityGuid, SceneSection, SceneTag, EditorRenderData also in a build?

#

bummer that we can't actually see what's the archetype capacity. (other than calculating it ourself)

rotund token
#

i have a ministring, size 16, 15 character, but burst 1.7 kind of broke it

#

i havent tested burst 1.8 if they fixed it

viral sonnet
#

I hope I can find a setting so physics doesn't actually collide with anything and I can only use it for spatial querying

rotund token
#

put it in a separate physics world?!

viral sonnet
#

wait what? how would that help?

#

ah, you mean a world where it doesn't actually steps?

rotund token
#

PhysicsWorldIndex is what i mean component wise

#

someone in here managed to get this working and ticking it manually you could run it without the simulation step

north bay
rotund token
#

or just dont put it in the simulation@viral sonnet just use the bvh yourself

#

use the colliders etc but leave off PhysicsWorldIndex

#

and then just pass it to the bvh like unity physics does

#

their bvh is very re-usable

viral sonnet
#

cool thanks! what do you mean "leave off index"?

rotund token
#

well if you dont add teh shared component

#

it wont be put in physics simulation

#

but you can still use the physics colliders

#

(purely a theoretical idea, i haven't tried to see how well it works)

viral sonnet
#

I'll play around with it. removing PhysicsWorldIndex certainly stops the physics step

#

and I'm a dummy. the mentioned NHM lookup is actually a Dictionary, I never figured out to use NHM to save the Animator class

#

saving it in the archetype sounds more attractive by the minute

#

hehe, the system vanished. had some free space on the physics entity. needed some data from it anyway

misty wedge
#

Any idea where this is coming from?

Too many debug lines added during the frame (max 10240 can be added from jobs). Some lines have been dropped.
To avoid this please pass "-debug-line-buffer-size <size>" on the command line or add to boot config

There is nothing being printed to console ๐Ÿคท

viral sonnet
#

have you disabled one of the messages?

misty wedge
#

Nope

viral sonnet
#

hm, never had this error

#

somewhere it will log though, such an error doesn't come out of nowhere

#

I have some acceptable numbers now from physics. 14ms with 250k colliders. no dirty hacks. I set the physics step to no physics and removed the rigid body from the entities. unity says they will be now static but they can still change position and spatial querying works fine. (with AI pathing)

#

there's some drifting at first because for some reason all enemies spawn on the same position. - bug aside, pretty acceptable for what it is. - I tried now with physics on for the steps and it doesn't make a difference. removing the physics body is enough

misty wedge
#

I do basically the same thing, just use the physics system for querying and use character controllers for movement

#

Granted the game is 2d and has no complex physics anyways ๐Ÿคท

solemn hollow
#

hmm interesting. id like to actually use collisions though. i would only need active colliders around the player. maybe i can disable the colliders for the rest of the simulation.

rustic rain
#

Hmm

#

is there an option to have random without individual components?

#

what can I tie it to?

#

I tried to tie it to LocalToWorld position value

#

but that ends up with 0

#

sometimes

#

leading to exceptions

rotund token
rustic rain
#
                    float3 pos = ltw.Position;
                    var rand = new Random();
                    rand.InitState((uint)pos.x);

                    float2 deltaPos = rand.NextFloat2(MINWanderRadius, MAXWanderRadius);
#

this fails sometimes

rotund token
#

well anytime pos is 0

rustic rain
#

I need a reliable random

#

yep

rotund token
#

its also not very random

#

everything at the same posx

#

will get the same value

rustic rain
#

it's never will be in same posx tho

#

kek

rotund token
#

why cant it be at same pos x?

rustic rain
#

but anyway

rotund token
#

(1,1), (1, 123414)

rustic rain
#

It just won't do

#

I need better option

rotund token
#

i usually just generate random outside job using unitys random to give initial seed

rustic rain
#

I'v seen option with adding Random to entity as component

rotund token
#

then add the entityInQueryIndex

#

to get a per entity state

rustic rain
#

I kind of look for a way

#

rn to also make a random that will replicate itself

#

under same circumstances

#

To combat save scumming a bit xD

#

eh, seems like adding it as component is the only way

minor sapphire
#

A little bit extra knowledge... A few years ago I was testing the new random struct and found that skmilar (close in value) seeds produced similar results. Don't know if that has changed.

rotund token
#

think it's just an xorshift generator

#

fast over random

rustic rain
#

hmm

#

is there a way

#

during conversion

#

to query through interface?

#

Basically I want to be able to add to certain Components declarations my interface

#

and then during conversion in case any entity has component with that interface

#

add another component

#

meanwhile I don't want to add interface to authoring monos

#

only to entity comp

rustic rain
#

hmm

#

So can I somehow create IComponentData type out of ComponentType?

#

by myself

rotund token
#

componenttype cant be an interface

rustic rain
#

not component type

#

but Component itself

#

AIList[0].GetType().GetInterfaces()

#

I think I'm unto smth

#

kek

#

it's array of componenttypes

rotund token
#

you can gettype from ComponentType

rustic rain
#

yeaaah

rotund token
#
var type = TypeManager.GetType(componentType.TypeIndex);```
#

something like that

#

actually theres a shortcut componentType.GetManagedType()

#

i guess

#

which just does the same thing under the hood

rustic rain
#
            foreach (var type in AIList)
            {
                foreach (var interfaces in type.GetManagedType().GetInterfaces())
                {
                    if (interfaces == typeof(IRandomComponent))
                    {
                    }
                }
            }
#

so is that it?

rotund token
#

i think that'd work

rustic rain
#

can't figure out why it won't show up in inspector

#

hmm

#

oh wait

#

me dum d um

#

Is it even possible to do such thing?

rotund token
#

unity hasn't marked ComponentType has serializable

#

it won't show in inspector

rustic rain
#

I know

rotund token
#

it woul djust be an int though (+ access mode)

#

you could write your own component type with a drop down easy enough

#

just make a custom inspector with

#

TypeManager.AllTypes

#

THAT SAID type index is not stable

#

if you make a build your component type index will be different to editor

rustic rain
#

hm

rotund token
#

you can use StableTypeHash which is stable

#

UNLESS you ever make any change

#

add/remove a field

#

reorder fields

#

change namespace

#

change name

#

etc

rustic rain
#

I'd rather find another way

#

kek

solemn hollow
#

i went the roundabout way and wrapping the type into a scriptable object

rustic rain
#

I simply need it for a system that will automatically add Random component to AI agents that require it

rotund token
#

entity query
any {all components that need random}
none {random}

rustic rain
#

well, that's the thing

solemn hollow
#

but he wants to do it with an interface

rustic rain
#

I want to do it through interface

#

not hardcoding

#

because I want to have oepn doors for modders, that would add new components that might require it

rotund token
#

well what i say to that

#

stop writing oop code

#

๐Ÿ˜„

solemn hollow
#

but you wouldnt need a random component per component. couldnt those modders add their own RadnomAuthoringComp if they wanted to

rustic rain
#

it's not per component, it's 1

#

ooooh

#

write groups

#

yeah

rotund token
#

if you care about modding everything you do should be setup as a writegroup

rustic rain
#

yes

solemn hollow
#

still writegroup doesnt solve his randomComponent problem does it?

rustic rain
#

it kind of does

#

I just need to do 1 query

#

question is, whether I can do it in conversion system

#

basically, once all other components are already added

upper tiger
#

why does this not set the localToParent?

commandBuffer.AddComponent<LocalToParent>(entityInQueryIndex, newEnt);
commandBuffer.SetComponent<LocalToParent>(entityInQueryIndex, newEnt, new LocalToParent
                        {
                            Value = localToParent
                        });
#

the entities in the editor havent had their LocalToParent changed at all

rustic rain
#

hm

#

feels so bad ngl

#

I can't figure out a way to do it

solemn hollow
#

So as soon as the LocalToWorld System runs it resets your LocalToWorld to 0,0,0

#

if it is a static entity you can remove translation from it. If it needs translation you need to set translation instead of LocalToWorld (or set both)

#

ups sry i didnt see its LocalToParent. Still the same applies. Translation writes to LocalToParent

upper tiger
#

thanks

#

yeah seems I can set translation but not localtoparent

#

the localtoparent updates with translation changes automatically

solemn hollow
#

you can. its just overwritten if you dont set translation. if you need the correct position in the first frame you probably should set both

upper tiger
#

ahh gotcha

#

I assumed if you set one or the other, the other would be automatically calculated

#

but only works one way

solemn hollow
#

yes. its advised to only read from LocalToParent / LocalToWorld and write to translation/Rotation/Scale

#

ofc for performance reasons you could want to write to LocalToWorld in some cases but then you need to take extra care with how you use the other components

rotund token
#

an example of this is the boids sample

#

where they have a custom component overriding the writegroup of the localtoworld

#

to take ownership of writing to it

rancid gust
#

Could someone explain me why a "burst compiled" job would perform better than without? I understand that it uses LLVM under the hood, but I do not understand why unity's JIT couldn't achieve the same, and even less why burst has to be explicitly added instead of being an implementation detail

rotund token
#

because burst has restrictions

#

i.e. no managed data

#

because of this it can make assumptions about your code

rancid gust
#

And it could be handled by the compiler

rotund token
#

and perform optimizations on those assumptions

#

apart from that, yes llvm and the ability to vectorize parts or all your code

rancid gust
#

And unity's jit/aot technologies cannot auto vectorize?

rotund token
#

i should point out, unitys current mono jit is very old/slow and things like il2cpp or .net 6 can compile much better code getting closer to burst performance

#

maybe only 20-30% slower for general scalar code

rancid gust
#

I see, though it is still weird that the annotation is mandatory instead of the compiler being an implementation detail. Or at least only present for compile time errors to ensure efficient compilation

rotund token
#

the reason the attribute is required is mostly just for editor speed

#

its much faster to just lookup attributes than to check every piece of code it verify its burst compilable

rancid gust
#

fair enough

rotund token
#

you dont really want to tab back into editor and wait 30 seconds for burst to figure out what it can compile

rancid gust
#

And isnt there any overhead going from managed code (jit) to foreign functions? It is at least the case on the JVM, in which case I'd expect small burst jobs to perform poorly

rotund token
#

there is but its much smaller than the general speedup you get

#

however this is why its recommended to not have simple function pointers for example

int Add(int a, int b) => a + b```
As the overhead would be more than any speedup
rancid gust
#

Alright, thanks for the explanations :)

rustic rain
#

burstcompile works in such way?

rustic rain
#

Oh man, feels so good

#

2k potential targets, 1k lookers
All processed in less than 2 ms

hot basin
#

do you use any spatial sorting?

left sparrow
#

Hello
Please tell me the sources where i can read about frustum culling and occlusion culling for dots ecs?

rustic rain
#

nah I just literally collect entities in NativeMultiHashMap

#

and then go through it

hot basin
#

for every looker?

rustic rain
#

looking for smallest value

#

yep

#

Burst magic

#

๐Ÿ™‚

hot basin
#

i wonder if sorting them into spatial buckets wouldn't be much faster

#

still NativeMultiHashMap but with bucket id as key etc

rustic rain
#

it was stress test tho

#

in real conditions

#

It'd be way more gentle

#

smth like 30 potential targets tops

hot basin
#

don't get me wrong, it's insane speed already ๐Ÿ˜„

#

I just wonder if such techniques have a place in DOTS

rustic rain
#

idk about sorting

#

but overall dots is perfect for my case

#

basically a huge sim

#

of thousands of agents

hot basin
#

can I get Entity in IJobEntityBatch?

#

var entities = batchInChunk.GetNativeArray(new EntityTypeHandle()); is this a proper way?

rustic rain
#

no

#

Get entity type handle

#

like component type handle

#

in systembase

#

and then assign it to field

hot basin
#

so var entities = batchInChunk.GetNativeArray(entityTypeHandle); and entityTypeHandle = GetEntityTypeHandle(), in system?

rustic rain
#

yeah

hot basin
#

thanks!

rustic rain
#

entities array is literally same as component arrays

#

ngl tho, so far I realised

#

that using jobs is meh compared to ForEach loop

#

xD

#

the only good side I noticed is that you can access shared component id

#

once I got rid of such need

#

I moved it all to foreach

#

meanwhile foreach loop always looks good on system debugger, while counting query count

valid hazel
#

Is the hybrid renderer supported on the switch platform?

rustic rain
#

Is dots even supported on switch?

calm edge
#

afaik hybrid rendering requires HDRP which isn't available on switch

solemn hollow
#

@valid hazel its says right there that it is not validated for mobile and consoles.

#

It can work but you will be alone with your troubles.

pine plaza
#

does any know how to implement state machine in dots?

solemn hollow
#

@pine plaza there are multiple ways. how you wanna do it depends on the usecase u need it for. IMO there is no 1 right solution to fit all.
to name a few:

  • Add and Remove StateComponents from entity. Might be good if you have very rare state changes -> structural changes
  • enabled and disabled component for each state on the entity -> no structural changes needed but polling all states every frame
  • enum in a component. switch in a system
  • polymorphic components from PhilSA. See the example in the readme
misty wedge
#

Any debugging tips? Everything works fine except if I spawn a lot of entities, then a lot of things get spawned in an ECB, and my game hangs and eats massive amounts of memory. No idea what is going on

#

The last point I can see in Rider where it hangs is EntityCommandBufferSystem.FlushPendingBuffers, specifically m_ProducerHandle.Complete()

#

I have no idea what dependency this is waiting on though

solemn hollow
#

What do you mean by alot of things get spawned in an ECB. do you refer to the entities you instantiate in ECB?

misty wedge
#

Yes

solemn hollow
#

so how many entities are we talking about?

misty wedge
#

There are 9000 things in the list that is run through, and per spawned entity about 10 values get written to the ECB

solemn hollow
#

I dont know how Instanciating prefabs is done in ecb. maybe multiple commands are set per Instantiate to remap entities or sth? Or do you do some setup logic for each Instanciated prefab. like setting position

misty wedge
#

I use ECB.Instantiate to spawn an entity prefab, and then overwrite some component values

solemn hollow
#

well thats where those commands come from then

misty wedge
#

Yeah but I don't feel like even 90000 commands would take up 8 gigabytes of memory

#

When it was 2 GB before

solemn hollow
#

those commands should not be whats taking the memory. its the spawned entities

misty wedge
#

I don't think 9000 entities would take up 8 gb

solemn hollow
#

yes they wouldnt.

pliant pike
#

sometimes its best not to use the ECB to instantiate entities

solemn hollow
#

its some editor stuff i guess. i have memory problems too

#

did you profile it in build?

misty wedge
#

Not yet

misty wedge
pliant pike
#

it might be faster to just use EntityManager.Instantiate

#

ecb in some cases just creates more work than is needed

misty wedge
#

Would probably be tricky since I don't even know what type of entity is being spawned ahead of time

solemn hollow
misty wedge
#

ECB doesn't support batch functions

#

I think that's what they means

pliant pike
#

yeah but your using I presume a job to queue up commands and then play them back on the main thread

solemn hollow
#

yah batching + setup entities is a pain anyways

pliant pike
#

that takes way time than just using the entmanager.instantiate

misty wedge
#

In batch mode

#

ECB just calls EntityManager functions

pliant pike
#

I can create thousands almost instantly just by using entmanager

misty wedge
#

I'm not sure how I would do that though. The archetypes aren't even the same for all spawned entities

solemn hollow
pliant pike
#

you can just use ordinary entityquerys surely

#

entmanager.instantiate can accept a nativearray of entity's as an argument

misty wedge
#

Yes, that's batch mode.

solemn hollow
#

How do you set up individual entity positions then?

pliant pike
#

yeah it took me a while to find that out

#

I just do a simple for loop after would

#

on the original nativearray of entitys

solemn hollow
#

i see. but honestly why spawn 1000 entities in one frame ๐Ÿ™‚

misty wedge
#

Yeah I think the smartest thing is just to limit it to 100 or whatever per frame

#

I'd still like to actually debug it and see what is going on that takes so long and uses so much memory

pliant pike
#

because its really quick and fast, I'm pretty sure I can do close to 100,000 in under a millisecond

solemn hollow
#

yes you can with batchcommands. but is that the best design you can go for?

misty wedge
#

You will still run into problems naively modifying component data, since it will cause a lot of memory copying

solemn hollow
#

sure if you have a spacebattle with 100000k spaceships fireing i see the point.

misty wedge
#

I would assume so? Adding a component will change the archetype of the entity

solemn hollow
#

no you would have the components already on the prefabs and only write to them

misty wedge
#

Ah I thought you meant spawning "empty" entities

pliant pike
#

I don't generally do much adding of components in things like that, I just pre-create the archetype and use that and set its components data

misty wedge
#

Isn't there a batch function to set component data for a set of entities?

pliant pike
#

maybe I havent used it yet

solemn hollow
#

whats the point though. to create an array of data for the batching you need to loop over sth anyways. can do that once later too

misty wedge
#

I can write the data from multiple threads, then a single call to EntityManager can set it

pliant pike
#

yeah unity's method would likely be more efficient than anything we can do manually

misty wedge
#

I guess Ill try just writing the entity's to spawn to a list and then actually create them on the main thread in batches, see how that goes

solemn hollow
#

btw ecb has a batch command

#

just checked

pliant pike
#

yeah its still just a delayed playback system though

#

personally I wouldn't use ecb unless I absolutely have to

#

I'm not an expert though

solemn hollow
pliant pike
#

the ecb is using the entitymanager though

solemn hollow
#

yes thats the point. its just at another point in time.

#

you reduce syncpoints that way

hot basin
solemn hollow
#

Sure if you manage everything correctly and manually set all your systems using entitymanager together at syncpoints then its fine. but sooooo much more work

hot basin
#

don't understand in which aspect ECB would broke it

pliant pike
#

yeah I guess if you want to schedule your sync points better then its good for that

solemn hollow
#

and u wont get much if any performance

misty wedge
#

This goes back to my point of being confused what is actually crashing the game

solemn hollow
#

its probably tooling lol

misty wedge
#

What do you mean?

solemn hollow
#

All the debug stuff for entities might have a big memory consumption. i never checked but my editor is eating tons of memory

misty wedge
#

Hmm, guess I'll test in a build

solemn hollow
#

in profiler it shows my entities is around 5mb or sth

#

but i dont know if that includes hybrid components not stored in chunks

misty wedge
#

Very annoying though that it seems to be impossible to figure out what is currently running

hot basin
#

welcome to multithreading ๐Ÿ˜„

misty wedge
#

It's more the issue of the native code

#

I would need to build and debug the C++ build

hot basin
#

but to be fair, "running currently" is what your main thread is doing

misty wedge
#

Well yeah, but that's stalling waiting for other threads

#

So not very useful

hot basin
#

not always

#

only if you .Complete() something

misty wedge
#

It is hanging on Complete

#

It's a dependency to the EntityCommandBufferSystem

remote crater
#

Yo, I have a gameobject with lots of child objects... How do I weld em all together so its a single entity?

solemn hollow
#

you do it in conversion. there is no magic to do that for you

#

for static hierarchies you might wanna use the staticoptimizeentity component

remote crater
#

Oh it welds it in conversion? Cool

solemn hollow
#

no you have to weld it in conversion.

remote crater
#

Ok, is there a proper term for welding so I can googlify it?

#

Thanks much

#

Its okay, seems like its working now

#

Here, let me show you, its funny!

solemn hollow
#

If you have childgameobjects which should add components to the resulting parententity you need to do this in your authoring components. id say you shouldnt build your authoring like that in the first place.

remote crater
#

Straight this is funny, I had an asset of Elon Musk's car I had in orbit of Mars way before the politics stuff happened: https://youtu.be/vytdbGtTKb4

Proof of Achievements no other gamer has: #1 world ladder Starcraft #1 World ladder Broodwar, #1 World ladder Warcraft3 at 200-0, first to 1500 wins Warcraft3, #1 World Diablo2 Hardcore experience ladder, #1 score Pittsburgh without Turtle Tip 1989 Nintendo World Championships, #1 world C&C3, #1 World SC2v2/l https://www.crystalfighter.com/achie...

โ–ถ Play video
#

Funny for me, but I'm weird

solemn hollow
#

not sure how this has to do with your hierarchy problem though ๐Ÿ˜„

remote crater
#

Well Elon's car was all sub childrened out and wasn't colliding

#

It had a complaint it wasn't childrening

#

Turns out I was doing the wrong inject method, which you led me to by talking about the convert process

#

I am reducing scope of my mmo to bare minimum

#

Which I thought would be SOL instead of all the star systems in the Milky Way

#

Now I realized a Mars base done bad would last a long time... So I am just starting with one random junk yard scrap system

#

Which lends itself to creativity: Just throw stuff out there, finally having fun

white island
#

VICTORY. I made the AStar system from value types only, it can cross between "worlds" (parts of the same graph that are technically in the same space but on different planes- useful for crossing through interiors vs exteriors), the whole thing can be serialized and deserialized on a "One File Per Node" basis (simplifying the serialization and allowing git collaboration without conflicts on the serialized graph), and on top of that, it can be burst compiled!

#

The last step is to make a KD tree for much, much faster nearest neighbor searching. Which I don't know how to make yet. But i'll figure it out.

solemn hollow
#

sounds great! wish i had bursted pathfinding :S

white island
#

this isn't the unity navmesh though, this is a hand-placed node graph for more granular pathfinding for off-screen NPC movement

solemn hollow
#

also on my wishlist xD

rotund token
rustic rain
#

huh

#

in 0.17

#

you'd need to do some weird

#

generic

#

stuff

#

is that in the past?

rotund token
#

For a function pointer? Well it's not related to entities it's a burst feature

#

But MonoPInvokeCallbackAttribute is still required for il2cpp builds

rustic rain
#

hm
That function didn't seem to be related to entities either

rustic rain
rotund token
#

yes (well it needs to be static)

#
    public static class FunctionTest
    {
        [BurstCompile]
        public static int Add(int a, int b)
        {
            return a + b;
        }
    }```
#

you'll want
[MonoPInvokeCallback(typeof(Func<int, int, int>))]
for the sake of il2cpp on the method

#

but yeah this works fine

#

i want to say this was allowed since burst ~1.5

#

it's been quite a while anyway

rustic rain
#

huh

#

that's very interesting

#

I wonder if I can try and attach burst to 2019 Unity

rotund token
#

pretty sure burst up until recently supports 2019

white island
#

that's a new one.

remote crater
#

Nonsensical!

#

At least the error has a whimsical sense of humor.

#

How is this triggering a write? I see only reads: DynamicBuffer<TriggerIgnoreBufferElement> beB = World.DefaultGameObjectInjectionWorld.EntityManager.GetBuffer<TriggerIgnoreBufferElement>(entityB);

remote crater
#

That's poor error formatting, I'll return to text only.

white island
#

I'm just adding a struct to a list

#

here's the stack trace and relevant code

 [System.Serializable]
    public struct KDPoint
    {
        public byte d;
        public float3 point; //theoretically this is redundant
        //-1 is no child
        public int leftNode; //left node index
        public int rightNode; //right node index
    }

 public struct KDTree //specifically for 3 dimensions
    {

public NativeList<KDPoint> nodes;

        public KDTree(int defaultLength, Allocator allocator = Allocator.Persistent)
        {
            nodes = new NativeList<KDPoint>(defaultLength, allocator);
            Debug.Log("KD tree allocated");
        }

public void addPoint(float3 p)
        {
KDPoint newPoint = new KDPoint
                    {
                        point = p,
                        d = newD,
                        leftNode = -1,
                        rightNode = -1
                    };

                    nodes.Add(newPoint); //HERE
rotund token
#

the error basically means you're trying to resize to a negative value

#

the question is what in your code is doing this

#

my best guess is you're calling addPoint on a KidTree that hasn't been instantiated via your constructor

#

so it's invalid memory

white island
rotund token
#

well your log only implies that a KdTree has been instantiated, not necessarily the one you're referencing
without seeing the kdtree file we can't really see what is setup wrong

white island
#

as the stack trace implies, I am creating it through the factory at the end of the file there

rotund token
#

hmmmmmmmmmmmmm

white island
#

and the debug points . length shows me 2, as expected

#

so im not instantiating it with 0 length or something

white island
rotund token
#

yeah i cant see anything obviously wrong

#

i'm going to give it a run at some point when i have free time

#

and see if i can repo it

white island
#

what does the requested length mean?

rotund token
#

what is going on ๐Ÿ˜ซ

#

but anyway

#

what htis error is saying

#

you set capacity to 2

#

but it's trying to add a 3rd element

#

so it's definitely not been setup to the correct size for the logic

white island
#

yeah hm.

#

also it shouldn't be adding a 3rd element. i need to do some testing

#

Okay, it's instantiated now for capacity 4, adds two elements, and then goes pppbtht

misty wedge
#

What does this option do exactly?

#

Reuse worker threads?

rotund token
#

if you untick this

#

you will only use mainthread

misty wedge
#

It will run all jobs on the mainthread?

rotund token
#

all jobs will run on mainthread, there will be no parallel work

misty wedge
#

Awesome, that's exactly what I need

rotund token
#

useful for debugging and potentially dedicated servers

misty wedge
#

Also why dedicated servers? For determinism?

white island
#

and I initialize my native list with a capacity of defaultLength + 1, which is 3, but then it says my capacity is 4? somthing is fishy...

rotund token
#

if you're running a bunch of instances on the same machine it can be more efficient to just run each instance on a single thread

#

rather than running each instance over multiple threads interfering with each other

misty wedge
#

๐Ÿ‘

#

Also any other tips on debugging? Everything on my project works fine and then it will randomly stall and commit 30+gb of memory, then crash

#

It's locking on a dependency, but if I interrupt with rider I can't find what the issue is

#

I assume it's an infinite loop somewhere, I don't think anything else could take that much memory

white island
rotund token
#

yeah see i thought an infinite loop could be the problem

#

but i couldn't figure out how it would go to a negative length unless you added 2.1billion elements

#

which i thought would cause issues earlier

white island
#

i uh hope im not adding 2.1 billion elements

#

also I have no idea how there could be an infinite loop

#

add is only called twice

white island
# rotund token yeah see i thought an infinite loop could be the problem

The stack trace says it's in the factory function, but for the record I am calling it like this:

print("Building KD tree");
            IOD.NPCGranularNavigationSystem.KDTree.KDTree kd = IOD.NPCGranularNavigationSystem.KDTree.KDTreeFactory.buildTree(
                (from p in nodeList.ToArray() where p.worldIndex == 0 select p.position).ToArray() //??? error here???
            );

            print(JsonUtility.ToJson(kd, true));
            kd.Dispose();

the LINQ statement produces a length of 2 which is expected

#

this is in a different file

rotund token
#

@white island

#

you have a loop

#

for (int i = 0; i < nodes.Length; i++)

#

in this loop you add a point

#

nodes.Add(newPoint);

#

increasing nodes.length

white island
#

... youre right.

#

as it keeps expanding

#

it keeps going

#

got it

#

it should be capacity instead

#

and i gotta be sure to actually return from the function, whoop[s

#

ok. that did it. Thanks. Lmfao

#

sometimes I'm blind to my own code

viral sonnet
#

does collisionWorld.OverlapSphere actually have a cap? like, does the NativeList keep growing over the start capacity?

rotund token
#

dont think it's capped

#

you can cap it if you want

#

or custom filter it

#

and all sorts of things

#

(physics is very flexible for this)

viral sonnet
#

I hate code that ends in interfaces ... lol - yeah, how can I cap it?

rotund token
#

OverlapSphereCustom

#

and implement your own ICollector<DistanceHit>

#

the default overlap sphere just creates an all hits collector from your list

            where T : struct, ICollidable
        {
            var collector = new AllHitsCollector<DistanceHit>(radius, ref outHits);
            return target.OverlapSphereCustom(position, radius, ref collector, filter, queryInteraction);
        }
#

physics provides a few defaults for you

#

but you can implement any with custom rules you want

viral sonnet
#

ah, so I early out in the AddHit when the cap is reached?

rotund token
#

pretty much

viral sonnet
#

ok cool, thanks a lot

#

weird they have so many but none for capped

rotund token
#

๐Ÿคทโ€โ™‚๏ธ

#

it's a pretty obscure use case

#

i've never considered a need for something like that

viral sonnet
#

pretty normal for RPG skills. hit N closest or smth

rotund token
#

yeah that seems like a reasonable use case

#

i believe from memory it does add them in distance order

viral sonnet
#

do you know what the return value of public bool AddHit(T hit) is?

#
            {
                return false;
            }``` only found this false in QueryInteractionCollector
rotund token
#

based off that code alone seems like whether it should fire physics events ๐Ÿค”

#

but honestly i dont know havent looked

viral sonnet
#

well, at least I know where to start. it's late and I'm not getting some of these implementations. like ClosestHitCollector is just overwriting m_ClosestHit.

viral sonnet
#
                    {
                        hadHit |= leafProcessor.ColliderCastLeaf(input, hitData[i], ref collector);
                        if (collector.EarlyOutOnFirstHit && hadHit)
                        {
                            return true;
                        }
                    }``` I found some more answers but the ClosestHitCollector is still a mystery to me how it actually works with the code and no early out
#

good thing is that I can control breaking the loop after the cap has been hit with setting EarlyOutOnFirstHit

rotund token
#

oh actually i think i was backwards

#

closest hit is last

#

which is what the ClosestHitCollector relies on

viral sonnet
#

now it makes sense ๐Ÿ˜„

#

and my cap collector wouldn't work. eh, I'll think of something else. no biggie

#

i need to debug this to confirm. so the list I get back has the farthest first

rotund token
#

i believe so

#

i think i've used this before

#

so if you only care about x closest hits

#

just take it from the end

viral sonnet
#

yep, easy enough

rotund token
#

but yeah you'll want to check this

#

and maybe add in an assert just to confirm in case unity ever changes this behaviour

viral sonnet
#

initially I wanted to cap the memory allocations. but with the nearest last, this doesn't really work out

rotund token
#

i haven't used it before

#

but you could try maybe UnsafeRingQueue

#

but i have a feeling this doesn't actually loop ๐Ÿ˜ฆ

#

which i thought it did

#

oh well

viral sonnet
#

interesting concept though

rotund token
#

but yeah basically just use a native array and index % length

#

you also get the count from memory on return

#

yeah NumHits

#

would always replace the furthest away

viral sonnet
#

eh, something for tomorrow ๐Ÿ™‚ Have a good night all o/

rotund token
#

and it's passed by ref so you should be able to read it after?

half jay
#

Hello, what can cause such a load in this job?

hot basin
#

I'm guessing high number of children in your hierarchy

half jay
#

every entity has no more than 6 - 7 children

hot basin
#

and as I can see by colours, you have burst turned off?

half jay
#

oops

ionic sierra
#

Hello. Anyone know what kind of performance difference to expect out of a 2D game in Dots. I remember the early demos, zombie games, and Dots cameras, boids, etc, but since they've changed to a more hybrid approach recently , what are the current performance gains and are there any current examples?

rustic rain