#archived-dots

1 messages ยท Page 273 of 1

pliant pike
#

the hard part also is figuring out where exactly this correlates to my code

haughty rampart
#

yeah that does not seem to be a lot of vectorized code

#

actually, is that even your code? doesn't seem like it. that's pretty much all from AllocatorManager.cs

pliant pike
#

yeah I think its part of my code its at the top but its not my code

#

like I said its difficult to figure out exactly where my code starts

haughty rampart
#

get to the line where there's a comment that says your c# file name

pliant pike
#

like that?

haughty rampart
#

yeah

pliant pike
#

cool

haughty rampart
#

does look pretty well vectorized

#

what's the issue again?

pliant pike
#

there's lots of nativequeue code like this just below though

#

that seems to be where the most time is spent in my job at least from what the markers indicate

#

there's tons of these yellow nativequeue lines

#

maybe thats the problem, Nativequeue isn't really good for what I want?

haughty rampart
#

what are you trying to do again?

pliant pike
#

its a flow field type pathing system checking for all possible paths within an area

haughty rampart
#

and native queue is used how?

pliant pike
#

I can show you

#
Marker.Begin();
                    while (indicesToCheck.Count > 0)                            
                    {                        
                        CellData curcellDat = indicesToCheck.Dequeue();
                        var deneigbors = GridCellHelperStuff.GetNeighbours(curcellDat.gridIndex, jobflowfieldat.gridSize.y);
                        foreach(int2 neigh in deneigbors)
                        {                            
                            CellData neigborCelldata = new CellData();//CelldataArray[indexneighpos];
                            for(int i = 0; i < PotentialMoveCells.Length; i++)
                            {
                                if(neigh.Equals(PotentialMoveCells[i].gridIndex))
                                {
                                    neigborCelldata = PotentialMoveCells[i];
                                }
                            }
                            if (neigborCelldata.cost == byte.MaxValue)
                                continue;                            
                            if (neigborCelldata.cost + curcellDat.bestCost < neigborCelldata.bestCost)
                            {
                                neigborCelldata.bestCost = (ushort)(neigborCelldata.cost + curcellDat.bestCost);
                                indicesToCheck.Enqueue(neigborCelldata);
                                for (int p = 0; p < PotentialMoveCells.Length; p++)
                                {
                                    if (PotentialMoveCells[p].gridIndex.Equals(neigh))
                                    { indicesToCheck.Enqueue(PotentialMoveCells[p]);
                                        PotentialMoveCells[p] = neigborCelldata;
                                    }
                                }
                            }
                        }  
                    }
                    Marker.End();```
haughty rampart
#

hmmm

pliant pike
#

well from posting that I at least realised one thing leahS I had one to many Enque()s

#

that will probably saves some cycles

karmic basin
#

You mean compared to SystemBase.GetEntityQuery() ? That one is cached.

pliant pike
#

and getting rid of that one Enque() seems to have reduced the time by roughly over 1500ms leahWTF

#

maybe it isn't such a good idea to use an nativequeue

wooden falcon
#

Am I blind or does there not exists something like Mathf.Deg2Rad in the Mathematics package?

haughty rampart
haughty rampart
wooden falcon
#

Ah

#

Thank you

pliant pike
#

yeah maybe its just that expensive, and also it is processing that extra value which is just a waste of time

rustic rain
#

hmmm

#

when I instantiate a prefab

#

I kind of expect it to instantiate children as well

#

but they are not instantiated

#

is that supposed to happen?

#

Entity prefab

covert lagoon
#

I thought I already asked this question before but I can't find it back with Discord's search feature.
When making an open world game with blocky terrain generated at runtime, can I use NavMesh APIs for the AI of hostile creatures who need to follow the players, or do I need to make my own pathfinding and link it to my character input components?

#

Also, here's another question I don't think I've asked before.
With Netcode for Entities, when the server creates an entity with ghost-related components in its server world, does it automatically tell the clients to create them? Either through RPCs, or simply by adding them to the next snapshots it sends (I don't know about their internals).

viral sonnet
#

Is that a generic blobHash deserizalizer?

round narwhal
covert lagoon
#

Keep in mind that this is an open world game

half jay
#

how can i measure cache miss in system? i want to understand if GetSingleton() before scheduling an Entity.Foreach() make missings ?

rustic rain
half jay
#

or may be find some explanation about this. I have a dispute with a colleague about this topic

covert lagoon
#
    [UpdateInGroup(typeof(ClientSimulationSystemGroup))]
    public partial class CollectOwnedPlayerInputSystem : SystemBase
    {
        // ...

        protected override void OnUpdate()
        {
            var ownedPlayer = GetSingleton<CommandTargetComponent>().targetEntity;

            if (ownedPlayer == Entity.Null)
            {
                var commandBuffer = _entityCommandBufferSystem.CreateCommandBuffer();
                var ownedPlayerId = GetSingleton<NetworkIdComponent>().Value;
                var commandTargetEntity = GetSingletonEntity<CommandTargetComponent>();
                Debug.Log("About to run Entities.ForEach");

                Entities
                    .WithAll<PlayerTag>()
                    .WithNone<OwnedPlayerTag>()
                    .ForEach((Entity entity, in GhostOwnerComponent ghostOwner) =>
                    {
                        Debug.Log("About to run Entities.ForEach");

                        if (ghostOwner.NetworkId != ownedPlayerId)
                        {
                            return;
                        }

                        commandBuffer.AddComponent<OwnedPlayerTag>(entity);
                        commandBuffer.SetComponent(commandTargetEntity, new CommandTargetComponent
                        {
                            targetEntity = entity,
                        });
                    })
                    .Run();

                return;

            // ...

Why?

#

There's an entity with a PlayerTag, a GhostOwnerComponent, no OwnedPlayerTag, yet the Entities.ForEach above never runs

rustic rain
#

you have the same log message before loop and in loop

#

is that intended?

covert lagoon
#

No

#
                Debug.Log("About to run Entities.ForEach");

                Entities
                    .WithAll<PlayerTag>()
                    .WithNone<OwnedPlayerTag>()
                    .ForEach((Entity entity, in GhostOwnerComponent ghostOwner) =>
                    {
                        Debug.Log("Running Entities.ForEach");
rustic rain
#

hmmmm, I have a leak somehwere and I can't find where

#

any tip how to find one?

covert lagoon
#

When I enter play mode with "PlayMode Type" set to "Client & Server" in the "Multiplayer PlayMode Tools" window, should I see logs of clients and the server in the console?

#

Are the created clients and servers even separate players? They seem to just be different worlds in the same player

#

If I should see server logs then I guess my server never sets client connections as in-game

drowsy pagoda
rustic rain
#

yeah, that is turned on by default for me

#

I didn't really find it

#

but it was result of switching from End ECB to Begin ECB

#

going back to End fixed leaks

#

but I can't figure out why

drowsy pagoda
#

Hmm

viral sonnet
vocal wing
#

When instatiating a Prefab entity, a copy of the source entity is created with all components (and shared components), minus the Prefab component. It also seems not to copy system state components from the prefab to the new instance. Is this the intended behavior? The docs are not explicit about this.

rotund token
vocal wing
# rustic rain

Ah thanks. I was looking at the ECB.Instantiate docs which is not as verbose.

rustic rain
#

also a tip: to instantiate whole hierarchy you need LinkedEntityGroup buffer component

#

I didn't know that, had to spent some time to figure out xD

vocal wing
#

Yes, thanks this I already knew. ๐Ÿ™‚ I tried to be creative with a system state component on the prefab to save an archetype change on instantiation. Guess that it currently not preventable.

#

But maybe I don't fully understand the archetypes yet, are system state and tag components not part of the archetype?

rustic rain
#

they are

pliant blaze
#

Is there a way to reverse a query and see what component its querying?

rustic rain
cerulean pulsar
cerulean pulsar
void wadi
#

hi guys, i have a NativeList<FindPathJob> findPathJobList = new NativeList<FindPathJob>(); throwing this error : The type 'Pathfinding.FindPathJob' must be valid unmanaged type (simple numeric, 'bool', 'char', 'void', enumeration type or struct type with all fields of unmanaged types at any level of nesting) in order to use it as a type argument for 'T' parameter
the struct is..

    private struct FindPathJob : IJob {

        public int2 gridSize;
        public NativeList<PathNode> pathNodeArray;

        public int2 startPosition;
        public int2 endPosition;

        public Entity entity;

        public void Execute() {...}

does anyone know if there is a workaround so I can force it to allow this 'managed type'?

rotund token
#

you can't have nativecontainers inside other native containers

#

but the better question i have is, why do you have a list of jobs?

viral sonnet
#

I remember the code from yesterday and he's scheduling the list from a job which prompted my question, since when is that possible? on topic of that, I'd also not recommend that. just let the job work on an array.

viral sonnet
void wadi
#

thanks for the tips guys, i just dont know how to apply it, ill keep trying and learning

rotund token
viral sonnet
#

yeah

rotund token
#

i remember trying to do this myself with maths a while ago

#

i could not get it to feel nice

#

so well done as that looks great

#

i just use cinemachine 3rd person camera with a modification to use dots physics because lazy ๐Ÿ˜ฆ

viral sonnet
#

i maintain an asset since 2015. guess cinemachine has come a long way, last I used it (which was some kind of wipeout demo) it still had clipping issues and not many features

void wadi
viral sonnet
#

build all your pathfind elements in an array and after all are gathered, schedule the job once and let it run on an that array.

void wadi
#

ok, I thought that was what the code is doing ๐Ÿ˜‚
for each entity, create a pathfinding job once thats done, run them all

viral sonnet
#

you don't need to schedule a single job for every pathfind request. it's not really how it's supposed to work

rotund token
#

seems to 'predict' the collision instead of going, clonk, ok slide along wall now

viral sonnet
#

yeah it does. started out as simple camera with a smart pivot like wow and then got quite a bunch of features were the most complicated one was the camera offset vector which many 3rd person shooters use. one of the tough things was to still keep the same point in the view because when the camera jumps around while aiming on someone, that's really annoying. ๐Ÿ™‚

#

I was thinking a lot if I should do a DOTS port but then I always concluded that the camera is still managed so there's little use

rustic rain
#

Anyone has any experience with saving?
I'm looking for a way to interface saving my data.

#

I need the most versatile system in this regard as possible

#

but I don't want to add for example interface to all component types that require saving

#

meanwhile also certain components actually mean, that some other component needs to be saved

rotund token
#

For recent save I use [Save] attribute (and [SaveIgnore on fields]) for this

#

at work we just have containers per entity type - so each type of entity gets its own data container which is just what it saves, probably not flexible enough for you though

rustic rain
#

yeah, I am looking at your link in forum

#

as part of inspiration

#

but I'm still not sure if that's the best approach

#

so far I decided that I will save all entities that have PrefabDef class object component

#

which is basically just link to serialized prefab in XML

rotund token
#

if you're writing a definition and attaching it

#

you could just use that to determine components to save

rustic rain
#

yeah, but that would be pretty complex

#

for writing literally everything

rotund token
#

i don't find it as flexible as just generic saving though

rustic rain
#
    <ShipDef>
        <defName>Faster</defName>
        <speed>0,2</speed>
        <rotationSpeed>0,2</rotationSpeed>
    </ShipDef>

    <GraphicDef>
        <defName>CapsuleShip</defName>
        <mesh>Capsule</mesh>
        <material>PlayerWhite</material>
        <children>
            <SphereHead>
                <position>(0;0,57;0)</position>
                <graphicDef>
                    <mesh>Sphere</mesh>
                    <material>Lit</material>
                </graphicDef>
            </SphereHead>
        </children>
    </GraphicDef>

    <PrefabDef>
        <defName>Player</defName>
        <defs>
            <defName>CapsuleShip</defName>
            <defName>Faster</defName>
            <defName>Wanderer</defName>
        </defs>
    </PrefabDef>

    <ComponentDef>
        <defName>Wanderer</defName>
        <enableAI />
        <addRandom />
        <comp>WanderingAI</comp>
    </ComponentDef>
#

here example of how I managed to make it work

#

GraphicDef is transform + RenderMesh hierarchy

rotund token
#

i am slightly concerned about your performance though if you need to scale really large

rustic rain
#

ShipDef is unique def that adds unique set of components

rotund token
#

like my approach, i can save 250,000 entities with hierarchies in < 20ms

rustic rain
#

ComponentDef adds tags by name

rotund token
#

and deserialize in ~30 (of which 20ms is entity instantiate which i cant avoid)

rustic rain
#

and PrefabDef actually creates entity prefabs

rustic rain
rotund token
#

but if you dont care about a) that crazy entity count or b) just hiding it behind load screens etc then its fine

#

flexibility for your game would be more important

rustic rain
#

yeah, versatility is key

#

since my biggest goal - maximum moddability

#

so anyone can inject their own dll with their own components, which will also be saved in simple way for modder

#

so far I see such options:

  1. I create special method in IDef and during save load, it'll assign/read all components
#
        public void SetUpPrefab(Entity e, EntityManager em)
        {
            foreach (var def in _defs)
            {
                def.SetUpPrefab(e, em);
            }

kind of like this

#

but with actually restored entities

#

but I find this option troubling, because that would mean I'll need not only to define this method for all defs

#

but also if for example X def needs saving of Translation + Rotation and Y def needs saving of Translation - I'll get duplicates

#
  1. I could try adding attributes, in which I could also link other component that needs saving for that component
    But that would somewhat break ECS approach of data oriented
    And also I won't be able to do that with translation, rotation and etc
molten flame
rotund token
#

when i go work on it again >_>

#

thought of doing some documentation and trying to setup some samples for testing

#

and noped out of there

#

tbh been too drained from work recently to actually do much of my own stuff ๐Ÿ˜ฆ

rustic rain
#

bruuuuuh, I still couldn't figure out how to do saving

rustic rain
#

Is there a way to get untyped object of IComponentData?

haughty rampart
#

object ?

rustic rain
#

Anything that can be serialized

haughty rampart
#

no i mean object

rustic rain
#

or maybe get ready string

#

which can later be transformed back into IComponentData of ComponentType

rotund token
#

DynamicComponentTypeHandle

rustic rain
#

but doesn't it require chunk to operate with?

rotund token
#

well that's where IComponentData live

#

if you're using IComponentData, you're (in)directly using chunks

rustic rain
#

yeah, but I meant I need this just for 1 entity

#

allthough later maybe I can try to go into per chunk base

#

For now I basically have list of ComponentType and I need to figure out how to get serialized data from them

#

I am looking into it, but I just don't get it where is magic

#

how would you determine ElementSize

rotund token
#

TypeInfo.ElementSize

#

var typeInfo = TypeManager.GetTypeInfo(typeIndex);
var elementSize = typeInfo.ElementSize;

rustic rain
#

hmm, I see

#

but that would give me what exactly?

#

this GetDynamicArray

#

array of whole chunk?

rotund token
#

an array of each element yes

#

you should be doing this per chunk - every chunk will be the same archetype so they should all be saved

rustic rain
#

I just struggle to imagine how it's done

#

also, this gives unreadable result basically

#

I would prefer editable through hand result

rotund token
#

yeah gl with that ๐Ÿ˜ฌ

#

you're going to have to do a few things entities was not designed for

rustic rain
#

I assume it's simply impossible to get component without knowing type before compilation?

#

unless ofc it's byte array

rotund token
#

what you probably want is

#

byte* ptr = EntityComponentStore->GetComponentDataWithTypeRO(entity, typeIndex);

#

and then convert ptr with
UnsafeUtility.CopyPtrToStructure<T>(ptr, out T value);

rustic rain
#

and if T is unknown?

#

I only have Type

rotund token
#

if T is unknown then you have a ptr

#

that's it

rustic rain
#

soooo, I can't serialize it

#

without Unity's intended way

rotund token
#

well i'd argue serialization is the conversion of data to a byte array

rustic rain
#

yeah, but with pointer I'm not sure how I can get

#

oooh

#

wait a second

#

Does ComponentType contain this kind of information?

rotund token
#

yes

#

you can get elementsize

#

and everything from TypeInfo

rustic rain
#

so, what is my best shot?
What kind of data type in the end?

#

byte[] or?

rotund token
#

it's already stored as a byte array

#

it's actually what made serializing entities so easy for me

#

didn't have to do anything

#

being unmanaged it's already in the format you need to write

#

now being readable that's a whole different problem

rustic rain
#

I'm ok with it being unreadable as long as I can simply read it back xD

#

EntityComponentStore where do I get this?

#

chunk?

#

hmm, nope

rotund token
#

it's inside entity manager

#

it is not public

rustic rain
#

oh

molten flame
rustic rain
#

hmmm

#

ISharedComponent can't nullable

#

that is sad

#

@rotund token sir, could you show how you desserialize that chunk data?

rotund token
#

i just do the opposite of how i wrote it

rustic rain
#

I get it conceptually, but I have no idea what kind of methods you even use

rotund token
#
                {
                    var headerChunk = this.Deserializer.Read<HeaderChunk>();
                    var entities = this.Deserializer.ReadBuffer<int>(headerChunk.Length);
                    var components = this.Deserializer.ReadBuffer<byte>(headerChunk.Length * header.ElementSize);

                    for (var i = 0; i < headerChunk.Length; i++)
                    {
                        if (this.Remap.TryGetEntity(entities[i], out var entity))
                        {
                            this.SerializedData.Add(entity, (IntPtr)(components + (i * header.ElementSize)));
                        }
                        else
                        {
                            Debug.LogError($"Entity {entities[i]} wasn't found");
                        }
                    }

                    index += headerChunk.Length;
                }```
#

oh you're more interesting in writing the data back?

rustic rain
#

I'm interesting in everything

rotund token
#
                if (components.Length == 0)
                {
                    return;
                }

                var entities = batchInChunk.GetNativeArray(this.EntityType);

                for (var i = 0; i < entities.Length; i++)
                {
                    var entity = entities[i];

                    if (!this.SerializedData.TryGetValue(entity, out var srcStart))
                    {
                        continue;
                    }

                    var dst = (byte*)components.GetUnsafePtr() + (i * this.ElementSize);
                    var src = (byte*)srcStart.ToPointer();

                    foreach (var element in this.SaveChunks)
                    {
                        UnsafeUtility.MemCpy(dst + element.Index, src + element.Index, element.Length);
                    }

                    foreach (var offset in this.EntityOffsets)
                    {
                        RemapEntityField(dst, offset, this.Remap);
                    }
                }```
i just loop all entities and see if they were saved
rustic rain
#

I'm trying to replicate this method, but so far very little progress

#

MemCpy ๐Ÿ™ƒ

rotund token
#

doesn't have to be used

rustic rain
#

it's fine, I get how it works

#

just scary

rotund token
#

could do a UnsafeUtility.AsRef and just write it as a component if you were doing it generic or something

rustic rain
#

kek

rotund token
#

but that code above

#

is, apart from job boilerplate

#

the entire code in my deserialization for componentdata

#

i have similar code for buffers

#

and then a small chunk to instantiate the prefabs

#

and that's basically my entire system

#

the rest is just features

rustic rain
#

hmm

#

That made super confused

#

this.Serializer.AddBufferNoResize(components);
so that gives you NativeArray in some sort of list

#

I assume it's managed one?

rotund token
#

Serializer is just a wrapper for NativeList

#
    {
        private NativeList<byte> data;```
#

like literally

rustic rain
#

ah

rotund token
#

it just handles all the T to byte conversions

rustic rain
#

wait a second, then how do you later serialize that data

rotund token
#

a list of bytes

#

is already serialized

#

that is my serialized data

rustic rain
#

ah yes

rotund token
#

i compress it and then write it to disk

rustic rain
#

How do you link it to entities? chunks or whatever?

rotund token
#

effectively I write
key[]
component[]

#

where key is just entity.index

#

that is what i use as my unique key

rustic rain
#

yeah, but in the end all you have is byte array

#

out of where can I get keys for them?

rotund token
#

if you notice the above code

#

var headerChunk = this.Deserializer.Read<HeaderChunk>();

#

i write a small header for each chunk

#

which is basically just Length

#

i.e. number of elements in this chunk

rustic rain
#

that byte array contains data other than componenets?

rotund token
#

so my final format looks like
int Length
int[] Keys
T[] Components

rotund token
#

thats per chunk

#

but there are multiple chunks per component right

#

so i have a component header

#

which is number of chunks, component type, saved component size (in case it has changed for migration) etc

#

then i have a header above this for number of components saved, type of compression etc

rustic rain
#

no I mean

#

how do you link that byte array

#

that's the part I don't get

#

that's all I have rn and I'm super confused

rotund token
#

whole thing is in my above code

#

deserializing is slower because i read everything back 1 at a time

#

to validate it etc

#

when i load i create all entities i need to deserialize onto

#

store it in a hashmap<int, Entity>

#

where int was the saved entity index, Entity is the new Entity

#

then to deserialize basically i just loop both arrays (key, value) and check if the entity exists then store the data for it in a hashmap

rustic rain
rotund token
#

that's the 'apply' step

#

first code was deserializing

#

and storing the valid data into a hashmap

#

the second step was applying which is just literally looping every entity in the world and checking if they have data that was saved

#

and if so write it

rustic rain
#

wait a minute

#

so this byte array that you get from chunk

#

it contains entity array as well?

rotund token
#

I get the entity array from the chunk as well

#

Using entity type handle

rustic rain
#

it slowly starts to make sense

#

so you made a struct which contains type/length, entitty (index) array and component (byte) array

rotund token
#

Well I don't make a struct, I just directly write them to my stream

#

But yeah

#

Past bedtime, need to sleep

#

Hopefully that helped

rustic rain
#

Yeah, thanks

viral sonnet
#

@rustic rain why XML instead of json?

rustic rain
#

attributes

#

names

#

just easier to write

#

I'll do saving in Json though xD

#

Only parsing XML is easy

#

writing is pepega

viral sonnet
#

I dunno, json reading and writing is like one line of code with a strongly typed model. also json is faster than xml

rustic rain
#

json has no built in attributes support

viral sonnet
#

I didn't see any attributes in your xml ๐Ÿ™‚ eh, if you like it more power to ya. i stopped writing xml parsers like 10 years ago in favor of json

rustic rain
#

well, it's probably just bias

#

cause I used to write XML in my first game

#

kek

viral sonnet
rustic rain
#

and Json didn't look good at all in it

covert lagoon
#

Should my non-Burst-compiled code use the Entities API's Method(typeof(T)) methods or Method<T>() methods when both can be used?

rustic rain
#

Method<T>() is probably better

covert lagoon
#

As far as I know, Burst doesn't support RTTI or whatever it's called in C#, so I can't use typeof(T) in Burst code

viral sonnet
#

it's just syntactic sugar

#

eh scrap that, if you need the type it's very different things

#

I would be surprised if burst doesn't support it. as long as T is unmanaged/struct it should work

#

both of these codes do very different things though. one gets the type as variable. the other is compiled with the types you actually use it for

covert lagoon
#

It's basically dynamic vs static dispatch, isn't it

#

๐Ÿค”

        public static int GetTypeIndex<T>()
        {
            var index = SharedTypeIndex<T>.Ref.Data;

            if (index <= 0)
            {
                ManagedException<T>();
                BurstException<T>();
            }

            return index;
        }

        public static int GetTypeIndex(Type type)
        {
            var index = FindTypeIndex(type);

            if (index == -1)
                ManagedException(type);

            return index;
        }
viral sonnet
covert lagoon
#

I did

viral sonnet
#

oh, this is not DOTS netcode?

covert lagoon
#

I think it's DOTS Netcode ported to GameObject-based development

#

Actually nvm

#

It's more a port of the concepts/architecture than of the code

#

I think

viral sonnet
#

yeah, seems it has nothing to do with burst/entities. man, I don't like codenames but having the same names for very different projects is even more annoying

covert lagoon
#

They're not entirely the same names

#

"Netcode for Entities" (previously "Unity NetCode") vs. "Netcode for GameObjects"

viral sonnet
#

ah they did rename it, I can only see "Netcode for Entities" in google ๐Ÿ˜„ well the problem I have is that it's still unity.netcode and the go one uses unity.netcode.gameobjcts which imples to me that gameobjects is built on unity.netcode. kind of confusing but if you know, you know

karmic basin
#

Nothing to do with DOTS

#

it's the new name for unity MLAPI

#

100% gameobjects

#

I agree very confusing naming ๐Ÿ˜›

rustic rain
rustic rain
#

var components = this.Deserializer.ReadBuffer<byte>(headerChunk.Length * header.ElementSize);
What is this type?

covert lagoon
#

Why does my server build log these errors (besides using the null graphics device)? Are shaders included in my server build?

ERROR: Shader HDRP/Lit shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/DebugLightVolumes shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/CameraMotionVectors shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/GGXConvolve shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/CharlieConvolve shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/OpaqueAtmosphericScattering shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/CustomPassRenderersUtils shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/HDRP/FinalPass shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Hidden/PostProcessing/SubpixelMorphologicalAntialiasing shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Sprites/Default shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
ERROR: Shader Sprites/Mask shader is not supported on this GPU (none of subshaders/fallbacks are suitable)
#

I have these components in my server build configuration

#

Not sure what I should have

#

Not sure if it's normal that Unity warns me that the "Net Code Conversion Settings" component is "not used by the build pipeline"

#

If you want to build a standalone player for the project you must create a BuildConfiguration - the regular build menu in Unity will not work.
The Netcode for Entities manual could be more helpful than that

#

It looks like the only place where the NetCodeConversionSettings build configuration component is used is here, in com.unity.netcode@0.50.1-preview.19/Runtime/Authoring/Hybrid/GhostAuthoringConversion.cs:

        private static NetcodeConversionTarget GetConversionTarget(GameObjectConversionSystem system, bool isPrefab)
        {
            // Detect target using build settings (This is used from sub scenes)
#if UNITY_EDITOR
            if (system.TryGetBuildConfigurationComponent<NetCodeConversionSettings>(out var settings))
            {
                //Debug.LogWarning("BuildSettings conversion for: " + settings.Target);
                return settings.Target;
            }
#endif
            // Prefabs are always converted as client and server when using convert to entity since they need to have a single blob asset
            if (!isPrefab)
            {
                if (system.DstEntityManager.World.GetExistingSystem<ClientSimulationSystemGroup>() != null)
                    return NetcodeConversionTarget.Client;
                if (system.DstEntityManager.World.GetExistingSystem<ServerSimulationSystemGroup>() != null)
                    return NetcodeConversionTarget.Server;
            }

            return NetcodeConversionTarget.ClientAndServer;
        }
covert lagoon
#

What's the point of BeginSimulationEntityCommandBufferSystem?

rustic rain
covert lagoon
#

So 2 sets of structural changes per update cycle?

rustic rain
#

as many as you want actually

#

fixed group also has 2

covert lagoon
#

Netcode for Entities's CommandSendSystemGroup is part of the GhostSimulationSystemGroup which is part of the ClientSimulationSystemGroup

#

It would make sense for my system that collects player input on clients to run before the GhostSimulationSystemGroup so that the client doesn't wait for the next frame to send the collected input

#

This system gets the owned player from GetSingleton<CommandTargetComponent>().targetEntity

#

If it's set to Entity.Null, it tries to find a ghost player owned by the client, gives it a PlayerInput buffer, and sets GetSingleton<CommandTargetComponent>().targetEntity

#

This is done in Entities.ForEach using an entity command buffer

#

Then it returns so input collection is skipped for the current frame

#

But for when it does not return early because the owned player is found and so the input is collected, I want the system to run before the GhostSimulationSystemGroup

#

The system currently uses EndSimulationEntityCommandBufferSystem

#

Should the system switch to using BeginSimulationEntityCommandBufferSystem or not

#

I can't talk

#

What the fuck

#

The words don't come out

#

Nevermind

#

Ok I think I should use BeginSimulationEntityCommandBufferSystem by default and use EndSimulationEntityCommandBufferSystem when I don't want the changes to go unnoticed by the PresentationSystemGroup until the next frame

viral sonnet
#

I read some logic for Begin and End to destroy entities but I forgot ๐Ÿ™‚ Maybe someone else remembers. solved some possible issues

covert lagoon
#

Not sure if this means anything by itself

$ cd Library/PackageCache
$ rg -g '!*{Documentation,Test}*' BeginSimulationEntityCommandBufferSystem | wc -l
46
$ rg -g '!*{Documentation,Test}*' EndSimulationEntityCommandBufferSystem | wc -l
13
#
$ rg -lg '*/Runtime/**' BeginSimulationEntityCommandBufferSystem
com.unity.netcode@0.50.1-preview.19/Runtime/ClientServerWorld/ClientServerWorldAllocatorResetSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Rpc/RpcCommandRequest.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostSendSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/PredictedGhostSpawnSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostReceiveSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostDespawnSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/NetDebugSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Rpc/RpcSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/Prespawn/PrespawnGhostInitializationSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostSimulationSystemGroup.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Connection/NetworkStreamReceiveSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/Prespawn/ServerTrackLoadedPrespawnSections.cs
com.unity.netcode@0.50.1-preview.19/Runtime/NetCodeDebugConfig.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/Prespawn/ClientPopulatePrespawnedGhostsSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Connection/NetworkStreamCloseSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Connection/HeartbeatSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/Prespawn/ServerPopulatePrespawnedGhosts.cs
#
$ rg -lg '*/Runtime/**' EndSimulationEntityCommandBufferSystem
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/Prespawn/AutoTrackPrespawnSection.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/SwitchPredictionSmoothingSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostDistancePartitioningSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Snapshot/GhostSendSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Rpc/RpcSystem.cs
com.unity.netcode@0.50.1-preview.19/Runtime/Rpc/RpcCommandRequest.cs
#

Netcode for Entities prefers BeginSimulationEntityCommandBufferSystem

woeful comet
#

Does anyone know if there's some way to update a RenderMesh's mesh from within a job?

#

I vaguely remember that there was an API for this, but I can't seem to find it now.

rotund token
#

you can get the nativearrays from a mesh and manipulate that

#

technically you can actually get shared components in a job when you're not in burst (and I even wrote a SharedComponentDataFromEntity container for this)

#

but you're going down a pretty rocky road if you do this

woeful comet
#

Thanks, what's the API for getting the NativeArrays from the mesh? I don't see an obvious way to do it.

#

I'd like to keep things bursted if possible.

rotund token
#

Sorry I meant there are overrides for writing to a mesh from native array*

#

SetVerticies, SetUVs, SetIndices etc all have native array overrides

woeful comet
#

Ah okay, so does that mean I have to calculate the mesh in a job (which I'm doing now), and set it on the main thread?

rotund token
#

yes unfortunately you need to write the final mesh on main thread, however you can speed this up a bit with MeshData

woeful comet
#

Thanks very much, I'll give that a try. ๐Ÿ™‚

rotund token
#

it lets you write all the verts etc to the mesh in a job

#

but you still need to call
Mesh.ApplyAndDisposeWritableMeshData(dataArray, mesh);

#

to finalize it on the main thread at some point

woeful comet
#

Ah, it was the MeshData API that I heard of before but couldn't find again.

#

Thanks again for the help.

hot basin
#

can i get array of values from NativeMultiHashMap?

#

is there a better way to have array of values per Key?

#

in my case Entity is the Key and I need array of floats

#

if that helps

rotund token
#

if you want an array you'll just have to iterate it and populate it yourself

hot basin
#

ok

#

can I assume same index per value?

rotund token
#

sorry not sure what you mean

hot basin
#

when I put the values in order

#

would I get the same order while reading?

#

or reversed

#

or it would be random

rotund token
#

you mean put values into hashmap

#

you should consider order random for a hashmap

#

if you dont remove an element then i believe it'll be reversed

#

but you shouldn't rely on this behaviour

hot basin
#

so Can I store values in something else to preserve order?

rotund token
#

a list? ๐Ÿ˜„ (nativestream?)

#

get enzis parallel block list

heady edge
#

Hello all it's been a long time since I played around with dots and slowly getting back just for the fun of it.
I remember that [BurstCompile] attribute applied to static function actually caused the burst to compile it. is it still the case?
If so is there a reason why those functions don't show up in burst inspector?

hot basin
#

wtf lately I figured out that NativeStream is best container ever

rotund token
hot basin
#

I mean it's just so versatile

viral sonnet
#

neat little trick for entity as key is to just use an int as key type and the index, saves one integer, the version.

#

nativestream is great for that, especially when it operates on the same query, then the data is ordered and you don't even need to index really

#

would require that every entity has the same amount of data though, otherwise it'll misalign

#

I've also tried indexing entities myself for when another query needs it. i've mostly found better solution for this. it's quite fast to do and can come in handy

hot basin
#

can I get index of entity in IJobEntityBatch?

#

for stream writing

rotund token
#

IJobEntityBatchWithIndex

viral sonnet
#

nativestream has the restriction that you can't write to the same index due to the memory block design and there's no good way around it (which is usually fine when the chunkIndex or entityIndex is used) for non-linear writes this could be interesting and I think I can make this work with the parallel list

#

parallelParallelList? ๐Ÿ˜„

#

could be a huge save when I manage to apply this to some of my code paths and I don't need to write out arrays and make a hashmap ๐Ÿค”

molten flame
#

Now that AddHybridComponent is gone, how are we meant to do hybrid things?

rustic rain
rotund token
#

oh

#

that you can probably ignore

#

that is for my [SaveIgnore]

rustic rain
#

how do I copy data though?

#

I am at a point when I restored entities, restored map

rotund token
#

UnsafeUtility.MemCpy(dst, src, ComponentLength);

#

is all you need

rustic rain
#

but saved data is in byte arrays

#

hm, I tried that

rotund token
#

thats what it simplifies to if there is no [SaveIgnore]

rustic rain
#

hold on, unity is opening

#

also, what is

#

SerializedData

#

is that (Entity, IntPtr) dictionary?

rustic rain
#

I don't really get, what is it

rotund token
#

<Entity, IntPtr>

#

this.Deserializer is just the opposite of Serializer (except just a native array)

#

it just holds the byte array

rustic rain
#
 foreach (var type in _typesToSaveWrite)
            {
                var elementSize = TypeManager.GetTypeInfo(type.TypeIndex).ElementSize;
                var dynamicHandle = GetDynamicComponentTypeHandle(type);
                foreach (var chunk in chunks)
                {
                    var components =
                        chunk.GetDynamicComponentDataArrayReinterpret<byte>(dynamicHandle, elementSize);
                    if (components.Length == 0)
                    {
                        continue;
                    }

                    var entities = chunk.GetNativeArray(entityHandle);

                    for (int i = 0; i < entities.Length; i++)
                    {
                        var e = entities[i];
                        if (!componentPtrMap.TryGetValue(e, out var srcStart))
                        {
                            continue;
                        }

                        var dst = (byte*)components.GetUnsafePtr() + (i + elementSize);
                        var src = (byte*)srcStart.ToPointer();

                        UnsafeUtility.MemCpy(dst, src, elementSize);
                    }
                }
            }
#

here's what I did

#

and that seems not to work

#

no errors, but entity position is not restored

#

and always defaults

rotund token
#

is it running the actual memcpy

#

because it looks fine i think

#

this is wrong
var dst = (byte*)components.GetUnsafePtr() + (i + elementSize);

#

needs to multiply
var dst = (byte*)components.GetUnsafePtr() + (i * elementSize);

rustic rain
#
                foreach (var savedChunk in savedType.chunks)
                {
                    var legnth = savedChunk.entities.Length;
                    var entities = savedChunk.entities;
                    var components = new NativeArray<byte>(savedChunk.dataArray, Allocator.Temp);
                    var compsPtr = (IntPtr)components.GetUnsafeReadOnlyPtr();

                    for (int i = 0; i < savedChunk.entityCount; i++)
                    {
                        if (remap.TryGetValue(entities[i], out var entity))
                        {
                            componentPtrMap.Add(entity, (IntPtr)(compsPtr + (i * savedType.elementSize)));
                        }
                    }
                }

Here how I create source pointer

#

what about getting pointer?

#

One remark, I serialize to managed byte array

#

and then recreate NativeArray from it

#

is that ok?

#

ooooh, ok

#

now that I swapped + to * it works

#

hmmm, now gotta figure out that thing for sharedcomponents

#

allthough, it's just integer

rustic rain
#

Any idea what is faster?
EntityManager's GetComponentData or GetSharedComponentData?

#

both are just integer wrappers

proper charm
#

Hi there,
How can I get started with Unity Dots?

rustic rain
proper charm
#

Can I use unity dots with my individual free license of unity?

rustic rain
#

this is for ECS tho

proper charm
rustic rain
#

smth way more fun than OOP

#

you don't have to use ECS for dots tho

#

there are also jobs and burst

proper charm
#

Is it worth to get into dots for an indie solo developer?

#

or should I continue with the native one?

rotund token
#

i'd say most (not all) are indie developers in here

#

depends entirely what your objectives are

#

and how much you enjoy coding vs making games

rustic rain
proper charm
rustic rain
#

nah, it's more about

#

what kind of game do you have in mind

#

if it's some kind of large simulation

proper charm
#

Multiplayer war game

rustic rain
#

with a lot of comutations

#

ECS might be the perfect one

proper charm
#

and also a simulative game of a city builder

rustic rain
#

but it's still alpha, so you'll have to create everything by yourself from scratch (almost)

#

city builder sounds good for ECS I think

rotund token
#

a lot of people who currently use dots do so because they like spending hours optimizing and getting the most
as it is still a preview, it currently does not have the same tools and usability as regular unity so if you're unfamiliar and new to it, it might take a lot longer to build your game.

#

hence i ask if building games or coding is your focus

proper charm
rustic rain
#

render pipeline is not really related to dots

#

you'll have to use either urp or hdrp with dots ecs after all

proper charm
rustic rain
#

anyways, I suggest just to try and read manual

#

it'll give you concept ideas

#

what ECS in Unity is about

proper charm
rustic rain
#

hmm, any idea how can I make some sort of message system for ECS?
Basically I have certain systems, that have public methods that are widely used by other systems. Can't avoid that.
What I'd want - make it so there's a way to call it as simple as CurrentWorld.CallXMethod
Instead of having to save those systems as fields in every other system

rustic rain
#

some kind of Buffer could do the job, without structural changes

#

my point stays though
If you have a lot of things to instantiate, enqueue or etc
Using entities/adding components for that would not be great for perfomance

#

Collision system is using buffers

#

For example

rotund token
#

dont get tricked, performance is relative

#

some of the people writing these systems are testing on 250k entities

#

most games are going to have 1/1000th of that

hot basin
#

Do I remember correctly that enabled/disabled components will be part of 1.0

#

Or at least that's the plan for now

rotund token
#

yes

#

(I think people have overhyped these in their minds though)

rustic rain
#

I'm kind of used to not having them already xD

#

What I can't wait for: getting rid of RenderMesh components

#

some dev said they will use smth else

rotund token
#

you'll have to pre-register all your meshes with the hybrid renderer

rustic rain
#

it's fiiine

#

For now I use resources

#

later I might figure out smth else

rotund token
#

how is this going to benefit you though?

#

(just curious)

rustic rain
#

Versatility

#

ability for modders to have simple access to all these tools

rotund token
#

im not really understanding how that will change

hot basin
rotund token
#

i believe so

hot basin
#

oh I get it now

#

they showed us the tech

#

here

rotund token
#

yeah

#

This means that you can't directly reference objects such as instances of Mesh and Material, and instead, you need to register them with the BRG before you use them

#

this is why i'm asking because if anything, I feel like this would make it harder for modders.

hot basin
#

why would it?

rotund token
#

now we dont know how they will set it up

#

but imagine you have to be setup via a subscene or something on game launch - this is unlikely but i'm just pointing out how a certain work flow could make it worse

hot basin
#

you can dynamically load meshes at startup and register them

#

I assume there will be such possibility

rotund token
#

but either way, i'm not exactly seeing why it would be better

#

hence curiosity

hot basin
#

in my solution I don't have any mesh/material on my entities so there is no managed components

#

only tag component identyfing how should I render this

#

of course it strategy game

#

so I can assume few things

rotund token
#

that's much more ideal because it means you can easily strip rendering from servers for client/server games

rustic rain
#

it works, just not everywhere

hot basin
rotund token
#

im not saying there is a problem

hot basin
rotund token
#

im just trying to figure out why its better for modders

#

which was issues claim

rustic rain
#

what

#

what is better?

rotund token
rustic rain
#

oh, I didn't really mean it about pre-registering

#

allthough

#

registering meshes and materials

#

sounds like interesting idea

rotund token
#

1.0 going to break all our projects ๐Ÿ˜„

rustic rain
#

it's fine

#

it's half broken anyway

#

build won't even run

#

because it crashes

#

xD

rotund token
#

maybe you should fix it ๐Ÿ˜›

hot basin
#

yeah for now I'm still waiting for 0.51 ๐Ÿ˜›

#

but I think I'd welcome changes in 1.0

rustic rain
#

I just don't see any solution

#

because all stack trace is going towards Unity TRS system

rotund token
#

interesting

#

i wonder what you're doing wrong

#

havent seen an issue in there in a long time

#

changing parents?

rustic rain
#

hm

#

yeah

#

What could go wrong with it?

#

rn afaik I simply assign Parent component

rotund token
#

only time i've ever seen people have issue with TRS is them doing parenting

hot basin
#

Don't you need to change LocalToParent also?

rotund token
#

i think it happens when you change parents in same frame or something

#

and the PreviousParent system state hasn't had a time to cleanup or something

#

never had the issue myself, just seen it rarely reported

#

basically something like reparenting causes issues

rustic rain
#

Transform group

#

is under tick simulation

#

which has ECB on start/end

hot basin
#

is IJobEntityBatchWithIndex with ComponentTypeHandle<> better than IJobParallelFor with Query.ToComponentDataArray<>?

rotund token
#

yes

rustic rain
rotund token
#

Query.ToComponentDataArray<>
is just doing a batch iterate and copying it to array

hot basin
rustic rain
#

IJobEntityBatch is giving you batchInChunk

#

from which you take componentData

#

vs you get Array from whole query

#

smaller array -> smaller cache miss

hot basin
#

but then I use the whole array so where are those misses?

rustic rain
#

no idea, how that low level stuff works

hot basin
#

so anyway

#

Can I assume that if I use data from entity it's always better to use IJobEntityBatch?

#

or .ForEach() if it's enough

rotund token
#

in 98.7% of cases yes

pulsar jay
#

Do you guys prefer methods in component structs, extension methods or some other way for functionality that is related to a component and should be reusable and why?

rustic rain
woeful comet
#

There's nothing about reusable logic that goes against DOD. It's just good software engineering practice.

rustic rain
woeful comet
#

If they modify the struct, then yeah, but static methods are a good way to organize code.

rustic rain
#

yeah, I use static Method(this T kek) for such cases

#

helps with organisation as well

woeful comet
#

Yeah, that's the best way to go IMO.

#

No reason to have files full of free functions IMO. We're not programming in C any more.

pulsar jay
#

Its still technically part of the struct as it "extends" it ๐Ÿค”

rustic rain
#

well, for one
Component structs usually is just data, that can be accessed from any sort of system

#

so by putting any logic in separate class

#

you follow DOD design

#

avoid clutter

#

nothing stops you from having methods in structs though

#

if it's specific struct that was designed by you for it

#

why not?

woeful comet
#

If a function applies to a specific struct, it should live with that struct.

pulsar jay
#

The advantage of the extension methods could be that you can have multiple files extending the struct. So you can have Assembiles that add the extension methods that are used by that assembly for that component

#

@rustic rain do you have any kind of naming convention for your extension classes?

rustic rain
#

VectorUtility
MathUtility
PepegaUtility

#

xD

#

nothing fancy

#

if it's system specific

#

hmm

#

I haven't had such case yet

#

kind of tend to have such methods as generic as possible

pliant pike
#

I have weird problem where a job seems to be taking excessively long I'm not sure what's the problem or how to solve

#

when searching an 18 by 18 grid it takes roughly 101ms, whereas at a 20 by 20 grid it takes 610ms

rustic rain
#

is burst on?

pliant pike
#

yep

rustic rain
#

how many if do you have in job?

pulsar jay
#

Thx for the input @rustic rain and @woeful comet. Will keep that in mind

pliant pike
#

4 ifs

rustic rain
#

can you bring it down to 0?

pliant pike
#

I'm not sure how leahWTF

rustic rain
#

anyways, what I mean is that

#

if statements break vectorisation

pliant pike
#

its weird at lower values the time it takes doubles each time(which seems normal)when the grid gets one bigger but at the 10 value it gets inordinately longer

rustic rain
#

have you thought of implementing quadrants?

pliant pike
#

I kind of do have a rough sort of that thing, it exits early when its searched usually less than half of the grid

rustic rain
#

maybe try brute force?

pliant pike
#

the job was roughly 2000ms at 20 by 20 now its down to 600ms

rustic rain
#

no early returns and etc

#

literally go through all data

#

and only then return correct result

pliant pike
#

gotta see if I can get it down further

rustic rain
#

that potentially will let you lift some ifs

#

and you might get truly bursted code

covert lagoon
#

Why does Rider tell me that the partial keyword is redundant when it knows that the class is a Unity ECS system

pliant pike
#

I am kind of brute forcing, but will see if I can get rid of some of the ifs, thanks

rustic rain
#

I never used it myself

#

but it shows that burst code gen

rotund token
rustic rain
#

in which you might get an idea whether result code is good or nah

pliant pike
#

you mean the burst inspector

rustic rain
#

yeah

#

I never used it myself yet xD

pliant pike
#

yeah that stuff is really hard to read leahS

covert lagoon
#

And in Unity I have the "JetBrains Rider Editor" version 3.0.14 package installed

#

It's the latest version

civic shard
#

So uh, there have been whispers that Unity dots helps with large entity counts, is this true?

rustic rain
#

hundred thousands entities and etc

civic shard
#

Does it work in 2D?

rustic rain
#

it's literally just engine

#

you can do anything with it

civic shard
#

Can you recommend a starting point video?

split cedar
rustic rain
#

maybe one day...

split cedar
#

if you solve them one day... you gotta tell me first before you publish it ๐Ÿ˜‰

carmine plover
#

Anyone know if PUN/Photon will work with entities/DOTS?

haughty rampart
carmine plover
#

Is DOTSNET the best option then?

haughty rampart
#

i have no idea what DOTSNET is
there is / will be a full dots networking package though

carmine plover
#

Are you referring to Unity's networking solution?

#

I've heard it's not fully fleshed out and as well documented as existing solutions

haughty rampart
carmine plover
#

Which one is the dots networking package? Do you happen to have a link?

#

Thanks!

haughty rampart
#

like even for normal gameobjects, after working with netcode for gameobjects for a while, i cannot recommend photon or mirror or whatever anymore

#

imo

carmine plover
#

Understood. Are you bucketing DOTSNET in with photon and mirror as well? How does DOTSNET compare to Unity NetCode for DOTS?

#

I'm reading through the documentation right now. But looking for some opinions as well ๐Ÿ™‚

covert lagoon
#

When should a system be put in the InitializationSystemGroup?

#

Where should my server choose a seed for my procedural terrain generation? In a system that is destroyed after updating once? In the OnCreate on my terrain generation system?

#

I want it to automatically be done when the server starts

viral sonnet
#

OnCreate and parse an args argument from commandline

#

[InitializeOnLoad] is probably fine too to parse the argument. I'm not sure if the system is already created then, I don't think so, you'd have to test for that

covert lagoon
#

Ok thanks

rustic rain
#

wtf

            _allSystems = GetEntityQuery(ComponentType.ReadOnly<StarNormal>(),
                ComponentType.ReadOnly<StarShared>());
#

it's not assigned into this query

whole gyro
rustic rain
#

no, it's not

#

it's instantiated

#

from prefab

#

I am really confused, I am assigning these 2 components to all entities in child hierarchy. But children don't get assigned ๐Ÿ˜

        public static void SetStarComponents(this EntityManager em, in Entity e, int ind)
        {
            var starNormal = new StarNormal() { systemID = ind };
            var starShared = new StarShared() { systemID = ind };
            foreach (var child in GetAllEntitiesInHierarchy(e, em))
            {
                em.SetComponentData(e, starNormal);
                em.SetSharedComponentData(e, starShared);
            }
        }
        public static IEnumerable<Entity> GetAllEntitiesInHierarchy(Entity parent, EntityManager em)
        {
            yield return parent;
            if (!em.HasComponent<Child>(parent))
            {
                yield break;
            }

            DynamicBuffer<Child> buffer = em.GetBuffer<Child>(parent);
            foreach (var child in buffer)
            {
                foreach (var anotherChild in GetAllEntitiesInHierarchy(child.Value, em))
                {
                    yield return anotherChild;
                }
            }
        }
rotund token
#

Does it actually have child buffer

rustic rain
#

yes

#

which contains child entity

rotund token
#

So are you not getting an error?

rustic rain
#

I did not just set parenting, I also created child buffer

rotund token
#

You seem to be looping a buffer and calling em set shared component

rustic rain
#

hm

rotund token
#

Which would invalidate the buffer

rustic rain
#

doesn't getting IEnumerable

#

already gives you final result of looping?

rotund token
#

Don't think so

#

It just calls that method once, yields, runs your code

#

Back into method

#

Same reason you can't foreach a dictionary and remove an element - invalidates the foreach

rustic rain
#
            var hierarchy = GetAllEntitiesInHierarchy(e, em);
            foreach (var child in hierarchy)
            {
                em.SetComponentData(e, starNormal);
                em.SetSharedComponentData(e, starShared);
            }

I even tried this, same thing

#

hmm

#

hmmm

rotund token
#

That doesn't change anything

rustic rain
#

I'll convert to array

rotund token
#

You need toarray or something

rustic rain
#

to test

rotund token
#

That said if it was actually iterating it should error

rustic rain
#

nah

#

same thing

rotund token
#

So if you're not getting an error I feel like it isn't iterating

#

Have you stepped through?

rustic rain
#

yeah, it seems to return both

#

hmm

#

wait, just one

rotund token
#

Why are you setting shared component on e

#

Not child

rustic rain
#

it's part of visual system

#

that enables, rendering

#

or disbles

rotund token
#

You are setting on the same entity every time

#

Not the child

rustic rain
#

what

#

me

#

so dumb

#

but that still doesn't fix broken children getting

#

hmm

#

it only returns parent

#

even though there is certainly a children

#

at very least because I instantiate from this prefab

#

and it has linked entity group

rotund token
#

Your get all entities in hierarchy seems wrong to me

rustic rain
#

but I need it

rotund token
#

You never turn a child

#

I don't think

#

You just loop to bottom and break

rustic rain
#

I don't return child, because I return parent

#

and then call same function on child

#

in which it becomes parent

rotund token
#

Oh I missed that part

#

That seemed an odd way to write it

#

But yep you want to return original parent as well

rustic rain
#

Wait a second

#

there is no child

#

wat

rotund token
#

Is it a static entity?

rustic rain
#

no

#

ok

#

so child buffer

#

is removed for some reason

#

after instantiation

#

bbbbbbruh

#

and how am I supposed to restore it

#

seems like an old issue

#

ok, so I still have LinkedEntityGroup

#

maybe I can restore hierarchy myself

rustic rain
#

sooo

#

how can I call method with burst?

#
 [BurstCompile]
        private void RestoreChildHierarchy(NativeArray<Entity> entities)
        {
            for (int i = 0; i < entities.Length; i++)
#

I did some monstrocity

#

and I need to make sure it runs bursted

rotund token
#

has to be static to start with

#

and you can't pass native containers to burst methods

#

(you can't pass structs except if it only has 1 pointer field in it)

rustic rain
#

hm

#

I can't even pass Entity?

rotund token
#

no

#

primitives and pointers only

#

just like you were talking to native code

#

(which you are)

rustic rain
#
            var list = new NativeList<Entity>(Allocator.Temp);
            for (int i = 0; i < entities.Length; i++)
            {
                var e = entities[i];
                var buf = EntityManager.GetBuffer<LinkedEntityGroup>(e);
                list.AddRange(buf.ToNativeArray(Allocator.Temp).Reinterpret<Entity>().GetUnsafePtr(), buf.Length);
            }

When I dispose list, will buffer be safe?

#

and also will those NativeArrays that get reinterpreted disposed if I dispose list?

#

Do I even need to do toNativeArray?

rotund token
#

yes it'll be fine

#

and no you dont need to do tonativearray

#

just do as

molten flame
# viral sonnet https://docs.unity3d.com/Packages/com.unity.entities@0.17/api/Unity.Entities.Ent...

Do you know the correct way to destroy a companion object without destroying the entity?
When I spawn one in netcode I get 2 instances on the host so I need to remove the game object, the entity however should stay as its ghosted position is required for the client companion object.
When I try to delete the companion object the companion transform system complains because its trying to look them up with entity references like everyone else

viral sonnet
#

hm, isn't the real problem that 2 instances are spawned? doesn't sound right. if you have a transform on the entity you can destroy the transform.gameobject and then remove the transform component

molten flame
#

This is normal in netcode on the host.
Normally one entity goes to server world and one to client world.
But companion objects dont live in a world, so you get 2 in the same scene

viral sonnet
#

why does a server spawn a companion object? isn't it client only?

molten flame
#

hmm, I see what you're saying...
Its part of a ghost prefab. So maybe I could replace it with a client only spawner instead and hook up the parenting afterwards on the client

#

Netcode makes things twice as complicated as they ought to be but I guess that comes with the territory

viral sonnet
#

yeah, there's an attribute so a system runs only on client, server or both. if you set this to client for the spawner it should work out

rotund token
#

oh yeah

#

its a huge problem when you run things like multiple clients on same machine

#

you get like 2x lights etc in the scene

#

i specifically avoid companion objects on ghosts

molten flame
rotund token
#

what do you mean by nameplates sorry?

viral sonnet
molten flame
rotund token
#

probably render them from code instead of UI

#

my draw system can already draw text really nicely in world

#

(mostly just for performance)

#

but if i didn't do it from code i'd probably just spawn them when required from a pool i think

#

i haven't considered it though

molten flame
heady edge
#

is there a bursted implementation of sort function for NativeArray/List? Build-in one seems not to be bursted

rotund token
#

it's bursted if you call it in burst code ๐Ÿคฃ

heady edge
#

yeah, asked the question and started to actually look at the attributes %)

viral sonnet
#

burst or not, depending on how many elements you have in the list, sort is slow

heady edge
#

well burst turned 3.5 ms into 0.43 ms, so I'm happy

#

I have to say I'm as always amazed with burst performance, it allowed me to calculate vision cone against 10k edges in sight in 1.5 ms whereas without burst it was around 5

#

and once I get to manual vectorization I expect it to become even less

viral sonnet
#

yeah burst is amazing. 10x speedups are pretty normal

#

sometimes even more, kind of crazy

rustic rain
#

I just don't get it

#
            _allSystems = GetEntityQuery(ComponentType.ReadOnly<StarNormal>(),
                ComponentType.ReadOnly<StarShared>());

I have this EntityQuery

#

StarShared is Shared Comp

#

if that matters

#

EntityManager.AddComponent<DisableRendering>(_allSystems);
I do t his

#

some entities are unnaffected

#

There it is

#

It's not part of that query, and has no relationship with SetRenderingSystem from which this query exists

#

and no, it's not prefab

#

Meanwhile, here other and it IS affected

#

absolutely no difference

#

WAaaaait a second

#

oh my god

#

I figured it out

#
            _curSystem = GetEntityQuery(ComponentType.ReadOnly<StarNormal>(),
                ComponentType.ReadOnly<StarShared>());
            _allSystems = GetEntityQuery(ComponentType.ReadOnly<StarNormal>(),
                ComponentType.ReadOnly<StarShared>());

they are same

#

and _curSystem is getting filters

#

should have simply created new

rustic rain
#

Any tip where can I find manual on loading/unloading subscenes?

#

I need to have full control over what subscenes are loaded, what subscenes are not loaded

oak sapphire
rotund token
rustic rain
#

is that good?

rotund token
#

seems pretty gross

#

btw you can load subscenes from jobs

rustic rain
#

also, can't find how can I stop subscene from loading by itself?

rotund token
#
            this.Entities
                .WithNone<RequestSceneLoaded>()
                .ForEach((Entity entity, int entityInQueryIndex, in SceneSectionData sceneData, in LoadWithBoundingVolume load) =>
                {
                    var boundingVolume = (AABB)sceneData.BoundingVolume;
                    var maxDistanceSq = load.LoadMaxDistanceOverrideSq > 0 ? load.LoadMaxDistanceOverrideSq : loadMaxDistanceSq;

                    foreach (var ltw in playerPositions)
                    {
                        var distanceSq = boundingVolume.DistanceSq(ltw.Position);
                        if (distanceSq < maxDistanceSq)
                        {
                            buffer.AddComponent<RequestSceneLoaded>(entityInQueryIndex, entity);
                            return;
                        }
                    }
                })
                .WithReadOnly(playerPositions)
                .ScheduleParallel();```
#

this is how i load subscenes within range of a player

#

reverse is just removing RequestSceneLoaded component

rustic rain
#

ahem

#

I'm confused

#

So, all subscenes inside loaded normal scene will be loaded

#

that seems clear

#

so, instead I should remove that subscene

#

and load it manually?

rotund token
#

subscenes can actually be made up from multiple sections

#

each with its own bounds

#

by default all subscenes will have 1 section

#

and this is where your entities actually live

#

(but you can break them up further into more regions if you wnat)

#

to load a section all you need to do is attach RequestSceneLoaded to the section

#

if you look at your SceneSystem.LoadEntitySceneAsync

#

what it's actually doing is

        {
            RequestSceneLoaded requestSceneLoaded = CreateRequestSceneLoaded(parameters);

            EntityManager.AddComponentData(sceneEntity, requestSceneLoaded);

            if (parameters.AutoLoad && EntityManager.HasComponent<ResolvedSectionEntity>(sceneEntity))
            {
                foreach (var s in EntityManager.GetBuffer<ResolvedSectionEntity>(sceneEntity))
                    EntityManager.AddComponentData(s.SectionEntity, requestSceneLoaded);
            }
        }```
#

adding RequestSceneLoaded

#

to all it's sections

rustic rain
#

hmm, I see

#

wait what

#

where does this SceneSystem exists?

#

is that Editor only?

rotund token
#

no

rustic rain
#

hmm, could you recommend any specific pattern for bootstrap?

#

rn subscene is just loaded, which I don't want

rotund token
#

that's kind of a broad question

rustic rain
#

What I want - is to load all subscenes manually

#

Basically I have a World subscene which is supposed to be loaded only when world is getting generated

#

and several subscenes that I would want to load/unload on demand

rotund token
#

i have a script i attach to all subscenes which tells it how it should load

#

AutoLoad
Range
Custom

#

(range is what you saw above)

rustic rain
#

hmm

rotund token
#

when i start a world, i then load all AutoLoad subscenes and i make the world not tick until they're loaded

#

(so i don't have to through dependencies in all my systems - these are mostly my settings, prefabs etc)

rustic rain
#

Do I need any special settings for mono behaviour script execution order for this?

rotund token
#

there's no logic on these scripts

#

they just hold data

rustic rain
#

oh

#

so when scenes are even loaded on it's own?

rotund token
#

what do you mean

rustic rain
#

rn, no special scripts or systems

#

from what I noticed

#

they are loaded in async

#

and sometimes even during OnStartRunning

#

they might be not loaded yet

rotund token
#

yes subscenes load async

#

could take seconds

rustic rain
#

so, when and from where are they even scheduled to be loaded?

#

first of all I am looking for a way to stop them from loading alltogether

#

so I can try and do that manually

#

also what bothers me is that normal scene is also loaded as entity

rotund token
#

untick it ^_^'

rustic rain
#

๐Ÿคก <- this is me

round narwhal
#

hi everyone,
since there's no update of DOTS Animation for 0.5, how can I animate models on a scene ?

frosty siren
rustic rain
#

you mentioned adding some data to scene game object

#

But I don't really see how it's data can be passed to entity

#

unless ofc, IConvertGameObject interface works on subscenes

rotund token
#

I need to load my auto loads as well

rustic rain
#

can ConversionSystem catch it?

#

or IConvert interface?

rustic rain
#

how do I know whether this entity is scene I want?

rotund token
#

There is no entity

#

Until you create it via loading the subscene

#

I think you can just set the flag don't load or something like that to instantiate the sub scene to create its entity but not load its assets.

#

(in bed sorry can't check api, time to sleep anyway )

rustic rain
covert lagoon
#

To which system group should a character controller system implementing basic physics belong to in a game that uses Netcode for Entities?

#

I want clients to predict their owned player's movement

#

But GhostPredictionSystemGroup does not belong to FixedStepSimulationSystemGroup, to which physics systems should belong afaik

#

I guess I'll put the system in FixedStepSimulationSystemGroup and make it retrieve the GhostPredictionSystemGroup to get the predicting tick anyway

covert lagoon
molten flame
covert lagoon
#

Nvm I found it

covert lagoon
#

I have 2 problems

#
  1. Creating a Unity.NetCode.PredictedPhysicsConfig singleton on both the client and server does not move physics systems to the PredictedPhysicsSystemGroup
#
  1. I can't manage to do a raycast that collides with my procedurally generated terrain
#

Ok I noticed something

molten flame
covert lagoon
# molten flame Are you using entities 0.50? How do you create your singletons? I do mine immedi...

Yes I am using Entities 0.50.1-preview.2.
I create my singletons with a system, not inside my bootstrap:

    [UpdateInGroup(typeof(ClientAndServerInitializationSystemGroup))]
    public partial class NetcodeConfigSystem : SystemBase
    {
        protected override void OnStartRunning()
        {
            var netcodeConfig = EntityManager.CreateEntity();
            EntityManager.AddComponentData(netcodeConfig, new PredictedPhysicsConfig
            {
                PhysicsTicksPerSimTick = 1,
                DisableWhenNoConnections = true,
            });
        }

        protected override void OnUpdate()
        {
        }
    }
#

It's probably not the best way but I still expect it to work

molten flame
#

mm ok, only difference to me is that it runs in a system and has DisableWhenNoConnections = true instead of false

covert lagoon
#

But if I make my player prefab's physics body dynamic instead of kinematic, it just falls through

#

Ok fuck me

#

I put my TerrainChunkMeshGenerationSystem in the ClientAndServerSimulationSystemGroup but I put my TerrainChunkGenerationSystem in the ClientSimulationSystemGroup

#

So the server didn't generate the terrain, so the player fell through on the server side, so the client received snapshots of the player falling through

#

And now my raycasts work too

scarlet inlet
#

Hey all: do you know if it is possible to iterate only a portion of a TransformAccessArray through a IJobParallelForTransform job?

#

I have a doubt now, maybe TransformAccessArray is not meant to be cached, but recreated every iteration?

rustic rain
#

what are you even trying to do?

scarlet inlet
#

iterate only a portion of the TransformAccessArray?

#

like let's say for an example sake I want to set only the first 100 positions in the array

#

and not to be forced to iterate it all

#

but I have the impression I may have misunderstood how to use it, if I should create the TransformAccess every iteration may make more sense. However it's still awkward if the number of gameobjects change, since the array must be of the exact size

#

so if I want to reserve space but not using it is a problem

#

in conclusion: I Wish I could at least pass an array and the count in the TransformAccessArray constructor, but it seems that even that is not possible

covert lagoon
#

Entity shows up in game view

#

But not in scene view

#

How

#

I checked in the hierarchy and the entity exists in both client and server worlds

#

Not that it only existing in one of them could change something in my opinion but I don't know what to check

#

Same Translation and LocalToWorld values in both worlds too

#

I restarted Unity and the issue did not fix itself

covert lagoon
#

But my PredictedPhysicsConfig singleton works now? Despite that I didn't touch the system that creates it?

covert lagoon
#
error NetCode: GhostField missing on field Alter.Characters.PlayerInput.Tick . Buffers or CommandData must have all fields annotated

^ When I first saw this error, I didn't think much and simply added the GhostField attribute to the Tick property of my following ICommandData-implementing struct:

    public struct PlayerInput : ICommandData
    {
        [GhostField]
        public uint Tick { get; set; }

        [GhostField(Quantization = 1000)]
        public float3 Translation;
    }

But I just noticed this in Netcode for Entities's source code:

    public interface ICommandData : IBufferElementData
    {
        [DontSerializeForCommand]
        uint Tick { get; set; }
    }

Should I replace the GhostField attribute on PlayerInput.Tick with DontSerializeForCommand?

#

Wait no I can't

#

If I do then I still get the same compiler error

#

It really wants me to use annotate all PlayerInput fields with GhostField

molten flame
#

Looks like you are correct, all fields should be ghost fields and it should be marked as ghost component

molten flame
#

I have an Entity Command Buffer question...
Say I have some entity that I delete with an ECB early in the loop.
There is no guarantee that, some later system that runs before the ECB plays back, reading that entity before it is destroyed, to do some logic, right?

rotund token
#

correct

haughty rampart
#

Unity when 0.51? XD

rustic rain
#

hopefully, before we all die out of old age

timber ivy
#

So does dots have animations yet?

karmic basin
#

Nope, not before long after 1.0

#

Have to rely on an hybrid with mecanim or roll your own animation implementation for DOTS

#

or find someone that sleeps less than you and already implemented it

timber ivy
#

I couldn't even find someone to pay to make that for me 9 months ago

karmic basin
#

Keep an eye on user DreamingImLatios 's framework, it will include animation at some point

covert lagoon
#

I don't know why it's annotated with DontSerializeForCommand in the definition of ICommandData

oak sapphire
covert lagoon
#
    public class GhostComponentAttribute : Attribute
    {
        // ...
        /// <summary>
        /// Gets or sets the type of ghost this component should be sent to if the ghost is owner predicted.
        /// </summary>
        public GhostSendType OwnerPredictedSendType {get; set;}

I don't want player input to be sent back from the server to any clients, right? So I should use GhostSendType.None?

heady edge
#

Any native collection out there that can insert sorted?

viral sonnet
#

so, uhm, who knows why nativecontainers are so slow in unbursted code? I said the problem is marshalling but some guy tells me I'm wrong. So what is it?

heady edge
#
            {
                var obstacle = Obstacles[i];
                var pp1 = new PolarCoords() {angle = 10, radius = 20};
                var pp2 = new PolarCoords() {angle = 20, radius = 10};
                // PolarHelpers.CartesianToPolar(ObserverPosition, obstacle.position1, out var pp1);
                // PolarHelpers.CartesianToPolar(ObserverPosition, obstacle.position2, out var pp2);
                ObstacleDatas[i] = new ObstacleData()
                {
                    cp1 = obstacle.position1,
                    cp2 = obstacle.position2,
                    direction = obstacle.dir,
                    pp1 = pp1,
                    pp2 = pp2,
                    obstacle = i,
                };```
when a thing like that became one of the two bottlenecks I have (other one is sort) I'm thinking i've reached the end of what I can squize out of it performance wise