#archived-dots

1 messages ยท Page 105 of 1

zenith wyvern
#

There's no easy answer to your question, you need to understand how to write basic queries and systems first

opaque ledge
#

i already know how to do basic queries and systems, i already have a system that updates markets to reflect their current price(depending on supply and demand), its a simple and lovely system ๐Ÿ˜„

#

but i couldnt solve the problem i am having

zenith wyvern
#

but i just couldnt do double query
@opaque ledge
What do you mean by a "double query"?

opaque ledge
#

i feel like i should do double query somehow

coarse turtle
#

2 queries and unionize them? I assume that's what you mean

opaque ledge
#

so what i tried to do is.. every market would hold comparrision information against other markets, so if market1 sells for 1, market2 buys for 5, market1 would hold value of 4(since its a positive transaction since trader is buying cheap and selling high) etc.. so i tried to get all the markets.. then i tried to get all the markets again, so i would compare market1 to market2 market3 and then market2 to market1, market3 etc., after this system is done traderoute chooser system would take a look at this info and find the highest value and send the trade ship.

#

so... i dont know how to do a query inside a job struct

#

and i dont even know if my way of thinking is correct

zenith wyvern
#

You can't run a job from another job. It's an inherent rule of the safety system. If you need information in a second job from a first one, you need to gather it in one job and pass it forward to the next.

opaque ledge
#

yeah i actually tried that before i gave up, i wanted to get all those markets from job 1 and put into nativelist and send it to job 2 and actually do the calculation there

#

but it felt like i was doing it in a wrong way because it felt like it was complex

zenith wyvern
#

If you feel like one system or job is doing too much, you can try to break up your data into smaller pieces that each get processed by their own systems

#

And Unity will do a nice job of handling the implied dependencies between that data

opaque ledge
#

so 1 query per job then ?

zenith wyvern
#

I mean you don't really have a choice but yes that makes sense to me

#

Maybe someone with more experience writing larger more complicated systems can provide some better insight

opaque ledge
#

i think you are right ๐Ÿ˜„

#

i probably will be working on it tomorrow morning

#

its.. kinda ugly code but hey if it works it works ๐Ÿ˜„

vagrant surge
#

@trail burrow the whole dirty bit thing is 1 bit per entire property

#

including things like structs

#

then the actual Delta system unreal has does its thing

#

thing is, unreal has a huge bottleneck on checking deltas, as it does so every update

#

typical unreal network update goes something like this

#

for each connection (player)
find objects relevant to that connection
filter by check rate
go through ALL objects, and their subobjects, and compare with the last snapshot
build deltas
prioritize
send

#

the go through all objects part is super slow

#

for reference, doing that in PUBG takes a few miliseconds per player

#

and we have 100 players at start of the match

#

the N^2 problem is real

#

pubg (and fortnite, but fortnite does it better) does some trickery for that. For example pubg will only update 10 other characters per character at each tick check

#

and the fun part, is that well designed ue4 codebase is much slower than bad codebase. A codebase with a God Class in Character (player) that has a huge fuckton of properties is significantly faster than a codebase with split concerns and stuff in components

low tangle
#

@coarse turtle you probably know this already, but its not worth it to make a custom engine no matter how much you think you are doing from scratch in unity. its trival to throw together a engine with ecs, jobs, physics, rendering etc but its another to take that and write all the editor tools, all little interactions between the librarys to make things work, setting up a proper build pipeline, cross platform?

#

in the case with unity dots, you can always fall back onto anything from monobehaviour world to get around something that isn't done in dots yet. like animations and fast rendering

coarse turtle
#

Yep

low tangle
#

totally get it though. I'd just love for dots only version of unity with source code

#

I'd love to just finish up whats missing good enough for my game and rock on

#

instead of dealing with a million broken projects they are working on (HDRP and URP disgust me)

coarse turtle
#

Well end of the day - the stuff we end up building on top of dots isn't much of a pain for us

low tangle
#

thats true

#

its so pleasant to work with once you get it

#

you just query things in your ongui and loop though them displaying the data, it ends up being faster than you might think

coarse turtle
#

like I get the conversion system is a bit janky for ppl here, but it fit our needs which was quite nice

low tangle
#

I've used it in my new projects but I can't use it in my main due to project requirements

#

I just use a custom manual hybrid setup

coarse turtle
#

ah - and we were debating on using imgui but since we really just work on this on our free time, one of my teammates didn't want to learn how to stylize in imgui - so it was better to stick with uGUI

low tangle
#

I've got a debug UI I'm thinking about releasing here / fourms soon thats basically just a runtime clone of the entity debugger

#

has most data and it even works in il2cpp from testing

zenith wyvern
#

I think the biggest issue with the conversion pipeline is at first they seemed to be leaning towards working naturally with entities in the editor

#

Then they just completely shifted to conversion system instead which...doesn't seem like anyone wanted

low tangle
#

theres some things I need to rework before release but it already is super helpful for tracking down the bugs where it only happens in a build

#

I really want to rework the UI layout of it first and cut down on the number of active elements, but thats all easy to do once I set aside time for it

safe lintel
#

considering what happens to skinned characters, hierarchical relationships with physics, i kinda get why a dots editor wasnt the right way to go for now

zenith wyvern
#

Yeah I guess it makes sense to keep everything completely separate for now while they're still changing the higher level stuff so much

#

Bummer that it causes so much more work for the users though.

coarse turtle
#

btw @low tangle what is your game, wondering if there's a store front page to look at ๐Ÿ‘€

low tangle
#

I'm hesitant to link it because I got review bombed hard by some tolls from another game

coarse turtle
#

ah - sorry to hear - no worries

low tangle
#

just sucks a few kids can ruin a game so hard

#

even with evidence from their discord planning it, valve still didnt care

#

prepping a big update that should help though

zenith wyvern
#

It's a bummer that steam is so easy for people to abuse. I like that epic store is giving creators more control over that stuff. Or will be

#

Right now they don't even allow reviews

low tangle
#

honestly thats better lol

zenith wyvern
#

I agree

low tangle
#

I mean the guys even went to every single social platform it was being posted on about, twitter, youtube etc and shilled the other game while talking trash

#

so its not exactly the primary selling platform reviews that can be the issue

zenith wyvern
#

Well you said you're working on a social VR game, then I can imagine where the review bomb may have come from and yeah...that community is something else.

low tangle
#

yep

#

I dont talk trash though, just produce results

zenith wyvern
#

Fair

odd ridge
#

in a JobComponentSystem, what's the difference between using the [ReadOnly] attribute abose a member variable versus using the readonly keyword in front of a member variable?

zenith wyvern
#

The [ReadOnly] attribute is only needed for job structs, not needed for the new ForEach constructs. As far as I know the keyword has no special meaning in ECS

odd ridge
#

@zenith wyvern how do I handle input in ECS?

zenith wyvern
#

You read it on the main thread and either respond to it immediately or translate it into ECS components to be read by systems.

odd ridge
#

@zenith wyvern I'm trying to create an array of keystates and pass this array to the job struct, but I get error "cannot be of reference type". how do you give an array to the job?

gusty comet
#

If I modify component data in a native array created by ToComponentDataArray

#

will the updated data be used by the entity?

#

or do I need to associate the updated data with the entity ?

zenith wyvern
#

You need to assign it back. But you can do ToEntityArray and I believe both arrays are aligned the way you expect

gusty comet
#

great!, thank you @zenith wyvern

vale nymph
#

If I put the IConvertGameObjectToEntity interface on my gameobject in a subscene do I need another method to call the Convert method? At the moment it never gets called during runtime

silver dragon
#

Maybe you also need ConvertToEntity?

vale nymph
#

I tried putting that on the gameobject and it 'Convert' it to an Entity but it still doesn't go through the Convert method in the class

silver dragon
#

Hm, it should do that. Are ConvertToEntity and IConvertGameObjectToEntity on the same gameobject?

vale nymph
#

Yes they are

silver dragon
#

Have you rebuilt the entity cache?

crystal zephyr
#

If you have it in the subscene it is not supposed to get called on runtime, isn't it? It will be converted when the subscene is created in the entity cache. On runtime the already converted stuff should get loaded of the entity cache.

silver dragon
#

Right, during runtime this isn't called as there are no more gameobjects...

vale nymph
#

Didn't the Rebuild Entity Cache button get removed since a few months? I've been unable to find

silver dragon
#

I don't use subscenes currently, don't know. They were so much pain i kicked them all...

#

Does anyone know hot to make CollisionWorld readonly in a Entity.ForEach? With entities 0.5 .WithReadOnly() doesn't work anymore because CollisionWorld doesn't have [NativeContainer] set.

crystal zephyr
#

Are subscenes or better its data now be able to be in an asset bundle and will it work on android to load them?

mystic mountain
#

@silver dragon I think you use ReadOnly on PhysicsWorld?

silver dragon
#

I tried PhysicsWorld and CollisionWorld and both can't be used with .WithReadOnly in 0.5

fair condor
#

When using the new Build Settings Scriptable object, (which is required to use subscenes) and I hit build, I get:

Build ClassicBuildSettings failed after 0ms.
Build step BuildStepApplyPlayerSettings is missing required component 'ClassicScriptingSettings'.

Does anyone know what that means?

#

Happens in the "Apply Player Settings" build step

silver dragon
#

Started a new forums thread about my physics issue. I feel i miss something important...

mystic mountain
#

@silver dragon try post your code

silver dragon
#

Solved (see thread) ๐Ÿ™‚

gusty comet
#

i am not able to install Entity from package manager,its stuck in installing

#

how to fix it ?

#

using Unity 2019.3.0f5

#

Win 10 Pro

mystic mountain
#

Anyone know why I get this error while trying to add to DynamicBuffer<LinkedEntityGroup>?

#

Use in normal componentSystem with
Entities.WithNone<SpaceshipFinishedSpawningTag>().ForEach((Entity entity, ref SpaceShipData spaceShipData, DynamicBuffer<LinkedEntityGroup> linkedEntityGroup) =>

mystic mountain
#

Seems like it gets invalidated when you add or instantiate other entities, so "EntityManager.GetBuffer<LinkedEntityGroup>(entity).Add(visual);" worked fine at the spots I needed it.

gusty comet
#

Hello, still learning. I've written a system that prints a debug message to the console every frame. After adding the second code block, it only prints once and ceases. What am I doing wrong? Thanks

[UpdateInGroup(typeof(ServerSimulationSystemGroup))]
public class GridGeneratorSystem : ComponentSystem
{
    protected override void OnUpdate()
    {
        UnityEngine.Debug.Log("alive");
    }
 }
Entities.ForEach((Entity ent, ref GridTile tile) =>
        {

        });
opaque ledge
#

Perhaps remove UpdateInGroup attribute ?

gusty comet
#

now it runs twice

tawdry tree
#

Tip: Adding 'csharp' or 'cs' just after the triple backticks,a dn then immediately adding a linebreak gives you code highlighting for C#
Where is the second block located? Does it wrap the debug message?
In that case, do you have any entities with GridTiles? Are you sure?
Have you tried using debug breakpoints? Have you checked the entity debugger to ensure you have them?

gusty comet
#

give me a few minutes and I'll let you know, thank you

#

GridTile didn't exist after all

zenith wyvern
#

@gusty comet A system only updates when the things its querying for exist

opaque ledge
#

I got a weird issue with getting a singleton from a job system.
My job system:

        NativeArray<Entity> markets1 = new NativeArray<Entity>(100, Allocator.TempJob);

        var firstJob = new FirstJobStruct()
        {
            entities = markets1
        }.Schedule(this, inputDependencies);

        var localbuffer = GetBufferFromEntity<LocalMarketComparissionBuffer>()[GetSingletonEntity<KanwisSingleton>()];

        var marketbuffermanager = GetBufferFromEntity<MarketDataBuffer>(true);

        var secondJob = new SecondJobStruct()
        {
            buffer = localbuffer.AsNativeArray(),
            entities = markets1,
            marketDataBuffer = marketbuffermanager
        }.Schedule(this, firstJob);


        // Now that the job is set up, schedule it to be run. 
        return secondJob;
    }

At first system is taking 0.2 ms but after 5-10 mins it becomes 1 ms and this is what debugger shows me:
http://prntscr.com/qrvwtq

Lightshot

Captured with Lightshot

#

So it... 'allocates' that entity and doesnt 'release' it i think

#

that KanwisSingleton spawns every frame on the debugger

#

This is the first time i am dealing with a singleton so i am not sure whats going on

opaque ledge
safe lintel
#

@opaque ledge i think its an issue with the latest entities package

#

it happens with the physics system too, 0.4 doesnt have that issue so im personally not upgrading yet. this is assuming your entities package is 0.5

mystic mountain
#

@opaque ledge How's the entity list, do you have multiple entities of that type or?

opaque ledge
#

@mystic mountain yeah, i needed to get a list of markets(which implements faction tag component and market buffer component), which thats what first job does, at second job i do the same thing but this time i get market component from that entity list also, so basically i am comparing markets to each other and save that to LocalMarketComparissionBuffer component inside singleton entity

#

@safe lintel yeah i am 0.5

mystic mountain
#

What I was refering to was in the entity debugger, if you could see that it is creating new entities of that singleton type

opaque ledge
#

oh no, it doesnt create any entities

mystic mountain
#

The "localbuffer.AsNativeArray()" has to be disposed, are you disposing it? *

opaque ledge
#

no i am not

#

hm, let me check

mystic mountain
#

If you're not, try enable Full Stack Traces for LeakDetection

opaque ledge
#

it doesnt give me any error about it tho

#

with full stack traces enabled

#

i think, when you do AsNativeArray it disposes itself later on

zenith wyvern
#

AsNativeArray just lets you work with the DynamicBuffer as if it was a NativeArray. You wouldn't want to dispose it since you probably don't want to dispose the underlying buffer.

#

You can think of it as if you were casting the dynamic buffer to a nativearray

opaque ledge
#

also as a side note, when you create a buffer element data, you should initialize every spot, otherwise when you do AsNativeArray, operation on that array wont be able to access that specific index, lets say i have 10 capacity on my buffer element data, 5 of them initialized, when you do AsNativeArray and want do set index 6 thru that array it wont allow you.

#

I thought it would work like native container allocation but it doesnt ๐Ÿ˜„

slow epoch
#

Anybody knows how Jobs actually handle that you can't use any fields from a Job before it's completed?

low tangle
#

leaks show up as warnings instead of errors @opaque ledge

opaque ledge
#

no warnings either ๐Ÿ˜„

mystic mountain
#

Guess I'll go back to using EntityQueries x)

#

Weird, it seem queries has worse performance than Singletons.

opaque ledge
#

yeah, looks like its a 0.5 version issue

#

should i create temp or tempjob native array in a job struct ๐Ÿค”

zenith wyvern
#

If it's not going to exist outside the job it should be Temp

#

And don't call dispose on it, it will be disposed automatically

opaque ledge
#

oh ? does that happen when its in job struct or all Allocate.Temp disposed auto ?

zenith wyvern
#

It works anywhere. It will automatically be disposed when it leaves it's current scope

opaque ledge
#

oh good, i didnt know that, thanks

low tangle
#

singletons are just a query that asserts there only being one and returns the first componentdata from Query.ToComponentDataArray(temp)[0]

#

@mystic mountain

#

you can check the source for them in the entities package

gusty comet
#

Anyone knows how to get the jobindex in a ICollisionEventsJob to fill the needs for EntityCommandBuffer.Current

verbal pewter
#

Hey all, I'm trying to create a helper class that will take an Entity and return it as a container with all the different elements that make up that Entity (components/DynamicBuffers). These helper methods would be called from within systems. What I'm trying to figure out is how I can obtain a DynamicBuffer from within this helper class. Outside of systems you're supposed to get the default world's EntityManager, and within a system you're supposed to use EntityCommandBuffers. Am I correct in assuming I need to get the default world's EntityManager within the helper, even though it's being called from within a system?

low tangle
#

entitymanager is always where you get data from the world outside of a system in that world

verbal pewter
#

Alright, thanks!

warped trail
#

@gusty comet try just CommandBuffer without .ToConcurent()

gusty comet
#

i thought in jobs i need to use .ToConcurrent()

#

but i will try it out, thx!

warped trail
#

it works, but i don't know is it ok to do this or not๐Ÿค”

safe lintel
#

@gusty comet both the trigger and collision events are not yet parallel jobs

#

.Concurrent only necessary if its an IJobFor or variation of it. as its just IJob then you use the non concurrent version of the entitycommandbuffer ๐Ÿ™‚

gusty comet
#

@safe lintel i did not know that! helps alot thanks

opaque ledge
#

is there any difference between Capacity and Length properties of a native container ?

verbal pewter
#

Capacity is how many elements it can store total. Length is how many elements it's storing.

autumn sleet
#

@gusty comet [NativeSetThreadIndex]

#

On top of a field in a job

gusty comet
#

@autumn sleet so with NativeSetThreadIndex above an int property, i can use the concurrent Commandbuffer, too?

autumn sleet
#

Yes

#

This sets a thread index for the job

#

the same as jobindex

mystic mountain
#

@low tangle Hmm, it's werid that with singleton it was round 0.95ms and with manual query.ToComponentDataArray it was around 1.3-1.5ms

low tangle
#

looks like it does a mem cpy from the root of the chunk

#

makes sense because it enforces a single componendata in the archtype iirc

#

I dont use singleton too often so I dont remember all the gotchas with it

#

ln 794

#

@mystic mountain

mystic mountain
#

Hmm ok

low tangle
#

that skips a copy and a native array alloc

opaque ledge
#

Hmm, GenerateAuthoringComponent doesnt seem to work on IBufferElementDatas

#

that sucks ๐Ÿ˜ฆ

gusty comet
#

@autumn sleet thats nice, thanks for the hint!

autumn sleet
#

@gusty comet no problem

odd ridge
#

I have a JobComponentSystem that I want to have access to my GameManager object, so from inside OnCreate() of my job system, I call GameObject.Find("GameManager"), but it returns null because OnCreate() is called before my GameManager object is created, how do I make it that OnCreate() is called after rather than before the object is created?

opaque ledge
#

i never tried that but have you check the Script Execution Order ? @odd ridge

#

if you make your script before default time, maybe that can help

low tangle
#

that wont work

#

system creation is after bootstrap but still before scene load

#

I suggest either a init function so you can assign it then to the system, or simply do a null check in the systems update and find it then if it is null

#
OnUpdate()
if(mgr==null) { 
mgr = Find("name"); 
return;
}
#

etc

opaque ledge
#

Hmm, so GetSingleton from system causes system to run even tho my query returns 0, but i need the singleton so i can feed it to my job struct ๐Ÿค”

#

is there a trick for this or i should just accept it and take the performance hit ?

coarse turtle
#

uh if you want an unsafe route - i haven't profiled this yet:

unsafe struct FetchSomeSingleton : IJobChunk {
  [ReadOnly]
  public ArchetypeChunkComponentType<U> SomeType;

  [NativeDisableUnsafePtrRestriction] 
  public T* YourSingletonData;

  public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) {
    var data = chunk.GetNativeArray<SomeType>();
    *YourSingletonData = data[0];
  }
}

ofc - you should replace T with a defined type.
@opaque ledge

opaque ledge
#

thats a scary looking code ๐Ÿ‘€ ๐Ÿ˜„

coarse turtle
#

So you would pass the pointer through jobs

#

Otherwise you could try using OnStartRunning()

#

to fetch said singleton

#

ofc checks are necessary - especially if you have 2 of them - or if your data changes in the singleton

#

Hmm possibly another way @opaque ledge is (needs profiling to see much of an impact this has)


// In a JobComponentSystem
var data = someEntityQuery.ToComponentDataArray<YourSingletonData>(out var singletonDeps);

var lastDeps = new SomeJobForEach {
  SingletonArrayData = data
}.Schedule(this, JobHandle.CombineDeps(singletonDeps, inputDeps));
pliant pike
#

isnt ToComponentDataArray a job in itself so that would be a lot of overhead

coarse turtle
#

Yea - i just don't know much of an impact it has since I never tested it

#

since I dont use much singleton data - I typically just use GetSingleton<T>() ยฏ_(ใƒ„)_/ยฏ

pliant pike
#

yeah that seems the simplest way, theres always going to be a bit of overhead because you have to sometimes check if it exists

left oak
#

on a JCS Entites.ForEach, do I have to specify WithBurst?

coarse turtle
#

If you want BurstCompilation yes

on a separate note I wonder how much impact CompleteDependency() has in GetSingleton<T> ๐Ÿค”

left oak
#

silly that they also include WithoutBurst then

pliant pike
#

well you cant debug with burst

coarse turtle
#

Hmm - anyone have recommended readings on assembly and simd? I'd love to learn a bit more ๐Ÿ™‚
Edit - I might take a look at some processor manuals as a starter ๐Ÿค”

left oak
#

but if it's not burst unless you specify WithBurst, what's the difference?

pliant pike
#

with burst is faster

zenith wyvern
#

In JCS ForEach will run with burst unless you specify WithoutBurst

#

WithBurst let's you specify some specific options

#

@odd ridge I feel like there's no nice way to do this right now. In the SceneManager class there are callbacks for when a scene is done loading so you can find your game object there. Or you can Inject your GameObject and use GetSingleton in OnStartRunning

#

Either way kinda sucks. If you can get away with making your manager a scriptableobject it's a bit nicer

#

By Inject I mean use ConvertAndInject on ConvertToEntity

odd ridge
#

@zenith wyvern thanks

#

@zenith wyvern OnStartRunning() was exactly what I needed instead of OnCreate(), I just didn't find the documentation for JobComponentSystem

#

now I did by reverse looking what you told me

dull copper
#

is there any docs about the new build system anywhere?

#

like, how does one do automated builds with it (how to run it from commandline)

#

it's kinda relevant now that you can't even build recent DOTS with the old build setup

dull copper
#

as a side note, IL2CPP is broken on 2020.1 again with DOTS

#

just tried a new project done from scratch on 2019.3 with dots + hybrid + unity physics and it built just fine

#

same project upgraded to 2020.1 fails on it

#

mono builds still work

#

it's nothing new tho, IL2CPP keeps breaking all the time :/

safe lintel
#

you can call the build command from the asset

        var buildSettings = Resources.Load<BuildSettings>("BuildSettings/Win64-Build");
        Assert.IsNotNull(Resources.Load<BuildSettings>("BuildSettings/Win64-Build"));
        buildSettings.Build();

its been a while since I did a build from command line but i assume it should work inside a static script

dull copper
#

should yes, I'll try that, thanks

dull copper
#

it does work if I let it open the editor window while it's building, it doesn't do anything with batchmode enabled

safe lintel
#

ah yet another thing to investigate ๐Ÿ˜„

dull copper
#

there isn't anything obvious on the editor.log for this either

pseudo epoch
#

i'm trying to setup ecs system in editor with the DefaultWorldInitialization.DefaultLazyEditModeInitialize() which give me a world but adding system don't work when i add system on the editor world any idee ?

twin raven
#

Do I remember it right that drawing gizmos is now possible from jobs?

#

Or debugdraw ๐Ÿค” ?

amber flicker
#

PSA if working with subscenes, removing colliders from gameobjects takes the import process down from 30s to nearly instant. Not sure if this is a consequence of not having dots physics installed. Edit: looks like that's not true.. possibly a combo of that with older subscene content. Unsure.

opaque ledge
#

So i want to create entities in my job component structs, but i cant send Mesh and Material to job struct so i cannot set RenderMesh mesh and material and therefore it wont be rendered, any suggestions on how to go on about this ?

twin raven
#

Are latest entities packages compatible with 2020.1 alpha?

hollow scroll
#

@opaque ledge maybe you can create entities in a job, and then do a Entities.ForEach(...).WithoutBurst().Run() to set the components if you need references to those things

#

after the previous job completes... just an idea, maybe there is a better way

opaque ledge
#

I am trying to do with prefab, lets see how it will go ๐Ÿ˜„

dull copper
#

@twin raven some things work, but I'm getting random issues myself

#

like, for example the moment I can't make IL2CPP builds work on 2020.1, they still work on 2019.3 with dots

next glen
#

@twin raven yes, with fewer issues than 2019.3 (in my limited experience)

#

Seems more stable, unexpectedly

dull copper
next glen
#

In 2019.3.0f5, DOTS didn't work at all

dull copper
#

so I'm guessing Unity Physics authoring hasn't been updated to the fast play mode enter

next glen
#

What version?

dull copper
#

@next glen 2018?

next glen
#

Typo 2019*

dull copper
#

and the error I showed happens on both 2019.3.0f5 and 2020.1.0a20

#

it's just issue with the domain reload, or more of lack of it

#

I bet it's a trivial fix

#

also why is dots not working on 2019.3?

#

it does work here

next glen
#

It works on 2019.3.0f4. Just not f5

dull copper
#

any example what's broken?

next glen
#

After adding a [GenerateAuthoringComponent] component and pressing play, it's a silent crash. There is a bug report for it, but it isn't getting a lot of attention. So it didn't seem widespread

#

Upgrading to 2020 fixes it 100%. Tried a bunch of solutions within 2019, but all failed

dull copper
#

hmmm, the line that gives me errors has this comment before it on authoring script: cs // This requires Entity Conversion mode to be 'Convert And Inject Game Object'

#

if I move the physics step script out of dots subscene and manually change it to that mode, playmode without domain reload works without errors

#

I do lose the DOTS Editor's entity conversion preview for that component by doing that tho

#

hmmmm, it's lack of scene reload that breaks it, not domain reload

eager jungle
#

Hello everyone, I've been doing OOP for 15 years, and I'm starting with dots a few days ago (you can imagine what my brain is undergoing ;)) , and I have so many unanswered questions in mind, but right now, there is one in particular that one of you may be able to help with: when a system (in my case a camera controller system) depends on different set of entities (different archetypes - in my case a camera and a player - which would be the camera target), what is the proper / efficient way to find the player entity components i need (Translation, but we can imagine it to be something else) for my camera system to work?

#

And a more general question: where to find "software architecture with dots/ecs" examples / tutorials / or other resources, in order to quickly think "ECS"? I'm not really interested in how to do things with unity, but more of the general process of designing stuff using ECS pattern

next glen
#

Welcome to the wonderful world of ECS! You don't "find" things. They find you

If you want to run a system on a specific entity, give that entity an empty component, which acts as a tag

Does that answer the question?

eager jungle
#

I get that, but does that mean my camera system should first query for the components i need on the player entity, pick the data i need, then query my camera components after that, and update them using the data from player? I know this is very basic question, but I'm really trying to not go in a completely wrong path ๐Ÿ˜‰

opaque ledge
eager jungle
#

thanks @opaque ledge

next glen
#

Camera system will never query anything. One of ECS's major features/pains is it's super modularity

Your system will just act on a bunch of components. A system is only logic. It doesn't know what an entity is

#

I'm sorry, I've gotta get to work. Can't write up a better explanation at the moment

#

Enjoy ECS though! It's a lot of fun. A great challenge

eager jungle
#

Thanks, my brain needs to process that. Not sure to get it, if anyone else can help, that's be greatly appreciated ๐Ÿ˜‰

amber flicker
#

I guess what does your 'camera system' want to do? Rotate towards a target? Well that could be a RotateTowardsTarget system that just requires a target and rotation tag etc.. so what you start of thinking as a specific task can quickly become very generic.

mystic mountain
#

What is your "Camera system" supposed to do?

amber flicker
#

Then there's the other aspect of it which is dealing with traditional unity monobehaviours and associating them with entities and/or tagging them with components

eager jungle
#

@amber flicker this is exactly that "I guess what does your 'camera system' want to do? Rotate towards a target? Well that could be a RotateTowardsTarget system that just requires a target and rotation tag". I absolutely understand that, and the data oriented aspect of it. I'm just asking what is the best way in my system to find the player / or register the player in some way, in order to rotate towards the proper entity

#

In my mind, the camera system is what makes the camera rotate, so it would run of camera related components

#

this here is a good example of what i want to do @32:00 : https://www.youtube.com/watch?v=BNMrevfB6Q0&t=2093s
but he's using a hack to get the player position. What would be the ecs way to do it ?

In this video, learn about what's involved in migrating existing game code to the new Data-Oriented Technology Stack (DOTS), which comprises the C# Job System, the Entity Component System (ECS), and the Burst Compiler. You'll also gain an understanding of the performance bene...

โ–ถ Play video
safe lintel
#

For my own camera system the camera entity is just a child of the player entity, so by way of the hierarchy, the camera follows the player. But another way would be adding say a PlayerTag component to the player, and in the camerasystem query the tag and look up its translation/rotation etc

eager jungle
#

so you'd do two queries in a row, 1 (readonly) for finding player translation, and 1 for updating camera component?

amber flicker
#

One bit of knowledge you may have not picked up (not sure if it's mentioned in the vid) is that you can use a ComponentDataFromEntity (CDFE) to access components related to any other entity. So, if your camera system knows the players entity, you can look up that players translation using e.g. (very psuedo code) allTranslations = ComponentDataFromEntity<Translation>(), allTranslations[playerEntity]

#

so if its the camera you want to rotate (still not sure what camera specific things this system is doing but anyway...), you could require e.g. <Rotation, CameraTag, CameraTarget> where public struct CameraTarget : IComponentData{ public Entity Value; } - then yup, you'll need to set the target somehow - potentially using another system. There are many ways to achieve a similar thing though.

eager jungle
#

i get it

#

how would you deal with a target entity that may change over time?

#

is it this other target setter system looking every frame for a target change?

#

is it a lot more costly to query the target entity from an archetype every frame in the camera system?

amber flicker
#

So much of this depends on your implementation I'm trying to be helpful in a general way.. which may not be very helpful. Feel free to share code here. If your camera system can only ever focus on one player at a time, it may be worth setting the target of a CameraTarget singleton or something. Common patterns for as things change is either to have a special tag in the archetype or filter a job on change of archetype. I guess you might already know but let's say you have 1000 entities with archetype [a,b,c] (let's say c is a tag like NewEntity), you can have a system that requires NewEntity then have another system that runs at the end of the frame that changes archetype [a,b,c] to [a,b] - this is incredibly cheap because it changes the entry for the archetype rather than changing each of the individual entities - so consequently this is a kind of an efficient event pattern where a system would e.g. only run once, when the entity was created

safe lintel
#

How do you want your target to change?

#

Or how do you envision it changing?

eager jungle
#

thanks @amber flicker , still processing that

#

@safe lintel , hmm adding or removing a component or tag for example

gusty comet
#

@zenith wyvern I still can't contribute much back to the group, but I found that entityQuery.CopyFromComponentDataArray can be used to sync changes made on a entityQuery.ToComponentDataArray array back to the entities.

#

Hopefully this helps somebody out there

zenith wyvern
#

Oh cool, I had no idea that existed

#

Thanks!

warped trail
gusty comet
#

Oh nice! Thank you @warped trail !

safe lintel
#

Well I guess another system to ensure say a CameraTarget is a unique entity would make sense in the context of this. You can split up this logic as much or as little as you want, using a query shouldn't have a bearing on perf, just remember to create your query in OnCreate and cache it.

eager jungle
#

understood

zenith wyvern
#

If your system is specifically concerned with when a component changes you can also use the ChangedFilters so it will only run when there's a change

eager jungle
#

thanks for that @zenith wyvern , guys, I'll try to put all of that new knowledge to practice ๐Ÿ˜‰

warped trail
#

you can make TargetableComponent and place it on every object which can be a target and HasFolower component on targets that already has something that following it. Then if that 'something' wants to change a target you can query everything that has TargetableComponent but don't have HasFolower component๐Ÿ‘

eager jungle
#

oh yea i get that, that could be useful sometime later

#

thanks

odd ridge
#

what is a ComponentDataProxy?

coarse turtle
#

ComponentDataProxy were the old way of "linking" entities to gameObjects - they're effectively replaced via the conversion pipeline

#

ConvertToEntity

odd ridge
#

can I still use ComponentDataProxy? is it going to be removed?

coarse turtle
#

You can still use it - just not recommended and I've no idea when it will be removed. The alternative is: ConvertToEntity w/ ConvertAndInject

odd ridge
#

what is the difference between ConvertToEntity and IConvertGameObjectToEntity ?

#

oh

coarse turtle
#

IConvertGameObjectToEntity is part of the ConversionPipeline - if you want to add some custom logic like spawning an entity paired with the gameObject that will be converted, you can do so there

#

ConvertToEntity is responsible for starting the process of converting the gameObject hierarchy into its entities format and subsequently allowing IConvertGameObjectToEntity to run in the ConversionWorld

clever depot
#

How do you all feel about unity deciding to focus on their MonoBehavior->Entity workflow opposed to focusing on core standalone ECS?

coarse turtle
#

Ppl have their opinions here - for me personally it fits my needs - since the authoring is a traditional workflow so I don't have to change much

safe lintel
#

standalone ecs wouldnt have rendering beyond tiny's capability or anything so, quite alright..

clever depot
#

@safe lintel I think the hybrid rendering is its own standalone module

pliant pike
#

yeah its the only way it could work really, otherwise everyone would be forced to use ECS

odd ridge
#

why do some components have [Serializable] tag but some others don't?

#

how do I tell what needs to have [Serializable]?

coarse turtle
#

[Serializable] attributes allow you to tell the .net backend that you want to be able to object contents into a file

zenith wyvern
#

Serializable has nothing to do with dots, it's gameobject related and the same rules it's always been forever

coarse turtle
#

in the context of unity - you can display regular object parameters/fields in the inspector

zenith wyvern
#

Plenty of material on google to learn about it if you're curious

odd ridge
#

I heard hybrid ECS is not as fast as pure ECS, anytime I use the conversion pipeline, it's not pure anymore?

#

or is related to using the hybrid renderer?

safe lintel
#

conversion != hybrid
conversion is literally converting data from one thing to another, can be hybrid or pure
hybrid implies using regular unityengine stuff, so any pure equivalent will most likely be faster.

coarse turtle
#

Reliance on MonoBehaviour components would fall into a "hybrid" style of ECS - especially if you need them active in your systems - e.g. like if you needed the animator

#

and you use a system to set animator params

warped trail
#

Tiny is the perfect example of pure ECS๐Ÿค”

#

it uses GLFW and BGFX under the hood

eager jungle
#

hey, anybody knows why environment lighting isn't working after my gameobject is converted to an entity?

warped trail
#

try turn off SRP batcher

#

if you are using URP

eager jungle
#

i am, let me try

#

thumbs up, thanks ๐Ÿ˜‰

#

is this a know bug, or just expected behaviour?

safe lintel
#

known bug, also setting stuff to static causes issues

eager jungle
#

thanks , amazing feedback, super appreciated ๐Ÿ˜‰

warped trail
#

i wonder if next "big improvement" in hybrid renderer will be HDRP only?

safe lintel
#

i think its supposed to be improvement for rendering nonstatic entities

low tangle
#

non subscene static entites

#

because right now they are always in the dynamic group

safe lintel
#

im dying for some package updates

coarse turtle
dull copper
#
## [Burst 1.2.1] - 2020-01-23

### Fixed
- Fix issue with function pointers being corrupted after a domain reload that could lead to unexpected function pointer calls.
- Fix potential deadlock between Burst and the Asset Database if burst is being used when building the database.
- Fix `AssemblyResolveException` when loading a project with dependent packages that are using Burst in static initializers or `InitializeOnLoad`.

### Known Issues
- The fix for the deadlock requires to temporarily disable the ability to click on a compilation error in the Unity Editor to jump to the source IDE.
south timber
#

Anyone here ever serialized a WheelFrictionCurve in the inspector? Or am I asking in the wrong thread?

dull copper
#

that doesn't sound like DOTS/ECS discussion

idle glen
#

Has anyone seen a more up to date guide to Unit Testing DOTS systems? All the versions I have found so far date back a year and enough has changed that tutorial doesn't work

tawdry tree
#

Are you familiar with unit testing in general?

#

Because the concepts (that differ from normal unit tests) are still the same - make a world, add the systems you want to test, add enough entities with the correct components, run one frame, then check the result.
Depending on how your code is set up you might also straight up test jobs' Execute method as well, which can be done as you would any other unit test in Unity, though I'd recommend using the 'Unity way' for keeping things tidy, unless you plan to do 'normal' unit tests as well.

opaque ledge
#

Improving everyday ๐Ÿ’ช

verbal pewter
#

@opaque ledge Grats ๐Ÿ˜„ That moment when you see things actually moving on screen is always so nice.

opaque ledge
#

ikr ๐Ÿ˜„

next glen
#

Does DOTS currently support 2D physics?

tawdry tree
#

There is no built-in 2D physics module(AFAIK), but if you put a restraint on the depth axis you get a similar result

low tangle
#

yeah that or just make the physics yourself

#

or import box2d

#

or use gameobject dummys with old 2d components

autumn sleet
#

@low tangle box2d?

coarse turtle
dull copper
#

I dunno what good that would do

#

I guess if one could port that to DOTS

#

Unity already uses box2d under hood for 2D physics

#

also afaik, Unity is working on 2D physics engine for DOTS but no idea where it's at or if their focus has changed

#

they technically need it for tiny

low tangle
#

Yep

#

Just pull in box 2d and make your physics entities match, then just have a system that does a sync of their transforms in, run the simulation steps, sync back.

#

Super easy with systems

#

It's exactly what they do with havok if you think about it

#

You have full control so it's much easier to do things like this and have them fully integrated with the rest of the world

#

This is also how physx and unity 2d physics work

dull copper
#

someone did that for bullet and some quite early unity ecs version

#

I upgraded it for some newer ECS when I tried it

twin raven
#

I did this with chipmunk2d

dull copper
#

is there some magic way to search for specific things on profilers timeline?

#

there's easy searchbox for hierarchy views

#

but now with DOTS jobs all over the timeline, it's really tedious to find small jobs there now

#

not to mention jobs getting spread to all 23 worker threads on 3900x :/

low tangle
#

man I wish I had that many

dull copper
#

it really makes the whole timeline view pain :/

#

I can only imagine how this is on new threadrippers

low tangle
#

damn

#

what about one of the unreleased rome 64s

dull copper
#

would be nice if you could force unity to limit the worker threads for debugging purposes

low tangle
#

you can actually set the job thread count somewhere

#

was talked about in here way back when

dull copper
#

hmmmm

low tangle
#

I dont know if it will actually do what you want but its close

#

let me see if I can find it

dull copper
#

I know fholm wanted it at some point

#

but that was quite long time ago

low tangle
#

bam

#

dunno if its set able. it doesnt say property or not

dull copper
#

yeah,wondering the same

#

I'd assume it's just a getter

low tangle
#

I'll take a look since I had visual studio open behind the movie I was watching

dull copper
#
public const int MaxJobThreadCount = 128;```
#

ah, you found the same thing

low tangle
low tangle
dull copper
#

You can set the value of this property at runtime to dynamically reduce the number worker threads available to the Unity Job Queue.

low tangle
#

worth a shot

dull copper
#

yup, I'll give it a go

#

thanks ๐Ÿ™‚

low tangle
#

np, let me know how it goes. I'd be interested in the results

dull copper
#

well, it does limit the ACTIVE worker threads ๐Ÿ˜„

#

but it doesn't like limit it to the first available ones

#

wonder what logic it uses to pick the workers there

#

it just picks a random worker and sticks to it

#

it does stay same unless I restart editor

#

imagine it's just coincidence it placed those three worker threads so that they could fit into same view at once on these cases

#

@low tangle ^

#

worst part is that I can't see the main thread timeline at all when scrolled that much down

low tangle
#

intresting

#

what happens when you do 1

dull copper
#

setting cpu affinity from task manager didn't change anything either as I think Unity really just detects the hw thread count from cpu anyway

low tangle
#

true true

dull copper
#

it's same with job count of 1, it just places that one worker thread then randomly somewhere

#

when I tried it first, it happened to go to first worker which would have been ideal

#

on next startup, it put it on worker 19

low tangle
#

would be good to report

dull copper
#

yeah I guess

low tangle
#

would be nice for the editor to place it at the top

dull copper
#

at least we can now scroll this down again

low tangle
#

thread on the forum

dull copper
#

profilers vertical scroll was broken for a long time

low tangle
#

ah

#

mm click usually worked for me

#

that or f for frame up

dull copper
#

they only fixed it on some recent 2019.3

#

yeah, I could make a forum thread about this

#

I still wonder if there's some way to find specific jobs on this timeline view tho

#

I've never really had issues finding things from this view prior to DOTS

low tangle
#

iirc hierarchy view links it up with the block view

#

so try clicking it there, then switch and hit f

dull copper
#

hmmm, I don't think it links it back to timeline

#

but I might just fail on using this ๐Ÿ˜„

#

I have like simplest job here where I just try to see what happens with debug draws

#

it does let me do the debug draws on it (using 2020.1)

#

it's also unbelievable how laggy Unity Editor is on startup nowadays. I dunno if it's because of dots or just in general

#

it takes like 10 seconds for me to become responsive after it opens

#

once it's revived itself, it's fine

#

I wonder if it's some burst related delay when running unity physics etc

#

and I don't mean entering playmode, just getting the editor usable

low tangle
#

ah

autumn sleet
#

Is there any way to have synchronization of Editor changes with Convert and Inject workflow? Current workaround is to have Proxy with GameObjectEntity that will allow do changes in Play mode and have them serialized with ECS.

gusty comet
#

is there a way to continue with the next cycle of a Entities.ForEach()? Like "continue" in normal for loops?

karmic pilot
#

just return from your lambda, then it will execute the next one

opaque ledge
#

Do you guys think i should make a faction components to each factions like FactionAComponent, FactionBComponent etc. or should i put int field to faction component and make ID from there, like 0 means faction A, 1 means faction B etc..

karmic pilot
#

depends on how you want to filter and/or use them later on. if in doubt, use both and measure the performance with large amounts of entities

gusty comet
#

@karmic pilot that easy, thanks

opaque ledge
#

So umm, my trade ships doesnt render anymore, everything else is working such as movement but it.. doesnt render, i have no idea why

#

i will just close and re open the unity, maybe it will work ๐Ÿ˜„

#

nope, it didnt work ๐Ÿ˜ฆ

#

sigh now i have to deal with this ๐Ÿ˜’

viral kindle
#

Ok, so ECS is still in questionable state by the looks of it :P

tawdry tree
#

Depends on what you're trying to accomplish, and how you do it (built-in? Custom? Porting/coupling external library?)

surreal grail
#

heyo! is there a way to use interfaces in Burst? when I try it gives this error: "Unable to find interface method ECS_Test.MeshJob.IVoxelType.init() from type object" I'm trying to call methods from an array or a list based on an ID

#

I guess the interface is somewhat an object so that's why I can't do it that way, but is there an other way to achieve something similar?

tawdry tree
#

Burst does some compilation magic, so I wouldn't be surprised if it simply doesn't support interface

#

What is the intefrace on? Job? Component? System?

surreal grail
#

it's a struct that has the IVoxelType interface

tawdry tree
#

Huh, but it seems to think there's an object involved

#

Wait no, bad sleepy brain, I mixed up object and class

surreal grail
#

this is all I have, it's just an empty method to test if it even works: ``` interface IVoxelType
{
void init();
}

    public struct AirVoxel : IVoxelType
    {
        public void init()
        {

        }
    }```
zenith wyvern
#

when I try it gives this error: "Unable to find interface method ECS_Test.MeshJob.IVoxelType.init() from type object"
@surreal grail
Post the code that's giving you this error

tawdry tree
#

The technical issue aside, that's not very good DOD, I believe

#

At least if that has anything to do with entities and their components. If it's outside that, then... I dunno.

surreal grail
#

it has nothing to do with entities, but it is BurstCompiled so it is in DOTS ๐Ÿ˜„

tawdry tree
#

Data oriented

surreal grail
#

@zenith wyvern it's just this IVoxelType air_vox = new AirVoxel(); air_vox.init();

#

thats in a job that compiles otherwise

tawdry tree
#

I don't undertsand the best practice well enough to say anything conclusive, so if some DOD folks could weight in and point at best practice, that'd be nice

zenith wyvern
#

Try AirVoxel air_vox = new AirVoxel()

#

You can't use any kind of polymorphism in Burst

surreal grail
#

yea, thats what I was trying to achieve

#

I thought that it was only inheritance that was not usable

dull copper
#

I have really basic question here , if I wanted to create additional entities on same conversion script I thought could just use dstManager.CreateEntity() for the extra ones. when the script runs, it doesn't give errors but the additional entities don't show up on the entity debugger either.. any idea what's going on with this?

surreal grail
#

so then, is there a way to get pointers to methods? ๐Ÿ˜„

#

cause I can put those in a list ๐Ÿ™‚

tawdry tree
#

@dull copper Are you doing basic CreateEntity? It seems more coreect to me to make one, then use that as a template/archtype for more

dull copper
#

it's super basic

#

I create entity, add component to it, setname for it so I can ID it quicly

#

I have system using the component it has, so it's not like it should be inactive either

zenith wyvern
#

There is conversionSystem.CreateAdditionalEntity but tbh I'm not entirely sure how it's supposed to be used

dull copper
#

wonder if this is breaking due to some dots editor glitch or because I use 2020.1 atm

#

that's meant for converting additional gameobjects I think

amber flicker
#

@dull copper you have to use CreateAddd... ah.. Sark beat me to it.. esp if you want to support subscene workflow, that's what you need to use

dull copper
#

yeah, I'm on subscene

#

but don't you need extra GO for that then?

surreal grail
#

Sark, yeah I've seen this FunctionPointer but it will cause me lots of pain without any examples, oh well guess I have experimenting to do

amber flicker
#

I think you can just pass the original GO

dull copper
#

ah, I'll try

#

I did come across that when trying to figure it out on my own but there's barely any mention on how these should be used ๐Ÿ˜„

amber flicker
#

tell me about it... caused (causing actually) massive pita for me

zenith wyvern
#

There's no getting around it, if you want to do polymorphism or anything polymorphism-like in Burst you need to jump through some hoops. I've messed with FunctionPointer a little but gave up on it when I found out you can't pass any structs into a FunctionPointer

dull copper
#

oh wow, it does work

#

thanks guys ๐Ÿ™‚

amber flicker
#

wooo ๐Ÿ‘

dull copper
#

var childEntity = conversionSystem.CreateAdditionalEntity(this);

#

I then added that as ref to my main entity

#

all good now

surreal grail
#

@zenith wyvern okay, thanks for the info, I think I'll try to return float3s and stuff, that would be enough for me, I don't really need to return anything more complex

#

one more craaaazy thing, does this sound possible? : new assetbundles that are loaded in would register their own function pointers into a NativeList that is used by a BurstJob so people could make mod-like assets for a game?

zenith wyvern
#

I think the FunctionPointers need to be set up at compile-time

surreal grail
#

yeah, that's what I'm afraid of

zenith wyvern
#

If you really want to get wild you should check out the source for the physics package, they mimic polymorphism for the different physics shapes. If I remember right they use temporary blob assets to store the polymorphic data until it needs to be used

surreal grail
#

oh that sounds exciting and complicated, might look into that, thank you again! ๐Ÿ™‚

left oak
#

anybody else get allocation warnings the FIRST time you press play in a scene after editor startup? No warnings on subsequent plays...

#

I am entering playmode with reaload domain disabled

opaque ledge
#

Its amazing, when i pull prefab to subscene it renders, but when i instantiate from a job, everything but rendering works

#

๐Ÿ˜ญ

#

Okay well, apperantly i had to do:
DOTS->Live Link Mode->SceneView: Live Game State

gusty comet
#

this is kinda silly, but I didn't know that math.normalize can return NaN

#

I hope that this helps somebody out there

#

I was doing this a lot:

#
            var isNan = math.isnan(nForce);
            if (!isNan.x && !isNan.y && !isNan.z)
            {
                force += nForce;
            }```
dull copper
#

You cant really normalize 0

#

So nan is correct

gusty comet
#

yeah

#

close to 0 also normalizes to NaN

#

So, is there a better way than checking for NaN ?

worldly pulsar
#

normalizesafe? ๐Ÿ™‚

gusty comet
#

yayyy

#

haha, I was trying safeNormalize() ๐Ÿ™„

dull copper
#

ah, I thought you used that already ๐Ÿ˜„

#

did some comment get removed above?

dull copper
#

so... of course now that I create entities on code, I will not get that nice entity conversion preview for the additional entities anymore

#

I wish we really had that DOTS editor

#

like editor that actually just showed the ECS world, let people pick the objects from it, examine the component values...

low tangle
#

working on some GUI for that but theres a few missing things in the entity debug api

safe lintel
#

@dull copper you sure? i see them on mine, could use a little more readability though

opaque ledge
#

@safe lintel whats that ๐Ÿ‘€

#

now that i think about it, i actually have ecs editor ui package but i only have entity debugger

#

does ecs editor ui package give anything besides entity debugger ?

low tangle
#

thats the conversion workflow showing on the source gameobjects

opaque ledge
#

huh, i dont think i ever saw that

safe lintel
#

yeah but three additional spring entities on the camera are just from code

#

@opaque ledge this only shows up for subscene entities afaik

opaque ledge
#

is that inspector or some other editor window ?

safe lintel
#

its the inspector

#

if you drag the "Entity Conversion" bar up, it might be sorta hidden

opaque ledge
#

ah, i dont have it ๐Ÿ˜ฆ component datas are just laid out vertically for me

#

including for subscene entities

safe lintel
#

what does it look like?

dull copper
#

@safe lintel I'll check, I have bad experience on clicking that part of the preview as it tends to get click underneath it ๐Ÿ˜„

#

like, it keeps giving tooltips of the inspector values that would be under it

#

like.. not bugged at all ๐Ÿ˜„

#

but yeah, it's early

#

@safe lintel ah I have to click the dropdown arrow

#

yeah, I see all things now, this will help a lot

#

thanks again ๐Ÿ™‚

#

oh, you can convert that to floating window too

#

much better now that I could dock it elsewhere

safe lintel
#

ah nice didnt know about the floating window

dull copper
#

so much nicer when don't need to resize and reposition it

#

I need to figure new editor layout for this now

safe lintel
#

so many hidden little things, docs team is gonna be put to work when this all gets finalised(heh)

dull copper
#

I used to stack hierarchy and properties on same side one over another

#

but with this thing in addition, it's just super crowded

low tangle
#

ooooh

#

they did add the floating window?

dull copper
#

it's possibly been there always ๐Ÿ˜„

low tangle
#

I asked for exactly that. thank you who ever did add that

dull copper
low tangle
#

it was from one of those closed tests

dull copper
#

ah if it was prior to first public version, then that would make sense

low tangle
#

yeah

viral kindle
#

but with this thing in addition, it's just super crowded
@dull copper // Just buy another monitor

dull copper
#

I have three :p

#

but I prefer to keep editor mostly contained on single window, usually only have game view out or if I do shader graphs, I have that on another

#

I keep one monitor for VS and one for browser/discord etc

safe lintel
#

upgrade them all to those ultrawides ๐Ÿ˜‰

dull copper
#

๐Ÿ˜„

viral kindle
#

Buy 4th one

dull copper
#

I have 4th one on the floor

safe lintel
#

make a 360 degree setup so you just swivel your chair ๐Ÿ˜„

dull copper
#

there's no space on the desk

#

I guess could put one on top

low tangle
dull copper
#

ha

#

I do have 130" on the projector but that would be really horrible to work with

low tangle
#

yeah home project tech has lagged hard

dull copper
#

anyway, can fit all in the editor, just need to rethink of the nice placing for all this

viral kindle
#

Why fit where you can just go VR?

dull copper
#

oh wait.... if I undock the entity conversion preview... it does it only for that conversion

#

it doesn't keep updating it for other selections

#

this must be a bug

#

as it makes no sense, especially since there can only be one floating window for this

viral kindle
#

Actually, that would be fun to try working in VR ๐Ÿค”

dull copper
#

unity had EditorXR project

#

but it's not officially supported even I think

viral kindle
#

No, I mean just mirroring windows and tricking it into thinking it has more monitors

dull copper
#

I could see lack of resolution becoming a real issue there

#

maybe better in the future

viral kindle
#

Would it be noticable with virtual screen being close?

#

You don't need to worry about monitors being in certain position, you will be able to move them

willow creek
#

hey, I'm working on a Native quadtree for points and just finished the range query, in case anyone wants to check it out: https://github.com/marijnz/NativeQuadtree/tree/master.
Insertion / construction is very fast, about .7 ms for the given test with 20k elements. Queries should be fast too but need better benchmarks for them.

tawdry tree
#

My experience with VR says you need pretty high-res screens for a PC desktop to be legible. My Vive is 1080ร—1200 per eye, And I have to lean in or stand really close to the desktop when using steamVR's 'see your desktop' feature.
Unfortunately I haven't had the chance to try some newer, higher-res HMDs. From what I've heard the Vive Pro and Valve Index's 1440x1600 per eye makes a pretty clear difference, though. Relevant thread:
https://www.reddit.com/r/ValveIndex/comments/dsl31z/index_vs_original_vive_resolution_from_tyriel_wood/
That's all a bit off topic, though, but I'm playing with the a few potential VR experiences/games, and I would likely try to use DOTS for them, because VR is hard enough on your computer as is. On the other hand, if DOTS means I don't get graphics optimizations (batching and such), then it's right out.

stiff urchin
#

When your DOTS code crashes unity. ๐Ÿ˜ต

#
System.InvalidOperationException: HashMap is full
Thrown from job: Unity.Transforms.ParentSystem.GatherChangedParents
#

Maybe turning off burst might catch the issue.

#

Even without burst it crashes pretty hard same error. I'm pretty sure I only have 1 parent component on the entity..

#

Perhaps because of the command buffer something funky is going on:

commandBuffer.RemoveComponent<Parent>(index, selectionEntity);
commandBuffer.AddComponent(index, selectionEntity, new Parent() { Value = entity });
low tangle
#

HashMap is full

#

your nativehashmap needs to be resized

low tangle
#

updated my visual studio 2017/2019 snippets for the new for each and added newjob which was missing

#

new foreach is RunFor

#

old is still ForEachEntity

remote coyote
#

@willow creek thanks for sharing!

twin raven
#

That is really cool @willow creek ๐Ÿ˜ป I am gonna give a it a try replacing my really primitive spatial hash map

willow creek
#

Cheers guys, it's still WIP so be careful when using it..

opaque ledge
#

So, when doing Entities.ForEach lambda you can use WithAll, WithAny and WithNone, but how can you do that in a job struct ?

dull copper
#

quote from burst 1.2.1 forum post: We hope to release the first preview of 1.3 in the coming days. Stay tuned!

#

and this was posted earlier about 1.3:
We are also eager to share as soon as possible the next 1.3.0 preview that is almost ready and which is going to bring several improvements: support for cross compilation, cache of generated code between editor restarts, new LLVM version, improved codegen with no-alias analysis, new x86 Intrinsics API for advanced SIMD scenariosโ€ฆ and more.
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.
This is also allowing Burst to completely remove the dependency from Visual Studio SDK C++ installs or from Linux build tooling. But note that certain platforms (e.g Consoles, iOS) are requiring Burst to use their platform SDK to generate an executable. So the cross-platform compilation is mainly for desktop platforms.

#

of course plans change but looking forward in seeing how much of this actually made into first 1.3 preview

#

not requiring VS c++ toolchain will make new installs simpler at least ๐Ÿ™‚

silver dragon
#

I hope there will be a new entities release soon which fixes those annoying singleton issues....

#

@opaque ledge There are [ExcludeComponent] and [RequireComponent] attributes. Though i don't remember their correct names right now...

opaque ledge
#

ooooh i see, thanks i will check it out

twin raven
#

Was cross platform deterministic floating point setting supposed to come in the first half of 2020?

dire frigate
#

Would this mean that we can finally compile to linux with 1,3? ๐Ÿ˜…

stiff urchin
#

Is there a way to keep an entity from rendering without removing the mesh component?

amber flicker
#

Haven't tried but adding the Disabled ICD might do it

#

scratch that.. that will stop it working in other systems too

mystic mountain
#

Anyone else bumped into problem of subscenes and prefabs? Seems when I update prefab that is also in subscene it won't get updated.

wary anchor
#

Quick sanity check on NativeList<> - the capacity is the amount of memory initially to earmark for the list, rather than the initial Length of the list, isn't it?

dull copper
#

@twin raven that was supposed to come a long time ago already

#

wouldn't hold my breath anymore

#

2022 then maybe? ๐Ÿ˜„

opaque ledge
#

maybe you can add "FrozenRenderSceneTag" ?

#

altenative to that maybe you can also remove LocalToWorld component if you dont use it

stiff urchin
#

It looks like FrozenRenderSceneTag works good.

#

thanks! ๐Ÿ™‚

#

Now I need to figure out how to do OR queries..

#

I think EntityQueryDesc with any will work..

pseudo epoch
#

Hey what are current restrictions for ecs and android ?? I've seen some post here about float precision, and i'd like to know if there are others know restrictions, i use android build for VR

willow creek
#

@wary anchor correct

opaque ledge
#

is doing GetBufferFromEntity and/or GetComponentDataFromEntity within a job expensive operation ? i generally store entity in my component data and use those functions to get what component data/buffer i need, but i am not sure if i should avoid it or not

coarse turtle
#

doesn't seem to take a big perf hit- but I didn't stress test it extensively. I use it if I need to recurse and grab data off the children which can happen to be in separate chunks

#

I think there was a forum post by tertle where he looked at the perf of ComponentDataFromEntity/BufferFromEntity

opaque ledge
#

thanks, i will take a look

low tangle
#

Basicly if you need random access, just do it

opaque ledge
#

So... how is everyone bridging between ECS and Monobehaviours ?

zenith wyvern
#

That's what ConvertAndInject is for on ConvertToEntity

#

Gives you full query access to your monobehaviour

wary anchor
#

@willow creek thank you!

low tangle
#

AddComponentObject on select entitys with managing of their lifetime with a SystemState and a lookup dictionary in a cleanup system @opaque ledge

left oak
#

I can't seem to resize a buffer that's a ref parameter in my JCS Entities.ForEach... How does one do that?

low tangle
#

.WithStructuralChanges()

#

and you might need to get the dynamic buffer though EntityManager instead of as a ref

zenith wyvern
#

You shouldn't need WithStructuralChanges. Show the code where you're trying to resize it. @left oak

left oak
#

I got it working. It seems like you can't access a dynamic buffer's methods when it's an Entities.ForEach parameter, so I just used a Job.WithCode and grabbed the buffer with entity manager first

zenith wyvern
#
        inputDeps = Entities.ForEach((ref DynamicBuffer<ABuffer> buffer) =>
        {
            buffer.ResizeUninitialized(10);
#

Works fine

left oak
#

huh, the first time i tried i got nothing

#

must've made some bizarre syntax error

#

my bad

low tangle
#

all good

#

for some reason I was thinking you were adding the dynamic buffer then resizing it

#

which is a structure change. my bad

gusty comet
#

If I've split up my code into many components and now need to access 8 components in Entities.ForEach (I would do chunk iteration, but netcode is giving me problems), how do I approach that?

safe lintel
#

i havent touched netcode but there is a problem with it and chunk iteration?

opaque ledge
#

@gusty comet if you are using tag components you can add RequireComponent attribute to your job struct

#

but since you said Entities.ForEach, you make a query in component system so you can use WithAll, WithNone, or WithAny methods

#

so Entities.WithAll<MyTagComponenet>().ForEach()

radiant sentinel
#

hello, how can i request new feature? for example InnerLoop at IJobForEach

low tangle
#

forms, but make sure you structure your request post well

gusty comet
#

hello guys,
does ECS just for optimizing scripts execution on CPU or can be used for GPU massive instanced of gameobjects rendering?

radiant sentinel
#

@gusty comet Currently CPU but you have structured data that can be pass to GPU.

gusty comet
#

so, ECS is just best method to making massive Navmesh Crowds?? and not for simple massive trees?

radiant sentinel
#

@low tangle ๐Ÿ˜„ its so hard, i forget that.

#

@gusty comet ECS is Data-oriented programming architecture pattern! you should think about any think that you want to implement. i dont know about unity Supported Components ๐Ÿ˜„

gusty comet
#

and where is Entities package on 2019.3.0f5?

radiant sentinel
#

i don't know, I'm using last preview. other friends should help you.

opaque ledge
#

@gusty comet from package manager, you have to tick "show Preview Packages" in advanced tab

#

and after that you also need to install Hybrid Renderer package

#

then probably restart unity ๐Ÿ˜„

gusty comet
#

@opaque ledge
nothing :[

opaque ledge
#

umm, did you check the show preview packages ?

#

you also need to check "All Packages"

#

in same row with advanced tab

vale nymph
#

So in the Unity DotsSample I am trying to add a new object the player could spawn with a button. The object has it's own Ghost Authoring component and everything. In Editor this works. It spawns the correct prefab at the correct location. However when I try to replicate this in a client build the object gets the default location of 0,0,0 and it's scale is also reset back to 1,1,1.
Anyone with knowledge of the sample that could tell me if I am missing a step in the build process?

opaque ledge
#

Anyone knows what "EndFrameParentSystem" does ? whenever i instantiate something from commandbuffer.Instantiate it jumps to 800 ms

mint iron
#

@opaque ledge it looks like it maintains a parenting hierarchy for transforms; and does work when Child associations need to be added/removed from an entity. see: Unity.Transforms/ParentSystem.cs

silver dragon
#

2019.3 is now out according to their latest blog post. Seems to be 2019.3.0f6 (still listed as pre-release in hub). Hopefully some dots packages will be updated shortly, too ๐Ÿ™‚

civic bay
#

How can I set up a system for my entities to raycast if they're going to hit a GameObject

#

Just need help setting up the most basic raycast system

velvet oxide
#

Like a bullet passthrough?

#
{
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var physWorld = World.DefaultGameObjectInjectionWorld.GetExistingSystem<BuildPhysicsWorld>();
        var colWorld = physWorld.PhysicsWorld.CollisionWorld;

        var job = Entities.ForEach((Entity entity, ref RayDetect ray, ref Destroyable des, in Translation trans) =>
        {

            if (ray.didHit)
            {
                ray.didHit = false;
            }

            RaycastInput rayInput = new RaycastInput
            {
                Start = ray.lastPos,
                End = trans.Value,
                Filter = new CollisionFilter
                {
                    BelongsTo = ray.belongsTo.Value,
                    CollidesWith = ray.collidesWith.Value,
                    GroupIndex = 0,
                }
            };

            Unity.Physics.RaycastHit hit = new Unity.Physics.RaycastHit();

            if (colWorld.CastRay(rayInput, out hit))
            {
                ray.lastHit = hit;
                ray.didHit = true;
            }

            ray.lastPos = trans.Value;
        })
            .Schedule(inputDependencies);

        job.Complete();

        return job;
    }
}```
#
public struct RayDetect : IComponentData
{
    public PhysicsCategoryTags belongsTo;
    public PhysicsCategoryTags collidesWith;

    [HideInInspector] public float3 lastPos;
    [HideInInspector] public Unity.Physics.RaycastHit lastHit;
    [HideInInspector] public bool didHit;

}```
#

I realize I have a Destroyable component in there that is not needed. I was just using it for testing before

civic bay
#

Not to pass through, I have a bunch of entities that rain down from the sky

#

No physics, just moving at random speeds

#

But I want to raycast to see if it's going to hit the floor, so I can tell it to stop moving down once it reaches the floor

#

The floor is a flat plane at y:0

velvet oxide
#

@civic bay yeah so you would set the move speed in a separate component and have the spawner setcomponentdata on each spawn so the move speed is different

civic bay
#

Yeah I got that already

velvet oxide
#

kk you can then attach this raydetect to see if it passes through a certain physics collider...you can add onto this for added funtionality after the hit occurs or you can make another component that compliments this one

civic bay
#

Thanks I'll try and implement it now ๐Ÿ™‚

#

@velvet oxide How are you creating the Entities.ForEach job here var job = Entities.ForEach((Entity entity

#

Am I missing a namespace?

#

I've included Unity.Entities

#

"Entities" doesn't exist in current context

velvet oxide
#
using Unity.Entities;
using Unity.Jobs;
using Unity.Transforms;
using Unity.Physics;
using Unity.Physics.Systems;```
civic bay
#

Yeah I got all those

#

Hmm

velvet oxide
#

another way to find out what your missing if you are using visual studio is cntrl-period when clicking on the red and it will suggest what you need

civic bay
#

Do you know what version of Entities you're using?

velvet oxide
#

I always update to the latest

civic bay
#

I can't access Entities.ForEach in JobComponentSystem

#

I can in ComponentSystem

velvet oxide
#

yeah the new way of using the job component system is different now

#

try updating your entity package?

civic bay
#

I'm apparently up to date with 0.1.1 but isn't it on 0.2 now?

#

I'm using Unity 2019.2.11f1 so might need to upgrade the engine

velvet oxide
#

yeah i'de only use dots with the newest beta of unity imo

#

so you can test out the visual scripting and whatnot

zenith wyvern
#

0.1 is very old, 0.5 is the latest

karmic pilot
#

u need 2019.3.+ for latest entities

civic bay
#

Ah

#

Thanks

#

I'll get that now

safe lintel
#

Use 0.4 there are issues with 0.5 and singletons

frosty siren
#

if i need push readonly CDFE to lambda job how i will mark it readonly?

zenith wyvern
#

Entities.WithReadOnly(cdfe).ForEach

#

Where cdfe is a local variable

frosty siren
#

ok, thx, will try

#

and if i have more than 1 RO data i will write Entities.WithReadOnly(...).WithReadOnly(...) ?

zenith wyvern
#

I believe so yes

frosty siren
#

I donโ€™t notice the documentation or is it just the effect of the fact that I started to learn lambda jobs too late and life is pain?

zenith wyvern
frosty siren
#

yes i didn't notice. Thank you

#

this is what i looked for
int entityInQueryIndex โ€” the index of the entity in the list of all entities selected by the query. Use the entity index value when you have a native array that you need to fill with a unique value for each entity. You can use the entityInQueryIndex as the index in that array. The entityInQueryIndex should also be used as the jobIndex for adding commands to a concurrent EntityCommandBuffer.

velvet oxide
#

Is there a way to GetComponentData from a specific entity without using the entity manager? I am trying to make a spawn system burstable using the spawn position as an entity transform.

#

I know @worldly pulsar posted GetComponentDataFromEntity<Thing>(); but how do you use this to get a stored entity?

opaque ledge
#

what do you mean get 'stored' entity ?

#

you mean get 'stored' entity's data ?

velvet oxide
#

example: ```void SpawnProjectile(Entity entity, quaternion rot, ref Shoot shoot)
{
var spawn = EntityManager.Instantiate(shoot.projectilePrefab);
//set position and rotation
var local = EntityManager.GetComponentData<LocalToWorld>(shoot.spawnPosition);
EntityManager.SetComponentData(spawn, new Rotation { Value = rot });
EntityManager.SetComponentData(spawn, new Translation { Value = local.Position });

    //set shot data
    EntityManager.SetComponentData(spawn, new Move
    {
        moveSpeed = shoot.projectileSpeed,
        MoveInput = new float3(0, 0, 1)
    });
}```
#

so I am getting an entity transform from the Shoot component

#

I can spawn and set component data using the command buffer but I cant GET component data

opaque ledge
#

ah right, like you said you can use GetComponentDataFromEntity<type>(entity), which will return you.. a list of entities that has that component

velvet oxide
#

oh its a list.. doh

opaque ledge
#

then you can get the component data with GetComponentDataFromEntity<type>(entity)

#

yep, it also has Contains method so you can check if your entitiy has that specific component

velvet oxide
#

beauty thought I was missing something stupid thanks

opaque ledge
#

yeah they are quite good ๐Ÿ˜„

#

@velvet oxide btw, for buffers you need to use GetBufferFromEntity

velvet oxide
#

ah okay thanks!

worldly pulsar
#

GetComponentDataFromEntity() returns a ComponentDataFromEntity struct which you pass to your job and inside that job you can do

Entity e = someEntity;
var myComp = compDataFromEntity[e];
DoStuff(myComp);

think of ComponentDataFromEntity<T> like a Dictionary<Entity, T>

zenith wyvern
#

You can also assign to it

#

If you want

velvet oxide
#

amazing that makes things so much easier. Thanks

worldly pulsar
#

yup, also compDataFromEntity.Exists(e) tells you if e has the specific component

opaque ledge
#

yeah they are quite useful, imagine that someone doesnt know those methods exists and struggle ๐Ÿ˜ญ

dull copper
#

havent tried the last package but changelog suggested there weren't really that many changes

#

wonder if it's even functional now

#

in past it totally ruined rendering with HDRP for whatever reason and also just having the package sitting idle on your project had huge perf impact

zenith wyvern
#

Yeah, I find it hard to believe anyone would pay to use dots physics right now

#

You'd have to be a real brave company to integrate that with something you expect people to pay for

dull copper
zenith wyvern
#

No. 2019 is "officially" released today

#

So there's a bunch of new pages

#

As far as I can tell there's not much new for those of us who have been messing with the 2019.3 preview this whole time

dull copper
#

yeah, I know it released, just reading the announcement blog post ๐Ÿ™‚

#

yeah, it's expected, whole RC stage was only getting the engine more stable

zenith wyvern
#

For some reason the blog post mentions UIElements runtime, but I don't think it's actually available as a package yet

dull copper
#

and beta on most parts too

#

it's available as package

#

but I dunno if PM lists it automatically

opaque ledge
#

yeah, its like 0.0.3 tho ๐Ÿ˜„

dull copper
#

I know I had it on my manifest few months ago

zenith wyvern
#

Yeah it seems weird for them to be advertising it on the blog post when you have to go to the github and manually add their in-development repo to the PM

#

I was hoping there was something further along that was integrated already

dull copper
zenith wyvern
#

Oh snap

dull copper
zenith wyvern
#

Maybe it's coming soon then

amber flicker
#

it is but just fyi pretty sure it doesn't support worldspace and might not support overlay either

dull copper
#

do note that bintray is the old registry, 2019.3 actually fetches packages now from Unity's own server afaik

opaque ledge
#

it supports overlay but not camera one i believe

dull copper
#

so, there could be some differences on the packages between the two

opaque ledge
#

and yeah no world ui either

dull copper
#

you can still put that package to your manifest manually

#

after it's there, it'll show up on PM and can get updates there

#

I'm actually quite torn about the runtime UI

#

I know the reasonable thing to do is to use the old setup

#

but I really dislike it in many ways

#

at the same time, new system is still half baked

zenith wyvern
#

UIElements feels more natural for dynamic UI that changes a lot at runtime

#

To me anyways

amber flicker
#

haha you sure you're only talking about the UI @dull copper ๐Ÿ˜„

zenith wyvern
#

Ugui always felt like I was frankensteining stuff together and trying to piece together stuff at runtime is awkward as hell

dull copper
#

@amber flicker well, it's just one of the things, new input, most of DOTS etc are still too broken for me

#

input system bugs me especially since it almost works for me, just breaks on some devices I need to support

#

also binding breaks on devices where idle state isn't 0 on some axis

#

(which is typical scenario for wheel controllers pedals where the pedal axis can be from -1 to 1)

vagrant surge
#

Explore the new features: DOTS updates and DOTS sample

#

literally the entire page on either Experimental or Preview ๐Ÿค”

zenith wyvern
#

Seems like they're really going out of their way to highlight the fact that this is not a LTS release

#

Based on their release cycle we can't expect dots to be stable for another year at least

dull copper
#

I really liked that they did mention 2019.3 shouldn't be used in production

#

it's not what they've messaged before about tech releases

#

they are essentially previews toward the upcoming LTS and should be treated as such

dull copper
#

this is new too: weโ€™re reducing the number of TECH stream releases from three to two per year.

#

it does make sense, considering they keep falling behind on 3rd tech stream all the time now

#

tbh, they could just have one tech stream and put feature freeze to it on Q3-Q4 and then just keep stabilizing it for LTS

#

this is bit off topic here tho

safe lintel
#

surprised the dots sample gets such a fancy landing page when it feels so rough around the edges

left oak
#

Any newbie advice I can solicit here for making accelerator structures (spatial hash maps, trees, etc) that don't take me straight to dependency hell?

tawdry tree
#

Do you mean that as a DOTS-specific question?

left oak
#

Definitely, yes

#

Everything I do that sounds good normally just screams runtime errors at me about previously scheduled jobs, etc

zenith wyvern
#

If you're asking how to share a container between systems without managing dependencies the answer is DynamicBuffers

#

Otherwise you need to manually manage your job handles.

#

If you absolutely can't fit your problem into a dynamic buffer you should look at how EntityCommandBuffer handles it with AddJobHandleForProducer

left oak
#

I'll try to rely on dynamic buffers, thanks. Native containers make me tear my hair out.

#

Are dynamic buffers that exceed their internal capacity a special case? Any special care I need to take?

zenith wyvern
#

They automatically resize themselves

#

As you add to them

#

If they grow too large I believe they lose some mild performance from not fitting nicely into a chunk but it's not worth worrying about unless you're doing something insane

tawdry tree
#

Better than breaking the DOTS model, at any rate

#

With DOTS, in many cases you should probably ask yourself why before trying to use some complex collection type (so basically anything that is not basically arrays). Of course you can use them outside jobs, but if you're using such complex data inside a job... why?
It might be valid, mind you, but it might not. I've made a habit to stop and think whenever something I try is hard to achieve

left oak
#

That's worth thinking about. I feel like I'm supposed to jobify all of my code when using dots, but that's obviously a misconception.

opaque ledge
#

Yeah, please consider usage of IJob and IJobParallelFor as well, they are not entity Jobs, and i am using on many cases in systems

#

Also, native arrays is pretty useful and the only way to get results from a job, so maybe if you explain your issues with it we can help better ?

#

they are kinda core mechanic imo, maybe you should invest in them

left oak
#

I thought I could do everything with Job.WithCode and Entities.ForEach, but that's seemingly not the case

opaque ledge
#

I.. think you can, but it depends on what you are trying to do

left oak
#

How do I even dispose of a NativeHashMap.ParallelWriter?

#

It doesn't seem to expose its Dispose method

opaque ledge
#

For example, in one of my systems i run 3 jobs, first job gets faction's owned markets, 2nd job gets some data of owned market to market comparision, 3rd job creates trade ships according to results of 2nd job, so i use native array to carry data job to job, and my 3rd job is IJob, and it calculates what is the most profitable route and creates a tradeship

#

Are you trying to write to NativeHashMap in a job paralely ?

left oak
#

yeah, as both Job.WithCode and Entities.ForEach require parallel writes

#

I think

zenith wyvern
#

@left oak ParallelWriter is wrapped around the original container. You dispose the original NativeHashMap.

left oak
#

so, is the original a member variable, and the parallel writer is local?

zenith wyvern
#
NativeHashMap map = new ()...
var writer = map.AsParallelWriter();
inputDeps = Entities.Foreach(// Uses writer)
map.Dispose(inputDeps);
opaque ledge
#

if you are only creating that hashmap to carry data for jobs, then you should create with Allocator.TempJob and call .Dispose() after all jobs are finished.

zenith wyvern
#

Does that make sense?

left oak
#

yeah that makes sense, thanks

opaque ledge
#

i suck at explaining stuff xD

#

tho i never used nativehashmap before

#

gl^^

left oak
#

yeah nativearray seems a lot easier, cause you can just DeallocateOnJobCompletion

opaque ledge
#

you cant do that on hashmap ?

left oak
#

not yet supported

#

if it ever will

zenith wyvern
#

All the containers seem to have Dispose(jobHandle), works the same way and makes it clearer when it's actually being disposed

opaque ledge
#

also a side note, if you create a nativearray with Allocator.Temp, you dont need to dispose it, but otherwise you need to, but you cant use it for jobs

left oak
#

interesting

zenith wyvern
#

You can create temp containers inside jobs. The only rule is they are disposed as soon as they leave scope, so you can't pass them to anything

left oak
#

I'm torn on how to implement a spatial map: I could see myself using a native hash map that consists of keys that are the occupied integral coordinates; or, I could make an enormous dynamic buffer that's an xyz grid compressed into 1d and just index into it by a hash of the coordinates to check for occupancy. The former seems easier, but the latter seems better.

warped trail
#

look at boid sample, i think it will help you with spatial map๐Ÿค”

zenith wyvern
#

The boid method is a very specific use case though where the map is only used in a single system. It gets a lot more complicated if you want to have a spatial map that's used frequently by different systems throughout your game

#

Still not sure of the best way to approach that problem myself

left oak
#

yeah, if I was throwing many things into fewer buckets, I would do it like the boid sample

#

this is more of a voxelized "is this coordinate occupied, or not"

#

I can't decide if it's better for each system to make its own map, if it needs it, or to find a way to share a single map

#

The former's certainly easier, but involves a lot of duplication of efforts

zenith wyvern
#

You could always fully integrate it with ECS where each bucket is a DynamicBuffer, with a SharedComponentData for it's spatial index. Something about that feels off though, but maybe I'm just not thinking about it right

tawdry tree
#

Is your space limited, as in, do you know how big it will be?
How frequently does contents change? (several times per frame, once per frame, every few frames, once per second, etc)

zenith wyvern
#

I was starting to do something like that for my voxel game but it was so horribly annoying to work with SCD I gave up on it

left oak
#

I could def put in hard limits and just eat the space cost of creating a huge "3d" buffer

#

But I liked the NativeHashMap solution, as it works without setting bounding boxes

tawdry tree
#

For voxels... I have been thinking about how I'd do a voxel game (or 2D equivalent), and basically came to the conclusion that I'd either go restricted (known, bounded) size, or probably move all the generation out of entities and possibly partially systems and just save the end result.
At any rate I'd start in non-DOTS(prototype the logic/algorithm), then jobify the procGen, then put the end result in entities, and see what I did from there.

zenith wyvern
#

Yeah I was trying to make a Minecraft clone, with the blocks set up like I described, it was not fun

left oak
#

it's def a hard problem

low tangle
#

You have jobs that produce the mesh and then turn that into a ecs render mesh and collision

tawdry tree
#

The end result should hopefully have chunks being single entities with just the mesh (and related), and the actual terrain data existing in ECS-friendly structures elsewhere (when it was loaded - otherwise just serialized to disk)

low tangle
#

You will be working with native arrays mostly to create the chunks

tawdry tree
#

If more convenient, I might put the data in entities, but I feel like that would add complexity with little benefit

zenith wyvern
#

My biggest headache was, no big surprise, trying to explictly define my spatial map in a NativeHashMap. I think it might be better if I was going that route again to just restrict all chunk access to queries via SharedComponentDataFilter

low tangle
#

You can do a full chunk (unity) based chunks

#

With the data per entity but I would not suggest doing that till you really understand the way memory is stored in them. To do it that way you well be still using a single entity as the output mesh

#

You mentioned integer cord bullets buckets into a hashmap, that's what boids does and it's quite fast. @zenith wyvern

tawdry tree
#

Actually, some ChunkDataComponent holding the data with an associated ChunkPositionComponent on the same entity, and an external map/dictionary of those entities (Dictionary<int2, Entity> or native equivalent) could work...

zenith wyvern
#

@tawdry tree That's exactly what I tried to do

low tangle
#

I'd suggest if you need to look lots of things up, just use a hash map, multi if it makes sense, and don't over think it

tawdry tree
#

I really ought to get back to experimenting with that; been distracted from Unity and ECS for too long. Just updated the editor, though.

zenith wyvern
#

Managing the native container for access between systems was an annoying headache

low tangle
#

Stop trying too make things more complex than you need. You need to just try and figure out if the simplest solution would work.

zenith wyvern
#

Yeah that's why I would just stick to entity queries next time for all chunk/block access. Let Unity manage the dependencies for me

#

Of course like it was said, if the world is bounded everything becomes a lot simpler. In my case trying to fit the concept of an infinite world into a NativeContainer was a bit too much for me

low tangle
#

You can't have infinity in your memory

#

You will still have a definable set in memory

zenith wyvern
#

Yes, obviously I would load/unload chunks as needed

low tangle
#

Meaning you can add another array that was the index map

zenith wyvern
#

I never even got that far because chunk and block access became so annoying to manage I gave up

low tangle
#

I'll actually be writing a voxels generator soon

#

I can share how I solve it and how fast it runs if you like

zenith wyvern
#

Sure, I'd be interested to see how other people do it

tawdry tree
#

If you can release the code for the relevant ECS and jobs, that'd be super helpful, partially because it's a common mechanic/feature, and partially as a 'real example'

low tangle
#

Yeah

#

Give birth to another 1000 Minecraft clones lol

tawdry tree
#

in fact, the very loose coupling makes that a cakewalk with ECS

#

Or more like, if you do ECS correctly there is no coupling unless needed?

low tangle
#

Yup

zenith wyvern
#

If anyone wants to see mine

low tangle
#

Typically the only coupling is the base data types, but not even the structue

zenith wyvern
#

Code is a mess

low tangle
#

It's not bad

tawdry tree
#

My philosophy when it comes to collection types in C# is:

  • Use list. Seriously, why not?
  • Arrays if and only if you know the specific, fixed size.
  • Dictionary, queue, and stack are convenient and have a place
  • Otherwise, ask yourself why?
  • Really, though, you can probably just use a list.
    That's in general, of course; with games, ECS, and looking for perf there are concerns that outweigh 'just use list, dummy', but as I get familiar with the relevant collections I figure I'll end up with something similar.
low tangle
#

Theres a really good section in the dod book on this

tawdry tree
#

Oh, and to be clear: In that philosophy is the assumption that the code is not performance critical, and will run on decent, modern hardware.

low tangle
#

Basicly, you can gradually go up the complexity scale if profiling actually says it's slow

#

But not before

tawdry tree
#

That too.

#

Premature optimization (root of all evil and all that) is not about being smart about choice of algorithms and data structures - it's about avoiding complexity and losing convenience/readability/maintainability in favor of some nebulous potential performance loss.
I saw a talk, by Kevlin Henney I believe going over that. If you think it's going to be slow, profile it! And if it is slow, make sure it's a part that you care about whether is slow or not.

low tangle
#

Exactly

#

Don't go for the big guns when you are developing something new. Think, plan, prototype with simple solutions

#

Don't just jump into chunk iteration with 4 hashmaps and 2 custom ones

#

That's got a good chance of being in the wrong train of thought anyways

zenith wyvern
#

How would you represent a chunk?

low tangle
#

Think about the data first, not how you would process this complex idea

zenith wyvern
#

Meaning a voxel chunk, not the ECS chunks

tawdry tree
#

The raw data would probably best be stored as an array type structure - in this case of known size, and outside ECS you could make it 3D, or 1D for some more complexity but also better perf

zenith wyvern
#

I eventually landed on just a DynamicBuffer<byte> for block types. Then per block data could be added as needed with SharedComponentData

tawdry tree
#

For example, I've made 16x16x16 chunks in mono-land, stored as 3D arrays for convenience

zenith wyvern
#

It works well since, yeah, a chunk is by definition a finite space

tawdry tree
#

Bear in mind the difference between infinite(unbounded), and finite(bounded) and known(specific) sizes, too

low tangle
#

dynamic buffer with internal capacity set correctly to stay in chunk memory. Then a some for each runs over each 'chunk' which is a CD generating and updating it's own mesh

#

That simple

zenith wyvern
#

For me the mesh was the easy part. The hard part was deciding how to iterate over voxel chunks in a readable way

#

SCD doesn't make it very readable

low tangle
#

Got a 'chunk'? Generate a mesh

#

It's all in a single dynamic buffer

#

Per 'chunk'

#

Need to edit a block? Find the chunk, set the index in the buffer

opaque ledge
#

I was wondering, i have a very big DynamicBuffer which exceeds the size of a limit of an entity so i guess Unity carries it to Heap and not in a chunk, does this impact performance ? should i avoid it somehow or its an acceptable loss since buffer needs to be that big anyway ?

low tangle
#

Acceptable

#

How big is internal capacity set too

zenith wyvern
#

Right, and let's say I want to place blocks across three chunks. I figure out the chunk indices my blocks are covering, that's easy. Now iterating them is something like:

NativeArray<int2> chunkIndices;
for( int i = 0; i < chunkIndices[i].Length; ++i)
{
  inputDeps = Entities
    .WithSharedComponentFilter(chunkIndices[i]).. Iterate
}
#

Does that seem right to you?

opaque ledge
#

well, right now its 1190 item amount and size is.. 120 KB

low tangle
#

Personally I don't use shared components

zenith wyvern
#

That's basically the direciton I was heading

low tangle
#

But yeah that looks fine

zenith wyvern
#

What would you use instead?

low tangle
#

Yes that will never fit, 16kb is chunk size @opaque ledge

#

There pointer to unity heap is fast

#

So don't worry about it

opaque ledge
#

ah cool, thanks ^^

low tangle
#

Profile if you are ever worried

#

Always use large n when you do

#

Typically 1000, 10000

#

@zenith wyvern I'd use a format that doesn't need to be sorted

#

I'll get up and write some code hold up

zenith wyvern
#

If you can give me a better alternative to SCD that would be amazing

#

Because SCD sucks

low tangle
#

Yeah, try to think on it

#

There is a few ways I can think of

#

None need a SCD

opaque ledge
#

what is this spatial thing you guys are talking about ?

zenith wyvern
#

@opaque ledge Basically a spatial hash map that's fully integrated with ECS IE: Not a native container

opaque ledge
#

what is spatial itself tho ?

#

i probably should google it

zenith wyvern
#

Yup

tawdry tree
#

You should, but tl;dr grouping data by 'position' in 'space'.
it's a mathematical concept, and as such applies to 'space' that is not about actual positions, but in games it usually is.

opaque ledge
#

space as in 2d/3d space or.. arbitary type of input ?

#

yeah actually nevermind, i am too noob for those i think

#

i will just make some simple ECS systems and go happy when they work so i can boost my self confidince

low tangle
#

thats the sprit

#

the way I look at it is ecs games are wide not deep when it comes to the code
if you can make simple systems to achieve the little bits of logic you want, you can make the whole engine

tawdry tree
#

The same data structures are used in some AI stuff, among others. Except there the 'dimensions' tend to be pretty much arbitrary data, and a lot more of them.

zenith wyvern
#

@opaque ledge Just look up spatial hash or spatial partition tutorials, there should be plenty online that are outside dots so much easier to understand

tawdry tree
#

Spatial partitioning, that's the good keyword

opaque ledge
#

will do ๐Ÿ‘

#

Btw, does ECS works with Unity UI or UIElements Runtime?

#

like.. can i turn them to entities ?

low tangle
#

its going to eventually work with UIElements