#archived-dots

1 messages · Page 214 of 1

ocean tundra
#

@night venture another component

#

called scale

#

check out the transfrom system doc, it lists all the components that make up a transform in ECS

#

as there Scale and CompositScale or sonething

night venture
#

already tried that...but as im loading from a sube, i hope it would have such thing. even tried with rendermesh.bounds, but unable so far

#

ps: have u ever messed with [DisableAutoCreation] ?

ocean tundra
#

also read the conversion workflow, in some cases it wont add componets

#

eg when scale = 1 1 1

#

and yea i use it tons for my networking

stone osprey
#

@ocean tundra Thanks ^^ even if it cant live without another entity ? Thats why i thought it might be not the best idea to have an entity here... Is there any downside if i still go with the "Item is no entity" approach ? That way the json produced would look much clearer and would make more sense ^^ It also reduces the references between entities which is always a plus.

ocean tundra
#

nothing wrong with references between entities

#

and if the referece is in a different component your foreachs can not run if a item isnt 'attached' to a parent

night venture
# ocean tundra and yea i use it tons for my networking

by my tests, seems [DisableAutoCreation] is not invoking OnCreate neither OnUpdate.
World.GetOrCreateSystem<SystemA>(); creates but it doesn't start running/invoking the OnUpdate function each frame. i guess it's because is not added as part of a systemgroup or something.

are u able to make them start working (ie: Onupdate being invoked by engine)? do i have to schedule a new job or something similar?

stone osprey
#

Alright ^^ is there anything wrong with the "Item in inventory is no entity" approach ? I often hear people arguing between "Everything is an entity" and "Not everything should be one".

ocean tundra
#

@stone osprey both aproches will work, what is easier for you?
the main downside i can think of is you cant really schedule paraell on a dynamic buffer, but thats only going to be a issue if you have 2000+ items

stone osprey
#

And i actually have the feeling that both are right

ocean tundra
#

yea both are right 😛

#

its what works best for you

stone osprey
#

Well actually the "Item in inventory is not an entity" approach works "better" for me... its easier to implement. Probably not that performant, but it makes the persistence part easier ^^ Ahhh... im just gonna play around, if i dont like one of them i still can switch pretty easily to the other one 😄

ocean tundra
#

@night venture Yup thats right and how its meant to work
Look up DefaultWorldInitialization or something similar in the entities package
basicly manually creating a system is a 3 step process

World.Create... = gives you a system
UpdateSystemGroup.Add = adds the system to be updated
UpsateSystemGroup.Sort = does the update before/after stuff

night venture
ocean tundra
#

nope

night venture
# ocean tundra nope

UpdateSystemGroup probably changed in latest versions. im unable to find it so far, but this fight won't last too much 😛

ocean tundra
#

sorry you need to find the group you want your system part of

#

like when you use UpdateInGroup(typeof(....))

#

usually the simulationupdategroup

night venture
ocean tundra
#

probably

night venture
# ocean tundra probably

FYI:

ComponentSystemGroup systemGroup =World.GetOrCreateSystem<SimulationSystemGroup>();
systemGroup.AddSystemToUpdateList(World.GetOrCreateSystem<CarSystem>());
ocean tundra
#

you should sort too

#

that way if you ever add a system that needs to update before/after carsystem it will work

#

but also for general systems i wouldnt manually create them 😛

night venture
ocean tundra
#

your initializeation logic should just be a normal system with code in onupdate

#

using singletons to control execution flows

#

oncreates are for creating data eg native containers

night venture
#

do you really think the MAP should be created OnUpdate? it doesnt make sense, as it's static

ocean tundra
#

maybe for loading resources too, but really for messing with entities

#

i do

#

i would have a custom UpdateGroup

night venture
#

please, elaborate. Although I agree with the dots approach, not everything is a system, hence it doesn't make sense to create the map within OnUpdate and use singletons...

ocean tundra
#

something like MapGenerationUpdate Group, that contains a bunch of systems doing the map generation/loading stuff
I would have some sort of Singleton (IsLoading, IsDoneLoading) ect to feed data to a loading screen and to disable any gameplay systems

#

im assuming im creating a fixed size procedural map

night venture
#

thats overkilling for a tile map

ocean tundra
#

in the case of inifinate (eg minecraft) it would be a bit different

night venture
#

actually, a 10x10 map

ocean tundra
#

maybe, you dont need the system group, but the IsDoneLoading singleton would still work

night venture
#

please, be aware im a @student and prefer doing little steps and iterations to improve and learn, rather that building the game spenting month designing 😛

ocean tundra
#

and means your no longer manually messing with system creation

#

which is something to adviod

night venture
#

I truly don't think the expected way is having all those system, each one checking if game has finished task A to properly run taskB, instead of having a call at the end of taskA to run taskB.

#

at least, for such simple test-games like this...

ocean tundra
#

its a whole different programming model

#

OOP vs DOP

night venture
#

that still, doesn't solve the issue. I'm not talking about data, neither objects...I'm talking about game initialization.

#

PS: Scale doesn't work, as its only a float to change all xyz. I'm interested to change Y only

ocean tundra
#

read the transform system doc

#

for scale and rotation there are additional more complex types

#

and the whole system works optionally on the different bits

night venture
ocean tundra
#

yea thats it

stone osprey
#

Oh i heard OOP vs DOP

rugged totem
#

How complete is DOTS in regards to basic/core functionality? Is it still incomplete or just unpolished?

stone osprey
#

Actually data oriented programming is also kinda object oriented 🙂

ocean tundra
#

@rugged totem Run, run far away 😛
Its ready if you like doing things yourself, but all the nice stuff a game needs is still missing

Animations, sounds, all the awesome unity features are not there yet

stone osprey
#

Or you go with a hybrid approach... which i use mainly.
ECS for data and flows.
GameObjects for visuals/audio/animations only

#

Actually works better than expected

ocean tundra
#

yea thats the way if you want things to work and finish something

#

its what i should do 😛

night venture
stone osprey
#

^^ if you wanna finish something... my indecision in questions like "Is an Item an Entity or not" or "Is this [insert feature] a component, a data structure or probably something else" literally costs me weeks or months xD so the speedup from using an hybrid approach is wasted right here

north bay
night venture
#

and you both @stone osprey @north bay , for your initialization/systems sequencing...handle it using "isLoaded" or with [DisableAutoCreation] ?

stone osprey
#

I actually have no initialisation systems ^^ So i cant say anything about that, sorry...

night venture
#

...and if a system needs another one as a dependency?

stone osprey
#

Mine do not need any other systems as a dependency ^^ I mostly have all my Entities.ForEachs grouped by features in the same system. And if not, i code them using queues or whatever that their order does not matter at all

#

Or i use the CommandBufferSystems

night venture
#

between systems?

turbid sundial
#

Is there a good way to convert NativeArray to BlobArray?

ocean tundra
#

i dont know any way

#

i usually have to loop over my source data and manually create all the blob array items

#

as you need to use that blob builder thing

night venture
#

hmmm....i need some algorithm help.

#

consider my map is 10x10 and a car spawning on left side must choose a random destination, EXCEPT one next to them (on left side).

#

cars would use A*

#

how could I make car set a random location except those close to them?...

#

should i iterate first on tiles to remove closer than 1 from the list of potential destinations, and then, choose one randomly?

#

are u able to think a system which does not involve O(n) ?

#

would tagging closer spawn/destroy tiles with a common tag be as equally bad as killing a cat?

bright sentinel
#

@night venture Could always just choose 2 random coordinates, and if they don't fit your constraints, just choose two new ones

#

With 98 possible destinations out of 100 (assuming you also can't choose the same one), you would have 2% chance to have to rerun the RNG once

night venture
bright sentinel
#

I mean, it seems like the fastest solution given that the chance to hit an illegal node is so low

night venture
bright sentinel
#

You could also just first randomize which row you're on. If you don't hit the car's current row, just randomize the column as well. Otherwise, just choose a random number between the other tiles you're not on

night venture
solid rock
#

I have a single NativeArray I'm using across two different jobs. (ReadWrite in both jobs)

NativeArray<FluidBuffer> buffers;

I schedule the two jobs, with the second one depending on the results of the first.

UpdateFlow flowJob = new UpdateFlow(buffers);
var flowHandle = flowJob.Schedule(buffers.Length, 1);
UpdateContent contentJob = new UpdateContent(buffers);
var contentJobHandle = contentJob.Schedule(buffers.Length, 1, flowHandle);
contentJobHandle.Complete();

This works completely fine. However, I would like to change the NativeArray to a NativeList, so that I can add elements to it from the main thread. However, if I change to a NativeList, I get this error when I try to use the NativeList in this way:

InvalidOperationException: The previously scheduled job UpdateFlow writes to the Unity.Collections.NativeList`1[SadnessMonday.DiscIndustries.Fluids.FluidBuffer] UpdateFlow.buffers. You must call JobHandle.Complete() on the job UpdateFlow, before you can read from the Unity.Collections.NativeList`1[SadnessMonday.DiscIndustries.Fluids.FluidBuffer] safely.```Despite the fact that I am not changing the actual jobs themselves. They still treat the NativeList as a NativeArray. The do not add or remove elements from the list, and in fact only have a NativeArray reference to it.

Is there any way to bypass this error? I want to use a NativeList so I can add elements to the list on the main thread between runs of the job. But I don't need the list functionality for the job execution itself.
karmic basin
#

If you use the first jobhandle as a dependency when you schedule second one, it will be happy ?

solid rock
#

I already am doing that

#

And it is not a problem when the array is created as an array

#

but when it is created as a list, I get the error

#

Can I somehow pinky promise the safety system that I will not be modifying the length of the list?

naive ice
#

Continue to treat them as a NativeArray in your jobs - assign them via NativeList.AsNativeArray

solid rock
#

I am still treating them as a NativeArray in the jobs

#
    public struct UpdateFlow : IJobParallelFor {
        [NativeDisableParallelForRestriction]
        public NativeArray<FluidBuffer> buffers;

        public UpdateFlow(NativeArray<FluidBuffer> buffers) {
            this.buffers = buffers;
        }```
#

I am relying on the implicit conversion between NativeList and NativeArray in the constructor

naive ice
#

Odd, that should work.

solid rock
#

Changing the site where I create the jobs like this I still get the error:

            UpdateFlow flowJob = new UpdateFlow(buffers.AsArray());
            var flowHandle = flowJob.Schedule(buffers.Length, 1);

            UpdateContent contentJob = new UpdateContent(buffers.AsArray());
            var contentJobHandle = contentJob.Schedule(buffers.Length, 1, flowHandle);```
#

I also Tried AsDeferredArray()

#

even though I don't think that fits my use case

#

also doesn't work

#

I feel like the safety system wants to protect me from adding or removing list elements

#

which makes sense - but I'm not doing it 😦

naive ice
#

Yeah, I use the same pattern with DynamicBuffers with no issue. Could be a bug, I would make a post on the Unity forums and see if one of the Unity devs has any input 😦

solid rock
#

Ok thanks

torn hollow
#

so i make changes to the velocity of a gameobj during jobs with NativeArray<Vector3>. i update the gameobj at the end of the update loop like so

 for (int i = 0; i < number; i++) {
            if (VelocitiesArray[i].magnitude > maxVelocity) {
                VelocitiesArray[i] = VelocitiesArray[i].normalized * maxVelocity;
            }
            var obj = goList[i];  
            obj.transform.up += VelocitiesArray[i]; 
            obj.transform.position += VelocitiesArray[i] * Time.deltaTime;
            goList[i] = obj; 
        }

i can see that the rotation of the gameobj and the positon changes based on the velocity array. Then in the beginning of the update loop i change my velocity array based on the obj transform:

  // init arrays
        Transform[] TransformTemp = new Transform[number];
        BoidsPositionArray = new NativeArray<Vector3>(number, Allocator.TempJob);
        VelocitiesArray = new NativeArray<Vector3>(number, Allocator.TempJob);

        // INIT ---------------------------------------------------------------------------------------------------------------------------------------------------
        for (int i = 0; i < number; ++i) {

            var obj = goList[i];  // ref to current gameobject 
            TransformTemp[i] = obj.transform;  // for TransformAccessArray

            BoidsPositionArray[i] = obj.transform.position;

            VelocitiesArray[i] = obj.transform.forward * maxVelocity; // change start velocity HERE
        }

        TransformAccessArray = new TransformAccessArray(TransformTemp);  // so far so good

problem is that the gameobjs rotation resets each frame

#

this is important for an object avoidance behavior, rn my objs are all stuck on a rotation loop and wobble across the floor

#

am i doing something wrong with accessing the native array?

coarse turtle
#

Looks like you're accessing the values correctly in the native array

torn hollow
#

okay thank you

#

the deadline is tomorrow, so if you have any ideas what else might be the problem please go for it^^'

coarse turtle
#

if it's wobbling you might want to check your velocities, maybe the heading is incorrect when you're moving the boids

amber spindle
#

i need a bit of help

coarse turtle
#

check it on a single thread and verify that it's correct, then you can multithread it

amber spindle
#

has anyone done the doomcraft lesson thing?

amber spindle
#

Assets\WanderingAI.cs(34,25): error CS0103: The name '_fireball' does not exist in the current context

this is the error message i keep getting

#

how do i format my code for discord?

#
{
    public float speed = 3.0f;
    public float obstacleRange = 5.0f;
    private bool _alive;
    // Start is called before the first frame update
    void Start()
    {
        _alive = true;
    }

    // Update is called once per frame
    void Update()
    {
        if (_alive)
        {


            transform.Translate(0, 0, speed * Time.deltaTime);

            Ray ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;
            if (Physics.SphereCast(ray, 0.75f, out hit))
            {
                GameObject hitObject = hit.transform.gameObject;
                if (hitObject.GetComponent<PlayerCharacter>())
                {
                    if(_fireball == null)
                    {
                        _fireball = Instantiate(fireballPrefab) as GameObject;
                        _fireball.transform.position = transform.TransformPoint(Vector3.forward * 1.5f);
                        _fireball.transform.rotation = transform.rotation;
                    }
                }
                else if (hit.distance < obstacleRange)
                {
                    float angle = Random.Range(-100, 100);
                    transform.Rotate(0, angle, 0);
                }
            }
        }
    }
    public void SetAlive (bool alive)
    {
        _alive = alive;
    }
}```
ocean tundra
#

@amber spindle What has this got to do with DOTS? i think your in the wrong place

solid rock
#

All I had to do was cache the length of the list in an int before scheduling the job and use that.

naive ice
solid rock
#

Yeah the safety system is pretty nifty

sturdy rune
#

I just copied the cube Netcode example into a 2020 LTS project and it is not working, and in fact gives me job temp alloc errors... perhaps I am missing osmething

stone osprey
#

Damn... i think im gonna implement my items as entities instead.
Just realized that they should execute different actions... like when a player clicks on them inside the inventory or when they are equiped etc... so i think its better to have them as seperate entities instead of structs.

north bay
#

Might be interesting to some

minor sapphire
#

that is an interesting post...

#

"Future releases of Entities will not be compatible with Unity 2021 until the end of the year at the earliest." wow

#

"I will leave the thread open for questions, but please understand that this is the information we can share at this point in time."
They are really holding their cards close to their chests lately...

frosty siren
#

what means by entities based package? "Entities" itself and ...?

minor sapphire
#

maybe hybrid renderer?

north bay
frosty siren
#

Can it be that render features for 2D URP, which i so waiting for, will be available in 2021 and not in 2020? I don't really know how features migrating between versions

coarse turtle
#

hmm damn

karmic basin
#

Thanks Script !

#

"Future releases of Entities will not be compatible with Unity 2021 until the end of the year at the earliest" is sure a hard one 😭

#

Not that I need 2021, but seeing so much hassle to deploy updates is not good news

little moon
#

That means no Deffered or Forward+ renderers until at least end of the year :/

hollow sorrel
#

entities + physics seems to work on 2021.1 tho?

#

at least at first glance

#

.1

pliant pike
#

maybe on the alphas but not on the official 🤔

minor sapphire
#

perhaps they are saying this in anticipation for entities .18 release?

safe lintel
#

it was oddly worded mostly saying 2021.1 but not mentioning 2021.2 also does this mean the 2022 alpha is around the corner?

amber flicker
#

If they're already saying 'not before the end of the year'... surely that means 2023ish?

safe lintel
#

i asked how 2021.2 factors into it and got this ominous response
We will expand on this specific point in the next posting we make on DOTS releases.

amber flicker
safe lintel
#

sounds deliberate, much like how mine is super vague 😆

zenith wyvern
#

With the way package management works from 2021.1, we have to have different ways of delivering Entities packages to our users. What on earth does this mean

light mason
#

I thought the same thing ^

amber flicker
zenith wyvern
#

It sounds to me like we won't be able to use the package manager anymore or something, like we'll just be getting a big zip file

#

Or more likely one file per package I guess

light mason
#

Can some give me a high lvl explanation on why

amber flicker
#

Well... Entities released are about quarterly now - not a stretch to imagine they just ship a new version of Entities with each Unity . release?

light mason
#

I read Martin post but I’m not sure why a change is needed

#

What driving this , why not just stick to what there

#

@amber flicker does that mean we can’t use interim version

#

Of unity

amber flicker
amber flicker
# light mason What driving this , why not just stick to what there

My take? Trying different approaches to deal with the fact 100's of teams are working on different aspects of the engine and users are having a very frustrating time trying to find a working combination. Where the only real fix is to change less or magically have the work further along I guess.

light mason
#

Isn’t this essentially removing ECS from the tech stream

zenith wyvern
#

Until the end of the year, that's what it sounds like yes. Which is a bit odd since it's a 180 from previous releases where they always seemed to target the cutting edge, or a couple versions behind that at least

light mason
#

I feel down about this

zenith wyvern
#

Eh, not worth getting too worried about it until there's more info. I'm mostly just frustrated that this is the first bit of communication we get about dots in months and it's all very vague and confusing

light mason
#

Yea your right , will just wait and see

karmic pilot
#

especially since from 2018 onwards ECS as integral part of DOTS has been pushed very hard for publicity sake, but now it is the first major preview package that is incompatible with new unity tech releases

stable sentinel
#

wait you cannot use entites with the new unity versions?

#

I mean it is okay as long as you aren't using 2021 I guess

solid rock
#

you can use entities

#

it's just a pain to add it to your project

sturdy rune
#

but you can use entities 0.17, just not newer

#

they are saying newer versions of entities not compatible

light mason
#

How does this affect tiny

bright sentinel
#

So only 0.17- is supported in 2020. 0.18 MUST be supported by something

zenith wyvern
#

Since Tiny depends on ECS I would guess it means you're locked to 2020

ocean tundra
#

yea they didnt say what 0.18 works on

#

whats the point in them even releasing it if it wont run somewhere :/

zenith wyvern
#

I took it to mean .18 and all future versions will be locked to 2020 for the foreseeable future

bright sentinel
#

But it seems that the package manager is the main kinda issue

#

So maybe some sort of bundle we can download?

ocean tundra
#

yea that will make sense, 2020 i mean

bright sentinel
#

Or a custom editor? 🤔

ocean tundra
#

sorry actually maybe a custom version drop

bright sentinel
#

But I mean, it would be insane if 0.18 is now stuck to 2020

#

What about in 3 years?

#

Then it's still on 2020...

ocean tundra
#

that would have solved this by then

bright sentinel
#

Well then why not just solve it now?

ocean tundra
#

no way they can leave DOTS on 2020 forever

keen yoke
#

what is dots

bright sentinel
#

Right, that's why I'm thinking a custom editor or smth

#

Like a fork of the current editor

ocean tundra
#

yea that makes sense too

keen yoke
#

hmmm

ocean tundra
#

@keen yoke see the pinned messages

keen yoke
#

oki

ocean tundra
#

i expect it will be a yearish tho

keen yoke
#

:)

ocean tundra
#

they wont want to be updating/releasing a custom version all the time

bright sentinel
#

Maybe it's just a way to really differentiate ECS that's in preview from non-DOTS preview stuff

ocean tundra
#

dont they have that expermental tag in package manager for that?

bright sentinel
#

Well obviously that wasn't enough since the Entities package was still removed

ocean tundra
#

maybe its the DOTS changes are now requiring core unity changes, which for some reasion they cant make it combatabile with old MBs

bright sentinel
#

Yeah, that's also quite plausible

#

But it seems kinda weird

ocean tundra
#

yea

#

wish they would be a bit more vocal about things, like a small technical paragraph about WHY they are doing this

#

maybe its as simple as supporting changing unity versions is just taking too much time

bright sentinel
#

Well that would just be shooting themselves in the foot

ocean tundra
#

true

light mason
#

It should all have been package .. with SRP shipping with editor and ECS potentials locked to 2020 it going to be extremely difficult to get a working combination of the editor

#

I’ve digging through my notes trying to reason what I need where

ocean tundra
#

i though that the SRP shipping with editor thing was still a package, but its basicly a 'default' package?

light mason
#

I’m not sure about that, I was under the impression is part of core

ocean tundra
#

dam that feels like a step back

light mason
#

I hope I’m wrong

safe lintel
#

maybe release a compatible editor only to their big customers paying a lot of money. thats what the cynical side of me thinks

minor sapphire
#

nah lol

#

I can imagine internally a disagreement between entities and packman teams 😄

#

something going on

#

"you keep breaking our packages! We're leaving!"

#

lol

safe lintel
#

like an advanced alpha 😆 hell they got one of the unity teams making custom dots demo ports for em

minor sapphire
#

I read the package manager changes blog post, but I can't see what about it would be the reason to need a new delivery method...

#

"With the way package management works from 2021.1, we have to have different ways of delivering Entities packages"

#

that's such a curious thing to say

#

I also remember a guy saying, quite a while ago now, that .18 was coming soon, so my bet is package manager changes have been the hold up, and not necessarily significant changes to entities...

#

I hope I'm wrong, I want tag enable/disable 😄

ocean tundra
#

yea i dont understand that line either, i dont understand how the current/new package management changes will effect DOTS

#

its already hidden, and a manual Add Package (with the full annoying package name) to add it

safe lintel
#

i didnt even know there were major changes to the package manager

#

in 2021

ocean tundra
#

it seemed to me just a renaming of things

#

this bit is interesting too "but please understand that this is the information we can share at this point in time. "

#

why cant they share more???

#

maybe some sort of business deal? like microsoft being interested in DOTS for the general C# stack?

minor sapphire
#

I reckon they're just tired of saying something too early and then getting shit for it later

safe lintel
#

i mean it wouldnt surprise me if a big enough company wanted to pay for a bit of a timed exclusive for the tech, first to market or something

ocean tundra
#

that would suck so hard

#

but yes i could see that

safe lintel
#

though the bungling of the rollout for this would make it seem like its just more mismanagement

ocean tundra
#

i guess just wait and see

#

out of interest, what 2021+ features will we be missing?
Theres the URP Deferred feature, anything else?

safe lintel
#

not sure what its called but incremental build caching thing to reduce build times

#

uitk being compatible with subscenes

ocean tundra
#

ohh that UITK would be nice

#

but i guess i can survie for now

coarse turtle
safe lintel
#

i dont really know why it breaks subscenes, only that it does (in 2020.x)

#

just the presence of the two packages together make subscenes not work, dont need any code that references either thing

coarse turtle
#

oh 🤔

minor sapphire
#

there is some of the c# 9 feature set

#

I was looking forward to this:

public static bool IsLetterOrSeparator(this char c) =>
    c is (>= 'a' and <= 'z') or (>= 'A' and <= 'Z') or '.' or ',';
#

also this

WeatherStation station = new() { Location = "Seattle, WA" };
coarse turtle
#

o - that's cool

minor sapphire
#

and this too

public WeatherForecast ForecastFor(DateTime forecastDate, WeatherForecastOptions options)
{
}
var forecast = station.ForecastFor(DateTime.Now.AddDays(2), new());
ocean tundra
#

c# 9 is so far away tho

#

for unity i mean

minor sapphire
#

it's out in the alpha now

#

but a subset

#

the features above are out

ocean tundra
#

i didnt think it was,

#

nice

minor sapphire
#

released in alpha 11

ocean tundra
#

when i last saw it about a month ago it was just for some internal Unity tools

coarse turtle
#

I think i remember reading that they're trying to aim for .net 6 to be able to fully support c# lang features

ocean tundra
#

any idea if roslyn (update) + source generators are included?

minor sapphire
#

I'm not sure

#

what will you use them for?

ocean tundra
#

im generating a ton of code for my networking tech, currently i just put it out in the users Unity project

#

but source generators give me a bit more flexability with it

minor sapphire
#

This was the release note point from alpha 11

Scripting: Updated C# language version to 9.0 for compilation and IDE's
We will support a subset of the language features from:
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9
These is the features that we support:

Pattern matching enhancements
Function pointers
Target-typed new expressions
Static anonymous functions
Target-typed conditional expressions
Extension GetEnumerator support for foreach loops
Lambda discard parameters
Attributes on local functions
New features for partial methods.
ocean tundra
#

the for compilation and IDE's looks promising

coarse turtle
minor sapphire
#

Is that related to c# 9 function pointers?

Function pointers provide an easy syntax to access the IL opcodes ldftn and calli. You can declare function pointers using new delegate* syntax. A delegate* type is a pointer type. Invoking the delegate* type uses calli, in contrast to a delegate that uses callvirt on the Invoke() method. Syntactically, the invocations are identical. Function pointer invocation uses the managed calling convention. You add the unmanaged keyword after the delegate* syntax to declare that you want the unmanaged calling convention. Other calling conventions can be specified using attributes on the delegate* declaration. For more information, see Unsafe code and pointer types.
#

this stuff is a little too deep for me...

#

and what does this all imply? delegates with burst or something?

coarse turtle
#

Yea I imagine delegates with burst

ocean tundra
#

we have that tho

coarse turtle
#

yeah through FunctionPointer<T>

ocean tundra
#

i guess this is native instead tho

minor sapphire
#

can I put a delegate pointer on an IComponentData? I have no use case, I'm just thinking it sounds wild lol

ocean tundra
#

actually its FunctionPointer 😛

#

yea pretty sure the FunctionPointer<T> can go in

bright sentinel
#

Is it blittable?

ocean tundra
#

i havnt tried but it is a sturct

minor sapphire
#

wondering if anyone can give me some thoughts...
I have blocks. They can be destroyed. When I destroy a block, I'm just hiding it via the shader and temporarily disabling it's collider. It regenerates and re-appears late.

#

When it's gone, I want to replace it with a more dynamic destructable box

#

so we can go pew pew and it gets destroyed..., and slowly regenerates

#

if I pew pew too many blocks at once, I will have many destroyed bits, so lots of little cubes for rendering and collisions, and thinking how best to handle this...

#

Preferable is to have the little cubes have damage values too and visually displayed by changing colour, some glowy red hot effect kinda thing...

#

but this is not 'manadatory'

#

so I thought... ok, OctTree?
start with big boxes and end up with small boxes at lowest grain?

#

could go with instantiate and destroy block entities of various sizes...

#

or... could go with voxel mesh generation based on the octree structure... I don't really need to worry about 'block types' like typical voxel generation...

#

but updating meshes all the time with lots of destruction happening all the time...?

#

could do some kind of 4x4x4 64 block grouping and have the shader disable individual blocks. Overdraw though?

#

I go think more 😐

robust scaffold
robust scaffold
# minor sapphire I go think more 😐

✔️ Works in 2020.1 ➕ 2020.2 ➕ 2020.3
🩹 Fixes:
► Make sure your source mesh has read/write enabled in it's asset importer inspector.

Compute Shaders are scripts that run on the GPU! They're very powerful, allowing you to leverage the GPU's unique abilities and generate meshes to draw procedurally. There's not a lot of information on using them, ...

▶ Play video
minor sapphire
#

It will require dots physics, and also with entities and burst, options like individual cubes, and small voxel mesh chunks in burst are available

#

I actually did not think about compute shaders

robust scaffold
#

"Simple" guide with a shader that adds a vertex in the center of every triangle, reconnects all the vertices, and extends the center vertex in a sinusoidal pattern inside and out.

minor sapphire
#

I will consider this option too

robust scaffold
minor sapphire
#

hmm it might not require dots phyiscs...

robust scaffold
#

Theoredically, there are plenty of research papers on GPU side physics calculation. Although if you get that working, you too might be in the position for your own PhD.

minor sapphire
#

haha

robust scaffold
#

Aim for the sky. The worst that can happen is a university offering you a position in their computing department.

minor sapphire
#

if I don't need the mesh back for physics, can I avoid pulling it back to cpu?

robust scaffold
#

Definitely. That's the main bonus of compute shaders. Generate dynamic meshes in compute shaders then have regular shaders read the mesh data and display on screen.

#

Extremely performant. Main issue is the very sensitive Unity side rendering calls.

#

Large amount of boiler plate and low level rendering systems. Cant really help there but follow that youtube link.

#

That's just a basic example of 2d physics. 3d is just extending that into a third dimension.

minor sapphire
#

ah well I'm using unity physics so I don't think I'm gonna split up a bit onto GPU

#

but I don't think I need a mesh collider for my boxes 🙂

robust scaffold
#

Yea, good luck. Start exploring more ways to subdivide cubes. Basically you'll end up at compute shaders or very close it.

minor sapphire
#

hah yeah well I started with thinking octrees

#

but still, ends up with creating/destroying many little boxes...

#

which I wouldn't dream of in a non dots world...

robust scaffold
#

DOTS definitely is not intending for trees. Any sort of nesting, no way.

minor sapphire
#

you can still do it, you just don't benefit from cache coherency etc much

robust scaffold
#

DOTS is basically how far you can go with making everything fit into a one dimensional array.

minor sapphire
#

lol, well, to a degree yes, but you can still use other things when you need to

robust scaffold
#

Do everything per entity, per index, per data. Basically a CPU shader.

minor sapphire
#

haha yes

robust scaffold
#

In fact, if I remember correctly, that's how they recommend you write DOTS code. Pretend it's a much more flexable frag shader where the pixels being iterated over are entities.

#

So no loops, no if else, no conditionals beyond inline ?: code.

minor sapphire
#

yes, but they always fall back to, "it always depends on your use case"

#

just depends on where your hot spots are

robust scaffold
#

Yea, that's unity. Burst is magic though. Everything about DOTS is a simple question: can it be shoved through the burst compiler?

#

Anyways, I got to get back to work. I'm burning through my free time (procrastinating on homework, the usual) and I need to figure out how dots netcode works.

solid rock
#

So can I think of it this way?

Using DOTS at a basic level gives me at least a performance boost of Nx where N is the number of CPU cores. But that's the lower bound. If I can also structure things to take maximum advantage of SIMD and cache coherency and all that good stuff then you really open up the throttle

minor sapphire
#

I wouldn't agree with your opening statement. That's depending on how well you can multithread your code. But ECS does make it easier to jobify if you're following ECS design patterns.

#

Those design patterns will also lend themselves to playing nice with the cache, and if you do it right a lot will be burstable too

#

with that combination, you can have really great performance

#

SIMD you can get in very particular situations

#

or also hopefully more situations without realizing lol

#

I have helped a couple of people convert some clunky unoptimised MB hot spots into bursted jobs

#

for the first guy, he got 100x speedup lol, it was so perfect for job bursting and he didn't realise

#

the second guy, got a 15-16x speedup on his hotspot

#

neither of those cases used ECS though, so you can still get great gains with just jobs and burst

#

and neither of those cases was really thinking hard about the data, more like "how can we get this to run in a burstable job" 😄

light mason
#

Maybe because burst and job are production ready it somehow lock ECS to that verified editor version, idk I’m really trying to figure this out for my own sanity.

remote crater
#

Want to see some show off videos I just posted a few minutes ago to show off new tech? :

https://youtu.be/qGUlnDIOrLA

&

https://youtu.be/3ssXMbfGCPI

I'm so excited. I got my world builders on. ECS/DOTS is a huge huge technology. Unity's stock will soar!!! And then when people see their cores help the game performance, people will but computers with more cores. Within 7 years, expect 1024 cores. So we get 10-1000x as many objects today. In 7 years, this figure will probably be 1000x-1,000,000x what we have now.

Enjoy the future of gaming.

If you like what you saw, please sub for more. It helps me. It may help you, but I make no promises!

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/goodnewsjim The Bro Zone Layer.

Temporary offer for anyone of any skill level: Can someone contact me to promote my game? www.starfightergeneral.com I'll gi...

▶ Play video

If you like what you saw, please sub for more. It helps me. It may help you, but I make no promises!

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/goodnewsjim The Bro Zone Layer.

Temporary offer for anyone of any skill level: Can someone contact me to promote my game? www.starfightergeneral.com I'll gi...

▶ Play video
viral comet
#

Hi Guys!
I use ConvertAndDestroy mode in my conversion.
For some reason, Authorings are still adding to the entity. Why this is happening?

minor sapphire
#

@remote crater you're underselling. You said 30fps but you: 1. are not in a build. 2. Have the scene view open. (3. did you disable the usual like safety checks and jobs debugger etc?)

#

But you're overselling the future 1,000x to 1,000,000x in 7 years lol

hollow jolt
#
using System.Runtime.CompilerServices;
//...
public class Klass
{ 
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static float Calc1( float a, float b ) => math.abs( a - b );
    
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static float Calc2( float a, float b ) => math.fmod( a , b ) - math.pow( a, b );

    static void Run()
    {
        Method( Calc1 );
        Method( Calc2 );
    }

    static void Method( Func<float,float,float> execute = null )
    {
        for( var i = 0; i < 10000000; ++i ) 
        {
            float result = execute( math.atan( i ) , math.sin( i ) );
        }
    }
}
#

trying to understand method In-lining

#

would this example be a good practice ? i want to avoid making 2 Run functions that use Calc1 and Calc2 , not sure how efficient this way of doing this

#

My concern is about passing the inlined method as an argument : Method( Calc1 );

gusty comet
#
UnloadTime: 2.379400 ms
NullReferenceException: Object reference not set to an instance of an object
  at Unity.Scenes.ResourceCatalogData.GetGUIDFromPath (System.String path) [0x00096] in <6d6849833010407eaf68aacfba8931a1>:0 
  at Unity.Scenes.SceneSystem.GetSceneGUID (System.String scenePath) [0x0000b] in <6d6849833010407eaf68aacfba8931a1>:0 
  at Unity.Scenes.GameObjectSceneUtility.AddGameObjectSceneReferences () [0x00034] in <6d6849833010407eaf68aacfba8931a1>:0 
**  at Unity.Entities.AutomaticWorldBootstrap.Initialize () [0x0000c] in <666db234fd54498496918391b0314900>:0 **

some dots stuff resulting in error in build

karmic basin
#

You built from platforms package or legacy way ?

gusty comet
#

ctrl+b

karmic basin
#

your subscene might not be in the build

#

okay i saw scene that's why but yeah probs missing entity stuff in your build

#

sometimes it looks like it works, but there are missing pieces

#

entities related stuff

#

that didn't exist when they built the first build pipeline

karmic basin
#

You can use entities packages from MB

#

you can access EntityManager, thus your worlds, entities, create queries, and so on

karmic basin
#

You deleted your questions, all solved then ?

gusty comet
#

No, I have unity physics package and it displays in entity debugger but my character falls through it

#

character is MonoBehaviour/GO

coarse turtle
#

Does the character use Unity's dots physics or does it use the MonoBehaviour physics 🤔

gusty comet
#

character has normal mesh collider monobehaviour

#

Entity has mesh collider too and convertToEntity

coarse turtle
#

idk how supported dots physics conversion is, been a while since I had used it. But I'd probably check the collision layers

gusty comet
#

do i need physics body script?

coarse turtle
#

Yea most likely I'd imagine

gusty comet
#

i hope it will work with monobehaviours collisions

coarse turtle
#

They're 2 different systems - they're wont communicate with each other

#

so you should either pick dots physics or monobehaviour physics

gusty comet
#

really? damn

#

will adding PhysicsShape to GO player (non entity) work though?

coarse turtle
#

Well if you are converting your gameobject to an entity and it has all of the appropriate components

gusty comet
#

my project is a hybrid so i need both entities and GOs to have collisions

coarse turtle
#

then you're likely using dots physics

coarse turtle
#

so you're not converting them - or linking the gameobject to an entity

gusty comet
#

the world is entities and player is not entity

coarse turtle
#

well to kind of support both gameobjects and entities - you can take a look at companion conversion

#

your gameobjects will still convert to an entity, but you will still have the gameobject representation

#

it'll be all entity driven tho, so you will be using dots physics if anything

gusty comet
#

are you completely sure that i need it to make this work?

coarse turtle
#

Well you can only pick 1 physics system as your way to resolve collisions

#

so you either pick monobehaviours or dots

#

if you are okay with having your gameobjects be entities driven, then companion workflow may work for you and you will be doing most of your game logic in entities

#

if you absolutely need things to be monobehaviour driven - then you may have a more difficult time trying to interface things with entities (might need to reconsider your approach)

#

e.g. you can have your character continue to use the SkinnedMeshRenderer + Animator using the companion workflow (if you don't want to dive into the dots animation package) but have it use dots physics to resolve collisions

gusty comet
#

how

#

hybrid components are slow docs are saying

#

eg same as not using dots at all

zenith wyvern
#

The point was you need to pick a physics system. Either gameobjects or dots physics. The two can't interact with eachother

eager jungle
#

Hey. Enabling hybrid v2 on unity 2020.3.3f1 (hdrp) triggers ArgumentException: Kernel 'CopyKernel' not found. in SpareUploader.cs. Any idea how to fix that?

little fern
#

hello, I have some questions about the job system (without dots) - is this channel optimal for them or should I ask in #archived-code-general ?

zenith wyvern
#

Jobs is part of dots so it's fine to ask here

little fern
#

ok great! 1.) can I use coroutines in the job system or should I think of a job as a sort-of coroutine ?

gusty comet
#

theres way too much MONO only stuff eg IK or custom scripts

zenith wyvern
#

As psuong said you need to reconsider your approach. The two physics systems cannot interact.

zenith wyvern
#

You can use coroutines and jobs together in some ways but you just need to remember that coroutines are main thread only, and jobs have a lot of restrictions on what can be passed into them

little fern
#
  1. can you please point me to some resource that can help me move an object towards a position ?
little fern
zenith wyvern
#

It's a bit too broad, maybe if you show what you've tried or give a more clear picture of what you're trying to do

little fern
#

say I have a cube; I want to move that cube towards (for example) another cube, the movement should be linear

zenith wyvern
#

I guess my question would be why do you need the job system for that

little fern
#

im moving a lot of objects and I dont really want to get into dots

zenith wyvern
#

Okay but moving a cube to a position really has nothing to do with dots. There's plenty of resources online on how to do that or you can ask in one the other channels. Or are you just confused about the syntax of how to schedule a job?

little fern
#

the latter

zenith wyvern
#

What about them isn't clear?

little fern
#

ok this didnt show up for me before lol - for some reason I got a 404 error when trying to look at this before

#

anyways thanks for you help, Ill check it out!

zenith wyvern
#

No worries, feel free to come back if you run into trouble with the implementation

little fern
#

sure thing 🙂

gusty comet
#

what do you guys think about having whole world and environment made by dots, but when player gets close, you create invisible objects with colliders in place of entities (but no renderer) ?this way u can have monobehaviour collisions and ecs-rendered world lol

#

of course you can kill colliders when you get further

#

mesh colliders on invisible GOs can get their mesh reference from entities too

#

and you can do pooling of these GOs

#

in my case, id also syns these GOs positions with entities positions every frame
but it wouldnt be really costy at all cause there would be prob no more than like 10 at one time

safe lintel
#

if you can avoid monobehaviours Id avoid any kind of switching in between

gusty comet
#

well no i cannot but i think this solution is gold

hollow sorrel
#

@gusty comet if it works it works
but imo i'd have ecs be the source of all logic, and only use gameobjects for rendering
so transfer of positions would be ecs -> gameobject
in your case if you wanted to move objects in ecs, it'd be like ecs -> gameobject -> ecs which can cause lots of bugs

gusty comet
#

the gameobjects are not syncing back to ecs

#

ecs is moving everything

#

gameobjects are just copying position and mesh from entities (mesh only for collision not rendering)

safe lintel
#

I just find it a hassle to have any real interaction between the two in a way that goes beyond interaction or ui. I do use animators for my characters and navmeshagents but I want to drop them asap.

hollow sorrel
#

oh i misunderstood then, thought you were using gameobject physics too
i think it depends on what you use those collisions for then

gusty comet
#

yeah i collide player with them

safe lintel
#

what in particular do you rely on gameobjects for anyway?

gusty comet
#

because player cannot collide with entities

#

so i will pool gameobject based colliders

hollow sorrel
#

how do you collide player without syncing positions back to ecs

gusty comet
#

player is not entity

#

player MB collides with colliders that are GO-based

GO-colliders inherit mesh (for meshcollider) and position/rotation from entities

safe lintel
#

why in particular do you have go colliders

#

just curious about your needs for monobehaviours

gusty comet
#

cause entity cant collide with GO and most of my game is in GO

safe lintel
#

if you are adapting an existing project to use ecs I guess it makes more sense, but it sounds a little like these colliders would be static? and in my mind good candidates for being actual entities but its still not a lot of information

gusty comet
#

well you cant collide player's GO with environment entity colliders

robust scaffold
#

Oh fuck

#

I think this might be the beginning of the end.

#

Welp, time to convert my entire logic to IJobParallelFor and IJobParallelForTransform.
Time to roll my own ECS format.
It's been nice knowing DOTS these past few months and years but it's being lowered slowly into the grave now.

light mason
#

I think it’s fine

#

I honestly think ECS dev are feeling the pain of working in a non stable unity and maybe want to lock the ECS to lts version , I mean noting worse that debugging issues not relating to your current work

#

This is 200% just my speculation

#

What ever the reason I did not sleep well

robust scaffold
# light mason I honestly think ECS dev are feeling the pain of working in a non stable unity a...

True. Whenever some bug internally from Unity pops up, it's such a pain to find a fix. Like that tempJob allocation error that appears if the game view is not vsync'ed.
Honestly, I'm actually relieved that this post came down. My projects rely heavily on multiple camera and camera layering in HDRP so I'm sticking with the Alpha pipeline.
That means I should no longer care about DOTS. Unity themselves are cutting the support.

light mason
#

I’m in a similar boat

robust scaffold
#

Years ago, back when DOTS was basically Burst and IJob, I rolled my own ECS system using a fuck ton of NativeArrays and custom containers. The boilerplate was real.
Gotta dust off those old codes and reimplement it. Maybe I was onto something back then.

light mason
#

I don’t think ECS is going anywhere

robust scaffold
#

Actually, I wouldnt be surprised if a community version of Entities based solely on a collection of NativeArrays in MonoBehavior appears. Just for those using it for data management.

#

Burst and IJobParallelFor isnt going anywhere. Unity sunk a metric ton of money into that and is being rolled out everywhere. DOTS, hrm. A lot more murky.

light mason
#

Did they mention ECS and GDC ?

robust scaffold
#

In the forum post? No. Just a declaration that future Entities packages will not be supported on 2021.1 and newer. Only 2020 LTS.

#

I cant think of a package that was continued to be developed beyond life support that remained in LTS. Last time something like this happened was UNet, and we all know what happened to that.

#

RIP UNet, but we got Mirror out of that slow death so maybe net positive?

robust scaffold
# gusty comet rolling to grave

Make your own entity component system. A bunch of native arrays, one for each "component" aka struct. The indices for the arrays would be the "entity". A set of native arrays all with corresponding indices/entities will be a "chunk". Instead of Entities.ForEach (which is a glorified IJobEntitiesForEach/IJobEntitiesChunk) you go straight down to the root IJobParallelFor and use the NativeArrays as ComponentDataHandles.

#

The only part from Entities package I'll miss will the the DynamicBuffers. Theres no easy equivalent in the base Job and Container package other than fixed size Buffer lists (RingBuffers and FixedLists).

#

Actually, when you think about it, I think DynamicBuffers are just FixedLists.

#

The real sad part is that we'll never be able to fully burst the job creation process now that Entities is dead. Hopefully the newer Burst versions and calling bursted functions in managed code might be ported to the job system.

gusty comet
#

but why?

robust scaffold
#

Why what?

gusty comet
#

ohh i just read the news

#

well its long time till 2021 gets out of alpha anyway

robust scaffold
gusty comet
#

oh im on lts lol (2020)

robust scaffold
#

It still works but bug reports and potentially breaking changes will no longer be fixed.

gusty comet
#

so no updates till end of year

#

nah no way im gonna make my own entity system lol

#

just stay at 2020 version

crude sierra
#

hey guys, question.. let's say i have 20000 moving capsules and I want to act on the collision of each of them (with themselves or other objects)
doing this with ICollisionEventsJob proved to be not enough in terms of performance.. also I assume I have to use Physics Bodies and Physics Shapes in this regard, what implementation would be best to handle this many collision events?

robust scaffold
#

And probably beyond. Yea, my projects go heavy on the HDRP shader side and multiple cameras. I really cant afford to lag behind and then upgrade all my shaders when Unity eventually pushes the entities version to whatever is the current version at the time of release. I dont even use hybrid renderer. I manually sync my entities with game object transforms. So annoying.

robust scaffold
crude sierra
#

they can be triggers, my action is destroying them on collision

robust scaffold
robust scaffold
robust scaffold
crude sierra
#

currently, im using one collision jobs to add collided entities to a NativeArray followed by a regular job that iterates over it and uses ecb to destroy them

robust scaffold
crude sierra
#

how do i access the entity tho inside a CollisionJob?

#

it doesn't know how to destroy entities, the job can recieve only IComponentData

robust scaffold
#

You can have an entity inside a IComponentData.

crude sierra
#

i have the entity itself, i just cant access any managers to destroy it within that scope

#

or am i missing something

zenith wyvern
crude sierra
#
 private struct CollisionJob : ICollisionEventsJob
    {
        public void Execute(CollisionEvent collisionEvent)
        {
          //Destroy collisionEvent.EntityA
        }
    }

this is what i cant figure out how to do basically

zenith wyvern
#

That should be very fast

amber flicker
crude sierra
#

but surely destroying them within the collisionjob if possible is the quickest way, instead of managing a nativearray?

robust scaffold
#

Something like this:

private struct CollisionJob : ICollisionEventsJob
{
  public EntityCommandBuffer ECB; // Dont remember the exact type.
  public void Execute (CollisionEvent collisionEvent)
  {
    ECB.Destroy(collisionEvent.EntityA); // Or something. Dont have the parameters of collision event
  }
} ```
amber flicker
robust scaffold
#

Then in the creation/queue of the job, you pass in ECB from the main thread. Dont know about performance, might still be shit.

crude sierra
#

hmmm

#

time for trial and error i suppose

zenith wyvern
robust scaffold
#

If you need performance, and thats what it sounds like with 20k entities, you'll need to customize the render pipeline. In fact, you probably need to do it outside DOTS entirely and use a ComputeShader. I believe the world positions of meshes can be obtained in a shader then use that to compute collision events and then selectively render meshes inside a compute shader.

crude sierra
crude sierra
crude sierra
#

regarding actually moving the capsules, would you say this way is the most performant?

    protected override void OnUpdate()
    {
        Translation playerBase = GameConstants.Instance.PlayerBasePosition;
        float deltaTime = Time.DeltaTime;
        Entities
            .WithAll<AttackerComponent>()
            .ForEach(
                (ref AttackerComponent attacker, ref Translation attackerPos) =>
                {
                    float step = attacker.speed * deltaTime;
                    attackerPos.Value = Vector3.MoveTowards(attackerPos.Value,
                                            new Vector3(playerBase.Value.x,
                                            attackerPos.Value.y, playerBase.Value.z), step);
                }
            )
            .ScheduleParallel();
    }
#

(they are all moving towards the PlayerBasePosition)

amber flicker
#

keep it to Unity.Mathematics if you can - burst goodness

robust scaffold
#

Ouch, vector3. Nope. Use Float3 and math.MoveTowards.

#

If it exists, just recreate it if it doesnt.

zenith wyvern
#

I don't think there's an equivalent in the new math library

robust scaffold
#

I mean, isnt it just lerp?

crude sierra
#

hmmm looks like no equivalent for MoveTowards out of the box

crude sierra
robust scaffold
#

Why doesnt package pages not have their dependencies listed. I have to recreate my manifest file again to remove entities and slot in basic Burst and I dont know what's automatically included.

crude sierra
#

should manage from here, thanks for your help guys much appreciated

robust scaffold
#
    "com.unity.burst": "1.5.1",
    "com.unity.jobs": "0.8.0-preview.23",
    "com.unity.collections": "0.15.0-preview.21",```
Back to the basics. It's like I time traveled back to 2018.
remote crater
#

Has anyone figured out how to launch 2021.2.0a12 or 2021.2.0a11 without the GUI error? Has anyone been able to build a standalone windows in 2021.2.0a10 I think it complained about platforms.

karmic basin
#

@robust scaffold you escalated so fast 😅 let's wait a little the next announcement to clarify things before giving up ?

#

I really hope it's because DOTS is branching too much and they cant keep it along the legacy editor

robust scaffold
karmic basin
#

this or a really bad packages management server-side

robust scaffold
#

As I said earlier, last time something like this happened was UNet. And where is UNet now?

#

Jump off the train before it falls off the cliff. Entities is dead. Long live Burst + Jobs.

safe lintel
#

remember the days when we were just waiting for that supposed dots blog post? 💩

gusty comet
#

well they said they will fix things at the end of year

safe lintel
#

unity's vague time estimates are hard to believe

gusty comet
#

kinda funy how they wrecked one of their most important features tho

north bay
#

Unity just has to open their mouths and properly communicate for once. But they rather make the most abstract forum thread and answer three questions and go radio silent right after that so everyone can interpret whatever they want into it again.

light mason
#

I still don’t think ECS is going away, it proven too powerful

north bay
#

I highly doubt that they are going to throw the last years of development away while still releasing .18? That wouldn't make any sense to me

light mason
#

Have they given a date for .18

north bay
#

Unity doesn't give dates, it stresses them out to much 🙃

light mason
#

Lol

#

Well they r a public company now investors wants dates

karmic basin
#

well I mean at least they began a public roadmap

#

no dates though, just steps

crude sierra
#

hey guys, i'm experiencing a race condition between collisions and destroying entities.. so a collision happens twice before the actual destroy happens..
this is the code

        {
                Ecb.DestroyEntity(entityA);

        }

#

so a collision manages to happen twice for entityA before it's actually destroyed

ocean tundra
#

The entity is destoried when the ECB is played

#

what ECB did you pick? maybe try a different one

crude sierra
#
World.GetOrCreateSystem<EndSimulationEntityCommandBufferSystem>().CreateCommandBuffer()
north bay
#

Try EndFixedStepSimulationEntityCommandBufferSystem the FixedSimulationSystemGroup can/will run multiple times a frame

ocean tundra
#

yea that

#

😛

crude sierra
#

nice will try that

#

thanks

ocean tundra
#

😦 I was hoping to wake up and see some more info from Unity about this crazyness no updating thing

zenith wyvern
#

Unfortunately they have a history of releasing vague and confusing info then disappearing for a while, like what happened when they were going to remove the scriptable render pipelines from github

ocean tundra
#

i know, i just keep hoping they would have learnt by now

#

there are definitly some teams inside Unity that have, eg the post about the .net update. SOOO many questions answered

safe lintel
#

yeah, some teams are super communicative, others kind of dont exist outside of what is thrown out there as the end product

ocean tundra
#

with something so public they should make every dev in all of unity have to spend 1 hour a week on the fourms/discord. imagine all the info/questions we could get answered

north bay
#

Remember when we actually had a dots dev in this discord answering questions?

ocean tundra
#

what!!! that must have been before my time

north bay
#

Yea it's been some time

hollow sorrel
#

they removed their posts

#

hope they didn't get in trouble for being the one unity dev that communicates

ocean tundra
#

😦 thats so sad

north bay
#

That's just strange to be honest

safe lintel
#

yeah he was great. wonder if theres some sort of gag order on communication?

amber flicker
hollow sorrel
#

i didn't wanna use names but his msg history used to go further back

crude sierra
#

sorry for the noob questions guys but is there a way to disable an entity rather than destroy it altogether? looking for a cheaper way

#

i'm currently looking at the Disabled component but can't find use cases for it

zenith wyvern
#

You just add the Disabled component and that entity will be ignored by all systems/queries unless they specifically look for disabled entities

#

That includes the renderer

crude sierra
#

ohhhh

#

thanks got it

ocean tundra
#

@crude sierra There is also DisableRendering if you dont want to disable the entity completly

crude sierra
#

is there a way to disable collisions only as well?

north bay
#

PhysicsExclude might work

crude sierra
acoustic spire
#

Should DynamicBuffer be faster than UnsafeList if I use little amount of entities? Can't choose which one to use for storing mesh data

robust scaffold
#

Since dynamic buffers are basically FixedLists I believe in the background, I think they have a maximum size of 4086 or something bytes.

#

So about 1000 floats.

acoustic spire
robust scaffold
#

If you'll be using more than 1000 floats in a single list, might as well use a NativeArray/List, skip the entities.

acoustic spire
#

You mean using stateful systems? That's an idea 🤔

remote crater
#

KornFlaks — Today at 3:37 PM
Alpha is no longer supported in DOTS. You'll need to downgrade to 2020 LTS or join me in Burst basics.

#

For real?

#

Cuz my code won't downgrade to that.

#

Can I just wait it out til a future version?

zenith wyvern
#

I've seen people say they are using 2021 without issues, but official word from unity is that only 2020 is supported/will work in the future

#

For a while

safe lintel
#

yeah im also on 2021.2 with almost every dots package

#

funny cos it almost felt like smooth sailing, almost everything working perfectly

remote crater
#

I have a finished game that won't make a standalone.

#

At least you guys are telling me I have to fudge updating/downgrading my project over and over until I find the right version.

#

That is helpful.

#

Gonna take a lot of loading bars with my 17 gig project. Takes about an hour to check a version.

#

But what is a programmer than patient?

pliant pike
#

I just downgraded my current project to 2020, it wasn't to bad, the hybrid renderer broke and a script couldn't find its dependencies

gusty comet
light mason
#

Bloody hell I wish Unity would say something already, people are already writing ECS eulogies

ocean tundra
#

yea i know

light mason
#

It’s not dead

ocean tundra
#

i feel like im getting contact panic from reading them

#

😛

light mason
#

IKR

#

Dealing with a lot of stress here , I’m like 7 coffees in checking the dam thread every 5min

#

I mean just say it not dead so I can carry on w life here

ocean tundra
#

haha yea, i know, i too keep checking it

#

ive put wayy too much time into ECS and even tho i 'know' unity wont drop it, i still want to know for sure

#

their track record is unfortuanlly not good enough

light mason
#

Yea I’ve spend so many 1-3am learning it hoping to get a leg up

robust scaffold
#

The fuck, hahahahaha

light mason
#

It would be a blow for sure

remote crater
robust scaffold
#

The thread on the compatibility is as hilarious as it is terrifying.

robust scaffold
light mason
#

When I saw you typing @remote crater I really thought it was going to be good news

ocean tundra
#

I know i shouldnt read it, just wait for more info, 😛

remote crater
#

I was wondering if you guys had advice on where to go? I could really just wait for alpha 13, 11 &12 don't work

robust scaffold
remote crater
#

Maybe try .09

robust scaffold
remote crater
#

The game 100% works in editor when hit rn

#

When I hit compile, it has a different version for windowws

robust scaffold
#

From the errors, it just looks like Entity package isnt being imported.

remote crater
#

Only ECS/DOTS part, the actual gameobject mode plays fine

robust scaffold
#

Check your package list. Is Entities on it?

remote crater
#

So maybe mess with my mainfest, ty

robust scaffold
#

Yea, copy this in: "com.unity.entities": "0.17.0-preview.41",. I think. I wrote that out by hand.

remote crater
#

yah, for some reason it mauled my maifest.json

robust scaffold
#

If you want stability with DOTS, you'll need to go all the way back to 2020 LTS. Or if you read through the doomsayers on the forums, drop Entities all together and somehow go it alone and make your own ECS.

remote crater
#

Its awesome tho, everything does what I want. I have a working game. I just need to hit publish for standalone on different platforms.

#

MAYBE! That's what I do, maybe I standalone not on windows!

#

I have pc parts coming in the mail for Linux.

robust scaffold
#

Wait, are you using Platforms build?

remote crater
#

I think someone said I have to have WIndows platforms or some junk

robust scaffold
#

Dont use the built in, use platforms.

remote crater
#

What is platfoirms?

robust scaffold
#

Yea. "com.unity.platforms.windows" Dont remember the version so you'll have to add it in via package manager and git.

remote crater
#

That doesn't work I think

#

I already tried that, new errors. I'll try again if downgrading doesn't work

#

TY

robust scaffold
#

It will work. Trust me. I've been typing out manual git links to package manager for countless dead projects. Use that and build using platforms.

remote crater
#

So you don't click build settings

#

what do you click to compile then?

robust scaffold
#

Nope, there's a new asset that platforms brings that you then click build on.

remote crater
#

like a menu item?

robust scaffold
#

Yea.

remote crater
#

ty tytyty

#

I think i had it, but just tried a normal build

robust scaffold
#

It shows up in the inspector. I dont have a project using platforms right now though.

remote crater
#

Lots of great info to run with here. Thank you all very much. Remember anyone who helped me, if I end up making millions, track me down and ask for manilla envelopes 🙂

#

all g g, you helped enough already

robust scaffold
#

Heh, nah. I dont take money for programming as a hobby. All my projects are open source and the very little donations I get go to my local childrens hospital as charity.

#

So if you have any spare cash, go donate it to charity.

remote crater
#

you got it bro, and may God bless you for helping brothers and sisters of humanity!

remote crater
robust scaffold
half jay
#

Is there any info or package about using particles in dots?

karmic basin
#

so install com.unity.platforms, plus additional platform packages com.unity.platforms.X, com.unity.platforms.Y, then create the build ASSET, click on it from your project folder, and build from the inspector only

gusty comet
#

just noticed scale is a single float not a float3/vector3

pooledColliders[0].localScale = entityManager.GetComponentData<Scale>(closestEntity).Value;

how do you get scale in localScale format (vector3/float3)

karmic basin
#

There are variations for it

#

Like NonUniformScale

#

and such

gusty comet
#

theres only one Value in Scale

karmic basin
#

when it's not 1/1/1

#

because it's implied as "uniform" scale

gusty comet
#

oh theres NonUniformScale

karmic basin
#

yeah and at least 1 other one IIRC

gusty comet
#

but will my GOs have it? they were converted with ConvertToEntity

karmic basin
#

Your GO no

#

your entities yes

#

the transform matrix is computed differently based on which combination of these components are present when the system runs

#

Last time I checked though, I had a hard time having the system take into account scales and pivots :/

#

@remote crater

gusty comet
#

ok thanks man

karmic basin
#

@remote crater

gusty comet
#

i heard that Ecb is faster than entity manager mb i should change

crude sierra
#

does anyone have a reference or can explain how to use C# Events/Actions with Jobs?
basically i'm trying to implement a HealhSystem that has a method called TakeDamage, which is invoked by an event caused from another system, so I got

private void TakeDamage(object sender, Entity entity)
    {
        var ecb = m_EndSimulationEcbSystem.CreateCommandBuffer();
        var healthComps = GetComponentDataFromEntity<HealthComponent>();
        ecb.SetComponent(entity, new HealthComponent
        {
            Health = healthComps[entity].Health - 1,
            ShouldDestroyOnDeath = healthComps[entity].ShouldDestroyOnDeath
        });
    }

but using this I get an error

InvalidOperationException: The ComponentDataFromEntity<HealthComponent> has been declared as [WriteOnly] in the job, but you are reading from it.
gusty comet
#
  collidersLTWs[i].transform.position = collidersLTWs[i].localToWorld.Position;

interesting, this wont work every frame in MBs cause localToWorld is a struct. so I would have to GetComponentData every frame.
and ref keyword didnt work unfortunately, any advice? how to use reference to localToWorld, or make entities expose some values so i dont have to getcomponentdata all the time, and instead cache the component?

gusty comet
#

maybe i can set MB variables from inside a System, to avoid getcomponentdata calls

dull copper
zenith wyvern
gusty comet
#

is Rotation worldrotation and Translation localposition?

#

i think translation is local and rotation is world

hollow sorrel
#

@gusty comet they're both local

#

if you want world pos/rot you get them from LocalToWorld

gusty comet
#

im sure rotation is world , i did read that on forum, and it also works in world manner

hollow sorrel
#

not sure why that would be the case, that sounds more like a bug if it is?

gusty comet
#

ok fine maybe youre right

#

anyway do you know answer to this?

            Entities.ForEach((ref GalaxyData galaxyData, ref Translation translation, ref Rotation rotation, in Entity galaxy) =>
            {
                galaxyData.elapsedTime += galaxyData.positionStep;
                translation.Value = new float3(Mathf.Cos(galaxyData.elapsedTime) * galaxyData.orbitRadius, Mathf.Sin(galaxyData.elapsedTime) * galaxyData.orbitRadius, 0f);
                rotation.Value = quaternion.Euler(galaxyData.rotationStep * galaxyData.elapsedTime);

                if (galaxy.Index == closestGalaxy.Index)
                {
                    DynamicBuffer<Child> childBuffer = GetBuffer<Child>(galaxy);

                    for (int i = 0; i < childBuffer.Length; i++)
                    {
                        // this only extracts entity from loop i think so you cant supply entity
                        GetComponentDataFromEntity<Translation>(childBuffer[i]); 
#

its great that u can use GetBuffer without entity manager inside ForEach

but i cant kinda get component data of child

#

i mean i could use entity manager but i heard it blocks threads

#

not sure

karmic basin
pliant pike
#

too add to my statement I made earlier where I said my project was fine when I downgraded earlier, it wasn't, it broke everything leahHMM

#

yeah I'd advise against doing it if you can

gusty comet
karmic basin
karmic basin
#

or .Run() if you don't need a job and it would be okay because main thread

gusty comet
#

native array?

karmic basin
#
//OnUpdate()

// native container outside the scope of the lambda
NativeArray<T> valueContainer = new NativeArray<T>([...]);
 
Entities
.ForEach(([...])) =>
{
    valueContainer[0] = [...]; // write to container inside lambda
})
.Schedule();

// back outside of lambda scope, valueContainer has been mutated
gusty comet
#

wow it can write

#

to native stuff, thanks

#

one question though, it doesnt let me add float3 to native array float3 type

karmic basin
#

yeah the job will access to the container memory, even on another thread

gusty comet
karmic basin
#

it's not a struct

#

you need to specify size and allocator as constructor params

gusty comet
#

oh yeah i forgot xD saw it in video

#

thanks mate youre saving me

karmic basin
#

🙂

#

Keep in mind if you check distance only once per frame, or even only a few times, you might as well just keep it simple with a .Run() instead of scheduling

#

unless you have hundreds of galaxies

gusty comet
#

i check distance every second, but once i find closest Entity, i write data eg pos/rot every frame

#

i have hundreds yeah

#

so i can check distance with .Run()

#

but i still need to write pos to native array in Schedule()

#

btw i assume theres no alternatives for nativearray for single values eg float quaternion?

north bay
karmic basin
#

ooooh nice

gusty comet
#

so empty DataComponent is a tag, that you use to query entities?

karmic basin
#

yup

#

among other use cases

coarse turtle
#

So i had some fun looking at the generated burst code, wondering if anyone has a clue as to why something like

return new float4(x / a, y / a, z / a, w / a);

generates the vcvtdq2ps instruction which converts a double word integer to packed floating point.

vs doing something like this:

return float4(x, y, z, w) / a;

doesn't generate that instruction (bottom picture).

gusty comet
#

InvalidOperationException: The previously scheduled job GalaxySystem:OnUpdate_LambdaJob1 writes to the Unity.Collections.NativeReference1[Unity.Mathematics.float3] OnUpdate_LambdaJob1.JobData.positionNR. You must call JobHandle.Complete() on the job GalaxySystem:OnUpdate_LambdaJob1, before you can read from the Unity.Collections.NativeReference1[Unity.Mathematics.float3] safely.
is there any workaround to this?

zenith wyvern
gusty comet
#

container in warning is used by only one ForEach

zenith wyvern
#

Can you show the code?

gusty comet
#
        NativeReference<int> closestIndex = new NativeReference<int>(Allocator.TempJob);
        NativeReference<float3> positionNR = new NativeReference<float3>(Allocator.TempJob);
        NativeReference<Quaternion> rotationNR = new NativeReference<Quaternion>(Allocator.TempJob);

        Entities.ForEach((ref GalaxyData galaxyData, ref Translation translation, ref Rotation rotation, in Entity galaxy) =>
        {
            galaxyData.elapsedTime += galaxyData.positionStep;
            translation.Value = new float3(Mathf.Cos(galaxyData.elapsedTime) * galaxyData.orbitRadius, Mathf.Sin(galaxyData.elapsedTime) * galaxyData.orbitRadius, 0f);
            rotation.Value = quaternion.Euler(galaxyData.rotationStep * galaxyData.elapsedTime);
            if (galaxy.Index == closestIndex.Value)
            {
                positionNR.Value = translation.Value;
                rotationNR.Value = rotation.Value;
            }
        }).Schedule();

        God.position = positionNR.Value;
        God.rotation = rotationNR.Value;
#

God is static class

zenith wyvern
#

Oh, it's because you're passing your container into a job then immediately trying to read it on the main thread

#

Think about what's happening there - you schedule a job, then before the job has even had a chance to run you're trying to read the results

gusty comet
#

oh true

#

i wanted to let monobehaviours know about these variables

zenith wyvern
#

So you'll have to force complete your job or rethink how you're reading the data

gusty comet
#

is there something like OnComplete for jobs

zenith wyvern
#

Or just change it to .Run instead of .Schedule

#

So it runs immediately on the main thread

gusty comet
#

no that will defeat the purpose of using dots

zenith wyvern
#

In which case you wouldn't need the native containers

#

Like I said you'll have to rethink how you're reading your data then. If you want to use monobehaviors in dots you should be using hybrid components, although that still wouldn't help you here. Trying to use monobehaviors is always going to make it very hard to utilize dots effectively

coarse turtle
# gusty comet is there something like OnComplete for jobs

You can also try double buffering your position and rotation values by keeping a copy of the previously known processed data. So you schedule your jobs and at the start of the next frame, you read the data into your monobehaviour.

#

but yeah definitely agree with Sark here, interfacing MonoBehaviours with DOTS has always been a point of contention. Easier to just pick one side that handles the game logic and utilize gameobjects for other things - whether it's rendering or something else

gusty comet
#

So you schedule your jobs and at the start of the next frame, you read the data into your monobehaviour.
how would you do that? i noticed native containers cannot be class variables so they can be only used during OnUpdate

coarse turtle
#

make a persistent container or allocate a pointer

#

struct SomeJob : IJob {
  // Choose one option or the other on implementation
  // Option A:
  [NativeDisableUnsafePtrRestriction]
  public T* data; // where T is some blittable data type of your choosing
  
  // Option B:
  public NativeReference<T> dataContainer; // Allocated with persistent allocation in OnCreate or something

  public void Execute() {
   *data = some_value;
    dataContainer.Value = some_value;
  } 
}

// In OnUpdate()
your_monobehavior_or_class.value = *data;

var job = new SomeJob { 
  data = some_external_pointer, created in OnCreate()  
  dataContainer = a_native_reference_allocated
}.Schedule();
gusty comet
#

what about ForEach filters etc?

#

i just used foreach until now

coarse turtle
#

you can still do it for ForEach lambdas, just takes a bit more writing.

#

you'll need to copy class variables into a local variable

gusty comet
#

i kinda get an error if i try to access native container that was not made in OnUpdate

coarse turtle
#

You'll probably need

T* data; // class variable

// OnUpdate
T* copiedPtr = data;
Entities.ForEach((...) => {
  // Use copiedPtr here
}).WithDisableUnsafePtrRestriction(copiedPtr).Schedule();
gusty comet
#

even if persistent

coarse turtle
#

depends on whatever your error message is

#

but if it's complaining about lambdas can only work with local variables, then just make a copy of the container

gusty comet
#

oh

#

then it will copy the reference

#

i see

coarse turtle
#

yea just be careful with native containers - they're structs so you're not copying all of the reference exactly

gusty comet
#

ohh so im not copying reference

coarse turtle
#

the pointer internally will be copied (so it points to the same data) but properties like Length might be manipulated on a shallow level

stone osprey
#

Quick design question...
Lets say i wanna make my player teleport to a mob, once that mob was clicked.

I could either do something like : Mob-Entity{ OnClickTeleportTo{ position}, OnClickTeleportToThisEntity } where OnClickTeleportToThisEntity injects the entities position into OnClickTeleport. And OnClickTeleport simply teleports the clickers ( The Player ) to that position.

Or i could choose another way like this : Mob-Entity{ OnClickTeleportToClicked } where i specialise a component for this task instead of "composing" components to achieve the same.

What way would you choose ? Does it even make sense to split such features into multiple components ? 😮

coarse turtle
#

tbh I'd probably just start basic - click on mob, get position, pass position to another job and move entities all in the same system

stone osprey
#

So in that case... its the second example i posted... a OnClickTeleportToClicked component with its system to do that ^^ Is there any advantage if i go with the first example ? I actually just think its more complicated...

coarse turtle
#

idk, I tend to start with large fat systems instead of splitting it up too much (mainly cause I'm lazy)

stone osprey
#

Alright, thanks 🙂

night venture
#

Hope there's someone who can answer this one:
Already implemented ITriggerEventsJob/ICollisionEventsJob, and I'm able to detect and handle collisions between my entities (or better said, their physical bodies).
However, I was expecting some "filtering" to match the entities involved in the collision, but it doesn't to work like that.

I was expecting my methods to be invoked when entities with componentA and B (for example) collide, but instead both TriggerEventJob and CollisionEventJob get fired when any entity collides with another, and inside the method I have to manually handle events based on type.
Is that the expected way?

Assuming that would be the expected way...should I have a general system to handle collisions which tags entities as colliding and then handle those with their respective systems? (eg: carCollisionSystem, bulletCollisionSystem, doorCollisionSystem...) Is that the expected way?

gusty comet
#

will the entities use different chunk if mesh is different? (assuming all the components are the same type)

#

hmm that seems not the case according to inspector

zenith wyvern
#

Because RenderMesh is a shared component

gusty comet
#

ohh i see

#

according to docs structural changes cause syncpoints. what about reading data with EntityManager (eg GetComponentData/GetBuffer) ? is it also causing Syncpoint

coarse turtle
#

I think in lambdas those get translated to GetComponentDataFromEntity and GetBufferDataFromEntity calls - you can verify in the DOTS -> DOTS Compiler -> Open Inspector

gusty comet
#

oh according to tests theres no frame drop with 100 GetComponentData calls per frame
(its also a bit faster than GetComponent)

robust scaffold
gusty comet
remote crater
#

Thank you KornFlaks, this is the video: https://youtu.be/8DtrSMyxPXI

If you like what you saw, please sub for more. It helps me. It may help you, but I make no promises!

You can also come to like the only positive zone of the Internet I know: www.twitch.tv/goodnewsjim The Bro Zone Layer.

Temporary offer for anyone of any skill level: Can someone contact me to promote my game? www.starfightergeneral.com I'll gi...

▶ Play video
#

I tried to use Windows Platform Universal to compile, but when I tried to run .exe it had errors, shown in video.

frosty siren
#

I'm sorry for such question. I get dependency error for code below.

protected override void OnUpdate()
        {
            var ecb = _ecbSystem.CreateCommandBuffer();
            var linkedEntityGroup_BFE = GetBufferFromEntity<LinkedEntityGroup>(true);

            Entities
                .WithAll<Disabled>()
                .WithAll<SpawnedEntityDisableSyncTag>()
                .WithNone<OnDisableEventDoneTag>()
                .ForEach((in LastSpawned lastSpawned) =>
                {
                    if(lastSpawned.entity == Entity.Null)
                        return;

                    if(linkedEntityGroup_BFE.HasComponent(lastSpawned.entity))
                    {
                        var linkeEntityGroup = linkedEntityGroup_BFE[lastSpawned.entity];
                        for(int i = 0; i < linkeEntityGroup.Length; i++)
                            ecb.AddComponent<Disabled>(linkeEntityGroup[i].Value);
                    }
                    else
                        ecb.AddComponent<Disabled>(lastSpawned.entity);
                })
                .Schedule();
        }

Error in console:
ArgumentException: The previously scheduled job DisableSpawnedEntitySyncSystem:OnUpdate_LambdaJob0 writes to the Unity.Entities.EntityCommandBuffer OnUpdate_LambdaJob0.JobData.ecb. You must call JobHandle.Complete() on the job DisableSpawnedEntitySyncSystem:OnUpdate_LambdaJob0, before you can write to the Unity.Entities.EntityCommandBuffer safely.

What i try to achieve is to reproduce EntityManager.SetEnabled(bool) but with EntityCommandBuffer. And in this particular case with i want to:
when spawner is disabled disable entity which was spawned by it

north bay
# frosty siren I'm sorry for such question. I get dependency error for code below. ```csharp pr...

Short answer call AddJobHandleForProducer at the end of your update where you pass Dependency as the parameter.

Long answer:
The problem in the snippet that you sent is that the ecbSystem is not aware that your systems job is running.
It will try to play back the command buffer that you create with CreateCommandBuffer once it updates. But since your job is still running the JobDebugger will yell at you that you cannot write and read to the entity command buffer from two sources at the same time.

To fix that you call AddJobHandleForProducer which makes the EntityCommandBufferSystem complete your job before playing back the buffer.

frosty siren
#

oh, yes. I completely forgot about this AddJobHandleForProducer. I'm sorry, too much time working with main thread 🙂 Thank you!

gusty comet
#

what if theres lot of chunks?

#

is the performance still better than on GOs?

#

i have 30 now but i may have even hundreds

ocean tundra
#

@gusty comet Chunks of how many entities?

#

the more entities you can fit in a single chunk the better performance will be

#

but even the worst case (1 chunk with 1 entity) should be faster then GOs

#

also theres advice to break apart bigger entities, so instead of 1 huge player entity you make a bunch of smaller ones (Player, PlayerStats, PlayerInventory, PlayerSkill1....)

#

that way you have smaller entities which means more will fit in a single chunk

#

(ps player is a bad example as most games will only have a few (or 1) players)

gusty comet
#

my entities would be mostly the same but they have rendermesh

gusty comet
ocean tundra
#

ok so each unique render mesh moves things to its own chunk

gusty comet
#

yeah thats what they said

ocean tundra
#

so 20 different tree models = 20 chunks

gusty comet
#

yes

ocean tundra
#

cool

gusty comet
#

kinda bad

ocean tundra
#

depends

#

how many of those trees you have

gusty comet
#

i havent added trees yet

#

now that i think of it, i may even have thousands of chunks

#

later in the development

ocean tundra
#

and also if your using schedule vs schedule parallel

gusty comet
#

yeah thats the diff

ocean tundra
#

yea a game with 1000s of unique models probably is very possiable these days

gusty comet
#

ye lets hope it will not lag

#

anyway did you use TransformAccessArray ?

ocean tundra
#

but also that sounds like a future issue 😛 worrying about something that may not happen, also by the time you get to that Unity/Dots/Hybrid renderer should have had a few updates, and hopfully will handle that even better

#

na never used it sorry, my use of hybrid gameobjects is almost NA

gusty comet
#

oh i use hybridRendererv1 idk if its still updated

#

they said no

ocean tundra
#

yea def not

#

should try v2

gusty comet
#

shaders wont compile

#

even after edit

ocean tundra
#

:/

#

annoying

#

custom shaders?

gusty comet
#

yes

ocean tundra
#

URP or HDRP?

gusty comet
#

basic pipeline

#

but the one i tried was urp

ocean tundra
#

yea i think v2 requires URP or HDRP

gusty comet
#

yes i changed to urp for v2

ocean tundra
#

which means you would need to remake your shaders

gusty comet
#

but failed to edit shaders

ocean tundra
#

which is a whole pain

#

not sure theres a good soultion

#

can you remake the shaders in shader graph?

gusty comet
#

LOL no way

#

i mean code editing

#

i fixed some errors

#

but didnt fix what i assume to be final error

ocean tundra
#

i know but shader graph def supports URP/HDRP and Hybrid renderer

gusty comet
#

custom code shaders also support

ocean tundra
#

yea but theres extra ytou have todo to support hybrid renderer

#

where with shader graph its a checkbox

coarse turtle
#

I think all that checkbox does is the equivalent of adding the shader feature/compile flag for the shader lol

ocean tundra
#

yea i dont know what it actually does 😛

gusty comet
#

Difference between Schedule() and ScheduleParallel()?

ocean tundra
#

basilcy schedule is 'single threaded'

#

schedule will process each chunk of entities all on 1 backgrould 'thread'
ScheduleParallel will break up the chunks to be processed in DIFFERENT threads

gusty comet
#

didnt know

#

why they tell u to use Schedule() all the time

#

lol

ocean tundra
#

ScheduleParallel has a bit more complexity to using it

#
  • in smaller cases is actually slower
#

eg using a command buffer, you need to use the Parallel version in ScheduleParallel

#

which means you need the entityInQueryIndex

#

and same for other native collections

gusty comet
#

i see no difference in fps

#

i guess my gpu is bottlenecking the results

ocean tundra
#

its the sort of thing thats only noticable with LOTS of ScheduleParallel

gusty comet
#

nono im sure if it would be noticeable but my gpu keeps my fps at 240

ocean tundra
#

and i think its main thread cost

gusty comet
#

in either case

ocean tundra
#

the are working on reducing the main thread costs of Schedule and ScheduleParallel

#

maybe 0.17 had some of those fixes already

karmic basin
crude sierra
#

hey guys, is there a sample project or docs for using DrawMeshInstancedIndirect with ECS?

coarse turtle
#

I actually just got it working lol

coarse turtle
#

Well, what's the error?

gusty comet
#

i think its just vsc

robust scaffold
# gusty comet i cant use pointers in unity

You can use pointers. Enable unsafe code in the project settings under Player or Editor, forgot which one. Not entirely recommended because it ruins the whole point of safety checks that DOTS has built in.

#

I mean, you can do it. If you really need to. Like re-implementing the IJobMultiHashMapXX jobs. Those must use pointers to internal buffers but otherwise it's recommended you find a way to do it without pointers.

gusty comet
coarse turtle
#

@crude sierra the general idea, is you can query all the local to world positions of your entities and set up the ComputeBuffer args. For the ComputeBuffer args:

// Initialization
ComputeBuffer xformBuffer = new ComputeBuffer(max_count_of_positions, sizeof(float4x4));
someMaterial.SetBuffer("VariableName", xformBuffer);

// In an update loop
xformBuffer.SetData(matrices, 0, matrices.Length, matrices.Length);
Graphics.DrawMeshInstancedIndirect(mesh, 0, material, bounds, argsBuffer, ...);

In your vertex pass, you can reference the correct matrix by passing in the instanceID as a parameter. You use this instead of unity_ObjectToWorld instead.

coarse turtle
crude sierra
coarse turtle
#

wdym? ultimately you'll need a shader

gusty comet
#

is there any way to see current syncpoints?

safe lintel
#

did you do your test with shadergraph? i also was investigating some drawmeshinstancedindirect example from the manual but was too lazy to try to port the shader code to urp

coarse turtle
#

No, I just wrote the shader myself. tbh I didn't know shader graph supported StructuredBuffers

crude sierra
coarse turtle
#

well the legacy shaders won't work with Indirect, because they don't have a StructuredBuffer variable

crude sierra
#

also, I couldn't understand how rendering it from code aligns with lets say EntityManager.Instantiate()

#

do you instantiate the entity without renderer, and assign it via code?

coarse turtle
safe lintel
#

thanks gonna give it another go

coarse turtle
gusty comet
crude sierra
#

yes yes i'm aware of that, but assuming I want to use DrawInstanced I can't use Unity's default Mesh Renderer in my prefabs right?

crude sierra
coarse turtle
#

Like that line specifically or an equivalent?

crude sierra
#

i'm missing the link between the entity and how it's rendered

coarse turtle
#

For something like hybrid renderer v2, I don't remember all of the components you need, but typically the conversion workflow will do something like EntityManager.AddSharedComponentData(entity, new RenderMesh { ... });

#

RenderMesh will contain mesh data and shadow casting options so hybrid renderer can render it. But I have little experience in using that.

crude sierra
#

so the actual DrawInstancedIndirect happens within the shader code?

coarse turtle
#

DrawInstancedIndirect is just a regular UnityEngine API call - so what I did was just write my own renderer, cause I'm not using Hybrid

#

in pseudocode this is what I did

// In SystemBase
var query = GetEntityQuery(typeof(LocalToWorld));

// In update
var ltws = query.ToComponentDataArray<LocalToWorld>();

// Set up the compute buffers
computeBuffer.SetData("_Matrices", ltws);

// Use DrawMeshInstancedIndirect to draw all the meshes
Graphics.DrawMeshInstancedInDirect(...);
solid rock
coarse turtle
#

not that I know of, I'm just calling it from the main thread

solid rock
#

Ok same

#

But I'm always looking out for ways to try to do it from a job or something

crude sierra
#

i think i understand

#

thanks!

coarse turtle
safe lintel
crude sierra
naive ice
#

I'm optimizing terrain picking. At a super high level, I'd like to do something like this:

    if(chunk.ExpensiveCollisionCheck())
        collisionList.Add(stuff);
}).ScheduleParallel()
Complete()
foreach(stuff in collisionList)
    ...```
What's the best approach here if I want to maintain parallel scheduling *and* variable-length output of said scheduled work? NativeMultiHashMap?
#

Note that I can't parallelize after Complete(), as some calculations require e.g. all collision data to be sorted first

karmic basin
# night venture Hope there's someone who can answer this one: Already implemented ITriggerEvents...

Yes that's "expected", at least that works good enough like that atm. Like the first time I talked to you about it, that's how Unity built it for now, and it can seem a little hacky sometimes. So yes you have to check that entityA and B fulfil you requirements, in your case make queries and check .HasComponent(entityA) and/or B
For your second question, I guess you could have a "collect" job as a first pass, but I would keep every logic seperate (avoiding a big triage system with let's say a lot of switch statements - if I understand well what you mean)

crude sierra
#

I feel like some of that doc is outdated tho because of the API to create entity command buffers

safe lintel
#

ive not tried using ecb's with sharedcomponents so not sure

crude sierra
#

okay, does anyone know the musthave components when creating an entity?
I'm getting this error:

A component with type:{0} has not been added to the entity.
remote crater
#

When I try my standalone.exe it says: The code execution cannon proceed because MSVCP140_APP.dll was not found. Resinstalling the program may fix this problem, same for: VCRUNTIME140_1_APP.dll, and VCRUNTIME140_APP.dll I was told to use the Universal Windows Platform because the normal windows compile does not work for DOTS.

#

Any clues?

#

Its the worst feeling when you thought you crossed the finishline, but there is one brick wall there you didn't expect

ocean tundra
#

Didnt know that the normal windows compile dosnt work 😦

#

but yea with DOTS it always feels like theres another wall 😛

#

when i first ever built stuff it was fine in editor and the builds worked, but was exploding cause i was using a class based componet (which contained another class ect)

#

was very annoying

remote crater
#

new version a13!

#

Maybe this one loads to editor unlike 11 & 12, and then compiles to standalone unlike a10. So you're saying there's a chance.

ocean tundra
#

well i wouldnt put too much hope in it

#

support for Entities is locking at 2020 lts

#

for at least a year

#

😦

#

have you tried 2020?

remote crater
#

I can't downgrade

#

My game works very well in editor

ocean tundra
#

😦

remote crater
#

I just gotta get a standalone

#

Its a finished MMO with 2 new hyper technology DOTS and New school MMO networking

#

minus some levels built

ocean tundra
#

hmmm well your going to be in a very odd place going foward, as future updates will likely be locked at 2020 lts. If you can get a build working you should NEVER change any of those versions 😛 no unity update, no ecs update

#

infact i would version lock the entire project, dont update any packages :/

remote crater
#

i make zillions of backups

#

If something goes awry I can backtrack

remote crater
#

Ok, so I still get the error I get in a11 and a12 in a13: Library\PackageCache\com.unity.platforms@0.10.0-preview.10\Editor\Unity.InternalAPIEditorBridge.012\EditorGUIBridge.cs(15,45): error CS0426: The type name 'HyperLinkClickedEventArgs' does not exist in the type 'EditorGUILayout'

#

Has anyone ever fixed that? It is just one error.

ocean tundra
#

@remote crater i would think your best bet is to copy platforms into a local package, and then try to fix that error

#

is it only happening during build?

remote crater
#

I tried to remove all platform segments out of /packages/manifest.json

#

and /packages/packages-lock.json

#

it hapens on convert a10 to a13

#

it completely changes my manifest too, removing entities n stuff

latent haven
#

Are there any tutorials on the DOTS sample? Or Unity Learn documentation?

#

Enter the Boss Room support is pretty good, anything like that for the shooter project?

remote crater
#

yes

#

Let me link

#

Lots of youtubers do stuff

#

Search dots ecs unity

#

but filter last month or last year

latent haven
#

I meant more official Unity tutorials, I googled and saw some stuff that looked OK

latent haven
#

I thought maybe it was hidden away in a secluded tropical github repo somewhere

remote crater
#

github with physics n stuff yah

#

name is liek

#

EntityComponentSystemSamples-master

latent haven
remote crater
#

Under UNITyOfficial

#

thats it

#

just load up scenes and hit play

#

my fav is boids

remote crater
#

Thats it, 6 ish hours over 2 days of trying unity different versions and configurations to no avail. Maybe A14 will let me update.

minor sapphire
#

they are not supporting 2021 until next year, or so they say for now