#archived-dots

1 messages · Page 159 of 1

icy kestrel
zinc plinth
#

the jobs system is tested thourouly, if anything some of your inputs are undefined or something

rancid geode
#

So, I found this line to be the culprit as of now, does anyone know why the commented out line (inside a job system) causes a big crash? Literally just that line
@icy kestrel maybe an IndexOutOfRange exception? your currentItemCount may be bigger than it was supposed to be (thus causing the crash)

icy kestrel
#

When removing the line and debugging the statement, I find that currentItemCount = 0 and items.Length = 25600. item also seems valid each time. I don't really see any errors here

#

My sort up procedure seems like it has to be the issue here since it involves a while true loop. Could this relate to my code above freezing? But this did work before outside of a Job System.

tawdry tree
#

You can compact that by inverting the if and breaking immediately

//Inside while
if(item.CompareTo(parentItem) <= 0))
  break;
//other stuff
#

What's the settings for the job? Without burst? .Run()?
How do you run it?

icy kestrel
tawdry tree
#

Burst jobs does not work with managed type AFAIK

#

Which means no arrays, no classes

icy kestrel
#

Oh ok, should I look at converting everything to native stuff so I can do that sort of thing? It means no Heap which increased my performance a lot

tawdry tree
#

As always, it depends.
It might not be worth it on account of complexity of code, debuggability, readability, etc, especially if changing away from it improved perf

icy kestrel
#

Ok I'll focus on trying to fix the issue at hand for now then, do you have any ideas? I'm completely lost xd

tawdry tree
#

Start by giving the while a safeguard

#

Which realistically speaking means turning it into a for running for like 1000 (or some other big number - estimate it to be a bit bigger than you ever expect it to run

#

that should stop it from running infinitely

#

And just to check, start with a low number, 10 perhaps, and increase it 10x each time

icy kestrel
#

I converted it to a for loop with 10 iterations and it still freezes and crashes

tawdry tree
#

Might be Swap that breaks? Does it do an array set?

icy kestrel
tawdry tree
#

Could be some trouble with array index of out of bounds and no exception from job

ripe plover
#

it crashed as in freezes? or closes @icy kestrel

icy kestrel
#

Brings my CPU to 100% and I have to force close Unity

stiff skiff
#

Sounds like a deadlock

icy kestrel
#

How are they caused?

stiff skiff
#

something looping forever

ripe plover
#

freezes, yup

stiff skiff
#

or something waiting on a thing to finish, that never finishes

icy kestrel
#

Ah yeah, but I don't have any loops left i dont think xd

mint iron
#

maybe its your compareTo, if that always returns > 0 you loop forever?

stiff skiff
#

I mean, that while(true) up there looks very likely

icy kestrel
#

Yeah they are all for loops now

stiff skiff
#

What does the updated code look like?

icy kestrel
#

Shall I just send a paste bin with everythiing in it?

ripe plover
#

maybe your CompareTo is broken?

#

mine is this

        public bool IsMoreEfficient(Node obj) {
            var CostA = gCost + hCost;
            var CostB = obj.gCost + obj.hCost;

            if (CostA == CostB) { return hCost < obj.hCost; }
            return CostA <= CostB;
        }
mint iron
#

this all needs to be rewritten as a native container i think?

stiff skiff
#

Just wondering, why write your own sort instead of the NativeArray Sort extension?

icy kestrel
#

Just converting now my old A* algorithm which came from an old tutorial^

#

I can't seem to find where my compareTo comes from

ripe plover
#

it depends on what T is

#

try searching on your IHeapItem<T> implementation

#

(probably the Node : IHeapItem..

icy kestrel
#

Oh right I see

ripe plover
#

try replacing it with mine 😛

#

yours should be returning -1, 0, or 1

#
    public int CompareTo(Node nodeToCompare)    {
        if (nodeToCompare.fCost == fCost) { 
          if (nodeToCompare.hCost == hCost) { return 0; }
          return nodeToCompare.hCost > hCost ? -1 : 1;
        }
        return nodeToCompare.fCost > fCost ? -1 : 1;
    }
#

I can't find the while loop in your posted script @icy kestrel

icy kestrel
#

The for loops were the while loops^

ripe plover
#

and removing them fixed the freezing, right?

icy kestrel
#

No xd

ripe plover
#

well good to know xD

#

how often do you request for pathfinding.Execute() ?

#

you gotta be careful in dots and async

#

because you can easily flood new threads and freeze your machine even with MonoBehaviour.Update()

#

is it easy to try requesting once per like half a second or so?

#

(or just on Awake())

icy kestrel
#

I have called it just once but will be ever 0.2s eventually

ripe plover
#

just once freezes it, huh xD

icy kestrel
#

Yep

ripe plover
#
int xxxx = 0;

while (openSet.Count > 0) { 
if (++xxxx > 1000000) { 
    Debug.Log("Breaking coz of this");
    break; 
}
...
icy kestrel
#

Ok ill try that

#

Got an interesting result from that

#

Still freezing, but my CPU is down to 0%

#

Won't come back tho

ripe plover
#

probs waiting on the job 😛

#
void Start() {
         PathRequest pr = studentComponents[i].studentStateManager.GetPathRequest(studentComponents[i].studentUnit.OnPathFound);

         PathFindingJob pathFindingJob = new PathFindingJob
         {
             _pathStart = pr.pathStart,
             _pathEnd = pr.pathEnd,
             _canClimb = pr.canClimb,
             _success = studentComponents[i].studentStateManager.success,
             _path = studentComponents[i].studentStateManager.curPath,
         };

         pathFindingJob.Schedule();
         pathFindingJob.Complete();
}
#

yeah no idea 🤷‍♂️ sorry

zinc plinth
#

you can only send native containers and blittable types to jobs, ofc it'll crash if you send managed types..

icy kestrel
#

Am I doing that?

zinc plinth
#

I don't know, I don't see the types of your variable; but you said you didn't know about that so I assume you did

icy kestrel
#

pathstart is v2, pathend is v2, canclimb is bool, success is nativearray<bool>, curpath is native list<float2>

#

it seems to be my memory that sky rockets rather than my cpu now

#

If I complete 1 job, then afterwards complete the job agaiin on different data, my game does not freeze. Any ideas why it doesn't work in parallel?

tardy spoke
deft stump
#

Rendermesh is an ISCD. so afaik, no.

#

what does the error say?

tardy spoke
#

Oh, yep

#

using Unity.Rendering;

#

I just assumed all the "defaults" would work out of the box - didn't even think of that for some reason.

icy kestrel
#

The new compareto method hasn't seemed to have changed anything

#

There's just something anti-parellel going on and idk what

mint iron
#

@icy kestrel is that link above still the version you're using, cause its got managed stuff in it like Vector2[] waypoints = new Vector2[0]; and List<Node> path = new List<Node>(); and new HashSet<Node>() im suprised it even compiles. You also cant use foreach unless you have a struct with foreach(ref whatever construction.

icy kestrel
#

It is yeah, I thought I could use any temporary variables I needed, oops. Am I not able to use my Heap too?

ocean cloud
#

Is the GameObjectConversionSystem only available at the start of the program?

#

Can I somehow access it on runtime to add prefabs etc

minor sluice
#

I think you can use
GameObjectConversionUtility.ConvertGameObjectHierarchy

#

or maybe other methods within the GameObjectConversionUtility class

ocean cloud
#

Alright thanks

#

GameObjectConversionUtility.CreateConversionWorld would be really useful but sadly it's internal

mint iron
#

@icy kestrel if its got class on it then you can't use it. External static methods that live on a class can be called from within the job, but anything passed in or created within has to be a struct. This is pretty old now but might help https://github.com/jeffvella/UnityAStarNavigation/blob/master/Assets/Plugins/Navigation/BurstAStarPathFinder.cs

icy kestrel
#

Ok thanks

tight blade
#

Does anyone know if theres a way to get around the whole "you need a class with the same name as your file" restriction? I want multiple component definitions in the same file, like real bad

tardy spoke
#

Not sure what you mean. I thought with ECS stuff the script filenames could be named whatever.

#

I did notice however that I was getting that error when there were compiler errors present though. It seemed to treat my ECS component as if it were a monobehaviour and gave that error until the compiler error was solved for some reason. Kind of hard to describe, and probably not your issue, haha.

tight blade
#

try adding a component that isnt named the same thing as the filename to an object in the editor real quick and report back

minor sluice
#

I have multiple IComponentData implementations in the same class without an issue,
but with monobehaviours that doesn't work

tight blade
#

yeah, theyre allowed in the same file, but you cant attach them in the editor

tardy spoke
#

kk I'll give it a shot

tight blade
#

okay now go to "add component" and add that component

#

maybe you can drag it onto it, Im not sure. thats actually a reasonable possibility, but you definitely cant get them in the "add component" search bar

tardy spoke
#

I drag and drop

#

Add component may interpret as a monobehaviour

#

ill chekc

tight blade
#

yeah, I hadnt actually thought of dragging and dropping, so thats a good enough workaround for me!

#

oh wait, no it doesnt

tardy spoke
#

Make sure your system is referring to it correctly by the updated name or whatever as well

tight blade
#

because if there are multiple components in the file, what would I be attaching by dragging it on?

#

yeah no, it just doesn't work.

tardy spoke
#

Hmm a component can hold more than one piece of data

tight blade
#

Im saying the thing thats impossible is adding a component from the editor that isnt named the same as the file

tardy spoke
#

Checking

tight blade
#

right, but add multiple component definitions

#

to that same file

tardy spoke
#

like multiple pieces of data or additional components?

tight blade
#

multiple structs

tardy spoke
#

right

tight blade
#

so make public struct AComp: IComponentData {} and public struct BComp: IComponentData {} and then add either one in the editor

tardy spoke
#

Tried with and without the multiple [GenerateAuthoringComponent]s,
It works, but only seems to register the first struct. No access to others.

tight blade
#

mhmm

#

well, appreciate the effort to confirm lol

tardy spoke
#

Is there a specific reason to not just put multiple pieces of data inside one component? Trying to keep things modular?

tight blade
#

they get attached to different entities

#

the same archetype wouldnt necessarily have both

#

and there is a semantic difference

#

between which ones have either

tardy spoke
#

Ah. Maybe it'll come in an update, haha. This stuff seems to be changing all the time.

tight blade
#

yeah, I imagine so

tardy spoke
#

I can't even figure out how to change materials and there's no tutorials on that, so you're way ahead of me, hahaha.

tight blade
#

i just figured if anybody knew an annotation or something to opt into the add component menu that bypassed the filenaming restriction, it'd be somebody here

#

its not a huge deal

tardy spoke
#

There are people here who are far more knowledgeable than I would be so ... have hope, haha.

tight blade
#

again, I appreciate the effort to sanity check me, though

tardy spoke
#

No worries!

#

I give back where I can within my limited capacity since I ask a zillion questions. Seems fair.

tight blade
#

yeah, I hear that

tight blade
#

does anyone happen to know, if I make a new NativeArray<int>(100, Allocator.Temp) is that initialized with zeros?

#

or is it uninitialized and undefined

safe lintel
#

id guess it would be zeroes

tight blade
#

particularly if I'm just using the pointer

#

yeah, that'd be my guess too

zinc plinth
#

arrays are not cleared afaik; would take too much time

#

also @ocean cloud be carefull with ConvertGameObjectHierarchy

#

it will create a new ConversionWorld on each call, so you want to call it really really few times

tight blade
zinc plinth
#

what you can do is put everything you want converted under a parent empty go, so that you only do that call once
tho you'll need to use the GO names as identifiers for the entities and use the conversion flag AssignName; you'll also need to skip one frame/create a new ParentSystem right after the system that's calling ConvertGOH because the only way to get those entities is via the root entity's childs

#

(you might be able to get a LinkedEntityGroup in the root entity, not sure if one was created when I did it)

#

but the LinkedEntityGroup will link every entity in that hierarchy, not only the real "top" ones, so it's up to you how to want to deal with it

hollow sorrel
#

arrays are not cleared afaik; would take too much time
@zinc plinth
the default constructor does clear

#

same as regular C# otherwise you could get unexpected behavior

#

i think you'd only not clear if you 100% know you're gonna assign each value before accessing

zinc plinth
#

why would you access before assigning GWaobloChildPepeShrug

#

that's undefined behavior in every unmanaged memory languages

hollow sorrel
#

plenty of times where you'd be fine with the default value instead of looping and assigning each value first

rough crown
#

Guys, I know you probably get this question a lot. but is there any up to date tutorial about making a complete game with dots? not just simulating large number of characters on screen moving? I've stumbled upon some recently but they were using some older versions of the Entities package

tardy spoke
tardy spoke
#

Finding good up to date tutorials on ECS is pretty painful at the moment, haha. Lots of weird crap about 100,000,000 blocks, no tutorials on how to change a material on an entity.

opaque ledge
#

havent checked but its 1 month so quite recent, maybe you can learn some stuff, i wanted to watch but never had the time

#

part 3 was recently published i think, should be more info in their youtube channel

tardy spoke
#

My strategy is searching YouTube and sorting by upload date.

zinc plinth
#

@tardy spoke docs will help you more than any tutorial for this

tardy spoke
rough crown
#

@tardy spoke thanks, I think I ill check out this course for now

zinc plinth
#

for anything rendering related you want to search threough the hybrid renderer docs

#

not the entities package

tardy spoke
#

Pretty spartan manual for the hybrid renderer as well at the moment, though

#

they show animating a material's properties, but no example of replacing a material. Might not be possible?

#

Might need to reinstantiate with a matching entity with the different material or something

#

@opaque ledge thanks for pointing out that YouTube video, I'm watching it now

#

@rough crown I haven't checked this out yet, but I hear the new "visual scripter" is a good way to learn some ECS stuff since you can view the code it generates. I would imagine the code it generates would be fairly current if it's been updated recently.

https://www.youtube.com/watch?v=nqt3p1n342A

tight blade
#

lol, is there a system thats supposed to be updating WorldToLocal? I just naively add it to my entity and it just stays float4x4(0) forever

hollow sorrel
#

@tight blade yea one of the ones that's in TransformSystemGroup

tight blade
#

yeah no I see it.. something weirds happening here

tardy spoke
#

Those are auto converted GO's to entities

#

As to whether they're actually updating I'd have to move one and check, but I think they are

hollow sorrel
#

there should be an EndFrameWorldToLocalSystem but you need both a LTW and a WTL component for it to run

tight blade
#

yeah. something subtler and stranger is going on. They definitely show in the inspector as having updated values, but I have a breakpoint in my system, and, even though they hit the query, they are float4x4(0) at the time the system runs. Might have screwed something up with my job dependencies

#

ugh, thats so weird. Whatever, I guess I'll just do the matrix invert myself for now until I figure that out.

opaque ledge
#

you mean LocalToWorld ? never heard of WorldToLocal before

hollow sorrel
#

btw does anyone know if a sync point only completes jobs in that world, or across all of unity/every world?

#

i would guess only that world but it's not the first time unity does weird things

#

nvm seems it is only per world thank goodness

tight blade
#

@opaque ledge WorldToLocal is just an Inverse of LocalToWorld for transforming world positions into local space

tardy spoke
tight blade
#

hmm? What no, its totally a thing. I mean I'm having trouble with it at the moment but yeah its a thing

#

its the inverse of the LocalToWorld matrix, calculated at the end of every frame

#

Yeah @tardy spoke I don't have the context behind what you're solving, but yeah conceptually you seem to replicating the notion of converting worldspace coordinates into player local coordinates

tardy spoke
#

I guess it wouldn't be difficult even just to invert the regular localToWorld, but it'd be handy if it's already in there, haha.

#

Ah, solving float rounding errors on on extremely large unity maps is the application.

tight blade
#

yeah, my use case is also efficiency. I calculate each entity (of a certain type) in the space of each other entity. So there are overlaps, and if any other systems use the wtl, i wouldnt want to duplicate that effort. matrix inverses are not exactly cheap

tight blade
#

errrgh god, does anyone know of a way to recursively disable unsafePtrRestriction? its getting thrown when I try to use my EntityQuery.CopyFromComponentDataArray

#

its not letting me do it though. God I hate the EntityQuery API so much

#

ugh. okay I finally cobled together the correct sequence of ad hoc job structs to safely dispose of this array after copying back to the Archetype

#

well, apparently it just doesnt allow you to use the WorldToLocal component that they calculate, because of course it doesnt.

hollow sorrel
#

@tight blade is your system order set up correctly?

tight blade
#

I mean I think they calculate it at the end of the frame, I'm just surprised that I don't get the values from the previous frame when mine updates

#

They must calculate it then reset it back to 0 specifically to foil this operation

hollow sorrel
#

that'd be weird as the only place they're using it is WTLsystem

#

but yea you should at least get value from previous frame

coarse turtle
#

hmm is there any way to hook entities with gizmos? I'd like to debug something visually and draw cubes as a quick implementation 🤔

tight blade
#

If you figure out the answer please report back, @coarse turtle . I havent been doing DOTS (or Unity or C#) for long, and that's been on my wishlist

safe lintel
#

theres a 3rd party asset called Aline @coarse turtle for job compatible gizmos

coarse turtle
#

oh neat - i remember someone posted a screenshot of something, I'll take a look, thnx @safe lintel

safe lintel
#

every translation should i say

coarse turtle
#

oh neat, I think this will be great to implement in my own physics engine 🙂

hollow sorrel
#

dat fps tho

ocean cloud
#

it will create a new ConversionWorld on each call, so you want to call it really really few times
@zinc plinth Thanks for the info! That is what I need, I need to add prefabs only at a scene transition

zinc plinth
#

then follow the tip I gave afterwards

#

it's annoying to setup but ho so worth it

ocean cloud
#

Wait so every call ConvertGameObjectHierarchy in one frame will create & destroy the system each call?

zinc plinth
#

*world, and yes

ocean cloud
#

Yikes, I called that tens of times at scene load atm lol

#

So by your method, the way to get the converted entities (child of the root GO) is by their name?

#

Although the root entity is a clean way to clear the prefabs, that's for sure

zinc plinth
#

first system: create your root go and instantiate everything you want to convert as childs of it
parentSystem [UpdateAfter(FirstSystem)]
secondSystem [UpdateAfter(MyParentSystem)]: get childs of root entity, check their names

#

and make sure that you remove LinkedEntityGroup from the root entity before you destroy it

#

otherwise you'll destroy everything

ocean cloud
#

alright I'll try, by parent system you mean those built-in systems in TransformSystemGroup right? just for getting that Child buffer component data from the root entity

#

why's 5argon's blog down at this moment 😫

zinc plinth
#

you can create new ParentSystems whereever you like; they will setup the parent and children components; you just do it bvy creating a class extending ParentSystem

ocean cloud
#

ah alright, thanks

zinc plinth
#

when CGOH gets executed the children relationship isn't set, so if you don't want to wait a whole frame you have to create that system

vagrant lotus
#

I am trying to use a native array of componentdata(from entity query) in scheduleparallel() jobs, how do i do so?

#

if the answer is blob asset, how do i convert a native array to blob asset>

safe lintel
#

query.ToComponentDataArray<T>(Allocator.TempJob);

#

@hollow sorrel so many things influence the editor framerate, one of which being reverting to factory layout 🙂

hollow sorrel
#

hah fair

vagrant lotus
#

Wait, so I can use native array with .scheduelparellel?

#

@safe lintel

safe lintel
#

yea

#

what does your code look like?

vagrant lotus
#

sorry for not being respondsive

#

im using systembase

opaque ledge
#

yeah you can use it, but you have to remove safety restrictions on bounds

#

before ScheduleParallel, you have to do .WithParallelRestriction(bounds) or something like that, i forgot the method's name now

vagrant lotus
#

ok

#

thank you both of you😬

vagrant lotus
#

WithNativeDisableParallelForRestriction(myvar) — permits multiple threads to access the same writable native container. Parallel access is only safe when each thread only accesses its own, unique range of elements in the container. If more than one thread accesses the same element a race condition is created in which the timing of the access changes the result. See NativeDisableParallelForRestriction.

#

so basicly if im only reading from it, nothing bad will happen?

tawdry tree
#

If you know that they don't use the same indices it's fine.
If they use the same indices, and it's purely readonly, it's fine
But if they use the same indices, and some write and some read... hoo boy, that's gonna be fun debugging

vagrant lotus
#

thank you

#

here is a silly question, how do i have a refference to a Ibufferarray of ibufferelement in a Icomponentdata

#

it would only be readonly

tawdry tree
#

Where are those interfaces from?
Do you mean the Dynamic Buffers?

vagrant lotus
#

yes

#

as in the dynamic array formed automaticly with IBufferElementData

stiff skiff
#

Note that you're disposing that bounds array before the job is done

vagrant lotus
#

Not asking for the same bounds array

#

As in IBufferElementData under another entity

#

Without using get buffer as it is not multithread, and not performant

mint iron
#

id like to help but i don't understand the question :S

vagrant lotus
#

Yeah

#

Been scratching my head

#

Basically, how to have and handle a reference to a dynamic array

mint iron
#

does the array have to be attached to an entity? fixed size or must be able to grow? should it be accessible from Foreach args?

vagrant lotus
#

basically, it is a Dynamic Buffer made with IBufferElementData, ECS build these DB with IBED automatically,

#

you can access them just like regular IComponentData in the Entities.Foreach((here) =>)

#

but what i want is a reference to it

north bay
#

The reference to the DynamicBuffer is the entity to which the buffer belongs

vagrant lotus
#

the problem is that i want to read it from another Entities

#

like Foreach(() => {access another entity"s buffer})

#

readonly

north bay
#

Try GetBufferFromEntity<IBufferElementData>(), that gives you an array like access to dynamic buffers of other entities

#

You can pass true as an argument to get a readonly variant

vagrant lotus
#

wait, i can use this with schedueparalell?

north bay
#

You probably have to force disable some safety to use it in ScheduleParallel

#

I don't use ScheduleParallel very often

vagrant lotus
#

ok

#

guess this is the problem with unity preview

#

instruction unclear

north bay
#

Try it out and see if something breaks

minor sluice
#

Short question: Is there any good example for how to efficiently perform a Point distance query in unity.physics? should I look into the EntityComponentSamples or does anyone know a good example for it?

vagrant lotus
#

will do

minor sluice
#

I assume CollisionWorld.CalculateDistance has a synchronous execution, but does it use jobs internally?

north bay
#

No, but you can call it from a job

#

There's a little text about Cast Performance inside the physics docs under Collision queries

minor sluice
#

ah, thanks,
so currently I just call it in an OnUpdate method within a class extending SystemBase.
I was reading just above this section "Cast Performance" up until now, read the section now too, but I'm still not sure,
could I simply put this into a regular IJob struct?

here is the relevant part of the current code
(I think the job would just be responsible for filling the nativeList then)

// https://docs.unity3d.com/Packages/com.unity.physics@0.4/manual/collision_queries.html
            var physicsWorldSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BuildPhysicsWorld>();
            var collisionWorld = physicsWorldSystem.PhysicsWorld.CollisionWorld;

            var pointDistanceInput = new PointDistanceInput
            {
                Filter = playerHitFilter,
                MaxDistance = playerColliderRadius,
                Position = queryWorldOriginPoint
            };
            if (collisionWorld.CalculateDistance(pointDistanceInput, ref allHitsTemp))
            {
                var entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;
                int hitLength = allHitsTemp.Length;
                for (int i = 0; i < hitLength; i++)
                {
                    var hitInfo = allHitsTemp[i];
                    Debug.Log($"Player query has hit collider {hitInfo.ColliderKey.Value} with distance {hitInfo.Distance}");
                    // Checking if we have the right object?
                    if (entityManager.HasComponent<EnemyComponentData>(hitInfo.Entity))
                    {
                        Debug.Log($"Player was hit by enemy");
                    }
                }
            }
#

I just got an advice that I could use a regular For(Each) job and query all the static colliders that way, but that's probably more inefficient than letting unity handle the broadphase properly.

I'll try performance of the current code and check if there needs to be an optimization, if so, maybe I'll represent the player as regular dynamic collider in the physics world then, I think that might require less manual work to setup

vagrant lotus
#

thanks a lot😬 @north bay

#

BufferFromEntities<> works

minor sluice
#

with 750 entities to query for my point overlap check, it takes 0.8ms, I think that's a great performance for now, even though it would probably be better, so maybe I'll revisit it later 🙂

zinc plinth
#

0.8 ms is a massive amount of time

minor sluice
#

oh okay,
probably will try out different things then (the 750 entities are also only sphere colliders)

pliant pike
#

I don't suppose anyone knows how I move an entity between different worlds?

minor sluice
#

no idea, but could you simply make a copy maybe, like?
entityManagerOtherWorld.Instantiate(entityThisWorld);

zinc plinth
#

This would work

minor sluice
#

and then maybe delete the entity in the old world if necessary

pliant pike
#

is in a subscene world so I guess I can get the entitymanager from that world and then copy to the default world 🤔

#

I'm using a gameobjectconversionsystem also so I have to the use the DSTEntityManager

#

I'm guessing that just works the same

minor sluice
#

I'm not sure at which point the convert method is actually executed, but maybe you could get the subscene world as static variable somewhere and use that within your conversion method?

#

to copy the entity over?

pliant pike
#

yeah I think I get it, thanks a lot

#

I'm sure things used to be simpler, entity's were created in the default world before

minor sluice
#

I'm just diving into ecs for a simple task at the moment, but I see that a lot of approaches will be deprecated starting with 2020.1, like JobComponentSystem jobs being replaced with regular entity queries and such,
but I think I'll wait a bit and see what changes they make before I try to extensively use it

#

It has been working for me pretty well so far though, especially the job system part

scenic kayak
#

Is there anyway to use lists and multidimensional arrays with unity jobs

#

i tried it and it seems to be giving me an error

#

Im using unitys job system to generate the meshes of terrain chunks in parallel however i keep getting the error 'GenerateChunkMeshJob.Vertices is not a value type. Job structs may not contain any reference types.'

This is the code for the job: https://pastebin.com/XEcaDWu5
This is the code for the execution of the job: https://pastebin.com/r2H36LFs
Basically, the chunks that need to be updated get sent to a queue. The update chunks method should then execute the jobs in parallel for the chunks in the queue. How do i fix the error?

#

ive tried importing a library for creating native lists and flattening the 3d array but its not working too well for me

mint iron
#

Vertices is not a value type. Job structs may not contain any reference types.' you need to use only unmanaged things

scenic kayak
#

what does that mean?

mint iron
#

it means you can't use List<T> or anything[] because they are managed types (classes)

tardy spoke
#

Isn't it something along the lines of "blittable data only" inside jobs or whatnot.

scenic kayak
#

how do i get around this?

tardy spoke
#

I believe there are replacements for list that can operate inside of jobs called "NativeList", etc, but I could again, be wrong there.

mint iron
#

i believe you can, with some hackery, pin a managed object and use reflection to get access to an underlying array (like in the case of a list) but i think you'd only consider that if you don't have control over the list (like its something internal to unity core)

scenic kayak
#

i found this but i cant seem to use it

coarse turtle
#

Make sure you use the Unity.Collections namespace

scenic kayak
#

yea i did but i still cant seem to use it

tardy spoke
#

@scenic kayak if you're activity learning DOTS I recommend watching how this guy does things. It's recent and it's pretty enlightening compared to a lot of videos on DOTS. @opaque ledge showed me this.

https://youtu.be/JkiJoAufH9A

coarse turtle
#

I'm not really sure what you mean by, can't seem to use it

scenic kayak
#

as in i cant access it

#

when i type NativeList<Vector3> there is red line saying it doesnt exist

#

if that makes sense

coarse turtle
#

Are you using assembly definitions in your project?

scenic kayak
#

i have no idea what that is

tardy spoke
#

This is an odd question but do you have all the correct packages for DOTS?

scenic kayak
#

im just using the job system

coarse turtle
scenic kayak
#

its not working for me

zinc plinth
#

Vector3 is not blittable

#

use Unity.Mathematics stuff

#

so float3

#

also tf is that declaration

tardy spoke
#

Damn... I said that then deleted it because I barely know anything. Should've went with my gut. 😛

zinc plinth
#

your announcing a type, not making a constructor call.....

coarse turtle
#

Get rid of the ()

scenic kayak
#

still doesnt work...

#

is it part of a package i need to import

zinc plinth
#

actually nvm Vector3 is blittable, it's a struct Eyes

scenic kayak
#

i already imported mathematics and jobs

zinc plinth
#

but Unity.Mathematics gets vectorized by burst, so use it instead

coarse turtle
#

Im assuming by default importing in Jobs also imports Collections

#

it's been a while since I looked at the package manager dependencies 🤔

zinc plinth
#

I always install the "dots editor", it has all the dependencies we need kinda

coarse turtle
#

also it might be the IDE complaining if it didn't load the .csproj properly

zinc plinth
#

I always get problems if I start rider before unity with packages not getting recognized

coarse turtle
#

same for vim/vscode

scenic kayak
#

i think i need to include an assembly in order to use native list

#

thanks for all the help :)

zinc plinth
#

you shouldn't have to do an,ything appart from having Unity.Collections installed and starting your ide once unity is fully launched in project

willow plaza
#

Hey people. What's the correct way to use a Raycast or CastCollider in the Entities.ForEach job without getting Dependencies error bullshit?

icy kestrel
#

What's a good way of off loading jobs into multiple frames? I have 1000 pathfinding job requests every now and then and I'd like it so I don't need all 1000 from the frame I call it. Any suggestions?

tardy spoke
willow plaza
#

@tardy spoke thanks! I'll give it a try.

tardy spoke
willow plaza
#

hmmm... so they have actually a separate struct that does all the raycasting...

#

but maybe what I need is the UpdateAfter EndFramePhysicsSystem...

tardy spoke
#

I'll see if I can grab a screenshot of it @willow plaza

willow plaza
#

thanks. I see they basically do the same as me, except in a separate struct. I think it's the update order that is the issue after all.

tardy spoke
#

Yeah, the guy doing the tutorial mentions that it's like a potential rough edge on DOTS that may be smoothed out that you have to specify that order "tag" not sure what [this is called], haha. Vid is from like 6 months ago, but I think it's still pretty current.

willow plaza
#

Hmmm... Still doesn't seem to work...

#

I guess I don't need a raycast there...

tardy spoke
#

Some of the other people here can likely help if you post the code up. Some experts around for sure.

willow plaza
#

Yeah, well, I really don't need a raycast in this case.

tardy spoke
#

Perfect! Problem solved. 😄

tardy spoke
#

This is a pretty naive question, but what is something you could with "EntityQuery" that you couldn't just do in a typical entity forEach system loop?

mint iron
#

bulk add/remove operations on all matching entities

#

you could do it in a foreach with ECB one at a time, but query version just changes the archetype

tardy spoke
#

Ah, okay, cool. 😄

knotty radish
#

Hey everyone (I will ask here too since it's related), is anyone using a beta or alpha version of Unity right now? If so, do you have any DOTS packages in your project?
If you don't, could you take 2s and check something for me (I'm looking at if I need to report a bug or not).
With the preview packages enabled, just check if you are able to find the Entities package in the package manager.
thanks :x

willow plaza
#

That would be a pretty big bug. Don't think they could've missed it...

hollow sorrel
#

it's not a bug

#

it's intended (not saying i agree with it)

#

@knotty radish tl;dr you have to add the package manually now

knotty radish
#

Wat

safe lintel
#

wow thats a big change

knotty radish
#

Thanks @hollow sorrel, don't know how I missed that thread/blogpost. I wish they did something just like the preview packages with a toggle.
I will watch that thread and wait for the new solution they will implement :(

hollow sorrel
#

yea it's easy to miss hidden in a relatively unused corner of the forums

#

i guess the intention for the change is to prevent people from stumbling on it but that's already the point of the preview package toggle so dunno why they went this far

#

kinda defeats the point of a package manager

safe lintel
#

i think there are a growing amount of people who stumble into entities and try to use it then like bounce off it and think its representative of the final product

#

so i kinda get where they are coming with this

knotty radish
#

I feel like it's because a lot of relatively new Unity users try to use those preview packages and then flood the forums with questions about "missing features" or "why is not working with my old unity version"

safe lintel
#

i dont think its just the new users 😅

knotty radish
#

While most of other devs know what "preview" or "experimental" means

#

There is a lot of people crying (for nothing) these days be it around packages or Unity updates

#

Like when they see a version saying "verified" or "LTS" they will say it's not stable enough or it's missing features and at the same time they don't understand why an experimental/preview package may have some bugs

#

Anyway I won't start a meaningless debate here :P
Thanks for info and happy coding!

tardy spoke
#

That's a bad UX choice. They should've just changed the name to experimental packages if they want to discourage use, or even more harsh "unstable packages".

#

And ECS isn't that bad. I suck and I'm figuring it out slowly. I would say entering the current javascript ecosystem is a lot more difficult.

safe lintel
#

maybe they should call the preview / experimental stuff unsafe, surely there would be no mistaking it could be a rough ride 😉

tardy spoke
#

Yeah, exactly. Unsafe would be fine.

#

If I have to manually enter the packages in the manifest does that mean I have to manually check for updates and paste over it each time? :\

pliant pike
#

they should have big bold warning letters in red

#

but at least keep them in the package manager that's what its great for after all

tardy spoke
#

Just have it when you select it it pops up and says "do you expect this to be a representation of the finished feature?" and if you click yes it deletes Unity from your hard drive

#

Not to mention that change breaks ALL ECS tutorials that showed getting the packages from the package manager, which is all of them.

pliant pike
#

there's no way I'm going to figure out how to edit the manifest or get them from github or whatever

tardy spoke
#

Oh, it's easy.

pliant pike
#

for you maybe leahS

tardy spoke
#

lol ill show you, one sec

safe lintel
#

if you can use dots, you can edit the manifest 🙂

tardy spoke
#

That's essentially how the package manager works, it adds and removes lines from there and then your system reads it and is like "ah, I need this stuff". So it's like you're editing which packages you have installed "directly" kinda.

#

and it'll detect changes you make. if you delete a package from there and run your project, it'll remove it.

safe lintel
#

potentially a problem is if it also hides dependency packages that need to be updated if you have a conflict, it can be done by manually checking out the registry site(ie https://packages.unity.com/com.unity.animation) and figuring out those dependencies yourself but its gonna make resolving issues a lot more of a pain in the ass if they really crack down hard on hiding preview packages

pliant pike
#

I don't know it seems pretty complicated to me leahWTF

tardy spoke
#

actually let me check something

#

Still pretty painful though, if I start another project and have to get the DOTS packages I'm not sure exactly how i'd go about it without the package manager to round them up.

#

@safe lintel after it's entered into the manifest I think you can view it in package manager to view dependencies, no?

pliant pike
#

yeah it just adds unnecessary complexity

tardy spoke
#

Agreed

safe lintel
#

should but its useful to know that site exists to view stuff that isnt shown or mentioned at all

tardy spoke
#

Yeah, hmm

#

I wonder if they'll end up changing it back, because I don't think feedback from people who don't really understand experimental packages is worse than 5,000 people now asking how to add packages that they saw being added in tutorials

pliant pike
#

I think they are just renaming them though to make them clearer, so they will return to the package manager at some point hopefully

tardy spoke
#

That's possible. And probable really. I'm sure they have UX people on staff that would obviously recommend against this move unless it was for really good reasons.

knotty radish
#

should but its useful to know that site exists to view stuff that isnt shown or mentioned at all
I miss bintray :(

tardy spoke
#

It seems like in DOTS they have a great system so far for simple entity mass creation/mass manipulation. I hope they can simplify the syntax for physics collisions etc to be a little less verbose, though, haha.

pliant pike
#

they need the feedback of people like us to improve it

tardy spoke
#

I would be they're working on that and just haven't got around to it yet.

#

Most the moves they make seem to be in the right direction

pliant pike
#

and there's going to be less people using it if its not in the package manager

tardy spoke
#

That is true

mint iron
#

the two big issues remaining seem to be subscenes and animation

#

the guy who was working on a subscene demo was saying a month or so ago in here that they break pretty hard with crazy load times when you start to use a lot of them, so maybe they're rethinking it.

#

for animation i'm yet to see anything that even remotely resembles a solution, the animation package has been getting updated but there are no demos at all on how to use it.

safe lintel
#

seems like the experimental animation preview subforum(jeez all these names are becoming a mouthful, like universal renderpipeline asset renderfeature) has devs from the anim team to respond to things, they mentioned refactoring rootmotion as something that could be delaying a samples update

#

but there was an update that had some changes around rootmotion and not sure if that was it or just one part of an ongoing thing as there havent been updates

#

anyway its kinda disappointing that of all the new systems, you get the most dev responses from the non unity team at havok

zinc plinth
#

lmao

#

thing is there's just so damn stuff they want to focus on at the same time that progress feels super slow on everything

pliant pike
#

I dont suppose anyone knows how I get the EntityManager from another world?

#

I'm trying to use this method EntityManager.MoveEntitiesFrom()

tawdry tree
#

Step 1: Get the other world
Step 2: World.EntityManager

pliant pike
#

ok good point I've got to find the world first 👍

tawdry tree
#

Usually you'd capture a reference when you make it... are you using the physics world or something?

pliant pike
#

its a subscene world

tawdry tree
#

To or from the subscene world?
And what world is the other one? The main world?

pliant pike
#

I'm moving an entity from the subscene world to the default world

amber flicker
#

for what reason? I ask because livelink basically does this

pliant pike
#

I'm trying to use a gameobjectconversionsystem to create convert some scriptableobjects into entity's

#

I've created an entity in that system and it creates it in the subscene world, I'm sure it didn't used to be that way, or maybe I'm confused

amber flicker
#

hmm.. my suspicion is that livelink settings have confused what's going on for you

tawdry tree
#

Doesn't that have both an entitymanager and dstEntityManager?

#

I know you get that with some of the conversion options.
(and it's easy to get confused about)

pliant pike
#

yeah it has a dstentitymanager

amber flicker
#

yes - though fyi neither of those are the editor world

tawdry tree
#

The destination entity manager is the world it ends up in ^.^

#

Should be the correct world at runtime?

pliant pike
#

nope I use the ordinary entitymanager and it doesn't appear to work at all

amber flicker
#

in case it helps explain... when subscene's open there are 3 worlds involved - 1. 'Converted Scene: Subscene', 2.'GameObject -> Entity Conversion Subscene' and 3.'EditorWorld' - 2 is where the conversion happens, 1 is where the resulting entities are copied to (so 2 always appears empty basically). When you have Livelink enabled then the entities in 1 are also copied to 3.

pliant pike
#

ok this is confusing, it appears its in a shadow conversion scene leahWTF

tawdry tree
#

entityManager is for a temporary world - changes to the specific entity should take effect, but changes to other entities should be with the dstEntitymanager

#

Not sure how adding new entities plays into that - from what Timboc says it should work either way?

amber flicker
#

in the case of converting entityManager refers to 2 and dstEntityManager refers to 1

pliant pike
#

so maybe I should enable livelink?

amber flicker
#

it might make it less confusing but I'm not sure really helps with your issue

#

my guess is you don't need to move your entities

pliant pike
#

its not confusing at all leahWTF

amber flicker
#

😅

#

I've had a headache trying to work this out

pliant pike
#

ok I'll try with and presume the data is there and see how it works, thanks

amber flicker
#

you know the entity debugger has a world drop-down right? so you can see what entities exist in those subscene worlds

pliant pike
#

yeah that's how I found the shadow world leahS

amber flicker
#

so hopefully you don't have to presume anything 😬 - lmk if you have specific questions

pliant pike
#

no worries will do, thanks

hollow sorrel
#

anyone happen to have a simple systems editor window? both entity debugger and the system window (from editor package) only show worlds that use the default playerloop and for some reason heavily depends on it

#

just gonna make one but if someone already has one that'd be coo'

amber flicker
#

sorry, not had a need for something like that yet

#

@pliant pike In this: (In Open subscene) this timeline shows ScriptableObject being inspected. When e.g. SO value changed, conversion runs, livelink patches corresponding entities in conversion world to editor world which the timeline preview then updates at edit-time. Few issues related to timings of when things happen and still bugs to squash but it can kinda all work.

hollow sorrel
#

ooo is that timeline with entities

#

that is sexy

amber flicker
#

yea front end to the tween library I've been working on

zinc plinth
#

ho so it's not public

amber flicker
#

will be a paid asset on the store that I hope somebody buys 🥴

#

serialized animations supporting relative values, works with hybrid & pure, custom monobehaviours or icd's etc

pliant pike
#

that's cool I did not know you could do that

mighty whale
#

is there any common mistake that could lead to the render meshes disappearing at the start of my game ?

#

im doing a minecraft like game and rendering with one mesh per chunk, and basically everything is fine as long as i keep my render distance to 3, but at 4 (sometimes 5) all the meshes appear for like a frame before disappearing right after that

mighty whale
#

I may have a clue but im not sure

#

so to render something i have to use the RenderBounds component somewhere, and i dont remember if I have to set the Center attribute to coordinates in the world or relative coordinates (and if so relative to what ?)

#

i can't seem to find this info

#

and in the entity debugger i can see that the mesh are going missing, with no error message in the console

#

this does not happen below a certain render distance

scenic kayak
#

Im a little confused on how to use jobs in my code. This should create a chunk generation job for each chunk object in the queue but im not getting the results i want

#

i just want to make sure that im creating the jobs correctly before i look into the logic side of things

willow plaza
#

That code looks different from regular jobs scheduling in so many ways... I'm not even sure you get back any results from the job and you also schedule and complete them one by one, so it's basically the same as executing them on the main thread...

willow plaza
#

Is there an alternative to Vector3.ClampMagnitude for float3?

warped grove
#

HI all, I'm looking for any tips regarding conversion of code into the jobs system. In my case, I'm looking to take my chunk loading code and distribute it across cores through the jobs system. Any help would be greatly appreciated

minor sluice
#

to use data in jobs, the data should be in structs, but unity has its native collections like nativelist and native array that you can use in jobs too,
I think I just looked here https://docs.unity3d.com/Manual/JobSystem.html

and basically, you could either set up your data structure to fit as input for a job, or you can use regular multithreading with plain c# threads

#

the benefit is that you don't need to have all data as structs, can utilize static variables etc., but most unity api methods are still not allowed to be called from anywhere except the main thread

#

it would also be possible to make an instruction queue, if methods need to be executed in the main thread, you could use a queue for tasks that the other thread can fill, and a regular monobehaviour in the main thread can poll the content each frame and execute it

#

math.clamp works for float3 too, but not sure how that behaves compared to clampMagnitude,
but an implementation would probably just be:

public static float3 ClampMagnitude(this float3 vector, float maxMagnitude)
        {
            float sqrLength = math.lengthsq(vector);
            if (sqrLength < math.mul(maxMagnitude, maxMagnitude))
            {
                return vector;
            }
            return math.normalize(vector) * maxMagnitude;
        }
willow plaza
#

math.clamp works for float3 too, but not sure how that behaves compared to clampMagnitude,
but an implementation would probably just be:

public static float3 ClampMagnitude(this float3 vector, float maxMagnitude)
        {
            float sqrLength = math.lengthsq(vector);
            if (sqrLength < math.mul(maxMagnitude, maxMagnitude))
            {
                return vector;
            }
            return math.normalize(vector) * maxMagnitude;
        }

@minor sluice yeah, I ended up writing my own utils method. Hoped there was one in the Mathematics library...

minor sluice
#

I haven't looked deep enough into the math code, but by checking the available methods, I didn't really see anything related to it

#

so not sure

willow plaza
#

Yeah, I just scrolled through all the available methods and classes in Mathematics myself. There's nothing similar to clampMagnitude.

amber flicker
#

I wonder how much faster clampmag would be than just calling .normalize in burst code or if it's even faster at all

minor sluice
#

yeah, I wonder if my if check above would even be faster than just doing something like math.normalize(vector) * math.min(math.length(vector), maxMagnitude);

amber flicker
#

probably doesn't make much difference - math lib is certainly missing some handy extensions that they seem resistant to adding

willow plaza
#

is it possible to add force to physics bodies in a bursted job?

minor sluice
#

you could just operate on the PhysicsVelocity componentData as one example, so I think yes

willow plaza
#

Anyone has a clue how to lock rotation of the physics body on a certain axis?

#

Similar to how you can do with regular rigidbody.

#

Should I just reset the angular velocity?

tawdry tree
#

How are you making the entity?
If you're making it by authoring, there is a component for that

willow plaza
#

I am. Is there a component that locks rotation?

minor sluice
#

I did some deep profiling tests and got this, is this slow for the physics?
so in my game there seems like a big default overhead for running the regular physics systems

With only 24 entities in the scene, with deep profiling, following happens:
StepPhysicsWorld.Update takes 2.88ms
BuildPhysicsWorld takes 0.63 ms
.PlayerEnemyCollisionSystem (ICollisonEventsJob) takes 0.12 ms.

With 760 entities in the scene, deep profiling:
StepPhysicsWorld.Update takes around 2.9-3.2ms
BuildPhysicsWorld takes 0.62 - 0.71 ms
PlayerEnemyCollisionSystem takes 0.11-0.13 ms.

willow plaza
#

StepPhysicsWorld takes 5 ms to update for me. I was starting to think I'm doing something wrong... I only have like 4 dynamic bodies and the rest are static...

#

And I don't really do anything with them. Only changing their velocity.

amber flicker
#

sadly very normal - good news is unity are working on optimising jobs and scheduling but no eta

#

I haven't touched physics yet but my assumption is the majority of that overhead is scheduling - you'll be able to do a lot of 'physics' before that number goes up.

willow plaza
#

So it's better to pack more work in each system instead of having multiple systems?

amber flicker
#

there might be some value in that, though I wouldn't worry that much - afaik this is high priority for Unity atm and hopefully it should get much faster

minor sluice
#

ah, thanks for the inputs! I was thinking I did something wrong too,
I might just use the overlap query instead.

there is a slight overhead in scheduling jobs, but it is usually rather miniscule, and you can also chain job dependencies/handles together for continuous parallel execution - so that they execute in order (I think?)

north bay
#

Generally disable the job debugger when profiling or even better make a build

#

Build physics world takes 0.3 ms for me with a rather complex setup

amber flicker
#

Yes good time to remind to only look at numbers in build - 0.3ms is quicker than I saw before - that’s great

#

Main thread or total time?

pliant pike
#

@willow plaza the solution I've seen for locking rotation is to set the mass.InverseInertia to 0 on the required axes

north bay
#

Main. I always see heavy drops in performance when going above 4 worker threads in release builds.

willow plaza
#

@pliant pike thanks! I'll give it a try.

minor sluice
#

I shall try a build, for sure, thx

amber flicker
#

Good point- 3900x here - doesn’t always help

willow plaza
#

It seems like if I have both custom authoring script and unity's authoring like PhysicsBody, The latter overrides any related components that I add in my custom script... How would I go around that?

#

trying to add PhysicsMass component with certain values, but it's getting overriden...

coarse turtle
#

Maybe you can write a GameObjectConversionSystem which runs at the end

#

to set the values

#

there are different update groups you can run those conversion systems in (I believe there's an GameObjectAfterConversionGroup attribute which runs as the last step in the conversion pipeline)

pliant pike
#

I think you have to keep updating the values, the example I've seen they have them in the job where your moving the character

amber flicker
#

Definitely feels a bit naughty if physicsbody overrides component values that it doesn't expose fields for... think I'd do what psuong suggests myself and create a component that runs conversion in the GameObjectAfterConversionGroup group

willow plaza
#

I think you have to keep updating the values, the example I've seen they have them in the job where your moving the character
@pliant pike Ah. I thought it was a const parameter like mass or something.

#

@coarse turtle I'll try the GameObjectConversionSystem way and see if the value changes. Thanks!

tardy spoke
#

Interesting more of a design question/debate -

Has anyone solved any issues in DOTS that are not obviously suited to DOTS, such as a dialog or quest system? How would you structure that at a high level if you had to do it?

coarse turtle
#

I think @opaque ledge has implemented a quest system before

#

generally I think with quest systems - on a simple scale, you keep track of an index and increment it if it's linear quest

#

so A -> B -> C -> Goal

tardy spoke
#

Yeah, I don't actually need to create one at the moment - was just curious on your ideas to expand my knowledge of the application of ECS. Hard for me to imagine how to do that at the moment, haha.

coarse turtle
#

but for things like graph/tree based quests that are not always linear, well the way I end up going about it is, design the data structure first, if the design of the quest can allow me to map a graph into an array, then I can jump around the array by setting the index i want to access.

And based on the index, probably some condition check to see if you've completed the task, and jump to the next index with the next objective.

tardy spoke
#

Right, if the player had to make decisions, etc.

#

Very cool

amber flicker
#

ecs is a great fit for something like that but I guess likely take a while to setup. Once going though, just add an 'active' tag to a quest and all your map and dialogue systems update accordingly - all that lovely dod-ness

tardy spoke
#

Yeah, that was my thinking. High initial front end investment (which realistically is just kind of how ECS works) for massive scalability later

#

Yeah it's just hard to imagine having one NPC "talking" using ECS through the use of systems and forEach loops. I'm sure it's possible and there are probably some fairly eloquent solutions once you see them.

#

Very cool, thanks for the input by the way. I'll start thinking about it as I'll probably have to make one in a bit.

amber flicker
#

imo hard things (oop or dod) are almost always timing - when does one piece of dialogue become active, skipping, having transition time etc

#

on a tangent, thinking about this I'm suddenly really keen to make a market scene where you can hear all the conversations and interrupt any of them up at any point 🧐 😅

tardy spoke
#

That's really interesting

amber flicker
#

I'm not aware of any game that's done making it important to wait for a natural break in speech to talk to an npc for example.. must not get distracted

tardy spoke
#

I was going to do an experiment in my VR game down the road - Oculus Quest has built in functionality to talk to up to 8 other people wearing Oculus quest VR headsets. I was going to make it just auto connect to whoever is nearby in the game, hahah. So it's like you can just walk up to anyone and talk to 'em, just like real life. Of course you'll get a bunch of trolls and stuff and it's probably not going to be "allowed" on the app store if you have that, but I just thought it'd be interesting.

#

Haha, well I design a lot of products and you'd have to consider kind of not only "the job to be done", but particularly in video games, "is this fun?"

amber flicker
#

bit like rec-room?

tardy spoke
#

LOL do they do that? Awesome

amber flicker
#

I think they do some amplitude based on distance but it's basically whoever's in the lobby and you can selectively mute

tardy spoke
#

I would be concerned that waiting for NPC's to stop talking in order to talk to them may not be "fun", hahah

#

Oh yeah, totally, that's exactly what the idea was.

amber flicker
#

not waiting for them to finish per-se - just like the idea of different moods/reactions based on what point you interrupt

tardy spoke
#

Yeah, I was thinking that

#

but you know what might even be more "fun" for the player is they halt their conversation naturally in order to talk to you

#

Like if they went "oh hang on a second my friend Bob is here" (you're bob) that would be neat

#

Cause it strokes your ego and makes you feel important and it's realistic. If I ask someone to go slay a dragon for me, I'm going to pretty curious if they did it when they come back.

#

Of course then you can't do a "rudeness" meter thing that alters mood, haha.

vagrant surge
#

remember, as usual, that you dont need to stuff everything into the ecs

#

a quest system really isnt something that is perf minded at all, or that works well in iteration. Just having the quest system as its own "normal" C# classes will likely work better

#

(btw ecs actually works damn well on rpgs, due to the scale of stuff, and the need to save the state of everything)

#

a world like skyrim has a few hundred npcs

tardy spoke
#

True, true

vagrant surge
#

but quests... they really dont fit directly into entities. So just having something like a entity for a quest, and then that has a component that points to a normal C# class will likely work better

tardy spoke
#

Yeah, like maybe entities for figuring out which quest(s) are active, but just write the quest objects themselves as some sort of monobehaviour system?

pliant pike
#

does anyone know if addressables are able to be loaded in GameObjectConversionSystems?

#

I have a feeling they might not be because I think those systems are run in editor mode

willow plaza
#

Question: entityInQueryIndex in Entities.ForEach can be named wathever I want, right?

ForEach((Entity entity, int entityInQueryIndex,
safe lintel
#

edit - sorry thought you said cant, i dont think it can be named anything other than entityInQueryIndex unless i am misremembering

willow plaza
#

aah

#

okay

safe lintel
#

hmm 2020.2 a18 change note Kernel: Reduce main thread overhead of creating job reflection data.

#

there are a couple of them for the entirety of 2020.2

#
Kernel: IJobFor.Schedule (Scheduled as single job) no longer has any unnecessary parallel for access restrictions.
Kernel: Reduce job system overhead on Mac
Kernel: Reduce main thread overhead of creating job reflection data.
Kernel: Refactoring in memory label code which resulting in lowering generated code size.
Kernel: Small optimisation for low-level atomic queue container used by the JobQueue
willow plaza
#

Let's say I fill a native array of RaycastHit in one job, complete the job and capture the array in a ForEach. How would I know which element corresponds to which entity? The indexes might not be the same, right?

var raycastResults = new NativeArray<RaycastHit>( rayCount, Allocator.TempJob );

var raycastJobHandle = PhysicsUtil.ScheduleBatchRayCast( physicsWorld.CollisionWorld, raycastInputs, raycastResults );
raycastJobHandle.Complete(); 

Entities.ForEach((Entity entity, int entityInQueryIndex, ref NavAgent agent) =>
{
    //would that work?
    raycastResults[entityInQueryIndex]
}
safe lintel
#

never personally used PhysicsUtil.ScheduleBatchRayCast sorry

willow plaza
#

ah, that's a custom method I wrote it.

#

the question is more about passing native arrays between the jobs

safe lintel
#

oh the index

willow plaza
#

if they have different query, there's no guarantee they will be ordered the same way, right?

safe lintel
#

pretty much

willow plaza
#

So how would you go about it usually?

#

if i want to calculate some temp data per entity in one job and access it in another

#

is it worth creating a component for that?

safe lintel
#

what is ScheduleBatchRayCast doing?

willow plaza
#

basically casts ray from each agent down to find the closest collision surface

#

and fills the results in raycastResults

safe lintel
#

why not raycast in a regular foreach?

#

its unclear what entity query you are using for your raycasting

willow plaza
#

it's a different query from the next job. I've just seen that in the Unity.Physics docs as a way to make fast raycasts in a batch.

#

but I guess I can just make individual raycasts in the main job...

#
Cast Performance
The above code all calls into Unity Physics through normal C#. That is fine, will work, but is not necessarily the most optimal solution. To get really good performance from the casts and other queries you should do them from within a Burst compiled job. That way the code within the Unity Physics for the cast can also make use of Burst. If you are already in a Burst job, just call as normal, otherwise you will need to create a simple Job to do it for you. Since it is a threaded job, try to batch a few together too and wait some time later for results instead of straight away.

Jobs can only be created in classes that inherit from JobComponentSystem. Here are the necessary namespaces for the following examples:
#

I think I misread it first

#

I thought that I have to do it as a separate job.

#

If I call this method in a bursted job it should work and be fast, right?:

public static Entity Raycast( float3 RayFrom, float3 RayTo )
        {
            var physicsWorldSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystem<Unity.Physics.Systems.BuildPhysicsWorld>();
            var collisionWorld = physicsWorldSystem.PhysicsWorld.CollisionWorld;
            RaycastInput input = new RaycastInput()
            {
                Start = RayFrom,
                End = RayTo,
                Filter = new CollisionFilter()
                {
                    BelongsTo = ~0u,
                    CollidesWith = ~0u, // all 1s, so all layers, collide with everything
                    GroupIndex = 0
                }
            };

            RaycastHit hit = new RaycastHit();
            bool haveHit = collisionWorld.CastRay( input, out hit );
            if (haveHit)
            {
                // see hit.Position
                // see hit.SurfaceNormal
                Entity e = physicsWorldSystem.PhysicsWorld.Bodies[hit.RigidBodyIndex].Entity;
                return e;
            }
            return Entity.Null;
        }
safe lintel
#

you shouldnt be getting your systems per raycast call, that should be cached in the system itself or at the most before the job itself

willow plaza
#

so I can't all that method in Entities.ForEach?

safe lintel
#

just need to reorganize that a bit(pressed enter too soon)

willow plaza
#

Let me explain properly:
I have a system that changes entities velocity each frame so that they keep on moving towards certain waypoints. However, sometimes it makes them go up in the air, because the next waypoint is on the hill for example. In these cases I want to avoid the entities from flying through the air, so I wanted to make raycasts down to the ground. Then I can reset entities y position to the raycast hit position.

north bay
#

Are you aware of the constraints in which burst and the job system operate?

willow plaza
#

more or less, yes.

safe lintel
#

public class MyPhysicsSystem: SystemBase{
BuildPhysicsWorld buildPhysicsWorld;
void OnCreate(){
buildPhysicsWorld = World.GetExistingSystem<BuildPhysicsWorld>();
}

void OnUpdate(){
var job = new RaycastJob{
CollisionWorld = buildPhysicsWorld.PhysicsWorld.CollisionWorld;
};
}

//Inside your job
struct RaycastJob : IJobChunk
{
    public CollisionWorld CollisionWorld;
    public void Execute(){ 
      Raycast(etc)
    }
    public static Entity Raycast( float3 RayFrom, float3 RayTo ){etc}
}

}

willow plaza
#

you can't use reference types or access unity api.

safe lintel
#

just meant you should be restructuring when you get your systems instead of doing it every time you raycast per entity(which I am not even sure of what happens if you were to try from inside a job thread)

willow plaza
#

I didn't post my system code though... Ah well, I did a little part of it.

north bay
#

The job system should error out.

#

We don't need to know your system code if you already use managed types inside the method that you want to use inside your system

willow plaza
#

But I don't use managed types!

north bay
#

BuildPhysicsWorld is a class

willow plaza
#

Ah I see.

#

I didn't have a good look at method...

#

I just copied it from the physics docs ><

north bay
#

There should be better samples there, let me look

#

There's only one about batched raycasts, huh.

You generally just want to cache the collisionWorld which you get from the BuildPhysicsWorld above your Entities.ForEach and than perform your casts just as thelebaron illustrated

willow plaza
#

Yeah. I just wanted to create a static utils method, but with how it works, it seems like I'll need to pass tons of stuff into it...

#

hmmm

#

would that work if called from a job?

        public static bool Raycast(CollisionWorld world, float3 RayFrom, float3 RayTo, out RaycastHit hit )
        {
            RaycastInput input = new RaycastInput()
            {
                Start = RayFrom,
                End = RayTo,
                Filter = new CollisionFilter()
                {
                    BelongsTo = ~0u,
                    CollidesWith = ~0u, // all 1s, so all layers, collide with everything
                    GroupIndex = 0
                }
            };

            return world.CastRay( input, out hit );
        }
north bay
#

jup

#

I was about to send you a sample of doing that lol

willow plaza
#

alright, I guess I'll settle with that 😄

#

@safe lintel @north bay thanks for bearing with my stupidity 😄

#

dots is really hardcore level difficulty with little to no up to date examples. At least not complex ones that show how to tie stuff together...

willow plaza
#

aaaaand the raycast doesn't seem to work. My skeletons are still walking through the air.😑

tardy spoke
#

Woops, ignore the "time" that that video starts at, but that series gets pretty advanced and shows a lot about tying stuff together

willow plaza
#

@tardy spoke ooooh! Thanks a lot!

opaque ledge
#

been a while since we got new packages 😭

tardy spoke
#

@willow plaza no problem, @opaque ledge showed it to me. As far as I can tell it's pretty much the only recent resource like that that currently exists, hahaha. Someone actually making something that isn't just 10,000 f***ing boxes rotating.

opaque ledge
#

yeah btw alex, thats how its done in "ECS" way

tardy spoke
#

Cool, just making sure I wasn't missing an explicit function or something for doing that

tardy spoke
#

I take there must be some things you can do with EntityCommandBuffer that can't be done by running a system with .WithStructuralChanges().Run(); ?

Or is WithStructuralChanges the "new" way of doing that?

opaque ledge
#

WithStructralChange creates a sync point, while entity command buffer 'stores' your structral changes and played back later at the frame, the less sync point you have the better

#

there is a page about this in entities manual

tardy spoke
#

Ah gotcha. Not the same thing.

#

Right, I think I read about that. I'll have to review!

safe lintel
#

WithStructuralChanges i believe forces every job to complete beforehand while Run only does the jobs in the dependency chain. the docs mention that using an ecb to queue your changes directly after using .run is faster if you can structure your changes this way

mint iron
#

i think WithStructralChanges makes it not run in burst as well, so that's a big reason not to do it unless you have to.

tardy spoke
#

So go with ECB's by default. Gotcha

#

Otherwise it'll call sync points just for that function instead of lining them up with other functions for efficiency

steel bobcat
#

Heyo

#

Anyone here got any clue what's happening with the Scale component?

#

I'm trying to scale up a sprite (quad with a material, in reality)

#

But when I do so it makes the movement of the sprite really weird

#

I have a simple chase system. Entities acted upon by this system take a target position, orient themselves along their forward vector, and slowly rotate towards their target. It's nothing special, but for some reason if I do anything to the scale they move as if they don't know where the target is at all, completely random, they just pick a direction and go towards it.

#

TL;DR : I want to scale something but it makes things not go the way they should.

#

Sometimes they just... stop moving whatsoever.

#

Any scale other than simply the default one, that is 1f either bricks the moving mechanism or makes them not move at all.

safe lintel
#

do you have some sort of hierarchy that is affected when you change the scale?

steel bobcat
#

I don't think so. It's a pure ECS entity, and I'm only acting on the entity itself.

#

It's not parented to anything.

#

Nor does it have any children

#

I could share the code if you wanted to take a closer look

safe lintel
#

if you do something simple like use Debug.Log(localToWorld.Position) before and after scaling it, is it the same?

steel bobcat
#

I hate this LocalToWorld component, it always caused unecessary trouble.

#

First time it used to scale when I wanted to rotate my object, now it does this.

#

I'll do so in a sec

#

I'll let you know

safe lintel
#

localtoworld is really just the sum of your translation rotation and scale(if one exists)

steel bobcat
#

It's the same position

#

apparently.

#

Yeah, I know that that is what LTW is, but something is just off when you're working with it.

#

The problem is the movement itself.

safe lintel
#

changes might be deferred a frame unless you explicitly update before the transform system works, or you might get certain results overridden given overlapping

#

anyway doesnt sound like ltw is your problem

steel bobcat
#

No, it really is. It's the only thing that really makes this not work.

#

Here's my script, for instance:

#


        Entities.ForEach((ref LocalToWorld ltw, ref SimpleFollowerComponent sfc) =>
        {
            float offset = math.PI / 2;
            float3 dir = sfc.target - ltw.Position;

            dir = math.normalize(dir);

            float angle = math.atan2(dir.y, dir.x);
            quaternion rot = math.slerp(ltw.Rotation, quaternion.AxisAngle(new float3(0f, 0f, 1f), angle - offset), sfc.rotFactor * sfc.rot);

            float3 pos = math.lerp(ltw.Position, ltw.Position + ltw.Up * sfc.speed, sfc.speedFactor);

            ltw = new LocalToWorld
            {
                Value = float4x4.TRS(
                    pos,
                    rot,
                    new float3(1f)
                    )
            };
        }).ScheduleParallel();

#

This is in the OnUpdate override

#

This works.

#

If I, however, instead of writing new float3(1f) for the scale component, I write sfc.scale which is a simple uniform float3, it stops working.

#

The movement becomes... strange.

#

It's not doing what it is meant to do.

amber flicker
#

I only skimmed the above so sorry if this doesn’t help but are you aware that any non uniform scale will replace the Scale component with a NonUniformScale component?

steel bobcat
#

Yeah, but it's an uniform scale I'm performing.

#

And not only that, non uniform scales just make my entities not move at all.

safe lintel
#

tbh even if something has a weird scale, it shouldnt affect its position

#

so Idk 🤷

amber flicker
#

sorry yea, just looked at that code and it sounds odd. I'm fairly sure Scale isn't what you expect in the LTW though - if you set a Rotation, Translation & Scale then read ltw.Rotation etc after the TransformSystem has run I don't think they're the same. Like the Scale is after the rotation transformation or something? Not sure if it could be related to that - generally I prefer to avoid direct Ltw manipulation if possible

safe lintel
prisma anchor
#

Is there a way to have a 'OnTriggerEnter' event with ITriggerEventsJob?

safe lintel
#

ok my package manager did not pick up that there was another package outside of 0.8.0.preview.1 so unless you needed to restart the editor to pick up the change, consider me officially on the I-hate-the-new-package-hidden-thing

mint iron
#

it will be interesting to see how they spin it, because they've spent the past year touting the merits of dots, but now they're basically saying don't use it.

safe lintel
#

i didnt even notice that the blog post is back from june

#

the blog lately is full of what feels like ads, doesnt feel like a good place for actual news or interesting stuff anymore

#

ok after reverting the package back it does pick it up. on a side note the new package seems bugged, my inspector not showing entity data when an entity is clicked?

#

and yeah i think this is a bad decision to kind of put the genie back in the bottle

mint iron
#

i dont really get what changed, it seems like they started to seriously try to tie up the major loose ends - the render pipeline, subscenes and animation. Things to make an actual game rather than just a 100k spinning cubes and now they're like 'woah woah' hold on there lets reign it back.

safe lintel
#

im sorta against the whole slowing dev down to just two "tech streams" a year, I want my bleeding edge tech 😉

#

the naming convention is probably what I think should change, for just about all their versions

mint iron
#

i was talking to the test manager in Copenhagen last year at the dinner event, and i was explaining how my biggest frustration was that none of the package work together; suggested they let us somehow report a combination of packages that function together. He was enthusiastic, then nothing happened. :S

safe lintel
#

i gotta believe part of it is like being in a monolithic bureaucracy, even one as cool as unity, to get certain things done you either gotta know someone high up the chain or wait a while for it to filter through

#

your idea could be that guy's passion project and hes fighting tooth and nail against deaf ears 😅

mint iron
#

yeah, maybe he tried, ill assume he did 😄

#

i know how it goes though, i saw joachim there too, but i didnt have the nerve to start up a conversation and give him my feedback, hes a rockstar and all that

safe lintel
#

or maybe not deaf ears but the guy above him thinks a, b and c need to happen in order for that to work

#

ah so this should be the lesson, approach joachim directly with the idea so at least you know it got through to the highest order(i would imagine)

coarse turtle
#

damn I think I'm pretty behind on packages after reading how packages are now hidden 🤔

mint iron
#

its a pretty big company now, they're listed as 2000+ employees

safe lintel
#

seems like it just went into effect recently though

#

also if a mod is reading, might be worth stickying a link to that thread, with it being required reading to do anything in dots

#

ok new dots editor package doesnt appear to work with the latest alpha editor

ocean cloud
#

I just realized that DOTS editor package exists

#

But seems like Entity Debugger window has already more features than both the Entities and Systems window? I don't get it

tardy spoke
safe lintel
#

well dots editor shows stuff like hierarchies and its much nicer to look at. basically a proper rewrite of the old debugger

hollow sorrel
#

oh man new dots editor update?

#

One of the major fixes was allowing the support of non-default worlds for the Entities window. 😱

#

i started on my own editor window because of this literally one day ago

#

glad they prioritized this feature, didn't seem like they would from reading the forum posts

#

ok new dots editor package doesnt appear to work with the latest alpha editor
@safe lintel
dunno if it's the same issue but the UIToolkit preview package has same issue, rolling back to a15 fixes it (and is what they recommended for now)

#

i'll check if this works on a15 in a couple mins

#

what's the issue you're getting? i'm getting a nullref at EntityHierarchyDiffSystem.Register but i'm not sure if that's because of unity or because of my custom world setup

#

nvm this is something weird, i can't find it in the files and error is pointing to 0.8.0 in library packagecache, but i don't even have that folder since it's 0.8.1 now

#

alright i deleted library and restarted and seems to work now on a15

#

although clicking entities doesn't show them in inspector, is it supposed to?

safe lintel
#

it works witth the latest beta if you want to try it there

#

but yeah nothing in inspector on the latest alpha

hollow sorrel
#

ah

#

systems schedule still doesn't support custom worlds and doesn't seem like it will from reading posts again

#

fuckit i'll do it myself

pallid carbon
#

I'm trying to use the ECS Sample Package but I'm getting a bunch of errors.

hollow sorrel
#

what unity version?

pallid carbon
#

newest

hollow sorrel
#

beta? alpha?

pallid carbon
#

base

#

actually it's 2019.4.0f1

#

haven't ported to .4f1

hollow sorrel
#

could you screenshot your package manager

pallid carbon
#

I'm reopening the project in .4f1, just a sec

willow plaza
#

what's .4f1? You ,mean 2019.4.4f1?

pallid carbon
#

yes

#

didnt work tho

#

I added the hybrid renderer whish supposedly added burst and entities and other stuff according to the ECS Samples page

willow plaza
#

click the Hybrid renderer and take a screenshot

pallid carbon
willow plaza
#

why does it not show dependencies? oO

hollow sorrel
#

is setting under advanced i think

willow plaza
hollow sorrel
#

they hiding that too now

pallid carbon
#

did it

willow plaza
#

It'd help if you post the details of the error.

pallid carbon
#

Assets\EntityComponentSystemSamples-master\EntityComponentSystemSamples-master\ECSSamples\Assets\Advanced\GridPath.Tests\CartesianGridOnCubeShortestPathTests.cs(5,22): error CS0234: The type or namespace name 'Tests' does not exist in the namespace 'Unity.Entities' (are you missing an assembly reference?)

#

Library\PackageCache\com.unity.2d.animation@3.2.3\Runtime\TransformAccessJob.cs(196,62): error CS1061: 'NativeHashMap<int, TransformAccessJob.TransformData>' does not contain a definition for 'Length' and no accessible extension method 'Length' accepting a first argument of type 'NativeHashMap<int, TransformAccessJob.TransformData>' could be found (are you missing a using directive or an assembly reference?)

willow plaza
#

Tests might be from unit tests?

#

also check if you have Collections package too

solar spire
#

The 2D animation package doesn't support newer collections releases

#

0.9.0 removed .Length, and it doesn't have an update to support it, so you have to use 0.8

willow plaza
#

Anyone else has a problem with VS not giving autocomplete options for IComponentData components?

#

For example, you'd expect autocomplete options to pop up, but they don't:

hollow sorrel
#

should be fixed in one of the more recent vs updates

willow plaza
#

@hollow sorrel thanks! That seems to have fixed it.

willow plaza
#

A question about debugging jobs. I understand that I can't put debug.Log in jobs unless they're run on the main thread, but what about breakpoints? And what is the common way to debug in dots?

tawdry tree
#

Switch to .Run() and use Debug.Log or breakpoints, or check the input and output data (aka copious amounts of Debug.Log).

willow plaza
#

So there's no way to Debug it when it's executed on another thread?

tawdry tree
#

You cannot directly debug it while it is on a different thread, as far as I'm aware. Hence, debugging on the main thread (a good case for some automated tests of your methods, hm?) or debugging the inpouts and outputs (white box testing as if you have a black box)

willow plaza
#

I see. I just hoped there's a way without changing the job to run on main thread every time.

tawdry tree
#

Ehh, better than debugging JS in browser

willow plaza
#

guess so

tardy spoke
#

Another general-ish question.

I was "disabling" gameObjects that were say 50 meters away from the character in my game previously before using DOTS/ECS. I had 100% opaque fog so you couldn't see anything further than that.

With DOTS/ECS, is there any "disabling" (besides deleting) of entities, and would it have any sort of similar benefit? Save on rendering time or something? Would it just be disabling and re-enabling the mesh renderer components?

I guess the question is, since my game map is 20 km big, are there any obvious DOTS/ECS optimizations that would typically be used for entities far away from the player/out of the player's view?

deft stump
#

For that, I'd recommend go for the Subscene workflow.

tardy spoke
#

Do you just mean tossing all the GO's under a sub-scene so it all converts to entities automatically?

#

Oh, right, you mean like the megacity demo with the live subscene loading. Gotcha.

mint iron
#

you can add a disabled component and it will cause the entity to be excluded from queries, unless those queries are set explicitly to show disabled. there's one like that specifically for rendering too but i forget what it is.

safe lintel
#

Disablerendering i think

tardy spoke
#

Very cool

coarse turtle
#

Does the hybrid renderer do frustum culling by default?

#

I'm curious

tardy spoke
#

I remember reading it doesn't

coarse turtle
#

ah

#

that sucks

tardy spoke
#

but don't quote me on that, that may be old news

coarse turtle
#

o

tardy spoke
#

I'm pretty sure it does dynamic occlusion though?

#

lol

#

maybe... dunno

coarse turtle
#

I remember reading the staticbatchrender group once which can you can write your own frustum culler

tardy spoke
#

It's odd because the game camera isn't really in the entity world so I have no idea how they interact

#

Hmm, something to look into

coarse turtle
#

yea, but if you're interested in writing your own, IJobParallelForFilter is a nice job extension to append or remove elements from a collection 🙂

tardy spoke
#

Excellent. I have no idea what i'll need because my early experiments I was CPU bound and not GPU bound on oculus quest with the 20km world

coarse turtle
#

I recently implemented it for a VR game and works nicely for frustum culling

#

I'm running into the same issues for the quest right now but for half a km

#

:/

tardy spoke
#

Nice! These things give me hope, haha. The oculus quest is a real donkey of a processor compared to any regular computer or even modern cell phone, haha.

#

What's taking up so much CPU on your game?

coarse turtle
#

Well I'm not CPU bound luckily - I'm graphics bound

tardy spoke
#

Right. I ended up literally going vertex colors, no textures, no lighting, LOL

coarse turtle
#

Yea - I don't have that liberty atm lol

tardy spoke
#

Yeah, if I was not able to do that, I don't even know where to start

#

What kind of graphics do you need?

coarse turtle
#

Well I think right now it's more me trying to argue against using certain graphical features

tardy spoke
#

I ran into a disaster on my initial builds. I didn't realize stacked cameras in Unity are basically a death sentence to VR performance, haha

coarse turtle
#

Like realtime lighting on the quest? wasn't sure how it'd be possible untethered - but this might be a bit off topic from dots 😅

tardy spoke
#

Hmm, what's the performance boost tethered?

#

I'm interested in it because I can't bake a 20km light map... at least I think I can't

coarse turtle
#

Kind of forget, I'll need to take a look into it - there are still things I need to do in the project since I only jumped on not too long ago

tardy spoke
#

Totally. Just starting mine as well. Keep me posted on any interesting performance findings, and i'll do the same? Haha

coarse turtle
#

sure

tardy spoke
#

👍

cursive cosmos
#

I have a question regarding player controls in a DOTS environment, should I control my player and the model using DOTS and are there any tutorials on this?

#

I checked some easy one where he literally just let unity convert the player space ship into an entity, but my player is gonna be a bit more complex with a lot of animation and so on.

tardy spoke
cursive cosmos
#

@tardy spoke will take a look!

safe lintel
#

if you want animation your options are somewhat limited, with dots animation itself being very very work in progress and outdated samples

tardy spoke
#

@cursive cosmos I just made a player controller system as well, pretty much based on that tutorial (except mine is FPS) but broken out into separate components/systems, want me to make a quick overview vid for you?

#

Also a trivial question for someone more familiar with DOTs - I'm trying to duplicate the same gameObject into two different entities. I tried this naive approach - along with breaking it out into two separate monobehaviours, which seems to just only convert once as well.

Is there a similar function to IConvertGameObjectToEntity for converting multiple entites? Or some common OOP workaround to have two identical members in a class (which is a pretty strange thing to even be attempting to do, granted)?

I could duplicate the gameObject and put one script on each, but that seems... really dumb, haha.

#

Ah, I think "GameObjectConversionUtility" might be what I'm looking for.

cursive cosmos
#

@tardy spoke I will just make my own, thanks anyways 😄

tardy spoke
#

No worries 😎

zinc plinth
#

about the culling stuff

#

there's culling with the hybrid renderer currently

#

you set WorldMeshRenderBounds, and add a PerInstanceCullingTag to your entity

#

also seems like lod groups gets converted from go aswell :o

coarse turtle
#

cool good to know - I haven't played with hybrid renderer lately

safe lintel
#

i envy those who dont have issues with it

#

v2 that is

cursive cosmos
#

@safe lintel Are you saying you can't trigger animations on entities that well currently?
Should I maybe focus making all the different world objects in DOTS and just keep the characters and moving 3D models in normal unity?

#

Is it even possible to interact with a entity as a normal game objects...I need to research way more on this, have been so busy making 3D models.

opaque ledge
#

wait, you just add PerInstanceCullingTag to your entity and they will be culled automatically ? @zinc plinth

zinc plinth
#

yes ?

#

you nedd the bounds, but ye

opaque ledge
#

oh, that isnt added auto ? well thanks anyway, actually implemented culling on my own, but i guess using Unity's culling will better 😄

zinc plinth
#

I had it already set on converted entities with mesh filter/renderer

safe lintel
hollow sorrel
#

i'm starting to reconsider how i parse input, right now all my button inputs have 3 bools: down, up and "held down"
however i'm having a hard time thinking of when i actually had to use up and held down states, since that can just be tracked by the thing that consumes that input if needed
does it make sense to only store 1 bool that says a button was pressed or not pressed? anyone else do it this way?

#

also this is dots related because i'm going from input that's tracked every render frame to a system that sets input components but only at 60fps so if i were to track input directly there then inputs would go missing

safe lintel
#

I personally have issues with managing input and whether its more than 60fps so 🤷

tardy spoke
#

@safe lintel just tried and got hybrid renderer v2 installed with URP 9 preview .35 on an Imac, so if you're on a mac, there may be some hope. Unity 2020.1.0b16

#

And if you're not familiar with URP gotta enable by creating pipeline asset then assign it's default "lit" material or similar to everything, otherwise it compiles and runs but nothing but gizmos display, haha. Oh, and assign the pipeline in the graphics section of the project settings.

zinc plinth
#

hoo I was missing LocalToParent lol

mint iron
#

one thing you can do with the new input system which is pretty cool - block copy the input state into a component each frame, which is close to free (especially if you locked the archetype and used a direct ptr). Then have a bunch of helper methods that check if a button is down or whatever by reading specific offsets. I was working on it for a while then got distracted by other shiny things :S

But... if you want to catch taps, double-taps, detect swipes, drag-drop, multi-touch, or bound actions etc then things get far more complicated i imagine.

tardy spoke
#

It should be the official ECS logo.

zinc plinth
#

if one thing that I love about Unity.Entities.Transform is RotationPivotTranslation

#

because you literally can't do that in GO without a empty parent GO

safe lintel
#

@tardy spoke among other things, doesnt support more than one light 😉

hollow sorrel
#

what's rotationpivottranslation?

zinc plinth
#

offsets the pivot point for rotations

#

it's in local space (I think?)

zinc plinth
#

when does an Entity (index + version) change in the lifetime of the entity itself ? ThinkMan

icy kestrel
willow plaza
#

@icy kestrel the error seems to be thrown on draw Gizmos in Jgrid class. Line 87.

#

You're trying to access the native array there after it has been disposed.

#

I'd assume it's because of the last method. Where you allocate a new native list right in the method.

#

After some googling, it seems like allocator.temp is only allocating memory for 1 frame. At the end of the frame the allocation is disposed. So, if you cache reference to that list and try to access it on the next frame, you'll obviously get the error that you get.

tardy spoke
#

@safe lintel lol just one light eh? I'll have to make sure it's a bright one then.

willow plaza
#

Here's more on temp allocation:

Allocator.Temp - intended to be used for the scope of the current function (ultra-fast allocation/deallocation, can be allocated within a job kernel I think but shouldn't be returned or passed on). Will start throwing warnings if it lives more than 1 frame.
safe lintel
#

might need to be disposing those temp allocations, cant remember for sure

tardy spoke
#

I'm sure I'm just missing something simple, but why does it hate my blobAssetStore so much? 🤔

"The BlobAssetReference is not valid. Likely it has already been unloaded or released."

deft stump
#

you're using it within a using statement.

#

wait I have an example code somewhere, on blobasset creation using Iconvert

#

@tardy spoke use this as reference.

willow plaza
#

I remember seeing unite video where they shown dots physics debugger. Is it a thing yet? How would I access it?

#

Or are these just regular Debug.DrawLine/Ray?

#

and mesh gizmos

#

or was it with the Havok physics only? 🤔

willow plaza
#

There isn't much info about physics hit collectors is there?

spark glade
#

@willow plaza not sure about this specific screenshot (presumably you can find it in one of the examples), but there is a PhysicsDebugDisplayAuthoring that lets you enable different debug flags.

#

Note: You only need one in your scene, not one per entity.

willow plaza
#

I've tried it out, but I didn't see any difference =/

#

perhaps because I was using convert and inject for most of my converted GO

spark glade
#

Hmmm I haven't tried it in forever. But it for sure used to work in like entities 0.4.x for debugging bodies.

#

It shouldn't matter how you convert and/or inject/destroy them.

#

I'd assume that it pulls data straight from the components.

willow plaza
#

I mean, I was able to see the collider outlines with or without that script...

#

So I didn't really understand what it was for. I must admit I didn't play too much with it's settings though.

#

But for things like raycasts and collider casts, I have to implement my own debugging, right?

#

would be nice if there was something like that by default...

#

I'd also like to understand the native collections more. For example, what I see a lot in jobs is passing native lists by ref. I understand it is to avoid copying the whole list and it's elements? Would it still work if I just pass it regularly? Would it be less performant? What should I be careful about when passing collections around. For example from a static method that is being called by a job. In that case, can I allocate the list inside the static method? Can I still pass it by ref if I do so, or will it get deallocated when the method returns?

#

So many questions and so little answers online ><

#

Also, when I allocate a native list, I don't have to specify it's size, right? In this regard it works as a regular list?

opaque ledge
#

afaik, NativeList is just a wrapper around a pointer (with some safe guard) this is why it works with bursted jobs, since its passed by pointer its automatically passed by ref, you cant pass it 'regularly',

afaik you should be able to create native collections inside static methods inside bursted jobs with no problem, you are creating a native collection INSIDE job make sure you allocate with .Temp, if you are PASSING a native collection to a job then make you you allocate with .TempJob

Yeah native list grows but when you exceed size a new block of memory is allocated with some size(squared size i think, so i heard) and your old list will be copied to this new block, which mean performance loss

willow plaza
#

I see.

#

If a list is passed by a pointer, then why do I need the ref keyword?

#

I see it in physics queries for example:

public bool CalculateDistance( PointDistanceInput input, ref NativeList<DistanceHit> allHits );
#

Is it so that I can pass in my own list?

#

why wouldn't the query create a new list then? Because it doesn't know for how long to allocate it?

opaque ledge
#

by list you mean nativelist right ? its better to say nativelist because they are different 😄

willow plaza
#

yeah, native list.

opaque ledge
#

about they are being passed with ref, i think both are the same, whatever they are passed by ref or not, but perhaps they do 'ref' to explicity show that this method writes to NativeList

#

but perhaps someone with more knowledge can explain better

willow plaza
#

I see. Well, thanks for your explanations. Now I understand it a bit more.

icy kestrel
#

Thanks, @willow plaza that solved it! One more issue I'm getting is that "OnApplicationQuit" is being called before my final frame of "OnGizmosDraw". Because of this, when using gizmos, I get an error at the end where the nativearray has been disposed. How can I check that a native array exists before drawing gizmos? Just an annoying error 😆

tawdry tree
#

Check if it's null or compare array.IsCreated

Indicates that the NativeArray has an allocated memory buffer.
Something like:

//Short circuit
if (array?.IsCreated != true) return; 
//Do stuff
#

Not equals true so that null also causes the return.

tardy spoke
#

@deft stump thanks for pointing me in the right direction! Found a CodeMonkey video tutorial on blob assets as well which I'm using to decipher what's going on there.

From what I read:

Blob assets cannot be modified once created. Instead, you must create a new blob asset, update any references to the old one and then dispose of it.

I think this may not be what I'm looking for - depending on what that means.

Basically I'm trying to duplicate my game world two times from one gameObject, keeping the colliders on one copy, and stripping them from the other copy. The copy of the game world with no colliders is used for "display" only, and moves inversely to the player controller, so the player remains at 0,0,0 world origin. The other world is static and the player moves in it regularly, colliding with physics objects regularly, etc.

I'm thinking if I use blob assets to store the copies then I won't be able to move the display world inversely to the player's controls, since the blob is just immutable data for reference only? Is that correct? Am I misunderstanding immutable in this sense? Would translation/movement components be "on top" of the blob, or would they require changing some (immutable) data within the blob in some way, which would break the functionality?

Anyone have any ideas on what the correct tool for this use case would be, if not storing the worlds in a blob?

#

A naive solution like duplicating the world gameObject with a monobehaviour and simply using IConvertGameObjectToEntity on each comes to mind, haha.

tardy spoke
#

Also to develop a deeper understanding of how Unity ECS is working internally, would I be better just trying to increase my knowledge of C# members or should I start doing some experiments with something lower level, like C++?

pliant pike
#

I don't think learning C++ will help you understand ECS better, just learning using and reading about ECS will help you understand it better

amber flicker
#

I'm sure you could get a lot out of c++ (pointers, comfortable with unsafe etc) but the usefulness-for-effort might not be that high

tardy spoke
#

Yeah, the lack of documentation in parts of ECS is a killer for noobs like me, haha. I'm in no hurry to get my project done or anything, so it's no big deal. Though I am interested in figuring out a bit about what's going on under the hood.

It would also be nice if ECS wasn't wrapped in an OO construct, but I doubt Unity could change that even if they wanted to.

#

Thanks for the advice @pliant pike / @amber flicker . Appreciate it!

pliant pike
#

there is a book about DOTS, I dont know if it would be any help

icy kestrel
#

Does anyone have any experience with making a "Heap" (binary tree) inside a jobsystem or does it manage memory and is not possible?

minor sluice
#

What's the best or least setup effort way to make sure that if an entity is destroyed, all entities that all child entities (entities having a Parent component pointing to this) are destroyed too?

zinc plinth
#

put a linked entity group on the entity you're destroying

tardy spoke
#

@pliant pike all of the resources made for DOTS are super useful... for about a week. 🙂

pliant pike
#

yeah I know what you mean especially at the rate ECS changes

#

but that's what you get for using something thats in beta

tardy spoke
#

Oh, this is on DOD in general. IE functional programming, no?

minor sluice
#

thx! how does this group differ from a child component? I guess that it can have more than 1 lined entity? (haven't heard about this group yet)

what would you do with a heap?

pliant pike
#

yeah that book is fundamental dots stuff

deft stump
#

the only thing I took away from that is...
"Think of DOD as a database"

tardy spoke
#

Oh weird, yeah, I'm just reading through some of it now. It actually is about video game implementations of DOD concepts... what a strangely titled book for the content, haha.

#

I'm a marketing director by day so I think this guy could like 10X his sales by just adding "for video game programmers" to the end of "Data-Oriented Design", hahahah.

deft stump
#

you can use DOD concepts in other fields

tardy spoke
#

omg it's Unity based also

#

hahahah

#

That title is sooooo bad

#

Yeah, this is cool. Would be a lot more practical if it was actually on DOTS, I think it's more just generalized theory around DOD, which is still cool and super useful.

hollow sorrel
#

if you're talking about that book it's not unity based

#

it's definitely more generalized

#

but really helpful

#

also DOTS != data oriented design

#

and not same as functional programming

#

DOTS = unity's tech stack, DOD = programming paradigm

#

just to clear things up

#

but yea i'd prob say that book is required reading if you're starting with ecs, it's the one thing that really helps the theory click

tardy spoke
#

@hollow sorrel in some of the code examples in the book they say "in Unity" specifically, which I thought was interesting.

hollow sorrel
#

ah it might have some references to it, no actual unity code tho

tardy spoke
#

No, looked somewhat like psuedo code

hollow sorrel
#

i don't even know if the author ever used unity

#

which is fine, it's a general concept

#

and still applies to unity's implementation

tardy spoke
#

Yeah, it's actually useful it is somewhat related to Unity

#

Interesting the ECS system is not a "Unity" thing but just another programming concept, haha. I learned that today.

deft stump
#

it never was.
Unity just "repopularized" it

tardy spoke
#

People were experimenting with it nearly a decade ago in various game engines, which is kind of cool to think about.

hollow sorrel
#

yea i think a lot of ppl have the misconception that unity invented ecs and data oriented design

tardy spoke
#

I think Unity's marketing team made sure of that. I would, haha.

#

It makes it seem like cutting edge tech and like you're super geniuses.

#

= more programmers on your platform.

deft stump
#

= more programmers on your platform.
then they realize that it's not coming out until 2021

#

:lul:

tardy spoke
#

Should we be concerned with Unity backing off the advertising and accessibility of ECS?

#

Was there ever an "official" explanation for that? We're not just learning stuff they're going to remove, right? Hahahah

hollow sorrel
#

yea same with burst, it's marketed as this super amazing high tech thing that makes your game's code way faster than anyone else could ever make and a supercool invention
when it's basically just using clang to compile your code with a couple unity specific things
if you were using regular C++ and used clang to compile you'd get about the same results as burst

deft stump
#

same with jobs system too

tardy spoke
#

They probably just watch this channel all day and they're like "Ok, so like 10 people use this, and it's costing us 30 million dollars to develop... and the one named Alex doesn't even understand it."

deft stump
#

backing off the advertising and accessibility of ECS?

#

what you mean?

tardy spoke
#

Oh, like making the packages harder to access/install

#

I think you have to add them to your manifest manually now instead of being able to get them through the package manager or something? Or maybe they just removed them from package manager for pre-2020.1 or something

deft stump
#

Not really, they did say they're going to add a new category in the package manager to better categorize Preview or Experimental versions.

tardy spoke
#

or was that just the visual scripting package that did that?

#

Ah, so it's just a technical reason. Great, haha.

#

It'll be interesting to see if Unreal engine responds to Unity ECS. They're probably waiting to see what the adoption is like.

deft stump
#

I doubt they will

tardy spoke
#

There's not many games that "need" it... it's just cool.

#

I mean the lower battery usage on mobile and stuff is nice.

hollow sorrel
#

i think what also helps is that unity's gameobject+monobehaviour+mono compiler combination is really slow in comparison to every other modern engine or even just .net core, so all they have to do is bring things "up to par" and they can claim everything is 100x faster so people get the impression it's the fastest thing there is

which is fine, i'm really happy unity came up with these systems, ECS and burst are great, i just think a lot of people will have misconceptions

tardy spoke
#

Truly large scale multiplayer games benefit I guess

#

Haha @hollow sorrel that's kind of interesting. Great marketing spin as well. It's 13X faster because our current stuff is 10X slower than it should be, hahaha.

hollow sorrel
#

yea exactly

tardy spoke
#

... well, realistically, is it not the fastest thing there is right now for mainstream game engines? Like can Unreal run a 100,000 unit game demo like the Unity stuff?

#

Like it may not be 13X faster, but is it not at least faster than something designed in a different paradigm, even if that paradigm is well executed

hollow sorrel
#

dunno about unreal but i've seen some benchmarks of rust + an ecs lib like Legion that seems to be an order of magnitude faster, maybe even more