#archived-dots

1 messages Β· Page 143 of 1

loud matrix
amber flicker
#

Hmm My bad - there probably is a way - maybe Run? Afk atm

loud matrix
#

This physics engine is confusing me to no end without being able to find the source to see any per function docs. Apply a impulse to a entity with no gravity and no damping. On the z axis 1f * deltaTime and it gains 10f velocity a second not 1f as one would expect.

graceful mason
#

Im not sure what I did wrong but I copied hte sample again and it works πŸ˜„

loud matrix
#

@mint iron Did you say you were using Unity.Physics?

loud matrix
#

After all this time I'm finally able to see InverseMass = math.rcp ... sooo it's not inverse it's reciprocalMass some of the weird ass results I've been seeing are starting to make sense

storm ravine
#

You’re using light theme (jk πŸ˜…) - you need to put your code in a class that extends SystemBase to use Schedule etc - might be worth checking out the samples quickly first.
@amber flicker You don't Job's itself independent from ECS. You feel free run them in monobehaviour land without any problems

graceful mason
#

In ECS, is there an multiDim array type?

storm ravine
#

NativeMultiHashMap

#

Or write by yourself

graceful mason
#

public int[,,] terrainMap = new int[ChunkData.ChunkWidth, ChunkData.ChunkWidth, ChunkData.ChunkWidth];

storm ravine
#

If you want something like that, you need write your own native container, it's pretty simple, just don't forget wrap it to tests πŸ™‚

graceful mason
#

I got it working use an 1d DynamicBuffer of ints

#

which I convert XYZ to i

storm ravine
#

Yep you can do that too

graceful mason
#

just not sure it feels rightr πŸ˜„

storm ravine
#

It right

#

flatting multidimensional arrays it's fine

graceful mason
#

it felt bad as I use my Convert XYZ to I function thousands of times

storm ravine
#

Point was if you want it to be like [,,] with convenient accessors etc. you need native container or custom struct around flatten array πŸ™‚

graceful mason
#

in my old style unity project, I just grabbed direct by index which I know

#

I should write my first ever test one day ..

storm ravine
#

Well your Convert XYZ is just x + w * (y + d * z) not so much work which can be replaced to math.mul(w, math.mul(d,z,y) , x) which will be compiled to only add instructions (2 per 1 multiply) instead of multiplication.

#

But of course all depends and should be profiled

graceful mason
#

ok thanks a lot

#

this ECS is hard ot get started, but I feel the power although I have nothing working jkust yet πŸ˜„

glass tiger
#

is it safe the update the dependencies of the 2D Entities package to their latest versions?

bright sentinel
#

You can try and see if anything breaks πŸ˜„

#

Usually it shouldn't be a problem, but I don't think they guarantee such things

glass tiger
#

I looked into it a bit more in the forums and it seems like it's not possible atm, they're planning to merge the 2d entities package + 2d foundational dots features with the rest of project tiny soon

#

so it seems I just need to wait for that to happen, hopefully it'll be soon

wide fiber
#

You can get the radius from the BlobAssetReference<Collider> SphereCollider that's created for the entity. Should be accessible from PhysicsCollider
@loud matrix I can't find it, how is the field called? There is no Radius field inside the BlobAsset and inside the Collider (for now I've found inside the mass properties the volume, and with the volume I am calculating the radius)

undone torrent
#

Hi there, is there a way to convert gameobjects to entities without running playmode ?

#

that is on editor mode

#

and using authoring script on the gameobject

#

if someone could answer that it will be a happy day for me πŸ™‚

tawdry tree
#

So you want them to become entities while in editor mode?

wide fiber
#

Where can I ask a "math" question?

Basically I have a circle in a grid and I want to get all the nodes in the grid that are touched by the circle (I've made an example, the red dots should be the one that I get from the function)

#

I thought it would be easier, but the circle can be of any size and it can be in any position

#

I have already made a function but there are some scenarios where it doesn't work

tawdry tree
#

No really a dots question, no, but to me it sounds like you need to check for circle overlap on _each of the corners. Any corner with overlap you can mark all four nearby squares as in contact

wide fiber
#

Yeah that's similar to what I was doing but there is a problem (I can send other examples to make you understand what's the problem). This question is not DOTS related so I've asked it inside #πŸ’»β”ƒcode-beginner

amber quail
#

i'm looking over the dots samples. is there any way to pre-compile all of them at once? so i don't have to wait before each one is being burst compiled before running it?

tawdry tree
#

ctrl+shift+B in Visual Studio should build all projects, not sure if that uses burst properly, but I assume it should. Other IDEs should have similar commands.

undone torrent
#

@tawdry tree yeah thats it i want them to become entities while in editor mode

#

i really want to use ecs systems, component and entities while editor mode is on

#

i read about DOTS mode on editor but not sure that is what i really want

#

okey i think i found the solution

#

I just have to activate DOTS->Live link mode -> Live Conversion on Edit Mode

#

my next question , and i really sorry cause it seems i only know to ask. Its if subscene will respect authoring monobehaviur script added to a gameobject when it convert it to entity

#

thx really much guys

thorny halo
#

hello, is there a way to visualize native container data in the inspector? ATM I'm writing an additional debugger for each script that uses one which is an enormous hassle.

rigid cosmos
#

Is there a way of having a nativecontainer inside a blittable struct? Specifically I need to have an array of integers

zinc plinth
#

nativecontainers aren't blittable afaik @rigid cosmos

storm ravine
#

Is there a way of having a nativecontainer inside a blittable struct? Specifically I need to have an array of integers
@rigid cosmos through pointers.

amber flicker
#

or (in case you're unaware of their existence) there are DynamicBuffers for array per entity

zinc plinth
#

^

wide fiber
#

Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..

gusty comet
#

you can create your own method for that

zinc plinth
#

just do an extension method ThonkEyes

rigid cosmos
#

@storm ravine how would one go about creating a pointer? I've not used them in C#, no clue where to start

storm ravine
#

Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..
@wide fiber float3.xz, float3.xy, float3.yz, etc.

rigid cosmos
#

@wide fiber public static float3 ToFloat3(this float2 target)

gusty comet
#

^

rigid cosmos
#

Or that ^ πŸ˜‚

zenith wyvern
#

Float3 constructor will accept a float2 as one of the parameters. You need to provide the other value so it knows what you're trying to do.

gusty comet
#

float2 float_2 = new float2(0, 0); float3 float_3 = new float3(float_2.x, float_2.y, 0);

#

guess theres alot of ways

storm ravine
#

Do not reinvent the wheel.

#

@storm ravine how would one go about creating a pointer? I've not used them in C#, no clue where to start
@rigid cosmos read source code of native container for example. Or plain C# documentation about pointers, low level memory manipulation etc.

rigid cosmos
#

Alright thanks, will do!

storm ravine
#

Why isn't there a "method" that automatically converts float2 to float3, I hate the fact that I have to create another variable float3 because I can't cast it..
@wide fiber You cant cast it by obvious reasons, how it should be casted? To float3(x, 0, y) or float3(x,y,0) or float3(0,x,y)? Someone often using float3(x, 0, y), someone float3(x,y,0).

loud matrix
dawn badge
#

maybe

loud matrix
#

only takes 1 second to get that fast too

naive parrot
#

You cant cast it by obvious reasons, how it should be casted? To float3(x, 0, y) or float3(x,y,0) or float3(0,x,y)? Someone often using float3(x, 0, y), someone float3(x,y,0).
@storm ravine same as Vector2/Vector3 casts?

graceful mason
#

I guess it would cast ... x =x y=y drop z πŸ˜„

craggy orbit
#

is there a reason that the contents of a subscene wouldn't appear in a build? the subscene works fine in the editor but when using it in a build it's like nothing exists. im using hybrid renderer v1 and have tried building with the subscene both added and removed from the build settings, with the base scene there. without the subscene everything renders correctly. here's the subscene component

storm ravine
#

@fleet hemlock you shouldn't compare math lib with Math\Mathf libs. Because math lib written with shader like syntax, and behaves absolutely similar. They looking to shaders core math behaviour when they write math. And in CG you also can't cast them implicitly πŸ™‚ Same as in shaders you can implicitly cast floatt to any - float2\3 but not float2 to float3 and all of them have the same float2\3.xx, float2\3.xy, float2\3.yx etc.

warped trail
#

@craggy orbit do you build with new build tools or old one?πŸ€”

craggy orbit
#

build tools? that might explain why i'm having trouble πŸ˜… never even heard of them

#

oh are those the Platform packages?

warped trail
#

yes

craggy orbit
#

ah. i'll give those a try then. i remember getting lots of errors be just installing them a few months ago. maybe they've been fixed

warped trail
#

just copy buildconfigurations from ecssamples

craggy orbit
#

the way i was spawning prefabs in the subscene had to be changed but it's all working now, thanks!

outer swift
#

I want to destroy an entity using a command buffer

#

How do I get a valid entity?

#
    {
        Camera camera = Entry.camera;
        float distance = camera.transform.position.z;
        Rect rect = camera.rect;

        EntityCommandBuffer simulationCommandBuffer = simulation.CreateCommandBuffer();

        Entities
            .WithStoreEntityQueryInField(ref query)
           .ForEach(
               (in WorldToLocal worldToLocal) =>
               {
                   float3 screenPos = camera.WorldToScreenPoint(new float3(worldToLocal.Position.xy, distance));

                   if (!rect.Contains(screenPos))
                       simulationCommandBuffer.DestroyEntity(???);
               }
           )
           .WithoutBurst()
           .Run();
    }
#

This is what I'm trying to do: When an entity goes off-screen, I want to destroy it

coarse turtle
#

Entities.ForEach((Entity e) => { cmdBuffer.DestroyEntity(e); }

outer swift
#

Yeah, but there's a condition involved

#

Oh

#

Right

#

Hm, can I get a component off an entity fetched that way?

coarse turtle
#

You can pass in the entity and its component data as arguments in the lambda

outer swift
#

Phenomenal.

coarse turtle
#

So you can do (Entity e, ref ReadWriteType c0, in ReadOnlyType c1)

outer swift
#

So Entity.Foreach(Entity e, ref WorldToLocal worldToLocal) => { /*check camera stuff*/ }

coarse turtle
#

yea pretty much

outer swift
#

πŸ‘

#

Excellent.

storm ravine
#

So Entity.Foreach(Entity e, ref WorldToLocal worldToLocal) => { /*check camera stuff*/ }
@outer swift replace ref to in as you not change that and only read from.

outer swift
#

@storm ravine Thanks, already did

#

@storm ravine While I got you here ...

#

Is there something akin to a camera in Hybrid Renderer V2?

#

I'm currently using the standard camera to check if objects are on the screen, and that feels very wrong

#
    {
        EntityCommandBuffer simulationCommandBuffer = simulation.CreateCommandBuffer();
        Camera camera = Entry.camera;
        Rect rect = camera.rect;

        Entities
           .ForEach(
               (Entity entity, in WorldToLocal worldToLocal) =>
               {
                   float3 screenPos = camera.WorldToViewportPoint(worldToLocal.Position);

                   if (!rect.Contains(screenPos))
                       simulationCommandBuffer.DestroyEntity(entity);
               }
           )
           .WithoutBurst()
           .Run();
    }
storm ravine
#

Only conversion by your self or enabling built in conversion by setting define HYBRID_ENTITIES_CAMERA_CONVERSION

outer swift
#

Any documentation on this?

#

I'll have a look at that. Thanks, @storm ravine!

graceful mason
#

anyone know how to ForEach entities witrh buffer?

#

Entities.ForEach(( ref MyBufferArray myBuff ) => { });

coarse turtle
#

ForEach((DynamicBuffer<T> buffer) => {});

graceful mason
#

Ah thanks

loud matrix
#

God I may have just sent 3 days on physics and only now discover the unit for PhysicsVeocity looks like it's units/s not units/frame

graceful mason
#

I guess thats good maybe?

loud matrix
#

Ok, no its not, I'm just going insane now. If i set PhysicsVslocity to a new float 0, 0, 1 it moves forward 1 unit a second

#

but if i add a impulse, with a inversemass of 1 so that the values would be the same it goes 1 per frame

#

Oh I don;t even know what I'm doing anymore, Never been more tempted to just delete unity off my computer

graceful mason
#

ForEach((DynamicBuffer<T> buffer) => {});
argh thats still not happening for me

#

The type 'Unity.Entities.EntityQueryBuilder' cannot be used as type parameter '

loud matrix
#

do you mean ForEach or foreach?

graceful mason
#

I just wanna make a simple system to edit this buffer πŸ˜„

loud matrix
#
        Entities.ForEach((DynamicBuffer<MyBufferElement> buffer) =>
        {
            foreach (var integer in buffer.Reinterpret<int>())
            {
                sum += integer;
            }
        });
#

foreach has become one of those questionable words with ECS as it could be the entity loop or a normal froeach

#

or both

graceful mason
#

I think its cause im mixing non buffer componenets, with buiffers

#

sactually I have no idea πŸ˜„

#

its workiong

#

Thanks

#

Ok, I muist declare the Buffer first in the list of componenets for it to work

#

Entities.ForEach(( DynamicBuffer<RequestedChunks> requestedChunks, ref ChunkLoader chunkLoader) => { }) WORKS

#

Entities.ForEach(( ref ChunkLoader chunkLoader, DynamicBuffer<RequestedChunks> requestedChunks) => { }) DOESNT

fringe sinew
#

I'm curious about one thing.

#

Vanilla unity had an interesting rewrite of the transform system in 5.4 I believe. The rewrite sped up the CPU usage when updating large hierarchies so that only those gameObjects that had important components actually received the callback.

#

So, for example, empty gameObjects will not cause any performance penalty if the parent is moved, but if the gameObject contains a collider or a meshRenderer, it will cause a performance overhead

#

Now, regarding ECS's Transform system

#

Considering that I have an "empty" entity consisting only of the basic transform components, will it incur any penalty if its parent entity moved?

vagrant surge
#

yes

#

the solution is "dont have that entity have a transform component"

#

or have it flagged as static

#

if the entity has a transform component, then you are directly telling unity systems that you want it to be updated

fringe sinew
#

Yeah, that's exactly the solution one would come up with, I was just curious

#

I can see one concrete example where it falls apart. Imagine that I have a gameObject positioned somewhere in the hierarchy that represents a pivot of sorts upon which I can look up the world transform, for example. Now such a thing won't work within ECS because the pre-5.4 style callbacks are brought back apparently.

vagrant surge
#

it is possible to do something similar-ish to the callbacks

fringe sinew
#

Without introducing some workarounds

vagrant surge
#

version IDs on the component arrays

fringe sinew
#

I meant, like, the whole process of ~transform changed -> notify all children~ thing

vagrant surge
#

thats what you can do with version ids

#

you will have an archetype for those pivot thingies

#

you can check with the ECS if their transform changed since last frame

#

and if it did, then you do whatever

#

btw, this is done at a per-chunk basis, not per-entity, but if you really want per-entity, you can store "old transform" and do comparaison

fringe sinew
#

Yeah, I just wanted to know if the transform system did stuff internally just like with pre-5.4 or if it did something interesting

vagrant surge
#

it uses those version numbers to not update what doesnt need updating

#

but im not fully sure how its internals work

storm ravine
#

Well open source code and read? πŸ™‚ Also you can look at Mike's talk about transform system, and moreover docs have pretty deep explanation how transform system group work. About exact implementation everything in all transform systems (TRSToLocalToParent, TRSToLocalToWorld, LocalToParent etc.) all based on IJobChunk with chunk version change detection. They all pretty simple, mostly 1 system with just 1 IJobChunk doing thing.

vagrant surge
#

oh wait that part is open sourced?

storm ravine
#

Of course, all packages source code in Library -> PackagesCache

#

In very rare cases it has reference to UnityEngine internal things (like BatchRenderGroup which used by HybridRenderer)

graceful mason
#

is there anyway to inactivate an entity like we do we gameobjectsd?

dull copper
#

@vagrant surge what do you mean?

vagrant surge
#

thought the transform systems were on the closed soruce side of unity

dull copper
#

like Eizen said, most packages (from package manager) are just c# code

#

well, they do have native code counterparts too

#

like, ECS is fully in c#, including all dots transform math

#

but job system is on native code and more so if you go to gameobject side

north bay
#

Does StepPhysicsWorld update in a fixed interval if you don't bootstrap it yourself, or why does it use fixedDeltaTime?
I'm using NetCode and i had to replace fixedDeltaTime with deltaTime since the update interval of StepPhysicsWorld was different on the client and server.

graceful mason
#

Anyone have any reference on entity streaming? Is it a thing?

storm ravine
#

ExclusiveEntityTransaction. This is what subscenes use for streaming under hood.

graceful mason
#

hmm, its complex to find good samples, my old code worked well just using GameObject.Inactive πŸ˜„ , for ECS do you think a suitable way could be to disable the Meshrenderer componenet?

#

(its just terrain)

#

any my ChunkLoading system, just tags these entitys with a MeshRenderer componenet when player is near

zinc plinth
#

isn't there a property on the renderer to disable it ?

graceful mason
#

yeah just wondering how best to "unload terrain" as I walk away

#

all terrainchunks are entitys, with a mesh. (I have a list of terrrainchunks I want shown)

zinc plinth
#

just have a system that somehow knows the camera bounds and check if your chunks are in it ?

graceful mason
#

yeah I got that

#

now how to make them disappear πŸ˜„

#

if there not in it

zinc plinth
#

isn't there a property on the renderer to disable it ?

graceful mason
#

Ill research that

graceful mason
#

Im too dumb to understand the docs πŸ˜„

zinc plinth
#

it's an ICD, so when you want to not render a chunk you add the ICD to your entity

graceful mason
#

Usually im ok with python docs, but still learning C# or whatnot so it can be hard. My day job is in GIS and our API docs aree insane good I now realise

#

ok that makes sense, so rather than remove the mesh and readd it, you just add this

zinc plinth
#

meshes are (afaik) shared components, it would be unholy bad perf wise if each time you wanted to not render something you had to remove a shared component

ocean tundra
#

Is there a "best" practice for native collections and resizing?

#

My NativeMultiHashMap is running out of space and i need to resize it

untold night
#

You can resize it on a thread, so you could calculate the needed space and resize the capacity as needed before utilizing it.

ocean tundra
#

what about native lists?

#

will they resize automaticly as i try to add?

#

answering my own question, no cant resize if using parallel writer

untold night
#

If you use Schedule instead of ScheduleParallel for a job that should work just fine, since it will only be on one thread it shouldn't have contention between writing and resizing.

otherwise you'll need to calculate and preallocate on a job that the writer jobs are dependent on

ocean tundra
#

i would like to caculate

#

but ill have to do the same bit of code 2ce

#

seems wastefull

#

and even then i might not need to resize

#

but i guess thats the cost of splitting the next peice of work up

untold night
#

try looking at NativeStream then. It requires a bit of setup for the number of ForEach loops (separate writers/readers basically), but then you could merge the result on an iJob to a native hash map or what have you.

I do something similar for one of my system chains

ocean tundra
#

Oooooo native stream... can they be used for networking?

untold night
#

I believe they are already

#

they're definitely used in Physics

ocean tundra
#

they may be what i need

#

basicly i loop over a bunch of stuffs, check to see if i should be sending it, if i should i write it into a nativehashmap with the id of the player to send to

#

then update some caches so i dont reloop over the same stuff next time, and dont resend same stuff

untold night
#

yeah NativeStream first then caching it in an IJob might be a better fit

ocean tundra
#

i might save that steam stuff for a optimization later

#

im already thinking about replacing ENet with Unity.Transport, when i do that i think i sawp

#

for now will go with Schedule

#

Can we use any Generics with SystemBase yet?

untold night
#

not that I'm aware of.

ocean tundra
#

lame

#

i have almost identical code, only real difference is a few types passed into WithAll<> and stuff

#

Translation VS Rotation

#

ect

untold night
#

yeah it's a bummer for sure, hope they fix it eventually

undone torrent
#

hi there

#

it is possible to authoring on edit mode ?

#

i know i ask all time same questions sorry

#

is it *

bitter socket
#

Hi guys,
I'm starting from Unity's DOTS Sample and trying to recreate a new character (different model&Animations)

I've gotten quite far, The character spawns and is able to move around, but I'm having difficulty with the custom animations playing. and I was wondering if someone else has tried succesfully something similair?

#

If so , @ me and I'd truly appreciate it!

amber flicker
#

@ocean tundra I know it's not the same but extracting a bunch of code out to static methods can be really helpful (and works smoothly with burst)

ocean tundra
#

@amber flicker Can the static method be generic?

amber flicker
#

All attempts I've made previously to work with generics in DOTS at all have failed. I rely on a significant amount of code-gen combined with static methods that take concrete types.

#

I appreciate it might not be that helpful if you were already aware of that way of working. There's also the potential option of a shared interface across components but like I said, not the same power as generics.

#

e.g. I don't think it's obvious if one was new to DOTS that you can swap out HasComponent in a SystemBase for a CDFE and pass by ref to a static method.

ocean tundra
#

CDFE?

#

And I've setup some code gen stuff too, which has been super helpful

amber flicker
#

ComponentDataFromEntity (what HasComponent/GetComponent/SetComponent use behind the scenes)

ocean tundra
#

Yea I've been using that

#

Has anyone got any automated testing setup for their project?

#

I'm looking at getting my build pipeline up and working, then i want to investigate automated testing

sudden comet
#

hello guys .. I search for a long time now .. I wonder how to reference a child GameObject of a Prefab as an Entity in a IComponentData .. to enable/disable it later .. thanks πŸ˜‰

ocean tundra
#

Are you using IConvertToEntity?

sudden comet
#

Sure πŸ™‚

#

I wonder how to get the Entity from GameObject

#

Has anyone got any automated testing setup for their project?
@ocean tundra what do you mean by automatic testing ? I did some unit test if it is what you talk about. Copying ECSTestsFixture.cs

#

Are you using IConvertToEntity?
@ocean tundra sure.. Iβ€―also tried [GenerateAuthoringComponent]

ocean tundra
#

in the IConvert... one of the paramenter (sorry cant remember which one, Conversion System??) has a method you can call, get entity or something like that

#

you pass it a game object reference which you expose as normal

sudden comet
#

GetPrimaryEntity ?

ocean tundra
#

i think thats just the root one

#

but test it

sudden comet
#

I already tried that and got GetPrimaryEntity(Object 'QuestMarker') is a GameObject that was not included in the conversion and will be ignored.

ocean tundra
#

its a child right?

sudden comet
#

yes

#

that the catch it seems

opaque ledge
#

you have to implement IDeclaredPrefabReference interface, and add your game object to method's list, then you can use GetPrimaryEntity in Convert method

sudden comet
#

No because it says it is not a prefab (as it is a child of a prefab)

opaque ledge
#

then you cant use it, are you trying to get a child entity reference ?

sudden comet
#

yes Iβ€―am

#

What is the best way to activate element of a prefab then in ecs style ? here a quest marker on a character (to give you a bit of context)

opaque ledge
#

you can use Child Buffer

#

so if your quest marker was first child of your prefab then you could do buffer<Child>(prefab)[0].Entity, which would give you the quest market entity

sudden comet
#

But it is no straightforward to get the right children (not really clean also)

#

It is a bit dirty, don’t you think ?

opaque ledge
#

perhaps yeah

sudden comet
#

πŸ˜›

opaque ledge
#

well, i never needed to do that, so idk

sudden comet
#

how would you have handle that then ? @here any other ideas ?

opaque ledge
#

i think you shouldnt use everyone or here tag πŸ˜„

#

well, i mean i probably make the quest marker a prefab itself, then when i activate it i would put it above the player's head

sudden comet
#

sorry for the here

normal perch
opaque ledge
#

tbh, using child buffer is simple and easy

#

its definitely not 'handy' as monobehaviour style, but in ECS it works like that

amber flicker
#

@sudden comet I also haven't had to do this yet. However have you read this article? https://gametorrahod.com/game-object-conversion-and-subscene/
I think you might be able to achieve what you want using something like:

{
    public GameObject itsChild;
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
      Entity childEntity = conversionSystem.GetPrimaryEntity(itsChild));
    }
}```
viral sonnet
#

What is the best way to activate element of a prefab then in ecs style ? here a quest marker on a character (to give you a bit of context)
@sudden comet In general, it's with EntityManager.Instantiate(Entity src)

#

I made a prefab factory class that converts a list of gameobject prefabs into entities.

#

With that you can pull the prefab entities for systems in the main thread update or on init

#

It's fast, no need for pooling or activating/deactivating

#

Right now, unity itself has no real means of linking converted entities and their gameobjects. so you have to make some kind of key to get them. either a int with your own Ids, a guid/string hashed to an int

#

if your job is not bursted it's also possible to just make a call to a static dictionary that has all relevant information

#

as in, directly inside the system. for jobs you'd have to get all keys for the systems in the main thread

#

@amber flicker your example is missing the IDeclaredPrefabReference

sudden comet
#

@sudden comet I also haven't had to do this yet. However have you read this article? https://gametorrahod.com/game-object-conversion-and-subscene/
I think you might be able to achieve what you want using something like:

{
    public GameObject itsChild;
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
      Entity childEntity = conversionSystem.GetPrimaryEntity(itsChild));
    }
}```

@amber flicker It does not work because GetPrimaryEntity(Object 'QuestMarker') is a GameObject that was not included in the conversion and will be ignored.

#

Anyway thank very much for you time

viral sonnet
#

eh, it's IDeclareReferencedPrefabs ... why do I copy/paste from other users? ^^

sudden comet
#

eh, it's IDeclareReferencedPrefabs ... why do I copy/paste from other users? ^^
@viral sonnet what do you mean ?

viral sonnet
#

the posted example misses this interface. you have to declare converted gameobjects with that otherwise you won't get anything from the conversionSystem

amber flicker
#

@viral sonnet not sure that's true - you don't need it for the conversion system to work

#

I think the code I posted would work if it's in a scene.. as a prefab I'm not sure - I'm expecting more stuff from Unity soon to help with the whole prefab workflow

sudden comet
#

Either way, it does not work

amber flicker
#

If you want to get an entity representation of the QuestMarker, it would seem the first problem is that it's not being converted?

sudden comet
#

it is converted .. it just that I’d like a proper mean to interact with it

#

I will probably put a TagComponent on it, or make the child register in the parent itself

viral sonnet
#

what do you mean with interact? instantiate it?

sudden comet
#

reference it when Iβ€―need to enable/disable it

viral sonnet
#

In the convert method you could write the entity to a static dictionary<string, Entity>

sudden comet
#

But Iβ€―don’ t have the Entity

viral sonnet
#

or have a static Entity in the authoring monobehaviour

#

how do you convert it?

#

you said it's converted

sudden comet
#

There is an entity in the World that correspond to the "QuestMarker"

#

But Iβ€―don’t know how to get it from the Convert method

#

I was wrong .. because Iβ€―used "convertandinject"

viral sonnet
#

is there any authoring component on the questmarker before it gets converted and injected?

sudden comet
#

no

viral sonnet
#

without any custom code you don't know where the entity ended up and you either have to get it by tag/comp or by the gameobject which you could also use if you inject it

sudden comet
#

Now that Iβ€―destroyed the entity it seems to work ..

#

I have other problem to handle πŸ˜› and need to check if is really working

wary anchor
#

Hi all, I'm getting crashes in builds but not the editor, struggling to see where they're coming from but some of the error logs hint that it could be either or both trying to access singleton components or persistent native arrays.
Does anyone have any tips for debugging this? So far I'm looking up the error.log and player.log files but the messages seem inconsistent. I didn't used to have any crashes a few builds ago, although quite a bit has changed, singleton components among them.

viral sonnet
#

have you tried with all safety checks off?

wary anchor
#

ahh good call thanks I'll try that now

#

well, yup that crashes Unity silently 😦

#

weird that it doesn't give me any errors about what is underlying this though

viral sonnet
#

there should be some output in the editor or editor-prev.log

#

a time ago my builds crashed because i had a try/catch in a componentSystem.

wary anchor
#

oh boy sorry that was longer than expected

#

ugh sorry will delete, I'm reading thsi the wrong way around

bitter socket
#

Has anyone worked with the DotsFormer Character within Dots Sample to help me with some animation issues? My Bones seem to animate (I tested this by attaching a cube directly to the bones) but my skinned mesh isn't following the animation set on the bones?

remote coyote
#

I noticed that when I explicitly create the client or server world from a system in default world (override bootstrap), I get an InvalidOperationException in ComponentSystemGroup.UpdateAllSystems due to collection was modified on m_systemsToUpdate.

#

anyone dealt with creating the client world outside of bootstrap?

graceful mason
#

I have the 1 Entity, which is the only one with a particular compnenent. Any better way to get reference to it than this?

#

WorldData worldtmp = new WorldData(); Entities.ForEach((ref WorldData world) => {worldtmp = world;});

remote coyote
#

lol, my client world has test systems in it

#

no wonder its throwing a fit

storm ravine
#

I have the 1 Entity, which is the only one with a particular compnenent. Any better way to get reference to it than this?
@graceful mason GetSingletonEntity\GetSingleton<T>

graceful mason
#

Thanks again your a guru πŸ˜„ I copying some of your codes from the forums too.

twin raven
#

Which Unity version should I download to try the latest dots stuff? 2020.2 alpha or 2020.1 beta?

amber flicker
#

Either should work fine I think

wide fiber
#

Can I make a sphere cast (Physics) without the UpdateInGroup(typeof(EndFramePhyscisSystem))?

#

It isn't a problem if the sphere cast is "older of some frames" because the physics has not been updated yet, but does it work?

wide fiber
#

I have done some tests and I think it still waits for the physics group (I have the dependencies for the physics, should I keep them?)

safe lintel
#

anyone know if can you profile inside a burst job? so far from my own attempt, doesnt seem like it picks anything up

mint iron
#

yep you can, gimmi a sec and ill remember how

#

run that and search for Job1z in the profiler and it should show up

safe lintel
#

thanks @mint iron

graceful mason
#

anyone got a good example of Authoring component, for a buffer of simple components. (more than 1 field)

mint iron
#

you want to put a BlobAsset/Fixedlist/unsafeList in a component or something?

graceful mason
#

X items, simple schemas

#

I can generate the authoring component for 1 item, but not when its in a buffer

#

as per docs: IBufferElementData authoring components cannot be automatically generated for types that contain 2 or more fields.

#

I guess this is more "GameObjectData" rather than "GameData", so perhaps it shouldnt even be entities anyway

mint iron
#

i would recommend you write a converter and use a subscene (but you could also use convertAndInject script), ill see if i can dig up an example from somewhere.

graceful mason
#

thanks man

safe lintel
#

can the markers only be used with run? doesnt appear to do anything

mint iron
#

hmmm, im not sure sorry.

safe lintel
#

yeah appears it only works with run, oh well

storm ravine
#

ProfileMarker useful, but for parallel profiling can be tricky πŸ™‚

safe lintel
#

yeah was attempting parallel profiling

dull copper
#

I've only profiled the systems

#

that's dead simple

storm ravine
dull copper
#

heh

#

yeah, they keep changing the api

#

nothing new there

storm ravine
#

They improve API

#

it's replacement for IJobForEach

dull copper
#

oh I didn't imply they did that without reasons

mint iron
#
storm ravine
#

This is what we asked in IJobForEach deprecation thread

dull copper
#

it's just, DOTS, and ECS has gone TONS of API changes so far, it moves really fast

#

I don't mean that's a negative thing for the end result, but it's not great for the early adopters (but again, it's still in preview so that's what you get)

#

I like the name :p

mint iron
#

as well as for any optional attributes placed on the OnUpdate method ([AllInQuery], [AnyInQuery], [NoneInQuery], etc.). ugh, anything with attributes always tends to turn out nasty.

storm ravine
#

Why but it's not great for the early adopters ? Nothing changed, only added convenient middle ground job replacement which will reduce IJobChunk complexity for some type of jobs which will be mess in Entities.ForEach πŸ™‚

dull copper
#

also would like if they actually deprecated .Schedule and just renamed it .ScheduleSingle for all types

#

I'm not going to get into that debate (about IJobForEach deprecation and new replacement NOT being an API change - because it is 😁 )

storm ravine
#

as well as for any optional attributes placed on the OnUpdate method ([AllInQuery], [AnyInQuery], [NoneInQuery], etc.). ugh, anything with attributes always tends to turn out nasty.
@mint iron this is why I mention in feedback explicit EntityQuery usage (and similar request for Entities.ForEach) πŸ™‚

coarse turtle
#

so is the OnUpdate like Unity's MonoBehaviour's message callbacks in a way? The method would just need to be called OnUpdate(...)? πŸ€”

storm ravine
#

Well that name definitely will be changed

#

Not suitable here

#

as systems already use that. IMO they should leave Execute for that.

coarse turtle
#

yea i agree with that

safe lintel
#

well posted my thoughts, id personally prefer to schedule them like regular chunk jobs, over using Entities.OnUpdate(job).with_stuff_.schedule

storm ravine
#

this is why I mention in feedback explicit EntityQuery usage (and similar request for Entities.ForEach)
πŸ™‚

#

They will do this in the end I guess

safe lintel
#

yeah, i also just wanted to add in my preference of not using the Entities.xxx part πŸ™‚

storm ravine
#

More similar feedback - more chances that Unity will see that is not only one person requirement and this things really needed for community

amber flicker
#

I'd much rather they directed the energy into a chunk api myself but I realise I'm probably in the minority

safe lintel
#

what is chunk missing that you would want to see?

amber flicker
#

chunk.HasComponent without the penalty of CDFE.. that's it.. then I'd be happy πŸ™‚

graceful mason
#

@mint iron those authoring scripts are complex, its insane it cant generate a GUI for you, considering it can make a GUI for BufferInts, and also a gui for MySimpleComponent. Why not smosh them together

#

thanks though, I will try to implement something πŸ˜„

storm ravine
#

@amber flicker Mmm can’t understand your problem? Maybe I miss your point. Chunk has HasComponent(ArchetypeChunkComponentType) for example. And which case you have when CDFE cost is affect you?

#

Chunk api pretty nice it self. It cover every thing I need, when I want performant scalable low level data processing, and when they added OrderVersion in last versions it become much nicer

amber flicker
#

@storm ravine SystemBase.HasComponent = 1 rand access per entity.... chunk.HasComponent = 1 linear memory access per chunk. In complex jobs it's useful to be able to switch some small logic on the presence of a tag for example. For now, I use IJobChunk but, as it's often with more complex jobs I have the issue, the IJobChunks ends up really verbose. Would be so much cleaner if you could e.g. ForEach(..optional MyTag), ForEach(..[] OtherChunkComponentTypes) or Chunks.ForEach (which is something they've mentioned doing at some point) even if they were always readonly it would still be v useful imo.

#

Or if one day they just changed the underlying behaviour of SystemBase.HasComponent to do the same, that'd be perfect.

storm ravine
#

Well Chunks.ForEach is on their radar for simplification IJobChunk. I see what you want with this message (because previous was absolutely unclear in that πŸ˜„ and not even points to systems).

#

BTW cdfe.HasComponent and chunk.Has both random memory access πŸ™‚ But yeah in chunk iteration you only check on chunk level not per entity, this is only difference

amber flicker
#

ah yes, ok that makes sense

#

it bothers me that I have a lot of code that, if I wrote more verbosely, would be quicker but it's a relatively minor issue

storm ravine
#

When Chunks.ForEach will be done it will cover your case for code clearance

amber flicker
#

yes exactly - I was saying that for me, that api has higher priority than another way to do pretty much the same thing we can already.. for me πŸ™‚

formal scaffold
#

Hmm are you using namespaces? I have made a namespace for a part of my game. Within that namespace I use Unity.Physics. But for some reason when I change my PhysicsVelocity while inside the namespace my Velocity is not updated. The system is running and when I remove the namespace i can see the changes in velocity.

I have not overwritten PhysicsVelocity inside my namespace but I think Unity confuses the namespace and PhysicsVelocity and thinks it's not the correct component. Any ideas? I would like to keep the namespace

tardy locust
#

Can you use the Unity NavMesh with DOTS?

safe lintel
ocean tundra
safe lintel
tardy locust
#

Thanks I'll check it out

graceful mason
#

is it possible to have 'big entities' in some way, or thats counter to the spirit of the system and stuff? 'Archetype too large to fit in chunk'

tardy locust
#

er

#

How many components do you have added to your archetype?

graceful mason
#

just working out where to store my mesh verts and tris etc πŸ˜„

#

I think I can just go: [InternalBufferCapacity(0)]

tardy locust
#

Can't you control chunk size?

graceful mason
#

I think 16064 is hard max due to mem allocation and stuff

tardy locust
#

hm

#

Might have to reconsider how you store your data?

graceful mason
#

but mybe tht [InternalBufferCapacity(0)] thing llocted outside chunks

tardy locust
#

Both what data you store and how your store it

graceful mason
#

I can generate it in 4 seconds, just trying to work out how to store it in memory

tardy locust
#

Maybe you could make a "LinkedList" setup with entities

graceful mason
#

lemme try this [InternalBufferCapacity(0)] thing

tardy locust
#

Every entity stores a part of the data split up into reasonable chunks

#

And a reference to the next entity that stores the next part of your data

#

Until you reach an entity that doesn't have the next reference you know?

graceful mason
#

ohh this [InternalBufferCapacity(0)] has beasted it itr looks like

tardy locust
#

beasted?

graceful mason
#

I read it stores it outside chunks, so it not so good

#

it shows all my data in the entity inspector

#

[InternalBufferCapacity(0)] public struct ChunkMeshUVsElement : IBufferElementData

#

so I think it working as good as can, just performing a biut like classic unity

tardy locust
#

Could try what I suggested too

graceful mason
#

sounds complex πŸ˜„

tardy locust
#

I'd be interested to know

#

πŸ˜„

graceful mason
#

doable but complex

tardy locust
#

Be my guinea pig damn it

ocean tundra
#

for mesh data wouldnt it be better to store it in Native Collections ?

#

i guess if its super dynamic it would help to have it attached to the entity

graceful mason
#

I think I may be, its a IBuffer of Vector3s

#

not sure πŸ˜„

tardy locust
#

Why not float3?

graceful mason
#

Im new πŸ˜„ they worked out great so far, tho not sure why I use those

tardy locust
#

I think float3 was specifically made to be used with this too

#

Or at least the types from math

safe lintel
#

could technically just make a class component and use AddComponentObject

#

for the big component thing

tardy locust
#

Yeah the Burst Compiler is made for the Mathematics types @graceful mason

graceful mason
#

Yeah, Will defo need to convert to that after I get my prototype going

#

want 1-2km draw distance ideally for voxel game πŸ˜„

#

I had 2km in unity classic at 1400FPS, but it took 3 hours to load + populate the meshhes πŸ˜„

tardy locust
#

Jobify and you are probably done

#

πŸ˜›

graceful mason
#

and trying to implement threading got me into ECS πŸ˜„

#

but my 2km demo, had only (terrible) terrain gen and no other code so seemed great to switch, I only started recently

#

and ran at 0fps for 3 hours til it generated. (or less / view distance setting)

#

is fun πŸ˜„

tardy locust
#

I think I have a different understanding of fun πŸ˜‚

graceful mason
#

you are making a game to?

ocean tundra
#

@graceful mason I love procedural generation

#

doing anything cool with it inside ECS?

#

3 hours is crazy long

tardy locust
#

I am making a game yes

#

And have a lot of side-projects

#

Probably too many πŸ˜›

#

Currently not utilising ECS and DOTS in a serious capacity

#

To try and learn about ECS in Unity

ocean tundra
#

nice

tardy locust
#

It's free for people to disect and look at but it is months old so, Unity doesn't do things like that any more

ocean tundra
#

yea they change so quickly now

#

i love it but it gets annoying having to rewrite older systems

tardy locust
#

Yeah

#

Such is beta packages

ocean tundra
#

yup

#

have you tried any automated testing in unity?

#

I've missed a few bugs lately that could have been caught via a automated test. but of course dont have any yet

#

and not 100% sure how to make any

tardy locust
#

Look up the Unity Test Runner

ocean tundra
#

thats for unit tests tho?

tardy locust
#

Well sure, but it's for testing in Unity at the very least

#

Automated Testing would require there to be tests in the first place πŸ˜›

ocean tundra
#

i was more thinking of end to end tests

#

like it could start my game as a host, and then start some clients, connect and play

#

somehow...

tardy locust
#

But that's not automated testing?

#

Or are you talking about something else? πŸ˜›

ocean tundra
#

its automated as no human needs to do anything

tardy locust
#

"like it could start my game as a host, and then start some clients, connect and play"

#

Sounds like humans involved

ocean tundra
#

no i meant something starts and does all that

#

command line tool maybe

tardy locust
#

Yeah okay...you still need to actually write the tests

#

If you want to really look into a client/server setup that you can use as a playground, albeit a rather advanced one, get the FPS sample

ocean tundra
#

i have all the networking working

tardy locust
#

It's a DOTS FPS sample project by unity that has both server and client

ocean tundra
#

just want to test it well πŸ™‚

tardy locust
#

Well, do you have agents that could play?

#

Because really what you need is a simulation of your game, not to play the actual game.

#

That would take forever.

#

You should, more or less, be able to simulate the whole thing server-side and let agents work with the data the server has access to. No game required.

ocean tundra
#

maybe... but thats not a end to end test

#

agents would be good

tardy locust
#

Agents would be necessary if you wanted it to be automatic

ocean tundra
#

and both full end to end and being able to simulate super quickly would be amazing

tardy locust
#

Please also elaborate on what you mean when you say "end to end"

ocean tundra
#

sorry its a team we use at work in web dev. basicly end to end for this game would be starting the game like a normal player, clicking buttons ect to start a game (host) and also doing the same thing for some clients, they join into the same game instance, game starts

#

so its a actual networked game, running like it would for players

tardy locust
#

You can simulate all of that

ocean tundra
#

i could

#

and probably would

tardy locust
#

Let me rephrase; You should simulate all of that

ocean tundra
#

the purpose of the tests are different tho

tardy locust
#

If you want automated testing, that is

ocean tundra
#

i want to confirm it ALL works

tardy locust
#

I mean yes..

#

But what does that have to do with simulating it?

#

If you want to keep your sanity you'll find a way to simulate the whole session, preferably at upscaled time so you can speed up the simulation and not have to wait forever for results.

#

Once you feel comfortable in the simulations, you could make a more elaborate "closer to real life" test with bots

#

But that shouldn't be the goto. Iteration time will likely be abysmal

ocean tundra
#

yea thats probs a good idea

#

time isnt really a issue

#

was more for a overnight test

#

like stellaris and factorio teams do

tardy locust
#

But first get the tests right. Then think about CI / CD

ocean tundra
#

they (stellaris) run the whole game every night on a bunch of machines, all with AI playing πŸ˜›

tardy locust
#

Yeah likely not in realtime though

#

And probably also with a lot of simulated environments

#

Automated tests are supposed to be predictable

bright sentinel
#

@ocean tundra You can definitely make tests like that, but requires a bit of an elaborate setup and probably can't be done entirely within Unity. What you can do is write unit tests in Unity with the Unity Test Runner (UTR). These would verify your basic functionality.

Then you could write some script (Python or whatever you like) to first start a server, where you could run the tests from command line. Once they have been validated, you can run clients, and then run tests on those.

However such a big setup will require quite a bit of work both to implement and maintain.

ocean tundra
#

@bright sentinel do you think it would be worth it tho?
I want AI's in my game anyway so hoping that it wont be much extra work to allow a AI vs AI game

bright sentinel
#

That's not really something I can answer πŸ˜…

ocean tundra
#

πŸ˜›

tawdry tree
#

Unit tests should always come first, at least for the most important "units"

#

But some launch argument which starts a constrained AI-vs-AI match with minimal extra fuzz shouldn't be too hard, assuming you already have AI

#

I rpobably wouldn't bother doing that until I had 90% of game, though, too easy to fall into the trap of non-progressing work

vagrant surge
#

ive tried to do unit tests on multiple projects

#

including PUBG itself (research)

#

unit tests for games... doesnt work

#

at all

#

the only case where it can work is for a online game, live service, where you absolutely dont want any regressions

#

its not just about the unit test development itself,but about the "lockdown" they cause

#

once a sector of code is well tested, that section of code is basically "frozen"

#

doing any change means having to adjust tons of tests

#

so unless you actually want to freeze that section of code because its "final-ish", then dont

#

what works much better is integration level tests. For example shove 10 bots into a deathmatch and see if everything happens at expected

#

those cost near-0 to implement, and can test big chunks of the game at once

#

Replays also can do that, you can try to run a replay and see if stuff still happens as usual

wide fiber
#

How can I get the LocalToWorld.Position of the current frame? Because I spawn a prefab (that has transform 0,0,0) in a random location, but the first frame when it spawns, LocalToWorld.Position gives me 0,0,0 instead of the new position

bright sentinel
#

@wide fiber I see 4 solutions. 2 of them requires that you spawn the entity before the transform systems run. This can be achieved by using the EntityManager directly. However, that doesn't allow you to do it in parallel. The 2nd solution is similar, but with an ECB. This requires you to set up a ECB before the transform systems, which then causes a sync point. This may not be ideal either.
A 3rd solution is to disable the renderer for the first frame. This should be done right after you spawned the object, and then a system that enables it again next frame.
Finally, the 4th solution is to change LocalToWorld directly after you spawn the entity. Then you would have to mimic the behavior of the Transform systems. You may be able to do it simply by setting position and rotation, but I haven't really touched it, so I wouldn't know.

graceful mason
dire frigate
#

Anybody know how close burst 1.3.0 is to release, or if 1.2.3 supports compiling to linux from windows?

tawdry tree
#

vblanco, sure unit tests in code works.
You can do it on the traditional "units" of methods, typically helpers and such, and on the "unit" of game mechanic. DOTS especially makes the latter easy - spawn entity with MoveForward and a given speed, simulate x time, check if position is correct. Repeat for a couple different speeds.
That tests one system, of course, but barring corner cases you can at least verify that the basic functionality of your core systems work.

wide fiber
#

@bright sentinel Ok ty (the problem is not the renderer, but it's another system that checks the distance between him and another object, if it's less than a 1 unit for example, he does a thing)

tawdry tree
#

Traditional tests work the exact same way, and have some use, but the "unit" of a minimal system iteration takes a bit of time and might need somewhat fuzzy checks. I made some basic tests of a "move forward" system which could test a dozen tests in time not far off from traditional unit tests.

#

The real question is whether it'd benefit the game and code or not - iterative processes already makes tests more dodgy, and the nature of games does not help with that.

eager jungle
#

Hi guys, I'd like to confirm something with you about memory layout with DOTs. When querying for some entities, it is the entire chunk that is brought to CPU cache? correct? And because of that, reading more or less components in a query shouldn't affect performance?

amber flicker
#

Out of curiosity @tawdry tree , what kind of things can mess up a system to move forward an entity that a test like that would catch?

tawdry tree
#

Only poor coding, really. Admittedly, it's pretty much a hello world example.

#

Hence why you would ask whether the tests are worth it or not

amber flicker
#

@eager jungle yes, that's my understanding - so long as you're reading components that are part of the chunk (rather than ComponentDataFromEntity).. well, every operation has some cost but it wouldn't have a performance cost in terms of fetching data

tawdry tree
#

I wouldn't do that test outside learning, but combined with a "turn towards" system you could automate testing of agents (stupidly) "pathfinding" towards player/food/whatever

eager jungle
#

@amber flicker OK great. I understood the "wouldn't" :p

amber flicker
#

haha yes sorry about that πŸ™‚

eager jungle
#

not related, but do you know what it the proper way (or suggested way) of handling events in ecs? I was thinking of creating entities carrying over some "event" component, notifying system, which would then be destroyed afterward. Event would be like: notify UI, trigger something... etc

tawdry tree
#

Events, as in...?

eager jungle
#

The "Options for Entity Interactions" talk might be what you're looking for. Either way i found it very helpful to understand some concepts.
https://www.youtube.com/watch?v=KuGRkC6wzMY
@tawdry tree k thanks, i was just about to watch it, already in a tab. Any other hints before i continue with that? I've heard some stuff about system state components of something. Is it worth digging into?

low tangle
#

system state components are a good tool yeah

tawdry tree
#

@eager jungle Honestly you should probably just watch that first. System state components should not be used for entity interactions, but if it's an event in the meaning of "thing happened, all systems that care can check the state and do their thing" they are good

amber flicker
#

@eager jungle tertle on the forums made this https://forum.unity.com/threads/event-system.779711/#post-5189462 - I'm not sure I'd ever include it in a project myself (although I'm sure it's very good) - this may be a good reference for what a complete 'event system' might look like in dots - but what an 'event' is and how it relates to your data & systems means it's a bit of a vague term

eager jungle
#

It's actually some kind of observer pattern I'd like to implement. Some system throw an event in the wild, and some system may or may not react to it by "subscribing" to that event, whatever this would mean in ecs

tawdry tree
#

That's a good point - In DOTS you might want to think of it differently. Events are generally rather OOP.

#

For that use case, creating message entities or system state should do the trick

#

Which is better depends on the use case - how often will this happen, what's the magnitude of changes here?

amber flicker
#

One thing to be mindful of is when and where timing is implicit or explicit. i.e. the order of your Systems can be explicit. Mixing that with firing off an event and responding means you need to be aware of when the data is changing and which systems will operate on it.

tawdry tree
#

The simplest, most naive way it to set a public static variable. I'm sure you can find reasons why that isn't the best idea, but if it's simple and works... Mightnot need anything else

eager jungle
#

let me give you a real life example maybe

tawdry tree
#

That too, the order is absolutely crucial. You wanna be explicit about Before/After.

eager jungle
#

my vehicule is moving and got hit by a projectile. I want to spawn a particle effect, and also shake some UI element say.

tawdry tree
#

Entity Interactions cover stuff like that pretty well

#

But the mechanics at play is a collision, and N number of other systems that want to react on that

amber flicker
#

I think that kind of thing I'd handle with Tags

eager jungle
#

yea, its just that i don't want to collision system to be in charge of spawning the particle for example, i just want it to trigger some events that the collision system isn't even aware of

tawdry tree
#

Regarding before/after, consider one "frame" of the game - you generally wanna make sure the order of operations is consistent, and that you do [other stuff][reset state][set new state][other stuff]. Depending on order you can have things reacting in different frames, which might be bad or ok, and to fix that you'd ensure the event is fired very early in the frame, and reset either end of frame of at the very start

eager jungle
#

i don't intend to use event to update states, but most probably just for transient stuff happening. Not sure yet how I'll handle that, but if order matters maybe it shouldn't be an event like that. .. hmm

tawdry tree
#

In this case state just means changes done in order for this to work, not game state or state of entities and such

eager jungle
#

what is the proper use case for system states components?

opaque ledge
#

mainly to monitor component add/remove and entity create/destroy

bright sentinel
#

@eager jungle I think it's mostly a semantic/organizational thing. You can pretty much get the same functionality with normal components, but it may be nice to organize components like that

eager jungle
#

@bright sentinel Hey thanks, can you detail what you're referring to? normal components vs system states components?

bright sentinel
#

Normal components are IComponentData while system state components are ISystemStateComponentData. They function very similarly, except that when you destroy an entity, the system state component will still live with the entity, until the component is deleted manually.

#

It's especially useful for detecting when an entity has been destroyed

eager jungle
#

thanks, reading that already, just wasn't sure your were talking about that

#

would you guys handle a bullet impact changing vehicle health in such a way? FireSystem => Spawn Bullets then CollisionSystem => Spawn Impact then Damage System => Deal Damage ? Can impact be considered an "event"?

bright sentinel
#

That seems pretty accurate to me

#

I'm also still trying to figure out events in ECS, so I don't really know of any alternatives

storm ravine
#

When querying for some entities, it is the entire chunk that is brought to CPU cache? correct? And because of that, reading more or less components in a query shouldn't affect performance?
@eager jungle @amber flicker Wrong πŸ™‚ Not whole chunk goes to cache. Depends on type you requested (not just declared in EntityQuery), cache lines (usually 64 bytes per line, but depends on hardware) only filled by exact type arrays parts you iterate linearly, amount of types listed in query not matter. What matter is how many of these types really used for processing and which types data you exactly gather. Processor not prefetch whole chunk (because there is no reason for that it's not SOA in regular meaning). When you requesting some component data (Translation, SomeTag for example) you use EntityQuery as mask for chunks which contain both of them (but that chunks can contain other components, there is one reason why chunks not prefetched and shouldn't), for example there is can be archetypes of Translation, SomeTag, Rotation and Translation, SomeTag and etc. And when you doing chunk iteration (which happens under hood anyway) you iterate every matching chunk, and in this matching chunks you implicitly iterate through only required arrays linearly (include Entities which lives in chunk as pointer to 0 component type index array), and this is where processor cache lines utilisation become a thing, cache line prefetch different AOS of data, and this is why count of gathered types (not just listed in EntityQuery) matter and have cost (for example difference of iterating 1mil entities in case when you get only 2 types (where first type is Entity) ~8ms and in case when you iterate same 1mil entities but operate 8 types (where first type is Entity) ~12ms. With disabled burst. With Burst enabled it will be ~1-2ms for 2 types and ~3-5ms for 8 types). Also what matter here is what you doing with data - reading or writing.

amber flicker
#

Thanks for the clarification @storm ravine - so in your example, the archetype has 8 components but when you do e.g. ForEach(component1, component2) it takes much less than ForEach(c1,c2,c3,c4,c5,c6,c7,c8) right?

storm ravine
#

Yes

#

Where Component1 is Entity

#

Just note for remember that πŸ™‚

#

Of course you can exclude entity and thus it will be -1 type for gathering

eager jungle
#

so is the chunk a struct of arrays of components ? and only the interesting arrays of components are prefetched?

storm ravine
#

Chunk is struct with pointers to memory buffers and offsets.

amber flicker
#

But it's also true that ForEach(e,c1) for an archetype with 1 component will be quicker than ForEach(e,c1) for an archetype with 2+ components - I thought that's because the chunk could fit less entities in, meaning less entities were brought into the cache line to be iterated over. I must be wrong about this?

eager jungle
#

oh ok, so every component type of the archetype of that chunk will be stored somewhere in a contiguous array, but usually not in the same contiguous memory as some other archetype using the same component?

storm ravine
#

Numbers above is for writing, for reading (all components in instead of ref) it will be ~4 and ~9

#

But it's also true that ForEach(e,c1) for an archetype with 1 component will be quicker than ForEach(e,c1) for an archetype with 2+ components - I thought that's because the chunk could fit less entities in, meaning less entities were brought into the cache line to be iterated over. I must be wrong about this?
@amber flicker c1 is same type?

#

or just 2 different archetypes with different c1?

amber flicker
#

same type

storm ravine
#

Well these ForEach wil itarate same amount of data, because their EQ will be the same

#

I mean if you have 100 entities with c1

#

and 50 entities with c1, c2

#

they both will iterate 150 entities

#

because query mask here only by c1

#

different amount of entities will be only if you declare different EQ where c2 will be involved πŸ™‚

amber flicker
#

I'm trying to understand why foreach(c1) for 100 entities with c1 is quicker than foreach(c1) for 100 entities with c1 & c2

storm ravine
#

it's not quicker

#

it will be the same

amber flicker
#

Time for more tests..

eager jungle
#

i don't understand either why that would be the same. Because if the chunk (of fixed size?) with C1+C2 contains less entities, they are more fragmented accros memory. Is that what you mean @amber flicker ?

storm ravine
#

I'm speaking about exact ForEach he wrote πŸ™‚

#

foreach(c1) and foreach(c1) - same

#

if you declare for example WithAny\None\All it will change count of entities

#

and of course will change timings

eager jungle
#

are you trying that @amber flicker ? πŸ˜„

amber flicker
#

yes... I must be wrong.. as sensei-Eizenhorn is always right πŸ™‚ - but in my previous tests, I'm sure it took different amounts of time to iterate. In addition, I'm sure I've improved job timings by decreasing the size of components that are not being read/required/accessed by the job

storm ravine
#

Ok I'll clarify it without chunk and memory things involved by your latest case:
You have 100 entities with C1 without any other types. And have 100 entities (imagine we can fit only 100 entities in chunk for simplification) with C1 and C2 this you have 100 entities with C1, C2 and 200 entities (in sum) with only C1 for iteration. You iterate this 200 entities - you iterate through all chunks with that C1 type and through all "arrays" of C1. If you'll have only 200 entities with C1 (absolutely without C2) timings will be the same, because you iterate 2 chunks in both cases. But important note here - we speaking about optimised packed data case πŸ™‚

#

There is many things involved

amber flicker
storm ravine
#

In you code chunks count will be different

amber flicker
#

obviously..

storm ravine
#

it will be 2 chunks vs 4 chunks

#

Yes of course

eager jungle
#

ofc, so more component = bigger size = more chunk for the same amount of entities = slower

bitter socket
#

Hey guys -
I had an issue yesterday with DOTS animations not being played on my own custom character within DOTS. The skeleton played the animation but the skinned mesh didn't. The issue apparently, it seems was that for Unity DOTS Animation to work (as it's done in the DOTS Sample) is to use Vertex Skinning node inside a Shader and make sure you apply that shader to your character. Thought I'd share the solution, instead of always asking the questions! Hope it helps people!

vagrant surge
#

@eager jungle indeed

#

thats also why it can be recomended that you split your object into multiple entities

#

for example having a few entities instead of a monolythic megahuge "player" entity

amber flicker
#

So this difference in speed is not to do with the cache line right? That was my mistake - thinking that it was related. But it's not - the time is spent fetching the pointer to the next chunk? or..?

vagrant surge
#

btw, unity ecs has HUGE fixed overheads on the systems

#

so that might be why you find that iterating C1 and C2 while only accessing C1 is slower than doing C1 alone

#

essentailly the more components you have in your foreach, the slower those overheads are

amber flicker
#

at 10mil, ~20ms vs ~40ms fyi

vagrant surge
#

uhm that doenst make so much sense, the overheads are more in the region of 0.1 ms

#

run it through profiler and check

#

and do something in the loop

#

like adding something to the comp

storm ravine
#

it's not about size, it's archetype
@digital scarab well archetype is about size in result. Because archetype define size of of your data and on how many entities will fit chunk and how chunks data will be spited (exclude all filtering, MaximumChunkCapacity etc. here for simplification and just speak about raw data)

#

Yep of course in tags case, but we again speaking about real data πŸ™‚ Not about chunk header for tag components πŸ™‚ I'm intentionally skipped all that additional stuff like chunk headers for tags, filters and all other stuff, because it affect things drastically πŸ™‚

eager jungle
#

So this difference in speed is not to do with the cache line right? That was my mistake - thinking that it was related. But it's not - the time is spent fetching the pointer to the next chunk? or..?
@amber flicker new memory zone (often) mean new fetching, so its kind of related i suppose

amber flicker
#

interestingly both scenarios take the same amount of time if I write to the component in the loop

coarse turtle
#

hey do u guys know how to use tiny unity?
@gusty comet Believe you just need to install the packages required by Unity tiny via package manager. There's a pinned Tiny samples repository which shows the structure

eager jungle
#

@amber flicker do you mean that if you do nothing c1+c2 takes longer, but if you write, both (c1 vs c1+c2) take same amount of time?

amber flicker
#

yes - perhaps it is a symptom of not doing anything in the foreach

coarse turtle
#

i did that, but theres no "create DOTS project" option under DOTS
@gusty comet I'm not sure about that option, haven't touched Tiny in a long time. IIRC you just need to author entities using subscenes and build with the build pipelines to build out a Tiny project.

vagrant surge
#

@amber flicker you are likely running into some weird shit

#

being the same amount of time sounds about right

#

because the overhead of 1 comp foreach vs 2 comp foreach is like 0.01 ms or so

#

so if you have something that takes 10 ms, thats just noise

coarse turtle
vagrant surge
#

@gusty comet the DOTS editor no longer exists

amber flicker
#

well... I'm pretty sure it was doing a test similar to this that sent me down the wrong understanding - It's good to know it's not true in general. I wonder if it is related to some in-editor safety test. As soon as I give it some work to do I get more expected results.

#

DOTS editor exists as a package still exists though right? It just doesn't do much and isn't related to Tiny πŸ™‚

vagrant surge
#

@amber flicker from when i tested, with all safety checks disabled, but still in the editor

#

there is about a 0.025 cost per-component in your foreach

#

due to checking dependencies in the job system

#

linear

#

so a foreach with 4 comps will have 0.1 ms of overhead

#

and a foreach with 8 about 0.2

#

but i dont know if thats a thing in full build, outside of the editor

#

thisis from the vehicle move system in Tiny Racer demo

#

red part is the "actual" work (the stuff inside the foreach)

#

everything else is overheads

#

of course, this is both in editor, and with the profiler, so its bigger than they actually are

amber flicker
#

I'm taking my timings from the work done across the threads which I think might not include that anyway?

vagrant surge
#

that doesnt include overheads

#

because the overheads are on the main thread

amber flicker
#

ya

low tangle
#

That picture is a bit blurry to try and make out

#

But it looks like you got a spread of 10 micro seconds

#

Which isn't much

#

And I see a Singleton access?

#

Smells like main thread heavy

vagrant surge
#

@digital scarab but you dont get zone traces with a native profiler

#

need the annotations

#

and function start-end

#

like the unity profiler has, where it shows the exact callstack

#

if with native profilers you mean stuff like vtune, verysleepy, or others, those are sampling, they just throw rng samples and record the callstack at points, those arent very precise for games

bold crown
#

i need help

#

is anyone good at RPG'game's here?

vagrant surge
#

do il2cpp builds have markers for vtune? unreal engine has them

#

ah then perfect πŸ‘

bold crown
#

yes?

#

could you get in a call with me?

#

i need help so bad!

vagrant surge
#

not the place

bold crown
#

?

gusty comet
#

Any good reason as to why
for (int i = 0; i < 144; i++) activeBuffer.Add(new ActiveGrid_Buffer { value = 5});
Only adds 4 elements to the activeBuffer?

#

In systemBase OnUpdate

bold crown
#

@digital scarab where for RPG,im new here.

#

or just help at all.

#

where for help then duh

#

my game

#

uh

#

okie then

gusty comet
#

I'm trying to fill a dynamic buffer inside a system, but it only fills up one page (5 elements). Not sure why it isn't adding all of it..

#

entity debugger

#

Well, If i do that same thing in monobehaviour it does show me all of the data inside the buffer.

#

I'm also in the process of trying to figure out how to debug.log inside a system πŸ˜›

#

no. I do mean dynamic buffer, as it is possible to use them in monobehaviour

#

Basically I create the entities in mono, and trying to process them in a system

#

I can understand why... It's how i'm getting started with it

wary anchor
#

I'm having a problem with a SingletonComponent apparently not being created in time. I create the component and use SetSingleton in OnCreate, then much later in a monobehaviour's event callback (which itself is called by the SystemBase in question) & after a bunch of setting up has happened, I'm calling GetSingleton() and that seems to be failing sometimes but not always in a build. I'm only seeing the errors in player.log (it doesn't crash):

  at Unity.Entities.ComponentSystemBase.GetSingletonEntityQueryInternal (Unity.Entities.ComponentType type) [0x0001f] in <54c4447081104ec68f143a5cd752b3ed>:0 
  at Unity.Entities.ComponentSystemBase.GetSingleton[T] () [0x00006] in <54c4447081104ec68f143a5cd752b3ed>:0 
  at PlayerSpawner.SetUpPlayer (Unity.Mathematics.float3 playerStartingPosition) [0x0002a] in <2f470fd45f8140c79c7135ea4902628d>:0 
  at PlayerSpawner.OnGameLoaded (Unity.Mathematics.float3 playerStartingPosition) [0x00000] in <2f470fd45f8140c79c7135ea4902628d>:0 
  at (wrapper delegate-invoke) System.Action`1[Unity.Mathematics.float3].invoke_void_T(Unity.Mathematics.float3)
  at GameStateSystem.GameLoadingComplete (Unity.Mathematics.float3 playerStartPosition) [0x0000a] in <2f470fd45f8140c79c7135ea4902628d>:0 ```
gusty comet
#

@digital scarab How would you suggest iterating over the dynamic buffer to see the results if not in entity debugger?

storm ravine
#

@gusty comet just to be clear - you see 5 in entity debugger and only one page?

gusty comet
#

Yes. only one page. There are no other pages or it just wont let me see the next page

storm ravine
#

Well and dragging slider don't do any thing for you?

gusty comet
#

nope.

#

I already have some Dynamic Buffers I created in mono, and they work. Now I'm trying to do the same in a SystemBase

#

That was originally made in mono i should maybe add

#

: MonoBehaviour

storm ravine
#

Mmm you working directly with DynamicBuffer and not with IBufferElementData?

gusty comet
#

No, I have made an entity, addded a buffer to that entity with IBufferElementData in a monobehaviour script. Then I'm referencing that buffer with this entity in a system to fill it up with values

#

the values I am giving it in the loop inside the system are added to the buffer correctly, but not the entire 144 elements

#

just 5

storm ravine
#

Show your code in OnUpdate

#

And which value used in InternalBufferCapacity for IBufferElementData

gusty comet
#

` protected override void OnCreate()
{
zoneRoomsEntities = GetEntityQuery(ComponentType.ReadOnly<Tag_Zone>(), ComponentType.ReadOnly<PlayerEntity>());
playerEntity = GetEntityQuery(ComponentType.ReadOnly<PlayerTag>());
activeGridEntity = GetEntityQuery(ComponentType.ReadOnly<Tag_ActiveGrid>());
}

protected override void OnUpdate()

var player = playerEntity.GetSingletonEntity();
var playerComponent = GetComponentDataFromEntity<PlayerEntity>(true);
index = playerComponent[player].indexOnZoneBuffer;
topRoom = zoneBuffer[index + 1].roomEntity; `
var topRoomBuffer = EntityManager.GetBuffer<roomGrid_Buffer>(topRoom);

    for (int i = 0; i < 144; i++)
    activeBuffer.Add(new ActiveGrid_Buffer { value = topRoomBuffer[i].value });`
storm ravine
#

And what @digital scarab suggested - put debug log to every element or size in general just to be clear that elements in buffer (not by entity debugger)

gusty comet
#

damn... hopefully its readable

storm ravine
#

roomGrid_Buffer which InternalBufferCapacity ?

gusty comet
#

I have not set an InternalBufferCapacity. I only added 144elements to it

#

I'll read about it

wary anchor
#

I'm having a problem with a SingletonComponent apparently not being created in time. I create the component and use SetSingleton in OnCreate, then much later in a monobehaviour's event callback (which itself is called by the SystemBase in question) & after a bunch of setting up has happened, I'm calling GetSingleton() and that seems to be failing sometimes but not always in a build. I'm only seeing the errors in player.log (it doesn't crash):

  at Unity.Entities.ComponentSystemBase.GetSingletonEntityQueryInternal (Unity.Entities.ComponentType type) [0x0001f] in <54c4447081104ec68f143a5cd752b3ed>:0 
  at Unity.Entities.ComponentSystemBase.GetSingleton[T] () [0x00006] in <54c4447081104ec68f143a5cd752b3ed>:0 
  at PlayerSpawner.SetUpPlayer (Unity.Mathematics.float3 playerStartingPosition) [0x0002a] in <2f470fd45f8140c79c7135ea4902628d>:0 
  at PlayerSpawner.OnGameLoaded (Unity.Mathematics.float3 playerStartingPosition) [0x00000] in <2f470fd45f8140c79c7135ea4902628d>:0 
  at (wrapper delegate-invoke) System.Action`1[Unity.Mathematics.float3].invoke_void_T(Unity.Mathematics.float3)
  at GameStateSystem.GameLoadingComplete (Unity.Mathematics.float3 playerStartPosition) [0x0000a] in <2f470fd45f8140c79c7135ea4902628d>:0 ```
storm ravine
#

If you not set InternalBufferCapacity it will be 128 / IBuferElement sizeof

#

And if you exceed that value it will be moved out from chunk to heap

gusty comet
#

@storm ravine setting InternalBufferCapacity(144) did not seem to do anything

#

i'll try to do the same with higher capacity

#

to all of them

storm ravine
#

Well, if you debug log actual size of buffer or debug log this

     Debug.Log(activeBuffer[i].value);```

Which result you see?

#

Put it after for (int i = 0; i < 144; i++) activeBuffer.Add(new ActiveGrid_Buffer { value = topRoomBuffer[i].value });

gusty comet
#

I understand that Debug.Log is not possible in Systems?

storm ravine
#

Why?

#

It's possible

#

and from latest releases it's even possible from bursted job with string literals

gusty comet
#

I'm still using 2019.3.3f1.. Might have been added since then

storm ravine
#

System itself it just code on main thread.

#

Doesn't matter

#

Debug.Log always worked in systems itself

gusty comet
#

Dunno where i got that idea from

#

huh.. Okay that answered a few questions then

#

It keeps on adding them nonstop

#

If i understand it right, a System will then keep on running over and over again. Which is where Entities.ForEach comes in to run the code inside it whenever theres a change, right?

#

instead of running it endlessly

zenith wyvern
#

A system runs whenever any entities it's querying for exist

gusty comet
#

Makes sense.

#

So in case where the entity its querying always exists, but needs to run a snippet of code only once in a while, is when i should use the Lambda?

zenith wyvern
#

The general idea is if you want a system to run you create an entity for it. When you want it to stop running you destroy the entity or remove the relevant component

#

There are performance concerns if you're doing that a lot in a single frame but that should be your starting point

#

So if you have some code that you only want to run once in a while, that should be in it's own system. You create the relevant entity/component, let that system do it's thing, then destroy the entity/remove the component when it's done

gusty comet
#

Okay! I think I understand now

#

I've been using entities.foreach exclusively until now, and it's been working great. But am I right to assume that it runs the code inside it only when there's a change in one of the reference components?

zenith wyvern
#

No, it runs every frame as long as the thing it's querying for exists

#

Unless you use change filters

gusty comet
#

Good to know. Much thanks @zenith wyvern @storm ravine
I appreciate your educational help ^^

graceful mason
#

Can we still use normal coroutines, with Jobs?

zenith wyvern
#

All coroutine stuff is restricted to the main thread

graceful mason
#

yeah the coroutine running on main can call a job every now and then? Or thats just a bad idea?

zenith wyvern
#

I don't see a problem with it

graceful mason
#

Ah cool thanks

wide fiber
#

Finally, the 4th solution is to change LocalToWorld directly after you spawn the entity. Then you would have to mimic the behavior of the Transform systems. You may be able to do it simply by setting position and rotation, but I haven't really touched it, so I wouldn't know.
@bright sentinel how can I set a local to world? LocalToWorld.Position is only a getter, I have to change the float4x4 Value, but I don't know what's the position

warped trail
#

you can create new LocalToWorld cs var ltw = new LocalToWorld { Value = float4x4.TRS(newPos,newRot,newScale) }

#

or cs new float4x4(rotation,translation)

wide fiber
#

Ok ty

wide fiber
#

(the solution doesn't work (the position is not changed, it spawns at 0,0,0), do you know other solutions?)

#

How can I get the LocalToWorld.Position of the current frame? Because I spawn a prefab (that has transform 0,0,0) in a random location, but the first frame when it spawns, LocalToWorld.Position gives me 0,0,0 instead of the new position
This is the problem

warped trail
#

you have to set Translation and LocalToWorld

#
ecb.SetComponent(entity, new Translation { Value = yourRandomPosition});
ecb.SetComponent(entity, new LocalToWorld 
{
    Value = new float4x4(quaternion.identity, yourRandomPosition)
});```
undone torrent
#

hello, it is possible to create a subscene via code ? and save scene ?

#

save subscene scene

#

on editor mode

wide fiber
#

you have to set Translation and LocalToWorld
@warped trail ah ok, thanks :D

warped trail
#

or use command buffer system which run before transform system πŸ˜…

wide fiber
#

I prefer the other way

graceful mason
#

is there a parent > child type of entity relationship possible?

#

ohh parent Component

coarse turtle
#

There's also DynamicBuffer<Child> if you need to grab the children from the parent

untold night
#

and LinkedEntityGroup as well

dull copper
#

we’ve been internally prototyping a version of ML-Agents that is built for DOTS. We’ve successfully integrated our DOTS prototype into sample scenes (see above) and Unity demos such as MegaCity and TinyRacing. The results have been outstanding. We were able to train agents in complex and large environments such as MegaCity in just a couple of hours on a standard laptop. We intend to release an experimental version of ML-Agents for DOTS later this year.

coarse turtle
#

oo

dull copper
#

I wonder if they have internally a version of megacity that runs on latest entities

formal scaffold
#

Can anyone help me with this error:

(0,0): Burst error BC1064: Unsupported parameter Unity.Mathematics.float3 linearVelocity in function VelocityStateMachine.ProcessVelocity.Invoke(Unity.Mathematics.float3 linearVelocity, Unity.Mathematics.float3 forward, Unity.Mathematics.float3 right, Unity.Mathematics.float3 normal, float t, float speed, float height): structs cannot be passed to or returned from external functions in burst. To fix this issue, use a reference or pointer.

Why can't I juse float3 parameters?

opaque escarp
#

huh, I thought they got rid of that previously. So at one time you couldn't use external functions with return types. Instead you had to use the out keyword to return stuff, and the ref keyword to pass stuff in

zenith wyvern
#

It looks like you're using a function pointer. You need to pass/return structs by ref if you're using a function pointer in Burst.

#

Like it says

opaque escarp
#

oh yes, it's not in general, specifically with function pointers that's right

zenith wyvern
#

According to the manual they are going to change it so you don't have to eventually, but not yet apparently

formal scaffold
#

When I use pointers as parameters for my function pointer why do I have to use "unsafe"? Makes me feel uneasy

opaque escarp
#

c# doesn't allow directy use of pointers by default since it's a managed language. To use unmanaged stuff, you have to use unsafe

#

and in order to do so in unity you have to enable Allow Unsafe Code in the settings, in addition to adding the unsafe keyword to the relevant class or method

tardy locust
#

A lot of the DOTS stuff is already using unsafe under the hood so

#

No need to feel uneasy about it

opaque escarp
#

well the dots stuff is all wrapped so you still get error messages and stuff if you, say, go out of bounds while using a NativeSlice. Using pointers directly though you have no such luxury

tardy locust
#

Sure but considering how easily you can crash the editor while working with dots stuff

opaque escarp
#

true dat lol

tardy locust
#

it's safe to say that...it's very unsafe

#

πŸ˜›

#

(did I win a nice subtle pun award there?)

opaque escarp
#

I wouldn't call it subtle, but you get the award nonetheless

tardy locust
#

I'll take it

vale stream
#

this might be the wrong place to ask, but why use a function pointer over a delegate?

tardy locust
#

Delegates allocate

opaque escarp
#

you can't use delegates in unmanaged code afaik

tardy locust
#

Probably also that

opaque escarp
#

the burst function pointers are also incredibly fast compared to delegates, at least when executed using Burst

tardy locust
#

unsafe...unsafe everywhere

opaque escarp
#

the problem of being faster than light is you must live in the darkness

tardy locust
#

But you are light

#

so

#

Is all good πŸ˜„

vale stream
#

as someone who was about to use a lot of delegate for an ECS behavior tree, this is good to know πŸ‘

dull copper
#

we do
of course they do...

tardy locust
#

it do be like dat πŸ‘€

dull copper
#

I don't really see it affecting us either way as it's not likely that they release it

#

at this point, would be nice to even have up-to-date ECS Samples repo πŸ˜„

tardy locust
#

It'll likely be like the FPS sample though. Continous iteration and release.

opaque escarp
#

I don't see why they wouldn't release it with the official release of ECS

tardy locust
#

Yeah I don't see why they wouldn't release it

#

It's a sample project

dull copper
#

it's been discussed here in past.. FPS sample was supposed to be public iteration from the beginning, MegaCity was a tech demo

tardy locust
#

Well things can change :b

dull copper
#

also it's probably nontrivial to decouple their internal wip versions of packages to actually make a new MegaCity release

#

or at least time consuming

tardy locust
#

and from what I've heard the FPS sample was also a tech demo before the choice was made to change it

dull copper
#

I dunno about that, I mean once they showed it to public, they were pretty clear from beginning it would be updated

#

many were let down because it got canned quite early on

formal scaffold
#

Don't I have to use a delegate in order to complile a function pointer and later Invoke it? In the Burst manual they give such an example

opaque escarp
#

you do

#

the delegate itself is just a signature though, idt you use an instance of the delegate

#

if that makes sense

formal scaffold
#

So thats a different delegate that you mean? Which is slow by comparison?

opaque escarp
#

Func or Action are typically used in place of traditional delegate signatures, so something like

Func<float,float,float> myAdd = (a,b)=>a+b;
Debug.Log(myAdd(3,4));

where you do myAdd(3,4) is invoking the delegate, and compared to burst functionpointers is very slow

formal scaffold
#

Oh I see, thats the alternative to function pointers within Structs I guess

#

Or any place really

opaque escarp
#

yes, they're the traditional c# way of handling "function pointers"

#

do note I believe in order to get the speed up of Burst FunctionPointers they have to actually be called from within a Burst-compiled job, you can't just use them in place of every delegate and expect everything to be better

tardy locust
#

Man, why can't programming just be magic?

#

What a bummer

opaque escarp
#

it is like magic at the highest level, or at least is indistinguishable from it

tardy locust
#

It's only indistinguishable if you can't fathom the technology

#

We do fathom

#

it

#

πŸ˜›

opaque escarp
#

I lost my interest in programming for a number of years because it got boring, everything was so systematic with OoP, but now you have the ability to do all sorts of shenanigans with DOTS, things that would have previously been only done in such a straightforward manner you can for lack of a better analogy, throw a curveball

formal scaffold
#

Sorry one last question, how can I get pointers within my lambda Entities.ForEach? float3* vel = *physicsVelocity.Linear; doesn't work. I tried &, ref, in, out

opaque escarp
#

tbh I just try random combinations of * and & until it works legend26LUL but you might want to just use a temporary variabl in that case, and set the Linear velocity to the temp variable

#

you might want to look into the fixed keyword though, I'm still a little shaky on pointer stuff myself

formal scaffold
#

Okay thanks, if I cant figure it out ill just open a Thread on the forums

vale stream
#

I'd like to implement behavior trees into my ECS stuff but I'm currently running into problems:

  • a behavior tree might want to get access to all sorts of entity data, which would mean casting a wide net and accessing a large amount of components if I want to use jobs
  • behavior trees for different entity types means making different jobs or versions of a job?

using EntityManager.GetComponentData in the tree nodes seems like an attractive alternative right now instead of creating a whole bunch of ComponentDataFromEntity objects, but then it couldn't be multi-threaded

I'm planning on using delegates/function pointers for tree nodes, basically Im trying to figure how I'm going to be passing info to the nodes, and right now just passing a big group of component data seems like the only way

tardy locust
#

From what I gather

#

Behavioural Trees have very simplistic components you can chain together in a lot of ways

#

Should be fairly generic

vale stream
#

The problem is that the behavior tree will want to read component data to make decisions
am I hurt, am I in combat, am I casting a spell, am I hungry, etc, etc

tardy locust
#

But its up to you to formalise that logic in a way that can be data driven

#

"am I hurt" could be something as benign as the difference between 0 and 1

#

You'll need to store state somewhere

#

Of each agent

#

Ideally you'd make it so that state data can be attached to any agent

vale stream
#

I guess I'm worried about having the size of state data balloon if keep coming up with behaviors that need new data

the frustrating thing for me is that running behavior trees will never write to the data it reads, parallelism isn't a concern

so ideally I wish I could just access the component data directly, speed, health, hunger level, etc

but then in ECS jobs, I have to set all that up before hand

tardy locust
#

I mean yea

#

But I don't see the issue then?

vale stream
#

I guess the issue is that number of potential components I'd want to access could get large
and having to do all that setup might balloon quickly

#

but I guess it can't be avoided

#

again, I wish I could do something like EntityManager.GetComponentData in each tree node
instead of creating a whole bunch of ComponentDataFromEntity objects at the beginning of the job

#

this is just me messing around, but this is what I was passing to my node delegates, in addition to the index

#

in an IJobChunk

opaque escarp
#

wait does it even allow that? I thought you could only use NativeSlices in struts

vale stream
opaque escarp
#

huh

vale stream
#

but Im also still sort of prototyping this whole thing

opaque escarp
#

maybe it's only if you try and put that in an IComponentData that it starts complaining

vale stream
#

oh yeah

#

this isnt data for a component

#

this is data from an IJobChunk to pass to a delegate

#

cmdState.state is an index for an array of delegates

#

so different behaviors like attack, follow path, etc are just delegates in that array

#

it doesnt execute the actual movement or attacking, those are separate systems
but it does check for when a behavior is finished or can move on to the next behavior or whatever

opaque escarp
#

is it performance or convenience that makes you want to avoid using GetComponentDataFromEntity?

vale stream
#

its the fact that the AI of the behavior tree could potentially want to look at pretty much any and all components an Entity has to make a decision

#

I mean, I'd be the one designing the AI, of course
but

opaque escarp
#

it sounds like GetComponentDataFromEntity is the way to go to me. You can use the .Has method to check if it actually has the thing, and go from there.

#

the alternative would be to set up a "write" relationship instead of a "read" relationship

vale stream
#

well the tree would never write to the components its reading
its just looking at them to decide on how the entity is going to behave

opaque escarp
#

yea sounds like GCDFE is the way to go to me

vale stream
#

I'm probably overthinking things
I just feel suspicious about accessing a huge amount of components from a job

#

I really should just try it and see how it works out

opaque escarp
#

yeah, even if it's not the most efficient thing possible, it'll still be by itself many times more performant than traditional c#, plus it will also have multithreading

#

it's the whole idea, with "Performance by default"

vale stream
#

I am very much looking forwards to also having a million units on-screen 😎

opaque escarp
vale stream
#

is this just rendering objects? or do they have some sort of behavior?

opaque escarp
#

they all have collision, physics, and are moving and turning based on dynamic expressions

formal scaffold
#

How many are there?

vale stream
#

dynamic expressions?

opaque escarp
#

I think it was 60,000 there

#

as for what I mean by dynamic expressions, that's a secret πŸ™‚

tardy locust
#

@vale stream The ECS system is fast enough to make up the difference from all the data you retrieve

stiff skiff
#

If I have a NativeArray of job handles, is there a way to wait for ATLEAST 1 of them to complete (and it tell me which one)

#

For some context, I've scheduled about 10 jobs for different types, and need to do some follow up work after the job is done (that can't be in a job currently)

graceful mason
#

I have same question, I just have in my Update Loop..... for JobHandle in handles if .iscomplete()

#

but i guess that may be badd

stiff skiff
#

I currently just schedule all 10, and then loop over the handles and call .Complete and do the followup work

#

But this is very wasteful if the first one in the array is done last..

#

I could do the busy loop, but then it won't use the main thread for doing the jobs while waiting.

graceful mason
#

i love scheduling jobs to run over multiple frames πŸ˜„

zinc plinth
#

huuuuh, I get endless install for Entities with 2019.3.13 :(

#

any way to see what it's actually doing ?

#

ho nvm it was just rly rly long

opaque escarp
#

I had an issue with procedural meshes in DOTS where they would go missing when refocusing unity or creating them within a few frames of hitting play. It seems the issue was Unity was deleting them, presumably thinking there were no references to them since the references were unmanagaged. Is there a way to stop this, other than just creating a list of all the meshes in managed memory?

zinc plinth
#

isn't there an attribute to run stuff in the editor that should normally be only run in game ? @opaque escarp

#

tho idk if it works with dots systems

opaque escarp
#

that's a different issue entirely. I think the thing here is Unity now tries to automatically delete unreferenced meshes to avoid memory leaks. But it deletes the meshes being used because their references aren't known by the garbage collector

zinc plinth
#

hmm

opaque escarp
#

the way I'm dealing with it currently is just having a List of the meshes. That's it. Doesn't do anything, it's just there, and that fixes it.

feral elm
#

Hey, still new to DOTS and trying to wrap my head around the workings. If I make a temp native array in Start, why do I have to call dispose when I'm done with it? Shouldn't it get garbage collected automatically?

opaque escarp
#

nativearrays are not garbage collected, period

#

the whole of DOTS revolves around using Unmanaged code, which means there's no garbage collection

#

theoretically they could set it up so that .Dispose is invoked automatically if you use a Temp allocator, but idt they've done that

feral elm
#

Ah, interesting. I assumed since it was still C# it was still managed. How careful do we have to be about memory leaks (I understand the basic concept, but have never worked with unmanaged code)?

zinc plinth
#

in editor mode it will shout at you really hard if you have any leaks @feral elm

#

as long as you use properly implemented native containers

#

so NativeArray, the stuff in Unity.Collections, and the jackson dunstan ones are nice to grab

#

you just have to choose the right allocator for the right thing

feral elm
#

Awesome, I'll grab those and read up on them! Thanks @opaque escarp @zinc plinth

zinc plinth
ocean tundra
#

Is there a way to write (increase a component version number) only if a condition is met?

#

If i use ref in a Entities ForEach it will always think the value is changing

untold night
#

you could use an entity command buffer if you know nothing else will touch it before the command buffer system is run.

If you want to accumulate changes, you may want to look at NativeStream or NativeMultiHashMap<T,U>

#

depends on your usage patterns

wide fiber
#

Does something like an Heap container exists (NativeHeap doesn't exist)? I am trying to optimize A* pathfinding

undone torrent
#

hi there, where can i find subscene inspector script , i mean i want to know what happen when button edit is clicked

#

I mean

#
    void Awake()
    {
        GameObject aux = new GameObject();
        subScene = aux.AddComponent<SubScene>();

        Scene subscene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene,NewSceneMode.Additive);

        EditorSceneManager.MarkSceneDirty(subscene);
        EditorSceneManager.SaveScene(subscene, Application.dataPath + "/" + "EJEMPLO.unity");

        EditorSceneManager.UnloadSceneAsync(subscene);
        subScene.SceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>("Assets" + "/" + "EJEMPLO.unity");
        

    }
#

i have this test code for creating an subscene on editor but i need to add some sentences that made the same effect of edit button on click

#

this let me to convert gameobjects to entities via code on editor , i guess

#

please any kind soul there that want help a lost programmer

undone torrent
#

okey i just find the scripts

storm ravine
#

I had an issue with procedural meshes in DOTS where they would go missing when refocusing unity or creating them within a few frames of hitting play. It seems the issue was Unity was deleting them, presumably thinking there were no references to them since the references were unmanagaged. Is there a way to stop this, other than just creating a list of all the meshes in managed memory?
@opaque escarp It's known from 0.9.1 and they already working on fix, I reported that bug when they released 0.9.1.

storm ravine
#

Fix for this has landed in master, and will be in next release, also they will fix side issue with UnloadUnusedAssets related to this, in future

pallid rapids
#

Hi there! I'm new to DOTS and Unity Physics and I've been trying to find out how to grab (aka parent) physics bodies and release/throw them. I know about the Parent and LocalToParent components, but I can't seem to find the correct configuration. Any help would be appreciated! πŸ˜ƒ

dull copper
#

@pallid rapids ecs samples repo has physics samples. Most of those are configurred to use mouse pick script that basically does what you just asked

opaque ledge
#

Olento, burst .13 is up πŸ‘€

dull copper
#

Just post the changelog if you feel like it :D

opaque ledge
#

πŸ˜„

#

my pc is potat so it takes time to download

#

but yeah i will do πŸ˜›

dull copper
#

Been meaning to make a tool that polls these easier now that the convenient bintray polling is gone but there is quite much on my plste right now

#

I can post it in a bit too. Just not on computer right now

opaque ledge
#
### Fixed
- Fixed incorrect struct layout for certain configurations of explicit-layout structs with overlapping fields
- Fixed a bug where the `mm256_cvtepi32_ps` intrinsic would crash the compiler.
dull copper
#

Sounds like some minor fix then

golden elk
#

not necessarily dots related, but I assume there is no way to get a nativecollection of verts/tris from a mesh other than using CopyFrom, even though they do have a way to set them?

#

Yes I am taking a base mesh and basically generating a loft from it so I duplicate the vertices and offset along a path

#

I'll check it out thanks

stiff skiff
#

@opaque ledge Where you do get the notification of new package releases?

#

I previously just checked the notification stream on bintray, but that seems to be dead.

mint iron
#

0lento πŸ˜„

opaque ledge
#

πŸ˜„

#

i just check package manager time to time πŸ˜„

#

whenever i open my project rather

opaque escarp
#

@storm ravine thank you for reporting it, I was just about to myself

graceful mason
#

Anyone know a good way to share materials? I think that may be my issue with my "batches" count and also, my game loop is spending 60ms "Add New Batches"

#

worldManager = GameObject.Find("WorldManager").GetComponent<WorldManager>(); entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = mesh, material = worldManager.material });

#

Is what I do now, couldnt work out how to simply pass a material to my dynamic mesh

#

my objects are also all stationary, so ideally I need to work out the ECS wayt to: mark GameObjects as static using the Static checkbox in the Inspector

graceful mason
#

adding typeof(Static) seems to have helped a bit. Im sure my material is setup wrong thou πŸ˜„

wide fiber
#

Has anybody made a movement system in DOTS using physics without overwriting velocity? (2D)

I have tried a lot of different ways, but it doesn't work as expected.. I can't overwrite the velocity because the entity will be affected also by other forces

graceful mason
#

I think you just overwrite velocity

warped trail
#

i think you can look into physics character controller

graceful mason
#

as if you pull something-10 it doesnt care something else pushed it +10 ?

#

just dont overwrite the velocity, add to it, or subtract from it

wide fiber
#

The problem is that I can't add to it forever, I want a max speed thing..

#

I have done some tests, but it's harder than what I tought

#

I can't check the length of my velocity.Linear and if it is going slower, I add the force.. because the object would "move jerky"

#

i think you can look into physics character controller
@warped trail is it open source? I'll check it

wide fiber
#

Ty

graceful mason
#

so is this line of code, making a new Material instance of each of my meshes? worldManager = GameObject.Find("WorldManager").GetComponent<WorldManager>(); entityManager.SetSharedComponentData<RenderMesh>(chunkTerrain, new RenderMesh { mesh = mesh, material = worldManager.material });

opaque escarp
#

anyone else have an issue with intellisense when using Entities.ForEach? it doesn't seem to track the type arguments correctly, but in normal lambdas it does

coarse turtle
#

hmm when you access the param in the lambda?

dull copper
#

@stiff skiff I guess one could just make bookmarks of the specific packages and poll them too

ocean tundra
#

Hey guys.. Ideas on how to do RTS style drag select?
My options I've thought of

  1. All selectable entities are to have a "screen position" which is Camera.WorldToScreenPoint
  2. Calculate the camera frustum and figure out a Unity.Physics query somehow
stiff skiff
#

Yeah, but considering "packages" is now the new delivery method for features. I assumed it would have a place to subscribe for updates

ocean tundra
#

Any others I havnt thought of?

opaque escarp
#

@coarse turtle yeah, as in here, t.Value doesn't pop up in intellisense, even though it's the correct thing

#

interestingly if I cause a syntax error by removing the parentheses at the end, it works

coarse turtle
#

o - yeah I think I have the same issue

opaque escarp
#

I wonder if it's a VS issue or something with Unity's integration...