#archived-dots

1 messages · Page 117 of 1

vagrant surge
spring hare
#

Oh wait so it’s an array with holes implementation like from that one that bitsquid blog?

vagrant surge
#

its stronger

#

but yeah its array with holes

#

you insert something, and it gives you a handle (for when you want to delete it). But the pointer never changes

spring hare
#

Does it use a bitfield for free list indices?

vagrant surge
#

its a freelist too, but does bitfield to speed for the jumps

spring hare
#

And I imagine to keep iteration from reading data wrong or writing to the free indices

vagrant surge
#

extremelly useful when making graphs. You allocate the nodes on this thingy, and then connect nodes to each other through normal pointers

spring hare
#

I wonder if that would be good for smaller pathfinding grids

vagrant surge
#

for small, pushing the nodes on a dumb array and keeping indexes is easier

spring hare
#

Being able to iterate with consistent striding but also skipping big areas of nothing could be nice

vagrant surge
#

i wonder if unity has something similar to this on the NativeStuffs

spring hare
#

Could probably make one using native arrays at least

#

What I’d really love to see from Unity is opening up our ability to do allocating

#

Like a small allocation slab system and a large allocation buddy system would be amazing

#

We kinda have void pointers now via some of their extension stuff

mint iron
#

i havent heard of such things, how is it more useful than malloc'ing stuff

spring hare
#

More specialized, so better in some cases and worse in others

#

Stack, slab, pool, free list, ring, buddy, there are just a lot of different allocation methods and it’s really case specific whether you’ll get more out of one than another

vagrant surge
#

@mint iron frame-based allocations

#

you could have an allocator that just autoresets every frame

#

the idea being that whenever you need "temporal" allocations, like to do an algorithm, you use this thing

#

allocating is literally doing ptr += alloc size

#

deallocating is "ptr = 0"

spring hare
#

Slab allocation is great for specific sizes of allocation you know you’ll be using a lot of, and that you’ll be using the entirety of, and (among slabs) that you don’t care about the fragmentation of.

vagrant surge
#

once you try going into the more complex ones, it kinda stops being useful

#

well, ECS uses a pool allocator for the chunks

#

thats why all the same size

spring hare
#

Makes sense

#

Buddy allocation is a nice compromise for large allocations of varying sizes

#

And benefits from no external fragmentation

#

Meaning you just have one big reserved allocation, and keep splitting it. And it may get internally fragmented, but it won’t mess with the rest of the heap

#

And any time two adjacent blocks become free, you merge them into a bigger one

#

Keeping internal fragmentation generally pretty low

mint iron
#

As i understand it some system has given you a ptr and promised a size from that onwards is yours to mess with. When you free it, said system knows that area is available to be given to someone else. that correct?

spring hare
#

Yeah, any allocator is just a system for reserving some number of bytes and then freeing those bytes again for another reservation

#

And yeah, by that metric if you’re doing stuff within an array you’re kind of using an allocator

mint iron
#

so are those things you're talking about - pool, freelist, ring etc are a layer on top; ie. reserve a large piece, and build your own system to distribute smaller pieces of it more intelligently?

spring hare
#

Yes and no. They are very often used to reserve the space within which you’ll be placing and organizing data with additional structure, but you can use them for whatever

#

Same could be said about arrays

#

Or a byte

#

“I need to store some information, where do I put it and what happens to the location when I’m done?”

#

Is about the size of it

mint iron
#

ok, i guess where i'm confused is that i've put all sorts of crazy containers on a space i've used malloc to acquire. And im not sure if thats the level you're talking about, or if these allocation systems are lower level than that like windows core level.

spring hare
#

It is the same level

#

Really we just have one block of memory, and the OS is already doing something with some of it, so we get some memory through the OS and do...something with it

#

Any time you have something you put somewhere in memory, that’s memory management

#

Static variables are memory management, you know exactly what they are and where they need to go and that will never change

mint iron
#

ty i appreciate your patience 😄

spring hare
#

A C# list is memory management, you’re using some but not all of an array and then you might use more so you get a bigger array

#

You want to get memory to store your information, you want that memory fast, you want it close to memory you’ll access with it or right before or after it, and then you want to get rid of it fast when you’re done and make sure that it’s usable when you need it again. And you want to make sure you’re not fragmenting memory so that the effective space you have to work with is less than the total space

#

There is only so far you can get trying to get all of these things at once in one solution built for every use case, so to get better performance you use memory allocation strategies that fit your use cases

mint iron
#

that makes sense. when i try to find info on what malloc does all i can seem to find it what its used for and how it operates. Also i know this is totaly not he place for this sort of discussion 😄 but yeah, its kinda frustrating i don't know where to learn this.

#

ahh nvm "malloc is part of the standard library and is declared in the stdlib.h"

spring hare
#

Malloc uses allocation dependent on the OS, unless someone overloads it haha

#

Getting memory from the OS has extra expenses

#

But fundamentally it’s doing the same stuff

slim nebula
#

whats the correct way to fix this:

#

it happens when I update unity

#

first time it happened, I removed havok physics and added unity physics. and that fixed it

#

but this update I remove unity physics and re-add it and the errors are still there

#

any ideas?

mint iron
#

it might be that the newer package requires a newer version of the editor; burst was particularly bad for that sort of thing.

foggy tree
#

Or what is the current proper way to mark a component as readOnly in IJobForEachWithEntity?

#

Nevermind, I found it.

slim nebula
#

I updated all my packages before that screenshot. maybe they havn't quite updated it all yet on package manager

dull copper
#

@slim nebula can you show a screnshot of your package manager for tab "In project"?

#

also, do mention which Unity version you are using

opaque ledge
#

okay so i have this piece of code in a MB

#
        var recruitmentFleet = entityManager.GetBuffer<FleetRecruitmentReserveBuffer>(data.entity);
        var playerFleetBuffer = entityManager.GetBuffer<OwnedFleet>(CampaignManagerMono.instance.campaignPlayerEntity);
        var playerFleet = playerFleetBuffer.ToNativeArray(Allocator.Temp);
        for (int i = 0; i < recruitmentFleet.Length; i++)
        {
            var recruit = recruitmentFleet[i];
            var index = playerFleet.IndexOf(recruit.ID);
            if (index >= 0)
            {
                var playerShip = playerFleet[index];
                playerShip.Amount += recruit.amount;
                playerFleet[index] = playerShip;
            }
            else
            {
                playerFleetBuffer.Add(new OwnedFleet { ID = recruit.ID, Amount = recruit.amount });
            }
        }
        playerFleetBuffer.Clear();
        recruitmentFleet.Clear();
        playerFleetBuffer.AddRange(playerFleet);
#

What does this do is, this is called by the button in UI. Basically player recruits ships from the station

#

if i do AsNativeArray, instead of ToNativeArray in playerFleet, it gives me error saying that this native array has been deallocated

#

I was just wondering why would it be like that

bright sentinel
#

"You can only access the native array as long as the the buffer memory has not been reallocated. Several dynamic buffer operations, such as Add(T) and TrimExcess() can result in buffer reallocation." from the docs

#

@opaque ledge So the AsNativeArray is a reference to the same data that the buffer is referencing, while ToNativeArray makes a copy of the data

#

And changing the buffer will break the reference that AsNativeArray gives you

junior fjord
#

I have a Component CreateMesh which I add to some entities. Then some systems run over these entities and do stuff. Afterwards I just want to remove the component from all the entities that have it, the best would be if that would happen without copying them around

#

is that posssible?

bright sentinel
#

In your system that runs over them, just delete them with the EntityCommandBuffer

junior fjord
#

wouldn't that copy each entity one by one from one chunk to another?

#

or does it realize that the whole chunk just lost that component?

bright sentinel
#

Hm, I'm not sure if you can do structural changes without copying

#

Maybe some chunk job can help you, but I haven't used them before

#

Ah yeah

#

Oh, nvm

#

"Although chunk components can have values unique to an individual chunk, they are still part of the archetype of the entities in the chunk. Therefore, if you remove a chunk component from an entity, ECS moves that entity to a different chunk (possibly a new one)"

junior fjord
#

yeah I also just read that

warped trail
#

there is this method in EntityManager and command buffer cs .RemoveComponent<T>(EntityQuery entityQuery); 🤔

#

my bet that this is the one of the fastest way to remove component from a lot of entities🤔

opaque ledge
#

ah i see thanks, i guess adding to buffer causes that

junior fjord
#

does anyone see why this

Entities
            .WithName("RemoveCreateComponent")
            .WithAll<CreateMesh>()
            .ForEach((ref Entity e, int entityInQueryIndex) =>
                {
                    commandBuffer.RemoveComponent<CreateMesh>(entityInQueryIndex, e);
                })
            .WithoutBurst()
            .Run();

gives me invalid ForEach signature?

#

@warped trail oh and thanks for the suggestion

warped trail
#

do just Entity e

#

without ref

junior fjord
#

ah ok yeah

#

but your above suggestion is even better

warped trail
#

You can do this and continue working with your createMesh, maybe some other systems will want this component too and you will be sure that next frame all this components will be removed 😅 👍 ```cs
BeginInitializationEntityCommandBufferSystem m_StartOfNextFrame;
protected override void OnUpdate()
{
var commandBuffer = m_StartOfNextFrame.CreateCommandBuffer();
commandBuffer.RemoveComponent<CreateMesh>(queryWithCreateMesh);
}

junior fjord
#

oh thats also a good tip

junior fjord
#

is there anyway to make a const size array global?

#

I just want to add a global to my Globals class that is a 6-element int2 array (known at compile time)

round summit
#

Hmm, what's the simplest way of doing this in dots?

void Deactivate(){
  rb.isKinematic = true;
  collider.enabled = false;
}
void Activate(){
  rb.isKinematic = false;
  collider.enabled = true;
}
vagrant surge
#

likely removing the phyics component

warped trail
#

to change body from dynamic to kinematic you can simply change PhysicsMass

round summit
#

inverse physics mass i think

warped trail
#

just look at PhysicsComponents.cs

slim nebula
#

@dull copper as requested

#

there's more checkboxes under "all packages" that dont show up in "in project"

#

I think that's everything

dull copper
#

yeah, those should be up-to-date

slim nebula
#

oh sorry the unity version is 2019.3.4f1

junior fjord
#

Does anyone know a better version of this that can be used in jobs:

    public void neighborValues(NativeArray<T> ret, int2 loc, T offMapValue)
    {
        var neighborOffsets = new NativeArray<int2>(6, Allocator.Temp);
        neighborOffsets[0] = new int2(0, 1);
        neighborOffsets[1] = new int2(1, 0);
        neighborOffsets[2] = new int2(1, -1);
        neighborOffsets[3] = new int2(0, -1);
        neighborOffsets[4] = new int2(-1, 0);
        neighborOffsets[5] = new int2(-1, 1);
        //..do stuff with neighborOffsets..
        neighborOffsets.Dispose();
    }

neighborOffsets is a simple, 6 element, always constant array which I need in that function

coarse turtle
#

fixedlist?

junior fjord
#

an alternative would be to have it as a static and always mark it as readonly and pass it into the function

#

but that also seems utterly complicated for a global all-game constant

coarse turtle
#

Oh - if you want to use that - you can the SharedStatic<> option in the BurstCompiler

#

hmm but I guess you want immutable 🤔

#

otherwise maybe an entity with a FixedList or a BlobAssetReference to a struct w/ BlobArray and you pass that into jobs

junior fjord
#

yeah thanks, that looks interesting but I do not need mutability

#

But is that really the simplest solution? I mean I can have global const variables, and as soon as I want a global const fixed-size small array I have to always pass that into the function?

#

FixedList is some new kind of small arrays that can be inside of structs/components?

coarse turtle
#

yeah

#

maybe a static pointer that's readonly and you access that in jobs

south falcon
#

Have your guys update Entities to 0.7.0? There is a error about burst.

coarse turtle
#

Not sure - but I remember seeing a few messages here about that - you might have to scroll up to take a look

#

@south falcon

south falcon
junior fjord
#

yeah there was a lot of discussion about that earlier I think

#

but I didn't have the problem so I didn't follow

#

and thanks @coarse turtle

warped trail
#

i don't have this errors🤔

south falcon
#

Are you using unity dots physics?

warped trail
#

yes

south falcon
#

That's confusing

warped trail
#

i remember there were some errors, but then i deleted Library folder and errors were gone

south falcon
#

I have tried deleted library, but error still

warped trail
#

if i'm not mistaken it is the recomended thing to do, if you upgrading your Burst package🤔

south falcon
#

Now I am trying to downgrade everything 😂

warped trail
south falcon
#

@warped trail What is your Unity verision? 2019.3.4?

warped trail
#

2020

south falcon
#

🤔

formal scaffold
#

Is it possible to use SystemBase for everything? Does it replace the JobComponentSystem? I don't have InputDeps.

warped trail
#

Dependency is new InputDeps

opaque ledge
#

yes, JobHandle is Dependency property now

formal scaffold
#

Oh great so full SystemBase then

fallow mason
#

Is 2020 now the latest version of Unity with respect to DOTS (and other preview/experimental packages)? I remember someone from Unity saying once that 2020 alphas didn't have a lot of the stuff 2019 betas did.

warped trail
#

next Hybrid Renderer will require 2020🤔

half cedar
#

Does ecs and the hybrid renderer work with URP?

warped trail
#

it kinda works😅

half cedar
#

kinda works is good enough for me!

warped trail
#

just turn of SRP batcher

half cedar
#

thanks

opaque ledge
#

there are many burst/job related improvements in 2020, but not any differences between packages

#

you can read alpha's last release notes if you want to know

fallow mason
#

Haha better be. "Kinda works" the DOTS M.O. right now

warped trail
#

why there is no beta now?

fallow mason
#

Hmm ok. I'll give 2020 a shot tonight.

opaque ledge
#

ikr Druid, i think its something with 2 tech releases per year

warped trail
#

and iteration times are killing me. Create script file wait for 10 seconds to compile, then 6 seconds to reload, press play and there is another 4-5 second to update scene for what ever reason after first Entity instantiation🤬

opaque ledge
#

did you disable domain reload ?

#

that kinda helps with play mode

warped trail
#

of course i disable domain reload

#

and i like this new feature with timer, it shows exactly how slow things are😂

opaque ledge
#

maybe something to do with closing subscenes ? i had something like that, i forgot to take subscene out of edit mode so it was taking like 12-13 seconds everytime i went in play mode

#

its taking 1 second now

#

Tho i destroyed my subscene, it.. isnt really useful for me

warped trail
#

going into play mode is very fast

opaque ledge
#

ah, nothing you can do about recompiling except asmdef, which i really dont know how to setup

slim nebula
#

I'm creating some entities programatically. how do I set the equivilant of Transform.Parent on the entity? I dont see any field on LocalToWorld there...
[EDIT] disregard, I found the Parent component to add to my entity

junior fjord
#

Note: Currently, the ISharedComponentData interface allows fields having reference types. However, we plan to restrict ISharedComponentData to unmanaged, blittable types only in a future version of the Entities package.
Does that mean no NativeArray in ISharedComponentData in the future?

opaque ledge
#

Yep

#

NativeArray is not a blittable type

junior fjord
#

ok so shared NativeArrays should rather go to static global classes for example?

#

well that is what I am doing 90% of the time anyways 😄

opaque ledge
#

oh yeah you talked about a constant global array access right ?

#

have you checked shared statics ?

coarse turtle
#

Well - i think native array will still have those safety checks (disposal sentinel) - but you could easily swap it with your own unsafe implementation

#

unless they removed that recently 🤔

junior fjord
#

@opaque ledge yeah, I checked them since @coarse turtle also recommended them but at a first glance they also seemed like an overkill (and also not readonly)

#

but maybe I'll check them again tomorrow

slim nebula
#

can someone help me. I'm trying to programatically create a child entity. and I just dont know what APIs to call. Is there some example somewwhere? My problem is that my prefab has a prefab. When I instantiate the top level prefab, the child prefabs aren't being instantiated. I'm not sure what I"m doing wrong 😦

#
[UpdateInGroup(typeof(ServerSimulationSystemGroup))]
public class GoInGameServerSystem : ComponentSystem
{
    protected override void OnUpdate()
    {
        Entities.WithNone<SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
        {
            PostUpdateCommands.AddComponent<NetworkStreamInGame>(reqSrc.SourceConnection);
            UnityEngine.Debug.Log($"Server setting connection {EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value} to in game");

            var ghostCollection = GetSingleton<GhostPrefabCollectionComponent>();
            var ghostId = ContinuanceFaultGhostSerializerCollection.FindGhostType<PredictedPlayerSnapshotData>();
            var prefab = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection.serverPrefabs)[ghostId].Value;
            var player = EntityManager.Instantiate(prefab);

            EntityManager.SetComponentData(player, new MovablePlayerComponent { PlayerId = EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value });
            PostUpdateCommands.AddBuffer<PlayerInput>(player);

            PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent { targetEntity = player });

            PostUpdateCommands.DestroyEntity(reqEnt);
        });
    }
}```
#

^this is basically a copy of the sample

#
[DisallowMultipleComponent]
[RequiresEntityConversion]
public class MovablePlayerComponentAuthoring : MonoBehaviour, IConvertGameObjectToEntity, IDeclareReferencedPrefabs
{
    public int PlayerId;
    public GameObject PredictedObject;
    public GameObject RubberObject;

    // Lets you convert the editor data representation to the entity optimal runtime representation
    public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    {
        dstManager.AddComponentData(entity, new MovablePlayerComponent
        {
            PlayerId = PlayerId,
            //RubberBandingData = new List<RubberBandingData>(),
            //HistoricalPositionData = new Dictionary<uint, HistoricalTranslationRotationData>(),
        });

        var prefab = conversionSystem.GetPrimaryEntity(PredictedObject);
        dstManager.SetName(prefab, $"Primary {dstManager.GetName(entity)}");
        dstManager.AddComponentData(prefab, new Parent { Value = entity });
        //var predictedEntity = dstManager.Instantiate(prefab);
        //dstManager.SetName(predictedEntity, $"Debug {dstManager.GetName(entity)}");

        //dstManager.AddComponentData(predictedEntity, new Parent { Value = entity });
        //dstManager.AddComponentData(entity, new Parent { Value = predictedEntity });

        //conversionSystem.DeclareLinkedEntityGroup(PredictedObject);
    }

    public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
    {
        referencedPrefabs.Add(PredictedObject);
    }
}```
#

^ I'm not sure what I can do here to make sure PredictedObject gets instantiated when my ghost is instantiated

#

I'd prefer not to instantiate all child objects in the GoInGameServerSystem

#

I feel that MovablePlayerComponentAuthoring should author the MovablePlayerComponent children

#

I've spent hours on this looking up tutorials and I"m totally confused and lost.

opaque ledge
#

@junior fjord at first i thought the same 😄 the example in documentation might seem like an overkill but its just a matter of copy/paste 😄 and dont care about not being read only imo, its a quick way to reach some info that you set in MB that you want to use it in bursted jobs, they are quite useful, i use it for all kinds of stuff, especailly for Random(so whole game will use this random) and some other info that could be hard to describe with component datas and buffers.

#

I dont know about the performance however, never had a time to test it tbh

slim nebula
#

I did it!

#
        var leg = dstManager.AddBuffer<LinkedEntityGroup>(entity);
        leg.Add(new LinkedEntityGroup { Value = entity });
        leg.Add(new LinkedEntityGroup { Value = prefab });
#

yeetsus

gusty comet
#

is netcode good enough for mmorpg yet

lusty otter
#

Never remembered to ask, for each frame, does Update in MB happen first or OnUpdate in SystemBase?

warped trail
#

@lusty otter i think mb's Update runs before simulation group and LateUpdate runs after simulation group and before presentation group

lusty otter
#

Thanks!

gusty comet
#

netcode isn't good enough for anything yet

#

not surprising considering it is a alpha/beta/gamma release

bright sentinel
#

@lusty otter With the EntityDebugger, you can show the full player loop to get the whole picture of where ECS fits in.

viral sonnet
#

@gusty comet Eh, I wouldn't say it that drastic. It's good enough for what it's made for.

#

but it's certainly not made for MMOs

gusty comet
#

it was made for a demo... 😄

bright sentinel
#

It's a bit more complicated, the demo was made to show it off.
Netcode is currently just made for FPS games though

#

So no MMO support yet

safe lintel
#

I doubt unity will make a specific mmo implementation for netcode, i think rts is on their list though

bright sentinel
#

FPS, RTS and fighting is the current plan

silver dragon
#

Any idea why the breakpoint on continue hits but the output on the right says the entities are different?

#

Hm, seems Rider is messing up my breakpoints...

#

Never seen this...

opaque ledge
#

If you are doing it on parallel job there will be some issues

silver dragon
#

Even if burst is disabled?

opaque ledge
#

yeah probably

#

since there is no determinism between what thread will finish first, it might show you info from multiple threads

silver dragon
#

Shouldn't be the case as there is only one entity the system processes (for debugging purposes). Anyway, will have a look at the vid, thx for the link!

vagrant surge
#

oh hey Tiny 2D

dull copper
#

yeah, it arrived last week

#

2d physics + sprites

bright sentinel
#

Ooo, anyone got a link?

vagrant surge
#

@bright sentinel tiny forum

dull copper
#

docs should be in the pinned

#

same with project tiny examples repo

#

that repo got two new examples to demonstrate 2D features

#

that webasm build was nicely tiny

#

2.5 megs for the match-3

vagrant surge
#

we also have a direct comparaison

#

tiny match3 vs entitas match3

amber flicker
#

how do they compare out of curiosity? or is there a comparison written up somewhere?

dull copper
#

I'd guess that the other has decent editor tooling 😄

zenith wyvern
#

It's wild that you can make a Unity exe below 10 MB now

coarse turtle
#

Yeah - i wonder if they're also going to have addressables integration

remote coyote
#

I guess I need to set target texture and panel transform?

#

I didn't see them do that in the UI Builder video

opaque ledge
#

@remote coyote add defaultUSS to stylesheet list

#

and yes you should set panel transform as well

#

not sure what target texture does but i didnt use it and it works well

#

also disable enable live update imo, right now that takes too much time when going to play mode

mystic mountain
#

@remote coyote not correct channel for this question, but you don't need to set panel transform or target texture 😉 What you've done wrong is to set your style sheet as the "Unity Style Sheet", which should be the Default.uss. Yours will be imported automagically.

remote coyote
#

ah

#

ty guys

#

and totes forgot this is not dots related, sorry!

safe lintel
#

anyone getting assertion errors when using Mesh as the physics shape type in the editor? I dont really recall this happening before but if you make a blank project with the phys package(and auto dependencies) and just test it out, it errors constantly 🤷

remote coyote
#

ah that was it, thanks CyrlyOne and Jaws! My heroes this evening!

slim nebula
#

what the heck is going on with deltatime vs actual physics simulation time

#

if I set the top value to 0.2, then my Time.DeltaTime is still 0.016666, but it changes the physics processing to perform 0.2 worth of physics

#

the result is that shit is moving 20x faster than the code is expecting

#

Should I just not use deltaTime? what should I be using?

#

or how do I configure the physics to behave

#

even now it's set to 0.01, but I'm getting 0.0166 deltaTime values

#

does the physics engine just not process a physics frame until enough time has elapsed?

zenith wyvern
#

You want UnityEngine.Time.fixedDeltaTime

slim nebula
#

ok I will try that, thanks

#

is there something I have to do to get my system to update on fixed frames instead of delta frames? (if that makes sense)

#

UnityEngine.Time.fixedDeltaTime seems to never be different than 0.01, but the system is being called every ~0.016 seconds still, so it's still desynched

#

do I just track the difference myself? do additional frames or skip a frame if needed? or is there some mechanism built in that I can use?

#

im so confused

#

am I not using UNITY_DOTSPLAYER ?

#

aha standalone dots vs hybrid

#

still not sure how it's magically doing more steps when needed

#

2 frames would be 0.032, which should mean 3 physics frames

#

DOTSSample does not appear to use fixedDeltaTime

#

which I guess is fine because their player controllers only interact with static objects 😩

#

this sample is such a hack job at every turn

slim nebula
#

oooooooo this looks promising

#

thanks sark!

#

I will work on this tomorrow (bed time for me now)

warped trail
#

EnableFixedRateWithCatchUp is broken btw, or i'm doing something wrong with it😅

scarlet inlet
opaque ledge
#

When i tried to dispose blob asset store right after i converted some gameobjects editor crashes, now i instead dispose of it in OnDestroy method and it is working fine so far.

scarlet inlet
#

yes this is what I have experienced, but there is no official answer. no good

static remnant
#

Is the Dots Netcode something more special or what should I be googling to find tutorials?
I have found it very hard to find anything I can work with properly.
Anyone got an idea?

remote coyote
#

there's not much in the way of tutorials yet at all

#

I worked from looking at the dots sample

#

and coded things myself from how I understand it after watching that

#

otherwise there is a get started example in their documentation

static remnant
#

Okay thanks I will look into the get started example

remote coyote
#

good luck!

bright sentinel
#

@static remnant The docs also has a getting started guide

#

It's slightly outdated, but should be easy enough to fix

fallow mason
#

I wish you could create a truly empty gameobject (like without a Transform). Then I could author entities without including unnecessary data.

opaque ledge
#

You could always create entity thru code 😄

#

i think @scarlet inlet was working on something like that, not sure if he found the answer

fallow mason
#

oh for sure. Just have wanted that for a while anyway before DOTS (ie manager scripts that just need a host gameobject)

opaque ledge
#

Thats probably will come with full DOTS editor, no idea when that will come tho 😄

fallow mason
#

I was trying to make a "create entity" menu item last night, where it creates gameobject and then destroys Transform. Impossible of course.

#

I think the only way right now is an authoring component that strips the transform component data off after conversion

opaque ledge
#

yep pretty much^^

#

but i remember Sebas doing the same stuff, for simple gameobjects that can work but i think it wont be pretty if you try to convert a prefab with nested stuff and try to remove unncessary stuff

fallow mason
#

I don't think Transform is a necessity for hierarchy

#

but I agree that Unity will probably not do anything to GOs as we know it. Likely a separate authoring object if anything.

fallow mason
#

You're talking a special built-in? Because that's possible in user land already, right?

#

I think that's fine, but I think the optimal solution would still be a blank slate, where the workflow is that you're only adding components at conversion time, not removing.

#

But I understand the limitations in regard to how scenes work

amber flicker
#

This feels pretty low down priority-wise to me - given the current to-do list? It also seems related (at least in my head) to how code-generated entities will correspond to in-editor representation in the future?

fallow mason
#

oh absolutely low priority. just a wish list thing for me.

#

another option would be to override the Convert method

#

of built-ins

#

don't know how feasible

#

and also would be problematic if you wanted different conversion per entity. eh nevermind

mystic mountain
#

Is the conversion thing gonna stick, or will it eventually be some other editor to put it togeather?

zenith wyvern
#

If you mark it as static it at least reduces the the amount of work done on it. But yeah, being able to make a non-transform gameobject would be great even outside ECS, just for organizational purposes

#

People have wanted it for many years

remote coyote
#

yeah, I like the conversion workflow

zenith wyvern
#

It would be useful to be able to organize related scripts/objects hierarchically without having it be tranform-related, for organization purposes in the editor

#

Having things in a hierarchy you can easily enable and disable in a click without it having any performance implications

#

I remember a blog post by a studio where they had almost all their go's nested for organizational purposes. They actually had a quite noticable performance improvement just by un-nesting their game objects. That's just silly. And organizing things in the editor hierarchy that way is quite common, it's not like some unusual use case

sour ravine
#

the real issue is conflating transform hierarchy with view logic

fallow mason
#

I've asked this before and gotten no response, so I figure I should ask while there's activity on the channel: Why does ConvertToEntity maintain the entity's name in conversion while SubScene does not?

#

even when I make a special NameAuthoring component, it does not convert :\

warped trail
#

entity's name is more like debug thing i guess🤔

fallow mason
#

right, and I want that debug thing.

#

don't need it in build, just want to know which entity I'm inspecting in the debugger.

zenith wyvern
#

the real issue is conflating transform hierarchy with view logic
@sour ravine
Like I said doing it that way is quite common. Responding with "well they shouldn't do that" is unfortunate and pretty indicative of why people get frustrated with how Unity responds to common issues people bring up.

#

Getting pretty off topic at this point though so whatever

fallow mason
#

Gonna go put that question on a milk carton

fallow mason
#

lol I kinda do

dull copper
#

we always want the full explanation

#

doesn't mean we'd understand it tho

fallow mason
#

but I can also be happy with the fact that I'm not insane and this isn't supposed to happen

stable fog
#

Sorry, just a small somewhat unrelated question, how new is Asset DB v2?

#

as in, how long has it been in place

#

Ryan had let me know that my asset referencing issue was effectively unworkable due to how the build process works. I'm just curious if that is an issue that could be changing

#

well that is irrelevant then, even if it did change I'm not lucky enough to be on 2019

fallow mason
#

Ok, I think I'm tracking at a high level. But in that case shouldn't this still work?: ```using Unity.Entities;
using UnityEngine;

public class NameAuthoring : MonoBehaviour, IConvertGameObjectToEntity
{
public string debugName; //Set to "Test" in the inspector

public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
    //dstManager.SetName(entity, gameObject.name); <- Ideal authoring workflow (other than automatic of course)
    dstManager.SetName(entity, debugName);
}

}```

warped trail
#

no😅

fallow mason
#

why not?

warped trail
#

because they "don't serialise names"

amber flicker
#

NameAuthoring in subscene -> Converted -> Serialized -> No names

fallow mason
#

debugName is just a string, not the name field of a gameobject?

#

so you're saying that convert runs before serialization and gets stripped before seeing it in the debugger?

#

ugh

warped trail
#

subscene is already converted and serialized data, so when you load subscene there is no conversion

fallow mason
#

so when I click "Close" on SubScene component, no conversion takes place?

safe lintel
#

for just a single instance where you need a name you could just make a one time component tag that has the name and filter it in the debugger, but obviously this gets less convenient for multiples

warped trail
#

it converts and stores converted data to disk

#

yes, you can set name from systems, that will work

fallow mason
#

so I'd have to store the name as a true IComponentData and set the name through a system

zenith wyvern
#

You could set it during conversion. They dont serialize the editor names. They will serialize your component.

fallow mason
#

right, got it

#

thanks

vagrant surge
#

its interesting that in the new tiny samples

#

they dont use the automatic authoring conversion

#

for creating authoring components automaticall

lapis jackal
#

Hi! Am i right understanding that new 2d entities feature is available only for DOTS Runtime / Tiny project? So there is no way to use it with some existing Unity dependent code?

warped trail
#

no Unity engine code in Tiny😕

lapis jackal
#

And there is no way to import 2d entities with 2d physics to Unity, right?

fallow mason
#

I think 2D entities has tiny dependencies

#

so probably not

#

yeah tiny deps, so no go for hybrid-ecs projects

lapis jackal
#

Ok, thanks. Hopefully that will be fixed.

fallow mason
#

I'm working on a multiplayer 2D WebGL project. It's a weird spot to be in right now, because Tiny is the future of WebGL builds. And I didn't have 2D until about a week ago. And now I still need netcode. Just a bit of a waiting game right now.

#

And learning. Waiting and learning.

opaque pilot
#

Currently lookng at the AngryDots example of converting GameObject Prefabs to Entity Prefabs in my own project and running into this error: ArgumentNullException: A valid BlobAssetStore must be passed to construct a BlobAssetComputationContext Can't seem to find anything on Google and the AngryDots example doesn't have this error so a little confused right now

#
manager = World.DefaultGameObjectInjectionWorld.EntityManager;
var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
redEnemyPrefabEcs = GameObjectConversionUtility.ConvertGameObjectHierarchy(redEnemyPrefab, settings);
safe lintel
#

I think you just make a blob for null, and then dispose it after ie var blob = new BlobAssetStore() then at the end blob.Dispose();

opaque pilot
#

Hmmm... Interesting, I give that a go

#

Thanks!

opaque ledge
#

an unity staff posted a link about SIMD in forums if anyone is interested about it

dull copper
#

that's pretty good video, he has few others on the topic too

#

watched those when they came out myself

coarse turtle
#

oh hey handmade hero

#

I loved that series 🙂

opaque pilot
#

@digital scarab 👋

#

Trying to convert a game template to dots 😅

#

Going to have another stab at it tomorrow to see where I'm going wrong with the conversion API

fallow kraken
#

Does anyone have an example of how to spawn an entity with a mesh at runtime without using a Prefab? I was under the impression that I'd only need to add LocalToWorld, Translation, Rotation and a RenderMesh, but looking at the entity debugger of an existing entity, there's a lot more (like RenderBounds, ChunkWorldRenderBounds, and a few more). Do I need to add all of those manually?

coarse turtle
#

@fallow kraken short answer - yes - I'm wondering if you can just use DeclareReferencedPrefabs and have the already converted prefabs

#

be readily available to instantiate

fallow kraken
#

ok lemme google DeclareReferencedPrefabs first 😉

coarse turtle
#

yea - it should be an interface - I haven't exactly used it yet so far but it might suit your needs

fallow kraken
#

hmm but DeclareReferencedPrefabs assumes there's a prefab, right? which i don't have for that particular entity. i basically have a mesh and a material which gets generated runtime, and a position obviously.

coarse turtle
#

Ah - I misunderstood - okay since that set up is similar to mine - yea I think you'd have to add those components manually

#

you can create the archetype and instantiate an entity with the said archetype and fill in the data as you go

fallow kraken
#

yeah but i have no idea what ChunkWorldRenderBounds is for example... and i have the feeling that these will change in future Entities versions... they seem pretty low-level anyway

#

but i can dig into the authoring classes, maybe that gives me more clues.

coarse turtle
#

I think that might be used to help determine culling - it's been a while since I used the hybrid renderer

fallow kraken
#

alright, thanks! 👍

fallow kraken
#

hmm, actually i can just create a game object and use GameObjectConversionUtility, that should work runtime, no?

fallow kraken
#

(it does)

hollow sorrel
#

i am using World.GetOrCreateSystem to create a system, it seems to add it to the world and run oncreate but not onupdate and doesn't show up in entity debugger, is there something obv i'm missing?

also tried with [alwaysupdate] so it's not that

#

also shows up correctly in vs debugger when checking world's systems

#

also this is in editor at edit time

#

maybe ecs doesn't update systems at edit time? but other systems seem to (SceneSystem etc) without appearing to do anything weird that i can see

coarse turtle
#

Is it a data dependancy issue where you don't have the required entities to operate on?

slim nebula
#

how do I define something so that a package is compiled with said define?

#

like a #define

solar spire
#

If you mean an assembly definition in a Package for package manager, you just use the Define Constraints

slim nebula
#

nah

#

I think I found it though

#

project settings > player > other settings >scripting define symbols

#

um

#

UNITY_DOTSPLAYER is what I was trying to define

#

does the standalone dots player exist? or is that just something unity has for internal development

#

causes a bunch of errors for me

dull copper
#

tiny uses it

slim nebula
#

the dots physics system runs every graphics frame and using the fixed timestamp... I'm not sure how I can work-around this...

#

so basically framerate dependant physics

#

I dont want this

#

who/what is tiny?

solar spire
slim nebula
#

I dunno if im stoopid or if this is nor available yet, but I cant fine any download link

#

I see source for samples but I don't get it

#

does it still just use unity editor?

#

is it just different packages in the package manager?

#

yup ok

#

thank you!

hollow sorrel
#

update on my systems in editor issue for those interested
[ExecuteAlways] attribute works same way for systems, is required to get it to update in editor (apparently Rett mentioned this to me before but i forgot)

editor doesn't have a fps cap tho so it runs a lot
which is prob fine in most cases but i don't want to risk editor responsiveness so looked to cap it anyway

seems [ExecuteAlways] works on ComponentSystemGroup too so made an editor systemgroup, and apparently you can use UpdateCallback to define if it should update so am currently using that to make it update at a fixed rate

might use same way to update runtime systems at a fixed rate, dunno what the cons of that are
if it's that easy i wonder why it wasn't done already (since plans for fixed rate simulationgroup was mentioned like a year ago)

spring hare
#

Anyone here ever tried to implement a state machine as a set of state-associated tables, like in the Data Oriented Design book?

#

For reference ^

#

Been struggling with the idea, because organizing data into tables, when that data is also mapped externally, means there needs to be some amount of indirection and/or copying and/or sorting, and it’s a bit hard getting a handle on what the common sense approach to take is

#

And I realize it’s context specific. What is the actual system or set of systems, what does the data look like, etc

#

But just inherently, it seems a little complex.

#

Actually I guess the issue is less FSMs and more operating on tables that map back to some ID-mappable data

coarse turtle
#

I think a slot map data structure might be worth looking into

#

if you want the idea of like a 'graph' like data structure that is associated with some id mappable data

spring hare
#

Is a slot map much different from something like a sparse set, or a hash map, or a free list with a parallel skip field?

coarse turtle
#

it uses a free list to help build the structure

spring hare
#

Well sparse sets do too, as does Unity’s entity mapping to chunk offsets

#

Does this try to keep data packed? Or keep it sparse but provide a way to locate the indices in use?

coarse turtle
#

I think he describes a period where the data get compact if you do an insertion/deletion to the data structure

#

so it looks like it tries to keep it packed

spring hare
#

Sounds sparse set-ish then

#

I love sparse sets as a data structure, they’re really useful for keeping data mappable, iteratable, and fast to insert/delete

#

One issue though, when you’re using multiple sparse sets as tables to map back to some original data array

#

When you insert and delete, the “swap back” behavior kind of jumbles up your iteration order of the original array

#

And you can sort, but that can be expensive too, especially since you’ll be potentially getting plenty of cache misses anyway due to not every table mapping to every data index

#

I don’t think there’s a way to “have it all” with perfect iteration, insertion/deletion, ordered access, etc when trying to maintain external maps to different subsections of a data array

#

But since there are multiple strategies for creating, updating, and changing those maps, it bothers me that I don’t have a good sense of what an okay default would be.

coarse turtle
#

I think determining that might be hardware dependent - as in you want to optimize for the range of target devices that's acceptable and runs consistently - but that's my take since that's my primary goal

spring hare
#

What would you say for something like Durango then?

#

You’re targeting Xbox, and for whatever reason you have a ton of FSMs to convert because they are all thrashing the instruction cache constantly. Out of order execution isn’t helping much

#

You have a scene with a bunch of characters, and there aren’t many additions/removals of these characters so character-normal data is pretty consistent. The data associated with the FSMs is character-normal, and used in enough transforms that you don’t think it’d be worth it to de-normalize it from the other character data for the purpose of making the FSM management easier

#

In a given iteration of your game simulation, the mutually exclusive state-based transforms will be reading from/writing to that character-normalized data, and potentially writing to state transition buffers for removal from/addition to FSM tables as well as state-transition-specific transforms

#

Assuming there’s a fair bit of state transition per frame (10% let’s say), where would you start with your tables?

#

One idea that came to mind for me was giving the original data an extra int map. That int would keep an index reserved in a free list, and when I wanted to add the data to a state table I would use that reserved sparse index to allocate a dense index at the end of a second array, like a Sparse Set.

#

The dense array of each table would point back to the correct offset of the original data array.

#

The original data array would also be backed a free list with a parallel bitfield, so its “allocated” indices would never change, meaning I wouldn’t have to use an additional indirection for if it moved.

#

The weakness here is that while table insertion and deletion would be fast and so would table index iteration, each index would not have data, and I’d have to eat the cost of the indirection. And in addition, with lots of table insertion and removal, those indices would start to scramble in order, meaning I couldn’t count on the cpu speculatively loading the next line of the original data array in order

#

So... with that said, how decent of a strategy is it? As a default strategy? Are there alternatives that work better as a default strategy for something like this?

#

If you wanted to do “data oriented” FSM with state tables, what would your first attempt look like?

dull copper
#

guess what just got merged to SRP master?

bright sentinel
#

Finally here 😄

dull copper
#

it'll still take a good while to propagate to actual releases

bright sentinel
#

Yeah, but at least it's closer 😛

coarse turtle
#

@spring hare Hey just saw this - I think my first approach is an array which typically just store a tuple of the transition between states and what data the index element points to in some secondary array or sparse set .

[ (5, a), (3, b), (0, c), (2, d), (1, e)] -> store the transitions between each state and what data the state points to

[ a, b, c, d, e] <- stores the data for the fsm (indices denoted as letters instead of #s)

Yeah once you start doing a bunch of insertions and removals from this fsm you start to get this unordered set - but I think this is good as a starter approach

warped trail
#

how can i store Entity in subscene without any default stuff like SceneSection,SceneTag etc.?🤔

spring hare
#

@coarse turtle thank you, that’s really helpful

lusty otter
#

Editor has been crashing a lot lately when I go into play mode, for seemingly no logical reason.
For example if I add unreachable cases to switch statement, when entering play mode it will just hang when entities are being created. However if I build apk and run on an actual device, it runs all fine (as it should, because all I'm doing is just adding unreachable cases).
Do you guys know anything that could be causing this? It's killing my efficiency.

coarse turtle
spring hare
#

Haha yeah I was looking at that one too. Was linked in this channel earlier in the week.

coarse turtle
#

Ah lol didn't know that

coarse turtle
#

@lusty otter might be some safety check on the editor side? Maybe something in the Editor.log says something?

lusty otter
#

There's no log I think?

#

For the unreachable cases, it doesn't actually crash it just hangs, I can close it but none of the editor UI works.

coarse turtle
#

Oh - wait I have the same issue but it wasn't consistent 🤔

#

yeah idk - I typically just restarted unity without thinking too much about it - maybe I'll file a bug if it happens again - see if I can reproduce it

lusty otter
#

Sigh.

amber flicker
#

I've encountered reproducible crashes when I've had safety checks disabled and an exception thrown in a bursted job I think - but I guess you've already made sure safety checks are enabled

stiff urchin
#

On MacOS it's 50/50 for me if I get a crash with DOTS or not.

#

which makes it pretty unusable.

#

even with simple examples

#

On my windows box it's much more stable, but it makes me uneasy..

amber flicker
#

Oh also.. rapid debug.log's reliably crash Unity for me (2019 & 2020) independent of machine - setting editor to vsync helps slightly but it's still not very tolerant

#

not sure if anyone else has found that

bright sentinel
#

Which version of the editor+burst are you on?

amber flicker
#

me? every version in the past year and a half 😅 - windows

bright sentinel
#

I mean, are you still crashing on the newest versions of each?

stiff urchin
#

yeah

#

well the latest 2019.3 that is

#

I haven't tried 2020 yet since it's alpha

bright sentinel
#

Yeah pretty sure 2020 won't fix it

#

But you're also on latest Burst?

lusty otter
#

For me, latest 2019.3, all packages are up to date, I tried turning off job debugger, leak detection, disabled burst compile altogether, and it still hangs.

bright sentinel
#

Hm, maybe the next version of Burst will fix that

#

Or so I've heard 👀

#

Not too sure about MacOS though

lusty otter
#

If I comment out the cases, which is not even being used, editor play mode runs all fine.

#

I guess it is a preview package after all but oh boy, this is frustrating.

bright sentinel
#

I recommend to just report a bug and let them fix it

lusty otter
#

Is the built in bug report upon crashing the way to go?

bright sentinel
#

Ya

#

Because their QA will actually look at those

lusty otter
#

I shall do 👍

slim nebula
#

My unity editor crashes now and then. I save a lot so I dont care, but I tried clicking the submit crash button and it kinda implied that my crash report wouldn't be looked at because it's not like I did something reproducable. Should I still submit crashes even if I have no idea why it crashed?

#

or is that just noise if my report quality is like 0....

#

I would hope that there is some stack trace they could look into, but I dunno if they just ignore it because the editor is scriptable

zenith wyvern
#

If it's not reproducible and you can't explain exactly how it happened then there's probably nothing they can do with it

slim nebula
#

ok

dull copper
#

re: 2020 alpha, there is beta coming out any moment now

#

b1 have existed for like a week now

warped trail
#

how stretched in time this moment is? 😅

dull copper
north bay
#

How stable is the 2020.1 compared to 2019.3?

dull copper
#

it probably boils down on what you use with it

#

in my experience, even alphas tend to be quite stable unless you couple with them with other preview packages

#

but the bigger issue on alphas is the package compatibility, they might not always be compatible packages for the new version at that point

#

things like that start to get better during betas

north bay
#

Yea, that's why i had to update to 2019.3 initially lol

zenith wyvern
#

I think they said next Entities version is 2020 only

dull copper
#

hybrid v2 is probably relying on 2020, yes

#

and you already get some things on 2020 that doesn't work on 2019, like debug draws inside jobs

#

(debug draws still don't work with burst)

slim nebula
#

I tried to read those v2 patch notes someone posted, but it was like reading a different language rofl. I have lots to learn I guess

stable fog
#

SerializeReference has various issues in 2020.1

dull copper
#

is it 2020.1 issue or just issue with the latest serialization package?

#

because last package definitely wasn't compatible for me

stable fog
#

uh, well I didn't install any packages to test it, is it included by default?

dull copper
#

if you haven't manually upgraded that specific package, it's not it

stable fog
#

Also, SerializeReference is new in 2020.1

dull copper
#

ah

stable fog
#

lets you serialize non-UnityEngine.Objects by reference

zenith wyvern
#

SerializeReference is in 2019.3 as well

stable fog
#

O.o

#

Are you sure?

stable fog
#

their example is where the problems actually come up wtf

#

I need to investigate this

#

well, the issue is specifically, if you have a class which has itself as a member, Unity will automatically populate thing new elements with the previous element data, which is typical unity behavior, but in the case of SerializedReferences can cause infinite update loops which kill unity

#

I haven't tested on a25 yet

opaque ledge
terse matrix
#

I recently learned that Unity is moving towards an ECS paradigm and I'm wondering if it's worth using for production in its current state. Would it be worth the time to make a pure ECS game in the next LTS release?

coarse turtle
#

I think that depends on your needs - see if the things you need are supported and if they're not is it okay for you to develop your own custom implementation?

zenith wyvern
#

ECS won't be in LTS for a long time I think

#

A few people are using it in production but I think right now it's pretty rare, the API isn't even stable yet

terse matrix
#

My current project is very suited to ECS so I might actually try a custom system. How much Unity functionality do I lose by doing this?

opaque ledge
#

yeah, you lose every functionality 😄 you gotta do hybrid

zenith wyvern
#

You can model your systems to use gameobjects while you transition. But you may not see much performance gain until you use burst and jobs, which greatly restricts the types you can use. No reference types or mutable static data.

#

IE no gameobjects in jobs and burst.

terse matrix
#

well shit

coarse turtle
#

Unless all you need is rendering you can certainly get by using it

terse matrix
#

Guess I'll hold back on Unity ECS for now lol

coarse turtle
#

okay maybe unless is a big overstatement - but rendering is something that's currently supported via hybrid renderer but ppl have had issues with it from what I see

zenith wyvern
#

You can still get huge performance gains by isolating your logic into ECS and then writing it back into gameobjects after processing, but it's not very smooth at this point in time

terse matrix
#

rendering/shader stuff is definitely the biggest thing I need from Unity

coarse turtle
#

there are certainly conversion systems which you can use to help transition gameObjects into their entity formats

#

I currently do this for my own 2d game

zenith wyvern
#

@terse matrix This is a good presentation on how you can try to utilize ECS and dots in an existing gameobject-based project without having to remake your entire project at once https://www.youtube.com/watch?v=BNMrevfB6Q0

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

▶ Play video
dull copper
#

@terse matrix if you want just the perf benefits, you can just put the perf crucial code into burst jobs and forget about the ECS part

#

that's way less risky if you need this today

#

burst + jobs are production ready

#

ECS isn't

#

and DOTS packages definitely are not

warped trail
#

but burst and jobs are part of DOTS😅

bright sentinel
#

@terse matrix You can do some ECS stuff with gameobjects, and do it gradually. The simplest is to use jobs, where you can offload some of your functionality to those. They are multithreaded, and are really good for things such as procgen or pathfinding when you have a lot of objects. These jobs can be scheduled directly from monobehaviours.

If that's not enough though, you can also utilize entities, by converting some of your stuff to ECS. Usually this would be where you have a lot of the same types of entities (e.g. enemy agents, similar buildings etc) that are then ported to ECS. You can also move your physics simulation over to ECS to leverage the performance gains frm that.

Finally you can of course do a full ECS build (except the rendering currently), which I don't really recommend for production. But the first two approaches are already being used in some productions

dull copper
#

yeah, I kinda mean stuff like engine components by dots packages, like physics, animation, rendering

terse matrix
#

job/burst system is 👌
glad that it's ready to use

dull copper
#

also jobs is in the unity core, the package you get on packge manager is just some small helper package 🙂

#

job system documentation is also on regular unity docs, not in the package one

#

as for the rendering, we might get quite substantial improvements on it soon but it's too early to tell how much better the hybrid rendering v2 will be

#

expect to hear more about that in coming weeks as Unity reveals their GDC content

terse matrix
#

Something I should probably mention is that I work with 2D

#

will Unity be improving rendering for my needs?

dull copper
#

I wouldn't expect better rendering with DOTS in a long time, unless you need some brute force stuff like hundreds of thousands sprites at one 😄

#

we are currently at a point where people would be happy to first get similar functionality than without DOTS

#

there are compatibility issues with current hybrid rendering approaches

#

and then there's separate rendering for project tiny as well

#

for 2D, you'd probably want to be using URP as it has quite nice 2D renderer

bright sentinel
#

Also pretty rare that a 2D project has actual performance issues. The only case I can see right now is ad games, in which case you'll have to wait for Tiny2D to be production ready

dull copper
#

@digital scarab btw since you are around, you wouldn't happen to know if there's already some way to define code to run burst with different code based on the currently selected SSE/AVX extension?

#

I guess not as it would probably break the determinism

#

I was kinda thinking I could help burst a bit by feeding it double precision math 4-wide out of the box on AVX but it wouldn't really help at all on SSE4

#

yes

#

oh, that's cool

coarse turtle
#

yea I agree with @bright sentinel about 2d - my game doesnt have heavy performance issues if it was in monobehaviours and the reason why it's in dots was that it was easier for us to reason about and change data manipulations and if we wanted to change the high level direction of the game (but sprite rendering is still done by the SpriteRenderer)

dull copper
#

IsAvxSupported

#

I was more of like thinking of just defines here tho but I guess I could do this as well

#

this adds extra check now

#

also thanks for pointing to the right direction 🙂

#

"Evaluates to true at compile time if AVX intrinsics are supported."

#

hmm, I guess that doesnt really help after all

#

I can't branch SSE and AVX implementations with that

#

yeah, because not every windows machine there supports AVX

#

but SSE is supported by all

#

and burst picks the implementation on the fly on the client computer

bright sentinel
#

On a side note (and being sort of new to ECS/DOTS), is branching seen the same way here as they are with shaders? Or are they fine to do?

dull copper
#

"Evaluates to true at compile time if AVX intrinsics are supported." makes it sound like it just sets that true when I compile on this rig 😄

#

oh, basically Burst itself can swap between SSE and AVX on the client computer

#

that works already

#

but what I would have wanted to do is provide different code for AVX and SSE

#

but apparently that's not a thing

#

and considering the determinism, it's probably not worth it

#

well, I can test it 🙂

#

yeah 😄

#

it's bit hard to test properly here tho as all my computers actually support AVX

#

and if you set the SSE4 as max supported on build, it doesn't tell if I succeeded or not

#

I could test this on avx2 though

#

because that's definitely not supported by my old i5

bright sentinel
#

@digital scarab Huh, I've never really thought about that. Do you have any resources I can read up on? Preferably targeted for non-compsci people like me

dull copper
#

@bright sentinel new math lib has select option that lets you bypass some branching if's

#

and it's definitely faster than the if

#

it's one of the things Unity has mentioned you can do to make burst compiled code run better

#

from: https://forum.unity.com/threads/math-selects-performance-vs-inline-if.532282/#post-3505501:


The main interest for using select is on SIMD types and more specifically on float4, as it is more naturally mapped to a SIMD register. It will typically result in using dedicated instructions instead of performing conditional move on each components.

For example, a math.select(float4, float4, bool4) without SIMD would generate the following scalar code (note that you can't generate currently this code in burst using math.select as it will always generate the following SIMD version instead):```
bright sentinel
#

Oh my that is already out of my league haha. Guess I'll leave optimization problems to actual compsci people if I ever get to that problem 😂

#

But no prob @digital scarab seems pretty complicated anyways

coarse turtle
#

I think i started learning it when I was fiddling with g++ and using the step debugger to see how asm instructions worked 😅

opaque ledge
#

This can help you for simd stuff, Unity also has some videos in their youtube channel

#

But i feel like its something i should try to learn after everything works correctly 😄

bright sentinel
#

Oh, that might be useful. I tried watching one of the Unite talks about performance with SIMD instructions, but I didn't understand much. This might be a bit more on the educational side, so thanks!

#

And yeah, I don't want to be optimizing performance before it's actually a problem 😛

opaque ledge
#

tbh, ECS by default (with power of burst) already provides with insane performance, but if you want to go for a real massive worlds i think thats when instrincts will come to help you

#

this is of course from a peasant point of view 😄

#

maybe there are some pro people out there that says "my life is not complete without instrincts", who knows 😄

coarse turtle
#

Hmm - I think there are use cases - was reading a tweet thread by folks at binomial who do image compression and want to support wasm simd instructions the other day lol

dull copper
#

it's pretty cool that we can do intrinsics via Unity.Burst.Intrinsics now

#

this is new in burst 1.3 or just not documented before it?

opaque ledge
#

👀

#

Olento is this true, you suppose to keep track of these things 👀

#

(just a joke btw)

slim nebula
#

does anyone know, is NetCode prediction based on time, or is it based on frame number (tick). It must be based on time right? Does that mean the prediction system might skip a tick on the client if the FPS is low, and process the same tick multiple times if the FPS is higher than the server?

bright sentinel
#

@slim nebula Pretty sure it's based on ticks, but the server is on a fixed rate

#

So it's based on ticks which are based on time

slim nebula
#

but the client isn't on a fixed rate though

#

I've seen delta times that are not 0.016

bright sentinel
#

Yeah, but that's what the prediction system uses to predict.

#

It looks at the ticks it received from the server

slim nebula
#

oh I guess the prediction ticks on the client dont have to line up with the server ticks, as long as the oldest tick is at the right time then the client can predict whatever

#

this makes sense thanks

bright sentinel
#

Yeah, there are some docs about this on the package docs

slim nebula
#

oh? any chance you could link me to that? I've been finding it hard to google this stuff 😦

#

or you mean it's in the actual package somewhere?

#

once I get it from unity package manager?

#

or this

#

I guess I should read through all that

bright sentinel
#

Yeah that's the one 😄

#

It's really useful I've found

slim nebula
#

cool thanks a bunch. appreciate it

dull copper
#

@opaque ledge new 1.3 burst too

gusty comet
#

How should I go about rotating a 2d entity right now? Using quaternion just makes the entity dissapear

safe lintel
dull copper
#

yeah, that's pretty much what was supposed to be the main highlight for the new package 🙂

#

they still don't have breakable joints

#

also no joint motors

#

both will arrive later on

#

I've been waiting for this release specifically in hopes I can get rid of the old joint scripts from physics samples

safe lintel
#

i can do ragdolls without stumbling through the math myself though 😄

dull copper
#

they haven't updates the samples repo for this yet

#

there's some breaking changes

safe lintel
#

@gusty comet rotation component?

dull copper
#

getting this now Assets\Scripts\Modify\ModifyBroadphasePairsBehaviour.cs(80,53): error CS0193: The * or -> operator must be applied to a pointer

#

but I'm sure the sample repo is going to be updated any moment now

gusty comet
#

yes, im using the rotation component

dull copper
#
## [Burst 1.3.0-preview.5] - 2020-03-11

### Fixed
- `MemCpy` and `MemSet` performance regression in Burst 1.3.0.preview.4 (as was spotted by [@tertle](https://forum.unity.com/members/33474/)) has been fixed.
- Fix a crash when loading assembly with PublicKeyToken starting with a digit
- Better handling of MonoPInvokeCallbackAttribute: no check for the namespace, don't print message on Mono builds

### Changed
- Improved error message for typeof usage```
#

not going to put physics packge changelog fully here as the list is kinda huge

#

basically they changed a lot of runtime API + added that LegacyJointConversionSystem

vagrant surge
#

uhm, so 2d Tiny is incompatible with 3d Tiny

#

come on....

dull copper
#

what do you mean by that?

#

the renderer?

#

also about that Burst update, I'm now going to do mono builds only to get rid of that spam 😄

vagrant surge
#

yes

dull copper
#

" Better handling of MonoPInvokeCallbackAttribute: no check for the namespace, don't print message on Mono builds"

vagrant surge
#

if you use 2d cant use 3d, and reverse

dull copper
#

2D not being able to do 3D makes sense but you'd expect sprite support on 3D too

#

maybe they just haven't added it yet

#

hmm

#

they actually didn't add joint authoring components at all(?)

#

I only see the legacy joint conversion system

stable fog
#

anyone played with the dots jobs particle system?

dull copper
#

and the Physics_joint.cs that has these joints

#

@stable fog there's a dots particle system?

#

or you mean the job system support for shuriken particles?

#

if so, there should be sample code snippet for it on the docs

stable fog
#

did I misunderstand the project

coarse turtle
#

o - looks similar to the bursted/jobified mesh api

#

I haven't used it yet though

warped trail
#

there is no havok update😕

dull copper
#

that's hardly surprising considering there's been 1(!) havok package update so far

#

and even that barely changed anything

#

they mainly removed the time limitation for the early preview version

bright sentinel
#

I'm pretty sure Havok are not putting as many resources into Unity Havok as Unity are putting into Unity Physics

#

Doesn't make much sense

#

At least at the moment

dull copper
#

Havok team is doing Unity Physics as well tho

bright sentinel
#

Wait really?

dull copper
#

basically anything on the physics solvers is done by Havok

#

Unity only does the DOTS conversion stuff and DOTS integrations

opaque ledge
#

anyone figured out how to do new foreach collisionevents and triggerevents ?

dull copper
#

of course nobody really believed Unity Physics getting out of preview on Q3 2019 but I like their optimism 😄

#

@bright sentinel ^

#

if you look at the unity forums discussions on unity physics package, there's a lot of replies from Havok guys directly

#

also... crap

#

since the joint conversion system requires physx components to be used, you have to put old rigidbody components there too for it to work

#

can't use new physics body ones

#

how they could not just make new authoring components while they were at it?

stable fog
#

heh, someone was arguing with me about the dots and burst performance, and I was like even the havok guys said burst was impressive

#

apparently thats not good enough though

safe lintel
#

yeah I guess I thought that they would also add some updated joint authoring components to go along with this update, but at least for characters using rigidbodies is good enough

dull copper
#

you could do ragdolls with the old joint scripts already

#

pretty sure the ragdolls from unity physics samples did this

opaque ledge
#

There you go, this is the Olento i know 👀

#

😄

#

and thanks

dull copper
#

swapped the link to one with unity hub link

safe lintel
#

i did do ragdolls previously, it was based on the samples but the samples ragdoll is a custom script, not using the joint authoring components. it just means your joint limits(well mine in this case) had to be figured out with math, and I am just terrible at math
like arm/torso joints that had no limits, spinning like a ballerina when dead 😄

dull copper
#

ah, so you use some wizard for that normally?

safe lintel
#

that builtin one does the trick for simple chars and my own uses, to convert it and get similar results would be good enough if it converts properly.

#

just to add, when attempting to set limits and not knowing how to set those limits with the right transform points would sometimes lead to exploding or self propelling joints flying off into the sunset

stable fog
#

oh its actually up now sweet, they changed the page and it was real confusing

#

THank unity for unity hub, managing installs is so much better these days

opaque ledge
#

Should i upgrade to Beta right away 👀

stable fog
#

I just did... but according to a lot of people I have very dangerous upgrade habits

#

I love living on the bleeding edge

dull copper
#

in that case, public 2020.2 alphas should start soon ;D

#

they are already at 2020.2.0a3

stable fog
#

I know I'm quite excited 😄

#

have they talked about .2 features yet?

#

still no Kinematica :*(

safe lintel
#

i just want the new hybrid renderer 🙂

dull copper
#

I doubt there's much new functionality at this point

stable fog
#

Kinematica is supposed to be part of one of these releases

#

or perhaps, released in a preview package along side of**

dull copper
#

HDRP team lead said like half a year ago that they'll address HDRP perf regression on DX12 for 2020.2 but we'll see

warped trail
#

StepPhysicsWorld still uses😑 cs float timeStep = UnityEngine.Time.fixedDeltaTime;

dull copper
#

that could mean anything too, as 2020.2 release is set to Q3/Q4

stable fog
#

are they running behind this year?

dull copper
#

I doubt it

stable fog
#

I thought .3 was supposed to typically be released in december?

dull copper
#

no I mean, they just removed one release from summer

#

there's only going to be two tech releases now

stable fog
#

oh, so .2 is the last release before LTS?

dull copper
#

IMHO, they could just do one tech release and keep adding stuff till Q2, stabilize it for release on Q3 and then polish it to LTS

#

it would make way more sense to me

stable fog
#

ultimately you have 1 release per year that actually matters which is the LTS

#

anyone not doing experimental R&D doesn't want a potentially* unstable client

dull copper
#

yeah, that's my point here really

stable fog
#

I mean, its not relaly true, I know a company who is working on moving from 2018.3 to 2018.4 LTS right now just because it makes sense to do so

dull copper
#

2018.3 to 2018.4 should be trivial tho

#

as there's no feature difference between the two

#

same api, same feats, LTS just may have more up-to-date SDKs and more fixes

opaque ledge
#

is really moving from version to version a huge task ?

stable fog
#

they are doing it specifically because its easy and because you should theoretically have more stability on LTS

#

@opaque ledge it really depends

#

on how much of the Unity API you're actually directly consuming and whether or not that API changed between versions

#

I donno if Unity is using Semantic Versioning, but per Semantic versioning, movgin from 2018.1 to 2018.4 should be a trivial change, as the API should not change

#

however, if you were relying on some bug or quirk of a feature that got fixed, then you're going to have trouble

dull copper
#

I've upgraded some Unity 3 project to Unity 2019

#

it's doable 😄

opaque ledge
#

btw, i was just doing some test today (maybe you saw the party hard video 😄 ) so i spawned 4k 'ships' in total and a TRSToLocalToParent or smth was taking like 20 ms

#

is there anyway to reduce that ?

amber flicker
#

avoid parenting things? 😄

safe lintel
#

there was a bug that constantly triggered that system, shouldve been fixed in 0.7 i think

#

but 20ms sounds a lot more than what the bug did i think

opaque ledge
#

yeah thats probably not going to work well 😄 i have this 'nose' capsule to show where my ships are looking at, probably thats the one causes it then

safe lintel
#

i did note that when spawning a prefab with a parent child setup, it seemed like it had to do work when spawning it in, which I thought would already have been done through conversion as it was an entity prefab

#

but that was a while ago, when it was entities 0.2 or something and i just got rid of a hierarchy for those situations

amber flicker
#

4k ships, LTP taking 20ms sounds quite wrong... unless you have like 100 children per parent?

opaque ledge
#

nope, just 1

amber flicker
#

safety checks off? burst enabled?

opaque ledge
#

which is the nose

#

yeah

amber flicker
#

have you removed the nose to double check that's where the time is spent?

zenith wyvern
#

Are all or most of your ships in the same chunks?

opaque ledge
#

yeah

#

i should probably check soon to see

#

or actually tomorrow, i am slacking rn 😄

stable fog
#

@dull copper can you convince the devs of the game I'm modding to move to 2020.4 instead of 2018.4 😄

#

I really want like, UIElements, and SerializeReference

dull copper
#

2020.3 LTS you mean?

stable fog
#

oh right

dull copper
#

or 2019.4 LTS?

stable fog
#

yeah, I donno whatever the final LTS release is for 2020

dull copper
#

yeah, that's a long wait now

stable fog
#

its a year away, gives them plenty of time to get started with 2020.1 😄

dull copper
stable fog
#

do you just like, troll the github all day?

#

like, I appreciate the effort

safe lintel
#

i refresh bintray occasionally and am totally in control of my habits and behaviours 🙂

worthy comet
#

.

pliant pike
#

does anyone know if theres a way to convert a transform straight into a localtoworld?

coarse turtle
#

ConversionAPI?

#

or you can just grab the transform.localToWorldMatrix and set it to LocalToWorld? 🤔

zenith wyvern
#

Mat4x4 will implicitly convert to float4x4, so yeah

pliant pike
#

I tried that it says cant convert matrix4*4 into localtoworld

zenith wyvern
#

localToWorld.value

pliant pike
#

nice thanks I'm always getting stuck on the silly things

dull copper
#

@stable fog I got few links bookmarked which I poll occasionally, mainly bintray and SRP repo tho

#

been thinking I should write an app that does all the checking for all things I follow in the internet

#

now there's just so many different things to follow, like RSS feeds, forums and stuff if you want to keep up

dull copper
#
Here’s a little something to spice up your week: Unity.Physics 0.3.0-preview.1 is now available to download via the Package Manager! Here are some of the key features you can expect to find in this release:

* Authoring support for Legacy Joints. Old-school gameobject based joints will now be automatically converted to Unity.Physics based joints when a ConvertToEntity component is attached, or if they’re placed in a subscene.
* The Physics Simulation can now be optionally stepped with in a single threaded mode or immediately. This is much more performant for simple simulations where job management costs more than the simulation step itself. See the '6. Use Cases/ImmediateMode' sample for example changes.
* New Collider Shape re-sizing handles. These will allow one to resize the collision shapes directly in the scene view, if that’s your cup of tea.
* Dependencies have been updated. Unity.Physics now has explicit dependencies for Burst, Collections, Jobs and Mathematics, in addition to Entities.
* Bug fixes!
* Performance improvements!
The Physics Sample has some changes as well, including fixes for a few issues, as well as updated dependencies (LWRP, Input System, DOTS Editor, Hybrid Renderer).
#

that being said, they really haven't updated those physics samples yet

warm panther
#

Ok, what am I not understanding here:

        private void LateUpdate ()
        {
            var translations = _query.ToComponentDataArray<Translation>(Allocator.Temp);
            var rotations = _query.ToComponentDataArray<Rotation>(Allocator.Temp);
            
            if (translations.Length <= 0) return;
        
            var rotation = rotations[0];
            var translation = translations[0];
            
            transform.SetPositionAndRotation(
                Vector3.SmoothDamp(transform.position, translation.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime), 
                rotation.Value);

            translations.Dispose();
            rotations.Dispose();
        }

Unity complains "InvalidOperationException: The NativeArray<Translation> GatherComponentDataJob`1.Data.ComponentData is allocated with Temp memory. Temp memory containers cannot be used when scheduling a job, use TempJob instead."

... but this is not a scheduled job. It's a MonoBehaviour, trying to read some data from a few entities (to move a camera object).

#

It works with TempJob allocation, but that can't be the answer 😉

#

I'm literally disposing the array 5 lines later.

#
            JobHandle job;
            var res = ChunkIterationUtility.CreateComponentDataArray(_QueryData->MatchingArchetypes, allocator, componentType, this, ref _Filter, out job, GetDependency());
            job.Complete();

So unity thinks it's a good idea to make this a synchronous temporary job, meaning my LateUpdate will finish when-the-xxxx-ever?

I'd like to read some entity data synchronously and immediately in my MonoBehaviours, please. 🙂 It doesn't have to be fresh, but the read needs to be instantaneous, synchronous, and non-blocking.

zenith wyvern
#

I'm not 100% but pretty sure you can't use "Temp" allocators on the main thread in the same frame that you schedule a job. As in anywhere in that frame.

warm panther
#

Yeah but I don't need a job, I need to read some data.

zenith wyvern
#

If you're scheduling a job during that frame the only time you can use "Temp" is inside a job

north bay
#

It gets completed immediately

safe lintel
#

my vague understanding is temp is auto disposed inside of jobs so you can allocate inside jobs and then not worry about disposing
tempjob expects to be disposed though so its use in this case is correct even if it isnt a job

north bay
#

But you have to pass TempJob or Permanent as the allocation type

warm panther
#

Is that the correct way to do it then? I was thinking of maybe making a system that copies data out, into some volatile data or synchronized (how's that even called in C#, I haven't touched Java in a decade and still speak like it) structure instead, that my monobehaviours bind to.

safe lintel
#

pretty sure its correct to use tempjob in this case - also reading

warm panther
#

Thanks

#

How do I know Job.Complete() immediately completes, it could be waiting for a huge dependency chain. I always understood it as something akin to Thread.Join()

zenith wyvern
#

It blocks the main thread

warm panther
#

THATS NOT IMMEDIATELY haha. 🙂

#

That's blocking 🙂

#

Also fine, but thanks for the clarification ^^

#

There's a big difference in my head with hoping to weasel in between a few dozen systems repeatedly locking a concurrent native container on access, or waiting for all of these jobs to Complete and then to read said data.

zenith wyvern
#

If you want to wait until the job completes you check jobHandle.IsComplete. You still need to manually call Complete once that condition is true, for the safety system.

warm panther
#

I do most decidely not want to wait for the jobs to complete in a Monobehaviour.

#

This is an example, it would be similar for UI where I display data that I would prefer to not duplicate, but take directly from the components and entites bound to the UI

#

Duplication would be acceptable only if that means I can read without waiting for any job dependencies.

#

I'll look into NativeQueue.ToConcurrent

#

or the atomic writing attribs etc

zenith wyvern
#

NativeArrays are already safe to write concurrently, assuming you're not overlaping indices. And they're safe to read concurrently as long as they're not being written to

warm panther
#

I define concurrent to be safe for reading and writing at random.

#

literally, there would be a copy job shoveling over the ComponentData into a native container, while at any opportune time, something from the main thread or even another job could peek or consume items in it.

zenith wyvern
#

The safety system is designed entirely around preventing you from doing that

warm panther
#

Ok. That's bad. What does NativeQueue<T>.Concurrent do, then. I thought it's like a queue that has a Mutex protecting non-atomic operations until they are complete.

zenith wyvern
#

It lets you write to it concurrently. Then you read from it after you're done writing. This is true of ALL containers, concurrent or not.

warm panther
#

hmm

#

I don't want to wait till I'm done writing, because I can imagine various scenarios where I don't know how long I'll be writing for.

#

(pathfinding?)

zenith wyvern
#

There's no magic solution, like I said, it's the entire point of the safety system to prevent reading and writing at the same time.

amber flicker
#

NativeStream might be useful here?

warm panther
#

I'd rather want my deadlocked threads back. 😄

zenith wyvern
#

You could copy all your data into a nativestream, all the same rules apply though

warm panther
#

yeah, doesnt help.

zenith wyvern
#

This is why they made ECS the way they did, they manage all the dependencies, we only have to worry about logic

amber flicker
#

Then I think perhaps @warm panther you might be misunderstanding something? Obviously it's unsafe to write to something in parallel at any time?

warm panther
#

it's not if access operators are atomic.

#
lock(_underlyingStructure) 
{ // do the work here 
}
#

And in native code, similar.

amber flicker
#

I don't know much about this tbh but do atomic operations rely on interlocking? My understanding is that it's pretty slow?

warm panther
#

and you can have fancy scoped locks so you don't block the entire array (like NativeSlice)

#

It's slow to spin and wait for a lock, yes, so you need to design your code so these spins are 0 or 1 for the majority of the time. Most processors have optimizations for these cases.

#

Anyway, I will need to figure out how to bind data to things like UI for a start.

zenith wyvern
#

What's wrong with just reading the components from a query?

amber flicker
#

how is locking a section of an array while you write, different to a system with a defined start and end writing to it? Because you can work with sections and individual elements rather than an entire array? Which you could do with either an archetype or worst case copy after work complete? Out of my depth here most likely

warm panther
#

What's wrong with just reading the components from a query?
@zenith wyvern that starts a new job, and waits for all the jobs that might have dependencies associated with these components.

#

@amber flicker I don't know... I'm more of a C++ guy, so C#'s threading model is a little alien to me.

#

But your code needs to agree on where these cordoned-off sections are, and then that's where your synchronization problem sits.

#

I'm pretty sure that's what NativeSlice does, though

zenith wyvern
#

If you're only accessing the components a read-only it would only be waiting for write jobs to complete. All reading will happen concurrently

warm panther
#

Except it blocks the main thread.

amber flicker
#

reading doesn't

warm panther
#

How is there any concurrency.

#

That's in LateUpdate in a MonoBehaviour 🙂

zenith wyvern
#

Since it knows there's no write jobs happening it knows everything is reading the same data

north bay
#

Than don't do it through the MB 🙂

warm panther
#

But I need to move my camera and I sure as hell don't want to write authoring components for every UI element.

north bay
#

You will always need a sync point somewhere

#

Why would you write authoring components?

warm panther
#

sure, except I see data as two things.

#

stuff that's not bad if it is wrong one frame

north bay
#

Make a standard managed list of your components and a system which applies the changes at the end of the frame

warm panther
#

and stuff that syncs

#

I suppose.

#

Then I need to inject my monobehaviour into the System, I wanted to avoid that. 😉

north bay
#

That's how i do all my presentation updates

warm panther
#

That's how I got here.

zenith wyvern
#

Why would you need the MB in the system

warm panther
#

Or the List or Queue.

#

Make it static? sounds fishy. 🙂

zenith wyvern
#

Just access your components through an entity query. You don't need any connection between your systems and your MB

warm panther
#

But the _eq starts and ends a job and holds memory for 4 frames

#

or something

#

But that was my naive approach in the code sample above, and it only works if I allocate TempJob memory.

zenith wyvern
#

You decide when your components get written to in the system. When you call ToComponentDataArray in your MB it will ensure any write jobs are complete, if they haven't been yet. You can do your level best to ensure they ARE complete by deciding WHEN you write to components.

warm panther
#

yes

#

that's right

zenith wyvern
#

What's wrong with allocating tempjob memory?

warm panther
#

I don't know, that's why I asked.

zenith wyvern
#

It's fine, just make sure you dispose them before they leave scope

warm panther
#

So most of my preparatory work has to be done writing during PreLateUpdate systems group

#

I can do that.

zenith wyvern
#

You can also add a ChangedFilter to your query and exit early if your components haven't changed so you're not allocating when you don't need to

warm panther
#

Then the MB will instantiate, start, and complete a Job, but it should have pretty slim dependencies.

#

Changefilter is a great idea for this use case (it is for camera targets)

#

so if everything is in a job, when do I get to use Allocator.Temp ... I guess when I need to process data that's not ComponentData

zenith wyvern
#

You use it inside a job. My understanding is that it's VERY fast. And you don't need to dispose it, it automatically gets disposed at the end of the frame.

#

And that's a good point, I never thought of that, I guess that's why you can't use Temp with ToComponentDataArray, because it's technically scheduling a job to create the array

warm panther
#

cool

amber flicker
#

Just to check - you don't want something like this right? just psudocode obviously ```private void SmoothMovement : SystemBase ()
{
void OnUpdate()
{
Entities.ForEach((CameraTarget targ, in Translation t, in Rotation r) => {
targ.transform.SetPositionAndRotation(
Vector3.SmoothDamp(transform.position, t.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime), r.Value);
}
}

warm panther
#
            _query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>());

How do I specify the type specializations for _query.ToCompoentDataArray<...> with this readonly query? the docs don't provide a concrete example for especially this case.

#

Just to check - you don't want something like this right? just psudocode obviously ```private void SmoothMovement : SystemBase ()
{
void OnUpdate()
{
Entities.ForEach((CameraTarget targ, in Translation t, in Rotation r) => {
targ.transform.SetPositionAndRotation(
Vector3.SmoothDamp(transform.position, t.Value, ref _smoothVelocity, smoothTime, Mathf.Infinity, Time.deltaTime), r.Value);
}
}

@amber flicker No I don't, that's fine for other purposes. I would like my camera and especially the UI to live in Mono space, at least until DOTS editor has a few more features to actually touch and find entities.

#

There's a clear 1:1 relationship, but I wanted to avoid using Singleton entities.

amber flicker
#

(just for clarity, CameraTarget in the above example is a MonoBehaviour - so just wanted to check you knew you could do that) - you want to keep the systems in the MB though?

warm panther
#

Because it's also a 1:n relationship, but the state "which n" is much easier to handle in Mono in these cases.

zenith wyvern
#

What do you mean by type specializations?

warm panther
#

the stuff in the brackets <....>

#
            var translations = _query.ToComponentDataArray<Translation>(Allocator.TempJob);

this doesnt work readonly

#
            var translations = _query.ToComponentDataArray<ComponentType.ReadOnly<Translation>()>(Allocator.TempJob);

this doesn't compile

#

(kind of obviously 😉

#

but here I am.

zenith wyvern
#
            var translations = _query.ToComponentDataArray<Translation>(Allocator.TempJob);

this doesnt work readonly
@warm panther
What do you mean it doesn't work?

warm panther
#

@warm panther
What do you mean it doesn't work?
@zenith wyvern InvalidOperationException: Trying to get iterator for Unity.Transforms.Rotation but the required component type was not declared in the EntityQuery.

#

Because it's the readonly type.

zenith wyvern
#

It's saying you didn't include Translation when you created your entity query

#

Err rotation

amber flicker
#

^ (well, Rotation right)

#

🙂

warm panther
#
            _query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>());
//laaaater

            var translations = _query.ToComponentDataArray< Translation>(Allocator.TempJob);
            var rotations = _query.ToComponentDataArray<Rotation>(Allocator.TempJob);
#

lol

#

ok

#

yes.

zenith wyvern
#

_query = _manager.CreateEntityQuery(ComponentType.ReadOnly<ControllableTag>(), ComponentType.ReadOnly<Translation>()); I don't see rotation

warm panther
#

these are getting too long

zenith wyvern
#

It doesn't help that you're trying to mix MB and ECS, it really wasn't made for that. I understand you have a good reason, but yeah

warm panther
#

It's not really mixing.

#

But I'll think some things over.

#

I've worked a lot with Entitas, where you usually have Views in gameobject land, and references to these views in ECS land. But it doesn't native-compile, so everything is pretty "normal" and C#, except for the components and entities that are pooled.

#

I like Entitas' extension syntax, where you can do entity.hasTranslation etc. In Unity ECS, I need to talk along a insanely long message chain, which is a capital code smell:

World.DefaultGameObjectInjectionWorld.EntityManager.HasComponent<Translation>(entity);
#

Sure, I can store an EntityManager reference but pracitcally, Entity should expose this info, but this might be the 1:30 am talking 😉

#

(I'm not saying Entity should contain the info, but expose the accessors)

zenith wyvern
#

As of the latest entities update inside a systembase you can just do HasComponent. Even inside a job, it will automatically be compiled to the "GetComponentDataFromEntity" bit, outside a job it gets compiled to EntityManager.HasComponent

warm panther
#

Yeah I noticed that and it is a big improvement

zenith wyvern
#

But yeah, the API definitely needs a lot of work right now. But it feels like they're moving in the right direction

warm panther
#

it's nice and fast enough to got me to start with it

#

if they shave 5 or 6 syllables off of most identifiers, I'll be happy.

And oh, as nice as Entities.ForEach() is, I haven't figured out how to make it work with a method/method group instead of an anonymous function. I really don't like how these read or indent, or debug, refactor, or anything, really.

amber flicker
#

you're not the only one who finds it verbose... but as Sark says, when you can work with ECS and the newer stuff, it's actually often pretty succinct I think - esp if you compare it to classic mb's and include having to find references to components on gameobjects, check they're not null and such - but it is early days

warm panther
#

Still a bit boilerplate, but it took Entitas a long time to reduce the boilerplate, and their ReactiveSystem still is a bit of a mess (and actually ECBs are a much nicer way of dealing with this, kudos, Unity)

odd cipher
#

Heyo, this might be a very broad question but, I'm wondering if I should use DOTS/ECS, if so, why?

zenith wyvern
#

If you're a hobbyist and you want to get in on the ground floor, then yes. If you're in production, probably not yet

#

ECS is the future for Unity as far as I know

odd cipher
#

Yeah because I'd have to rewrite a lot of my game to make it work with it

zenith wyvern
#

The normal way of doing things will be around for years yet I think, so there's no rush

warm panther
#

Yeah I'm prototyping a hobby project. In my day job, I run a studio of 13, and using SRP and addressables was already a hairy affair for a game we began in 2019 😉 Game turned out nice, though.

#

ECS is absolutely the future.

#

And it works, for the most part, exactly how my brain, which is awesome.

odd cipher
#

Alright, was just looking into some optimization for Texture2D or Threading and stumbled across this

warm panther
#

I don't like having to letterbox everything through the native APIs, takes away a lot of the expressiveness of C# - I would rather have a domain specific language for Systems, then.

zenith wyvern
#

You can always ignore ECS and just focus on jobs for now. Just learning how to use jobs properly can give you massive performance gains

warm panther
#

But... it's not bad. It's a huge improvement already.

#

Yeah, but ECS really lends itself to how I think about games.

odd cipher
#

Yeah having some problems learning Jobs :p

warm panther
#

It's Jobs that throw me off, probably because I always think they are just a wrapper for java.lang.system.Thread

#

PTSD, srsly.

odd cipher
#

I got Jobs working once but it seemed to have slowed down my "world creation" which is what I added it for, so I guess I was doing something wrong.

warm panther
#

So yeah, guess it would be healthy to get cozy with Jobs

zenith wyvern
#

Well if you have any specific problems or code snippets, feel free to ask here or on the forums

warm panther
#

Thanks for your help, everyone.

odd cipher
#

Yeah so, what I'm trying to do is optimize my 2D world creation, currently it takes 200ms to generate the whole world on a Texture2D. Thought I could try and reduce that with Jobs but I'm not sure it works in the way I want it to

#

as I said I did get it working with Jobs once but it pretty much just made it take 800ms instead, so I was probably doing something really wrong

zenith wyvern
#

What did you try? I assume you have color data that you pass to a job to be processed, then write it to the texture when the job is complete?

odd cipher
#

Yeah you pretty much summed it up there, the main problem was probably that I was creating a new Job for every "tile" on my map, which is 40,000 tiles.

#

Not sure though

zenith wyvern
#

Yeah that is definitely not right

#

In that case you would probably want to use an IJobParallelFor that does the per-tile work on each index of an array

#

You can tweak the batch sizes to decide how much work gets done on each thread

odd cipher
#

Interesting, I suppose I'll try and learn that then 😅

warm panther
#

Yeah you pretty much summed it up there, the main problem was probably that I was creating a new Job for every "tile" on my map, which is 40,000 tiles.
@odd cipher You should be a politician, you will definitely get elected after creating so many jobs.

odd cipher
#

Okay that's funny

odd cipher
#

@zenith wyvern Still having some problems with the Jobs system, dont fully understand it. everything is going wrong 😅

zenith wyvern
#

What's wrong specifically?

odd cipher
#

I dont really know to be honest

zenith wyvern
#

Well if you can give any more details we can try to help. What's not working - are you getting errors, is it not doing what you expect, are you not understanding the syntax?

odd cipher
#

I suppose I just dont understand the syntax

zenith wyvern
odd cipher
#

Yeah, currently getting this ```
IndexOutOfRangeException: Index 1 is out of restricted IJobParallelFor range [0...0] in ReadWriteBuffer.
ReadWriteBuffers are restricted to only read & write the element at the job index. You can use double buffering strategies to avoid race conditions due to reading & writing in parallel to the same elements from a job.

zenith wyvern
#

It's saying the native array in your job has a size of 0

#

So you haven't constructed it properly or you forgot to pass it to the job

#

Either that or you're trying to write to an index other than the index passed in Execute. To avoid race conditions you can only write to that index in an IJobParallelFor

odd cipher
#

Blegh, I don't think Jobs will work for this

zenith wyvern
#

Why not?

odd cipher
#

I just cant figure out how to make it work at all