#archived-dots

1 messages ยท Page 35 of 1

rustic rain
#

not great

#

here it is

rustic rain
hot basin
#

ok

rustic rain
#

Has anyone had any troubles with queries shared component filters?

#

query.SetSharedComponentFilter(new StarShared() { systemID = ind });
Basically I do this, I get 0 entities

#

meanwhile

#

without it I get tons

#

and also meanwhile

#

that same entity

#

ind is confirmed by debug log = 0

hot basin
#

is BRG for mainly static objects?

rustic rain
#

no

#

entities graphics work through BRG

hot basin
#

so all you need is constantly update InstanceDateBuffer?

#

to be honest I don't see much improvements over my Graphics.DrawMeshInstancedProcedural solution

rustic rain
#

no idea, sir

#

I never figured it out

misty wedge
#

Are you not allowed to write to a NativeStream in parallel without disabling safety?

hot basin
#

you are allowed I think, use thread id as a "stream batch id" (I don't remember what's the proper name)

misty wedge
#

BeginForIndex?

hot basin
#

oh yeah it was a function

misty wedge
#

thread id won't work for that, since you can only write to each index once

hot basin
#

yeah I checked it now, I'm using int indexOfFirstEntityInQuery as it's still a IJobEntityBatchWithIndex

misty wedge
#

How many buffers are you creating on the stream?

hot basin
#

buffers? do you mean streamWriter.BeginForEachIndex(index); calls?

misty wedge
#

No, when you create the native stream you need to set the amount of buffers it uses

#

Which is what BeginForEachIndex refers to

hot basin
#

ah then it's unit count in my case, I'm using stream in my AI so as many as agent count

keen root
#

How to make it change to a different place when the button is clicked ?

misty wedge
keen root
#

how to make click button and this button change position

misty wedge
keen root
#

ok ty

misty wedge
#

It works fine if it is normally scheduled

hot basin
#

do you start with 0? are you create stream with actual value in bufferCount?

misty wedge
#

Yes, I set the stream count to ChunkCount for the schedule IJobChunk

#

then I use unfilteredChunkIndex to set the foreach index

hot basin
#

strange

rustic rain
#

Sirs. Can anyone test whether unmanaged shared component filter works for entity query on your end?

#

It doesn't for me and I'm going crazy figuring whether it's me or unity bug

misty wedge
#

e.g.

rustic rain
#

๐Ÿฅด

misty wedge
#

What's not working?

rustic rain
#

When no filter: this entity matches query

#

When I add filter: query is empty

#

Meanwhile shared comp matches entity 100%

misty wedge
#

Are you sure the value set in the filter is correct?

rustic rain
#

Yeah, it's literally just integer in a nutshell

#

I even used log to confirm

misty wedge
#

Can you show the whole query?

rustic rain
#

Not anymore, not at pc. But it matches entity

#

Without filter

misty wedge
#

And the query also includes the shared component?

rustic rain
#

Yeah

misty wedge
#

Are you just calculating entity count to check?

rustic rain
#

I do calculate, and I then use it in a job

misty wedge
#

And the calculated number is 0?

rustic rain
#

Yes

#

No filter: 25

#

All those entities even match filter

#

Ironically

misty wedge
#

Odd

misty wedge
#

Now that WorldUpdateAllocator is a thing, is it faster to use that and just let the rewind handle it, or to schedule explicit Dispose jobs?

spice vale
#

my guess is that WorldUpdateAllocator is faster

#

Maybe I misunderstood your question, but I'm not even sure it is possible to dispose allocations from WorldUpdateAllocator

drowsy pagoda
#

Can someone help me understand what this means: Returns a uniformly random float2 value with all components in the interval [0, 1) when calling Random.NextFloat2 vs NextFloat2Direction.

rotund token
#

Direction should be normalised

drowsy pagoda
#

Ah, I get it now

dense storm
#
A BatchDrawCommand is using the pass "Sprite Unlit" from the shader "ShaderGraph/Procedural Bullet" which does not define a DOTS_INSTANCING_ON variant.
This is not supported when rendering with a BatchRendererGroup (or Hybrid Renderer). MaterialID (0x4) MeshID (0x1) BatchID (0x2)

How to define DOTS_INSTANCING_ON?

#

Wait it works on non-sprite SG Shaders

#

Sprite Unlit can't be drawn by dots graphics?

#

๐Ÿ˜ญ

#

Ok it worked when its not sprite

drowsy pagoda
#

Suppose there is no way to check if the non-indexed entity has a SharedComponent equivalent to a ComponentLookup<T> inside a IJobEntity.ScheduleParallel()?

drowsy pagoda
#

Can you give me a quickie? Currently I am using query.AddSharedComponentFilter then ToEntityListAsync and then gonna pass that list of entities into IJobEntity job to verify if the entity exists.

#

Oh IJobChunk will let me use a SharedComponentTypeHandle right?

#

๐Ÿค” that's interesting. I will try that route first, feels cleaner and more optimal.

rustic rain
#

Use shared comp type handle

#

And use it with chunk

#

To check your optional component

drowsy pagoda
#

Thx

dense storm
#

Why is clipping weird when using Entity Graphics?

#

GameObject counterpart looks fine

rotund token
#

Looks 2d? How are you rendering it with graphics?

rustic rain
#

sprite is attached to Base map property

deft pilot
#

can you Reinterpret something like:

DynamicBuffer<Foo> foos;
foos.Reinterpret<Bar>();

public struct Foo : IBufferElementData
{
  public Bar Value;
}
#

project currently doesn't compile so cant' test it

#

or do i have to reinterpret it like for like:

DynamicBuffer<Foo> foos;
foos.Reinterpret<Bar>();

public struct Foo : IBufferElementData
{
  public FooBar Value;
}

public struct Bar : IBufferElementData
{
  public FooBar Value;
}
spice vale
#

Both works

#

essentially having a struct inside another struct with nothing else does not change the layout at all, just the type.

deft pilot
#

yeah i was hoping that was true

#

my previous problem got more complicated

#

.>;

#

now it have something like

#

3 element buffers on a singleton entity that two of them hold positional data

#

another holds a mapping between that, and an intermediate mapping entity

dense storm
deft pilot
#

that maps to another entity that holds pathing data

#

#sadge

#

aka List<List<Vector2Int>>

#

this is what it feels like to create a joining table in sql

#

1 > Many <> Many > 1

dense storm
rustic rain
#

yay

#

I fixed selection tool finally

#

actually made it extremely fast through burst

#

if I only could find a way to read pixel faster

#

it'd be as good as instant

deft pilot
#

trying to understand this error: ArgumentException: All entities created using EntityCommandBuffer.CreateEntity must be realized via playback(). One of the entities is still deferred (Index: -1).

#

it seems to be pointing at me trying to get a buffer

#

atleast according to the stack trace

rustic rain
#

when you create entity through ECB

#

you get invalid entity

#

with index -1

#

which is only valid for buffer

#

it will be actually created and get normal index when PlayedBack

deft pilot
#

i understand that about ecb

#

but why would it throw that error when trying to get a buffer

rustic rain
#

maybe you're trying to get a buffer from deferred entity?

deft pilot
#

i'll try to write some pesudo code

#

its abit too large

#

hmm let me check

#

i dont' think i am

#

yeah i'm not

rustic rain
#

then you better show code

#

guessing can only be as good

deft pilot
#

yeah gimme a sec

#

can't just copy paste this its way too large

#
// in protected override void OnUpdate()
var buffer = EntityManager.GetBuffer<FooElement>(this.cachedEntity);
var ecb = new ECB();
var entities = fooEntityQuery.ToEntityArray(Allocator.TempJob);
foreach (var entity in entities)
{
  for (int i = 0; i < someLength; i++)
  {
    var fooComponent = EntityManager.GetComponent<FooComponent>(entity);
    if (!this.FooCheck(ref ecb, buffer[i]))
    {
      continue;
    }
  }
}
ecb.Playback(em);
ecb.Dispose();

private bool FooCheck(ref ECB ecb, FooElement fooElement)
{
  var someBuffer = EntityManager.GetBuffer<BarElement>(fooElement.Value);
  var entity = ecb.CreateEntity();
  var buffer = ecb.AddBuffer<Foo2Element>(entity);
  buffer.Add(new());
}```
#

so its erroring in the method

#

when i try to get someBuffer

rustic rain
#

ecb doesn't need ref btw

deft pilot
#

hmm k

rustic rain
#

well

#

I'd attach a breakpoint

#

and take a look

#

at values

#

of entities

#

you are trying to get buffer from

deft pilot
#

thats weird...

#

hmm

#

so it must be because i added it to a buffer

#

okay i need to ecb adding data to buffers to

#

let me do that...

#

entityCommandBuffer.AppendToBuffer( i'm assuming its just that

rustic rain
#

๐Ÿค”

#

didn't know that method exists

#

good to know

#

hmmm

#

feels so bad I can't add any abstract data to world without assembly modification

deft pilot
#

how do you guys keep track of how systems work?

#

like i had to literally diagram out my data structure just to remember wtf is going on

rustic rain
rotund token
#

But generally not that complicated

deft pilot
#

keeping all this in my head

#

seems much harder lol

rotund token
#

A lot of my libraries are only 1 system

#

I was going to write a sequence diagram for another soon though

#

But system groups can help as well

#

To group behaviour

rustic rain
#

sir, do you have any idea how to store NativeReference untyped and then retrieve it by type?

#

public static NativeReference<T> GetSingletonStructReference<T>(this EntityManager em) where T : unmanaged
I want to have this utility method

#

that lets you store and obtain signleton struct per world

deft pilot
#

which makes sense

rustic rain
#

is there burstable way to get Type hash?

deft pilot
#

type hash?

#

typeof(T).GetHashCode() this thing?

rustic rain
#

just any unmanaged data unique per type

rustic rain
deft pilot
#

couldnt you just identify it via name

#

do you need hash?

#

or do you have collisions

rotund token
rustic rain
#

with safety handle

rotund token
#

Then being untyped doesn't make sense

#

Because untyped is void*

rustic rain
#

void* is fixed size of 4 bytes, right?

rotund token
#

Technically depends on platform

rustic rain
#

๐Ÿค”

#

I guess

#

sizeof(T) is resolved during compilation?

#

what I want to try

spice vale
rustic rain
#

is to store untyped memory sizeof(NativeReference)

spice vale
#

4 bytes for 32 bit and 8 bytes for 64 bit

rustic rain
#

and access it by type hash

#

but I also need a way to obrain hash from Type in burst

rotund token
#

There's a burst hash function

#

Burst util or something I can't remember

#

Gives you Hash<T>

rustic rain
#

ok so

#

hmm

#

I guess what I want is

#

HashMap of <long,IntPtr>

spice vale
#

Ah you want to make a typed singleton storage?

rustic rain
#

yeah

#

for smt hlike

#

MousePosition

spice vale
#

just use Typemanager to go from type to index

rustic rain
#

I don't want it to use comps

spice vale
#

just add the attribute and never use than as comps

#

Getting a hash with burst method is not guaranteed to be unique, is it?

rustic rain
#

should be

deft pilot
#

its never guaranteed to be unique

rustic rain
#

with 64 bit

deft pilot
#

why would burst change it?

spice vale
#

Therefore I don't think it will be possible using that method, and you can't check if it was a collision, since you can't use the type

deft pilot
#

if you care about collisions you wouldn't even use hashing in the first place

#

but i doubt collisions matter here

#

its not like it randoms a hash

#

it generates it against your input

#

are you confusing this with GUID?

#

only thing i can think of

spice vale
#

if type "PlayerMoveInput" and type "PlayerAttackButton" hashes to same value, he can't check if there was a collision, and will use same data for both

deft pilot
#

why would it be the same?

rotund token
#

There is a tiny chance it will be

deft pilot
#

you are referring to the infinitely small chance there is a collision right?

#

that happens with normal hashing

spice vale
#

yes

deft pilot
#

burst is irrelevant

#

and the chance is super tiny

rotund token
#

But at 64 bit it's low enough I don't think it'd be an issue

#

On the rare chance it fails it should be obvious in your app

#

You just have to remember why

deft pilot
#

well according to simple stats

#

you have about 40% chance of collision

#

after 4billion hashes

#

on 64bit

spice vale
#

But is it guaranteed that the hash will be same across all different kinds of hardware/computers?

deft pilot
#

my guess is there is a static formula

#

in the backend that allows it to be burstable

#

otherwise i can't see this working

#

but would have to see source

rustic rain
#

ok

spice vale
#

would suck if It would cause a crash for some random player

deft pilot
#

but even if it changes per computer basis

rustic rain
#

@rotund token are native containers allowed now in ISystem?

#

any idea?

deft pilot
#

the chance of it happening usually isn't a consideration

rustic rain
#

great

deft pilot
#

how many unique things is he gonna hash anyway

#

unless its over 4 billion

#

i doubt it matters

rustic rain
#

Me personally - about 5

#

or 10

#

tops

deft pilot
#

lawl

#

you don't even need 64bit then

rustic rain
#

modders might use over hundred

spice vale
rustic rain
rustic rain
#

it's one time operation to get pointer, that's it

rotund token
#

He can detect it in a tryadd

#

Anyway

#

But modders make it a bit more problematic

#

You can't fix that easily

deft pilot
#

big doubt

#

like even at 1million unique items to hash

#

its like 1/1million chance

#

of failing

rotund token
#

I know unitys animator hash is 1/300000

#

Collision

#

32bit

#

Which is much higher than you'd expect

#

But 64bit is magnitudes less likely

deft pilot
#

yeah

rotund token
#

(birthday paradox always gets you though )

deft pilot
#

but i think there is a limit on how many keys you can map anyway

#

true true

#

but stats already calculated for that

#

(still not sure why you can't just have a string id)

rotund token
#

^

#

Just avoid it fixed string

deft pilot
#

is there a way to loop over all buffers of a certain type?

#

using entity queries

#

and ToComponentData?

#

welp doesn't look like it

rustic rain
#

why not?

deft pilot
#

doesn't seem to like it

#
myQuery.ToComponentData<DynamicBuffer<MyElement>>(Allocator.TempJob);```
#

didn't like that

rustic rain
#

๐Ÿค”

#

use SystemAPI.Query

deft pilot
#

O.o?

rustic rain
#

or iterate chunks manually

deft pilot
#

i was just gonna grab all the entities then iterate over their buffers after getting them manually

rotund token
#

That's how you do it

rustic rain
#

would be way faster

#

rather than EntityManager

#

hmm

#

how can I create a pointer reference to abstract memory?

#

I guess I need to allocate memory

#

copy to it

#

and then save pointer

spice vale
#

btw @rustic rain isn't what you are doing already accomplished by sharedstatic in burst?

rustic rain
#

I need it per world

spice vale
#

but you can have two keys, maybe one can be world the other type?

rustic rain
#

no, that is not it

spice vale
#

why?

rustic rain
#

I don't want and shouldn't do hacking by inheriting from it

#

besides

#

I need it for unmanaged world

#

sooo

#

Looks like AllocatorHandle

#

is a ready solution for my custom allocation

deft pilot
rustic rain
#

buffer type handle

deft pilot
#

got a unity doc or anything i can read on it?

#

still can't find anything weirdly

rustic rain
deft pilot
#

hmm i'll keep it in mind will have to see what their use cases are

#

unity docs on this sucks

rustic rain
#

typaHandles are for iterating over chunks

deft pilot
#

whats a "chunk"

rustic rain
deft pilot
#

fair enough

#

I haven't dived that deep into unity's ecs that much, just taking what i know from other ecs libraries and trying to apply it here lol

#

ahh okay so chunking is just unity's term for their cache of objects with similar components

rustic rain
#

ok, think I made it

#
    [UpdateInGroup(typeof(InitializationSystemGroup))]
    public struct SingletonNativeReferenceStore : ISystem
    {
        public NativeHashMap<long, IntPtr> ptrMap;
        public NativeList<int> sizeList;
        public void OnCreate(ref SystemState state) { state.Enabled = false; }

        public void OnDestroy(ref SystemState state) { }

        public void OnUpdate(ref SystemState state) { }
    }

    public static class NativeReferenceUtility
    {
        public static unsafe NativeReference<T> GetSingletonStructReference<T>(this EntityManager em)
            where T : unmanaged
        {
            var hash = BurstRuntime.GetHashCode64<NativeReference<T>>();


            var handle = em.WorldUnmanaged.GetOrCreateUnmanagedSystem<SingletonNativeReferenceStore>();
            ref var store = ref em.WorldUnmanaged.GetUnsafeSystemRef<SingletonNativeReferenceStore>(handle);

            if (store.ptrMap.TryGetValue(hash, out var ptr))
            {
                UnsafeUtility.CopyPtrToStructure((void*)ptr, out NativeReference<T> output);
                return output;
            }

            var value = Memory.Unmanaged.Allocate<NativeReference<T>>(Allocator.Persistent);
            var instance = new NativeReference<T>(Allocator.Persistent);
            UnsafeUtility.CopyStructureToPtr(ref instance, value);

            var size = sizeof(NativeReference<T>);


            store.sizeList.Add(size);
            store.ptrMap.Add(hash, (IntPtr)value);

            return instance;
        }
    }
#

oh wait, forgot to allocate collections

open shore
#

Does anyone know how to get Unity's new input system to work with ECS? I want to be able to support multiple players with multiple input devices.

brave field
rustic rain
#

renders meshes

#

without physics

#

to select them

#

with mouse

brave field
#

I thought default dots ady have tat?

rustic rain
#

in editor I guess

#

1.0 feature

hot basin
#

I found out that somehow I render things twice. Is HR/EG making that second camera? or is it SceneView camera? In second case I assume that it will go away in build?

rustic rain
#

hmm

#

any idea how I can deallocate specific amount of bytes

#

allocated by Memory.Unmanaged.Allocate<NativeReference<T>>(Allocator.Persistent);

hot basin
#

it's still there

rustic rain
#

pog

#

my NativeReference implementation works

#

allows you to create singleton struct per world

#

with only access to Manager

#

by storing it you get direct access to whatever value you want

#

perfect for storing input per world I think

#

or other things that don't really need Entity

drowsy pagoda
#

I have a parallel job that needs to do a physics distance query. However upon running it it's giving me that "previously schedule job" error about conflicting with Broadphase and other physics stuff. I'm assuming I didn't add the physics system as job dep. But I can't find where to get it. Back on 0.50 it was a simple method from the StepPhysicsWorld. But now I don't see that or the class. Where do I get this?

hot basin
#

try adding query to RequireForUpdate

#

do I need add new blob asset in the baker?
I found: AddBlobAsset(ref blob, out var hash); but do I need to store that hash?

drowsy pagoda
hot basin
#

yes, dependency should be autamatically figured out if you properly add your queries to it

#

I found out that in 0.51 it was more automatically than in 1.0?

#

bunch of my systems suddenly needed that additional RequireForUpdate to work

drowsy pagoda
#

In this particular case, I am not using the source gen methods. So I donโ€™t think that will work for me. When I get back I will try it, but I donโ€™t think that will do it.

rustic rain
#

Will OnStopRunning be called

#

on next update

#

where OnUpdate won't?

#

I have a reactive system that updates data to smth

#

and I need to set a boolean here, whether data is valid (was updated this frame)

#

or not (was not updated this frame)

#

all right, I checked source and seems like it

viral sonnet
#

how is this better than just storing the value in a singleton icomp?

solemn hollow
#

hey im wrapping my head around baking right now. quick question: how do i sort the baking systems? e.g. if i want to set the transform of the resulting entity how do i make sure it runs after the system that just copies the gameobjects transform?

#

Or even better: how do i skip the copying of the transform?

rustic rain
#

after that it's direct pointer

rustic rain
#

Baking systems are SystemBase now

#

and they are literally same thing as runtime

#

you query over entities only

#

so you have to implement temporary baking types

#

there are attributes for temporary types that get removed automatically

#

or attached to all entities

solemn hollow
#

ah great! so i guess this will do : [WorldSystemFilter(WorldSystemFilterFlags.BakingSystem)] [UpdateInGroup(typeof(PostBakingSystemGroup))] [UpdateAfter(typeof(TransformBakingSystemGroup))]

rustic rain
#

why do you need transform group?

solemn hollow
#

i want to override transforms for some Prototype instances

rustic rain
#

I think there's smth built in about it

#

but I never figured

solemn hollow
#

hmm there might be now. Prefabs dont cut it in my usecase but maybe ill find some decent solution later on. for now id be happy to just convert everything to 1.0 as soon as possible without breaking everything

rustic rain
#

๐Ÿ˜…

#

I'm still converting

#

since the first day basically

gentle gyro
solemn hollow
#

no im not. would that have consequences?

gentle gyro
#

Can't build mobile with 1.0 and IL2CPP right now...

#

Or at least it crashes on startup

solemn hollow
#

good to know but i guess that will be fixed soon

gentle gyro
#

possibly 2022.2.0b11...

solemn hollow
#

ah even better if the error isnt in entities package itself

gentle gyro
#

Not sure if it is or isn't
But I believe ECS is being built-in to Unity now so it still could be an error in ECS

solemn hollow
#

i got the selected entity for editor tools like this: ```public static class EntitySelection
{
public static Entity selectedEntity
{
get
{
var proxy = Selection.activeObject as EntitySelectionProxy;
if (proxy && proxy.Entity != Entity.Null)
return proxy.Entity;

            return Entity.Null;
        }
    }
}```

is there a new official way?

#

EntitySelectionProxy is now internal

olive kite
#

Isn't there a component that is needed so that modifying LocalToWorld updates the entity or am I mis-remembering?

rustic rain
#

scene view selection works

solemn hollow
# rustic rain scene view selection works

sry i dont know what you mean. I need a working solution for this:
var selectedEntity = Selection.activeObject as Entity;
Compiler complains that entity is a non nullable type

solemn hollow
#

"cannot cast Object to Entity"

rustic rain
#

๐Ÿค”

#

maybe it's not Entity then?

solemn hollow
#

basically a system needs to know which entity is selected in the editor

viral sonnet
#

every change applies

olive kite
#

ok thanks, just checking. I must be doing something in another place

rustic rain
#

a little confusion ๐Ÿ˜…

rustic rain
#

๐Ÿค”
Assets\Runtime\SelectionSystem\SelectionTool\EntitySelectionTool.cs(156,25): error SGQC001: WithAll<SelectionRenderAspect>() is not supported. WithAll<T>() may only be invoked on types that 1) implement IComponentData, ISharedComponentData, IAspect<SelectionRenderAspect> or IBufferElementData, or 2) are UnityEngine.Object types.

#
                query = SystemAPI.QueryBuilder()
                    .WithAll<Selectable>()
                    .WithAll<SelectionRenderAspect>()
                    .WithAll<StarIndex>()
                    .Build();
#

IAspect<SelectionRenderAspect>

#

It's not even a thing

#

wtf

#

I'm so done

#

๐Ÿฅด

rotund token
#

What does star index look like

rustic rain
#
    public struct StarIndex : ISharedComponentData
    {
        public int systemID;

        public static implicit operator StarIndex(int x) => new() { systemID = x };
        public static implicit operator int(StarIndex x) => x.systemID;
    }
spice vale
#

the icons don't match, tag vs sharedComp

rotund token
#

Hmm try implement IEquatible

#

Hmm maybe that's not needed anymore

#

But it was earlier I thought

rustic rain
#

nah, still same

#

0 entities in query

rotund token
#

How are you adding this shared component to things

rustic rain
#

during baking

rotund token
#

You haven't accidentally added via the managed path?

rustic rain
#

no I use default

rotund token
#

I guess just try filter managed

#

To rule it out

rustic rain
#

nnnope

#

query.SetSharedComponentFilterManaged(ind);

#

still 0

rotund token
#

Hmm

#

I'm on a tropical island so can't really check atm

#

But I definitely upgraded and tested my save library in 1.0

#

Which requires filters on subscene shared components which was working

drowsy pagoda
#

Error: The previously scheduled job Broadphase:PrepareStaticBodyDataJob writes to the UNKNOWN_OBJECT_TYPE PrepareStaticBodyDataJob.FiltersOut. You are trying to schedule a new job EnergyReplenishDirectiveJob, which reads from the same UNKNOWN_OBJECT_TYPE (via EnergyReplenishDirectiveJob.JobData.CollisionWorld.Broadphase.m_StaticTree.BodyFilters). To guarantee safety, you must include Broadphase:PrepareStaticBodyDataJob as a dependency of the newly scheduled job.

Where can I get this so-called Broadphase:PrepareStaticBodyDataJob dependency to add to my job dep?

rotund token
#

Are you modifying physics?

#

If not you shouldn't need to

drowsy pagoda
#

Nope, onlly thing I'm doing is var physicsWorld = GetSingleton<PhysicsWorldSingleton>(); passing it into IJobEntity and there all I do is just this call if (CollisionWorld.CalculateDistance(queryInput, ref hits))

#

I think it's because of the way I prepared for the job. Can I post some code?

#

It's also attributed with Unity.Collections.ReadOnlyAttribute in the job struct

rotund token
#

You don't have a secondary exception right?

drowsy pagoda
#

one sec, I think I made it go away. Gonna do a quick test here...

#

My jobs in this system need to be chained to avoid race conditions. And the first job in the chain I put default as it's inputDeps. But then when I changed it to Dependency prop, the errors went away.

Does that sounds right for a dependency chain to look like this Dependency->JobHandle1->JobHandle2 & 3->Dependency because at the end of the chain, I do Dependency = JobHandle.CombineDependencies(lastHandleInChain, Dependency).

#

Like for job handle one to depend on the Dependency and then have the Dependency at the end depend on all the chained jobs.

rustic rain
#

It contains all dependencies on all type handles or comp lookups

drowsy pagoda
#

Oh thank you for explaining that. Now it makes sense. Yeah as soon as I did that, everything started to work as intended. thx again man.

solemn hollow
#

where did the option to rebuild entity cache go in 2022.2?

#

my subscene conversion fails without producing a useful log ๐Ÿ˜ฆ

rotund token
#

All settings moved to preferences

late mural
#

wondering does float3 have a function similar to Vector3.distance()?

solar spire
#

math.distance

late mural
#

thanks!

late mural
#

trying to figure out the best way to optimize this: I have to do a for loop through an array of around 30 thousand length, i have to do that for loop a lot of times though in another for loop, so I'm wondering what the best combination of job types would be to get this being performant?

deft pilot
#

am i using this incorrectly?

this.tileFinishTileQuery = EntityManager.CreateEntityQuery(ComponentType.ReadOnly<TileFinishComponent>());
var tileFinishComponents = tileFinishTileQuery.ToComponentDataArray<TileFinishComponent>(Allocator.TempJob);
foreach (var tileSpawnComponent in tileSpawnComponents)
{
  // do stuff
}
#

seems to be returning nothing

#

data definitely exists

deft pilot
#

-facepalm

#

its a field on a component

#

i knew that

late mural
#

getting this mysterious message, the array is definitely 100 thousand in length though...

#

and even if the error message is telling the truth, you still should be able to get index 0 of something that is 1 in length, right?

#

found this post by Tertle, wondering does this still apply to 2021.3.11f1?

#

ignoring the error results in visual anomalies like particle's positions suddenly teleporting when they touch an object

#

could also potentially be an issue with Nvidia Flex somehow messing up the arrays, all of the demo scenes are capped to 99 thousand fluid particles at highest... (also sidenote: it is kinda insane that my gtx 750 Ti can handle that many fluid particles while still running 60fps lol)

rustic rain
#

This is a bug from 0. 17 lul

late mural
#

ah, do you have any clue what could be causing my issue then?

#

managed to work out it is either an issue with Vector4* or NativeArray<Color32>, those are the only arrays i use in the location i am getting that error from, still both should be length 100 thousand...

rustic rain
#

Attach debugger and debug it

#

Why guess

late mural
#

aha, how do i do that, im a bit of a noob im afraid lol

gentle gyro
late mural
#

found a simple solution, instead of attatching a debugger, i just removed [BurstCompile]

#

this is the real error message

gentle gyro
late mural
#

ah turns out i accidentally set my max particels to 100 thousand instead of a million, whoops

rustic rain
#

ok

#

I resolved my problem with query

#

it seems like

#

ECB in baking system

#

added component the wrong way

#

I cached entities and comp values myself and added through EntityManager

#

that fixed the issue

rotund token
rustic rain
# rotund token Details?

in my case:
I added unmanaged shared component through ECB

Filters didn't work

I added unmanaged shared component through EM

Filters work

#

doing test in new project rn

#

๐Ÿค”

#

new project works

#

Here's what I had

        var ecb = new EntityCommandBuffer(Allocator.Temp, PlaybackPolicy.SinglePlayback);

        foreach (var (kek, e) in SystemAPI.Query<BakingTempTest>().WithEntityAccess())
        {
            ecb.AddSharedComponent(e, new SharedTest { value = 0 });
        }

        ecb.Playback(EntityManager);
        ecb.Dispose();

Here's what I have now

           var query = SystemAPI.QueryBuilder()
                .WithAll<StarIndexTemporary>()
                .Build();

            var hashSet = new NativeHashSet<EntityId>(
                query.CalculateEntityCount(),
                Allocator.TempJob);


            foreach (var (starRef, e) in SystemAPI.Query<RefRO<StarIndexTemporary>>().WithEntityAccess())
            {
                var star = starRef.ValueRO;
                var ind = math.select(default, star.index, star.initialized);
                hashSet.Add(new EntityId { e = e, ind = ind });
            }

            foreach (var entity in hashSet)
            {
                using var hierarchy = em.GetAllEntitiesInHierarchy(entity.e);
                em.AddSharedComponent(hierarchy, new StarIndex { systemID = entity.ind });
            }

            hashSet.Dispose();
rotund token
#

Odd

solemn hollow
#

whats the new way to do RequireSingletonForUpdate? just create a query and require that and ignore the fact that its not checked at this point that there might be multiples?

rustic rain
#

and yeah, it creates new

#

with size of 1

#

afaik

misty wedge
#

Does the safety system not handle writing to different indices on a NativeStream in parallel?

#

It keeps giving me an obscure error

open shore
misty wedge
#

What issue related to ECS do you have?

misty wedge
open shore
misty wedge
#

Well the point of the InputSystem is to abstract away what device is being used, so I probably wouldn't do that

#

You could just have a component per player with all the input for that frame, but there are lots of different ways to do it

open shore
#

how would I set the values of the component?

rustic rain
#

in a system

open shore
#

yeah I get that, I just don't know how to read input values of multiple users. I've never used the input system for projects with coop

misty wedge
open shore
#

ok

rustic rain
#

or any?

open shore
#

not a set amount, it should be between 1 to 4

rustic rain
#

well, what you can do

#

is to keep around a singleton array

#

size of 4

#

type would be struct of inputs

#

that your game need

#

smth like

open shore
#

yeah I don't like that

rustic rain
#

struct Input{
bool rmb;
bool lmb;
bool jump;
}

open shore
#

It'd feel better if it were a component per player

rustic rain
#

well

#

can be done too

#

you'd have to register generic components

#

per player

misty wedge
#

I'd assume each player has the same inputs

#

Since they use the same actionmaps(?)

open shore
#

since I'm planning to have multiple character types that can be controlled, and each type has a different input strucure... and players can change their type during the game

rustic rain
#

I don't get why have singleton component per player

#

though

#

it's as good as hardcoding stuff

misty wedge
#

Ah, nevermind then

misty wedge
rustic rain
open shore
#

yes

rustic rain
#

then

#

it's easy

#

just have an entity with input component that controls all character related systems

#

and separated by SharedComponent

open shore
#

but I want to make a structure that would work with lan/multiplayer. Kind of like unreal's framework

misty wedge
#

That's a lot more complicated than local coop

rustic rain
#

struct PlayerIndex : ISharedComponent{
public int playerIndex;
}

rustic rain
misty wedge
#

What you want to do usually works the way that the local coop client "owns" all local players, and everything else works as normal

#

Since you have the possibility of multiplayer though, and want to play local only, you need to start a local gameplay server (with 1 client, the local coop session, which could have e.g. 4 players)

open shore
#

I'll explain the framework that I have in mind (heavily taken from unreal):

  • Every real player has an entity
  • The scene is filled with entities that represent characters. Those characters may be fundamentally different (for example, a snail character and a rabbit character with different controls and movesets).
  • The player entity can "possess" one or multiple characters. The player will feed its possessed characters with input every frame.

What makes this powerful is that the "player entity" doesn't have to be a local player. It can be a player from another computer or even a CPU with programmed logic.

#

I somehow want to integrate unity's input system into this

misty wedge
rustic rain
#

ngl, feels like the most simple solution: just run another client for another hotseat player xD

#

and just code normal network multiplayer

open shore
rustic rain
#

I remember that feature from castle crashers I think

misty wedge
open shore
misty wedge
#

Then you probably just want multiple owned "player" entities for a single client session, and that session collects input for all players and sends it to the server

open shore
#

exactly

misty wedge
#

So with what exactly are you having issues?

#

Since there are a lot of design decisions that need to be made here

open shore
#

getting the inputs... I've never done local coop before

misty wedge
open shore
#

yeah I'm trying out what you wrote there

#

it looks like it'll work. The only thing that I'm not getting is how to associate a User with an entity

#

Do InputUsers have Ids? And if so, would it be a good idea to store that in a component?

misty wedge
#

I mean you can just associate an integer with each player

#

But it seems it does have a uint id

#

So just use that I guess

open shore
#

oh great then I'll use that

#

thanks for the help

misty wedge
#

What networking solution are you using?

open shore
#

not sure yet. I might make my own. I don't want to worry about networking for now, I just want to make sure that I have a framework that'll make it easy to implement networking in the future.

#

I know ECS has a networking solution but I haven't looked into it yet

misty wedge
#

The reason I'm asking is that depending on how you implement it, you may need to send your input to the server, so something to maybe keep in mind

karmic basin
#

You should worry about networking right now if you know you'll have it in the future

misty wedge
#

I agree

#

e.g. Unity's solution will require some architectural decisions in regards to input handling

open shore
#

I have a general idea of how my networking will work so I am designing a system that'll work with that.
I'm just prototyping for now and I'm going to tackle the networking issues before I start finalizing the project so I'm not to worried about that.

misty wedge
#

If you build it yourself you can do what you want, but like I mentioned, unity's netcode will require some special stuff for inputs

open shore
#

I'll read about it

misty wedge
#

The gist is since it's fully authoritive, you send your inputs to the server instead of updating the clients position

viral sonnet
#

sounds a bit too ambitious. for coop an authoritive server is overkill. p2p and a relayserver is what most use with host migration. steam relay works great for this.

misty wedge
#

Also afaik there is no p2p multiplayer solution for ecs, so you'd have to roll your own

viral sonnet
#

i don't think a couch coop with online multiplayer has any right to invest into cheat prevention unless enough people play it. cheat prevention isn't just a coding problem, it costs money and requires lots of server structure

misty wedge
#

I don't really find fully authoritive server models very complicated to work with, netcode for entities has been really nice on that front imo

#

The hard part there is reducing the effects of ping

viral sonnet
#

yeah, you need at least 3-4 servers minimum

misty wedge
#

Well, you can just let people host them, you'd need a NAT punchthrough service though if you don't want people to forward ports

viral sonnet
#

might as well go through steam relay

misty wedge
#

I've never used it so I can't comment, I only know the "usual" struggles with these things

#

I'm assuming it also locks you to steam

viral sonnet
#

there's a community project for unity.transport to go through steam relay

#

sure. when on pc you have to be on steam anyway

misty wedge
#

guess other platforms don't exist anymore

viral sonnet
#

if you follow any figures, no there aren't ^^

misty wedge
#

A lot of people are hobbyists not making games for money ๐Ÿ™‚

viral sonnet
#

well then don't make a multiplayer game

misty wedge
#

Why not?

viral sonnet
#

because it costs money

misty wedge
#

No it doesn't

#

Let people host the server

#

Ever played minecraft? Terraria? Factorio?

#

none of those games have statically hosted servers

viral sonnet
#

yeah true ๐Ÿ˜„ those games are the best of the best so people put up with anything

#

people don't put up servers for a couch coop that has 5 minutes round (i think)

misty wedge
#

Who said it lasts for 5 minutes?

viral sonnet
#

noone, i made up a strawman ๐Ÿ˜„

misty wedge
#

๐Ÿ˜…

#

I think at the end of the day it depends extremely on what you are working on

viral sonnet
#

point is, better worded, the game has to be worth it.

misty wedge
#

I wouldn't even say that, some people just want to make multiplayer games, even as a hobby

#

even if there aren't millions of people playing it

viral sonnet
#

afaik those are mostly p2p games

misty wedge
#

None of the ones I mentioned earlier are

#

There are also AAA games that are P2P, so I don't think there is a huge generalization you can make

viral sonnet
#

i don't know any p2p game that doesn't use a relay server. the security concern of seeing ips over others was just too big

misty wedge
#

A P2P game using a relay server is still a P2P game

viral sonnet
#

true but only because we have no better abbreviation for it. technically there's nothing p2p going on when all peers connect to one node

misty wedge
#

I'm specifically talking about P2P vs an authoritive server. Technically speaking you are right, if I host a client and server on my machine, we are just two "peers", but it's still server authoritive

viral sonnet
#

what's among us using for networking? do you know?

misty wedge
#

I'm guessing mirror, but I have no idea. It uses steam's API for networking though since iirc you didn't need to forward anything

#

Or they may have their own NAT punch through service, but I doubt that

#

But the Unity.Transport integration for steam relay sounds cool. Especially since unity now finally has a unified networking system that is (hopefully) here to stay

viral sonnet
#

Tbh, I'd like to make a talk/big blog post about this because it was a really nice way to scale and grow from "I want to host this on a free cloud instance" to "I now am popular enough to have to deal with hackers" to "whatever Among Us is now".```
#

I use https://github.com/willardf/Hazel-Networking on Linode. Tbh, it's extremely cost-effective for me(ymmv), but I generally suggest people use Photon until they have some success.

misty wedge
#

There's another recent big game that attempted this, the "P2P authoritive" system, but they had issues with hackers aswell iirc

#

Ah alright, so not mirror after all

#

Never heard of that one

#

I'm not sure if the souls games do any authoritive calculations, hackers have always been an issue there too

viral sonnet
#

the point i want to make, for a long persistent game like Minecraft, Terrario, Factorio -> authorative server. anything else, short 30min rounds, non persistent world -> p2p with relay servers

misty wedge
#

Definitely, like I said, it depends on the project

#

I was only saying that just because you are a hobby dev / small project doesn't mean you can't work on an authoritive multiplayer game ๐Ÿ™‚

viral sonnet
#

DS has relay servers too but yeah, their anti cheat sucks. i think it's p2p in the classic sense. no authority or shared authority that suppresses hacks/cheats

misty wedge
#

They have a dedicated matchmaking server but after that it's all P2P

#

I can't remember the name of the project I'm thinking of...

#

iirc it is also fully P2P but they somehow attempt to check for cheating, I have no idea how it works though

#

Elite Dangerous is also P2P from what I can remember

viral sonnet
misty wedge
#

Yep, servers are expensive after all

dense oriole
#

uhm, I have a (probably) stupid question -- what is "ScheduleParallel" equivalent in Entities 1.0 foreach?

rustic rain
#

or codegen free IJobChunk

solemn hollow
#

i really like the new bakers but man it is annoying to replace 100+ conversions :S

viral sonnet
#

100+? damn. i had exactly 64 to update. took me 4-5 hours

#

not counting when i moved all bakers to a seperate namespace ๐Ÿ˜…

solemn hollow
#

i didnt expect to have so many myself. they built up over the years. i do have a lot of small modular components. when i find the time i should combine them to more useful authoring components.

misty wedge
#

Any ideas why this is failing code gen?

#

Already tried restarting the editor, same issue

#

Weird, if I put it above the job struct creation, it works

#

Are there special cases where this isn't allowed @proud jackal ? otherwise I'll try and write a bug report, it works in another job for me for some reason

proud jackal
#

Look at the front page for known issues ๐Ÿ˜„

misty wedge
#

Front page? Of the entities forums?

proud jackal
misty wedge
#

Ah, I saw it. My bad

proud jackal
#

Yeahh.. This one ๐Ÿ˜›

misty wedge
#

The job where it works is an IJobParallelFor so I'm guessing that's why it works

proud jackal
#

Yup, if you look at the sourcegened result for the system, it's because we have to do nested replacements for IJobEntity (which is what caused the error)

misty wedge
#

Also something else I was wondering, is it required to put [NativeDisableParallelForRestriction] when writing to a NativeStream in parallel or is this somehow related to the memory leak issue?

proud jackal
#

Good question, this is outside my area, but I guess the docs don't say a thing about it?

misty wedge
# proud jackal Good question, this is outside my area, but I guess the docs don't say a thing a...

Yeah that's why I was confused. Disabling the safety stops throwing the error and everything works fine, otherwise I get a bunch of these cryptic error messages:
ArgumentException: Index 4 is out of restricted IJobParallelFor range [2...2] in NativeStream.
ArgumentException: Index 12 is out of restricted IJobParallelFor range [6...6] in NativeStream.
ArgumentException: Index 10 is out of restricted IJobParallelFor range [5...5] in NativeStream.
etc

raw mica
#

@misty wedge My guess is that ActiveChunkTrackingComponent contains a NativeContainer (in this case a native stream perhaps?). We are working on improving the messaging around this error as it's non-obvious but ComponentLookup is a NativeContainer itself, so when a ComponentLookup is used to fetch a component with a NativeContainer in it, this not allowed by the safety system currently. Since the NativeContainer inside the component isn't seen by the safety system at schedule time, it looks like you're accessing a native container that was never prepared for access on job threads and you start getting less helpful/misleading safety errors. Disabling the safety system is fien to do in this case but you do also accept all the extra care needed to ensure you do not access the NativeStreamin in your component in parallel in a non-readonly manner

rotund token
#

From memory native stream range nearly always breaks safety from how it's setup and needs parallel safety turned off unfortunately.

#

I think there's a method public void PatchMinMaxRange(int foreEachIndex)

#

On the writer you can use if you want to keep the rest of safety enabled while overriding the min/max range

dense storm
#

Does [RequireMatchingQueriesForUpdate] includes [WithAll(typeof(SomeTag))]?

drowsy pagoda
#

What is the equivalent to ConvertToEntity component in ECS 1.0?

#

I'm trying to convert and inject go outside a subscene

viral sonnet
copper sorrel
#

Entities 0.51 Raycasting

drowsy pagoda
#

I see. Thx

drowsy pagoda
#

๐Ÿค”

viral sonnet
#

do you need a hybrid object or why do you need that?

drowsy pagoda
#

yeah I do.

viral sonnet
#

consider this way. convert what the entity representation should be in a subscene. either give it some tag or put it in an IComp container so you can query it and get the prefab entity of it. the GO, which is then just a graphical representation, on awake can then instantiate the prefab entity. it also works the other way around.

dense storm
#

How expensive is entityManager.GetComponentData<CompData>(entity) to use in Update loop? is it as bad as go.GetComponent<Comp>()?

drowsy pagoda
rustic rain
#

Or array indexing

dense storm
#

Ok thanks!

rustic rain
#

What it does under the hood:

  1. array access by entity index to get chunk of entity
  2. little calculation of chunk offset (also includes array access)
dense storm
#

Where in the samples can I see how to use EndCommandBuffer in systems?

#

If anyone ever come across one

#

Bc all tutorials about it is outdated.

#

Need to destroy entity, and I heard its better to do it at end simulation buffer

#

But getting this error when using with jobs ```the type Unity.Entities.EndSimulationEntityCommandBufferSystem is a managed type and is not supported``

#

But I can use normal ECB with jobs properly

rustic rain
dense storm
# rustic rain What do you want again?

I read that destroying entities should be done in end simulation command buffer, not the regular one? Idk I'm confused about the whole concept so I'm looking for the usage.

misty wedge
chilly crow
#

is there a nice way to force a gameobject to bake? I have an editor script that procedurally adds a child to a gameobject but it's not baking it until I close/open the subscene

rustic rain
#

baking is done in one run

chilly crow
#

๐Ÿ‘€

#

how does the baking preview work then?

rustic rain
chilly crow
#

I don't get it ๐Ÿ˜…

#

I have Live Baking enabled, so it does run through the bakers without waiting to close the subscene

rustic rain
#

only during run

dense storm
#

Importing com.unity.physics gave all of my systems error SGJE0010: IJobEntity.Execute() parameter 'transform' of type LocalToWorldTransform is not supported.

#

Anyone knows why?

rustic rain
#

physics only supports old transform

dense storm
#

So I just have to wait till it supports it?

rustic rain
#

or use old transforms

solemn hollow
spice vale
solemn hollow
#

oh it didnt do it for me

dense storm
#

Okay got it all sorted out, thanks!

wicked trout
#

For anyone interested in this info: Unity 2022.2.0.b10 + Entities 1.0.0-exp8. If you compile a game in ILCPP2 and you have a subscene in your scene the game will crash. There is a workaround though, instead of using a subscene to instantiate entities use the EntityManager.CreateEntity() function.

#

This links shows how to instatiate Rigidbodies at runtime for example without a subscene

#

I hope this helps somebody

#

(Specially considering that my game runs at 40 FPS when compiled with Mono and it runs at 70+ FPS with ILCPP2)

#

(I have configured ILCPP2 to only compile for ARM 64 on Android)

solemn hollow
#

How do i move a package to the asset folder without breaking Components on Prefabs?
2DAnimation package has an error with entities 1.0. When i move the package to my project all bone setups on my prefabs are gone...

radiant berry
#

Hello, i was wondering how in DOTS you would design things differently?
Like for example you have a pickup class that get's inherited by classes doing specific logic for their pickup.
Like if you picked up health it gives the player a certain amount of health or if you picked up Ammo the player gets some ammo.
Is it still possible to have some kind of inheritance like that where you have 1 main class having the basic logic and then the inherited classes doing specific logic?

solemn hollow
#

@radiant berry you would probably split it into multiple systems. 1 system doing the "basic logic" for pickup like e.g. destroying the pickable item and another System operating on a other component that adds health. Composition over inheritance

spark quail
#

There is no inheritance in DOTS. it's not an OOP style

rustic rain
#

in fact, there's practically no classes in dots

#

mostly structs

#

๐Ÿ˜…

solemn hollow
#

sure you can use inheritance. You could have a BaseSystem handling the PickupLogic and some item specific systems that inherit from the BaseSystem. its just not the best practice.

spark quail
#

What would be the point of that? Wouldn't you have one system handling all pickuplogic, not just for specific items

#

DOTS isn't an object-oriented approach; it's a data-oriented approach... hence DOTS - Data-oriented technology stack

#

so OOP principles such as inheritance are going to be of limited use, or even harmful

solemn hollow
# spark quail What would be the point of that? Wouldn't you have one system handling all picku...

I would probably have a System per specific item logic and 1 System for the shared item logic.
one system that handles something like a PickUpItem Component.
another specific system queries for WithAll<PickUpItem>() and HealOnPickUp Component for example

inheritance is just a tool. use it in the right places. even in OOP composition beats inheritance. its all about using the right tools for the job.

spark quail
#

Perhaps, but only by coincidence. A system conceptually isn't an object. It's just because DOTS is written on top of C# that means you're still technically using objects. You have to design in a different way. Everything is composition because you're working from the data up

rustic rain
#

ISysteem is not even an object

#

just a tiny bit of allocated cache

#

technically, Unity invented c++ inside C#

spark quail
#

Right

#

ComponentSystem is still a class though?

rustic rain
#

think it was deprecated

#

SystemBase is base system class

#

and yeah, it is a class

#

but deeper we dive into Entities

#

the less SystemBases we need

#

some seniors in this channel reported converting most of their systems to ISystem

solemn hollow
#

didnt have the time yet to convert everything but its one of the next things ill attempt

rustic rain
#

BRG usage is way too low-level

#

besides

#

you still have to store it somewhere

solemn hollow
#

I have an incremental baker that traverses a graph of scriptable objects that might try to add the same component multiple times based on the individual scriptable object settings. Its giving me this Error:

"Baking error: Attempt to add duplicate component VectorizablePosition for Baker Baker with authoring component UtilityDecisionAgent. Previous component added by Baker Baker"

Id like to have a TryAddComponent...
Is there any way to check whether a component was already added by a previous baker?

rustic rain
#

use Baker to add temporary data

#

and then loop over it in BakingSystem

solemn hollow
#

but the temporary data would also be the same component

rustic rain
#

not really

solemn hollow
#

the only way i see right now is to traverse the whole graph first to gather a list of all Components to add and then filter out duplicates before adding all those components.

rustic rain
#

you can any

solemn hollow
rustic rain
#

add temporary tags that are meant for your workflow

solemn hollow
#

okay ill try but i doubt it works

#

@rustic rain how do i declare temporary components? i cant find it in the docs yet

rustic rain
#

or smth like that

solemn hollow
#

ah thx

solemn hollow
# rustic rain add temporary tags that are meant for your workflow
using Unity.Entities;
using UnityEngine;

public class BakingTest : MonoBehaviour
{
}

public class Baker1 : Baker<BakingTest>
{
    public override void Bake(BakingTest authoring)
    {
        AddComponent<TempComponent>();
    }
}
public class Baker2 : Baker<BakingTest>
{
    public override void Bake(BakingTest authoring)
    {
        AddComponent<TempComponent>();
    }
}

[TemporaryBakingType]
public struct TempComponent : IComponentData
{
}```
#

temporary types still throw the duplicate error

#

my actual case is this: ```public class Baker : Baker<BakingTest>
{
public override void Bake(BakingTest authoring)
{
AddComponent<TempComponent>();
//go down in Scriptable Object Graph...
AddComponent<TempComponent>();

}

}```

solemn hollow
viral sonnet
#

yeah, that seems like the only way right now. it can be coded so the compiler doesn't complain but at the end the system can't be instantiated.

solemn hollow
#

hmm why is that? cant you make an instance with MakeGenericType and add it to the PlayerLoop?

rustic rain
solemn hollow
#

because youd need to register the actually used generic components in the assembly?

rustic rain
#

not really

#

generic components are fine registered in runtime

#

unless it's IL2CPP

#

but Burst won't compile it

#

I mean generic jobs

solemn hollow
#

huh. my jobs scheduled from generic Systembases run with burst

rustic rain
#

Generic system bases are fine

#

it's generic jobs that aren't

#

also depending on complexity of how generic it is

#

it might just be useless

raw mica
#

Indeed. This is why there are attributes such as RegisterGenericJobType and RegisterGenericComponentType We can statically determine some closed forms of generic types by scanning all assemblies (not cheap to do but makes things more convenient) however you can't always resolve generics this way such as scheduling a generic job from a generic method where the T closing the generic job comes from the generic method's T GenericArgument.

#

The specialized attributes allow us to know what special cases you have so we can generate the IL and/or pass the correct context to Burst for AOT code generation

viral sonnet
rustic rain
#

and there goes the whole point of generics ๐Ÿ˜…

viral sonnet
#

not totally, you have to implement them anyway.

#

and i prefer 2-3 lines of implementation than copy pasting a whole system + jobs

raw mica
#

Yes, my 'indeed' is specific to that generics are complex, not that they are useless (far from it!) Many cases for generics we can indeed deduce, but you do certainly run into issues with heavy generic library code that is intended to work out of box for end users. Usually they need to opt-in to a closed form using on of the "registerxxx" attributes

viral sonnet
#

i'm okay with registering or some other code overhead. are there plans to make generic ISystems work at some point? this is my current SystemBase which I wanted to convert to ISystem public unsafe partial class StatChangeSystem<TStatsConfig, TStatBuffer_Base, TStatBuffer_Final, TStatEntityReference> : SystemBase where TStatsConfig : struct, IStatsConfig where TStatBuffer_Base : unmanaged, IComponentData where TStatBuffer_Final : unmanaged, IComponentData where TStatEntityReference : unmanaged, IStatEntityReference

raw mica
#

There are not immediate plans to do so but that could change. The complicating factor is that ISystem is meant to be burst compilable and that ultimately means burst compiling instance methods which is something Burst does not support. To do so, we need to provide some custom wrapping/trampolining, assembly scanning and more RegisterGenericSystem attributes to make it work. We are very aware of the iteration loop slowness that source generators, IL Post Processing and Burst have today so we want take some care to ensure features added don't add too much more pain in this space. There are a few things going on to make improvements to iteration and once we make some more ground there we will likely have some more leeway to add support for generic ISystem support

viral sonnet
#

thanks for the answer! sounds very complicated! ๐Ÿ™‚ as long as SystemBase works i'm okay with it. having some class based systems is not too bad and the the expensive code is burstable anyway

rotund token
#

I've just resorted to generic implementation structs for isystem

#

With default generic job field to get it to schedule fine from burst

#

Works well enough

#

Is what I mean by default generic job field

#

Little gross but good enough to trick burst into being able to handle it

#

Where possible I also replaced a few generic systems with dynamic type handles (again via implemention structs and extension methods)

raw mica
#

Yeah anything that ends up being a generic job should be fine (provided you might need one of the RequireGenericJobType attribute escape hatches). The main issue is really the instance methods when it comes to bursting generic systems as Burst needs to know what T is when you refer to it as a generic field on your system etc... That part we sort out for jobs already so any shenanigans you can do to rejig your problem into "how can I make this into a generic job" should get you most of the way to bursting generic things. We certainly don't want all this hoop jumping for you though and aim to improve this area

#

If anyone is really craving generic ISystem bursted OnUpdate calls the process could be implemented in one's own ILPostProcessor cloning some of the logic we already do for handling bursting shared components with IRefCount methods but it will be fiddly and will certainly add a tax to your iteration time today

#

(I don't advise it though and would encourage moving important hot paths to bursted static functions when you can, and call them from SystemBase<T>)

solemn hollow
#

I instantiate some generic systems like this:

sysType = typeof(BaseScoringSys<,>);
         constructedClass = sysType.MakeGenericType(outputBufferComponentType, readComponentType.GetComponentType);

         object sysInstance = Activator.CreateInstance(constructedClass);
         sys = (BaseScoringSys)sysInstance;
         
         currentworld.AddSystemManaged(sys);
         var updateGroup = currentworld.GetOrCreateSystemManaged<ConsiderationUpdateGroup>();
         updateGroup.AddSystemToUpdateList(sys);

worked in entities 0.51 but it somehow broke in 1.0
The Error happens in line "currentworld.AddSystemManaged(sys);"

The Error:
ArgumentException: The passed-in Type is not a type that derives from SystemBase or ISystem

#

__
BaseScoringSys Inherits from Systembase

rustic rain
#

to add systems from system list

solemn hollow
rustic rain
#

smth like this

#

it contains static method

#

to add systems to world

solemn hollow
#

".AddSystemsToRootLevelSystemGroups();"

rustic rain
#

yeah

solemn hollow
#

thanks! seems to work. still a strange error. id expect both ways to work

viral sonnet
#

someone on the forum figured it out how to serialize the enabled state of comps. close the subscene ๐Ÿ˜…

rotund token
#

... ๐Ÿ˜…

#

I keep getting surprised that everyone leaves their subscenes open

#

Had a script in 0.51 that would force quit play mode if a subscene was open because it just broke netcode ghosts

#

This seemed fixed in 1.0 so removed the script but habit just has me always closing them

#

So I've just avoided so many random issues people seem to have

#

Considering these issues though, sounds like I need to bring the script back!

viral sonnet
#

tbh, i was under the impression it doesn't even make a difference ^^

rotund token
#

It's what causes the physics to fall through floor a lot of people have issues with

#

From a brief guess / look I'm not sure the baker systems run in this state

viral sonnet
#

oh that's also related to subscene open. hm

rotund token
#

Though I have not investigated enough to say for certain

#

But if you look at live baking state it doesn't include changes from systems

gusty comet
#

Does ComponentLookup heavily pollute the cache with each access?

#

Feel like it's inevitable to use ComponentLookup to basically pass data between entities

#

I avoid using Component/BufferLookup in constant-frame operations, and try to make most interactions event-based, but with thousands of actors, there's going to be dozens if not hundreds of Lookups every frame

viral sonnet
#

and try to make most interactions event-based
What's that? Creating entities?

rustic rain
#

Shouldn't make it a way too big of a deal

viral sonnet
# gusty comet Does `ComponentLookup` heavily pollute the cache with each access?

hard to say, not every lookup is equal. i've profiled a lot and some lookups were absolutely destroying performance and some were really fast. it's really dependent on the memory layout, memory locality and internal cpu optimizations. there's no strict rule other than avoid them were possible but don't feel bad if you can't and never write additional data just to prevent a random access. unless the write is used for a persistent acceleration structure no write will ever be worth it.

haughty rampart
#

are you sure? i've finally been able to get to work on it and, while unity doesn't throw me any errors and visual studio correctly shows me the generated code, unity itself does not seem to find the generated code.
i've tried importing my old generators, those work immediately without problems.
maybe i'm just missing something ๐Ÿค”
thanks in advance

long adder
#

Please, I want to change the parameters in the _schedulepremovejobs_b7_0 method. It is a method in the internal class.

Its position is classAIMOVESYSTEM_SERVER.CLASSC._SCHEDULEMOVEJOBSB7_0

My mistake, can you help me point out? thank you

dense storm
#

How do I get TransformAspect.Lookup's Entity?

deft pilot
#

is it cheaper to destroy an entity

#

or remove a component

#

i'm assuming its to destroy an entity

#

also can't find how to rate limit one of my systems any advice?

haughty rampart
# deft pilot is it cheaper to destroy an entity

depends. in most use cases removing a component, but it will incur a structural change. but it's definitely the better choice when you want to keep the remaining entity around and in working state. if you just want to temporarily get rid of a component, you can also just disable it, and later easily reenable it, both of which will not incur any structural changes

deft pilot
#

wtf.

haughty rampart
deft pilot
#

oh

#

okay

#

can't goto 1.0

#

doesn't have 2d support

#

for like half the crap

haughty rampart
#

i'm not sure what 2d support in pre 1.0 you're referring to anyway

dense storm
#

Perhaps Tiny's 2D Physics

deft pilot
#

2d physics needs a hack to work

haughty rampart
#

don't think tilemaps work with native pre 1.0 either

deft pilot
#

yeah it didn't natively work

#

but atleast the editor was okay with the it and it still loaded if you monob'd the changes

#

in the new unity

#

it just doesn't recognize any of the rule tiles

#

non of the editor features work

#

its just a blank file (rule tiles etc...)

#

and doesn't render at all

#

so i'm waiting for it to update to support it

dense storm
haughty rampart
#

maybe it just messed up the migration for you cause that doesn't seem like something that slips through

deft pilot
#

yeah i kr

#

don't think so

#

others have tried

#

and couldn't get it to work either

#

if you figure out something let me know

haughty rampart
#

sure. am not really working with 2d, but i might take a look at it

dense storm
#

Think back the times before Unity get 2D Physics and other 2D Features.

#

You lock an axis constraints

#

And call it 2D

haughty rampart
#

cause it is

#

pretty much

deft pilot
#

lol yeah

#

like worse case scenario

#

i create my own tile grid stuff

#

and fake 2d in 3d like unity does

#

but reinventing the wheel just sucks

haughty rampart
#

either way, you'll have to change a loooot of code when you'll be upgrading

dense storm
#

What's the equivalent of TransformAspect.Lookup's .HasComponent(e)?

haughty rampart
#

equivalent in what context

dense storm
#

I need to get the lookup's entity

#

Or even other components it has

#

Previously I can do ComponentLookup<LocalToWorldTransform>.HasComponent(e)

haughty rampart
#

there's SystemAPI.[lookup something]

deft pilot
#

but anyway how do i deal with simulation speed?

#

like trying to figure out lets say i want to spawn something every 60 frames/so trying to target 60fps 1/s - but the fps is like 200 - you cant clamp the fps easily and you shouldn't

#

cause technically you can do that in monob

#

you just wait at the end of every frame to try delay rendering

#

and aim for a targeted fps

#

main reason is for multiplayer games the only way i'm considering to keep sync is via lockstep

haughty rampart
#

i mean you can always just keep track of a float and increment it by SystemAPI.Time.DeltaTime and return if float < [number]

deft pilot
#

that doesn't work thou

#

it would desync

#

best you could do it something like

#

currDelta - 1f

#

but that would still make the spawner

#

spawn late

karmic basin
#

Can't you use Systemgroup rate manager ?

haughty rampart
deft pilot
#

na

#

i'm not touching unity networking

haughty rampart
#

that's either dumb or foolish

rotund token
#

Transport is fanatic

haughty rampart
deft pilot
#

maybe it is

#

but i already have my own networking library

haughty rampart
#

then look at transport and just copy what you need

deft pilot
haughty rampart
deft pilot
#

thats assuming

#

there is a server

haughty rampart
#

do NOT do p2p

deft pilot
#

its not p2p

#

but no one is auth

#

so i guess its p2p

#

in that sense

haughty rampart
deft pilot
#

but there is a "host"

#

that determines desync

#

its lockstep so everything is simulated client side

#

via data

#

states aren't passed across

haughty rampart
#

== cheating infested

deft pilot
#

that would just desync

#

if lets say you try to buy an item that you can't

#

and you send data that you attempted to buy item id 1

#

and your hash of your inventory is now whatever

#

and it gets compared with the host sides hash

#

it now no longer matches

#

and clients desync

#

but lets not divert this discussion as to why you want me to use unity networking

haughty rampart
#

and if you do a legit action and have package loss, you just lost whatever you have been doing

deft pilot
#

eh...

#

packet loss in tcp can be replayed

rotund token
#

You just have 2 friends join a game and hijack it from host

deft pilot
#

host is the auth in hash comparison

haughty rampart
#

tcp is majorly unsuitable for most game actions

deft pilot
#

you can also do that in udp

#

but its more flaky i guess

#

tcp isn't that slow that it matters anyway

rotund token
#

So it's server authorative then

deft pilot
#

yeah

#

but not in the traditional sense where clients send actions

#

and server sends states

haughty rampart
#

ahemm.....'tcp' and 'not slow' in one sentence is straight from hell XD

rotund token
#

Therefore the server is keeping the timer

deft pilot
#

not exactly

#

you can be behind in timer

long adder
haughty rampart
rotund token
haughty rampart
#

yeah, my question

deft pilot
#

your data sent across for "current action" has a timer of -1

#

your client will try its best to keep up with simulation

#

but that doesn't matter if you are behind or not

#

(as long as you aren't in front)

rotund token
#

So it's not lockstep

#

I'm so confused

deft pilot
#

nothing is exactly lockstep thou

#

cause of delay

haughty rampart
#

seems majorly wonky

deft pilot
#

you just have buffered things to simulate/process

rotund token
#

What is the benefit over just having a single host

deft pilot
#

less data sent across the wire

haughty rampart
#

who cares