#archived-dots

1 messages Β· Page 72 of 1

junior fjord
#

but the answers by @solar ridge in that thread are actually exactly what I also assume is the right solution

#

to have an rng per system and just send it to the jobs

#

I would really post your problem to the forums, maybe there is an interesting answer πŸ˜„

#

ah wait I did not read to finish

#

ah ok well the stuff he proposes at the end with one rng per thread is pretty much perfect I'd say

#

the copy by value thing is interesting, I didn't think about that. You actually do have to initialize one Random per OnUpdate then.

#

But I think one rng per thread is probably best practice, that is also what I always read when doing multithreaded random things as I remember now that I read that thread πŸ˜„

#

but this all does not explain the bevahiour that you got, so if you are going to post, still notify me

tawdry tree
#

Seems like the seeds should probably not come from time or whatever you use, but instead something like position. Depends on what you're trying to accomplish (I kinda skimmed the conversation, so might've missed something)

junior fjord
#

no you should not reseed every time you need a random number

tawdry tree
#

Ah, you're doing parallelization where you want a (potentially) massive number of jobs to each get a random value?

minor sapphire
#

yes exactly Hodhandr

#

but I'm seeding inside the job:
Random rand = new Random((uint)(index + DateTime.Now.Ticks % (uint.MaxValue - 1)) + 1);

solar ridge
#

Inside the job you neednt do that.

#

First off what kind of job?

minor sapphire
#

IJobForEachWithEntity

solar ridge
#

Ok so you have an index. Good

junior fjord
#

yeah but he already tried sending an pre-seeded rng to the job and that got weird results somehow

solar ridge
#

So what you can do:
upon making the job pass a seed that you gen random each job creation. Inside the job, make a new random using seed and using the index

junior fjord
#

allthough that is what should get the actual random beheviour whereas reseeding often somehow works but does not have to

minor sapphire
#

sending a pre-seeded random into the job got me the most unrandom result so far, I assume it's a thread safety issue

solar ridge
#

Did you use the index as wrll?

junior fjord
#

no that is also not the right practice to gerenating actual random numbers @solar ridge

solar ridge
#

Otherwise everey thread had the same random number genned each next

minor sapphire
#

yeah, I used time + index

#

this is the basis for what I did: index + DateTime.Now.Ticks

#

it got me the most random results so far

#

still don't entirely like it cause DateTime is not a high resolution timer lol

solar ridge
#

Right. All that would change is when you do Time call. It would be on create instead of everey frame. Every frame would be using rand.next passed to the job

#

Have you posted your full code of the non random problem?

minor sapphire
#

yes

solar ridge
#

Okey doke. Give me a moment to find it as I am on mobile

solar ridge
#

...

minor sapphire
#

this is the way that I want to do it, but I think using the same instance is not thread safe, hence my very unrandom spawning.
The commented out way is what I tried next, it passes in a random element to add to the seed

solar ridge
#

You dont pass a rand to it

#

You pass a seed. Very different

minor sapphire
#

yes, the commented way

#

I used the 'seedoffset' + index

#

it was better, but it was not completely uniform and I can't explain why

junior fjord
#

it really just does not give you the right distribution actually

#

It could work sometimes but the rng are not developed to be seeded repeatedly, it is just not how they work

minor sapphire
#

what if the seed is random each time?

junior fjord
#

also not

#

in theory an rng could always start with the number 1, and only "on average" give you the right distribution

minor sapphire
#

so then the only alternative is really to pre-generate a list of random numbers in a list and pass it into the jobs...

solar ridge
#

Wrong math library though. I have had no issue reseeding using the new systems

junior fjord
#

a computer cannot generate real random numbers, it can just generate a sequence of numbers that has the right statistical properties

minor sapphire
#

Soaryn, using Mathematics.Random?

tawdry tree
#

There might be some overhead with seeding, though if you just want the appearance of random (and/or the ability to control it) you might instead want to consider some pseudorandom noise (perlin noise or something) instead.

junior fjord
#

@solar ridge yeah I guess the use the mersenne twister algorithm that can cope with some stuff, but statistically you will probably still not actually sample the right thing

solar ridge
#

I what I mean is that stack overflow assumes Java and c++ normal libs

junior fjord
#

but nvm I mean just do what works guys, just wanted to tell you that this is not the right way to get the actual random numbers you want

solar ridge
#

Noise could benefit you yes

junior fjord
#

yes but the answer holds universally

#

it is nothing specific to any library

minor sapphire
#

justsomequestions, I think passing in the random instance to a bunch of threads is worse

tawdry tree
#

If you're generating a giant thingy and don't actually need it to be random (protip: you don't. If you do you know why I'm wrong), noise tends to be better

junior fjord
#

most of them use mersenne twister today I think anyways

minor sapphire
#

noise is more expensive though

tawdry tree
#

Is it though?

#

Isn't it just a bunch of math anyway?

solar ridge
#

Youd gen noise noise once really and just keep pulling the next point

#

But keeping track of that next point in parallel at times could be painful

#

But you could skip rows (assuming a 2d texture like noise for instance) for each thread

#

Even in your working system Id use ticjs as seed in onCreate

#

Rather than 1

minor sapphire
#

in my working system I using ticks + index in the job itself

solar ridge
#

Ah right

#

The rand isnt even passed

minor sapphire
#

correct

solar ridge
#

Fair

minor sapphire
#

I don't like this either though lol

#

but it works for this case

#

according to a thread I read, Mathematics.Random returns similar values for seeds close to each other, so this is not a great method heh

#

I could like hash the index and use that though

solar ridge
#

You could also see how true that is...

minor sapphire
#

yes indeed lol

#

I suppose that would be the diligent thing to do

solar ridge
#

They shouldnt be .. but if they are do a different operation for index

#

Ie bit operations soarynLOL

minor sapphire
#

ya

tawdry tree
#

The one way I've actually used random* (noise, actually) is in terrain gen, where the inputs would be some manner of position, which parallelizes really easily (and deterministically).

#

If you need to make them distinct, I've read the suggestion to multiply with some semi-high prime number (as long as you know you don't overflow, or can deal with that)

solar ridge
#

The forum is a dangerous place. There are a lot of intelligent and clever people... then there are those ... who think they are soarynOops

minor sapphire
#

yes true I'm writing a test now haha

solar ridge
#

Care to test new Random(0) to confirm if it crashes?

#

I know new Random had issues in the past

#

Cant remember the exact reason

#

Likely state related

minor sapphire
#

Oh I had an error where it said seed must be > 0

#

gave me console error msg

solar ridge
#

Yeah. So carwful witj modulos then :-)

#

.... my phone typing is getting worse

#

Guess it is time to get out of bed and do some dev then soarynNap

minor sapphire
#

exactly hehe

tawdry tree
#

Flawless logic

junior fjord
#

actually harder to find than I thought, many stackoverflow threads actually did recommend seeding often which is kind of wearing

minor sapphire
#

oh god guys you'd be interested in this test...

#

shocking result

tawdry tree
#

Those results don't look very random to me...?

minor sapphire
#

exactly

junior fjord
#

πŸ˜„ πŸ˜„

minor sapphire
#

I'm modifying test

junior fjord
#

are you guys even listening to me

#

thats prety much what I am telling you and what the thread said

minor sapphire
#

@junior fjord yes but I'm just looking for the best way for me to get a random distribution

tawdry tree
#

Oh, I thought he was doing next/next/next, not new/new/new

solar ridge
#

Let him do science here

junior fjord
#

var r = Random(1)
for i=1,100
r.nextFloat()

is your best bet

minor sapphire
#

Guys I fully expect that doing next next next would produce a nice set

solar ridge
#

^^

junior fjord
#

they will behave random

solar ridge
#

He is wanting to know first index of each random seed

minor sapphire
#

I know

solar ridge
#

how different that first entry is

minor sapphire
#

I cannot easily do next next next using unity ecs, this is the issue

junior fjord
#

but the thread you send had a solution

#

I mean the forum thread

#

one rng per computer thread

solar ridge
#

We have looped in conversation...

junior fjord
#

or post the thing you had to the forums, because it actually should work. Maybe there is some very subtle mistake or it even is a bug

minor sapphire
#

He was not using ECS, he was using jobs though

solar ridge
#

Which in all intents and purposes of the use case is the same

junior fjord
#

can't you access thread id in the ecs jobs too? I mean they are the same jobs

solar ridge
#

ECS Foreach Entity is a forloop with magic on it

minor sapphire
#

right lemme recheck that thread

junior fjord
#

it is the last entry

#

maybe a bit overkill but I think that is the best practice forever solution

minor sapphire
#
[NativeSetThreadIndex]
private int threadIndex;

does this get set by unity or something?

solar ridge
#

Should

junior fjord
#

yes in that version it did, I am not sure how it works nowadays (if it still is the same)

solar ridge
#

The index is the same thing

#

as I believe it is chunk index

#

Err

#

scratch that

#

Right... ForEach ... single burst not a loop soarynPalm

#

One moment let me see if I have my random for that one

#

That thread ID should at least still work. My concern is that the same thread would process both

#

On the slim chance that it does

junior fjord
#

what do you mean? Each thread will only access its own rng

minor sapphire
#

this is really weird cause I am using .ScheduleSingle, I thought this one thing is running on one thread WTFFFFF

#

my mind is destroyed right now lol

solar ridge
#

Ah

minor sapphire
#

still I'm gonna try this just to see what happens

solar ridge
#

Wait.. if you are doing single you should only need one seed...?

#

Unless that doesnt get written back to whilst the job is running πŸ€”

minor sapphire
#

yeah exactly, it implies that the original "pass in the system's intance of Random" SHOULD have worked

solar ridge
#

Well...

#

actually... you wouldnt make the new Random in the job then

#

Is the thing

#

You'd pass the fully setup Random if running single thread

minor sapphire
#

yes, the original code had the system instantiate random OnCreate

junior fjord
#

yes I also think the original should have worked

#

I really have no clue why it doesn't

#

for me a pretty similar system works

minor sapphire
#

it seemed the most intuitive, and I still have no idea why that didn't work given it 'should' be running on one thread with ScheduleSingle()

junior fjord
#

allthough I did not have such a nice way as you to see if they are actually very random

#

you seem to be very opposed to just posting on the forums, right? πŸ˜›

minor sapphire
#

I'm gonna follow through with this test then try original again lol

#

yeah man, I'm on a role of tests right now haha

junior fjord
#

πŸ˜„ do what you have to do

solar ridge
#

... uh

#

Hmm Im trying to think in the pastebin. Did you try changing the state in main thread at all?

#

IE in the update rand.Next

junior fjord
#

ah @minor sapphire I maybe know why the original did not work

#

did you runt he system multiple times to get that output or all positions in one run?

solar ridge
#

As I know you;d have issues if you have an int for example in a job and wanted that result

#

So for each pass over rand.Next or what ever just to make the state change

#

Basically what you have but at line ~61 where Rand= rand, that is always the same state

#

so the first 100 ships would be the same as the next 100 ships

minor sapphire
#

@junior fjord the system does run multiple times. The OnUpdate is called for 20 seconds

#

OnCreate() is called every frame??

junior fjord
#

maybe try seeding the Random once in OnUpdate

#

since the rand is passed by value and therefore copied

solar ridge
#

Dont necessarily need to reseed (though that should work) you just need to increment the state

junior fjord
#

so each time you start the job it will start with the same rand

#

so maybe once per OnUpdate could change things, and then pass that in to the job

#

but I am on team one rng per thread overall, I think that is a pretty neat solution

minor sapphire
#

Soaryn!~!

#

I just thought about what you said!

#

I think you're right!

solar ridge
#

LOL

minor sapphire
#

It's a struct, it's passed by value

#

the state is the same every time!

#

I need to pass it by ref yeah?

solar ridge
#

Yea which is what @junior fjord may have just stated πŸ˜‰

minor sapphire
#

LOL i missed justsomequestions saying the same thing haha

junior fjord
#

ah yes, sorry did not read what you wrote @solar ridge

solar ridge
#

Mmmm not sure you can do that with job... 'twould be better to merely take what you have and just call rand.NextWhatever

#

Befor making the job

#

so that the state is dif each job schedule

#

otherwise, while you have a rand, it is the same rand state each run

#

Er

#

No reseed

#

Just to be safe

#

You could even have a randSeedMaker soarynOops

junior fjord
#

if you only call rand.NextWhatever make sure however to not make it rand.NextFloat, elseways you always get the same random sequence just offeset by 1

solar ridge
#

and just do Rand= new Random(rand.nextUint)

junior fjord
#

it is better maybe to make
rand = new Random(rand.NextInt) or something like that

#

yeah πŸ˜„

solar ridge
#

Yeah that was why I back pedaled to reseeding πŸ˜‰

#

Always good ideas in theory, mine are.. but not always implementation

junior fjord
#

yeah @solar ridge what you says should work

#

sorry if you stated that earlier and I missunderstood

solar ridge
#

This would explain why the index didnt really work

junior fjord
#

once per onupdate should generate enough random numbers per seed to be actually a bit random

solar ridge
#

Yep

minor sapphire
solar ridge
#

LOL

minor sapphire
#

ok I'm gonna read what I missed from you guys lol

solar ridge
#

O.o

#

what on earth are you.... doing with an array

junior fjord
#

maybe threads are not stared to be indexed by 0 but by 1?

minor sapphire
#

I was copying the one per thread example

#

oh yes indeed good point

solar ridge
#

Ah you neednt do that now (Shouldnt need to)

minor sapphire
#

fixing

#

yeah I just wanted to see what would happen heh

solar ridge
#

Crashing I think was the answer soarynLOL

junior fjord
#

ah

#

processorcount is less tha thread count I think

minor sapphire
#

yeah thread index started from 1

junior fjord
#

I am by no means an expert but I think I have 2 cores (~ processors) and 4 threads

#

ah ok than that was it

minor sapphire
#

but why LOL

#

ok so

junior fjord
#

is there something wrong?

#

for me it looks good

minor sapphire
#

no, this is a good result

junior fjord
#

nice πŸ˜ƒ

minor sapphire
#

I see no non-uniformness

#

this method should work in all scenarios and be the lest amount of seeding as far I can see

#

but I'm gonna scroll up and read what I missed lol

#

I can try original version passed by ref too

junior fjord
#

yes I also think overall this is the best method. I would even maybe not create the array in the system but in a static class at the beginning of the game

minor sapphire
#

oh this is a good idea too

#

a random util

junior fjord
#

yep

#

all systems can even use the same, I think its perfect

solar ridge
#

Lol just don't forget to dispose that on app quit

#

Ohh... hmmm jobs that are using it would need to be completed before disposing on app quit soarynScared

junior fjord
#

yeah but I have a few of the static helper data classes, I just always put an Initialze and Destroy on them which I call from my Bootstrap monobehaviour

solar ridge
#

That would... be fun to handle

minor sapphire
#

I'm 2 days into ECS so this is new to me haha

junior fjord
#

does the app quit without quitting its jobs first?

solar ridge
#

Yes

#

As it starts a thread

#

it does not wait for it

junior fjord
#

πŸ˜„

solar ridge
#

Found that out the hard way

junior fjord
#

haha ok yeah that could get ugly then

#

never would have guessed that

minor sapphire
#

lol

solar ridge
#

I think helpers right now are a ... slightly misguided solution for somethings that are memory stored. Not bad ideas mind you, but just early

minor sapphire
#

well if it gets disposed before jobs complete... the jobs will just go and die in the background yeah? lol

solar ridge
#

Likely should wait to see what changes before making a full on rando Helper

#

Shiny not quite

junior fjord
#

but don't you have the same problem if you store stuff in systems?

solar ridge
#

Depends on the job. And then in some cases they wouldnt dispose things in the background correctly if crashes

junior fjord
#

or is ondestroy called later than their jobs for the systems?

solar ridge
#

@junior fjord I can complete the job before appquit

#

I manually call complete with the handle

#

then dispose

wintry birch
#

afaik random isnt thread safe

junior fjord
#

ah yeah ok, so one needs to keep track of all jobs that use some nativearray and complete them before you dispose

#

that is probably easier in systems that in static classes

#

@wintry birch the end solution now was to also have one random per thread

wintry birch
#

oh yeah sorry i didnt read everything, just saw something about a static random

minor sapphire
#

yeah I'm not even sure how to pass rand by ref for the original method but because it's not thread safe I don't really wanna go that way anyway

#

so I think this one per thread is the best

wintry birch
#

yes, afaik

minor sapphire
#

but wtf did I just put in my code lol using Unity.Collections.LowLevel.Unsafe;

solar ridge
#

... out of curiosity...

minor sapphire
#

needed for [NativeSetThreadIndex]

solar ridge
#

Would you have been able to add a Random to your spawner and make it NOT readonly? soarynOops

junior fjord
#

my randoms are not readonly so yes it is possible

minor sapphire
#

I'm not sure what you mean

solar ridge
#

Each spawner has their own random with random seed

#

so when you go to spawn you'd just do spawner.random.Next

junior fjord
#

but my system did not run in parallel actually I think since it only had one entity to process

#

it was my first system and very misguided for the jobsystem πŸ˜„

#

so dunno if that would have had runtime issues

solar ridge
#

That random would be passed by ref and would be updated each next

#

Something to profile in the future

minor sapphire
#

How do I actually pass this rand by ref, it's not a method paramater

solar ridge
#

Well if you store the rand on the spawner it would already be done

#

That is why I thought of it

#

Only things passed by ref are the entity components you are filtering

minor sapphire
#

the spawner has the main thread component OnUpdate and the job thread component

solar ridge
#

So if the spawner had a random that was genned when it was created

#
IJobForEachWithEntity<ShipSpawner, LocalToWorld, Rotation>

Then assume spawner was something like

ShipSpawner {
LiterallyAnyFields Blah;
Random Rand;
}
#

So when you'd access the spawner you get a rand you can use for it as well πŸ˜‰

minor sapphire
#

ohhhh in the component data

solar ridge
#

Yeaaaa

#

Hence why I mentioned, would be interesting to profile

minor sapphire
#

heh interesting idea

#

god why not have a random COMPONENT lol

solar ridge
#

Potentially could be bad

minor sapphire
#

no bad idea, how to seed lol

junior fjord
#

but that way you again have only very few random values per random seed

wintry birch
#

i did a bit of research and what people recommend is having a global locked thread to generate random seeds, and having 1 rand per thread, using those random seeds

solar ridge
#

Potentially could be good

wintry birch
#

i mean locked random

solar ridge
#

Yea...

#

No idea who would recommend that πŸ˜‰

wintry birch
#

why

solar ridge
#

That was sarcasm πŸ˜‰

#

I recommended that from the get go

#

Btw @junior fjord "Random Number Generator based on xorshift."

#

"Designed for minimal state (32bits) to be easily embeddable into components."

junior fjord
#

yes if you reuse it it is fine

#

just saying you should not only seed it, spawn your entity using 2-3 random numbers and then throw it away

solar ridge
#

Not really a problem in this case

junior fjord
#

you will be again seeding for only 2-3 random numbers

solar ridge
#

as seeding it. is just setting state

#

Err problem being overhead

junior fjord
#

yes seeding is always just setting state

solar ridge
#

Regardless though, I'd be interested in seeing spawners have a built in rand field in their component data

#

As long as the spawner is not a shared component we should be fine

#

as the rand would be reused constantly, no reseeding needed, and it would be updated per use

junior fjord
#

yes, if you reuse the same rand in the same component you are completly fine

solar ridge
#

How many bytes is a uint soarynThink

junior fjord
#

most of the times I guess 4

solar ridge
#

Because that would be the cost of storing the rand

#

which would be cheaper than most NativeStrings

#

32 bits, yeah 4 bytes soarynGood

junior fjord
#

@wintry birch do you still know where you read that? I don't think I fully understand it

wintry birch
#

let me find it again

#

here it is
As noted by some commentators, there is another potential problem in using different instances of Random that are thread-exclusive, but are seeded identically, and therefore induce the identical sequences of pseudorandom numbers, because they may be created at the same time or within close temporal proximity of each other. One way to alleviate that issue is to use a master Random instance (which is locked by a single thread) to generate some random seeds and initialize new Random instances for every other thread to use.
@junior fjord
https://stackoverflow.com/a/3049478

minor sapphire
#

yeah that's essentitally the technique that was used

#

the system had its own master rng, used to generate seeds for the thread rngs

junior fjord
#

@wintry birch ah ok thanks

#

I would have just seeded every one with Seed(time + threadindex) but yeah maybe even using another rand for seeding makes it even more unpredictable

#

and if similar seeds actually result in similar sequences as @minor sapphire suggested it is probably not even a good idea to do it how I suggested

minor sapphire
#

yeah doesn't use seeds next to each other

#

or close

#

keep it random πŸ˜„

wintry birch
#

what about ThreadStatic? its recommended in the docs

junior fjord
#

@wintry birch ah but btw they are talking about Random.Next from standard library, I was talking about random from Unity.Mathematics

wintry birch
#

oh

#

nevermind then

junior fjord
#

that stuff does replace a lot of non-threadsafe stuff with threadsafe counterparts I think

#

so there is a chance that Random from there is threadsafe too but who knows πŸ˜„

solar ridge
#

Kind of. Most of it assumes you won't write at the exact same moment (in most cases the job scheduler should have that handled) however, I dont know exactly what would happen if 2 threads started competing for "next"

#

Likely nothign bad

#

BUT WHO KNOWS

minor sapphire
#

Note: this example uses IJobForEach.ScheduleSingle(), which performs the Job on a single thread. If you used the Schedule() method instead, the system uses parallel jobs to process the entities.

#

So my spawner is theoretically running on a single thread. So I thought, I can just instantiate a RNG once per frame in OnUpdate (rather that one per thread in an array), using a master RNG to generate the seeds, and pass that in to my single running thread.

#

Seems this one per thread thing is important EVEN THOUGH I'm using ScheduleSingle for this job, supposedly forcing it to run on a single thread

#

whatever, I'm gonna put back the one per thread array 😐

wintry birch
#

is the master rand locked?

minor sapphire
#

no, I better go test that

#

but it's only accessed from main thread anyway

#

I'm only accessing it on OnUpdate

#

Meh I'll go lock it anway lol

#

oh no I think I understand why, it's cause my master rand is in in util and it's a bloody struct passed by value lol

#

silly mistake

solar ridge
#

.... you made a matrix scene... neat

minor sapphire
#

haha yep pretty much

#

hey what would be the right way to prevent a system running for the first second or so

protected override JobHandle OnUpdate(JobHandle inputDeps)
{
    if (Time.realtimeSinceStartup < 1f)
    {
        //return JobHandle.;
    }
#

can't return null, and can't see any obvious property to return in the JobHandle struct

#

or could create a JobHandle, mark it complete, then return that I suppose

#

that seemed to work

if (Time.realtimeSinceStartup < 3f)
{
    var jh = new JobHandle();
    jh.Complete();
    return jh;
}
solar ridge
#

Reutn input deps

minor sapphire
#

ohhhh

#

ty

solar ridge
#

You COULD return a new job handle but lets assume the system had info it needed

frosty siren
#

I have a little trouble with SCD understanding and i need your advice, guys. I have units in my project and each unit refers to some fraction. I need only to store index of a fraction per unit. So with fact that usually unit doesn't change his fraction and i have not so much fractions i thought that use SCD for storing fraction index is a good idea. But i need to access unit's fraction to often and it can't be done in jobs directly. The only way is to prepare SCD values as array in main thread and transfer it to job.
The question is:
Is there enough benefit in this situation to use SCD?

junior fjord
#

@frosty siren I would first just go with a normal component and later decide if you want to have it as a shared one

#

the shared component also will change memory layout since the archetypes are divided by shared component data value

#

it could very well be that it is better to later have all archers in the same archetype, since the most heavyweight system will be on their behaviour

#

if you have the fraction as shared you have them sorted by fraction already

#

you could also maybe then have two shared components but maybe there are only 10-20 archers of a specific fraction and then your chunks would get rather small

#

but I am also more of an beginner

#

but for my project I for now make everything a normal component and will decide in the end what I make shared

#

and to effectively iterate on the scd values I guess you'd just use the chunk iteration, since then each job only has one chunk and therefore one scd value (but I've never done scd, so that is just a guess on how one circumvents your idea of preparing arrays)

frosty siren
#

@junior fjord thank you very much, your answer is very useful!

junior fjord
#

@frosty siren happy to hear that πŸ˜ƒ

#

@frosty siren ah and I think it is faction not fraction on english btw πŸ˜„

left spindle
#

I'd like my JobComponentSystem to interact with a single Entity/GameObject. I'm trying to pass the relevant values (just position right now) to each job, but how do I set that in the System in the first place?

#

I hope that made sense.

left spindle
#

I saw somewhere that you can use a static variable for the System's class? Set that from a Monobehaviour?

manic aurora
#

hm, there’s no trick to cloning a world or copying entities to a new world, is there? i know you can transfer entities between worlds, but id like the copy. found an old official post saying they intended to eventually support world cloning but 🀷

junior fjord
#

@left spindle I don't fully understand your question, can explain a bit more?

amber flicker
#

Just stumbled across a post by 5argon in case anyone else finds it interesting - https://gametorrahod.com/tag-component/ - pretty much mirrors my own experience

Game Torrahod

Tag component or "zero-sized component" is a special case in Unity ECS where IComponentData doesn't contain any field. The use is to intentionally separate entities to more chunks because a chunk is defined by one set of archetype.

frosty siren
#

@junior fjord yeah, it's faction but from my language to english fraction is also faction but with another context. Will rename my structs)

junior fjord
#

@amber flicker None of these occur if you are using EntityQuery overload of EntityManager where it operates on everything in a chunk equally.. Do you understand what that is about?

amber flicker
#

@junior fjord I'm not totally sure - perhaps worth asking him on the forum. I wondered if it was simply saying that using an EntityQuery would supersede any tagging? If somehow using e.g. RequireComponentTag was more efficient than constructing an EQ, I'd certainly like to know πŸ˜„

junior fjord
#

@amber flicker yeah it would interest me too.
Also this, If you could do per-chunk EntityManager action it is a no brainer to use tags instead of if the value. (So try to design the game this way, maybe cleverly using ISharedComponentData that things you want to tag are always grouped.) seems to be something I'd like to understand what he is trying to say

#

does he mean if I could just tag the whole chunk in one go and the entity manager would realize there is no reallocation necessary?

amber flicker
#

I think they're saying essentially if you can early out on a chunk, you should

#

From my understanding (which could be flawed), that would still basically be equivalent to chunk iteration and checking a bool for the chunk

#

If anyone else wants to chip in with different opinions/interpretations please do

junior fjord
#

hmm I still don't really understand it. I mean tagging basically means that the EM just gets you the chunks that have a specific boolean condition enabled

#

which other per-chunk EntityManager action is meant here?

minor sapphire
#

I'm just reading up in the background here

#

super interesting info

#

take-out for me seems to be to tag if you'll do a lot of work afterwords, but don't tag if work is not so big, and by work I guess I mean amount of filtering of entities

#

what is the EM btw?

#

entity manager I guess, answered my own question there

junior fjord
#

I think about this kind of problem in many settings and normally go with option B but I am not sure if that will maybe end up in some kind of problems later

amber flicker
#

If there are many TaxPayments and few TaxGroups does it make sense to make TaxGroup a shared component data added to entities that have a TaxPayment?

junior fjord
#

yeah but that is just one example problem of a few. If I'd always go with shared components I'd have very small chunks at the end.

Overall my humans for example have the following attributes that already all show similar "problems" to taxes and could be shared:

  • Their Profession
  • Their TaxGroup
  • Their Faction
#

if I would do a shared component for all of these I'd only have a chunk of for example "wealth (high tax-group) gold miners in village xyz" which are I guess like 2-3

#

I'd rather decide in the end which of these components should be shared

#

but if you think that is a bad approach please tell me

amber flicker
#

Just my opinion but... I think you're right to be mindful of breaking up chunks too small but it's a bit hard to answer these kind of questions without fully getting your head around the relationships between the data and what really needs to know about what. In this case, if Profession, TaxGroup & Faction rarely changed, I might wrap them all up as Enums in a single CitizenStatus IComponentData or smth

#

sorry, a shared component data

#

Actually I take that back...

#

I think your chunks wouldn't be that small because presumably your systems would also be logically separated - i.e. the TaxSystem shouldn't need to know about the Faction or Profession otherwise that data should be in TaxGroup right?

junior fjord
#

yeah most of the systems only need one of these

#

I'd say the most heaviweight systems are the ChooseProfessionSystem and ChooseProductionSystem

#

these need to know about taxes and Profession+Taxes respectively

#

because they basically calculate which profession is the most worthwile and which good is the most worthwhile (which is pretty much determined by taxes and nutrition)

#

but the chunks would still be small.
I want to support many small villages (100-200 humans) and a few larger cities (1000-2000 humans) and I guess overall there will be maybe 50-100 professions at most (but I can't put these in enums since I read them from textfiles)

#

and per city there could again be like 5 different taxgroups to tax the wealthy more than the poor (hopefully πŸ˜› )

#

so you'd be down to pretty few if you have everything as shared component

#

so at most 2000 per city, divided by 5 tax groups are 400 and then by professions are like 8

#

and these are the largest chunks, for the villages they are much smaller

amber flicker
#

Hmm I think I would have components on each human with e.g. their profession (which is just an int) that the ProfessionSystem would use to index into a static (well, shared amongst systems) NativeArray containing the data you need

junior fjord
#

yes that is what I am doing and what I tried to describe as Option B in my thread, thank you πŸ˜ƒ

hollow sorrel
#

i hear job system has some overhead so it's not recommended to use on things that take less than 0,05ms

but i'm using Entities.ForEach() and it seems to be causing 0,05ms overhead (with just one entity and one component) per time that method is used (e.g. twice in same system or once in two systems is both 0,10ms)
is there a better way to iterate components on the main thread?

#

ofc could be this is just editor overhead, i'm not sure how to check build since i'm looking at entitydebugger

unreal tundra
#

@hollow sorrel I'm trying to use ForEach, but I can't seem to get access to it. Whenever I try all i get is "foreach". Is there something I'm missing

hollow sorrel
#

yeah it's Entities.ForEach() now

unreal tundra
#

and just like magic it appeared

#

thanks!

neat magnet
#

Is this is correct way of managed allocation inside execute

#

Nativelist<int> one;

#

Execute

#

{ one = new Nativelist<int>(Allocator.Temp)}

#

I am using 19.1

frosty siren
#

Is it a good practice to use additional component to mark changes on concrete entity? I mean we can simply skip chunks that have no changes with version comparison but can't detect changes per entity.

neat magnet
#

It is giving me error that container is not assigned, DO I also need to create container and assign it via scheduling job in update method even though I need some temp allocations inside jobs ?

frosty siren
#

@neat magnet i think it will always produce an error if u will not assign variables of your job, so u need assign "one" NativeList in main thread. But u can allocate NativeList inside execute.

public void Execute() {
   var one = new NativeList<int>(Allocator.Temp);
}
neat magnet
#

Thanks, Can I use them for parallel writing ?

#

[NativeDisableParallelForRestriction]

frosty siren
#

Yes, but if u sure that u will not break up race conditions

neat magnet
#

Thanks @frosty siren

frosty siren
#

Small clarification: u can only use [NativeDisableParallelForRestriction] for fields declared in jobs not for variables inside Execute()
it's obvious, but still

minor sapphire
#

struggling to find information on what the "Convert And Inject Game Object" conversion mode in the "Convert To Entity" MonoBehaviour does. anyone able to point me in the right direction or tell me?

junior fjord
#

@frosty siren I just have a bool directly in the component that tells me if it changed for now

frosty siren
#

@junior fjord but if i have system that just read component value and not bool part it's better to separate, isn't it?

junior fjord
#

yeah, actually can't think of any reason why one should not seperate

#

you are probably right

left spindle
#

@junior fjord I guess my major problem is that I don't know how to get separate entities to interact with each other.

vale gorge
#

Is there a good way to get the index of an element inside of a NativeArray?

left spindle
#

I know IJobParallelFor uses the index

junior fjord
#

@vale gorge do you mean searching for an array entry by value?

#

@left spindle you could check the examples on github, they make a pretty god tutorial

vale gorge
#

I have the NativeArray element, but I need to know it's index value within the NativeArray.

left spindle
#

I am going through them, the Hello_* ones?

junior fjord
#

yes

left spindle
#

I don't see any ones where entities interact with other entities.

junior fjord
#

yes, so you have the value and want the key. Why not just do

if(array[i] == value) break;
use i
#

what do you mean by interact?

#

do you mean physics?

left spindle
#

Yeah, that's one way. I was just making a grid of items, then I wanted to shoot a ball into them, and determine which item it's closest to, as an exercise.

junior fjord
#

that is a pretty advanced example for a beginner exercise

vale gorge
#

@junior fjord I would, but it is a very large array and causes a massive hit to performance

junior fjord
#

the physics stuff is pretty new and not as well documented. There are physics examples and you could do that but if you want to learn about ECS I'd start with something simpler first

#

else you'd have to grasp how ECS works and how the brand new early-acess-y physics-ecs works in one go

left spindle
#

I know how to make things interact with themselves. I've gone through the tutorials. (It's awesome!)

#

Now I'm trying to move onto something more advanced.

junior fjord
#

@vale gorge yeah if you explain a bit more how you got around to having that problem maybe I have an idea, but if your array is not sorted or anything I don't think there are more efficient algorithms than that

#

NativeArray does not have this functionality implemented

left spindle
#

Like GetComponent<> but for ECS...

#

Coming from OOP it's a major change in thinking! Pretty cool though.

junior fjord
#

yes it has a steep learning curve but it is rewarding

#

but interaction basically happens in the systems now, you don't have these event like functions

#

I am basically programming a simulation so I did not need to learn about physics yet, but I'd say you should first have a very solid understanding of the ecs itself before moving to using the physics stuff

#

or try go ahead and read the physics examples in the repository

#

they even have shooting stuff etc., its just more complicated

left spindle
#

The physics samples in the repo throw errors on my machine, unfortunately.

junior fjord
#

do you have Entities version 30 and the newest unity?

#

they worked for me like a week ago

left spindle
#

That's another thing, it keeps wanting me to "upgrade" to .24-timefix or something.

junior fjord
#

hmm, sorry I've never heard of that

#

you need the Entities package version 30 and the hybrid renderer

#

and probably also the mathematics package

left spindle
#

I have NO idea where to get the nuget

junior fjord
#

you already have the nuget

#

you have a to new version as it seems

vale gorge
#

@junior fjord so what it is is I am rebuilding a mesh. But I want it to keep vertex color data for the vertices that have not changed positions sense the last rebuild. I was using a Dictionary where they key was the position and the value was the color.

But to stop the game from freezing I am moving it to a job. So I can't use a dictionary now. So instead I have native arrays that store the old positions, and colors, and set that stores the new positions and colors. And check to see if the positions are the same and if so I copy the color over. But I can't get the right index for the color unless I can get the index for the corresponding position.

Hope that makes sense, and I appreciate your help. πŸ˜ƒ

junior fjord
#

as least how I understand that

left spindle
#

But...I don't know how to do that, it's not in the package manager.

junior fjord
#

yeah sorry, I'd post on the forum to ask

#

I have no clue

#

hmm is there no way to alter the rebuilding mesh algorithm to somehow keep track of which positions change instead of doing it afterwards?

frosty siren
#

i have a trouble. when i start my project unity editor not responding after "Resolving packages". Do u know what it is and what i can do to solve it?

UPD: here is solution https://answers.unity.com/questions/1428939/unity-201720f3-resolving-package-error.html

UPD 2: solution worked only a day ago but now any steps from post doesn't change anything

safe gate
#

Hey everyone, I opened the DOTS sample scripts in Rider and I get these error messages, but on Unity they don't show up. Any ideas how to get rid of them?

junior fjord
#

But really for graphics and physics I am the wrong guy, I am basically writing a simulation

#

@safe gate I have the same problem and did not get it resolved

#

are you also getting it in a IJobChunk?

vale gorge
#

Sadly no.

safe gate
#

@junior fjord too bad. I'm glad I'm not the only one at least

junior fjord
#

does unity still compile though? I am rewriting a lot and did not have my thing in a compile-ready state the last few hours

vale gorge
#

Looks like a Hashmap could work for what I want. But I can't seem to find them. I have using for Jobs, Entities, and Collections. But can't seem to find them.

#

Are they only in 2019.1?

left spindle
#

Aha! It's under "Mono Cecil" in the package manager, not nuget

left spindle
#

Another problem that I run into is the "ArgumentException: Object at index 0 is null" happens every time I hit play, for instance, in the physics example "Hello World"

#

That and a LOT of instances of "Internal: JobTempAlloc has allocations that are more than 4 frames old"

#

Sometimes in the editor, and I can't get it to stop. I have to load a new scene.

left spindle
#

I can't learn a thing from the physics samples...

vale gorge
#

Any ideas why this

[NativeDisableParallelForRestriction]
        public NativeArray<Color> newColors;
        [NativeDisableParallelForRestriction]
        public NativeArray<Vector3> newPositions;

        public NativeArray<Element> old;
        
        public void Execute (int i)
        {
            newColors[i] = Color.white;
            Vector3 pos = newPositions[i];
// This line specifically.
            Element point = old.Where(p => p.Position == pos).FirstOrDefault();

            if (point.Color != Color.clear)
            {
                newColors[i] = point.Color;
            }
        }

Is getting me this error IndexOutOfRangeException: Index 0 is out of restricted IJobParallelFor range [256...319] in ReadWriteBuffer.

left spindle
#

Does the old need the [Native...] attribute too?

vale gorge
#

Stupid... yeah.... thank you.
I even looked to make sure I had the attribute on stuff...

left spindle
#

Hooray I helped!

blazing mural
#

Has anyone else had issues getting entities rendering quads to sort in any predictable way?

urban rivet
#

Transparent?

blazing mural
#

Yes

#

Nothing I do seems to work. If they arent entities, and just gameobjects, they sort fine. Its a 3D scene with quads moving along Z.

#

Otherwise it seems like the latest created entity is always rendered on top.

#

Opaque seems to work fine

vale gorge
#

Before I do a bunch of work trying to reimplement something. Am I right in thinking that you can't use a variable that is a class in a job?

#

Even if it is all self-contained with in the job.

neat magnet
#

I am creating nativelist like this in 19.1 var p = new NativeList<int>(Allocator.Temp);

#

IS there any way I can read and write on this list

#

Unity showing error The native container has been declared as [WriteOnly] in the job, but you are reading from it.

minor sapphire
#

All I'm doing is spawning entities over a bunch of seconds at the start of the game. None of this archetype have been destroyed yet, only spawned. And yet the chunk utilisation for this archetype looks like this. I would have expected chunks to be filled. Wonder why not...

minor sapphire
#

interesting, over time as I spawn more and more, the histogram improves, but it always starts out not so great

#

meh whatever

junior fjord
#

@minor sapphire do you know how to read that chunk utilization? I never get it

minor sapphire
#

I think so

#

you want tall bars to the right

#

y axis (162) is number of chunks

#

x axis is chunk size

#

tall bars to the right means you have many chunks where each of them is full (highly utilised)

#

my graph shows I have a heaps of chunks that are only partially utilised

#

which is strange considering I have not removed any entities of that archetype when I took that pic

#

Guys, can I perform an entity query from within a job?

#

oh it's a class so probably not 😐

junior fjord
#

@minor sapphire thanks that makes sense

minor sapphire
#

ok if I have jobs A and B scheduled from one system where B depends on A, can I pass data from job A to B?

solar ridge
#

Should be able to

minor sapphire
#

Is there a way to batch EntityCommandBuffer.Instantiate and EntityCommandBuffer.SetComponent calls?

#

queuing up all these commands to be executed one by one seems unfortunate

stuck saffron
#

Pretty sure you can batch instantiate but there isn't batch set components yet

vale gorge
#

You can't use reference types within a job at all correct?

rancid geode
#

@vale gorge thats correct

vale gorge
#

Well shoot. Alright, thanks.

frosty siren
#

@minor sapphire are u sure u are not in case, when u use SCD which changes data layout?

#

@neat magnet if I understand u correctly u just need to not mark your list at all and u be able to read and write

solar ridge
#

Entity queries are done main thread. If you are wanting to use it with say a Foreach job, you can pass it when scheduling

#

To answer an earlier question from @minor sapphire

pulsar mesa
#

Is there some equivalent of a callback for when a component is removed via EntityCommandBuffer.RemoveComponent?

#

I want to execute some code whenever a certain component is removed, but I remove it in a job so I can't call the main thread

tawdry tree
#

You could create a message entity?

pulsar mesa
#

how does that work?

tawdry tree
#

As in, an entity whose sole purpose is to signal to another system that something has happened

pulsar mesa
#

ok. so have a system that just constantly iterates over the message entities?

#

and do something if there is one?

tawdry tree
#

Yeah, that's one way to do it

#

Alternatively, send in a nativecollection (typically array) of size one to the job which potentially removes the component. Then, if it removes the componenet, you change the content of the array.

#

Usually a NativeArray<bool>[1] (or int)

#

That requires you to use system dependencies and to make sure the previous job finished (change or no change) before you access it, though

pulsar mesa
#

when you say send in a native array, do you mean create another system that has the UpdateBefore attribute and somehow modifies the current system that removes the component?

#

sorry, im not really familiar with interaction between systems/jobs yet

tawdry tree
#

So the nativecollection-as-message method means you have two or more systems, where SystemA has read/write access to a nativecollection.
It sets the values as it needs to according to whatever needs you have.
Then other systems can set that system as a dependency, run SystemA.Complete(), and then access the nativecollection to read the values. These systems should probably only have read access, so that you can use the output from SystemA in multiple other systems. That or you end up making a chain, if that's something you might want.
ie. SystemA does stuff, then SystemB takes that as input to do something else and has an output etc. Pretty sure in you want systemB to make its own collection, though, just in case. To make sure you write once, and then only read.

pulsar mesa
#

ok that makes sense

tawdry tree
#

The entity-as-message method is simpler, but has up to one frame of lag, and you need to do some trickery if you want multiple consuming systems. - The initial system would need to run before everything else, and you'd need a MessageDeleter system that ran after everything else. That or make sure the last two things that happen in a frame is to delete old messages and then make all the new ones that have been 'queued' somehow.

pulsar mesa
#

gotcha

#

i see now πŸ˜ƒ

#

thank you for the help!

solar ridge
#

IsystemComponents I beleive are your ideal scenario for when an entity is removed

#

Ah.... scroll locked.... soarynPalm

near gulch
#

any idea when ECS is gonna come out of preview?

safe lintel
#

i think around this summer for the core parts

solar hill
#

hey so i was just doing som stuff with jobs and realised it would be great if i could have a job wait in its execution. so do something, wait a bit, do another thing etc etc. is there a way to do that?

toxic walrus
#

@solar hill no idea why you would want that but you can run a for loop from 0 to 100000 to simulate waiting

solar hill
#

@toxic walrus well say you wanted to start a process running and have it run in the background then after a predetermined amount of time do something again.

solar hill
#

i allso have some more abstract questions about the "correct way to implement certain things. for example caching data in the system that a job is running on. for example, if you needed something to have a timer or multiple stages or something would it be better to cache that data in a hashmap on the system that uses it or to keep it in a different component attached to the entity?

#

i feel like using a different component would lead to having tons of tiny annoying components say a "current step "component and a "timer" component, just to name a few.

#

My dilemma comes from having seen most of the info on ecs say to just use little components whereas the unity demo for BOIDS stores a lot of data in the system. Is that only really smart ina scenario where you have a lot of things doing similar stuff using SharedComponentData?

golden heron
#

@solar hill just applying some logic to your questions...

#

caching a timer on the system, or on the object - decide this simply by figuring out whether each entity needs and independent timer, or are they all running from a central one? If its from a central one, send the data into the system, if its independent, place a new component value.

#

In the boid example, the system needs the central timer,

#

because, for example, the entire school of fish is moving in time, wiggling sideways to look like they are swimming.

#

I have a similar question, more to do with where to break the system down. I have,in the simplest description, intentions to write a movement system and a rotation system, and i need drag calculations, should i have four systems, one each for the movement/rotation then one each for drag?

#

What would you think, faldor?

solar hill
#

hmmm interesting i think if we are looking at a system that may be used on a huge number of entities it is worth taking into account the individual cost of getting a component. i think the "best practices" would probably tell you to break it into 4 systems. However from a performance standpoint having your movement and drag be done in the same system would eliminate the need for essentially identical entity and component retrieval between each system and its associated drag system.

#

Besides, when really thinking about it, drag is an essential component of movement. I would say that there is not a strong argument for separating them.

golden heron
#

The cost of getting a component - they are gonna be paying the cost anyways, and for your timer, it's data is basically a float (i guess), so its not a huge concern. If the component system is using the chunks method rather than direct entity management, this wont be much of a concern.

#

As, in the chunks method, the chunks are already sorted into the collections of data that match into the same groups.

solar hill
#

well that's not entirely true, getting the entity architype twice for two different systems, using essentially identical data, is less efficient. Getting the list of entities for a specific combination of components does have a tiny cost. That cost might be apparent when iterating over potentially millions of moving entities . It really does depend on the scope of the number of entities this system will deal with

golden heron
#

You are referring to my question now, i guess? I will give a quickidea of the usage case.

solar hill
#

i was to you question in both my answers

golden heron
#

My game is a space based mmo, with self contained solar systems of planets orbiting suns and with many interconnected solar systems, connected by starlanes.

#

The ecs systems involved in the movement will exist in two forms, one of them is client side, it runs a single solar system at a time, the other is server side and will run the movements of a large number of ai ships in all the systems simultaneously.

solar hill
#

well i think your game is probably a prime example of a time when you may want to consider the cost of searching for entities twice when you don't have to.

golden heron
#

I am hoping for 2000+ systems, with half of them possessing a number of ships they'll send places, so i imagine we are talking something like 5000 simple background entities, the server's movements will consider time and space, but not really collision, whereas client moves will be fully collision calculated.

#

So, the main question about the drag applies mostly to the client systems. But still the general idea, "How many small steps should i break the system down into" applies a lot.

#

It seems your generalised answer is, "Be careful not to break the steps down too small if the same selection of components is gonna be searched"?

solar hill
#

yeah. well i think the best way would be to just run your own tests. I'm pretty sure that someone on the unity forums made a post about the cost of getting entities and it was small, but noticiable when getting lots of them

golden heron
#

Ok, cool, was this a new post?

#

The archetypes system seems to be there specifically to avoid this cost of iterating to match entitys?

solar hill
#

no, fairly old. tbh it may not be very relevant, ecs has changed a hell of a lot

golden heron
#

Thats what im thinking, you know what an archetype is?

solar hill
#

im not sure.... maybe. though you do still have to consider the cost of initialising a job, its not much but again, its there.

golden heron
#

An archetype is a search shortcut, basically.

#

When it sstarts it basically scans your entities

#

the archetypes are automatically generated, it looks through your entities and any groups containing the same components, are then sorted into archetype groups

#

When you request the entities with the specific components for your system, its likely an archetype already exists making the get faster

#

If it doesnt exist already as an archetype, im not sure if it adds a new one - it would make sense that it did - but i do know that it can look at another archetype as containing this one.

#

So, before you even run a single system, ecs (at keast the newest one) already has your entities sorted into piles, and labelled piles at that.

solar hill
#

hmmm.... this makes me want to run my own tests now.

golden heron
#

However, im new to learning this, that might be wrong, but thats how i understood it

solar hill
#

yeah it does make sense... though you would think you would end up storing a huge amount of useless data if you made archetypes of every combination, regardless of whether it is used or not.

golden heron
#

Well i imagine that the archetypes themselves might be somehow considering what a sensible combination is, maybe it looks at your systems or something, im not sure.

#

Rather than every combination. It wasnt 100% clear what defined the archetypes, it was just clear that the sorting was already done. Do you use the jobchunks?

solar hill
#

yeah that would make sense.

#

jobchunks?

golden heron
#

You can send two different jobs to act on the entities, one does just one entity, the other does a chunk of enemies (chunk is their chosen term) but basically a group with same requested components

#

Altho i was just thinking... For every job added to the heap, there will be a small cpu pause somewhere at some point when it calculates. So, if you make any job chunk too complex, then surely you will end up with a system which has fluctuating timings? In some ways, the pause between jobs coming more often in spite of their being more jobs might help the system stay smoother?

minor sapphire
#
IsTrigger: if this flag is enabled, the collider is treated as a "detector" rather than as a physical body. This means it cannot receive forces from a collision, instead, it will raise an event to signify that an overlap occurred. For example, you can use this to determine when your player enters a specific region.
EnableCollisionEvents: this is similar to the previous flag, but still allows the body to push other bodies normally. The events that the simulation raises, then can be used to determine how objects are colliding -- this would, for example, allow you to play sound events.

This makes it sound like I can access some kind of events to know when things collided. Has anyone seen an example of how to do this?

golden heron
#

In ecs?

minor sapphire
#

ya

golden heron
#

Im about to code my own cos their physics explanations are lacking.

#

It took me a hile to find out even that i needed to download it as a package hehe

solar hill
#

is it from the new unity-physics package?

minor sapphire
#

I think it might be about this:

Unity.Physics.SimulationCallbacks.Phase.PostCreateContacts
At this point, we have performed the low-level collision information between every pair of bodies by inspecting their colliders. You can access this through Simulation.Contacts where the data is in the format of a ContactManifold containing some shared properties, followed by a number (ContactManifold.NumContacts) of ContactPoint contact points.
#

yes

golden heron
#

But my own use case, being able to remove the background automatic physics is very useful. Calculating physics in space is quite easy tho.

#

That looks like the thing - where are you getting that from? Looks like usefull information there

golden heron
#

Damn yoo!

#

Hehehehe thanks for the link ( @minor sapphire )

#

I wish id known that was there sooner

minor sapphire
#

so it looks like as the simulation runs its various stages, data becomes accessible

#

so perhaps you would add a system that queries for that data and then raises events in ECS however you like to implement that

golden heron
#

Makes sense. (Thanks @solar hill for your thoughts too :) )

#

Im thinking of a method which should enable me to completely eliminate the possibility of fast movement resulting in missed collisions, tho. With the speed of stuff in my game the entire suite of unity physics has no way to work it.

#

I mean, 900 units per second is enough to make bullets jump through ships frequently, but, its space! Bullets should be real fast! And some of my ships exceed 1200 units per second... So they cant be hit when they travel more than a ship length per frame.

#

Here is an interesting question tho...

#

To collect the entities our system works on, we request some data components. Lets say, part of the processing that needs to be done is done by one system, and later, another system needs to use that data, but it isnt in the selection chosen by the components for the system, and its entity-specific. Is there a standard way that ecs would pass this information?

#

Would you for example, add components for the second system, and make the first system output its data to the entities components directly, so when scooped up by the second system it gets the data that way? Of course, taking appropriate steps to make sure that the first system always runs before the second

#

@solar hill "As you create entities and add components to them, the EntityManager keeps track of the unique combinations of components on the existing entities. Such a unique combination is called anΒ Archetype. The EntityManager creates anΒ EntityArchetypeΒ struct as you add components to an entity. You can use existing EntityArchetypes to create new entities conforming to that archetype. You can also create an EntityArchetype in advance and use that to create entities." - ecs package docs, unity docs website

#

So, it seems like it does track every unique combination, but, it does so by those that exist, not those that could exist.

solar hill
#

I see, that does make sense. Though I would still like to compare a two system Vs one system solution to ascertain how much overhead there is when pulling the data from those entities.

junior fjord
#

is there a better way to quickly enable and disable systems for profiling than commenting them out?

minor sapphire
#

@junior fjord you can disable them during runtime in the entity debugger, but not sure if you can do so before hitting play

junior fjord
#

yeah I just went with commenting out as always πŸ˜„

#

but I started to put systems and components together in the files so I now have to be careful about which parts to comment out

junior fjord
#

ah I can just manually disable enable the systems from my bootstrap mb

junior fjord
#

does anyone have any clue how come Time.Delta time always returns exactly 0.1f (i.e. 0.10000000001) when I am in debugging mode?

amber flicker
#

err that doesn't sound right πŸ˜ƒ

junior fjord
#

yeah thats so weird πŸ˜„

#

if I am not debugging, my first frame is 0.02, then one is again exactly 0.1 and afterwards everything is 0.02 (I know, could be better :P)

#

if I am debugging, Time.DeltaTime ist just always 0.1

#

took some time to understand that that was causing some of my problems

amber flicker
#

when you say debugging, do you mean profiling or..?

junior fjord
#

I mean using rider and attaching a debugger to the thing

amber flicker
#

ah I see

junior fjord
#

I have a timing system that just counts up Time.DeltaTime and increases some variables like currentTimeStep for other systems

#

I had duration of a TimeStep set to 0.1f and every frame it made a time step and said durationLastTimeStep = 0.1f

#

I had to set duration of a TimeStep to 0.5f to realize that actually the Time.DeltaTime did always return exactly 0.1f πŸ˜„

#

but no idea why or how I could debug that

amber flicker
#

sounds like a nightmare if you get that in just a standard empty project... good for finding race conditions etc though πŸ˜…

minor sapphire
#

wow trying to work through collisions in 2nd preview of physics is quite an adventure

#

kind of like solving a puzzle

#

but I'm learning bit by bit so if anyone is looking at collisions and collision events let me know, maybe we can compare ideas

junior fjord
#

@minor sapphire what do you mean by 2nd preview?

minor sapphire
#

I mean 2nd release

#

version

junior fjord
#

did they release it in the near past and is there documentation?

#

or is it still the same thing that the samples are using?

minor sapphire
#

no nothing since april 8

#

I'm just making the point that it's a challenge working with such an early preview

junior fjord
#

yes of course, just wanted to make sure I did not miss anything

frosty siren
#

will chunk change version if i get access in IJobChunk to some DynamicBuffers and then i call AsNativeArray() at one of them?

junior fjord
#

@frosty siren I don't know, I imagine it depends on if you got the dynamicbuffer as readonly

#

btw with rider it is really easy to jump to the source code of the ecs which is often very readable

frosty siren
#

@junior fjord
Note that for efficiency, the change version applies to whole chunks not individual entities. If a chunk has been accessed by another Job which had the ability to write to that type of component, then the change version for that component is incremented and the DidChange() function returns true.
So what the benefit of using chunk skipping in case when i haven't accessed to component and i have no need to compute it and in case when i have accessed to component and i have no way to skip chunks which was really rewrited not just accessed?

I understand that i can have many archetypes with same component and different logic for this archetypes but one algorithm that work with this same component and in this case chunk skipping will have benefit i guess

safe lintel
#

Is the chunkIndex the same as an index(from say IJobParallelFor) for using EntityCommandBuffer.Concurrent and chunk jobs? or should I be using non concurrent EntityCommandBuffers with chunk jobs?

minor sapphire
#

from within a IJobForEach, can I change component data for another entity? It does seem to go against the idea of tight memory access though. Trying to implement an event system and getting a bit stuck hmm

elder wharf
#

something like this?

private struct MyJob : IJobForEach<RandomComponent>
{
    [NativeDisableParallelForRestriction]
    public ComponentDataFromEntity<CustomComponent> CustomComponentFromEntity;

    public void Execute(ref RandomComponent ac)
    {
        // get component from another entity...
        var customComponent = CustomComponentFromEntity[ac.Entity];

        customComponent.Value = 42;

        // set component of another entity...
        CustomComponentFromEntity[ac.Entity] = customComponent;
    }
}

protected override void OnUpdate()
{
    var job = new MyJob
    {
        CustomComponentFromEntity = GetComponentDataFromEntity<CustomComponent>()
    };

    job.Run(this);
}

@minor sapphire

minor sapphire
#

Oh I haven't seen customComponentFromEntity before

elder wharf
#

this is just how I named my variable^^

minor sapphire
#

Oh on mobile and it wrapped lol

#

H thougt I tried that. It said I wasn't allowed to write into that container...

elder wharf
#

ah

#

ah yes, you need to add the attribute [NativeDisableParallelForRestriction] on the variable

#

I forgot to add it on my example x)

minor sapphire
#

Ohhh I see

#

So it's doable, but I'd have to careful about what's happening to that component in parralel?

elder wharf
#

yep

#

you can also run the job without it being in parrallel by using .ScheduleSingle() instead of .Schedule()(in case you have some problems with parrallelism...)

minor sapphire
#

Oh I see Ty!

#

Super helpful man Ty. Now I can't wait to get back to work tomorrow heh

elder wharf
#

πŸ‘

winter veldt
#

hey all. is there like.. somewhere to keep up with the current state of the ECS? i keep ending up with different examples from different stages in its development. The samples don't seem to cover everything and the docs for up to date stuff are generally empty

#

I'd love to play around, but it ends up being such a headache

safe lintel
#

experiment and ask questions, also check out the pinned message here

winter veldt
#

i am experimenting.

#

here's a question. i'm trying to make a movement system using an IJobForEach, if I use LocalToWorld, can i set the value of it to move an entity?

tawdry tree
#

No, it's the Position component you should change

#

At least, I'm pretty sure the LocalToWorld component is, in fact, there to help you convert the local position into a world position.

winter veldt
#

there isn't a position component anymore i believe.. it's Translation. but my entities don't have that, just a localtoworld component, which seems to have translation, rotation, and scale rolled into one

#

so if i try to query entities via translation it doesn't seem to do anything?

#

lol ok nevermind it's Translation.

#

I believe I need to spend some time to actually understand the Entity Debugger correctly.

tawdry tree
#

Hmm, merging them makes sense, and they renamed it too, huh.

safe lintel
#

you could modify the localtoworld directly, but its not as convenient as modifying the translation

frosty siren
#

Should i call EntityManager.GetArchetypeChunkBufferType<T>(bool) to get type every OnUpdate() or just once? The question is: "what information contains ArchetypeChunkComponentType/ArchetypeChunkBufferType/etc?"

safe lintel
#

i do it ever frame and it seems to work fine, but I have wondered about caching it

frosty siren
#

Do u dispose your native container every OnUpdate() or initialize it once and then just clear it?

safe lintel
#

eh nativecontainer for what?

minor sapphire
#

does LocalToWorld.Position return a world space pos? It seems to be giving me world 0,0,0 despite my object being at y -50

#

what is the correct way to get a world space position from an entity, plus say 10 units along its local y direction

minor sapphire
#

hmm I must be misunderstanding something

#

perhaps the transform system hasn't run or something? But that doesn't make sense cause translation.Value has the correct position

#

maybe I just misunderstand the purpose of LocalToWorld

#

that is perhaps all local position and direction information

#

oh but it's actually correct within a different system...

#

must be something about timings when considering spawned entities

tawdry tree
#

Is it in world pos (0,0,0)?

minor sapphire
#

maybe I should explain more.
I have a ship, spawned by a ship spawner. The ship spawner's transform is in the pic above, at -50, and rotated.
The ship spawns as expected, at -50, and rotated as expected.
The debug output for the ship spawner looks good.

#

SP in the debug output for 'Ship Spawner'

#

The spawned ship has a Weapon component

#

it is trying to spawn a bullet. The rest of the debug info is from the weapon system. It thinks the ship is not at -50, but rather at 0,0,0

#

and it thinks it is not rotated

#

but, at the very bottom

#

the TRANSLATION component is correct, showing -50

#

So, for some reason, the LocalToWorld component does not agree with the Translation component...

mint iron
#

are you trying to spawn a bullet as a child of the ship in terms of auto transforming?

minor sapphire
#

yes

tawdry tree
#

Well duh

#

Then the position is in the ship's transform-space

minor sapphire
#

I would like the bullet to spawn at the position of the ship + say 10 units in its forward direction

tawdry tree
#

childing is for when the bullet would be part of the ship

minor sapphire
#

no wait, I would not want the bullet to be a child of the ship

tawdry tree
#

what you want is to spawn the bullet at ShipPos+(Ship.forward*distanceFromShip)

minor sapphire
#

I want the bullet to be it's own entity not childed

tawdry tree
#

Vector math, it can be tricky!

#

But yeah, there's a reason why it givens you the forward vector

minor sapphire
#

yeah, I agree with your math there, but in the weapon system (on the ship entity), the LocalToWorld.Forward is incorrect.

#

wait wait

#

lemme just confirm that

tawdry tree
#

If it's rotated in some combination of 90 degrees, then you probably just messed up the rotation of the ship model/sprite in the first place

minor sapphire
#

the ship spawner is rotated roughly 45 deg

#

the next 5 lines are the ship's weapon system showing the LocalToWorld and Tranlsation component values

#

they SHOULD match the values of the Ship Spawner

#

Notice that the Translation.Value does match

#

but the LocalToWorld values do not

#

the ship spawner is a direct ConvertToEntity object in the unity hierarchy. The ships are spawned after hitting play. I wonder if that is related

tawdry tree
#

The forward.Y float seems to just be a rounding error. 1E-8 = 0,00000001
In fact, so does the up.Z

minor sapphire
#

yes, I'm just treating it like 0

tawdry tree
#

For all intents and purposes, the direction vectors seem to be ~=Quaternion.identity, aka world rotation

minor sapphire
#

yes precicely

tawdry tree
#

Meaning you simply don't apply the rotation?

#

Could you share your system code? Just the spawning bit

minor sapphire
#

The ship itself is rotation 45 degrees

#

this is working as expected

#

Oh god I have to go to dinner, I'll be back soonish

tawdry tree
#

So if I understand correctly the ship spawner spawns a ship in a random nearby location? And that works as intended, correct?
The line where you set the owner shared component look like an odd way to do that to me, but I haven't touched those in a long while so not sure what the 'proper' way is. If it works, it works.
It seems pretty clear to me that the values sent to the weapon job are incorrect. If I understand IJobForEachWithEntity<TEntity, T1, T2 [...]> the other values will be taken from the TEntity entity, meaning you get the (local) location and rotation of the weapon, not the ship.
In short, to fix this you need to find out how to either get worldPos and worldRot from the wep's components, or get the other components from the correct source. Might still need to covnert to worldSpace, though.

minor sapphire
#

The weapon is just a component on the ship entity

#

It's not its own entity, so it doesn't have its own transform or pos or anything

#

Hmm

#

I feel like maybe the transform sysm has not run yet to convert translation and rotation into localtoworld

#

I couldn't see that system in the system list so not sure when I should schedule my systems...

#

Perhaps I could try waiting a frame before firing

#

I'll try that when I'm back at comp

#

Perhaps I should stop using Localtoworld and use the the translation and rotation components instead.

minor sapphire
#

it does indeed seem fine if I don't use values in LocalToWorld immediately after a spawn.

#

so likely issue is the transform system didn't have a chance to update LocalToWorld yet. It must be waiting for my logic to update Translation, Rotation and Scale before applying to LocalToWorld for rendering

#

I guess in this case one should use Translation and Rotation if you want up-to-date values if perhaps you are relying on information updated from a movement or rotation system, and indeed immediately after a spawn

#

wonder if it's a bug though

mint iron
#

that makes sense, im not sure when localToWorld is updated, i would assume you cant use it until next tick. Maybe u could set a group dependency on the system to get yours to run directly before it.

stoic monolith
#

Hi all, can i PM someone asking some noob question about ECS? Or some links? i haven't started learning it but my main concern if i even need for some things im doing

minor sapphire
#

@stoic monolith if no one has replied you can pm me. I'm new myself but getting the hang of it.

#

And now for a question of my own.
Anyone know if there is a SharedComponent version of ComponentDataFromEntity? Or in other words, how do I get shared component data from a referenced entity within a job?

gusty comet
#

Do particle systems work with ECS? My instantiated entities have child objects with particle systems that don't seem to be working

tawdry tree
#

I don't think there's ECS particle systems yet, no, so you would need to spawn in gameobjects with particles separately. Or find another way to achieve whatever you're trying to do.

dull copper
#

you can jobify shuriken particles tho

#

and visual effects graph is still mostly gpu I think

#

@gusty comet

tawdry tree
#

Well yeah, but you can't turn a particle gameobject into an entity; you need some other method.

dull copper
#

yeah, I guess you still need gameobject today for this stuff still

#

just pointing out the job system possibility in case that was one reason to ask about it

tawdry tree
#

Overall I see a few alternatives:
-Use gameobjects for the particles
-Use some shader (or as Olento suggest, VFX graph)magic
-Olento suggest Shuriken particles via jobs, never touched that so can't say
Depends on what you're trying to accomplish, really.

dull copper
#

I don't really suggest any of those, just pointing they exists πŸ˜ƒ

#

I don't have first hand experience on jobified particles more than trying they worked on some early preview build + have tried VEG samples

tawdry tree
#

The only one I can actually get behind of those is the gameobject method, as you (Pyrrhic) presumably know how it works. It introduces complexity as you need to have hybrid objects, and won't give you the (full) ECS performance, but it's probably the path of least resistance.
Again, depends on what you're trying to accomplish; a lot of things you would think of using particles for can sometimes be done through other means for a no worse result.

minor sapphire
#

Starting to the get the hang of things. 8k ships in total, about 4k bullets at once. Everything has a sphere collider. 60-70fps. I'm not sure that I've done it well though. Gotta wrap my head around things like sync points and try and understand why I don't see a lot of activity in jobs threads in profiler.

#

hmm I need to check vsync lol

#

hmm it's off, fewer ships have more FPS

tawdry tree
#

Do you have a gif/video of that? Even just a couple seconds would be interesting

minor sapphire
#

sure gimme a sec I'll record something

#

(tries to figure out ShareX recording)

junior fjord
#

I used it today

#

and I am also interested in a video

#

but how come you don't see job activity in the profiler? thats odd

#

I see it, my problem was actually why the systems still also took that much time in the main thread

minor sapphire
#

Oh I do I guess I'm just not yet understanding where the work is

junior fjord
#

allthough the update method did nearly nothing besides crating the jobs

minor sapphire
#

yes I have a lot of main thread action

junior fjord
#

do you use the buffers a lot?

minor sapphire
#

dynamic buffers? native collections?

junior fjord
#

no I meant the command buffers

minor sapphire
#

oh right

#

I do a fair bit yes

#

every time a ship is destroyed or created, I'm using the buffers

#

plus a couple of other things

junior fjord
#

for component adding/removing you could also try to just add the components with some default values beforehand

#

thats a thing I changed at some point which gave me the opportunity to burst compile more systems

#

anyone here doing ludum dare?

minor sapphire
#

ok I got a 20ish mb recording lol

#

hmm

#

where to upload...

#

here we go

#

really wanna figure out what the bottlenecks are

junior fjord
#

looks cool, congrats πŸ˜ƒ

#

yeah thats what the profiler is for I guess πŸ˜„

minor sapphire
#

heh, it's 1 week of ECS learning

#

gotta get used to reading profiler timeline with jobs

minor sluice
#

is this with the new ecs unity physics?
really nice demo

#

might be the time to whip out my old bullet hell project again

minor sapphire
#

yes that's the new physics

#

everything has a sphere collider on it as triggers

#

in my trigger system I query all the collisions generate from untiy physics and look for anything with the 'HandleTrigger' component, and attach some trigger event into to a Dynamic Buffer along with a 'TriggerInfoTag' so systems can query for that and know they have some stuff to handle

#

the 2D colliders aren't available yet so that's all with sphere colliders

#

due to a bug where kinematic colliders cannot raise collision/trigger events with other kinematic colliders, I made all bullets dynamic but adjusted properties so they would act as kinematic

#

on the forums it was confirmed as a bug

#

with everything as kinematic, not needing to run any physics forces code, I wonder how much cheaper it will be

tawdry tree
#

Yeesh, that's kind of a critical bug since the whole point of kinematic is to NOT have that physics cost...

minor sapphire
#

lol yes

tawdry tree
#

Also, the thingy (can't really call it a game) looks pretty cool, do you have controls for how many ships it will spawn or how fast, or are those compile-time?

minor sapphire
#

that's on my to-do list πŸ˜ƒ

#

at the moment it's controlled in the ConvertToEntity monobehaviours

#

spawners, max ships per spawner, spawn rate, bullet fire rate, bullet life time...

#

I even have a blue team lol

#

disabled currently

#

can add more spawners with other models and stuff

minor sluice
#

didn't expect the performance to be that good,
also, is it true that the unity physics don't rely on state? (from prev frames etc?)

I am waiting for the 2d physics too, but I would only need 2 shapes: circle and line,
so that would be 3 resolvers, however, do you think it is easy/possible to whip those 2d solvers up and integrate it?

I think I will just wait for them to integrate it since they will eventually do so

minor sapphire
#

but I'm using physics layers right now to get around lack of physics filtering editor controls that will come later

#

if you rely on their collision detection... it's slightly annoying right now

#

you have to go and get their collisions collection which gives you pairs of colliding colliders

#

then get the entities for those

#

and decide what to do with them

minor sluice
#

I think this would just be the ecs way, one system puts out the collision pairs and you decide what to do with them? doesn't sound bad, but hopefully it is a bit more convenient in the future?

tawdry tree
#

Doesn't the new physics package already support/use ECS?
Physics is, as it turns out, complicated, and consists of a rough pass ('which objects are in the general vicinity of each other'), a fine pass ('Which objects actually collide') and finally applying all the forces. The package does all of that, and I suspect that whether it uses/supports ECS or not, you're not going to make anything more performant before it does, at least not outside the simplest possible implementation (no force, just 'are these boxes overlapping')

minor sapphire
#

when those burst jobs are complete (the physics system) you are left with a collection of colliding pairs

#

then you use it. So my system loops through the pairs to create a dictionary of <entity, List<collision info>>

#

then adds collision info to entities that are tagged with a 'trigger handler' component

#

then other system can notice that there is a trigger/collision event

#

and use the data

#

I use a dynamic buffer to list the collision events

#

cause an entity can participate in more than one collision in a frame

safe lintel
#

has anyone successfully compiled a uwp project with the latest burst+entities?

#

in fact is there any concrete info on what platforms dots can be built to currently? I dont know if I am wasting my time with uwp nor do I want to waste time trying other platforms if its currently unsupported

tawdry tree
#

It's just normal code with a particular framework backing it, I'm pretty sure it should work everywhere the Unity runtime usually works. Haven't heard anything about that not being the case, and it seems like a caveat they'd mention.
Either way, super easy to test, just load up a sample project and build UWP and see if it runs.

safe lintel
#

was getting a burst compiler error when building, ugh building for uwp is just my nightmare for some reason

#

yep, empty project with burst builds, when I add all the other dots packages, errors out

#

bleh

dull copper
#

is UWP officially supported for Burst?

safe lintel
#

hmm The UWP build will always compile all four targets (X86, X64, ARMv7 and ARMv8)

#

maybe im lacking the armv7 and v8 stuff for building.. but thats strange

stark cloak
#

Hey! This may seem rather trivial, but if you're looking for a raycast from the Camera.ScreenPointToRay() to work with the new physics colliders, here is the stripped down version from one of the examples provided on github: ```//Standard Unity Engine Ray
UnityEngine.Ray unityEngineRay = Camera.main.ScreenPointToRay(Input.mousePosition);

    //Converted Unity Physics Ray
    float rayDistance = 100f; //move this eventually
    Unity.Physics.Ray ray = new Unity.Physics.Ray(unityEngineRay.origin, unityEngineRay.direction * rayDistance);
    RaycastInput raycastInput = new RaycastInput() { Ray = ray, Filter = CollisionFilter.Default };
    float3 mousePosition = float3.zero;
    if (m_physicsWorld.PhysicsWorld.CollisionWorld.CastRay(raycastInput, out Unity.Physics.RaycastHit hit))
        mousePosition = hit.Position;```
final fox
tawdry tree
final fox
#

Thank you ^^ "Nice and vague" ^^

real oriole
#

Hi guys, what is currently the best practice way to draw and animate 2D sprites with the ECS system?

cunning perch
#

no best practice at the moment i believe since 2d hasn't been touched? There was a repo where you can draw sprites somewhere with ECS somewhere i think

minor sluice
#

usually what I have seen done is that you use mesh renderers with a quad and use the sprites as texture

#

you can batch them up and pass materialpropertyblocks if you have a lot of the same sprites, that should slightly differ in some attributes, like color tint

real oriole
#

Right, so just ignore the 2D renderer and use the 3D one on a plane. Will also have to figure out a way to animate them

cunning perch
#

yeah i think that was it

real oriole
#

Alright I will give that a shot.

real oriole
#

Is it actually even worth trying to do it at the moment if you are not rendering 10k+ sprites on screen?

tawdry tree
#

I wouldn't know, but ref. the earlier question, the simplest way to do 2D is to make quads with the sprite as a texture. Without looking at the above repo, I suspect that's what it does (though with a bunch of magic for perf)

real oriole
#

yes it is doing something like that, but using a bunch of unsafe stuff though, and deprecated/obsolete functionality

#

I think for the moment I will just use a hybrid approach and hopefully by the time I am running into performance issues there will be natively supported solutions

minor sluice
#

10k sprites went okay last time I tested

#

not sure when they will provide native sprite rendering with jobs?

#

the issue is that the posted repository does the stuff in the main thread I think, so it is not jobified

real oriole
#

correct, although I think you should be able to

near gulch
#

hey guys, where can i find the megacity repo?

#

and how are you guys bootstrapping? do you have a bootstrap script?

near gulch
#

@stark cloak thanks

analog tangle
near gulch
#

yeah i thought there was a public repo

quick stream
#

what would cause a gameobject (image) that is masked to not show up until i make it inactive then active again?

#

actually I think it might have something to do with this Shape2D plugin

near gulch
#

@quick stream not sure. OnEnable / OnDisable are called when that happens. Maybe those methods are modifying the mask.

#

I haven't used ECS in a while, do we still need a Bootstrap script?

quick stream
#

good point, I'll check

#

hmm doesn't seem to be the case

#

ok so if I put a breakpoint on the mask-related code in the shape plugin... it works

#

so there's some weird async stuff going on

safe lintel
#

@final fox the dots roadmap talk mentions late this year for animation preview package(but its still vague)

quick stream
#

it actually doesn't appear to be directly related to the plugin, weird

near gulch
#

try isolating as much of your code as possible (commenting out) and locate the root cause. @quick stream

quick stream
#

Problem is I'm using an engine

#

and it may be related to that

near gulch
#

native rendering ?

quick stream
#

is that an engine? if so, no

near gulch
#

what do you mean "an engine". You mean Unity right?

quick stream
#

I mean a plugin that's very large and functions as the foundation of my game

near gulch
#

or do you have use interops to access external plugins

#

ok

quick stream
#

seems to be something related to rendering, if the game loads when it's in the background, it's fine

#

only happens when i have it open

near gulch
#

you can attach a debugger to the plugins if you have their debugging informations

quick stream
#

i don't even know if it has anything to do with the plugin

#

only thing the plugin is doing with these objects is changing their visibility, sometimes alpha

near gulch
#

try disabling everything except the object that's getting masked - including non-related code

quick stream
#

works fine when there's no unity mask component

near gulch
#

you can also use a frame debugger

#

that will show you all the draw calls for the frame

#

there's also a renderman extension for unity

quick stream
#

Is this in VS?

near gulch
#

it's built in to Unity

quick stream
#

huh

near gulch
#

renderman you can download

quick stream
#

i always use the VS debugger

#

it's quite buggy

near gulch
#

Unity->Window->Analysis-> frame debugger

quick stream
#

neat

near gulch
#

if you need to go more low level

#

there's a plugin called RenderMan

quick stream
#

ok

#

no

near gulch
#

it will give you full profiling information

quick stream
#

this is more than neat

#

i had no idea this existed, it's so useful

#

you can backtrack

near gulch
#

yeah

#

πŸ˜„

quick stream
#

unfortunately it doesn't help when the thing isn't being rendered

#

oh!

#

it is being rendered

#

maybe this will work

#

ok, there is literally no difference between the properties of when it's visible, and when it's not

#

actually, one number is different, and it explains the issue

#

thank you so much for telling me about this tool

near gulch
#

np, glad it helped

quick stream
#

i wish VS debugger wasn't so buggy

#

it freezes and i have to crash unity

#

for something that messes up this much there really should be a panic button

#

(it just froze again just from trying to inspect a material object)

#

So it seems I still have an issue

#

the problem was that I'm changing a material shader property through code but this isn't causing the actual material to update

near gulch
quick stream
#

Alright, thanks

near gulch
#

how are oyu guys architecting your player and input class with ECS?

#

hybrid approach?

safe lintel
#

not really sure how it cant be hybrid

#

but personally got a player input system just feeding input on the main thread into a player input component

near gulch
#

yeah i agree, thanks

safe lintel
#
A new release of Tiny Editing tools built on top of Unity.Entities is coming soon. " ```
oo exciting
dull copper
#

considering the three year plan, I seriously hope the new ECS editor will use it's own scene view

#

and not reuse the gameobject world's scene view

#

if they allow both at once, you can still do hybrid and have editor for both

#

I asked about this from Joachim ~6 months ago and he said there's no plan for such approach

#

but I hope they reconsider

#

having only pure ECS editor or only gameobject scene editor is serious limitation

#

I feed that they've hardcoded scene view so badly that they don't want to consider such thing

#

but if they did work to decouple the scene view, it would also allow them to do things like prefab editing in a separate window while still keeping the main scene showing the active scene

#

probably biggest questionmark on such approach is how to deal with hierarchy panel and inspector, as you can freely place those on main layout now and they'd have to be duplicated for each additional view

dull copper
#

I proposed a solution for that on the forums (put a toggle to swap between DOTS and Gameobject editors on the fly)

#

I don't expect them to do that but it would solve so many issues

minor sapphire
#

just really hope audio isn't too far off in the horizon

dull copper
#

For these particular types and operations, we’re saving about 8-17% of the CPU time by switching to Unity.Mathematics.

#

most here probably use the new math lib by default already, still nice to soo someone trying to benchmark the difference

#

by here, I mean people who use Burst in jobs

final fox
#

@safe lintel That's nice ! That's enough for me πŸ˜ƒ Thank you !

stoic monolith
#

Is it normal to get null refs when seeing GameobjectEntity in inspector?
at UnsafeUtilityPatched.cs:15
I'm super new, trying hybrid..

minor sapphire
#

I think you may get null refs when a selected entity is destroyed?

stoic monolith
#

This is really just from the sample package.
They're editor window calls though, and seems harmless but spams all the time i click something else in inspector

minor sapphire
#

oh yes I get some of that kind of stuff too

winter veldt
#

what are the use practices of Mathematics.Random? I've tried to create a single Random object that i can send to all jobs.. but when i use it, i get random values.. but those values are always the same for each job

#

am i meant to instantiate a new random inside each job? i was under the impression (from other random classes) that the best way to get good random results is to use a single instance across all elements

foggy chasm
#

iirc this was a topic last week in this chat - and the consensus best practice seemed to be to have a random in each job, whose initial seed is determined by a global random

dull copper