#archived-dots

1 messages ยท Page 145 of 1

golden elk
#

also true

frail seal
#

Uhh

#

So how do I deal with it?

golden elk
#

close entity debugger window and reopen most likely

frail seal
#

Things like that make me wonder when Dots will finally stop being a preview package

#

But yeah, thanks for help

golden elk
#

yeah I've been avoiding dots for that reason, but I am using jobs+burst which are nice

frail seal
#

By the way I am making a Dots simulation, which will let me combine different particle behaviors. I have created far too many individual projects around gravity, electromagnetics, relativistics and other stuff, that I think it's time for me to unify them into one.

golden elk
#

nice

frail seal
#

Sure is

gusty comet
#

Disregard my earlier question.. managed to make it work using activeBuffer.RemoveAt + activeBuffer.Insert...
Just want to make sure its the correct approach?

graceful mason
mint iron
#

ugh, why not add a component called PendingDestroy or something to the entity inside the job, and then have a system that deletes entities by query that contain that component.

graceful mason
#

I think I just use entitycommandbuffer maybe ๐Ÿ˜„

#

I dont get why the docs dont show how to use it for us newbs ๐Ÿ˜„ ill look for a sample

frail seal
#

Uh

#

Now I experience crashes from something, that haven't caused any crashes so far

#

To be precise, EntityManager.CreateEntity causes the crash

#

Okay, found the issue.

#

The method itself is bugged

#

You can call variation, that spawns a single entity, but you cannot fill a list with entities - it causes instacrash.

#

Can anyone reproduce it?

#

I am not 100% sure if it is really a bug

ocean tundra
#

@storm ravine Wow thanks, I'll add updating my conversion/loading stuff to my TODO list
Doesn't even look that hard :P
Thanks again

formal scaffold
#

Hey, does anyone know, given a random Entity, how does the System know which archetype the entity is from? Systems access Entities from diferent archetypes depending on how many components are queried for.

#

So when collecting all possible Entitiy ID's(Index) there are bound to be some duplicates, right? Since a new archetype starts at 0

ocean tundra
#

@formal scaffold the entity id dosnt start at 0 again between archetypes

formal scaffold
#

Is the id continuous throughout the engine?

#

Hmm maybe I have read it wrong in the manual then

ocean tundra
#

kinda

#

Ids get reused when you destroy and create entities, thats what the version number is for

west furnace
#

What is ECS/DOTS not good for atm

ocean tundra
#

@west furnace Tough question, I'm so far in my bubble of my game I haven't really considered anything else
I think its best when you have lots of something(s) but I think you could make any game in DOTS

west furnace
#

in general someone said that I shouldn't use it for everything

#

because it's not ready

#

but what's the actual real world problem

ocean tundra
#

thats probably true around certain tech bits, like animations are preview, haven't seen anything with Particles or VFX, netcode is coming but looks targeted for FPS

#

the core ECS/JOBS/BURST is really solid, but those other bits...

#

but there's intergation flows now with older Monobehaviours and Components, so worst case you can use those

west furnace
#

I think I want to use dots because I want a traffic system, but I want to know what I'm getting into

ocean tundra
#

traffic would work well, you dont need animations (do you??) you can use the new Physics for collisions

#

worst part would probably be getting your road data into ECS, would need to break it down into points and connections i guess and then structure that somehow

west furnace
#

I do actually

ocean tundra
#

what are the animations?

west furnace
#

Well I was thinking about having both cars and people

ocean tundra
#

yea that makes sense

#

there is a preview animation package

#

but to start with i recommend just geting all the data in and working, and leaving your people unanimated (as T pose) thats what im doing

#

after i have it all solid and working i plan to integrate the new animation package

#

but ive just seen Kinematica has a preview package and has DOTS support... might play with that

west furnace
#

this might just be a bit too experimental for me to use...

#

maybe for a future project

ocean tundra
#

yea its all very experimental

#

if you want the performance and scale tho, no other way

ocean tundra
#

Any tips on how to find these allocation warnings?
Internal: deleting an allocation that is older than its permitted lifetime of 4 frames

bright sentinel
#

@west furnace I'd say it's not good for quick prototyping, or when there are only one (or few) objects of each type which have lots of interactions. That's a tradeoff with the whole philosophy, so that probably isn't going to change.

As for things that are just not good right now, the authoring/editor workflow could definitely be better. Also overall support for more advanced features and tools. Networking, animation, pathfinding etc etc. Physics is really good though, but still not perfect.

The general advice I've heard is to use normal Unity unless you can't. For example, ECS is very good when you have many of the same entity, and allows you to have way more entities in general (10.000+) without too big performance hits.

dusk relic
#

Hey, is there any way to instantly terminate a job? I do not care about the results of that job as they will no longer be valid. Optionally, I could just edit an array the job is using and then reschedule the job after it has finished, but I can't. Or is there a way to disable the lock the job places on the nativearray so I could edit it?

small fable
#

@dusk relic You could call Complete() on the jobHandle.
You may find reordering systems or just waiting until the next frame to be easier.

dusk relic
#

Calling complete() freezes the main thread as it waits for the job to finish, I wan't to terminate the job, not wait for it

#

I could wait for the next frame, but it would be really convenient to just edit the same array as it would not create any memory overhead

#

Waiting for the job to finish would require me to store the changes somewhere else, which is not ideal

#

What I'm saying is, since the results of that job will be invalid no matter what happens, why not just edit the array used by the job?

amber flicker
#

if the job is across workers, short answer is there isn't a way to do it - and even if you could, it probably wouldn't be quicker than early out-ing - you can do is early out on a chunk level using IJobChunk if necessary. To disable the 'lock' on NativeArray - if you know for sure you're not writing to the same index multiple times, you can use e.g. .WithNativeParallelDisable I think it's called

#

since the results of that job will be invalid no matter what happens - I may not be understanding your problem very well

dusk relic
#

I'm trying to edit the noise map for the terrain from the main thread, but since it's being used by a job started on previous terrain modification I can't

#

noisemap is the nativearray

amber flicker
#

Ok I think I see - I think what I said stands in that the best you can do is early out

dusk relic
#

Could you elaborate?

#

For each chunk I'm using IJobParallelFor

#

And the meshes you see are not entities

#

I don't understand why I can't just edit the nativearray

#

Can I not disable the safety checks?

#

Or can I use GetUnsafeBufferPointerWithoutChecks to get the pointer and edit the data, or will it also throw an error

small fable
#

.WithNativeDisableParallelForRestriction(myDynamicBuffer)

dusk relic
#

????.WithNativeDisableParallelForRestriction(myDynamicBuffer)

amber flicker
#

that's for the lambdas. In your case you should be able to add an attribute to your nativearray if you want to disable safety checks

#

e.g. [NativeDisableParallelForRestriction]

dusk relic
#

Yeah that disables it from inside the job

#

I still can't write to it from the main thread

amber flicker
#

but... wouldn't your jobs potentially still be writing to it even if you could?

#

Afaik there's no way to 'cancel' a job once it's been scheduled. The thing I'm not sure about is if you can e.g. write to a shared static that a job checks whilst the job is running to help early out.

dusk relic
#

No, the mesh job is only reading the noise map

amber flicker
#

so my understanding (which could well be wrong) is that if you try to write while something's reading from it, the read can certainly get either the old or a new value but potentially even something invalid/crashy?

dusk relic
#

Yeah it doesn't matter what reader reads from it, since when the job is done a new job will immediatly start

#

updating the potentially invalid data produced by the job before

dry dune
#

[NativeDisableParallelForRestriction] - Allow buffer read write in parallel jobs
Use at you own risk only when you sure that other jobs can't write to same entity, at the same time.

dusk relic
#

I need to write to a nativearray in use by a job from the main thread

amber flicker
#

I guess you'd need to create the array outside of the job, add the attribute and then pass it in? Not attempted something like this myself and have no idea if it should be safe.

dusk relic
#

Array is created outside of the job

#

How do I add the attribute to it without it being in the job though?

dry dune
#

if you sure that you never going to write to the same position that any job writes to, you can disable safety check and do it on your own risk, but if you not sure this may cause race conditions and crashes

amber flicker
#

are you saying you can't add that attribute where your array is declared outside the job or that when you do, it still doesn't let you write to it?

dusk relic
#

Doesn't let me write to it

#

Even NativeDisableContainerSafetyRestriction doesn't change anything

dry dune
#

yes safety system prevents you from writing while job is running, but you can disable that check on you own risk if you need

dusk relic
#

How?

dry dune
#

[NativeDisableContainerSafetyRestriction] public NativeArray<int> myArray;

dusk relic
#

Ahhhh I was doing it outside the job that's why it was not working , thanks @dry dune @amber flicker

#

I didn't know that existed though.. just found out about it when you said it

amber flicker
#

Groovy, I have my own question now :)
What are peoples thoughts on an ideal syntax for tweening entities/ICDs? Currently I have entity.TweenRotation(), entity.TweenTranslation() etc but I'm concerned that with all the variations this could lead to polluting the auto-complete for an Entity with hundreds of entries.

stiff skiff
#

Tween.Rotation(entity) ?

#

Or a similar builder pattern to what ForEach, Tween.With(entity).Rotation().Translation()?

naive parrot
#

Fluent API +1

amber flicker
#

For the case where there are multiple properties per component, any preferences?

bright sentinel
#

Why not go with the ECS way and use components to specify the tween?

#

User adds a "Translation tween" component

#

Which has the different variables needed for all the information on the tween

amber flicker
#

I may support that at some point for a more 'pure' workflow. At the moment there's similar functionality to DOTween so you can chain methods which is quite convenient. Tween.With(entity).Rotation(..).SetLoops().OnComplete etc.

naive parrot
#

User adds a "Translation tween" component
this is how i have structured my ECS tween engine. a Tweener core that evaluates curve based transitions. and ForEach after that just applies the interpolated values for to/from values provided by ColorTween/RotationTween/ScaleTween etc components.

bright sentinel
#

But why have it another way? That is the ECS way, so writing non-idiomatic code shouldn't be what you're striving for, especially when writing APIs that other people should use

amber flicker
#

Trying to juggle multiple aspects. You might be right. Monobehaviour land currently looks like e.g. transform.TweenLocalPositionX(..) - I want to perhaps converge on a more unified API between the two.

bright sentinel
#

Well the whole point, to me at least, is that MB and ECS are two completely different architectures - Object oriented and data oriented.

#

Trying to unify them is just going to cause you more trouble

#

I would be sad to mix the two types of writing code if some tool forced me to do that

#

I've only just gotten used to ECS-idiomatic code, and having to mix it with that would be horrible imo

naive parrot
#

been on this route. agree with @bright sentinel i started out trying to have a ECS DOTween basically and the blocker was trying to retain the OOP oriented API. plus MB will never be able to reasonably utilize the scale i was aiming to offer with my Tween Engine. pivoted to ECS only eventually.

amber flicker
#

@stiff skiff any thoughts on components? Does E.g. Tween.With(entity).RotationValue() work? I also currently have all single axis variants for convenience - e.g. RotationY() - bit concerned that .With(entity) will still contain hundreds of entries though I want to utilise autocomplete

dry dune
#

for my needs i made it so

Tween<Translation>().target().by(float3).delay().duration().ease();
Tween<Translation>().target().from(float3).to(float3).delay().duration().ease();
Sequence.append(t).append(t).append(t).whenDoneAddTag<Done>.start();```
amber flicker
#

@bright sentinel & @naive parrot I don't disagree with either of you - I've been working with dots heavily for the past couple years now. That said, I don't think the verbosity is nice as soon as you do something slightly more involved. SetLoops(LoopType.YoYo, 3) avoids the repetitive nature of if(hascomponent)setcomponent(new blah{ settingICareAbout, maybeSettingIDont} for every configuration aspect.

#

also I do want to make it easy for people to migrate from monobehaviour to dots as they want to

bright sentinel
#

if(hascomponent)setcomponent(new blah{ settingICareAbout, maybeSettingIDont}
For the first part, I'm not sure how you would avoid the if statement. Secondly, when creating a struct with the initializer you don't have to set all the variables

stiff skiff
#

I assume the builder does nothing but create an ECB to setup the components to add to/for the entity

#

So if someone wants to do that manually, they can do that

#

The Flow API would just be there for people that don't want to deal with that

amber flicker
#

Yes good point

stiff skiff
#

This has been my approach for most API's we've been building onto the ECS

#

Lowest level first, then 1 or 2 layers on top

#

Our Monobehaviour integration is also simply a layer on top of ECS

bright sentinel
#

What I'm proposing is that users just slap a component on the entity that describes the tweening. You can have multiple types of IComponentData depending on what kind of tweening it should be. A linear movement could be:

public struct LinearTranslationTweenData : IComponentData
{
  public float3 from;
  public float3 to;
  public float time;
}

Then you could have some system state component or whatever to handle the actual tweening with time and whatnot

#

Users would then just add that component to whatever entity

amber flicker
#

the problem is, that's the data that ends up on an entity anyway... like zero says, you can add all that manually but it's a chore to remember what to add under what conditions and fill in defaults etc

dry dune
#

internally my tweener uses components like this
but for convenience of configuring creation of tween properties entity is made using chain interface

bright sentinel
#

Why would it be a chore over function calls/lambda? Either way you have autocomplete, it's just whether it is a function call or a component

#

You still have to remember what the functions do and under what condition to call them in

#

I don't get why AddComponent(new Tween.LinearTranslationData{...}) is so much worse than Tween.LinearTranslation(...)

dry dune
#

tricky part was a generic job system that can tween various data types ๐Ÿ™‚

bright sentinel
#

I just know that I'll be having a hard time using a non-ECS API in an ECS architecture

#

The whole basis of ECS are the components, and by not utilizing it, you're going to be making the architecture a lot more complex

#

When you could make it a whole lot simpler

amber flicker
#

that's ok - in your case you'll be able to add the components yourself no problem

frail seal
#

Um

#

Why my build crashes when I divide double3 by a double?

#

Both are non-zero

#

I see. Apparently now I can't divide vector itself. I have to divide each coordinate in a new double3.

#

I can't believe how buggy 0.10 is

leaden hatch
#

I'm trying to instantiate some prefabs as entites. I'm getting a reference to the prefab and instantiating like this:

Entity spawnedEntity = entityManager.Instantiate(goPrefab);

in debugging goPrefab is the correct GameObject.
The enties are created but they are missing all components. Is there an extra step I'm missing?

dry dune
#

goPrefab should be an entity not a GameObject

leaden hatch
#

Instantiate has an overload for a gameobject though

#

Oh i think I need to impliment IDeclareReferencedPrefabs and declare the prefabs

frail seal
#

Can I somehow scale my entity?

coarse turtle
#

there should be a scale component/nonuniform scale component, but I don't remember if it affects the transform/rendering data yet

#

you can also set the scale directly in the float4x4 across the diagonal ๐Ÿค”

dry dune
#

there are 2 components on for uniform scale and one for nonuniform

#

Scale(){Value = 1} and NonUniformScale(){Value = new float3(1,1,1)}

frail seal
#

Thanks

#

Also, stupid question, how do I set up my RenderMesh?

#

As an example, I have entities, that use same mesh and same material

#

Should I add RenderMesh type to entity's archetype and then Set or Add SharedComponentData to each entity?

gusty comet
#

Pretty much. You'll need the following components to render an entity:
LocalToWorld, RenderMesh, RenderBounds, Translation, Rotation

#

By the way, does anyone know why an entity which has a sprite shader (cull off), when flipped (rotation.Value = quaternion.Euler(float(0,3,0)), only shows Half of the sprite when flipped?
I'm using 2020.1 right now, but in my earlier project, on 19.3.3 i can see the entire sprite

amber flicker
#

That is why we are currently working on adding Enabled state to all components. This way you can enable / disable components from any job safely without changing the structure. ``` - Joachim https://forum.unity.com/threads/entites-foreach-on-icomponentdata-class.894007/#post-5875804 ๐Ÿ˜ฒ ๐Ÿฅณ
#

that's huge

coarse turtle
#

I wonder if they'll repurpose the EntityQueryOption.IncludeDisabled filter ๐Ÿ‘€

bright sentinel
#

Now you can actually code ECS idiomatically without it hitting framerate ๐Ÿ˜„

#

(Now as in when this lands)

thorny halo
#

Hello, I was wondering how the data layout looks like inside the cache when accessing an index of an array. I was watching https://www.youtube.com/watch?v=0_Byw9UMn9g and at ~7:30 the commentator starts talking on how the data layout looks like when using OOP design and then later DOD design. However, I was wondering, when you access an index inside an array, does the whole array get loaded into the cache or is it that one value which you're accessing?

Unity's new ECS features enable huge performance improvements over traditional object-oriented ways of designing game systems, but data-oriented design is a much different way of thinking. Watch to learn how to think in a data-oriented way so you can take advantage of these ne...

โ–ถ Play video
frail seal
#

(Ooh, neat video, I'll watch it too)

bright sentinel
#

@thorny halo I may not be 100% accurate about this, so take it with a grain of salt.
There are multiple types of caches on the CPU. The L3 cache is the largest and slowest, but is the one that talks with RAM. L1 and L2 caches are only available to one core (or maybe it's two cores). Whenever you reference the whole array on one of those cores, then the whole array is loaded into each of their caches.
Now, ECS has one thread per core, and this is exactly the reason - you can work on the caches pretty much one to one. So to fully utilize this, you want to use NativeSlice, and pass that to each job. That way, only the specific part of the array is loaded.

The biggest caveat here is that I don't really know whether Burst does anything smart about this. Maybe the Entities.ForEach statement is already compiled down into this. But now you know that you can at least do it manually.

thorny halo
#

@bright sentinel thanks

frail seal
#

@gusty comet Actually, it doesn't seem to work for me. Things crash when render system updates

#

In one of previous Entities versions I used PostUpdateCommands.AddSharedComponent, but nowadays I can't understand where did PUC go

#

And it's not like it is running within a job.

gusty comet
#

first off, entity manager needs to be called like this:
EntityManager em = World.DefaultGameObjectInjectionWorld.EntityManager;
Second, try creating and rendering a single entity as a starter in a simplified way

coarse turtle
#

I don't suppose others have run into this issue with burst on Linux, but does the editor continuously have a pop up saying the version of burst has changed, please restart the editor? Seems to continously happen no matter how often I restart the editor ๐Ÿค”

gusty comet
#

You'll need to setcomponent with data to rendermesh, translation etc..

wary anchor
#

will entityCommandBuffer.AddComponent() fall over if there is already a component of this type on an entity, and/or how do I check for this first to set its data rather than adding?

#

and/or if I call remove when there isn't a component, will that fall over? ๐Ÿ™‚

#

nice, apparently it doesn't fail by removing first, not sure that that's the right way to go though, info on this is sketchy in the docs AFAICT at the minute

frail seal
#

I am thinking of downgrading my Entities version

#

0.10 is super unstable

#

Everything I do leads to crash, unless I discover a work-around

zinc plinth
#

show us error logsโ„ข๏ธ

frail seal
#
Loaded scene 'Temp/__Backupscenes/0.backup'
    Deserialize:            1.773 ms
    Integration:            321.497 ms
    Integration of assets:  0.005 ms
    Thread Wait Time:       17.017 ms
    Total Operation Time:   340.292 ms
Stacktrace:


=================================================================
Got a SIGILL while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Crash!!!
zinc plinth
#

huuuuh yikes D:

frail seal
#

Previously I had render system's "OnUpdate" in stacktrace

zinc plinth
#

isn't that more of a Burst problem than a Entities problem ?

#

what happens if you disable burst ?

frail seal
#

Will entities work without it tho?

zinc plinth
#

ye

frail seal
#

Okay, I'll try

zinc plinth
#

don't uninstall it, just tick off the burst compile option

frail seal
#

Yeah, I was about to search it in the menus

#

Finally some progress, thanks

zinc plinth
#

๐Ÿ‘

frail seal
#

Turns out my mesh was null... for some weird reason

zinc plinth
#

eizenhorn is typing

frail seal
#

Ack, actually, nvm, I am in the wrong scene rn

zinc plinth
#

?

storm ravine
#

I already told you :)

First what you should to do when you got crash - disable Burst, usually it crashes only with burst, with disabled burst compilation you'll see clear errors.

#

This is because burst has troubles with exceptions handling

#

Depends on hardware

frail seal
#

I thought Burst only compiles job stuff

storm ravine
#

We on 0.10 in huge and complex project and all works fine, it crashes only in rare cases when you have errors in your code. In 90% is user error.

frail seal
#

Can you also divide double3 by double?

#

And does instantiating entities by a list work?

coarse turtle
#

should be the case - you would get a double3 as the result, but you might be get a divide by zero error

frail seal
#

To me those two things are completely bugged

zinc plinth
#

by a list ?

storm ravine
#

Yes it woks without problems

frail seal
#

Yeah, by specifying an archetype and a native list you want to fill

storm ravine
#

Instantiating entities with NativeArray overload if I remember your previous messages

frail seal
#

Yeah, Archetype + NativeArray args

storm ravine
#

We using all overloads for instantiating in different places and all of them works fine

frail seal
#

Maybe it had to do with using wrong EntityManager idk

#

For the past 2 days I've had probably 50 crashes

zinc plinth
#

turn off burst and see GWaobloChildPepeShrug

frail seal
#

Fhew, finally everything works

#

...without burst compiler

#

I probably need to play around with it's versions

#

But for today - I'm done

#

Everyone, thanks

dusk relic
#

Do you have burst safety checks enabled?

#

@frail seal

gusty comet
#

Any idea why the following would happen?

  1. An entity has two components that other similar entities don't.
  2. EntityManager.SetSharedComponentData sets its RenderMesh to a new() one, and the mesh is set to a different mesh.
  3. The DisableRendering tag is on the entity.
  4. It renders anyway.
  5. Every single similar entity NOT sharing a chunk with it also has its rendermesh changed.
#

This is driving me insane. I just want procedural geometry. Will I need a different quad prefab for every single unique shape? It's described like we can instantiate a prefab, and change the instances. Then change the prefab and instantiate for different geometry.

#

Instead, it's like prefabs are permanently bound to everything instanced from them.

#

I really hate this workflow.

ocean tundra
#

Some code snippets?
This sounds super bad

gusty comet
#

The functionality is spread over several systems. I'd have to provide my entire project's scripts.

#

Here's what happens, in a nutshell:

#
  1. A quad prefab is made.
  2. It's instantiated several times, to make grids.
  3. The grid quads are all tagged gridQuad. The prefab isn't.
  4. The prefab is tagged Progenitor. The gridQuads aren't.
  5. I try to change the vertices for the Progenitor, so I can instantiate it for billboards.
  6. All of the gridQuads have their vertices changed too.
#

I also can't prevent the Progenitor from rendering. The DisableRendering tag is just ignored.

ocean tundra
#

The prefab has the Prefab tag on it?

gusty comet
#

Does it need that?

ocean tundra
#

yup

gusty comet
#

I'll try adding that.

ocean tundra
#

and when you query for it you need to do something like WithOptions(include prefab)

#

or something like that

#

Prefab is a super special component

gusty comet
#

Okay, so it's something getting hung up in the conversion procedure. When I instantiate, will the prefab tag automatically not pass on to the instances?

ocean tundra
#

no

#

when you convert to a entity, if its already a prefab it will have the Prefab tag added

#

when you convert a gameobject it dosnt get that

#

but you can add it yourself

#

i do

#

but also loop over the linked entity group and add it to everything in there

gusty comet
#

And then remove the prefab tag, instantiate, and add it back to the progenitor

ocean tundra
#

dont remove it

#

i think that would just cause more weirdness

gusty comet
#

Wait. Everything? As in, every gridQuad and every billboard?

ocean tundra
#

im not sure about your prefab setup

#

linkedentitygroup is what groups together children entityis

#

its added automatcily as part of the convertion flow

#

so your flow should be something like this i think
GameObject => Convert => Prefab

#

then if you want to modify the prefab

#

Instaniate it, modify, then add Prefab again

gusty comet
#

So it won't automatically instantiate the prefab tag to the clone?

ocean tundra
#

no

#

just like in normal unity

#

when you Instantiate a prefab its not still a prefab

#

my flow is similar,
Unity GO Prefab => Instantiate GO => Modify it => Convert => Add Prefab to entity

gusty comet
#

This is causing all kinds of chaos. I got the gridQuads to render ... without their material, and until I added the prefab tag to them

#

So, basically, absolutely everything procedurally generated will need the prefab tag

ocean tundra
#

nooo that cant be right

#

entitys with the Prefab tag are excluded from almost every entity query

#

how are you rendereing?

gusty comet
#

Using the Universal Render Pipeline

#

HD was just too slow

ocean tundra
#

hybrid renderer v1 or v2

gusty comet
#

v2

#

If I don't add the prefab tag, they automatically get the TerrainLit material (do not want), and if I add the prefab tag then even if I include prefabs in every related query, they don't render at all.

#

The prefab already has a material in its rendermesh

ocean tundra
#

yea a Prefab wont be renderd

#

you should just have 1 prefab

#

and Instantiate that a ton of times

gusty comet
#

That makes more sense. But what's up with the material getting changed?

ocean tundra
#

no clue yet

#

break it down real small

#

with like 5 entities

#

so you can quickly compare the Prefab and the instances

gusty comet
#

I don't see a need to go smaller. When they all render, they're in a perfect grid, named, and their parent grids are tagged for direction relative to the player camera. All the debugging stuff is there. It's just guessing what's happening under the hood.

#

They render perfectly if the first one has no prefab tag. I just can't reuse it then.

ocean tundra
#

you can still Instantiate a existing entity, it dosnt have to be a prefab

gusty comet
#

Yep. Looks like maybe the prefab gets no rendermesh in the conversion process. Nothing I set up sticks with it, except the vertices.

#

mesh name is gone, default material used

#

Leaving it as a non-prefab, I'll need a different base entity for every single quad shape (the problems I first mentioned). Such a strange requirement

ocean tundra
#

well that sucks

gusty comet
#

It's the instantiate method causing the weirdness. Has to be. It's causing entities to share memory in an unexpected way.

ocean tundra
#

at a guess something is cleaning up the mesh

#

so a sharedcomponent is shared

#

so they are all the same instance

gusty comet
#

Yes, but these should be in different chunks, since they have different components.

#

And if I set a new rendermesh by value, it should move that entity to a new chunk, rather than change everything in the chunk. So, there's some unexpected behavior here.

amber flicker
gusty comet
#

Checking it out; thank you

ocean tundra
#

yea that looks super useful

gusty comet
#

Oh, I've seen that! That's a different bug. When you press play, nothing is rendered. Stop, and press play again, and it works.

#

Got it! There was a query I forgot about. Build a system, optimize, repeat. It had been a few weeks.

ocean tundra
#

๐Ÿ˜›

#

you can see what systems are using the entity, its right at the bottom of the selected entity

gusty comet
#

I knew about the system though lmao It's the one where the mesh and material are set. It couldn't have been more obvious. Time for coffee I think smfh

ocean tundra
#

๐Ÿ˜›

#

good luck

gusty comet
#

Thank you

graceful mason
#

Hi, is a Vector3Int not compatible with burst?

ocean tundra
#

what are you procedural generating?

#

@graceful mason nope, use int3

#

also use the new math library

graceful mason
#

ok thanks

#

yeah just got most my code converted i think

gusty comet
#

First, a grid. Then, my UI. I developed this neat effect where billboards have inertia when the camera moves. Finally, terrain and structures once the UI is in place.

#

Everything after that is effects, animations, and logic

ocean tundra
#

@gusty comet I cant visualize that, billboards like for trees?

gusty comet
#

Quads as entities that are manually kept facing the camera, in a system. There's a slight delay when the camera moves, before the quad follows. So, it feels like the UI quads have weight.

#

I'm not sure if I'll keep it in the long run, but it happened accidentally and I hadn't seen it before. So, I fixed it, and then deleted the fix.

ocean tundra
#

@gusty comet sounds cool, so ui just takes a second when moving??
What type of game?

gusty comet
#

Sort of a RTS + RPG mashup, but probably starting as a TTRP aide to get it right

ocean tundra
#

TTRP??

#

I'm working on a RTS

gusty comet
#

Tabletop RPG

graceful mason
#

argh, Entities.ForEach uses ISharedComponentType ChunkCoord. This is only supported when using .WithoutBurst() and .Run()

#

is it the shared type, or my basic public struct chunkcoord int3

ocean tundra
#

@graceful mason Share the chunk coord type?

gusty comet
#

See if the compiler will let you use IComponentType instead of shared, now that you're using int3.

#

So long as your struct has non-blittable types, it'll make you declare it as shared for thread-safety

graceful mason
#

public struct ChunkCoord : ISharedComponentData {public int3 coord;}

#

I wanted to be able to qqueryt for particular coords

gusty comet
#

Alternately, you can cache your data from threads in a SharedStatic (Burst safe), and then move it to your shared component using EntityManager.

ocean tundra
#

that looks fine

gusty comet
#

public struct ChunkCoord : IComponentData {public int3 coord;}

ocean tundra
#

another option is you use a HashMap instead of a shared component

gusty comet
#

Making it a shared component, it's automatically in managed memory (so, no Burst)

graceful mason
#

I had IComponentData but could never work out how to query a coord and get the entity

#

I guess that makes sense sort of ๐Ÿ˜„

gusty comet
#

EntityQuery(typeof(ChunkCoord)).GetSingletonEntity() should do it

graceful mason
#

I have l1000s of chunks, each with a coord

#

how to get chunk 0 0 0

gusty comet
#

Maybe not then lol

#

Tag the first entity of chunk 000

ocean tundra
#

yea so i think make a native hash map in some system and share that

#

<int3,entity>

#

another option

#

if you know the max size of your wolrd

#

you can convert x,y,z into a index in a single dimension array

#

that would be even faster then a hash map

#

theres a discussion about these wayy up in the chat

#

i was asking about fog of war

graceful mason
#

Im thinking hard ๐Ÿ™‚

ocean tundra
#

maybe see if you can find it

#

@graceful mason Whats your usecase?

graceful mason
#

im just using the things wrong ๐Ÿ™‚

#

I have an entity, a "chunk" it has a coord, and a terrainbuffer

#

fiunnally i try to loop those entities

ocean tundra
#

yea so i would make a static list of those entities

#

either hashmap or array

gusty comet
#

int hash1 = math.floor(math.pow(x, 2.0f) + (double)y);
int hash2 = math.floor(math.pow(z, 2.0f) + (double)hash1);

That will give you a unique double for any x, y, z, so long as you don't commute them.

ocean tundra
#

you probably want a uniquie int tho.. dont want to risk rounding issues

#

tho floor should be to a int right?

gusty comet
#

Whoops. That's what the floor is for

graceful mason
#

for now, i will try using componentdata

#

as before it took 0.4 seconds to generate each entity

#

but with burst maybe i can make it fast enough

#

whats commuting?

#

oh

#

Yeah its gone from 48 FPS to 1800FPD

#

burst is a beast

gusty comet
#

Commuting is changing their order. Say, if you wrote that into a method that takes x, y, z as parameters, and then somewhere you passed y, x, z, then that couldn't be guaranteed unique as compared with all the x, y, z hashes.

graceful mason
#

haha ok that sounds like some schrodinger type stuff a little over my head. I always keep X as X always so hopefully im ok ๐Ÿ˜„

golden elk
#

Is there currently any way to do skinned mesh animations in URP+DOTS

graceful mason
#

one day I will discover what is causing a bug in my code, and I will remember this convo ๐Ÿ˜„

storm ravine
#

Is there currently any way to do skinned mesh animations in URP+DOTS
@golden elk write your own GPU skinning shader and system, it's simple.

golden elk
#

Well yes I was wanting to avoid that. Unfortunately Unity's GPU skinning is HDRP only, and GPU Crowd Instancer doesn't support mobile.

#

And I feel like this must already exist somewhere, unless everyone using DOTS is only using HDRP or making 2D games

storm ravine
#

We using built-in and wrote own renderer and systems.

ocean tundra
#

@golden elk theres the Unity.Animation Package

golden elk
#

doesn't support URP it says

ocean tundra
#

I've seen conversations in the forum claiming it works...

#

ill see if i can find it

graceful mason
#

argh, so say I generated 5 chunks. (0,1,2 3,4) , when I do EntitiesForEach(chunk) I get a chunk .. say it was number 2, its job needs chunk1 and chunk3 data too

#

This is where I make a static list of those entities?

#

feels insane theres no query by component value function to me, but I guess it all makes sense too work., I will try ๐Ÿ˜„

zinc plinth
#

@graceful mason you can filter queries by shared component

but filter by component is astonishingly slow and you should not do it

graceful mason
#

yeah it doesnt work with burst then

zinc plinth
#

if you have multiple entities holding the same value on purpose, make it a shared component

#

wdym ?

graceful mason
#

Entities.ForEach uses ISharedComponentType ChunkCoord. This is only supported when using .WithoutBurst() and .Run()

#

I got that

zinc plinth
#

can I see your code ?

graceful mason
#

sure, its super basic mosly

#

Behind scenes, I only make the //and populate there "TerrainOther Buffers" job for entities where all surrounding terrains are made

#

so now, how to get hold of there data ๐Ÿ˜„

ocean tundra
#

so the issue is the bottom comment?? how to get chunk 2 and 4's terrain map?

graceful mason
#

yeah

ocean tundra
#

ok cool

graceful mason
#

I think the advice above, make a static list sounds ok

graceful mason
#

so in my system

ocean tundra
#

you could have another buffer

graceful mason
#

inssrtead of just for x generate chunk entity..... I make it ....for x generate entity and save in list

ocean tundra
#

like otherMapElement

#

but instead of int you have the Entity

#

and populate that during gen

#

and stick to some rules like 0 = left, 1 = up ect

#

or you can do that

#

during generation

#

save the entity and cord into a NativeHashMap<int3, Entity>

#

and make that accessable

zinc plinth
eternal ice
#

Is there currently any way to do skinned mesh animations in URP+DOTS
@golden elk Sorry in advance if Google translator translated poorly.

I have a script adapted from GitHub + shader for GPU animations.
The requirement for the device was ES 3.0+ (to extract Vertex ID: SV_VertexID) and animations must be of type "Generic"
A bit dirty code, in a hurry, removed the part of custom rendering...

The shader has 2 uv channels, a color map is stored in the second channel.
"_BaseColor" - the color of the repainted part is superimposed on the second channel, you can delete it if you do not need to.
In the comments I tried to note this

Shader - https://pastebin.com/yfx4RsMc
Animation asset - https://pastebin.com/QD9U7Nn6
AnimMapBaker (EditorWindow) - https://pastebin.com/UP3M3Xan
AnimMapBaker (Main part) - https://pastebin.com/Kz51pkfh

#

Although it seems to work on 2 ES, but for sure, I donโ€™t remember if in 2 ES SV_VertexID support.
But on all sorts of specific ES 3 exactly works

ocean tundra
#

@eternal ice Thanks for that ๐Ÿ™‚ save for later
I can't find the posts talking about Unity.Animation working on URP but now I'm thinking I got Hybrid Renderer and Animations swapped around

golden elk
#

Thanks I will give it a shot โค๏ธ

opaque escarp
#

what's the proper way to instantiate an entity from a monobehaviour? I looked at the ECS samples, and in it they use GameObjectConversionUtility.ConvertGameObjectHierearchy, and pass in null for a BlobAssetStore, which does not work on my end. Manually creating a BlobAssetStore with new BlobAssetStore seems to like crashing Unity. what do?

ocean tundra
#

i make a blobassetstore and keep it round, then in the monobehaviour destory i clean it up

eternal ice
#

@eternal ice Thanks for that ๐Ÿ™‚ save for later
I can't find the posts talking about Unity.Animation working on URP but now I'm thinking I got Hybrid Renderer and Animations swapped around
@ocean tundra I am waiting for the Unity 2020 release because the Hybrid Renderer V1 does not work well ... I wrote a custom render pass and job system. From the Hybrid Renderer I extracted the culling task and on updating Job systems I select the necessary units, affter sorted by teams and write to batches. In the pass, I draw these units with CommandBuffer.DrawMeshInstanced. It turned out pretty well ~ 600 animated units of different colors (5 commands) on the iPhone 6 with a stable 60 fps. Prior to this, GameObject + RenderMesh gave the same process only 30 (iPhone either 60 or 30 can only). And 30-45 fps on the Nexus 5 on which before that it was 18-24.

ocean tundra
#

@eternal ice Yea I'm using the 2020 beta, but I havnt turned on V2 rendering yet

#

I'm not fussing with performance, still too many core gameplay things i need to implement, after I have them all in ill start reviewing and optimizing, 100% sure that Rendering will be a big one

opaque escarp
#

@ocean tundra when you instantiated it, did it have any physics related stuff on it? I think the issue with mine might be it creates physics stuff while the broadphase is executing or somethng. As sometimes it crashes on instantiation, other times it doesn't.

ocean tundra
#

i am using physics

#

no issues

#

are you saving the blob asset store?

opaque escarp
#

okay, the issue was I disposed the blob asset store too early, which made it crash when using entities with physics components attached specifically

ocean tundra
#

yup that makes sense

#

physics colliders are blob assets

opaque escarp
#

ty

golden elk
#

@eternal ice Got the GPU skinning stuff working, thanks again

golden elk
opaque escarp
#

Is there a particular UpdateGroup it's best to create MeshColliders in? I'm currently just kind of creating them whenever, but I'm running into weird issues like some collision meshes occasionally don't exist, and I haven't been able to find any logic on my end that could explain it, so I'm wondering if there's some threading shenanigans going on

ocean tundra
#

@golden elk Wow amazing

#

@opaque escarp Create them on entity spawn?

#

or if you can as part of the prefab

opaque escarp
#

it's procedural, so can't do it as part of the prefab

#

at the moment I have it get created at some time after the data for the mesh is generated in the normal update group

ocean tundra
#

so if its all procedural could you have it all in a separate world and then load it into the main world when all ready?

opaque escarp
#

I could do that, but I'm not sure if that would do anything different

ocean tundra
#

its more of a end state i guess

opaque escarp
#

at the moment this is the code I have for generating the meshcolliders

BlobAssetReference<Collider> thing = MeshCollider.Create(vertices.Reinterpret<float3>().AsNativeArray(), tris.Reinterpret<int3>().AsNativeArray());
                col = new PhysicsCollider { Value = thing };

where col is a PhysicsCollider passed by reference

#

I guess my question is if there's any way a collider could end up corrupted with this

#

I've also noticed some other weird issues, like I move the camera and the collision mesh suddenly works, which makes me think that it's an issue with my stuff, but nothing else points to that

ocean tundra
#

does the entity have a PhysicsCollider on it from spawn

opaque escarp
#

yes

ocean tundra
#

or do you just add it then?

#

can you try not having a collider on spawn

opaque escarp
#

all right

ocean tundra
#

then it wont be included in those physics querys

#

and maybe a bit safer

opaque escarp
#

didn't work

#

I really wish there was any kind of debug visualization at all

ocean tundra
#

:/

#

its comming

opaque escarp
#

yea

ocean tundra
#

you could try turning on physics debugging

#

add a PhysicsDebugDisplayData

#

a singleton entity

opaque escarp
#

I'm a little hazy on singletons, would on do that in the OnCreate of the System?

ocean tundra
#

yea you can

#

just create a entity

#

and add that component

#

as long as you dont make more then 1

opaque escarp
#

now how do I get it to do its thing

#

oh gizmos on

ocean tundra
#

yup

#

and set true to the bits you want to see

opaque escarp
#

crashed unity so hard task manager couldn't end it lol

ocean tundra
#

well...

#

thats not good

opaque escarp
#

might've found something

#

and yeah that debug thing was exactly what I awnted

ocean tundra
#

awesome

#

glad i could help

opaque escarp
#

oh lordy the degu is slow as snot though

#

and runs my computer out of memory

#

that's why it crashed so hard

#

well I'm certain I'll be able to figure out the issue with this eventually, ty

#

huh, the colliders are there in the debug, they just don't respond to queries or actual collisions

#

then I move the camera and they start responding. I don't even...

#

all right it's almost definitely an issue caused by my stuff. Might be rebuilding the mesh every frame or something, as disabling my generator script magically made them react to collisions.

ocean tundra
#

@opaque escarp sweet, glad you figured it out

opaque escarp
#

Unfortunately I'm no closer to the solution. My hunch at this point is that collision pairs aren't being generated properly, maybe due to bounding boxes not being aligned, and adding a new entity to the chunk triggers an update with the builtin stuff that resolves the issue. Is there anything other than Translation/Rotation/LocalToWorld that the collision system uses to generate the collision pairs that may have not been set?

lusty otter
#

After a lot of hard decisions I rewrote my project in good old Unity rather than ECS, and for the first time ever I ran my whole project in editor play mode without crashing.

#

I really like ECS and look forward to it when it's more mature, but for now it's really not ready for production yet, even for a project as small and simple as mine.

opaque escarp
#

indeed, it is in "Preview"

ocean tundra
#

@lusty otter What is your project?

#

@opaque escarp I dont think so. when the Physics Sim runs it does a bunch of stuff internally but i dont think it does anything to any other components

mortal owl
#

I'm glad I've had refrain from using it a year ago, and now I've just started a new project but I won't even consider using it. Hope it will be finished in 2021/2022/2023...

lusty otter
#

It's a scriptable mobile rhythm game, it really isn't complicated compare to the stuffs you guys working on in here.

#

Before I went back to the old ways, build works on fine on actual devices but in play mode it crashes once the scripting engine is in a few levels of call stack deep.

#

On iOS there are plenty of issue with Job system/Burst crashing the app.

#

I went from the initial full DOTS setup, to slowly one by one removing components, starting from removing ECS, then Burst, and now finally I've removed Jobs, it's basically just good old Unity now ๐Ÿ˜…

mortal owl
#

I don't trust any of the the 'new' packages anymore unless there are lots of people confirming it's actually usable in production. Even with those packages out of 'preview'. It's really a mess now

#

If good old stuff works, long live the old days

opaque escarp
#

@ocean tundra Thanks I'll read up on that tomorrow

mortal owl
#

I think this is a really 'audacious' move. if the hardware is improving dramatically,then this is goona fail because what DOTS what to solve is to force Programmers to code in the hardware-cache friendly way (data-oriented). But if that's no longer the problem, say 3 years later, we have huge-cache hardeware when coding this way doesn't really bring 'siginificant' performance gains, then I think it won't be adopted by much people. For example, in the old days we have lots of GPU tricks to code in a specific way to 'conform' to the GPU, but now they are all gone. and see the latest ad by Unreal5, now we can even ditch normal map in circumstances. Hardware v.s. Software ๐Ÿด

lusty otter
#

I guess it's more relevant to my project, which is targeted at mobile (low to mid end devices as well) so performance is indeed a big concern.

#

For a more complicated project yeah I can imagine the headaches, but my logic is very simple (everything is scripted by the user anyways) and transitioning between the two isn't too bad.

#

If DOTS things worked, even to a semi stable degree, I would still be going with it. But sadly that's not really the case for me.

#

The most bizarre issue I've had over the course of the project has to be that, by having more than 15 cases in the script executor's switch statement in a job, somehow causes editor to always crash, even if the extra cases aren't even being executed, or I have Burst turned off completely. I was never able to resolve this issue by the way, and had been working on the project without being able to editor play mode that part of the game.

frail seal
#

@dusk relic Yes I do have Burst safety checks enabled

dusk relic
#

Ok I donโ€™t know how to help you

#

Does the unity physics mesh collider require a rendermesh or can I set the collider mesh separately?

#

Also if I can, is it sharedcomponentdata

ocean tundra
#

@dusk relic It does not require a RenderMesh

dusk relic
#

OK

frail seal
#

How do I pass component data array (indexed by integers) into a job?

#

I need to make a simple n-body system, where each particle attracts every other particle

#

In previous DOTS versions I used IJobForEach into which I passed readonly native array parameters

#

But nowadays it seems to be deprecated

dull copper
#

In addition to that we are currently working on an overhaul of the workflows for creating ghosts and generating code, but that change still needs a bit more time and will not be in the next release. This was a change required for two of the game productions we are using to verify that the netcode is production ready.```
dull copper
#

@dusk relic I'll just confirm the earlier, unity physics doesn't even need hybrid rendering package to work

dusk relic
#

Alright, but how does the collider know what it represents then

#

just buffer of vertices and indices?

dull copper
#

well, depends on collision type

#

box, sphere, capsule, cylider you can just define yourself

#

for convex and mesh collision you just ref the mesh on the collision authoring component

#

easiest way to author these is to just place them on mesh itself

#

you can sync physics objects to meshes manually if you want to

#

like if you want to use nonhybrid renderer and dots physics

#

there are bunch of ways to do this

#

like, easiest is to just use convert and inject and put copytransformtogameobject component to conversion script

#

@dusk relic

vagrant surge
#

@lusty otter i made a rythm game in Entitas

dull copper
#

but you can also store the GO tranform to entity on authoring stage and keep them on totally different objects, like have DOTS physics objects that get fully converted to entities but still hold GO transform for rendering part

vagrant surge
#

if you want to use something that works but miss the ECS paradigm, maybe check that out

#

unlike DOTS, it actually works well in hybrid

dusk relic
#

I'm researchin this for marching cubes collision

#

so the object doesnt move

#

I found that traditional rendering is better for performance

#

but mesh colliders suc

#

for obvious reasons

lusty otter
#

Yeah I'm rolling with my own ECS paradigm now, it's really simple but more than enough for what I'm working on.

dull copper
#

I'm not sure if physx mesh collisions are that bad

#

like, I wouldn't expect major wins on dots physics

lusty otter
#

The things I want the most from DOTS are Burst and Jobs, which sadly don't work very reliably yet.

dull copper
#

it could do even worse

dusk relic
#

Simulation isn't that bad, but baking the colliders lags real bad

dull copper
#

which unity version have you used?

#

there's been a lot of work on making the bakes faster

dusk relic
#

2019.3.something

#

I did set the bake option to be faster for generation instead of simulation, but no noticeable impact as far as i can see

dull copper
#

that lets you bake off the main thread

#

of course if you need to apply it instantly, that will not fix the whole issue

dusk relic
#

Alright will have a look, thanks

dusk relic
#

I'm not quite sure what's happening here. It's like it's baking the mesh both on the main thread and on the jobs ๐Ÿค” orange is mesh baking

dusk relic
#

Turns out Physics.BakeMesh is broken and got fixed in 2019.3.10

mint iron
#

I wouldn't expect major wins on dots physics i was looking at the collision code a couple weeks ago and it really doesn't seem very optimized. Im sure the bvh traverse and stuff is fine but most things just go through the same full hull-hull tests and its littered with branches, no simd etc.

humble falcon
#

Dear community, here again I need help from you guys. I have some basic questions, not sure if it is possible or not. So basically, I have lots of entities in my scene. They all are doing some calculation. While I am going around with my player, I noticed, that it doesn't matter if the entities are nearby to my player or not. The systems still do its calculation on each entities. I find it not really performant to be honest. So I want some kind of filtering, where depending on the distance, the systems doesn't need to iterate through all entities, but only those who are nearby the player. I have now queried all entities and put it to a job, where I put nearby entities to a nativelist. So my question now: How do I iterate only through the entities inside the list with the foreach lambda expression? Here is my code example: https://hastebin.com/hagiqinoli.cs

mint iron
#

If you want to use a query (or indirectly by using ForEach args) then you'd have to have a tag component on the entities that are within range of the player. So you'd have a process to apply/remove tags, and then you can simple WithAll<NearPlayerTag>() in your ForEach chain.

#

Alternatively you can maintain a collection of some sort for the entities within range of the player, and then iterate your collection using Job.WithBurst()

stiff skiff
#

Since this is using ForEach in SystemBase, you can use GetComponent instead and iterate over your list of entities

#

It will compile down to a GetComponentDataFromEntity

humble falcon
#

@mint iron tagging the entities nearby is a good idea. I have to test it, how performant it will be. The other option with Job.WithBurst(). Is it something that I can also parallel schedule?

stiff skiff
#

Note that tagging will temporary change the archetype of the tagged entities, making them move chunk. And then later when removing the tag, doing the whole move again

thorny halo
#

Hello, i recently got into learning about caches/temporal locality/spatial locality and was wondering if i understand things correctly about it. I need a way to store data into a NativeArray for a quadtree. I was wondering which of the 2 ways of storing nodes is more efficient for spatial locality, by depth or by parent -> node hierarchy. Presumably for the purposes of traversing the tree in a "parent -> children -> deeper children fashion". I presume it's the latter since there's less jumping around inside the array, but am not sure. https://i.imgur.com/ZxTPa8l.png

humble falcon
#

@stiff skiff I am not sure how GetComponentDataFromEntity would help my cause. I mean Of course I can get lets say a nativearray from the position of the entities. But than I still have to compare it to my player position and than sort out the entities, that are far away. Maybe I am missunderstanding something ๐Ÿ™‚

stiff skiff
#

If I understand correctly, you want a first pass grabbing all nearby entities

humble falcon
#

@stiff skiff yeah tagging will change the archetype. thats a good point. I have to test it, if this way is expensive

stiff skiff
#

and then a second pass of logic with ONLY those nearby entities

humble falcon
#

yes I want grabb all nearby entities. and than I want all systems only running through the nearby entities and ignore basically the others

stiff skiff
#

When you say "all systems"

#

you mean systems that run after that filter step?

#

Or a few methods

humble falcon
#

ideally all my systems. I also dont want the entities to get rendered for example.

stiff skiff
#

Right, then the tag component is the way to go

mint iron
#

@thorny halo you want to maximize the possibility of reading data right next to each other, i did something similar recently and the octree would scan all 8 at a certain depth together, the Aabb were layed out all right next to each other in memory, so it could be done in two sets of 4 bounds (the bounds (aabb4 was restructured so all the x's were together, all the y's together etc so they can be hit at the same time with SIMD)

stiff skiff
#

Do we actually have any tools for C# / Unity to profile cache / branch misses?

#

Its something I miss from my C++ projects

deft stump
#

@humble falcon why not just list all entities nearby in a dynamicbuffer?
there's a Code Monkey actually has a video about it.

#

the example project he used later in the vid lists all entities nearby

graceful mason
#

im still going insane trying to work out how to use an ECB, please can anytone show me there init code? Something like?

#

EntityCommandBuffer entityCommandBuffer = World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>();

#

Cannot implicitly convert type 'Unity.Entities.EndSimulationEntityCommandBufferSystem' to 'Unity.Entities.EntityCommandBuffer'

#

Argh, I been reading version 0.0 docs ๐Ÿ˜„

#

Im so damn dumb

wide fiber
#

I am having some problems with Unity DOTS:
โšช UI
โšช Animation
โšช Sprite sheet
โšช MonoBehaviour accesses Components inside Entities

How can I implement these things?

humble falcon
#

@deft stump I am aware of that video. I used dynamicbuffer for other stuff. For my usecase this approach is only possible if I have multiple bufferelements, because I am using multiple archetypes.

#

@wide fiber Regarding your fourth point, not sure what your usecase ist, but you can simply write some kind of HybridConversionSystem. Lets say you want a monobehavior to be aware of the position of an entity. In OnUpdate you than have to access the monobehavior object and pass the position from the entity.

viral sonnet
wide fiber
#

@humble falcon thanks I'll try your solution :D

pliant pike
#

I don't suppose anyone has any idea how I would move something at a constant speed, by using the total distance(calculated) with a variable frame rate

bright sentinel
#

@pliant pike So you want to move your object from one position to another position with a given time?

pliant pike
#

yeah basically I want to move something along a spline with a constant speed

#

I can calculate the length of the spline roughly enough

wide fiber
#

If you know the length of the path you can get the speed, then you should use Time.DeltaTime to make it frame indipendent

pliant pike
#

yeah I just need to move it a specific distance each frame

#

I guess I could divide the total length into parts and then move it a certain amount to each of these over time

wide fiber
#

@humble falcon so inside a system base I should get a reference to the MonoBehaviour and set the values based on the component of an entity? How can I get the MonoBehaviour reference

pliant pike
#

thanks for the help guys ๐Ÿ‘

wide fiber
#

I guess I could divide the total length into parts and then move it a certain amount to each of these over time
@pliant pike I can't understand the problem, is this a math problem? Do you have a time value and a target position and you need to get the speed needed to reach the target?

coarse turtle
#

@humble falcon so inside a system base I should get a reference to the MonoBehaviour and set the values based on the component of an entity? How can I get the MonoBehaviour reference
@wide fiber Assuming you're using ConvertAndInject, you can access the MonoBehavior as the first param like so Entities.ForEach((Animator anim) => {})

pliant pike
#

yeah I think I'm getting it now just divide time by distance to get the speed, then use that to move it like speed * time.deltatime etc

wide fiber
#

@wide fiber Assuming you're using ConvertAndInject, you can access the MonoBehavior as the first param like so Entities.ForEach((Animator anim) => {})
@coarse turtle ok thanks, but if I don't convert the MB GameObject to an entity what can I do? (I can't convert UI to entity because it wouldn't work)

coarse turtle
#

You could try doing a "hybrid component"

#

which I believe is EntityManager.AddHybridComponent(Component component)

#

you still attach a ConvertAndDestroy

wide fiber
#

Ok

coarse turtle
#

and the entity associated with the gameobject is hooked via a CompanianLink component

#

so CompanionLink.Value -> should return the associated gameObject

wide fiber
#

๐Ÿ‘

wide fiber
#

The UI doesn't work, I've added all the hybrid components to my text GameObject (TextMeshProUGUI, CanvasRenderer and RectTransform) but it is invisible

coarse turtle
#

o dang ๐Ÿค”

leaden hatch
#

anyone have any tips for handling ui input? I'm thinking of having a controller singleton component and having the ui monobehavior make changes to the singleton component's properties, and having a inputHandlerSystem process the changes. However I cant work out how to guarantee the ui will make the changes before the inputHandlerSystem runs

gilded glacier
#

what about using a flag field (something like isDirty) in the component, then having the monobehaviour set the dirty flag to true, then let the handler system run only if the flag is true and then reset it after execution ?

graceful mason
#

does anyone know how to get an instance of a system in a system?

mint iron
#

World.GetOrCreateSystem<T>() ?

graceful mason
#

Ah sweeet thanks so much

#

was using GetExistingSystem ๐Ÿ˜„

#

why would you ever need that one

ocean tundra
#

I use get all the time

#

dont want to risk creating a system

#

as i have my own system init flow

#

and in the latest entities they made it safe to use Get in OnCreate of a system

craggy hinge
#

is there any way to draw debug lines from inside a system's ForEach loop?

#

i'm on the 2020.1 beta

ocean tundra
#

@craggy hinge Only without burst and no threading

#

So use .WithoutBurst().Run()

#

instead of schedule...

craggy hinge
#

gotcha. sort of annoying but fine for debugging I guess

#

thanks!

ocean tundra
#

yea

#

i really want a new debug tool, that will work in dots and in builds

#

but dont want to build it

#

๐Ÿ˜›

craggy hinge
#

hahaha very relatable mood

ocean tundra
#

plus lines are evil

#

why are they so hard to draw

craggy hinge
#

they're too thin. they slice your gpu all up

ocean tundra
#

haha yup thats it

storm ravine
#

Only without burst and no threading
@ocean tundra @craggy hinge You can now draw line in bursted job without any problems. Only limitation is amount of lines. And it can be expanded by Unity run arguments.

ocean tundra
#

oh sweet, thats good

humble falcon
#

Dear community. I have got a small question. Maybe I missed something, but where in Entities.ForEach do I get the jobindex. ECB.AddComponent needs three argument the jobindex, the entity and the component. The manual doesnt really help either.

storm ravine
#

Manual really help if you read it ๐Ÿ™‚

humble falcon
#

ah there it is. well I was reading only the section about the entitycommandbuffer. So basically I have to use the EntityInQueryIndex as jobIndex. Thx @storm ravine

scenic oracle
#

I have a weird behavior in Dots Physics :
When moving a character (via PhysicsVelocity), it get bumped like crazy.
This happen even using a basic sphere on a basic Plane, but not if its moving on a same-sized Box.
It seems to happen only with MeshCollider, and behave kinda like if the engine was considering every polygon ridge as a different collider or something.
Is this the intended behavior and/or what do I need to tweak to be able to walk smoothly on anything else than Sphere&BoxColliders ?

deft stump
#

how do I use the new input system in ecs?

scenic oracle
#

You need to install it from the package manager first.

#

And it will completly disable the standard input system, so make sure you are ready to update everything.

deft stump
#

@scenic oracle I'm familiar.
What I'm more concerned is implementation.
Implementing New Input System in Mono is quite easy (given that there's plethora of tutorials on it)
as for implementing it in ECS. there's none.

scenic oracle
#

Not sure what you mean.
Just extract all the values at the start of your "OnUpdate(JobHandle JobHandle)", so you have them as local variable before the "Entities.ForEach".

odd cipher
#

So currently my world is just a large texture that the player flies across, it can currently handle 1,048,576โ€ฌ tiles. Do you guys think it would be worth changing this to using Entities? Would there be any benefit and would Entities be able to handle that amount of tiles (and more)?

#

I'm pretty sure it wont be able to handle over 1,048,576โ€ฌ entities correct?

vagrant surge
#

the overhead of a million entities would be about 16+ megabytes

#

and slow everything else down a bit

#

if you do it smart tho

#

1 entity every 8x8 tiles or similar

#

then it could be alright

odd cipher
#

Yeah but I could do that with gameobjects. I don't think there would be a big difference

storm current
#

Hello, I am looking for a way to destroy child entities automatically when the parent is destroyed. The Forum posts I found are extremely outdated. Does anyone has a more current solution?

vagrant surge
#

@odd cipher ah sure, entities have much lower overhead than gameobjects

#

having a million of them isnt good, but miles better than a million gameobjects

#

which i dont even know how it even ran

odd cipher
#

I don't have one gameobject per tile that would be insane, I have one gameobject that has 1,048,576 tiles in it, through a texture.

#

using a texture means that I have a max of 8192x8192 pixels but I could fix that by just having more than 1 texture for the map.

storm ravine
#

Hello, I am looking for a way to destroy child entities automatically when the parent is destroyed. The Forum posts I found are extremely outdated. Does anyone has a more current solution?
@storm current LinkedEntityGroup. Should include entity itself and every entity which should be destroyed\created as group. Nothing changed. If you converting prefabs - it's already have LinkedEntityGroup. Otherwise - create it by yourself

odd cipher
#

@vagrant surge ^^

mint iron
#

@odd cipher i would assume loading and accessing data as entities would be slower than a simple 2d array access like you have now. Should you do it? probably comes down to if it provides some kind of acceleration for your accessing needs.

For example say you're primarily accessing a specific index pair and iterating from that point, entities would be problematic - because its split into chunks you can no longer access it by array index on the whole.

If you used SharedComponentData for grouping entities into spatial chunks you could then find the right data and iterate within that region. Then if your systems work over a subset of spatial chunks (like the current + nearest edges where they might overlap) and add components to specific entities so that they can be quickly found in ForEach queries, it could be quite clean and tidy.

But a million is still a lot..... maybe consider making larger buckets and dynamic buffers to hold whatever is inside, or use a dynamic/sparse grid approach so you don't have a fixed overhead even in areas of the world that are not being used.

storm current
#

@storm current LinkedEntityGroup. Should include entity itself and every entity which should be destroyed\created as group. Nothing changed. If you converting prefabs - it's already have LinkedEntityGroup. Otherwise - create it by yourself
@storm ravine Thanks, I will look into it ๐Ÿ™‚

odd cipher
#

Hmm, I feel like the system I currently have is good enough, All I have to do if I want to support more tiles is to divide the texture into multiple textures. For example if I have 4 textures and each go up to its maximum 8192x8192 size and the terrain sprite size is 8x8 then if my math is correct I should be able to handle 16,777,216 tiles with just 4 gameobjects. And so on

gusty comet
#

think about the data, thats the gist of data oriented design

#

don't try to morph your requirements to fit into entities or gameobjects etc

#

consider your access patterns and choose the simplest approach

#

although unity says it is performance by default, simply switching to entities won't give you any benefit if you don't think about the data

#

the big difference though, would be burst and the job system

#

which can be used outside of ecs

#

I would recommend that you try to use that to its fullest potential

odd cipher
#

Yeah, most of my game is data oriented, Everything visual with the map is essentially done with one class

And yes, I do use Burst and Jobs. With that I am able to generate a 1024x1024 (67,108,864 pixels) world in 1200ms. And a 200x200 world in 13ms

graceful mason
#

when it comes to processing data, say in an Entities.ForEach

#

If I have an unlimited amount of data, you think I could just say

#

if delta/time > X return // inside loop

#

and it can pick those jobs up another frame

safe lintel
deft stump
#

@safe lintel Oh thanks! Just what i needed!

ocean tundra
#

When inside a job (Job.WithCode) and I'm using a concurrent entity command buffer where/how do i get Job Index?

graceful mason
#

just include.... int entityInQueryIndex

#

as a parameter in the foreach

#

ah sorry I probs gfot that wrong for jobs.withCode

storm ravine
#

Why you using concurrent entity command buffer with Job.WithCode in first place

#

It's single threaded codepath (main thread if Run and any worker thread if Schedule)

ocean tundra
#

๐Ÿคฆโ€โ™‚๏ธ

#

@storm ravine Thanks, i've removed the concurrent buffer

graceful mason
#

and burstable

#

soemthing to do with[NativeDisableParallelForRestriction]

coarse turtle
#

the blockTypes?

graceful mason
#

yeah

#

its not part of the looped entitys

coarse turtle
#

You could try blockTypes.AsNativeArray() and pass it to the lambda using WithReadOnly(...)

#

to the foreach statement

graceful mason
#

Sounds good, you got an example of that? in here? .ForEach((Entity entity, int entityInQueryIndex, WithReadOnly(var blockTypes.AsNativeArray())

coarse turtle
#
var blockArray = blockTypes.AsNativeArray();

Entities.WithReadOnly(blockArray).ForEach(...);
graceful mason
#

ah okiess

#

noice

#

Thanksa

#

argh WithReadOnly requires its argument to be a local variable that is captured by the lambda expression.

coarse turtle
#

well blockArray would be a local variable

graceful mason
#

ohh user error

#

my bad

#

thanks again

gusty comet
#

is there a dots equivalent to the CharacterController component?

humble falcon
#

@gusty comet I am not aware of an already written charactercontroller component in dots. But why didn't you just write one for yourself. There are lots of tutorials out there. ๐Ÿ™‚

gusty comet
#

But why didn't you just write one for yourself.
@humble falcon i don't want to, that's why
also, all these tutorials make use of physics, which i don't want
i just want the vanilla charactercontroller in the non-dots unity

humble falcon
#

Doesn't that make writing one even easier if you dont want your character interact with physics? Well in that case I would just rewrite the standard character controller in ecs. It will not take much time anyway. Regardless you will have to write your own character controller. But maybe I am missing something and there is a prewritten component.

amber flicker
#

@gusty comet I can totally understand not wanting to write your own implementations of everything - but fair warning - working with ECS at the moment is a lot of that.

humble falcon
#

@gusty comet What is the usecase for why you want to use the standard one in ecs? You dont have to. Use ecs only if it is really usefull for your scenario. You can also only use the one from unity and if you have entities in the scene that need to track the player position, you can just do that by having an playerentity that is only tracking the position of the player gameobject.

gusty comet
#

guess i'll just use physics since there's no other way

trail burrow
#

people seem to forget that the reason you use a ready made engine is so you don't have to build all of this yourself...

frail seal
#

How do I iterate through entities within foreach job?

gusty comet
#

https://hatebin.com/zpqsqcrqeq

D:\Gamedev\Dots\Assets\_Game\Scripts\Systems\MouseLookSystem.cs(13,9): error DC0023: Entities.ForEach uses managed IComponentData MouseLook&. This is only supported when using .WithoutBurst() and .Run().
#

oh it doesn't want it if I put in MouseLook in the for each lambda

trail burrow
#

I doubt the in modifier does anything for burst

gusty comet
#

welp turns out i was wrong with tying camera to dots anyway

gusty comet
#

it seems i do need to put camera into dots because the physics will just overwrite the rotation i assign

humble falcon
#

@frail seal Please specify. I mean Entities.ForEach is already iterating through entities. Or do you mean within. If that is the case. You have to put the entities in an native container and inside the job you go through the native container.

humble falcon
#

Dear community, I am currently facing performance problems right now cause by the RenderMeshSystemV2. As you can see in the picture. Even though I am not facing any entities at all, the RenderMeshSystem seems still to go through my entities. Looking at Hybrid Renderer it should get culled, but somehow its not. The only option I have right now is removing the RenderMesh component from the entities altogether. But I am not sure if that is the right approach... I am kinda stuck right now.

craggy orbit
#

downgrading is always an option. i've gone back and forth multiple times within the same project

opaque ledge
#

Yeah there is no automatic culling afaik, you have to do it manually

humble falcon
#

@opaque ledge yeah I even made LOD Group, and the entities got culled visually, but not performance wise... it really sucks right now...

storm ravine
#

Itโ€™s not true. They culled. Frustrum culling on the place and works as expected, depends on pivot and bounding box. You can see that render thread just near to idle state. System process entities of course, because it should check if they inside frustum pyramid or not, it not happens magically, itโ€™s obvious frustum planes check. Moreover matching entities doesnโ€™t mean they all will be processed, because it not show your change/order filters. Also, side note, I guess you not enabled hybrid renderer v2 define?

humble falcon
#

@storm ravine what do you mean by hybrid renderer v2 define? Well I am using hybrid renderer v1 because my project is running on version 2019.9f

storm ravine
#

Then v2 not enabled and you using HRv1 which wasnโ€™t so good in performance. Unity improved performance on CPU (and GPU) with V2 version (require SRP 9+ and 2020.1b8+)

humble falcon
#

Oh ok so basically, It would be wise to switch to version 2020+ so that I get the performance benefits from V2 ... I was thinking about another approach. Is it possible for RendererMeshSystem to only interate through a filltered entities. So that it is not checking for all entities.

#

Because I am using a Tag right now called InvisibleTag and I put the tag to entities that are not visible. But I dont know how to access the renderermeshsystem

storm ravine
#

In v2 they added DisableRendering

humble falcon
#

Before with that tag I used to remove the RenderMesh component of an entity. Which really helps cutting performance, but I had trouble to add back the rendermesh component

storm ravine
#

You can use that for fully exclude some entities from rendering and processing temporarily

humble falcon
#

yeah I saw that component in Unity.Rendering.Hybrid. I add that component before instead of my invisibletag. But if you say it only affects v2. Than it is not working for V1

storm ravine
#

Yes

#

Well you can override render mesh, just made it local package (for prevent resetting on every editor restart) and change rm system code, itโ€™s implementation simple and editing pretty straightforward.

humble falcon
#

is there an example how to do that. Because I had trouble doing something with rendermesh.

#

ah you mean replacing rendermesh altogether. ok I will try it than.

storm ravine
#

Not replace, edit

valid atlas
#

Hey, for mmo games do we need the DOTS ?

#

Sans NPC

craggy hinge
#

hello! I'm quite new to ECS, still trying to wrap my head around some basics. say I've got a system like this:

foreach_pseudocode((in FakeComponent1 comp_1, ref FakeComponent2 comp_2) => {

  int c = comp_1.a + comp_1.b;
  comp_2.value = c;

}).schedule
``` my instinct here would be to pull c out into a higher scope so I can avoid a ton of allocations, but then I can't run this threaded since I keep modifying it (makes sense). what's the smart way to do this? do I really reallocate it every loop?
mint iron
#

structs typically aren't heap allocations so you don't have to worry about it. also, for simple statements the compiler will usually re-write it as comp_2.value = comp_1.a + comp_1.b so it literally doesn't matter if you want to separate it out for readability reasons.

coarse turtle
#

I think int c would be allocated on top of the stack and not the heap

craggy hinge
#

aha, gotcha

#

thanks!

valid atlas
#

Strings are something one should be afraid of.

#

๐Ÿฅถ

deft stump
#

so I have a new input system with dots problem.

Entities.WithoutBurst().ForEach((ref PlayerMovementData movedata) =>
{
  //this code here doesn't work
  movedata.direction.y = (upMovementControl != null &&       
    upMovementControl.wasPressedThisFrame) ? 1 : 0;

  movedata.direction.x = (rightMovementControl != null &&       
    rightMovementControl.wasPressedThisFrame) ? 1 : 0;
                    
  //while this code here works
  movedata.direction.y = (downMovementControl != null &&     
    downMovementControl.wasPressedThisFrame) ? -1 : 0;
                
  movedata.direction.x = (leftMovementControl != null &&               
    leftMovementControl.wasPressedThisFrame) ? -1 : 0;
  //why?
}).Run();
#

for context.
I'm trying to emulate the GetKeyDown() in the old input system using the directional keys with the new input system.

So I made this hacky code smell way of doing it. Where assigning the value of 1 in the component gets assigned on that frame, and then goes back to 0 on the next frame and waits for input.

In any case, the bottom pair works. but the upper pair doesn't.

storm ravine
#

Your bottom rows override top rows always, you didn't see that? No matter what values you set on top, bottom always override it to -1 or 0

deft stump
#

it works...
frick...
you're right.

#

I just commented the bottom pair

#

@storm ravine thanks thankss

dry dune
#

looks like Entites.ForEach do not support generics :|

error DC0025: Entities.ForEach cannot be used in system MySys as Entities.ForEach in generic system types are not supported.

and IJobForEachWithEntity which does support generics is marked as Obsolete

Please use Entities.ForEach or IJobChunk to schedule jobs that work on Entities. (RemovedAfter 2020-06-20)

so looks like the only way to do a generic job that iterates over entitles is to use IJobChunk or to use manual iteration

odd cipher
#

I'm not sure what I did but unity keeps crashing from one of my jobs (I think) is there a way to know what happened?

bright sentinel
#

@odd cipher You can try looking at the crash log

odd cipher
#

Yeah.. I don't think I can figure it out from that

mint iron
#

turn off burst and set a breakpoint in the job, if there's no issue and its only occuring in burst... then... yeah

#

also try load up the .dmp file from crash logs dir run debug as native and check the callstack

odd cipher
#

Right I think one problem is that I use somenativearray.GetSubArray(start, length). it seems to be really slow

#

maybe not actually.. idk

odd cipher
#

I cannot figure out why its crashing..

#

Actually. Got this "IndexOutOfRangeException: Index 640000 is out of range of '640000' Length"

#

I don't get why thats an error though

zinc plinth
#

@odd cipher max index is length - 1 >.>

odd cipher
#

I havn't had that problem before..

odd cipher
#

Still havn't been able to figure it out.. it might have to do with this csharp for (int x = 0; x < spriteSize; x++) { int pixelX = (t.x * spriteSize) + x; for (int y = 0; y < spriteSize; y++) { int pixelY = (t.y * spriteSize) + y; colors[pixelX * textureHeight + pixelY] = c[x * spriteSize + y]; } }

#

it only sets half of the texture

storm ravine
#

What you trying to do. Show full code. Because pixelX and puxelY very questionable.

graceful mason
#

If I can, should I seperate my entity, into multiple entitys? (Adding I guess overhead) e.g. BuildingMeshEntity, BuildingMeshVertsBufferEntity, BuildingMeshTrisEntity. Or I can just add all these buffers to one entity without any issues?

#

there >16032kb or whatever it is

odd cipher
#

@storm ravine alright so that loop is done per tile in a job. Itโ€™s supposed to set the tileโ€™s color array (c) onto the worlds color array (colors) but it doesnโ€™t really work correctly

outer swift
#

Should I use Mono or IL2CPP as script backend for building burst projects?

#

Just made an IL2CPP build and it performs worse than in editor

#

Leading me to believe it's not burst compiled

dull copper
#

il2cpp is the preferred option with dots

#

It shouldnt be slower at all

outer swift
#

๐Ÿ‘

#

Strange. Because it is slower

#

Probably isn't getting compiled with Burst after all

#

Profiling time!

outer swift
#

42 milliseconds waiting for something

#

But hey at least it's being burst compiled!

mint iron
#

looks like vsync waiting for frame to keep target fps

outer swift
#

Yep, but I haven't set any target FPS

#

Just vsync to every vblank

#

Let's try to set the target fps to 60, then

#

That made it worse ๐Ÿ˜„

mint iron
#

what is the issue though, you can basically ignore it, its going to sleep because it doesnt need to work...

storm ravine
#

@storm ravine alright so that loop is done per tile in a job. Itโ€™s supposed to set the tileโ€™s color array (c) onto the worlds color array (colors) but it doesnโ€™t really work correctly
@odd cipher show code. That loop looks fine, your t.x/y is your tile offset in global โ€˜colorโ€™ array and you set it, need to see your setup, and exact error from console

#

what is the issue though, you can basically ignore it, its going to sleep because it doesnt need to work...
@mint iron not when it become 15fps and 60ms ๐Ÿ™‚

mint iron
#

help me understand here ๐Ÿ˜„

#

if your frame is taking 15ms, then its going to wait for 45ms doing nothing.

#

why is that bad?

deft stump
#

maybe it's a rendering issue

storm ravine
#

if your frame is taking 15ms, then its going to wait for 45ms doing nothing.
@mint iron look at his profiler, if it 30-60fps limit that fine, but as you can see - it drop frame-rate to 15FPS and that absolutely not fine ๐Ÿ™‚

mint iron
#

ahh yep. thnx, i see now.

storm ravine
#

@outer swift that build profiling? In editor all works fine?

outer swift
#

@storm ravine That's build profiling, editor looks fine to me. 10ms idle until render, which looks about right

storm ravine
#

Itโ€™s not idle itโ€™s editor overhead, your frame timing ~4ms which is ~250fps

#

If you disable vsync for build does it change fps?

#

Because in build your PlayerLoop timing definitely should be better than editor

verbal pewter
#

Hey all, I worked through the NetCode "Getting Started" example and am having issues getting things to display. When I open the Entity Debugger I see that there are two worlds, DefaultWorld and ClientWorld0. There are no entities in DefaultWorld, they're all in ClientWorld0. The thing is... I don't see any entities in the game view. I have a top-down camera for testing right now. Am I missing something?

#

Does this have something to do with the camera rendering DefaultWorld instead of ClientWorld0 or something?

outer swift
#

@storm ravine I tried with vsync and no target framerate, I tried with vsync and target framerate of 60 and finally no vsync and unlocked framerate. All performed equally bad. The worst was no vsync and unlocked framerate, which would occasionally take 100ms per frame

storm ravine
#

Looking for screenshots from thread it feels like you GPU bound... what happens on screen which give you this profiling data?

outer swift
#

Not much. 100,000 cubes with unlit material.

#

I have no problem rendering scenes with millions of polygons across throusands of objects in other projects.

#

My specs:

  • Ryzen 2600x
  • 16GB DDR4 PC-3200
  • AMD RX580 8GB
  • Project running off Samsung 970Pro M2 SSD in a 4x M2 slot
wide fiber
#

Guys I am trying to create a game using Unity Tiny, I have installed the package (0.25.0) but I don't have a create tiny project button

vagrant surge
#

@wide fiber its not possible to create a unity tiny project easily

#

the recomended workflow is that you clone one of the samples and start from there

hollow sorrel
#

@outer swift does the gpu profiling section say anything during build version?

outer swift
hollow sorrel
#

@outer swift try disabling graphics jobs in player settings

#

i think it only works without

outer swift
#

But how come it works fine in editor?

#

Are builds and editor literally running different code?

hollow sorrel
#

maybe graphics jobs aren

#

't used in editor

#

but not sure

cursive osprey
#

I'm getting above 300 fps on windows platform but, when I test my game on a phone I'm getting max 10 fps does anyone know why?

wide fiber
#

@vagrant surge ok ty

deft stump
#

what's the best approach to do gird movement (like Megaman Battle Network) in dots?

ocean tundra
#

@deft stump I would probably make a int3 position component which then updates the Translation component with int3Pos.x * tile size

#

then all your position changes go into the int3 one

#

but translation and all dependant systems continue to work fine

deft stump
#

Where do i put the check if the tile is for the player to move in or not?
Do i make a component for that?

ocean tundra
#

probably do that before you update int3 position

#

which is <int2, bool> (position, walkable)

#

then you just need to check if map point is walkable

humble falcon
#

Does anyone know the right and updated approach to do animations? So I have a 3D Model which has an Idle animation. Obviously in dots I can't simply use the Animator. How do I than achieve my goal, just making my entity doing its idle animation.

ocean tundra
#

so theres 2 approaches I've seen

#

1 is use Unity.Animation, its still VERY alpha but had a update recently

#
  1. Do it yourself ๐Ÿ˜›
#

i've copied this from someone a few days ago:

I have a script adapted from GitHub + shader for GPU animations.
The requirement for the device was ES 3.0+ (to extract Vertex ID: SV_VertexID) and animations must be of type "Generic"
A bit dirty code, in a hurry, removed the part of custom rendering...

The shader has 2 uv channels, a color map is stored in the second channel.
"_BaseColor" - the color of the repainted part is superimposed on the second channel, you can delete it if you do not need to.
In the comments I tried to note this

Shader - https://pastebin.com/yfx4RsMc
Animation asset - https://pastebin.com/QD9U7Nn6
AnimMapBaker (EditorWindow) - https://pastebin.com/UP3M3Xan
AnimMapBaker (Main part) - https://pastebin.com/Kz51pkfh

#

personally when i start with animations im going to try to use Unity.Animation

humble falcon
#

mhm so there is really no straightforward simple solution to do that... Ok I will look into Unity.Animation than.

ocean tundra
#

let me know how it goes

#

main issue is no docs

outer swift
#

Extremely stealing that code

humble falcon
#

ugh those are the ones I hate the most. No docs. So basically error and trial than ๐Ÿ˜ซ

ocean tundra
#

heres some examples but theres a new animation update

outer swift
#

I'm already having fun writing physics, collision and camera code from scratch ๐Ÿ˜„

ocean tundra
#

@outer swift Theres Unity.Physics which also has collision bits

outer swift
#

I know, but last I checked it was slower than my implementation.

#

I don't need anything complicated.

ocean tundra
#

yea makes sense

#

all i need is the collisions bit

#

i eventually plan to rip that out from the sim bit

outer swift
#

Then again, I haven't checked in a very long time, so it might have picked up. But I remember it having some ridiculously uneven performance even on a small number of bodies.

#

Anyway my experimental DOTS game is essentially a 2D top-down game using 3D art, so I can use 2D colliders and that's what I intend to do.

ocean tundra
#

yea smart

outer swift
#

It definitely doesn't look like DOTS is ready for anything complex, so to avoid snagging on obvious missing bits and being able to focus on learning design patterns and figuring out an architecture for handling a game in DOTS, I'm just aiming way low.

ocean tundra
#

yea i agree with that

#

but i love to go big

#

๐Ÿ˜›

outer swift
#

I love doing things alone

#

Big is orthogonal to alone

ocean tundra
#

yup

#

but im having tons of fun

outer swift
#

Especially since I suffer from a serious case of I don't like this API

#

Which inevitably leads to me implementing my own

#

Like Unity's filthy goddamn event-based collision

ocean tundra
#

yea i have decided no reimplementing things unless i 150% need it

outer swift
#

I value my sanity, so instead of wrapping Unity's collisions I just wrote my own simple SAT implementation

#

After I realized that "oh I can't actually rely on collision events to fire" I decided that nope

#

"Why isn't OnColliderStay firing?"

#

"Why isn't the collider interacting with the trigger?"

#

"Why does the rigidbody change the behaviour of the collider?"

#

rabbit holes ahoy, and I prefer to fly rather than dig

ocean tundra
#

yea all those were so annoying

outer swift
#

Plus I hate the goddamn physics.

#

Why is it async?

ocean tundra
#

i think thats why i like DOTS so much, all the code is there for us to look at, and change if we really need to

outer swift
#

So the idea of doing the things I need doing (procedural IK and soft body physics) with Unity's PhysX implementation constantly acting up ...

#

... nahhh

#

Yes, it really cuts to the bone of why I like Unity: It's a Make Your Own Engine framework

analog horizon
#

After upgrading my project's ECS package from preview 15 0.9.1 to preview.6 0.10.0, I've been having this error pop up once for every GameObjectEntity in a scene after performing scene reload or level change. It doesn't seem to be breaking anything. Rolling back to preview 15 0.9.1 fixed this, is there a better way to go about scene reloading that will avoid this issue? If not, how/where should I report this issue?


//This is the code used to reload the scene
 public static void ReloadScene()
        {
            instance.StartCoroutine(RestartEntityWorld());
            Debug.Log("Loading scene");
            SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
            Debug.Log("Scene loaded");
        }

        private static IEnumerator RestartEntityWorld()
        {
            Debug.Log("Wating for end of frame");
            yield return new WaitForEndOfFrame();
            Debug.Log("Frame complete");
            World.DisposeAllWorlds();
            Debug.Log("Worlds disposed");
            DefaultWorldInitialization.Initialize("Default World", false);
            Debug.Log("Worlds reinitialized");
        }


ocean tundra
#

so.... wont that reload code load the scene first then dispose and recreate worlds

#

idea 1, dont dispose all worlds, just save and dispose the main world

#

as theres some magic worlds created via unity for loading/conversion

#

idea 2, dont use scenes and instead use sub scenes

#

i will add i dont feel subscenes are ready yet

#

i've tried to use them and hated it

analog horizon
#

Yeah in theory it should destroy and then reload all systems. I think your first idea for saving the worlds initial state as a seperate world would work well with my current set up (better atleast then sub scenes lol)

ocean tundra
#

yea thats what i do

#

i manually create my worlds

#

do some custom init stuff

#

and update / destroy them as needed

analog horizon
#

Ahh does that let you add and modify individual systems?

ocean tundra
#

yea

#

that DefaultWorldInitialization has a get all systems method

#

or something like that

#

2 sec ill find the code

analog horizon
#

Interesting! I would love to see that actually haha

#

I imagine that that would be how I would copy the starting state

ocean tundra
#

how do you post code :/

analog horizon
#

oh I saw it for a sec there lol

ocean tundra
#

ty

#
var world = new World("Server");
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default, false);
var filteredSystems =
            systems.Where(x =>
            { //CUSTOM FILTERING!!!!
            
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, filteredSystems.ToArray());
analog horizon
#

Oooo

ocean tundra
#

the catch with this approch is i dont have my world auto added to the update loop

#

so i have to call world.update manually

#

but thats something i want

analog horizon
#

Huh where do you call it from?

ocean tundra
#

a monobehaviour Update

analog horizon
#

I've been wondering when the main Update is being call compared to the Mono update

ocean tundra
#

๐Ÿ˜›

analog horizon
#

Oh cool lol

#

I think that will work!

#

One last question

#

When are GameObjectEntities loaded into the world? and how do I make sure they get loaded into the startingWorld?

ocean tundra
#

Oooo interesting question...

#

so i dont use those

#

but that new world you could set to World.Default injection world

#

then load your scene

#

that has all the GameObjectEntities

analog horizon
#

Aw dang, do you use authored components?

#

Ooh yeah and then just copy from default without running any systems

ocean tundra
#

i use the conversion flow hard, all my prefabs are converted just after that world creation code and i create them as needed

analog horizon
#

I should be doing that but I'm too lazy lol

#

I'll go with copying from the default world

ocean tundra
#

if you replace world.Default.... the GameObejctEntities should go right into your world

analog horizon
#

Yeah exactly!

#

Thanks a lot for the help :)

ocean tundra
#

all good

#

oh

#

one last issue

analog horizon
#

ye?

ocean tundra
#

custom worlds that are manually updated DONT show in the DOTS tools correctly

#

the systems dont show ๐Ÿ˜ฆ

#

its annoying but i can work around it

#

the entities still show

analog horizon
#

Oh shoot, like in the analysis tool?

ocean tundra
#

yea

analog horizon
#

Oh phew, thats not too big of a deal for my current workflow

#

but still kinda annoying

#

I swear there was a drop down to select the monitored world at some point

ocean tundra
#

yea its just annoying

#

they are working on it

#

there is

#

and it works with the custom world

#

but the systems just dont show unless you use the default update

#

but you can grab that from the DefaultWorldInitialization somewhere

analog horizon
#

Mm okay yeah that makes sense

ocean tundra
#

but if you do that dont manually update

analog horizon
#

This might sound weird, but could you use the default world Update to update system from another world?

ocean tundra
#

probably

#

i kinda do that too

#

i make a few extra system groups

#

and update those at different frequencys compared to the main default groups

#

you just call Group.Update

analog horizon
#

Ooo intresting like a LowPriorityUpdateGroup that's only called X amount of frames or something?

ocean tundra
#

exactly that

#

๐Ÿ˜›

analog horizon
#

Damn thats clever haha

ocean tundra
#

thanks

#

and i have things like my server only updating in FixedUpdate

#

and some systems updating in normal update at X frames

#

ect

analog horizon
#

Heh I might need to steal that thats great lol

ocean tundra
#

also adding a custom world to default update is super easy ( ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world); )

analog horizon
#

I wonder if it would be better to update your server on a seperate thread instead of fixedupdate because of the jankyness that is how untiy handles fixedupdates lol

#

Oh sweet!

ocean tundra
#

i read up on ity

#

havnt tried yet

#

but looks like there are issues with that

#

something around job scheduling from another thread

analog horizon
#

but a persistent thread or something, thats well above my head lol

ocean tundra
#

yea

#

lower frequency is good enough for me for now

#

if running a whole world completly in a background thread becomes stable ill jump at it

#

but i expect it to be way down the todo list

#

if at all

analog horizon
#

That'll be neat if/when we can do that

#

yea exactly, fixedupdates probably good enough for the majority of cases

ocean tundra
#

yup

#

all the world Initialize stuff is public in those classes above

#

so you can always steal the bits you need