#archived-dots

1 messages ยท Page 106 of 1

low tangle
#

but like input, both those projects were started before ecs/burst got going

opaque ledge
#

ah, it doesnt work right now then

#

yeah, i understand

zenith wyvern
#

From the sounds of it it's many months away before it will be integrated with dots

low tangle
#

yep, but that shouldn't really matter when it comes down to it

zenith wyvern
#

I would keep an eye on Project Tiny to see how they handle UI

dull copper
low tangle
#

you just use the old ones and make due with simple bridging

opaque ledge
#

oh, should i take a look into Megacity and Project Tiny ?

#

for learning ECS

low tangle
#

uh

#

no

zenith wyvern
#

Don't look at megacity

low tangle
#

not really

#

they are full of in dev stuff and are not easy to grasp starting out

dull copper
#

also don't look at project tiny either ๐Ÿ˜„

#

that thing keeps making even more u-turns than DOTS

low tangle
#

did you look at the fantastic hello cube and what not in the samples

opaque ledge
#

yeah i took a look to hello cube ๐Ÿ˜„

low tangle
#

and the physics examples in the same repo

opaque ledge
#

thats pretty basic tho

tawdry tree
#

The UI isn't going to make a particularly big perf impact unless you royally screw something up, so just do it the old way and query any relevant entities from mono-land. As a bonus that should make it easy to transition to their ECS versions when that time comes.

zenith wyvern
#

If you mean learning general ECS concepts in terms of a full game there's not much out there from Unity

dull copper
#

well the physics examples are really not DOTS samples

low tangle
#

aye but you only need basic tools when you learn ecs

dull copper
#

they mainly interacts Unity Physics through monobehaviours there

low tangle
#

that combined with playing around and learning in the framework

#

and read the DOD book!

dull copper
#

I wish they actually had DOTS samples for physics there

opaque ledge
#

that DOD book is so boring ๐Ÿ˜ญ

dull copper
#

but actually Unity Physics docs have some

#

(few snippets)

tawdry tree
#

Well, here goes nothing: time to upgrade my ECS sandbox project from Entities and hybrid renderer 0.1.1 to 0.5.0 and 0.3.2, respectively.

low tangle
#

that dod book was one of the lighter book and whitepapers I've read lol

opaque ledge
#

damn ๐Ÿ˜„

tawdry tree
#

Those things are crazy dry if you're not used to them, though. They'll fricking desiccate you if you're not careful

opaque ledge
#

yeah but i mean it kinda feels like.. it explains the foundation of how should data orianted system should be implemented such like Unity's ECS, i.. dont know how it will help me understand stuff on higher level instead lower level

zenith wyvern
#

Yeah I have a hard time reading it too, I'm not good at pure technical reading

low tangle
#

when you get a bit further along it talks about things like "existence based processing"

#

and the section on "dont use ifs"

#

both of these apply to ecs a lot

tawdry tree
#

But what if...!

opaque ledge
#

gasps He said the word ๐Ÿ‘€

#

yeah i will check it out thanks, i read the database section of it(first section) and it was.. boring and it generally told how things work instead of how can i get advantage of it

#

but in time i will read it

low tangle
#

you could skip ahead if it gets dry like that

#

the database section helps understand how ecs is structuring your chunks and selecting / sorting them

opaque ledge
#

So i was wondering, how you guys use sharedcomponentdata, systemdata and jobs for chunks ? I have hard time understanding their advantage, in a world of tag components it seems shared component data is useless since it sits on a chunk(right ?)

low tangle
#

basically, they are a tool to use

#

you use them when it makes sense

zenith wyvern
#

SCD just lets you group related components, whether you want to force them into certain chunks or in my case I wanted to have a single point of access to a NativeArray based on it's position in the world

#

The problem is they are really awkward to use and you can't use them directly inside jobs

low tangle
#

you can

#

and the downsides are that it fragments your chunks causing you to use more memory and less per chunk

opaque ledge
#

but doesnt SCD sits on a archetype ? how will you be able to use it if you put a tag component ? Like i am using tag components to drive simple AI, how can i utilize SCD in cases like that

low tangle
#

I had to use them to pull off a complex system before dynamic buffers came out

zenith wyvern
#

Maybe it's changed, when I was doing blockworld you definitely could not use a SCD inside a bursted job

low tangle
#

let me check if that job is bursted

#

ah well shit

#

deleted that system a long time ago

#

cant remember the exact name to pull it out of the repo

zenith wyvern
tawdry tree
#

Huh, just 8(4 pairs) deprecation warnings about World.Active in the sandbox project. And two of those is from a conversion utility I made...
Time to brush up on the conversion workflow

low tangle
#

yep

tawdry tree
#

Nevermind, two nullrefs and a burst error about function pointer when trying to enter play mode

#

...this will be incremental

low tangle
#

did you update burst?

#

might want to restart the editor

tawdry tree
#

Oh yeah, good point

#

No errors, yay!

#

No behavior... not so yay

low tangle
velvet oxide
#

Sorry to break up the flow guys but is there a way to do a "method" in a burst job? I am trying to not copy paste the same code over and over to do the same output

#

do you use something like:

#
            {
                //do jerb
            });

            if (otherComponent.boolValue)
            {
                jerb.Run();
            }```
low tangle
#

static function

#

or just a member function of the job

#

in a lambda you would likely need to convert it to a job struct at the moment to have member functions

tawdry tree
#

Examples:

struct SomeJob : IJob{
  public void Execute(/*...*/);
    Method(1);
    HelperClass.StaticMethod(2);
  }

  //member function
  void Method(int arg){
    //...
  }
}

public static class HelperClass{
  //Static method
  public static void StaticMethod(int arg){
    //...
  }
}
low tangle
#

yep that looks good

tawdry tree
#

Alright, so the way the sandbox project is set up, it had a gameobject, which it converted. From that it grabbed a RenderMesh as a shared component, to use with a predefined archetype...
Looking at the samples, I feel like the more appropriate way would be to just make a ConvertGameObjectToEntity prefab and conversionSystem.GetPrimaryEntity(Prefab).
If I understand correctly, this will convert it behind the scenes at compile time, so only once, and I can use the normal 'entity prefab' method to create variants of it?
Is this correct?

opaque ledge
#

@low tangle when i asked about bridging ECS and Monobehaviour you mentioned system data, can you give me an example so i can learn from that and implement my bridge ?

#

if it isnt secret or anything ofc ๐Ÿ˜„

velvet oxide
#

@low tangle and @tawdry tree Thanks!

low tangle
#

well, theres nothing really secret about it, AddComponentObject on a entity with any mono compnent

#

this is for keeping track of a linked gameobject so you can destroy it when a entity is deleted

#

some older systems work the other way around and the monobehavour link manages the entity and delete it when they are destroyed

tawdry tree
#

@low tangle Anything on my Q?

low tangle
#

yeah thats correct

#

it wont convert behind the scenes though

#

it would have to be in a subscene

#

what you will do in this case is have a convert to entity on it, which does it at runtime on the first frame

#

its async but its important to know when it happens

#

it will just give you the prefab entity you want that you can then instantiate

#

you could also do it on a gameobject in resources / ref'd somehow and run the converter directly

#
var ent = GameObjectConversionUtility.ConvertGameObjectHierarchy(go, new GameObjectConversionSettings {DestinationWorld = World.DefaultGameObjectInjectionWorld })
tawdry tree
#

I already added the convert to entity script, and it shows up as an entity in the debugger (and visibly). I really just want a reference I can clone, somehow, and looking at that old code of mine.... Oof, old ECs code is hacky!

low tangle
#

just fat names

#

personally I just do this above when I was creating my prefab entitys

#

start of the system, grab the prefab go, convert it to a entity, add a 'Prefab' component on it so its inert

#

then instantiate away

tawdry tree
#

Active part of old code:

var protoEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(proto, World.Active);
var result = World.Active.EntityManager.GetSharedComponentData<RenderMesh>(protoEntity);
  Object.Destroy(proto);
 World.Active.EntityManager.DestroyEntity(protoEntity);
#

That's from my "EcsUtilities" helper class, and the method takes the name of a gameobject and returns a rendermesh from it

low tangle
#

ah yeah, just add the prefab component and keep the source entity around

tawdry tree
#

It doesn't like World.Active, though, and also this is in a static helper class - ideally the system does this

low tangle
#

World.DefaultGameObjectInjectionWorld

#

they renamed it so people dont get it confused with the ComponentSystem.ActiveWorld or however it goes world ref

tawdry tree
#

Know what IDeclareReferencedPrefabs does? The docs are not very helpful...

#

Yeah, the deprecation warning suggests to use that

low tangle
#

its used by the normal conversion system for linking up the declared extra gameobjects to convert

tawdry tree
low tangle
#

yep

tawdry tree
#

What's the name and namespace of the prefab component?

#

Oh, it's literally just Prefabin Unity.Entities.... I feel silly now

twin raven
#
Entities.WithAll<SomeIBufferElementData>().ForEach((Translation2D _trans, Entity _e)=>{
  DynamicBuffer<SomeIBufferElementData> buffer = EntityManager.GetBuffer<SomeIBufferElementData>(_e);
  //buffer.Length can be 0
})

How do I use Entities.ForEach with DynamicBuffers? Shouldn't it not run if the entities don't have any elements?

#

Oh I just realized that I can use the dynamicbuffer in the inline function

Entities.ForEach((DynamicBuffer<ActiveTarget> _targets, Translation2D _trans, Entity _e) => {...

I guess I just check the size and remove the dynamicbuffer if it is not needed

#

I think this is called Rubber duck debugging ๐Ÿ˜„

dull copper
#

so for Convert and Inject GO to work, I can't use dots subscene, so I'm again back in the starting point with no entity conversion preview ๐Ÿ˜„

#

it's such a small thing but it would be awesome if it would just work

cobalt eagle
#

this is literally insane

#

this changes everything

dull copper
#

how? ๐Ÿ˜„

#

like, was pathfinding perf a limit for you in past?

low tangle
#

0.1ms is pretty high for that single grid (didn't watch more than a second)

#

thats likely just the job startup cost + tiny bit of work

#

in the comments though he makes a good point, that's a unoptimized dots solution vrs a the same in oop. so even if you are not that 'good' at dots it will still be faster.

dull copper
#

he had 700ms on regular monobehaviours, which is totally weird comparison as that example was totally unoptimized

low tangle
#

yeah that was intentional

#

lazy case vrs lazy case

#

instead of splitting hairs on the best possible oop version

#

which really just ends up being a microcosm of memory management and its totally opaque

#

I dont like wasting time writing defensive code (at least in games)

velvet oxide
#

Is unity making some sort of dots pathfinding? Or are they extending navmesh?

zenith wyvern
#

Not that I've heard of. Seems like there's plenty of other important stuff they want to finish first

safe lintel
#

dev in the forums posted that they are starting it this year so i expect it wont be available for some time

magic frigate
#

Says he will likely replace this with whatever Unity comes out with eventually.

gusty comet
dull copper
#

along with bunch of other DOTS package updates

opaque ledge
#

I believe you cant acess Unity API methods in job structs you need to get them in component system and send it to job, so something like

float delta time = Time.deltaTime;
var job = new MyJobs{time=deltaTime}
return job.schedule(this, inputDependicies);
#

Dont forget to make a public float field in your job struct

#

ooh thanks Olento

#

did they release new burst ?

dull copper
#

not yet

#

if you mean 1.3 preview

opaque ledge
#

ah i see, getting debug.log will help ๐Ÿ˜„

dull copper
#
## [Entities 0.5.1] - 2020-01-28

### Fixed

* Constructor-related exceptions thrown during `World.CreateSystem` will now included the inner exception details.
* Fixed an issue where `BlobAssetReference` types was not guaranteed to be 8-byte aligned on all platforms which could result in failing to read Blob data in components correctly on 32-bit platforms.
* Fixed issue in MinMaxAABB Equals() comparing Min to itself rather than other.
* `Entities.ForEach` now properly treats `in` parameters of `DynamicBuffer` type as read-only
* Fixed potential crash caused by a leaked job after an exception is thrown during a call to `IJobChunk.Schedule`.
* `DefaultWorldInitialization.GetAllSystems` now returns `IReadOnlyList<Type>` instead of `List<Type>`
* `DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups` now takes `IEnumerable<Type>` instead of `List<Type>`

### Changed

* Updated dependencies for this package.```
opaque ledge
#

oh just fixes then

dull copper
#

rest of the package updates (jobs, collections, hybrid rendering) are just dependency updates

#

so yeah, just a hotfix apparently

opaque ledge
#

i probably should look into blob assets

zenith wyvern
#

Same here, still haven't touched them

#

Huh, did they not fix the singleton bug?

#

Hopefully they just didn't mention it

opaque ledge
#

what is the singleton bug

zenith wyvern
#

In 0.5 GetSingleton causes a singleton to be spawned every frame apparently

opaque ledge
#

i had a singleton bug where it keep querying it every frame, so it would query 1000 times

low tangle
#

oooh thats a great update

#

IReadOnlyList<Type>

opaque ledge
#

ah yeah, that doesnt happen to me anymore

#

it.. was fixed when new burst was released for some weird reason

low tangle
#

hybrid got a update too

zenith wyvern
#

Just dependency update it looks like

low tangle
#

man I dont know if I can do this minor update

#

never know if its going to break with il2cpp

opaque ledge
#

Do you guys think there will be new stuff added ? seems like most of the foundation is already implemented, i feel like they will release fixes from now on

low tangle
#

yes there will be

#

still in active change

zenith wyvern
#

Definitely. Apparently there's a big update coming for Hybrid Renderer in particular

low tangle
#

it aint the last either

zenith wyvern
#

And I'm looking forward to expanded API on Foreach

opaque ledge
#

i mean, i am talking about entities package itself

low tangle
#

rendering will be the longest ecs package imo

gusty comet
#

anyone using visual scripting ?

opaque ledge
#

oh you know, i had a question about that, what is the difference between doing Entities.ForEach and IJobxx structs ?

low tangle
#

if your talking about the new foreach in a JCS

#

then nothing

zenith wyvern
#

The ForEach literally generates the IJob code

opaque ledge
#

so it doesnt matter then ?

low tangle
#

JobForEach<T1, T2>

opaque ledge
#

i mean no difference

low tangle
#

it does matter

zenith wyvern
#

It matters because the ForEach is way more readable

low tangle
#

it saves you time

zenith wyvern
#

And yeah, easier to write

low tangle
#

and its easier to get started / understand a gist

#

but not the real thing going on

opaque ledge
#

idk, i generally use IJobxx, it makes it more readable for me and more maintainable

low tangle
#

accessible

opaque ledge
#

but thats only me i guess ๐Ÿ˜„

low tangle
#

you shouldn't shy away from a tool for the sake of it

#

but I typically do all jobs in one yeah

#

only my main thread stuff in lambdas

opaque ledge
#

can you do double query in ForEach ?

low tangle
#

no

#

nested you mean?

opaque ledge
#

ah alright

#

yeah

low tangle
#

nah you cant

#

and 100% no in a job

#

jobs cant run other jobs

#

you could ofc create a raw job and get all the up front chunks and do all the iteration yourself

#

but if you need it that bad, you really need to stop and rethink your logic

opaque ledge
#

nope, i use 1st job to get i want and use the results in 2nd job, so no nesting

low tangle
#

thats the correct way to do it

#

list, array, hash

#

whatever makes sense

#

updating all the packages now and crossing my fingers

#

๐Ÿคž๐Ÿป

opaque ledge
#

which brings me to a point, when you layout jobs in sequential order, like Job1 depends on input dependincies, Job2 depends on Job1, Job3 depends on Job2 etc.. will this system run if lets say Job3 or Job2 has 0 entities to process ?

#

gl ๐Ÿ˜„ ๐Ÿคž

low tangle
#

yes

#

if you chain jobhandles

#

it will run every single one

#

think of it this way

opaque ledge
#

isnt that kind of a waste

low tangle
#

no

#

think of it this way

#

if you call .complete what happens to a job

#

runs till its done right?

#

put one that goes before the other, it will do the first then the second

#

all the way up to n

#

you jobs are all getting called .complete by the scheduling system

zenith wyvern
#

I doubt you need to worry about the overheard of a job whose query has no entities running in the middle of a chain

low tangle
#

the job structure under will basically early exit since there are no chunks to iterate on

opaque ledge
#

Yeah but shouldnt underlying system know that all of the jobs that depends each other wont be able to run so it shouldnt let system updaate ?

low tangle
#

the job itself describes the conditions to run, not the job before it

opaque ledge
#

i mean same goes with GetSingleton, system runs because i am retrieving it but my job has 0 entities so it wont update

zenith wyvern
#

I'm not sure...but again, don't worry about it. Until you actually see a performance problem just write your code so it's easy to understand.

#

Worrying about the overhead of an empty query is almost definitely a premature optimization

opaque ledge
#

yeah i understand, its just annoying, and makes me think my system is running even tho it shouldnt run at the time

low tangle
#

IJob = none
IJobParallelFor = 1-n with m numbers per thread/job
IJobChunk = will run a thread/job per chunk that matches the query archtype
IJobForEach = a jobchunk that runs a function on each entity within that chunk

opaque ledge
#

ah you know i was going to ask about that

#

(such a surprise right ๐Ÿ˜„ )

#

so i have my 1st job retrieving some entities and write to a native array, and my 2nd job is IJobParallelFor and simply calculates stuff for each of these entities

#

But the thing is i cannot know how many entities i have got because i cannot use native list in 1st job since it cannot be written in parallel after its' length

#

so i cannot give the proper container size to IJobParallelFor and i.. simply give like 100 or smth even tho i have 20 entities to process

#

any advices ?

zenith wyvern
#

Why can't you use a NativeList in the first job?

opaque ledge
#

because its parellely writing, if my list has 5 items, 6th iteration wont be able to do list[5] = value, so it access to it as a native array and not really a list

#

and if i initialize some items in this list to contain all of those entities, since i dont know how many entities there will be, i will simply initialize arbitary number of items meaning i will still not know how many entities i processed

zenith wyvern
#

There's not really good documentation for it yet, let me write up a small example

opaque ledge
#

jobs 0.2.3 version ๐Ÿ‘€ ๐Ÿ˜„

#

ah wait, nvm, i actually dont know what is the most recent version of jobs

#

i confused it with burst, so i was surprised lol

#

and thanks

#

ah i see, so there is a second method to calculate size which we can override ?

#

i will try to implement one when i am on my pc

zenith wyvern
#
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var ints = new NativeList<int>(Allocator.TempJob);
        
        inputDeps = new IntJob
        {
            ints = ints
        }.Schedule(inputDeps);

        inputDeps = new Reader
        {
            deferredList = ints.AsDeferredJobArray()
        }.Schedule(ints, 32);

        return inputDeps;
    }

    struct IntJob : IJob
    {
        public NativeList<int> ints;
        public void Execute()
        {
            for (int i = 0; i < 500; ++i)
                ints.Add(i);
        }
    }

    struct Reader : IJobParallelForDefer
    {
        public NativeArray<int> deferredList;
        public void Execute(int index)
        {
            int val = deferredList[index];
        }
    }
#

Not tested but that should be pretty much right

opaque ledge
#

ah i see, so it just calculates how many items in there on its own, thanks

gusty comet
opaque ledge
#

what is the error

gusty comet
#

i cant see ECS graph

zenith wyvern
#

I haven't messed with the visual scripting thing at all sorry, you might try asking in the thread for it on the forum

gusty comet
#

i already did

opaque ledge
#

it says on the unity console that your scripts cant be compiled because there are some errors, you need to fix those issues first

#

i think unity isnt simply compiling the visual scripting package

gusty comet
#

yes i cant understand the error

opaque ledge
#

if you can take a screen shot of those errors maybe we can help

gusty comet
#

ok

zenith wyvern
#

All I can suggest is to make sure you're using the latest unity version (2019.3.06f) and try deleting your library folder and restarting unity

low tangle
#

that actually looks like its not been updated for entites 4+

#

which is where the Time change came from

gusty comet
#

how to update it ?

#

in VS

#

its line 143

low tangle
#

go to your package's folder edit the line it talks about

#

if its in the package cache you will need to move it to the package folder

#

yeah its in the cache

#

move it

gusty comet
#

all the folders ?

#

inside package cache to package folder ?

low tangle
#

no just the graph

#

visual scripting

gusty comet
low tangle
#

yes

#

now go in there and fix the time errors

#

your gonna need to figure this out yourself

opaque ledge
#

btw, in some ecs codes i see inject attribute inside job structs, is that still a thing ? if so what does it do exacttly and how can i use it

gusty comet
gusty comet
#

How do I debug while using the burst compiler?

#

I get Burst Error: Loading a managed string literal is not supported

#

more detailed - I'd like to debug during a Job

opaque ledge
#

yeah it isnt supported yet, i heard UnityEngine.Debug.Log will be supported on next burst version

#

simply remove burstcompile attribute and call Debug.Log i believe

gusty comet
#

I'm not sure where the BurstCompile attribute is added because it goes back to JobHandle override which is something UNity did

#

(checking the DOTS sample)

dull copper
#

"For strings, we hope to bring basic support for them for the 1.3 timeframe in the case of Debug.Log and also with NativeString."

#

(1.3 burst)

#

Unity never promised it'll make it tho

#

so we'll see

#

I'd assume you'd also need 2020.1 if you want to be able to use that within jobs

#

(like you need for debug draws on jobs)

opaque ledge
#

BurstCompile attribute is added to job struct, you need to remove that

gusty comet
#

I ctrl + F'ed the entire solution for "struct Job" and only found struct JobHandle and it doesn't have a BurstCompile attribute

opaque ledge
#

search BurstCompile then ?

gusty comet
#

i'll get all though - going through all of them will take too long

opaque ledge
#

or if query is built with ForEach, there could be .WithBurst() as well

gusty comet
#

the ForEach uses .Run()

opaque ledge
#

nah, its like Entities.WithBurst().ForEach(()=>).Run()

#

should be something like that

hollow sorrel
#

you only need to disable it on the job you're trying to debug

#

do you know what you want to debug

gusty comet
#
            Entities
                .ForEach((ref Ability.EnabledAbility activeAbility, ref Ability.AbilityStateActive stateActive, ref Settings settings, ref PredictedState predictedState) =>
            {
                updateJob.Execute(ref activeAbility, ref stateActive, ref settings, ref predictedState);
            }).Run();
#

@opaque ledge

#

@hollow sorrel how do I do that?

opaque ledge
#

and you get the error when you put a Debug.Log here ?

hollow sorrel
#

oh if your lambda is in a jobcomponentsystem i think it enables burst by default

#

need to add .WithoutBurst

gusty comet
#

there's a function inside the Execute method that debug.log

#

Entities.WithoutBurst. then?

hollow sorrel
#

.foreach(fsdjkgjksdg).withoutburst().run()

opaque ledge
#

yeah

amber flicker
#

you can also just disable burst from the editor menu for viewing logs in editor

gusty comet
#
            Entities
                .ForEach((ref Ability.EnabledAbility activeAbility, ref Ability.AbilityStateActive stateActive, ref Settings settings, ref PredictedState predictedState) =>
            {
                updateJob.Execute(ref activeAbility, ref stateActive, ref settings, ref predictedState);
            }).WithoutBurst().Run();
#

this than?

#

@amber flicker that would be easier - where can I find this?

opaque ledge
#

from DOTS menu i think

#

DOTS->Burst

amber flicker
#

yup Jobs->Burst->Enable Compilation

gusty comet
#

Just for clarification on the entire burst thing - that won't break any code or anything , right? It'll just make everything load slower? yeah?

hollow sorrel
#

that's the idea

gusty comet
#

Let's see how it goes then. Only needs to finish compiling

#

so I''ll see ya lads in 2022

remote coyote
#

Anyone else having compile issues after updating to latest entities package?

#

Library\PackageCache\com.unity.entities@0.5.1-preview.11\Unity.Entities.PerformanceTests\SharedComponentPerformanceTests.cs(37,46): error CS0246: The type or namespace name 'SampleGroupDefinition' could not be found (are you missing a using directive or an assembly reference?)

azure nacelle
#

I did have an issue where the collections update that was needed, wasn't listed in the dependecies

opaque ledge
#

Did you also update HybridRenderer package ?

remote coyote
#

yes, I'm on 7.1.8 there

#

and updating Performance testing API didn't help either

#

(to 2.0.6)

#

Collections and Jobs + Burst updated too

#

Fixed one compile issue in Netcode, but these "you're missing an assembly ref" is not as easy to track down

opaque ledge
#

well, apperantly samplegroupdefinition lives in test framework

#

maybe try to install/update that ?

remote coyote
#

thanks, that's a start, knowing where it comes from

#

hopefully they'll release a Netcode version soon that fixes the IReadOnlyList issue. Silly to redo it every time I restart Unity

mystic mountain
#

I'm trying to parent through code, and visually the objects are close to eachother, but logically it seems they are not?

#

Translation usually means local space, but in this case it seems it is showing world space for some reason? Have I missed some part of parenting?

opaque ledge
#

i have never tried it but i believe there is a component to handle parent/child relationship

mystic mountain
#

This is my code rn

    // Add parent, set position
    EntityManager.AddComponentData(entity, new Parent() {Value = parentEntity});
    
    EntityManager.AddComponentData(entity, new LocalToParent() {Value = float4x4.identity});

    EntityManager.SetComponentData(entity, new Translation() { Value = math.mul(ltw.Value, new float4(characterTeleportData.teleportPosition, 1)).xyz});
    EntityManager.SetComponentData(entity, new Rotation() { Value = math.mul(characterTeleportData.teleportRotation, ltw.Rotation)});
#

But it is interesting with linked entity group, I have parented other things manually, but they seem to show up in the linked entity group, but not the character

twin raven
mystic mountain
#

Seems my problem was related in what systemgroup it was run.

civic bay
#

Can you not use PostUpdateCommands.RemoveComponent() in Entities 0.5?

#

I have a component system running with a query, but I remove 1 of the tags from the entity at the end of the update

#

But in the Entity Debugger, the system is still running on all entities at 3.25ms, but it doesn't show the entities that are being affected?

#

And in the Chunk Utilization, the entities are still showing that tag that should've been removed

#

Nevermind, wasn't running it properly

#

Ignore everything I said

mystic mountain
#

I've no idea why the groups matter though, I'm changing from GhostPredictionSystemGroup => ClientAndServerSimulationSystemGroup..
(edit) I might just be stupid I realize...

#

Yep, I just hadn't parented on the client, so visually it was wrong ...

civic bay
#

How come the BuildPhysicsWorld update time constantly increases, even if the game is idle?

#

It started out at 0.1ms but over time reached 10.9ms

#

(Still unfamiliar with ECS, so trying to learn as much as I can)

#

This is my BuildPhysicsWorld, is it supposed to add Physics Step every frame?

silver dragon
#

There are some bugs ongoing with current entities package. There is an update now (0.5.1) but the changelog isn't updated, so don't know if it's fixed now...

civic bay
#

How can I get this update?

#

It's not showing as an update in the package manager yet

silver dragon
#

For me it is, maybe hit refresh packages below

civic bay
#

Yeah I did

#

Hm

#

I'm using 2019.3.0f6

#

Nvm

#

Found it

#

Had to drop down Entities

#

That fixed it

silver dragon
#

There is a small symbol on the right side of the packages indicating there is a newer version

civic bay
#

Oh it was just a tick for me

#

Not the little download icon

#

Thanks @silver dragon

silver dragon
#

๐Ÿ‘

civic bay
#

How can I make a Job Component System run only once?

zenith wyvern
#

Enabled = false;

civic bay
#

Thanks

civic bay
#

How can I destroy an entity inside IJobForEachWithEntity<T>, in a JobCompSystem

silver dragon
#

With the use of a EntityCommandBuffer.ToConcurrent

civic bay
#

Yeah I got that

silver dragon
#

Though don't forget to add the jobhandle to the barrier!

civic bay
#
    private EndSimulationEntityCommandBufferSystem endSimCommandBufferSystem;
    
    [BurstCompile]
    private struct JobTest : IJobForEachWithEntity<MyData>
    {
        public EntityCommandBuffer.Concurrent CommandBuffer;

        public void Execute(Entity entity, int index, ref MyData data)
        {
            if (data.OnFloor)
            {
                CommandBuffer.DestroyEntity(index, entity);
            }
        }
    }

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        JobTest job = new JobTest
        {
            CommandBuffer = endSimCommandBufferSystem.CreateCommandBuffer().ToConcurrent()
        };

        JobHandle jobHandle = job.Schedule(this, inputDeps);

        endSimCommandBufferSystem.AddJobHandleForProducer(jobHandle);

        return jobHandle;
    }
#

What bit am I missing?

silver dragon
#

What errors do you get?

velvet oxide
#

you need jobHandle.Complete() I think

civic bay
#

Oh null ref on JobTest job = new JobTest

zenith wyvern
#

You need endSimCommandBufferSystem = World.GetOrCreateSystem<EndSimulationblahblahblah inside OnCreate

silver dragon
#

Yep, that's missing

#

And no need for complete

civic bay
#

Ah shit

#

Thanks

#

Knew I was missing something

#

Cheers @zenith wyvern @silver dragon

silver dragon
#

hrhr

civic bay
#

You didn't see that ๐Ÿ‘€ ๐Ÿ˜‚

silver dragon
#

Obey the hints from your IDE ๐Ÿ˜›

#

like "is never assigned"...

civic bay
#

Yeah I didn't see and just assumed I was messing up the JobForEach instead

silver dragon
#

And now go and use Entities.ForEach ๐Ÿ˜›

civic bay
#

Inside OnUpdate?

#

Instead of the struct?

silver dragon
#

Instead of the job

civic bay
#

How come?

vale nymph
#

Is there a way to change the layer of an entity at runtime? To have it be culled by the camera for example

silver dragon
#

@vale nymph Hm, you mean the layer on the RenderMesh? This is a ISCD, so you should not change it. You could disable the whole entity, but exclude only from rendering does not work with the default systems... as far as i know

civic bay
#

@silver dragon Sorry for constantly questions, but if I do ForEach, where do I assign the commandBuffer?

#
    private EntityCommandBuffer.Concurrent CommandBuffer;
    private EndSimulationEntityCommandBufferSystem endSimCommandBufferSystem;

    protected override void OnCreate()
    {
        endSimCommandBufferSystem = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();
        CommandBuffer = endSimCommandBufferSystem.CreateCommandBuffer().ToConcurrent();
    }    

    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = Entities.ForEach((Entity entity, ref MyData data) =>
        {
            if (data.OnFloor)
            {
                CommandBuffer.DestroyEntity(entity.Index, entity);
            }

        }).Schedule(inputDeps);

        endSimCommandBufferSystem.AddJobHandleForProducer(job);

        return job;
    }
civic bay
#

Thanks

vale nymph
#

@silver dragon Thanks for the info. I'll try with disabling the entity ๐Ÿ‘

stable fog
#

Is the dots editor just extra stuff or does it replace the gameobject workflow?

dull copper
#

@stable fog dots editor package basically gives you two things today:

  • entity conversion live preview on DOTS subscene objects
  • option to add conversion script on nonsubscene objects from the inspectors top area
#

afaik it doesn't actually change the workflow itself other than giving that mentioned shortcut

stable fog
#

nods

dull copper
#

well, I dunno if you'd need the conversion scripts on DOTS subscene without it (?), with the dots editor, you definitely don't need the extra scripts there

stable fog
#

is there ever going to be a pure dots workflow

zenith wyvern
#

The messaging seems to be that Conversion workflow is how it's going to be from here on out

dull copper
#

for now, yes

stable fog
#

heh, I don't understand it

dull copper
#

but they didn't say they totally canned the dots editor

#

it's just not worked towards atm

stable fog
#

I have what is kinda a conversion workflow, but I have a custom editor in my Visual Templates examples for making Entities

dull copper
#

I personally expected to have full dots editor by now

stable fog
#

its not really a conversion workflow thouhg, you're not creating intermediate objects

zenith wyvern
#

They have been pretty clear that the end goal is to have pure entities at runtime

stable fog
#

it wasnt particularly hard to do either

zenith wyvern
#

We're a long way from that but that is what they're working toward

stable fog
#

though it does depend on 2020.1 features, specifically SerializedReference

hollow sorrel
#

i think someone else will probably have built a pure dots editor before unity does

zenith wyvern
#

Seems pretty likely, I wouldn't want to be tasked with trying to keep up with all the API changes

stable fog
#

I almost have a pure dots editor

#

but you still have to have a GameObject to host all the Entity archetypes

#

and lol, it looks broken atm...

hollow sorrel
#

entity selection someone already figured out https://github.com/JonasDeM/EntitySelection/
entity hierarchy shouldn't be too hard to make since entity debugger basically already has that
and i think someone also made a prototype of entity inspector that lets you edit values

stable fog
#

oh thats way more useful than what I have

#

I can just make and define entities in the inspector

#

without using monobehaviors

#

well, without intermediate monobehaviors

hollow sorrel
#

yea

stable fog
#

this is old, but it works and my current one doesnt

zenith wyvern
#

I think a big problem right now is there's no good general purpose solution for rendering entities

stable fog
#

ran into a bug with iterating over serialized properties

hollow sorrel
#

oo i saw that, looks good

zenith wyvern
#

But I guess we can expect hybrid to get better so there's no harm in using it

stable fog
#

I only developed it as an example/test for my uielements lib

zenith wyvern
#

It seems like the existing conversion workflow does exactly what you're doing there

#

With [GenerateAuthoringComponent]

#

Unless I'm missing something

stable fog
#

in the conversion work flow don't you have to create monobehaviors to represent your componentdata?

zenith wyvern
#

GenerateAuthoringComponent does it automatically

#

But you are restricted to one per file which is pretty annoying

stable fog
#

generate authoring data automatically creates your ComponentData?

zenith wyvern
#

It creates a monobehaviour version of your existing componentdata

stable fog
#

ah

opaque ledge
#

yes

zenith wyvern
#

With fully editable fields in the inspector

stable fog
#

yeah, in a sense I suppose

opaque ledge
#

but for buffer types you have to implement your own authoring

stable fog
#

in mine you're just using the ComponentData

#

there is no conversion happening

zenith wyvern
#

But you still need a monobehaviour

stable fog
#

yes you do, its a host

#

but only 1

zenith wyvern
#

Yours has a nice benefit of being synced at runtime I guess

stable fog
#

and if someone consumed this project,t hey'd have to create none

opaque ledge
#

just put [GenerateAuthoringData] on your IComponent and drag it to your gameobject

zenith wyvern
#

That's possible to do with conversion workflow but very annoying

stable fog
#

eh, well its not necessarily synced at runtime

hollow sorrel
#

i think it's weird they decided to codegen seperate monobehaviours for conversion, what twiner does seems a much better solution

#

codegen isn't free

stable fog
#

its more that this is a archetype manager with default settings

#

so the idea was you pick "prefabs" from the manager

#

and instantiate them

#

there is very likely problems, it not like a completely thought out project, it was more just a test of my VisualTemplating system

zenith wyvern
#

I think they are working on making it less restrictive, so you could have multiple per file and hopefully let it work with types other than IComponentData

stable fog
#

multiple componentData per file?

#

I don't understand why you'd want that tbh

#

it just creates a situation where you have to eventually deal with a weird organization issue and start breaking apart your files

zenith wyvern
#

I usually have one per file, but I can see a case for wanting to group related components

stable fog
#

thats called a folder/namespace :p

hollow sorrel
#

i tend to put multiple components in one file too
navigating folder tree is more work than scrolling a file in vs

#

usually don't even have to scroll if your components are small

stable fog
#

Ctrl+, type name of class/struct/whatever, enter

#

Assuming you're using Visual studio that is

#

but I'd hope whatever IDE you're using has such a feature

civic bay
#

What's an efficient way to get all entities in a given radius

#

If I have 20k entities for example

#

And I just want to get all the entities that are say 1uu around it

coarse turtle
#

I'd say typically - in a general sense, building a data structure for regions (like octal trees) helps with this - usually used in broad phases of physics frameworks ๐Ÿค”

amber flicker
#

Imo: Lvl1: ForEach() check distance, Lvl2: Physics SphereCast (I assume there is such a thing, not played with Physics yet), Lvl3: Spatial data structures, Lvl4: Check Unity physics source, Lvl5:....

hollow sorrel
#

what does memory layout look like with dynamicbuffers? it always allocates as much in the component as internalcapacity is set to, right? like if you set it to 8 but it only has 2, there will just be 6 empty spots in memory per component

amber flicker
#

that's my understanding, yup

hollow sorrel
#

makes sense

opaque ledge
#

can i convert a camera to an entity ?

#

or camera game object to an entity

coarse turtle
#

I think there's only the latter

pliant pike
#

I dont suppose anyone knows how you use the new input system in DOTS?

#

I'm using these in start running which is what I was doing in a mono behaviour csharp inputAction = new PlayerInputActions(); inputAction.PlayerControls.Move.performed += ctx => movementInput = ctx.ReadValue<Vector2>();

#

but it doesnt seem to work

hollow sorrel
#

i haven't used it but that looks like you're trying to assign a delegate event

#

prob better to read inputs in a system at the start of a frame and fill an input component

pliant pike
#

I see so that way wont likely work in dots, thanks

civic bay
#

Is it possible to do subtractive components as expressions in the ForEach lambda?

#

To have a Component System run on Entities that have 'a b c' components and explicitly not 'd'

#

Because if I have an entity that has 'a b c d', this system will still run on it, right? as it still meets the abc requirements?

hollow sorrel
#

yeah, you can use .WithAll .WithAny .WithNone in your ForEach lambda

#

so in this case you'd have WithAll(a, b, c) and WithNone(d)

warped trail
#

@civic bay there is the thing called Write groups

hollow sorrel
#

altho i don't even think you need the WithAll, it's implicit by the lambda params

warped trail
coarse turtle
#

or you can use an EntityQuery reference and pass it into the Job.ForEach lambdas

civic bay
#

Will the ForEach only get entities that match the EntityQuery exactly though?

warped trail
#

@civic bay 9.30 the time Mike starts to talk about Write Groups, i think that exactly what you want๐Ÿค”

civic bay
#

Thanks!

velvet oxide
#

@pliant pike ```public class PlayerInputSystem : JobComponentSystem
{
private PlayerControlsActions controls;
private float2 inputMove;
private float2 inputLook;
private bool inputFire;
protected override void OnCreate()
{
controls = new PlayerControlsActions();
controls.Enable();

    controls.Player.Move.performed += ctx => inputMove = ctx.ReadValue<Vector2>();
    controls.Player.Look.performed += ctx => inputLook = ctx.ReadValue<Vector2>();
    controls.Player.Fire.performed += ctx => inputFire = true;
    controls.Player.Fire.canceled += ctx => inputFire = false;
}

protected override void OnDestroy()
{
    controls.Disable();
}

protected override JobHandle OnUpdate(JobHandle inputDeps)
{
    var move = inputMove;
    var look = inputLook;
    bool jump = controls.Player.Jump.triggered;
    //bool fire = controls.Player.Fire.triggered;
    bool fire = inputFire;

    var job = Entities.ForEach((ref PlayerInput input) =>
    {
        input.moveInput = move;
        input.jumpInput = jump;
        input.lookInput = look;
        input.fireInput = fire;

    }).Schedule(inputDeps);

    return job;
}

}```

#

not sure if this is the "proper" way to do it but it seems to be workign for me for now.

dull copper
#

that looks what you'd expect to have there now

#

(like, it looks like the proper way to do it for the time being)

velvet oxide
#

then the component

#
public struct PlayerInput : IComponentData
{
    [HideInInspector] public float2 moveInput;
    [HideInInspector] public float2 lookInput;
    [HideInInspector] public bool jumpInput;
    [HideInInspector] public bool fireInput;
}```
pliant pike
#

I see using componentdata is a much better way of using them, that's awesome, thanks @velvet oxide

opaque ledge
#

So apperantly i cant get random number

#

i do var random = new Random(5), and then call random.nextint(0,20), it always returns 0

pliant pike
#

I'm curious though, why use GenerateAuthoringComponent and then HideInInspector?

velvet oxide
#

Just personal preference. I mostly just use IComponents to hold data and the ones I dont want showing up in the inspector I hide

viral kindle
#
new Random(5)
```gives you random with a seed set, so you will always get same sequence from it
#

@pliant pike

opaque ledge
#

i mean i tried other values, lilke 1-4-52-42 etc, they all give 0 and i am using this in a job, all of them gives me 0

#

i dont understand how am i suppose to use it

warped trail
#

random.InitState() ?

pliant pike
#

I always use Random.Range whenever I want something random

viral kindle
#

Oh, I miss mentioned

opaque ledge
#

nah its still the same, random.Initstate() didnt work

#

i am trying to use random in Mathematics.Random not UnityEngine.Random Calabi

viral kindle
#

Sorry, no idea then

pliant pike
#

you still need a range though surely? otherwise you have an infinite possible numbers

zenith wyvern
#

@opaque ledge If it's giving you the same value it means you're passing the same seed. Google how random number generators work with seeds and you will understand

opaque ledge
#

its not just giving the same value, it always gives me 0 even when init with different numbers

zenith wyvern
#

You're telling me if you do

Random rng = new Random(1);
NextInt(0,20);
rng = new Random(2);
NextInt(0,20);
#

Gives the same number?

opaque ledge
#

yeah something like that

#

let me check that

warped trail
#

first int is always 0๐Ÿค”

opaque ledge
#

So i did something like this:

        if((uint)Time.ElapsedTime > 0 ) random = new Random((uint)Time.ElapsedTime);
        else random = new Random(1);```
And i send random to my IJob, and i am taking random like this:
        var randomNumber = random.NextInt(0, 20);
        UnityEngine.Debug.Log(randomNumber);
#

always gives me 0

zenith wyvern
#

Not sure then, I don't see what you would be doing wrong from what you posted. If you try the code I actually posted above you'll see it should return different values

opaque ledge
#

first code works on jobcomponentsystem btw

warped trail
#

@zenith wyvern your code return 0 as first value, no matter the seed

zenith wyvern
#

The first call to NextInt(0,20) would always return 0?

warped trail
#

yes

zenith wyvern
#

Well there you go then, I didn't know that

warped trail
#

but im not sure that it supposed to be that way๐Ÿค”

opaque ledge
#

@zenith wyvern tried your code on a jobcomponent system, both gives 0 for me

zenith wyvern
#

Try calling NextInt(0,20) immediately after you seed it but before you pass it in then

warped trail
#

@opaque ledge before the job, just create some native array and populate it with random numbers

#

and than use jobIndex as index to that array

opaque ledge
#

ok so i put Sark's code to a monobehaviour still both 0

warped trail
#

or something like jobIndex % yourArrayWithRandoms.length

opaque ledge
#

yeah probably i will do something like that

#

i mean.. is this a bug or ?

warped trail
#

next values are random

#

you have to initialize Random only one time

zenith wyvern
#

It doesn't seem right that the first call would always return 0 but I don't know enough about it

hollow sorrel
#

try bigger seed range

#

like 100000

zenith wyvern
#

Seeding an RNG and using once then discarding is definitely not the right way to use it anyways

opaque ledge
#

i just did

        UnityEngine.Debug.Log(rng.NextInt(0, 20));
        UnityEngine.Debug.Log(rng.NextInt(0, 20));
        UnityEngine.Debug.Log(rng.NextInt(0, 20));
        UnityEngine.Debug.Log(rng.NextInt(0, 20));``` and it gave me 0, 0, 12, 1 every update ๐Ÿ˜„
zenith wyvern
#

You should search the forums to see how other people have been using RNG in jobs

opaque ledge
#

hmm, let me see

warped trail
#

bigger seed gives different first value

opaque ledge
#

yeah, i tried like 56127 and it gives me 5 now but it still doesnt chance even tho i only created Random on OnCreate method and simply use NextInt on my job

warped trail
#

Random is a struct

#

so you are passing it to a job by value

zenith wyvern
#

Once it leave scope you would be losing it's state. That's why someone suggested you generate the numbers in a NativeList and pass that instead

#

There are other strategies too, like I said you should look it up on the forums

opaque ledge
#

wait so sending my Random to jobs doesnt work ?

#

i am using it like this:

        var thirdJobHandle = new CreateTradeShipJob()
        {
            commandBuffer = commandbuffer,
            comparisions = ownedComparisions,
            positions = positions,
            random = rng
        }.Schedule(secondJobHandle);```
hollow sorrel
#

i think the usual is to randomize the seed of the random that you're passing into the job
at which point you might as well create the random value outside the job unless you need multiple in the job

zenith wyvern
#

@opaque ledge As druid said Random is a value type.

opaque ledge
#

i dont know the range tho, i can only know my maximum range inside 3rd job

warped trail
#

you can use %

#

create native array of random nubmers and pass it to your job

#

yourArrayWithRandoms[jobIndex % yourArrayWithRandoms.length]

#

should work๐Ÿค”

opaque ledge
#

wow okay, yeah calling NextInt works on system OnUpdate but not when i call it inside job

#

i... dont understand ๐Ÿ˜ญ

warped trail
#

same seed = same output๐Ÿ˜„

opaque ledge
#

yeah but i am not changing the seed inside OnUpdate either, but it does give me different numbers

tawdry tree
#

I'd like to point out that Random is pseudorandom, so similar seeds (especially close to 0, but not exclusively) tend to give similar numbers

opaque ledge
#

OOOOOOH

#

now i understand

tawdry tree
#

If you want more variation, multiply the input with some semi-high number (usually a prime)

opaque ledge
#

Random on my system is copied by value to job

warped trail
#

yes๐Ÿ‘

opaque ledge
#

so when i call NextInt, it doesnt affect my original random, it affects the copy

#

so my Random Struct doesnt actually know i called him

#

dayuuum

#

my mind is blown right now

tawdry tree
#

Oh, that issue. If you're using the Unity random (which is a struct, and thus value) and not System.Random (which is a class, and thus reference), you would usually just create it in a job, and seed it using some output from outside plus something unique to the job iterator (index, for IJobParallelFor)

#

As long as no burst is involved, could potentially force by value, but that would be horribly thread-unsafe

zenith wyvern
#

Simple solution is pass a NativeArray<Random> of size one. Get the random, do NextInt, and assign it back to the array

opaque ledge
#

Yeah, i never worked with structs before, i simply never needed to, i just have to get used to it

#

yeah i will just make persistent nativearray just for that random and simply pass that to jobs

pliant pike
#

I cant seem to get the above code to work, I have to use [alwaysupdatesystem] to even get it to run and then no inputs are being applied to the entity/ component

#

I've checked it is reading the inputs, but its like the job Entities.foreach isn't running

warped trail
#

try to make it like in the UnityPhysicsSamples

pliant pike
#

yeah i might do that thanks

safe lintel
#

entities 0.5.1 is out, seems to fix the issue with singletons (and also my own problem with burst not running in the editor)

pliant pike
#

nevermind it is working

stuck hatch
#

Hello, how do I use DOTS Transforms correctly? Do you have tutorials for me? I do not know which component is the right one (Child, Parent)

stuck hatch
#

the site is difficult to understand

warped trail
pliant pike
#

yeah I wouldn't bother trying to read all that to be honest

tawdry tree
#

@stuck hatch Use transforms for what? What are you trying to achieve?

pliant pike
#

I know you need a localtoworld component

stuck hatch
#

I want to add a child and remove a child, like old unity transform.setParent and remove child

tawdry tree
#

I am not sure how to do that (leave it to someone else), but would like to point out that it might not be 'correct' under the ECS model.
Though as with all best practice kinda things - if it works, it works, and you can always improve on it later. You sound like you're still learning (aren't we all?), so I wouldn't care too much about that.

safe lintel
#

@pliant pike well its the best source for understanding how the transform system works, its not gonna make sense if you skim read it but it details in depth what the interactions are. just read Section 1 & 2 slowly

warped trail
#

in the video Mike Acton explains everything๐Ÿ˜„

stuck hatch
#

ok i go through the page

pliant pike
#

I know I just couldn't understand much of it to be honest maybe a few parts

safe lintel
#

well not saying i understood things on the first go, & I still refer back to it ๐Ÿ™‚

pliant pike
#

I think that is where I learnt about scale and non uniform scale so maybe it is useful

safe lintel
#

but i wish all the dots packages had documentation like that, like physics docs is pretty simplistic in comparison

pliant pike
#

I feel like the physics needs a cheat sheet or something

#

these are the common ways physics is used and these are the ways you can do it in dots physics

#

woot! I just got something moving with physics at least

outer glacier
#

I have a spawn point that is a child game obj that gets converted to entity. I have a gun entity that references the child entity. I'm trying to get bullets to spawn from the child's position. Anybody know how to do this with Unity.Mathematics? It's something like transform.TransformPoint() I think.

pliant pike
#

why would you need maths library for it?

#

you just get the position of the child surely

left oak
#

LocalToParent of the child and LocalToWorld of the parent?

outer glacier
#

@pliant pike getting the Translation.Value of the child does not change while the gun is moving

pliant pike
#

well then maybe their is something wrong with the parent child system as the child should move with the parent automatically if its set up correctly

outer glacier
#

It doesn't work the same in ecs as it does with regular transforms

#

@left oak how do I combine those?

pliant pike
#

I mean the simplest way I would do it without using all the parent child function, is to save the gun translation into an entity component and then get it directly from that

outer glacier
#

I thought about storing a float3 on the gun for the spawn point offset but I think that still doesn't work if the gun is a child of another entity

#

I think I just need the equivalent of Transform.TransformPoint in Unity.Mathematics.

pliant pike
#

all you really need to do is tag it as a gun and if it exists in the scene and has all the correct components, you can get them with the entityquery or singleton, foreach etc

warped trail
#

but transformPoint is simple matrix multiplication isn't it?

outer glacier
#

Well I think so but saying it's simple doesn't tell me how to do it. Ha. The picture I posted had how I was trying to do it but it's still kind of offset weird.

#

Maybe I shouldn't make the gun a child of the character. That's probably wrong in ecs.

pliant pike
#

you have to otherwise it would not move with the player though

safe lintel
#

can you not just get the child's LocalToWorld.Position ?

pliant pike
#

I can see how it would be difficult you cant use the editor to position the gun spawn point

outer glacier
#

@safe lintel yes you can ๐Ÿคฆโ€โ™‚๏ธ

#

That fixed it. Thanks for the help guys

#

Somehow I didnt know that it had a Position property. I thought you had the manipulate the matrix value somehow.

coarse turtle
#

Well the Position property grabs float4x4.c3.xyz / c3.w

#

if you need it ๐Ÿ™‚

outer glacier
#

Thanks. Yeah my matrix math skills are not very strong. Haha

warped trail
#

math.mul(Parents_LocalToWorld, point) is equivalent to Transform.TransformPoint

#

point has to be float4 with w=1 if it is position, and w= 0 if it is direction

#

if i'm not mistaken๐Ÿค”

coarse turtle
#

that should work out iirc been a while since I had to do any of this manually lol

dull copper
#

from ML-Agents roadmap: Packages - We will be releasing a preview Unity package for ML-Agents that will be available in the Unity package manager. We hope this will resolve many production and implementation issues with our Unity developers. Our plan is to first release this package for object-oriented (Monobehavior) in March. We plan to release a package for ECS in 2020.
link: https://github.com/Unity-Technologies/ml-agents/issues/3263

coarse turtle
#

yep ๐Ÿ‘

mystic mountain
#

Do you need to do anything specific to include SubScenes into builds?

safe lintel
#

build with the new build pipeline

mystic mountain
#

I see..

#

Does it mixmatch between ProjectSettings and that or is it fully isolated? Like define symbols etc

safe lintel
#

i am not sure tbh

dull copper
#

I'd assume the player settings defines etc get included

#

but yeah, you def need to use the new build setup for subscenes or they just get omitted on builds

#

(or at least something goes missing)

mystic mountain
#

Uff, hmm can I build for x86 through that?

dull copper
#

would assume so, there isn't a setting?

#

I bet it's that "Standalone Windows"

#

instead of "Standalone Windows 64"

mystic mountain
#

Hmm, was that I was trying, but still got error, maybe I was reading it wrong

#

Yep, read it wrong x)

dull copper
#

"Editor's active Build Target needed to be switched. Please wait for switch to complete and then build again."

#

so I guess you wait for it process the change first

mystic mountain
#

Nono, I was doing the Standalone Windows and it complained net bindings was 64x and I built for 86x, was just the other way around.

#

Maybe it is because I create them through instantiation...

willow creek
#

It's currently not possible to access the UnsafeList contained by NativeList, I have a need for that or otherwise have to roll out my own version of a native list for perf benefits. Do you know if this is a topic or going to be changed soon?

trail wraith
#

idk what i'm doing wrong, but i can't get subscenes to work at all, all scenes added on new build pipeline. game objects with the convert script work fine. my streaming assets folder in the build is 4.5gb. but nothing loads

dull copper
#

wonder if it's still some code stripping issue

#

but I dunno why it would only affect subscenes

frosty siren
#

What today is a best way to sync destroying entity and gameobject? How u do it?

trail wraith
#

might try upgrading the project, on 0f1 atm

safe lintel
#

@frosty siren you can try using companion gameobjects, I think destroying either destroys the other but i havent actually tested that part of it, its also not recommended for anything but experimenting so that on top of dots being preview is kinda not too confidence inspiring

valid haven
#

Am i correct in thinking there will be no PhysX DOTs/ECS support? So for advanced physics one needs to look to Havok? My challenge is the network replay functionality of Unity Physics is desirable but not super excited about its stateless physics (although I understand replay somewhat depends on reversing the state).

frosty siren
#

@safe lintel what is companion gameobject? managed componentData?

safe lintel
#

theres a demo of it in the samples repo

#

like wireframe gizmo or something similar, that scene should explain better than i can but it kinda links a gameobject to an entity

#

yeah pretty much @valid haven though i believe physx is open source now so you could make your own port of it to dots if youre feeling ambitious

valid haven
#

lol as fun as all that math sounds, that sounds like a project in of itself ๐Ÿ˜‰

#

Any thoughts on how to deal with Havok's stateful system and achieve good multiplayer fps projectile accuracy (e.g. network replay like accuracy).

#

Also I noticed havok's licensing is per seat, I assume only developers involved in the physics coding would need a seat?

zenith wyvern
#

If I have literally zero experience doing anything network related would the dots shooter sample be a reasonable place to start learning?

valid haven
#

I would say so, theres a decent unity video on on it, looks pretty straight forward.

zenith wyvern
#

I wasnt sure if it's at a good place yet for beginners, I know they said they're working I higher level layers down the road

valid haven
#

honestly compared to the old net solution it looked simpler.

#

just getting into it myself tho, so shrug.

ebon ember
#

I suspect it's just the way I create the NativeArray

low tangle
#

the native array is a copy

#

not the actual values

#

you will need to apply the data back afterwards

ebon ember
#

@low tangle This says otherwise ๐Ÿค”

low tangle
#

_voxelGroup.ToComponentDataArray<Voxel>(Allocator.TempJob);

#

this line creates a job to go and find all voxels, and copy them into a destination nativearray

#

it is a copy end of story

ebon ember
#

Any idea how to get the values then?

low tangle
#

jobforeach instead

valid haven
#

unity supports voxels natively? ๐Ÿ™‚

zenith wyvern
#

@ebon ember You could use entityQuery.CopyFromComponentDataArray to write the changed values back to the original entities

ebon ember
#

@zenith wyvern Ah! I was just looking for that!

#

@valid haven It's a component I created

valid haven
#

i c ๐Ÿ˜

zenith wyvern
#

I wonder how many people are trying to make voxel games in ECS now, hahah

#

I've seen at least 4 including myself

valid haven
#

what engine are they using?

#

I am trying to figure out how best to create ECS/DOTs powered game with mineable asteroids

zenith wyvern
#

I meant in Unity with the ECS framework specifically

valid haven
#

I mean which voxel solution they using. Custom? or one of the assets on the store.

zenith wyvern
#

Custom

valid haven
#

Creating a good voxel solution is pretty much an entire project in itself is it not?

zenith wyvern
#

After all these years Unity is finally pushing for performance first so it makes sense people would try to jump in. And I'm including myself in that of course

#

And yeah, that's what I mean. I've seen a few other people talk about making their own framework for an open world voxel game

valid haven
#

Hopefully one of you make it an asset so others can use it as well ๐Ÿ˜‰

zenith wyvern
#

It was always possible of course but with dots and ecs it creates some new interesting opportunities

#

Mine is open source. It's dead ended right now though, I'll get back to it at some point

valid haven
#

What are your design goals for it?

zenith wyvern
#

Basically to make a lame minecraft clone, just to see if I can

valid haven
#

i c. I am looking for something that can replicate Space Engineers like roids, procedural roid clusters with interesting shapes, and non-blocky deformations as they are mined.

zenith wyvern
#

As far as I know most people achieve that with marching cubes. I've never tried that, I'm happy enough with plain old blocks

valid haven
#

yup, havent found a reasonably priced marching cubes implementation, let alone one focused on dots/ecs with navmesh support.

gusty comet
#

Anyone use visual scripting ecs ?

zenith wyvern
#

Does getting a component with the EntityManager force a sync point? Or only if you try to write to the component?

safe lintel
#

id love to know the answer to that myself

low tangle
#

writing causes a CompleteAllJobs to happen yes

#

well, structure changes does

zenith wyvern
#

But not entityManager.GetComponentData(entity) right?

low tangle
#

get wont

#

you can always profile and check yourself

#

you will see these two on the main thread

#

this is a monobehavour that creates a few entites

zenith wyvern
#

Oh, that's a good tip, dang

#

Thanks

low tangle
#

np

#

the completealljobs is basically the sync point

opaque ledge
#

how can i create a world and init those systems into that world and stop that world so my systems will be stopped as well ?

low tangle
#

the way you update that world is directly controlled

#

so you will have to update it yourself, if you dont want it to update you just dont update

mystic mountain
#

Anyone know the correct way of adding subscenes dynamically, i.e. instantiating them into scene? (still only 1)

#

I tried by having it as a prefab, but it doesn't seem to work when I build.

opaque ledge
#

So, how can i make a world UI(Gameobject) follow my entity ?

#

Should i be using the AddComponentObject ? i never tried to work with it but if that is the correct direction then i will

#

is there any alternatives to it or ?

warped trail
#

do you want to sync transforms between entity and some game object?

opaque ledge
#

yeah, perhaps even getting some data from that entity to set my UI text

warped trail
#

Have you looked at physics samples? There is EntitySender EntityTracker scripts

opaque ledge
#

ooh okay, i will check it out.

#

is it in new sample repo ?

warped trail
low tangle
#

CopyToTransform

#

CopyFrom

#

AddComponentObject the transform

#

To the same entity that has a Copy and a translation

#

@opaque ledge

opaque ledge
#

i will check those, thanks

low tangle
#

Also for AddComponentObject

#

After you do that, you can literally just put the monobehavior into the foreach lambda

#

No ref or in

#

It's really easy to do ecs on monos that way

#

Just make sure it's no burst and Run since those are main thread

opaque ledge
#

But how can i get the entity that particular monobehaviour is attached to ?

#

i guess i have to manually set that, i should probably have a public Entity field on my Mono, and when i create an entity i should set that Entity to that Mono ?
So something like:

var entity = commandBuffer.CreateEntity();
var mono = commandBuffer.AddComponentObject(entity, typeof(MyMonoBehaviour));
mono.entity = entity;```
#

would that be the way to go ? @low tangle

dire frigate
#

I notice that the new blog post from 2019.3 says that they've upgraded physx, wherein another article explains that physx is now threadsafe to use with jobs?

#

has anyone tested this?

dull copper
#

there's like 25 bugfixes for burst on 2020.1.0a21 fix list (between a20 and a21)

pliant pike
#

whats the correct way to use getsingleton, I get an error when the singleton does not exist so I have to use HasSingleton but then the variable I cannot initialise it to null

#
PlayerInput bakedbeens = null;
            if (HasSingleton<PlayerInput>())
            {
                bakedbeens = GetSingleton<PlayerInput>();
            }
            else```
#

I cant do that it doesn't work but I need to do something like that, if I use it in that then the variable is out of scope for the job

#
private PlayerInput playInput;
 if (HasSingleton<PlayerInput>())
        {
            playInput = GetSingleton<PlayerInput>();
           Debug.Log("The input value is " + playInput.moveInput);
        }
        else
        {
            return;
        }```
#

that seems to work in Onupdate

coarse turtle
#

You could try RequireSingletonForUpdate<T>() so the system only updates when you have said singleton - keep in mind that if you have another entity query - and you use RequireForUpdate(entityQuery) they're not combined as the rule for the system to update

pliant pike
#

oh yeah I forgot about that thanks, I might change it anyway instead of constantly getting singleton see if I can use an event type system

gusty comet
#

Is it possible to check if a singleton (ComponentData) exists? GetSingleton and GetSingletonEntity throw exceptions if it does not exist.
Can just build a query and do query.CalculateEntityCount() > 0, but I wanted to know if there was a quicker way

safe lintel
#

like above HasSingleton<MyComponentDataSingleton>()

ebon ember
#

JobHandle myJob = Entities.ForEach((ref LocalToWorld transform, in Voxel voxel)

#

Isn't it supposed to be read only with "in"?

gusty comet
#

@safe lintel ah thanks, didn't notice someone had already asked about that

cerulean wren
#

Hey guys!
Just a quick question... is ComponentSystem etc. usage allowed 'inside' asmdef's?
I mean, I have some code that I would like to put inside non-main dll, but then... the ComponentSystem is not running, even with [AlwaysUpdateSystem].

coarse turtle
#

yes it's allowed - I write component systems in asmdefs

cerulean wren
#

Weeeelp... Then I messed up something, thanks ๐Ÿ˜„

#

Ok, now it's working. Compiler probably got a stroke.

gusty comet
#

Do you guys think there will be a Dictionary/HashMap implementation like Buffers with IBufferElementData?

coarse turtle
#

that would be the unsafe datastructures

#

that's coming no idea when

#

but you would be able to put them into component datas as the only thing stopping native containers from getting into component data structs are the safety checks

gusty comet
#

So you think, they will work on using native containers in components?

coarse turtle
#

yea - that's what I remember reading here from Topher (unity staff) when mentioning fixed lists

gusty comet
#

fixed lists are already useable in componts, arent' they?

coarse turtle
#

yes

gusty comet
#

nice, so i am looking forward to a FixedDictionary ๐Ÿ˜„

coarse turtle
gusty comet
#

thx, going to look into it. Do you use it?

coarse turtle
#

just his unsafe hash set

dull copper
twin raven
#

What does that mean?

craggy orbit
#

if i'm understanding correctly, material properties with DOTS will soon work with the URP

twin raven
#

oh nice, lets gooo! ๐Ÿ˜„

craggy orbit
#

heck yeah ๐ŸŽ‰

zenith wyvern
#

Also I know people have been having a lot of horrible render errors in URP with Hybrid, I imagine this will address that

silver dragon
#

Is it possible to use ProfilerMarker with Burst somehow? I get

Burst error BC1033: Loading a managed string literal is not supported
gusty comet
#

hello guys,
i made massive navmesh zombies by using animation instancing method ... but based on my profiler the update func. of my zombies script take much cpu ...
so, have to used ECS? [convert zombies to ECS] which is hard :
or is it possible to using Unity Jobs with Burst compiler to optimizing just this script?

amber flicker
#

Assuming the navmesh is the part taking the majority of time, afaik there's no way to speed that up using DOTS other than writing your own pathfinding solution (which is doable but depends on if it's something you want/need to tackle).

mint iron
dull copper
#

as for that URP PR, I think it's going to address some of the dots instancing issues but wouldn't expect it to magically fix everything ๐Ÿ™‚

#

it's nice to see they are working on it tho

silver dragon
#

thx @mint iron, i really forgot to add it as a local var to my Lambda Job. At least code runs now, though the result is empty. Have to play around a bit more with the preformance framework...

wary anchor
#
Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <a3d417b16c80486ca3272865b9417295>:0)
Unity.Jobs.IJobExtensions.Schedule[T] (T jobData, Unity.Jobs.JobHandle dependsOn) (at <a3d417b16c80486ca3272865b9417295>:0)
PickupCollisionSystem.OnUpdate (Unity.Jobs.JobHandle inputDependencies) (at Assets/_Prot/Scripts/ECS/Collisions/PickupCollisionSystem.cs:143)
Unity.Entities.JobComponentSystem.InternalUpdate () (at Library/PackageCache/com.unity.entities@0.3.0-preview.4/Unity.Entities/JobComponentSystem.cs:125)```

I'm not doing things in the right order, and I'm not sure what the right order is.

I have a NativeArray<PickupData> which contains info for all Pickups in the current world. Every frame, I'm checking which of those is near the player and constructing a NativeList<PickupData> which is a much more manageable size for calculations and the shader.

When I pick up a PickupData, I'm deleting it by remaking the NativeArray with a length 1 shorter than before and adding all entries except the one that's been identified to be picked up.

After picking up, I get the error above where the NativeContainer has been deallocated (I've made a new one and reallocated it) but apparently this has happened at the wrong time. 

Do I need to jobify the deletion step and make that a dependency of the other jobs so the scheduler knows it has to wait for that deletion/reallocation before trying to access the NativeArray again?
pseudo epoch
#

@wary anchor Maybe use a NativeQueue instead of rebuild a NativeArray would be easier ?

silver dragon
#

or NativeList

#

Can you show some code? Would be easier to find the issue.

wary anchor
#

wouldn't I get the same issue if the length of the array changes when a job is already schedules? I'll give it a try anyway

#

I would show some code but I am currently in the middle of rewriting a section of it so the deletion step is a Job ๐Ÿ˜„

#

Thanks for the suggestions guys!

silver dragon
#

Try to use .Dispose(JobHandle), so it disposes after job is finished (just a guess)

wary anchor
#

Thanks @pseudo epoch and @silver dragon - NativeList works a treat for this with the RemoveAtSwapBack() method
๐Ÿ‘

left oak
#

How do dynamic buffers handle empty indexes, like from RemoveAt?

zenith wyvern
#

Same as a managed list I believe, but it uses memcopy to move everything around so it should be pretty fast even if removing from a low index

#
int elemSize = UnsafeUtility.SizeOf<T>();
byte* basePtr = BufferHeader.GetElementPointer(m_Buffer);

UnsafeUtility.MemMove(basePtr + index * elemSize, basePtr + (index + count) * elemSize, (long)elemSize * (Length - count - index));

m_Buffer->Length -= count;
left oak
#

thank you for the detailed response ๐Ÿ˜„

dull copper
#

new dots tiny and dots runtime packages

vagrant surge
#

anything important?

dull copper
#
## [DOTS Runtime 0.2.0] - 2020-01-21

* Full codegen support for Jobs API```
```md
## [Tiny 0.21.0] - 2020-01-21
* Added Tiny Animation features
* Added volume changes affect audio
* Added pan to audio
## [Tiny Rendering 0.21.0] - 2020-01-21

* Add support for cascade shadow maps (1 csm directional light, fixed to four cascades). Refer to the CascadeShadowmappedLight component for more information.
* Add support for spot light inner angle.
* Fix culling under non-uniform scale when CompositeScale is used
* Update package dependencies```
#

so, additions here and there

zenith wyvern
#

Dang, I was hoping to see the runtime mesh api for Tiny

#

I guess 2D is coming early February, fingers crossed it will come then

safe lintel
#

i dont understand why, but 2020.1a21 is lightyears faster playing in editor than 19.3, my (dots)game's loop seems like 2x the speed(2-3ms vs 4-6)

dull copper
#

same options on both enabled for DOTS?

solar spire
#

was that script debugging toggle in the corner that defaults to being off introduced in 2020 or is it in 2019.3?

safe lintel
#

i looked for it briefly in 19.3 and didnt see it there or in preferences

#

same options but i didnt check the script debugging, lemme see

solar spire
#

Then it could be that script debugging is the difference. There is a setting in the editor preferences in versions that didn't have the nice button, and I think it's been on by default

safe lintel
#

still way faster

low tangle
#

since the new lambdas are code gen'd the query is actually populated before OnCreate

#

so you can do conditional query updates by using that

#

wish there was just a simple .RequireQueryForUpdate() option instead

#

I wouldn't need a OnCreate most of the time since I usually just put a primary and secondary query up there

lusty otter
#

Can I create an entity completely with code and then instantiate a bunch of them?

vagrant surge
#

of course @lusty otter

lusty otter
#

Thanks

#

I'm making a user scriptable game, and all elements are scripted by the user including textures and what not.

#

It doesn't make sense to make a pretty much empty prefab to instantiate, or is that still recommended for some reason?

zenith wyvern
#

Not sure what you mean @lusty otter. If you want to create an existing entity from code you can use EntityManager.Instantiate to create a copy or create from an EntityArchetype

tawdry tree
#
//Something like:
var entity = entityManager.CreateEntity();
entityManager.AddComponent(/* as you want/need */);
//Repeat as necessary, possibly setting component data

//Later:
entityManager.Instantiate(existingPRefabEntity); //clones entity
lusty otter
#

Hmm okay, I'll look into this further, thanks!

opaque ledge
#

do you guys think i should make a entity query for processing singleton data or just get the singleton data and send it to IJob and process them there?

zenith wyvern
#

Hah, I was literally just thinking about this. The problem with running it as a ForEach is it forces you to use parallel-safe containers (or pass them as-read-only, or disable the safety system) inside the job, even though you're only working on a single entity.

#

The problem with doing an Job.WithCode is you no longer have an implicit query, so your system will run all the time.

#

My gut feeling is the latter makes more sense, then you have to explicitly create a query and use RequireForUpdate like June was showing earlier.

#

If anyone has a more sensible/readable way to do this I'd love to hear it

tawdry tree
#

So this operation will not be parallelized? It's just a pure data-in data-out function?
Does it need to be a job? Why? Because that sounds like a good case for simply running it on the system. I suppose you can parallelize it with other things as a job, but you could just do a conditional in a system if you don't need it to run always.

zenith wyvern
#

In my case most of the time I want to make structural changes so I wouldn't want to run it on the main thread since it would force a sync point

#

But that's a good point if you don't need to make structural changes

meager nacelle
#

hmm, that GCHandle trick to run managed code in the job system doesn't seem to work if your manage code also touches a NativeArray

#

any ideas?

#

ping me if you know

lyric spoke
#

Hey everyone! I am setting up DOTs in my existing project, and the following error appears when I enter play mode:

~\Library\PackageCache\com.unity.entities@0.5.1-preview.11\Unity.Entities\Types\TypeManager.cs(431,13): error: Cannot find the field `TypeInfos` required for supporting TypeManager intrinsics in burst at Unity.Entities.TypeManager.GetTypeInfo(int typeIndex)

Any ideas on how to fix this?

opaque ledge
#

hmm, did you update burst ?

lyric spoke
#

Burst is version 1.1.2, I just grabbed Burst, Entities, DOTS Editor, Unity Physics, and made sure they were all up to date.

#

Wait a minute..

#

Why does it say up to date when 1.2.1 is released...

zenith wyvern
#

@lyric spoke Are you using 2019.3.06f?

lyric spoke
#

Yes

zenith wyvern
#

Did you try deleting your library folder?

#

And restarting?

lyric spoke
#

I haven't, going to see if using the actually latest version of Burst fixes this first though

#
Unexpected exception Burst.Options.OptionException: Unexpected arguments: `--is-for-function-pointer --managed-function-pointer=0x000002001B8CE270` at Burst.Compiler.IL.Jit.JitCompilerService.Compile (Burst.Compiler.IL.Jit.JitCompilerService+CompileJob job) [0x0012a] in <3179d4839c86430ca331f2949f40ede5>:0 

Fek

lyric spoke
#

@zenith wyvern That seems to have fixed the issue! Thank you!

Now I just need to figure out why my shader graph incinerated itself...

opaque ledge
#

A question, what is the difference between JobComponentSystem and ComponentSystem classes ? also, when doing job stuff, .Schedule runs the job on worker threads, .Run runs on main thread right ? on what circumstances i should use one over othe ?

fickle sapphire
#

Hello :D

I've updated entities package to 0.5.1 and now World.DefaultGameObjectInjectionWorld is null. Shouldn't Play Mode create one by default? Any suggestion to fix this?

lyric spoke
#

@fickle sapphire Is an error relating to Burst appearing when entering play mode?

fickle sapphire
#

@lyric spoke Yeaph! Here we go:
Library/PackageCache/com.unity.entities@0.5.1-preview.11/Unity.Entities/Types/TypeManager.cs(431,13): error: Cannot find the field TypeInfos required for supporting TypeManager intrinsics in burst
at Unity.Entities.TypeManager.GetTypeInfo(int typeIndex)

pliant pike
#

@opaque ledge JobComponesys is multithreaded and ComponentSystem is single threaded, its mostly supposed to be used settings things up and testing

lyric spoke
#

Alright: Go to the package manager, Burst, Show Versions, and make sure to select 1.2.1. After that installs, exit Unity, delete the Library folder in your project's folder, and once that completes, relaunch Unity.

#

That should fix it

#

Just fixed that not even an hour ago XD

dull copper
#

you need to be on 2019.3 to run latest DOTS

#

oh this wasn't scrolled down

fickle sapphire
#

@lyric spoke you're a lifesaver. That did the trick ๐ŸŽ‰๐Ÿค˜

lyric spoke
#

๐Ÿ‘

zenith wyvern
#

Just make sure to always put [AlwaysSynchronizeSystem] and return default if your JobComponentSystem will only be running on the main thread

opaque ledge
#

ah okay, thank you, i thought component system always run on main thread so i was using it to read input manager and move my player

zenith wyvern
#

It does, but JobComponentSystem will as well if you do all your ForEach with .Run instead of .Schedule. Check out the offical pong tutorial for a good example https://www.youtube.com/watch?v=a9AUXNFBWt4

In this workshop style video we walk through an example project created by Unity Evangelist Mike Geig on how to script a Pong style game using Unity's Data Oriented Tech Stack (DOTS) including the Entity Component System (ECS). This video covers the latest syntax in Unity 201...

โ–ถ Play video
opaque ledge
#

ForEach is equal to job structs right ? or do you mean ForEach lambda ?

pliant pike
#

I wasnt aware of that, I'm a bit behind on the updates it changes so fast, thanks Sark

zenith wyvern
#

I'm talking about the ForEach construct where you pass in a lambda. Watch the video, he explains clearly how and why you run code on the main thread inside JobComponentSystem

lyric spoke
#

What is the proper way to handle things like cameras in DOTs?

I have a system that I want to use to move the player, but the player has the camera attached to them. It deletes the camera when the entity is created.

pliant pike
#

I'm guessing you want the camera to move with the player, the best way is to just update its position with the player

#

I did it with a Componentsystem but now I'm trying to figure out how to do it with a JobComponentsystem

#

you could just pass the camera straight into the Entities.foreach in a ComponentSystem but I'm curious how you pass it into a job ๐Ÿค”

pliant pike
#

I've tried and I'm thinking its probably best not to try doing it with a job at all

left oak
#

yeah, i'll pass the transforms components of my camera entity so i can manipulate it in space, but i've not tried manipulating the camera component within a job

pliant pike
#

I just get an error that says have to use run() and withoutburst() for objects passed by reference

#

and even when I do I just get tons of errors, so doesn't work and even if it did without Burst it wouldn't be any faster than just running in Onupdate I'm guessing

left oak
#

are you using an entity conversion of the camera, or just references to the gameobject?

pliant pike
#

I couldn't convert the camera to an entity

left oak
#

yeah, but you can still get Translation, Rotation, and LocalToWorld from a conversion

#

which, if all you

#

need is to move the camera

pliant pike
#

I just ended up with a black screen for the camera

left oak
#

I think you need to keep the gameobject of the camera

#

you can't convert and destroy

#

and you need a CopyTransformToGameObject... I think

#

this all might've changed

safe lintel
#

just add convert&inject to the camera, it should preserve it

pliant pike
#

ok I'll try them thanks

pliant pike
#

I've been away from dots for so long I'm basically having to learn it all over again now ๐Ÿ˜•

karmic pilot
#

that might happen again with every major iteration step for DOTS :>

pliant pike
#

basic question but is there a way of assigning a instantiated entity in a job to a local public variable in jobcompsys?

left oak
#

well, you certainly can't do it from the command buffer within the job you instantiated it from

low tangle
#

Just query for it

#

But storing a entity like that seems like code smell

pliant pike
#

yeah I know I'm just going to need it always its a player character

#

I've created them in onstartrunning

low tangle
#

Right, but why not just query and get it

pliant pike
#

I'd have to query it in update and wouldn't that be a bit of unnecessary overhead?

low tangle
#

Not really

#

It's a n of 1

#

I've got networking systems where I go and grab my 1000 players at the start of the systems update

#

It's not even noticable in performance

#

You should design systems to go and get the minimum data they need with minimal indirection

pliant pike
#

and that's just constantly running?

low tangle
#

Yes

pliant pike
#

oh cool

#

I just need to make sure I only create one then

low tangle
#

My whole update loop for entities and monobehaviors is about 1.5ms total

#

Rest is rendering and nothing else

pliant pike
#
if (EntityManager.Exists(GetSingletonEntity<PlayerTag>())) return;```
#

is that a good way?

low tangle
#

That works, or you can create the query and . CalculateEntityCount() == 1

pliant pike
#

oh yeah, thanks

zenith wyvern
#

If you create an explicit query then your system already wont run unless the player exists right?

low tangle
#

No

#

By default a system will run when any of it's queries have more than one

zenith wyvern
#

Oh right, but you could pass the query to RequireForUpdate to override other ones

low tangle
#

Correct

zenith wyvern
#

Guess it depends if your system only depends on the player though

low tangle
#

This is why you want to keep your systems small and single responsibility

pliant pike
#

Entityquery works with component tags right?

low tangle
#

ComponentType.ReadOnly<T>()

#

.Exclude

pliant pike
#

actually thinking about it I should probably just use Getsingleton()

low tangle
#

Singleton's can only have one component on them

pliant pike
#

I just need the entity currently

low tangle
#

Then that will work

pliant pike
#

I always forget you have to first check their is singleton, doh!

ocean tundra
#

Hi all. How do you build a project with the latest DOTS packages?

#

I'm trying to build for Windows (Mono or il2cpp) and getting the following error:
IL2CPP error for type 'Unity.Properties.CodeGeneratedPropertyBagRegistry.System_ObjectPropertyBag' in assembly 'C:\Projects\SpaceShips\Temp\StagingArea\Data\Managed\Assembly-CSharp.dll'
Additional information: Invalid method 'System.Void Unity.Properties.PropertyBag`1<System.Object>::Accept(TContainer&,TVisitor&,Unity.Properties.ChangeTracker&)' found in vtable for 'Unity.Properties.CodeGeneratedPropertyBagRegistry.System_ObjectPropertyBag'

#

I'm just using File > build settings but I've seen talk about platform.**** packages, do I need one of those?

pliant pike
#

ok strike that above csharp if (EntityManager.Exists(GetSingletonEntity<PlayerTag>())) return; it does not work, you have to use HasSingleton<>()

left oak
#

why wouldn't you just always have a PlayerTag and just GetSingletonEntity<PlayerTag>()?

#

Atleast, if you're going the singleton route anyway

#

bong rip

pliant pike
#

yeah I did

zenith marsh
#

Hello guys, I am currently experimenting with Unity DOTS and I realized recently that my burst compiler seems to be only active the 2nd time I launch my jobs after going into playmode. I am using Unity Mathematics simple noise function in one of my job and the execution of this job takes about 15s when I launch it for the first time but then only 1.5s the next times. Did anyone had similar issue or know how to solve this ? I'm currently using Unity 2019.3f6 and the latest version of DOTS packages

left oak
#

Set CompileSynchronously to true to make sure that the method will not be compiled asynchronously

#

In general, you should use asynchronous compilation.

zenith marsh
#

I think that's exactly what I am looking for, thank you very much I will try that!

low tangle
#

yeah, one of the dots guys said on the forum they will fix up synchronous compile times

#

they are sequential instead of being done in jobs like the async ones

#

option #3

#

but it will slow startup time until they get that update done

zenith marsh
#

Thanks for the info but adding the burst attribute "did the job" for me since only one of my job was really a problem

low tangle
#

yeah for your case since it was just one

#

my game runs like shit for like a full minute if I dont run sync on everything

#

devs are working on it though

zenith marsh
#

I see I will probably get to this point later haha