#archived-dots

1 messages ยท Page 58 of 1

late mural
#

ah, how would i implement that?

rotund token
#

just inherit from as well

late mural
#

oh ok, thanks a ton!

#

ok now i just gotta workout how to add the parents correctly, as it seems doing it like this: ```cs
state.EntityManager.AddComponent<Parent>(SomeChildEntity);
state.EntityManager.SetComponentData<Parent>(SomeChildEntity, new Parent
{
Value = WhateverParentEntity
});

rotund token
#

turn off burst and get the full error

late mural
#

hmm, how would i get a component out of an IJobEntity? i thought to use a NativeReference<TheComponent> but unfortunately nested native containers are illegal

late mural
late mural
late mural
#

how would i instantiate an entity, and have it keep all the components of that entity?

rotund token
#

CommandBuffer.Instantiate

#

or EntityManager.Instantiate

late mural
#

tried that, but it isnt keeping the components, well isnt keeping the local transform component atleast

#

i suppose i could manually go through every component the entity has, then add that to the instantiated entity? Or is there a better way?

#

perhaps im doing something wrong in the baking? Is GetEntity(GameObjectPrefab) the correct way to get an entity version of a gameobject prefab?

#

is there anyway i can check how baking has converted the GameObject prefab into an Entity?

late mural
#

using GetEntity(), if that is what you mean?

robust scaffold
#

or do you want to step through the baking process?

late mural
#

i want to see the components of the entity created by GetEntity() to see if it has the right components

robust scaffold
late mural
robust scaffold
#

You might need to hunt for it as if it was baked previously, the entity should resolve to link to the original GO

robust scaffold
late mural
late mural
robust scaffold
late mural
robust scaffold
late mural
#

ah, that is unfortunate, so what should i use instead?

robust scaffold
#

Buffer components.

late mural
#

ok thanks a ton

#

how about native lists, they fine, or do i also have to replace them aswell?

robust scaffold
#

A dynamic buffer component is a native list. And yes, you need to replace them with a buffer.

late mural
#

ok thanks

robust scaffold
#

Nothing NativeX is allowed.

late mural
#

ah ok thanks so much!

#

ok so if im understanding this right, i add 1 buffer for every element in the array, right?

robust scaffold
#

For each array you add a buffer and for each element, well it's just a native list tacked onto an entity.

late mural
#

fascinating, so i put the native arrays and lists inside the buffer component then? Or am i completely misunderstanding this?

#

oh wait i think i get it, so i treat the component like one element in an array, and when i add the component to an entity, i can specify elements and stuff that is itself?

robust scaffold
late mural
#

ok fascinating, thanks so much

robust scaffold
#

Where RequiredClient is:csharp public struct RequiredClient : IBufferElementData { public EntitySceneReference Value; }

late mural
#

seems you bake buffers very similarly to the way you convert an array of structs to be entities instead of gameobjects, thanks so much!

robust scaffold
#

The equivalent list would be a NativeList<EntitySceneReference> scenes = new NativeList<RequiredClient>(Allocator.Persistant).Reinterpret<EntitySceneReference>();

late mural
#

ok fascinating, thanks so much!

late mural
#

is there anyway to get RW access to a singleton form of a buffer? Sadly GetSingletonBufferRW<>() seems to not exist...

robust scaffold
#

The boolean after the entity indicates RW state (false = RW, true = RO)

late mural
robust scaffold
late mural
#

awesome, thanks so much!

robust scaffold
#

Right, an i'm off to sleep. If you have any further questions, hopefully someone else can help ya out. Good luck and see you tomorrow.

late mural
#

good job, and thanks a ton!

late mural
#

now that i know you cant use native stuff in components, what would be the replacement of a NativeHashMap?

rustic rain
#

you can, but it won't bake

late mural
#

i dont need to bake it, so can i just use it then?

rustic rain
#

yeah, I think so

late mural
#

so it is only native array and native list that can't be used in components?

rustic rain
#

all native containers can be used

#

as of 1.0

late mural
#

oh wow, judging by what KornFlak said i thought i would have to replace them, was what they said incorrect?

rotund token
#

while yes you can put native containers on components

#

it won't really work how you want

#

you can't access the container in a job

#

you can only access it in a system and then pass it to a job

late mural
#

oh ok fascinating, so i should use the buffer components when im planning to do something in a job with them, and native containers when i dont plan to use it in a job?

rotund token
#

i would suggest, for the most part just don't put containers on entities

#

unless you really know what you are doing and have a very specific reason for it

late mural
#

well i need to store containers somewhere, unless there are replacements?

rotund token
#

basically only put them on singleton entities you get on main thread then pass to jobs

#

to share a container between systems

late mural
#

ok fascinating!

hushed lichen
#

I've got a project (in 0.51) with a dynamic buffer on an entity.
Very specifically on the entity - created at runtime - because storing a reference to it in a component caused problems. Unity crashed, the "solution" would probably be to update the reference every frame with GetBuffer on the entity but then why even have the reference on the component anyway?

late mural
#

also if i have an array of gameobjects and i then during baking convert it into a native array using GetEntity() is this going to mess anything up, or will this work?

late mural
late mural
late mural
hushed lichen
#

How are you instantiating your prefabs?

late mural
hushed lichen
#

I meant the process more than the function call itself ๐Ÿ˜…

late mural
#

oh sorry lol

hushed lichen
#

How are you getting the prefab and sending it to the Instantiate() call?

late mural
#

essentially i have a biome component, with an array of feature structs, each feature struct contains a gameobject and a few other details about the feature, i then bake this into a component version of the array of feature structs, with entities instead of gameobjects which i get via GetEntity(), whenever a chunk needs to be generated i grab all biome components and go through them to decide which one to generate, then go through each feature and pick a random one, once i have my random one i then instantiate it

hushed lichen
late mural
#

i've seen that before, but i cannot get it to work with my logic, either the entities i store on the components somehow become invalid, or GetEntity() is going wrong, or instantiating is going wrong, and i cant tell which

#

is there anyway i can debug what is going wrong?

hushed lichen
#

You've got that kind of authoring component, set the Entity reference to your prefab and get and instantiate it as the SpawnSystem does?
If so, I don't know what the problem is. I'd probably start by adding a Debug.Break() call, check the reference, check the prefab entity (in the DOTS Hierarchy window) and possibly debug print the prefab reference you get in the code. See if they match.
Makes sense to also print the entity returned from Instantiate()

#

Oh and, try to do it in a small environment first? Just one prefab with limited systems and not a whole slew of collections with references to prefabs or whatever.
Simplify, solve, expand.

late mural
#

ooh fascinating, ill try that thanks

#

ok i've done a bit of debugging and now i can confirm that my prefabs are being correctly converted into entities! But they are not getting instantiated correctly, instead of duplicating the prefab, it decides to do this:

#

which lets me know that i have no clue how to instantiate stuff

late mural
#

ok after many googles i can say that instantiating should be really easy, but for some reason just wont work for me, how odd

late mural
#

wait a second, do entities have to be passed by reference, as that may be the issue?

rotund token
#

made up of 2 ints

#

they do not need to be passed by reference

hushed lichen
#

You can see that on the screen grab above too. Index and Version.

rotund token
#

i just a wrote a packet fragmenter for netcode

#

Basically if you add any data to a DynamicBuffer<NetworkPayload> (which is just a byte) on a ghost entity

#

it will compress then split it into smaller 512kb ghosts and recombine them on the client's ghost NetworkPayload

#

designed for binary data that's mostly static between 1-20KB

#

i thought about writing it as a separate socket side channel

#

but i really wanted to be able to just tie into netcode relevancy for this

devout prairie
# late mural i've seen that before, but i cannot get it to work with my logic, either the ent...

I'm guessing that during baking, the GetEntity() that you store and later use to instantiate is getting invalidated.. Normally that'll happen if for example you don't store the GetEntity() result in an IComponentData or a buffer ( because using GetEntity() during baking returns a temporary entity value which gets tracked and then updated on your components/buffers after baking is complete )..

rustic rain
#

only whatever is supported by baking will be properly remapped to actual entity

devout prairie
misty wedge
#

How do I use WeakObjectReference during baking?

#

The inspector just shows me the struct contents, nothing to e.g. drop something in

misty wedge
#

(Also I'm guessing you wrote this for sending your navmesh?)

#

I feel like the editor for WeakObjectReference is just broken for me, WeakSceneReference shows a scene field to drop a scene into..

rustic rain
#

bruuuh, is there just any fix to avoid restarting editor if you stop play mode with entity inspected?

vocal basin
#

Does anyone have a new guide? The pinned github is gone

vocal basin
#

Thanks

rustic rain
#

I'm extremely frustrated

#

smth in my physics is doing very funny stuff

#

as soon as I get my trigger event

#

my entities are getting swapped with another

#

their position

#

is swapped somehow

#

and there is nothing in my code that does smth even relatively close to it

#

here logs are thrown before and during trigger event job

#

and now 1 frame afterwards

#

same for entity 175

robust scaffold
#

Trigger event, no collisions, just overlap?

rustic rain
robust scaffold
rustic rain
#

Here's moment couple frames after overlap

#

basically

#

tree1 got swapped position with tree2

#

Tree1 should be left, Tree2 right

#

feels like someone in Unity made a very funny joke

#

I did tons of records in journal

robust scaffold
rustic rain
#

and nothing modified LocalTransform component except for Unity Physics Export System and my system that moves entities by a bit

#

during that trigger event time frame

#

And my movement system looks like this

        private partial struct MovementJob : IJobEntity
        {
            public float2 playerVelocity;

            private void Execute(Entity e, ref LocalTransform local, in Movable movable)
            {
                Discard(e.Index, local.Position.x);
                local.Position.x -= playerVelocity.x * movable.speed;
                Discard(e.Index, local.Position.x);
            }

            [BurstDiscard]
            private static void Discard(int ind, float val)
            {
                Unity.Debug.Log($"{ind} {val}");
            }
        }
#

and it is pretty clear from log, it's not my system

robust scaffold
rustic rain
#

now I will test one other thing

rustic rain
robust scaffold
#

ah true

rustic rain
#

now I will make a backup of LocalTransform

#

before physics import

#

and then write it back

#

because in my world, physics should not move anything

robust scaffold
#

Try making them kinematic or even static

rustic rain
#

all of them

robust scaffold
#

Hrm, no clue then

rustic rain
#

if I make them static, triggers don't work

#

which is odd

#

hmm

#

now static works with trigger

#

god, this is driving me crazy

#

๐Ÿฅด

#

ok

#

seems like static thingy solved it

#

welp, but that only delayed me going crazy ๐Ÿ˜…

#

I think it's a bug

#

and I want to see if it's reproducable

robust scaffold
rotund token
#

It's really just designed for small static or rarely changing binary data

#

Checking if data has changed if as easy as change filtering the buffer and then just checking length != 0

#

As the payload buffer is cleared once split

rotund token
rustic rain
rotund token
#

Umm no I don't think so because I changed behaviour of stuff

#

It's a 2 line script

robust scaffold
rustic rain
rotund token
#

I get disposed world issues

robust scaffold
#

That's concerning. I just get this replacing the entity inspector:

stiff mesa
#

Hey. I've got a question. In Entitas, there is a thing called Reactive System. It only updates if specific components have changed and it automatically queries for the entities that have those components changed. Is there something similar in DOTS?

rotund token
#

I think it's addressables

robust scaffold
rotund token
#

The addressable header does a get hash code check on the object which for entity selection proxy hashes world

rustic rain
robust scaffold
rustic rain
#

and how to unselect?

stiff mesa
rotund token
#

Or something like that

#

You can check if the entity proxy is selected first if you wanted etc

rustic rain
#

I guess that's it

        static EntitySelectionErrorFix()
        {
            EditorApplication.playModeStateChanged += LogPlayModeState;
        }

        private static void LogPlayModeState(PlayModeStateChange state)
        {
            if (state == PlayModeStateChange.ExitingPlayMode)
            {
                Selection.activeObject = null;
            }
        }
rotund token
robust scaffold
rustic rain
#

no more wasting precious time restarting editor

rotund token
#

Kek

rustic rain
#

kek indeed

misty wedge
#

So anyone know how to use WeakObjectReference?

#

I just don't feel like it should look like this

robust scaffold
#

@light badger When you accept join requests from a client in your OnlineFPS sample, is the send RPC component suppose to be broadcasted to all connections?

misty wedge
#

If a client sends an RPC it's always only sent to the server

robust scaffold
misty wedge
#

Ah, my bad

#

That seems like a bug then

#

Unless the clients need the information for something ๐Ÿคทโ€โ™€๏ธ

robust scaffold
#

As in the code sample is from server accepting a specific client connection request and now is sending a join request RPC back to all connections apparently.

misty wedge
#

This is what I do

robust scaffold
rotund token
#

Wasted archetypes ๐Ÿ˜ฑ

robust scaffold
misty wedge
#

I will waste as many archetypes as I please

rustic rain
rotund token
#

I'd probably do the same thing as I'm lazy but yes you should create entity with an archetype then do a set instead to avoid creating an extra unused archetype

misty wedge
#

I tried it and my FPS doubled, insane

hushed lichen
# robust scaffold Same here

Looks to me like SchnozzleCat adds a RequestEnterGameRPC component and you're adding a ServerJoinAcceptRpc component as the only notable difference

rustic rain
#

I wish AddComponentData has overload for multiple component types

rotund token
#

It does

rustic rain
#

๐Ÿค”

#

really?

misty wedge
rotund token
#

Look at the componenttypeS overloaf

misty wedge
#

And mine is obviously better because I capitalized RPC violating my naming conventions

rustic rain
#

๐Ÿคฃ

#

damn that looks horrible

rotund token
#

Much better

robust scaffold
#

I wish new[]{} was burstable. Damn bill gates and managed arrays.

hushed lichen
#

That does look kind of horribly excessive in complexity for the same end result.
Not that atypical but still

rotund token
#

same result?! he's saving 16KB of memory and removing an archetype from query searches!

#

game changing

robust scaffold
#

I think a better version would be AddComponent(Entity, new ComponentTypes())

#

But this hyperoptimized version skips one add component.

hushed lichen
misty wedge
#

Like I said, it doubled my FPS. I'm now a believer

hushed lichen
#

If I have a complaint with it, it's that the interface for getting that (apparently very significant) performance increase is so much more cumbersome than the simpler "add components one at a time" approach

misty wedge
#

(I was also joking with the doubled FPS ๐Ÿ˜… )

#

Pretty sure you are fine with adding components one at a time. Ideally you'd instantiate a prefab most of the time and then set the data on that

#

(at least that's what I try to do)

hushed lichen
#

I mean, if it's 16KB of memory per time you do that, it's a significant improvement in a larger project

misty wedge
#

That's true

#

That's when you tell your users to just download more RAM

hushed lichen
#

Yeah same, if I know I need some components on a prefab I want to have them on there already if I can.
The one thing I haven't figured out how to do on a prefab in that regard would be adding a DynamicBuffer. Doubt you can do that on a prefab in the first place.

rotund token
#

basically the AddComponent ServerJoinAcceptabledRpc will create a { ServerJoinAcceptabledRpc } archetype
then the SendRpcCommandRequestComponent will create a { ServerJoinAcceptabledRpc, SendRpcCommandRequestComponent } archetype

misty wedge
rotund token
#

no

misty wedge
#

:[

rotund token
#

it's also not unused, you'll use it again on next connection

misty wedge
#

Not the ServerJoinAcceptabledRpc

rotund token
#

there is a limit of around 8-12k archetypes and it's really easy to hit if you add/remove a lot of components

misty wedge
#

that's just the intermediate from adding twice

hushed lichen
#

I'd say it's probably closer to "temporary" rather than "unused"

#

or, yeah, intermediate

rustic rain
#

16kb is 0.025 of amount of memory that would be enough for everyone

#

๐Ÿคฃ

rotund token
#

in this small case, it really doesn't matter

#

but i have seen people have large dynamically generated entities at runtime

#

that just do like 50 addcomponents 1 after the other

#

and we did something like this at work

#

and using an editor analysis and pre-computing the archetype saved us over 2,000 archetypes

hushed lichen
#

Oof. That seems just plain painful.
Much cleaner to just have the components on the prefabs so you don't need to cross reference instantiation to figure out what components are associated.

rotund token
#

work project has no baking/conversion

#

project started before that existed

hushed lichen
#

Ah, and no time allotted to technical debt?

rotund token
#

haha you have never seen a project with more technical debt

#

god damn awful

#

can't wait till we start a new one which will be built upon my own libraries

hushed lichen
#

That sounds painful to work in

rotund token
#

so painful

#

being in charge has perks though, i can just assign all the painful tasks to others ๐Ÿ˜„

rustic rain
hushed lichen
#

At some point, just fucking upgrade lol

rotund token
#

there's no way we could upgrade this project to 1.0

rustic rain
#

I know

#

I couldn't upgrade my own SMALL project from 0.51

#

I straight up redo it

#

because it's easier

rotund token
#

i tried upgrading us to 2021.3 and it was a nightmare

#

and too close to launch so gave up

hushed lichen
#

Don't have to go to 1.0 just because you're upgrading the editor lol

rotund token
#

the 0.51 upgrade took enough effort

rustic rain
rotund token
hushed lichen
rotund token
#

yeah i tried 2021

hushed lichen
rotund token
#

too many issues

#

we are just using 0.51 on 2020

#

and since our gold build pre is due on tuesday

#

be a while before i try again

hushed lichen
#

Makes sense ๐Ÿ˜…
Rough time to release too

rotund token
#

we're just going from early access to 1.0

#

though it's a huge update

#

basically a new game

hushed lichen
#

Even if it was from 1.0 to 1.1, I'd consider it a release. Probably a case of definition differences though

rotund token
#

oh yeah i got ya

light badger
robust scaffold
# light badger ah, yeah that's something that should be changed

Okay, thought so. Good network framework though. I'm going line by line and overhauling my own to largely match what you're doing. Although I am hesitant on using ECBs for deferred structural changes. Are they really better than just direct EntityManager calls for network initialization and spawning?

#

Maybe I'm just old but i still remember those benchmarks that showed even bursted ECBs required 2x or even 3x more execution time to structurally change the same commands as directly using entity manager calls. But this was 2018-2019 profiles back when ECBs just managed to get bursted. I havent seen any comparisons since.

hushed lichen
#

Don't know about comparisons so the only input I have (sadly) is that ECBs help with sync points since you're not doing structural changes interspersed throughout the system updates

light badger
#

direct EntityManager calls would be totally fine in most cases, although sometimes ECBs are required in order to do structural changes in a loop without invalidating data

robust scaffold
rotund token
#

the one thing i've been trying to do recently is avoid every frame empty ecbs

#

making sure systems early out that don't need to run or avoid using ecbs where a system needs to run constantly but only rarely writes to the ecb

#

i find the overhead of playing back an empty ecb a bit high

safe lintel
#

whats an empty ecb?

rotund token
#

ecbs.CreateCommandBuffer()

#

dont do anything with it

#

just the ecbs.Playback overhead on the command buffer

#

and disposing

#

this is the cost of an empty ecbs

safe lintel
#

ah

rotund token
#

0.08ms on my machine

#

that doesn't sound like a lot

safe lintel
#

hmm, now im paranoid if i do this alot or not

rotund token
#

but if you have 15 systems with ecbs, that's a ms per frame

hushed lichen
#

Every frame? Potentially multiple ECBs? Ouch

rotund token
#

now ok i'm a little exaggerating here from an editor profile as it's a bit less in a build

#

(about half that)

#

but you still get the point

robust scaffold
rotund token
#

i just removed structural changes or do them in OnUpdate for singular entities or once off changes (init)

robust scaffold
#

Ah

misty wedge
#

What if you need to destroy / create something

#

pool it?

rotund token
#

i have a whole destroy pipeline

hushed lichen
#

Store the entities to be destroyed in a buffer or what?

rotund token
#

where you can react to things being destroyed, cancel it etc

robust scaffold
#
private void TryGetEcb(WorldUnmanaged world, out EntityCommandBuffer ecb)
{
    // * Command buffer for deferred structural changes.
    ecb = _ecb.IsCreated
        ? _ecb
        : SystemAPI.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>()
            .CreateCommandBuffer(world);
}```
misty wedge
#

I think the biggest thing for me is just entities being created and destroyed on the client by the server

rotund token
#

and you can't use an ecb after its been playedback

misty wedge
#

I think they mean re-use the same one across a single frame by multiple systems

robust scaffold
rotund token
#

oh is this for a single system?

robust scaffold
rotund token
#

yeah ok

robust scaffold
#

yea

#

At the very end you get this: _ecb = default;

rotund token
#

you could probably wrap this behaviour in your own ECBS + singleton if you really wanted

#

where you write a custom CreateCommandBuffer(x) that would return a cached version for a system or a new one

rustic rain
#

hmm

robust scaffold
rotund token
robust scaffold
# rotund token ๐Ÿฅณ

Oh, very nice. I thought you also had a fadeout as well? I've been kinda mirroring this implementation using ghost relevancy which is slightly buggy.

rotund token
#

fadeout for what sorry?

robust scaffold
#

fadeout for distant objects that just got spawned in on that navmesh

rotund token
#

oh the navmesh is built on server

#

this is showing it streaming to client

robust scaffold
#

Ah

rotund token
#

the first draw is the servers full navmesh

#

i decided not to regenerate it on clients and instead send it

#

because ghosts streaming in constantly just ends up causing it to rebuild constantly

#

and runtime navmesh generate with complex meshes is just not that fast

#

(about 1.5 seconds for this scene using 50% of threads)

#

what i did was add support for sending navmesh via netcode relevancy

#

and then added a packet fragmenter so i wouldn't run into network issues

#

by default compressed most of these cells are 0.5-1KB

#

but in the centre with a lot of details they go up to 10KB which is too large for netcode ghosts

#

so i wrote a generic network payload implementation

#

basically you put any type of binary data in a NetworkPayload buffer

#

and it will auto split it into 512KB chunks over X number of ghosts

#

then recombine them together on the client after they've all synced and assign to the clients local NetworkPayload buffer

#

great for static data in the 1-20KB range

robust scaffold
#

@light badger Also, is there a reason why you're not using the existing linked entity group for tracking owner relationships?

rotund token
#

when i was helping shinclef setup rival with my game library we had the same thought

#

adding stuff to a LEG on a ghost broke a bunch of stuff or something when we tried

robust scaffold
#

They're all just 1 element and otherwise wasted space.

rotund token
#

hate to say I am finding LEG very useful recently

#

though i am still at war with the forced LEG and default capacity

robust scaffold
#

I was thinking about adding a LEG to a network ID component for automatic owned ghost destruction.

rotund token
#

i think unity did something similar in the car demo

robust scaffold
light badger
#

to be honest I can't really remember if I had a real justification for this. Some vague sense of maybe having more explicit control over things

robust scaffold
rotund token
#

definitely worth a shot, our use case might have been different

robust scaffold
#

I was thinking this instead of a ClientOwnedEntities buffer and also using the CommandTargetComponent to indicate player entity instead of a custom component. csharp // * Using LEG for easy cleanup of owner controlled entities when the network is destroyed. ecb.AppendToBuffer(srcEnt, new LinkedEntityGroup { Value = playerEnt });

rotund token
#

oh this is on the network connection?

#

yeah that's what i do

#

rival from memory uses network connection -> player (commands) -> character

#

i think we had issue putting character onto the player leg

robust scaffold
#

ah, hrm. Okay. I'll need to see if i run into the same issue

devout prairie
#

What is this LEG of which you speak..

rotund token
#

linked entity group

devout prairie
#

Ahh, LinkedEntityGroup

#

Need to look that one up

#

HNY tertle I assume you're in 2023 already

rotund token
#

well into morning ๐Ÿ™‚ ty!

rustic rain
#

bruh

#

for some reason some AnimatorController gets serialized

#

and other don't

#

in subscene

rotund token
#

what do you mean by others

rustic rain
#

literally just 2 different animators

#

practically no difference between them

#

and they are simple

rotund token
#

what do you even mean by serialized?

rustic rain
#

as soon as I close subscene, it's gone

#

Missing

rotund token
#

(and what is AnimationController)

rustic rain
#

It's an asset for Animator

rotund token
#

oh rac

#

ok

rustic rain
#

๐Ÿค”

#

turns out if I have prefab, it gets serialized

#

what the

rotund token
#

how are you serializing it?

#

on a class icd?

rustic rain
#

just this

        public override void Bake(Animator authoring)
        {
            BakingUtility.AddAdditionalCompanionComponentType(typeof(Animator));
            AddComponentObject(authoring);
        }
#

I'm making a build rn to test

#

whether it'll be fine

rotund token
#

hmm from what i understand AddAdditionalCompanionComponentType might not actually work in builds

rustic rain
#

it works

#

๐Ÿ˜…

rotund token
#

well that's good i guess

#

what do you intend to do when they remove this ๐Ÿ˜„

rustic rain
#

๐Ÿคฃ

rotund token
#

i love the optimism!

#

soon ๐Ÿ™

rustic rain
#

and do my animations by swapping id

safe lintel
#

are there any plans for the foreach to ever compile to jobs in the future or is it strictly mainthread access?

rustic rain
#

which is probably the best solution rn

#

but I'm too lazy to implement it

#

๐Ÿ˜…

rotund token
safe lintel
#

was a little surprised it wast an all in one replacement for EFE but just curious really

rotund token
#

i'm glad it's not

#

i find efe just caused bad code constantly

#

sure the job starts out small and maintainable

#

then someone adds some functionality

#

and someone else some more

#

and then a bit more

#

next you have a 400 line EFE with 12 local fuctions

rustic rain
#

oh yeah, that was my character controller in 0.17

#

๐Ÿ˜…

#

huh

#

looks like my VisualTreeAssets on the other hand don't get serialized for some reason

#

in a build I mean

rotund token
#

๐Ÿ˜ฆ

rustic rain
#

some do, some don't which is odd

#

yeah, indeed

#

some are nulls, some are not

#

what the

rotund token
#

this is cool

safe lintel
#

ok using chat gpt to figure out ik lookat solver for animation was pretty damn neat.

rotund token
#

oh no, the first step to being replaced

safe lintel
#

when it blends to run?
edit oh misread to instead of is ๐Ÿ˜€ - still blending could be improved to take foot position into account

misty wedge
#

I want a reload timeline

late mural
#

trying to wrap my head around buffer components, is the InternalBufferCapacity() how many bytes each element needs, or something else?

robust scaffold
robust scaffold
late mural
#

fascinating, im not the best with memory, so i have no clue what stack and heap memory is im afraid

robust scaffold
#

Memory inside the chunk (indicated by internal buffer cap) is fast but you balloon the size of the entity. Outside the chunk is slow but more entities can fit inside the same chunk.

#

Rule of thumb, just set the internal buffer capacity to 0 outside of some very small edge cases.

late mural
#

ok thanks a ton

robust scaffold
#

More entities inside a single chunk is almost always better than having immediate memory access to a dynamic buffer element.

late mural
#

ok cool!

robust scaffold
#

98% of the time, you want an IBC to be 0, 1.5% you use a fixed field. 0.4% you use a copy pasted field (like how the fixed X bytes are done). 0.1% you use a IBC of a larger value.

late mural
#

ok got it, thanks!

#

wondering is it possible to get a buffer in an i job entity like regular components?

robust scaffold
#

yea, DynamicBuffer<buffCompType>. Standard rules of in for RO and ref for RW.

late mural
#

thanks a ton!

#

do dynamic buffers get passed by reference in job fields, or do i have to instead just store a native reference to the entity and then grab the buffer afterwards? (i hope that made sense)

robust scaffold
late mural
#

ye but i mean i want to pass the dynamic buffer outside of the job, does that make sense?

robust scaffold
#

hrm, I think that's possible. Using a IJobEntity to query for a specific dynamic buffer then writing that buffer into a NativeArray<DynamicBuffer<BufType>>(1) for use in another job. But the safety system might throw a fit.

late mural
#

perhaps it would be better to just store the entity from the parameters in a NativeReference then, and just grab the buffer afterwards?

robust scaffold
#

Yeaaaaa, that's more advisable. Use a BufferLookup<BufType> obtained from SystemAPI

late mural
#

ok thanks a ton!

robust scaffold
late mural
#

is there anyway to get a component of an entity created in an ecb before it is played back? (tryna figure out how to set the pos of an entity while using an ecb...)

late mural
tribal pollen
misty wedge
robust scaffold
late mural
#

ok thanks a ton!

robust scaffold
#

@light badger All over your code, you check GhostOwnerComponent NetworkID against local connection value to operate on only local ghost owned entities. Is there a reason why you're not just using GhostOwnerIsLocal enabled component in the query?

late mural
#

wondering, is it better to do parenting first then do positioning, or should i setup positioning first and then setup the parenting? (also if the parent's position is 0 0 0 then any child's local position should be equal to its world position right?)

robust scaffold
#

Parenting and inheritance in DOTS is a bad pattern. Sometimes necessary though but aim to minimize as much as possible. If you must parent, setup parenting then set positions using the TransformAspect.

late mural
#

ok fascinating, thanks a ton!

robust scaffold
#

Has anyone managed to get the IInputComponentData working for thin clients? Or is ICommandData the only way it'll be serialized?

#

Hrm, seems like it.

robust scaffold
#

No, input components should be working for thin clients, all the required systems are hooked up and enabled for thin worlds, but the buffer isnt being populated. Why

#

There we go, i forgot to set the ghost ownership on the instantiated player entity. Woops.

robust scaffold
#

@light badger Another suggestion, in AuthoringKinematicCharacterProperties, move CustomPhysicsBodyTags below the two interpolation tags. This will remove the double "General Properties" headers that appears when the imgui tag sets a header and the uielements also does so.

#

@light badger First is original in rivals and the second is the proposed change:

rustic rain
tribal pollen
robust scaffold
rustic rain
#

๐Ÿ˜…

#

But sir

robust scaffold
#

It works with everything, no internal access required. Just spawns a GO and mirrors the transform.

#

It even works in editor. Like magic

rustic rain
#

I dont want x2 gos per entity

robust scaffold
#

Replace all companion GOs with this hybrid setup.

#

ah, i see

#

well, stop being lazy.

#

It's more like 1 go and 1 prefab but still, laziness is bad. Companions are gonna get nuked soon.

rustic rain
#

Then we'll get alternative for sprites

rotund token
#

and this is from the companion king!

robust scaffold
rotund token
#

if netcode is anything to go by, the alternative is basically just what kornflaks posted

#

netcode already has a hybrid presentation implementation

#

which just spawns gameobjects/manages them

rustic rain
#

I only need hybrid because of sprites

robust scaffold
#

Yea, i just wholesale copied the hybrid presentation but used a component to indicate linked GO rather than a native list.

robust scaffold
rotund token
rustic rain
rustic rain
#

unlit

rustic rain
#

And i use fmod

robust scaffold
#

Imagine using audio, my game will be as silent as the grave. People (i.e. me) have youtube anyways.

rustic rain
#

Workflow might be painful

rotund token
robust scaffold
rustic rain
#

How does it work in authoring?

#

I have many prefabs

robust scaffold
#

I shared the entire folder above but here's how it looks:

rustic rain
#

I build scene with them

robust scaffold
#

ultra simple.

rustic rain
#

Yeah, but I need to see sprite in scene view

robust scaffold
#

Works with spawning anything mono, including tilemaps that are updated like a regular monobehavior.

rotund token
#

(this is basically the same concept as my original hybrid implementation i was promoting months ago and no one was interested. suddenly 1324123 copies)

robust scaffold
#

Works in scene view.

robust scaffold
robust scaffold
rustic rain
#

How does it work in scene view? (sorry, on phone, haven't seen folder)

robust scaffold
#

[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation | WorldSystemFilterFlags.Editor)]

rustic rain
#

Ah

robust scaffold
#

If you dont have netcode, you might need to change client simulation to default.

rustic rain
#

You have editor system

robust scaffold
#

It's the same system used in runtime, just also runs while outside of playmode.

#

The transforms are there, the mono prefab is also there, why not also spawn the go as well?

rustic rain
#

How do you dispose gos? Im curious

#

In editor

robust scaffold
#

Same as companion gameobjects (I copied pasted this)

#

It took about 15 min to throw this together

rotund token
#

oh interesting. i just clean them all up in system ondestroy

#

but that seems like a maybe even more reliable approach

rustic rain
#

Huh

#

I forgot about this

robust scaffold
#

Note, this only works if the subscene is open, havent figured out a way to render the go's with the subscene closed like hybrid renderer but eh, it's good enough.

#

It renders in runtime with the subscene closed, just not in editor.

rustic rain
#

I see, Ill take a try on this, I guees

#

Bruh

robust scaffold
#

runtime as in play mode

#

not outside of play mode

#

ugh, im mixing up my terms

rustic rain
#

That means workflow is still miserable, sadge

robust scaffold
#

I mean, just open the prefab in scene view

#

This is play mode

#

And this is outside of play mode. Might be because of something in netcode though.

rustic rain
#

But scene view is important, in edit mode

robust scaffold
#

So just open the subscenes then

#

Oh and there's no picking in scene view, if that's important then uh, that'll require quite a bit of work.

rustic rain
#

Yeah, and then close them on every change... Gotta be a better way

robust scaffold
#

wait no, it does work

rustic rain
#

?

#

I'm confused

robust scaffold
#

I just had the subscene not loaded because I custom load them for netcode

#

If you have them on auto load scene, the game objects show up

rustic rain
#

๐Ÿฅด

#

Yay then

robust scaffold
#

as I said, netcode might fuck with things, lots of things are toggled off and only manually ran in code.

rustic rain
#

Jeez, networking sounds painful

robust scaffold
#

The only thing now not working is scene picking. Give me a sec i got an idea.

robust scaffold
rustic rain
#

Scene picking doesn't worl for companion either ๐Ÿ˜…

#

Needs some kind of proxy

rotund token
#

netcode is trying to make a lot of historically difficult network things a lot easier

robust scaffold
rustic rain
#

Should help with authoring

robust scaffold
#

Or the 50 million errors on awake also halts execution until I fix it

rustic rain
#

Auto load on default

#

And disab

#

Led in runtime

robust scaffold
#

Alright, the picker's internal because unity is evil, gonna get some asm hacks to see if this works.

#

Damn, no, picking doesnt work even setting editor render data

rustic rain
#

So on click it goes over spaawned gos and compares to registered

robust scaffold
rustic rain
#

Editor one

robust scaffold
#

Yea, there could be a lot of things in the editor

rustic rain
#

Or other way

robust scaffold
#

Picking only happens in editor anyways

rustic rain
#

Store temporary component on go

#

Which stores entity

robust scaffold
#

ugh, too much work for just picking

#

wait, hrm

rustic rain
#

Id do it

#

As soon as Ill get to pc

robust scaffold
#

kk

#

yea, you can pick the GO itself as long as it's not hidden in the hierarchy

robust scaffold
calm edge
#

In ECS physics is it more performant to make a trigger collider that is added to the world or to do casts manually?

robust scaffold
calm edge
#

specifically for weapon projectiles, though in my case they can be large so just doing raycasts isn't enough

robust scaffold
robust scaffold
#

oh boy, 2d character controller is a lot harder than I thought.

#

i'll figure it out tomorrow...

rustic rain
#

with 1 less axis

late mural
#

in a SystemBase how would i get rid of entities?

rotund token
#

entitymanager.destroy
commandbuffer.destroy

late mural
#

thanks!

robust scaffold
# rustic rain same as 3d though, no?

Top down means that one should assume characters are always grounded. Which changes a key assumption at the root of the controller. So I'm gonna have to change a lot of things to accommodate that assumption.

rustic rain
#

this should be pure 3d

robust scaffold
rustic rain
#

then why do you care about being grounded at all?

robust scaffold
#

Exactly. The character controller does however. So I need to change that.

#

Hopefully without editing the actual package. It seems flexible enough to allow for custom overides.

rustic rain
#

are you using built in controller?

#

or rival?

robust scaffold
#

No, rival

rustic rain
#

you could probably just delete the whole concept of being grounded

robust scaffold
#

I don't want to edit the actual rival package.

#

But yea, I'm gonna try to do something along those lines and see how far I can get.

rustic rain
#

in rival manual

#

it wants you to modify package

#

in order to add features

robust scaffold
#

Problem is maintaining it as dots moves forward and physics might change

#

I don't want to maintain an entire character controller, one that I didn't write myself so I don't know it as well.

rustic rain
#

then I think Rival does not suit you really

#

package is built around the idea of modifying it, so...

robust scaffold
#

But I don't want to write one myself. So I'm gonna work around the existing api

#

One that will enable me to drag and drop any changes coming into the assets folder and not worry about maintaining compatibility with whatever the physics team does

#

Because rival works as I wish it to in 3d, it's just several key assumptions must be injected at the foundations of the asset for it to work in a 2d top down format. 2d sidescrollers are a lot easier than this.

rustic rain
#

could anyone remind me

#

how to select Entity through code?

#

what package

#

do I need to publicize?

#

nvm

#

I think I found it

rotund token
#

is my little wrapper for it to read it

#

seems to be in Unity.Entities.Editor

rustic rain
#

yeah

#

now the problem

#

is that how do I trigger on editor clicking hybrid go

#

I tried this, but no luck

    [InitializeOnLoad]
    public class LinkSelection
    {
        public LinkSelection()
        {
            Selection.selectionChanged += SelectionChanged;
        }

        private void SelectionChanged()
        {
            var selectedLink = Selection.activeGameObject;
            if (selectedLink is not null && selectedLink.TryGetComponent<HybridEntityData>(out var hybridEntityData))
            {
                EntitySelectionProxy.SelectEntity(hybridEntityData.world, hybridEntityData.entity);
            }
        }
    }
rotund token
#
// Selected entities should always try to show up in Runtime mode
                            SelectionBridge.SetSelection(authoringObject, context, DataMode.Runtime);```
if you want it to play nice with data modes
otherwise yeah, EntitySelectionProxy.SelectEntity is fine since it probably doesn't matter
rustic rain
#

oh wait

#

my constructor is wrong ๐Ÿ˜…

#

it's simply not working though

#

seems like nothing changes

#

if I try to click hidden go

late mural
#

is it possible to get access to component data from a monobehaviour? (seems it would be easiest to setup a ui using a monobehaviour)

rustic rain
#

๐Ÿ˜…

late mural
#

ah, what would you recommend then?

rustic rain
#

the most simple way - use Model View Presentation pattern
And just for each presentation (view) create a system

#

access your UI objects from here

#

and manipulate from within system

late mural
#

ok but you cant access ui from components right, unless there is an ecs version of the canvas?

rustic rain
#

this is easiest for small application, but it won't really scale

rustic rain
#

just don't use it in OnCreate

#

because Scene is not loaded

#

yet

late mural
#

ok thanks a ton!

rustic rain
#

How do I specify that system should run in runtime and editor
[WorldSystemFilter(WorldSystemFilterFlags.Editor)]?

rotund token
#

| localsimulation

frigid crypt
#

Can anyone help me understand what is going on here?

#

This issue only appears when I launch standalone build of my game

#

Scene loading works fine in editor

frigid crypt
#

No one has any idea what should I do with it?

rustic rain
frigid crypt
#

Even a scene like that causes problems

#

With or without a subscene

#

And only on a built executable

#

In editor in play mode everything seems to be working fine

rustic rain
#

not scene

tribal pollen
#

@rustic rain what changes do you need in your animators to make them animate as a companion ?

rustic rain
#

at least from the error

rustic rain
#

Animator.Update

tribal pollen
#

Oh, and you put that in a mono on your go prefabs

#

?

rustic rain
#

for now I literally just use companion link hack

#

and then query each animator as component

#

which is extremely slow

#

0.2ms to update 10 super simple animators or smth

frigid crypt
rustic rain
frigid crypt
#

Instead of loading the entire scene I'm just loading the SubScene itself

rustic rain
#

subscene is just a monob that points to serialized entities

#

you can't load it same way as normal scene

frigid crypt
#

Well, it somehow works for me

rustic rain
#

bruh, I hate that hybrid workflow with double prefab

#

I'll stick to companions

#

even though functionality is same, keeping twice as much prefabs for same price is meh

calm edge
#

what is the parallel version of GetComponentLookup?

rustic rain
#

if you want write access and you ensured it's safe

#

there is attribute

#

[DisableParallelWhatever]

calm edge
#

my use case isn't safe thought ๐Ÿ˜†

#

I guess there's not really anything I can do to get around that

rustic rain
#

then you are asking for crashes and corrupted data

calm edge
#

I guess I'll just have to do that bit serially

#

do I need to do something special to destroy an entity with children?

rustic rain
#

well, you need to destroy all children

calm edge
#

is there a proper way of doing that or do I just have to do it manually?

rustic rain
#

nah, people just come up with their own ways

#

Here's one way

        public static NativeArray<Entity> GetAllEntitiesInHierarchy(this BufferLookup<Child> lookup, in Entity parent,
            Allocator allocator = Allocator.Temp)
        {
            var list = new NativeList<Entity>(1, allocator);
            list.Add(parent);
            if (!lookup.HasBuffer(parent))
            {
                return list.AsArray();
            }

            var buffer = lookup[parent];
            foreach (var child in buffer)
            {
                var children = GetAllEntitiesInHierarchy(lookup, child.Value);
                list.AddRange(children);
                children.Dispose();
            }

            return list.AsArray();
        }
#

works with EntityManager too

calm edge
#

if I do CommandBuffer.DestroyEntity(entityIndexInQuery, entity); can I only call that with one entity, or as many as I need?

#

one entity per entityIndexInQuery I mean

rustic rain
#

just look at all available public methods I guess

tribal pollen
# rustic rain you need to update them

I'm feeling pretty dumb, can't even get this 'easy' hack to work >_>
Systems finding animator components and calling update on them (with delta time), but still nothing happens.
If i drag a prefab into the normal scene it does work though.

rustic rain
#

your animator game objects must be saved as prefabs

#

or else Animator Controller will not be serialized

#

it's some kind of glitch I found out yesterday

tribal pollen
#

I think they are prefabs? or do they need to be like an extra one

rustic rain
#

they need to be stored as prefab file

#

I mean

tribal pollen
#

the animators are a component on a prefab which gets baked

tribal pollen
#

@rustic rain both the animator and companion components point to the same item, and if i click it, it can find it....

rustic rain
#

which adds your animator to tick in OnAwake

#

or OnEnable

rustic rain
#

ok, I'm done with Hybrid

#

I just hate it

#

I want to make sprite renderer within entities graphics

misty wedge
#

tell unity to add 2D to entities graphics please

rustic rain
#

I'm trying to learn how to make one

misty wedge
#

Can you use material property blocks in entities graphics?

rustic rain
#

there is material property ovverides

#

but it's funky

#

MaterialPropertyFormat this type does not exist

rotund token
misty wedge
rotund token
#

Sorry srp batcher not batch renderer *

misty wedge
#

How does the batcher replace the need to override material settings

#

(I'm asking since that's all that SpriteRenderer really does)

rotund token
#

Yeah - The rendered object must not use MaterialPropertyBlocks.

#

For srp batcher

misty wedge
#

I know, sprites don't use it either

#

They are already dynamically batched anyways

rotund token
#

You just use different materials with the same Shader

misty wedge
#

Seems kind of weird to have to create an in memory material for each sprite, especially if you aren't using atlasing, but I guess it works

#

I wonder if that will still dynamically batch

#

I'm guessing no, but I've never tried it

rotund token
#

If it has the same compatible Shader and mesh, it should batch

misty wedge
#

The mesh isn't the same though, since it needs to write the sprite atlas UV coordinates into the vertex

#

And it won't be the same anyways if you do something like tight packing

#

(I'm talking about dynamic batching, not the SRP batcher)

#

I've also thought about trying to write something for 2D sprites for graphics, but there's too much I don't know about how unity handles sprites

#

I still have no idea how the sorting groups work for example

#

I hope unity releases something in that direction some time soon, although I doubt it

rotund token
#

so now i'm confused

misty wedge
#

Yep, I'm an idiot ๐Ÿ˜… my bad

#

Then you'll need to create a material per sprite / atlas

misty wedge
rotund token
#

nope

#

though i don't pay much attention to graphics

misty wedge
#

I wish the companion linked object at least had support for more 2D stuff

#

There's no reason for e.g. SortingGroup to be missing from it

safe lintel
#

can I iterate only on all of a chunk's enabled entities or is it strictly a per entity basis?

#

wait maybe need to use entityquery for this

misty wedge
#

If you want the "disabled" entities to not be in that chunk, use a tag component so they are moved

#

How do you even access the companion linked component? It just says SpriteRenderer in the inspector but that of course doesn't implement IComponentData...

#

Or do you need to get the CompanionLink and then call GetComponent on the game object?

tired mulch
#

Does anyone have any tips regarding how one could think when wanting to implement things in a "generic" way in a chunk job for example.

My case in particular is about abilities, and I would like to add different behavior for my different abilities, but process the abilities in the same way. But I'm having a hard time figuring out how I can do that without adding a big switch to check the abilityType in all my systems that do work in the ability ๐Ÿ˜›

#

My OOP brain is having a hard time haha

misty wedge
#

I implemented a prototype for an ability system recently. It is node based though, but does use a switch statement to call the correct code for each node

tired mulch
#

And you can access these nodes in your jobs?

misty wedge
#

Yes

#

The graph is stored in a scriptable object during authoring time, and is then converted to a blob-based representation of the graph for use in bursted jobs

#

A single job then executes all running abilities in parallel

tired mulch
#

Yeah that's the behavior I'm working on. I'll see if I can use the blob asset too

misty wedge
#

The switch statement is kind of annoying, but I'm not sure if there's a good way around it

misty wedge
tired mulch
#

Yeah, I guess the challenge is being able to describe an ability "pattern" with unmanaged types

#

Might end up breaking up my ability system to multiple too to make it a bit easier (buffs vs offensive etc)

misty wedge
#

I went with a graph this time since I hadn't done it before and it makes it possible to design more complicated abilities

#

e.g. something like an If-else node is much easier to parse in a graph than in an array

#

(during authoring)

tired mulch
#

Yeah graphs do sounds like a good thing to use, as it could be used for various things (life-time, acceleration, etc)

misty wedge
#

Yep I plan to (hopefully) reuse the entire authoring part for other graph stuff (e.g. AI)

robust scaffold
misty wedge
tired mulch
misty wedge
#

it's what shadergraph uses

tired mulch
#

I see

robust scaffold
#

Works with sprites both in runtime/play mode and in editor/scene view. With the subscene open and closed. Works with tilemaps and more. Only restriction is that it's entity authoritative. There's no GO -> Entity transform communication.

misty wedge
misty wedge
tired mulch
#

Yeah that's the one I'm watching. I was thinking of trying a method of using curves to define the behavior of my abilities too (slightly more mathematical), but should be able to be represented well in 2d arrays

#

like animation curves but for other types of behavior of an ability as well

misty wedge
robust scaffold
#

Pulled straight from my current project. It has some netcode attributes so just delete them if you're not using netcode.

misty wedge
#

I am ๐Ÿ‘

#

Haha I love this

robust scaffold
misty wedge
#

Now I'm tempted to rename mine to Oven too. Mine are just called Baker sadcat

robust scaffold
#

I started with baker but the autocomplete always mis-selected the proper class name.

misty wedge
#

I only scanned it quickly, is there a reason why the MonoLink isn't the ICleanupComponent?

#

You'd need to check for destruction against something like Simulate though

robust scaffold
#

Ideally you wont be destroying something inside prediction as there's no rolling pack of destruction anyways

misty wedge
#

I mean checking for destroyed by doing WithAll<MonoLink>().WithNone<Simulate>()

#

And having MonoLink be the ICleanupComponent and get rid of TransLink

robust scaffold
#

I mean, yes you can merge translink with monolink...

#

And then track destruction off simulate.

misty wedge
#

(although Simulate should usually be on the entity)

#

Very cool though, thanks for sharing. If 2D support is really that far out I'll experiment with this ๐Ÿ‘

misty wedge
robust scaffold
misty wedge
#

Nobody plays 2D games nowadays anyways...

#

Something I was also wondering when looking at the code @robust scaffold , is it better to use WorldUpdateAllocator instead of Temp when working on the main thread? I've not used WorldUpdateAllocator a lot

#

I guess it will better "preserve" the temp memory pool for use inside jobs? ๐Ÿคทโ€โ™€๏ธ

robust scaffold
robust scaffold
misty wedge
robust scaffold
misty wedge
#

Looking forward to trying this out, since I have a few client side rendering stuff that is "part" of the sprite, but since I currently don't have entities on the client for sprites, it makes reading and writing that data a lot slower than it needs to be

rotund token
#

omg netcode there has to be a way i can tell you to handle this better

#

x512

misty wedge
#

That is code-gened I believe

rotund token
#

this is the codegen result

robust scaffold
#

Composite = true?

rotund token
#

lines of this

misty wedge
#

Epic programmer moment when you crack the 10k lines

robust scaffold
#

isn't there an unsafe utility for change checking?

#

mem compare or something?

rotund token
#

yeah

rotund token
#

hmm didn't change anything

robust scaffold
#

what are you trying to network? FixedList?

rotund token
#

i just want to serialize a 512 KB packet nicely

#

so i'm going to remove all substructs and at a minimum use longs

robust scaffold
#

[GhostField(Composite=true)] did nothing?

rotund token
#

i have it on the serializer template

robust scaffold
#

Try putting it onto the field as well.

rotund token
#

let me restart and force a recodegen

robust scaffold
#

Wait no, this is for specific overrides.

rotund token
#

hmm now it wont even generate into the temp folder

robust scaffold
#

You have to change something inside the component for it to show

rotund token
#

runs fine

robust scaffold
#

a whitespace change is enough

#

noooope

rotund token
#

still the same 11k file

robust scaffold
#

I think you might need to write your own serializer.

rotund token
#

i did

robust scaffold
#

the source gen? Then why would it produce this?

rotund token
#

yes

robust scaffold
#

It should produce whatever you put here and nothing else.

rotund token
#

the actual serializer is just this

#

this whole other part is the has changed

#

load from backup

#

etc

#

part

robust scaffold
#

and still the 11k file? huh

#

try specifying the subtype explicitly?

rotund token
#

i'm not sure what you're expecting? it has no subtypes

#

this is a custom ghost template

#

not a variant / subtype

robust scaffold
#

Is it still generating the 11k lines of change filter? Or have we moved beyond that?

rotund token
#

it is

robust scaffold
robust scaffold
#

Thanks, give me a min

rotund token
#

i basically just need to custom implement these methods

#

since all i did was the serializer/deserializer

#

mimicking the fixedstring implementations

#

oh yeah definitely i see, fixedstring uses 32 as a base and then has overrides on a few methods

robust scaffold
#

using fixedbyte510 because I dont want to make a fixedbyte512

rotund token
#

oh i just did it

#
        public unsafe bool Equals(FixedBytes512 other)
        {
            fixed (void* ptr = &this)
            {
                return UnsafeUtility.MemCmp(ptr, &other, UnsafeUtility.SizeOf<FixedBytes512>()) == 0;
            }
        }```
#

via IEquatable<FixedBytes512>

robust scaffold
#

oh

rotund token
#
        public void CalculateChangeMask(ref Snapshot snapshot, ref Snapshot baseline, uint changeMask)
        {
            #region __GHOST_CALCULATE_CHANGE_MASK_ZERO__
            changeMask = snapshot.__GHOST_FIELD_NAME__.Equals(baseline.__GHOST_FIELD_NAME__) ? 0 : 1u;
            #endregion
            #region __GHOST_CALCULATE_CHANGE_MASK__
            changeMask |= snapshot.__GHOST_FIELD_NAME__.Equals(baseline.__GHOST_FIELD_NAME__) ? 0 : (1u<<__GHOST_MASK_INDEX__);
            #endregion
        }```
robust scaffold
#

huh

#

well, you wouldnt need sizeof fixedbytes512...

#

but I guess that's for future refactoring.

rotund token
#

it's true but i am considering changing the size of this

#

to 256

#

i dont know what packet size i want

robust scaffold
#

Why not sizeof(FixedBytes512)?

rotund token
#

habit

#

though in this case i already chagned it

#
        {
            fixed (void* ptr = &this)
            {
                return UnsafeUtility.MemCmp(ptr, &other, sizeof(FixedBytes512)) == 0;
            }
        }```
#

write after i pasted it

#

^_^'

robust scaffold
#

I've been using sizeof() rather than unsafe utility... ah. Okay. Thought I was doing something wrong

rotund token
#

but i always just use utility

#

as it avoids need of unsafe

#

but i already have unsafe here

robust scaffold
#

I just tack unsafe onto the parent class / struct so I have access to all the pointer goodies.

rotund token
#

all SizeOf is doing is wrapping sizeof()

#

i'm slowly removing pointers from my libraries

robust scaffold
#

I thought SizeOf<> also resolves generic types?

rotund token
#

public static int SizeOf<T>() where T : struct => sizeof (T);

robust scaffold
#

oh wait, regular sizeof can also do so

#

what was that catch with sizeof() instead of marshal.sizeof<>()?

rotund token
#

no idea, what's an efficient way to make a hashcode of this struct

#

i feel like burst has a tool for this

#

oh wait no that was just for hashing a struct

robust scaffold
#

hashwide for the 4x structs.

#

I dont think mathematics has built in md5 generators

rotund token
#
        this.offset0000.GetHashCode(),
        this.offset0016.GetHashCode(),
        this.offset0032.GetHashCode(),
        this.offset0048.GetHashCode()));

hashCode = (hashCode * 397) ^ math.hashwide(new int4(
        this.offset0064.GetHashCode(),
        this.offset0080.GetHashCode(),
        this.offset0096.GetHashCode(),
        this.offset0112.GetHashCode()));

// .. etc

return (int)math.hash(hashCode);```
robust scaffold
#

I guess it works. I would get a pointer to the header byte then cast to a uint4x4 then hashwide a for loop of 512/4/16 (=8).

rotund token
#

C:\dots2\Packages\com.unity.netcode\Runtime\SourceGenerators\Source~\NetCodeSourceGenerator\Generators\NetCodeSourceGenerator.cs(95,1): error NetCode: GHOST_IMPORTS is not a valid fragment for the given template at Unity.NetCode.Generators.GhostCodeGen.GetFragmentTemplate(String fragment)

#

i don't even have GHOST_IMPORTS in my template

#

oh

#

i guess i need it

#

hey file is down to 32KB

#

a nice 559 lines

robust scaffold
#

share for the class?

rotund token
#

the template?

#

sec

robust scaffold
#

the code gen

#

a screenshot of what it looks like

rotund token
#

oh

#

code gen

robust scaffold
#

well, both is good

rotund token
robust scaffold
#

very nice

rotund token
#

let's see if it actually worrks

#

my originally implementation just used a byte dynamic buffer but obviously that's not great

#

hence it was just a quick first pass and i'm trying to properly implement it now

#

hmmmm

#

does not work

#

Failed to decode ghost 473 of type NetworkPacket(4), got 4185 bits, expected 4231 bits

#

what'd i do

robust scaffold
#

What line did that error come from?

rotund token
#

cant tell

#

only getting the sink

#

either going to be 1173 or 1178 ghostreceivesystem

#

wait no thats fine

#

it seems to serialize and deserialize fine

robust scaffold
#

What's the max size of packets again? 4kb might be pushing it. Or there could be plenty of room

rotund token
#

1636 or something like that for unfragmented

#

16kb for fragmented

#

i had no issue pushing this via a 512 length buffer

#

and on my testing i could push up to about 9kb entities

#

before it broke down

#

(it breaks down in transport not in netcode)

#

512 was meant to be way below the limit

#

it is failing though on the writing part though