#archived-dots

1 messages Β· Page 138 of 1

coarse turtle
#

Yea i'd do that too

#

You can write some extensions to make it slightly easier if you're constantly using a DynamicBuffer for some type

loud matrix
#

Never seen much on shared statics, I'll see if i can dig up more on them than what i can see in the burst docs

opaque ledge
#

Its.... AWESOME

#

its perfect for global datas

#

you just have to figure out the way to construct it, but its basically copy paste from the manual

loud matrix
#

I was gonna say, the docs just setup an abstract and ignore the construction part of it

opaque ledge
#

thats basically it, you just copy it and change "int" part to whatever you like, and you just create another class as your keys and thats it

loud matrix
#

I assume one class can have multiple shared static parameters?

#

provided they each have a unique key

formal scaffold
#

I can pass a normal Array to a Job? Or does it have to be a NativeArray?

opaque ledge
#

yep

#

@loud matrix

#

it has to be Native Array, normal array is a class so its managed

safe lintel
#

@formal scaffold not sure if you know of them but there are fixedlists that can be used inside components

formal scaffold
#

@safe lintel No I don't are they documented in the ECS Documentation?

safe lintel
#

yes

opaque ledge
#

not in manual tho i think

formal scaffold
#

Okay thanks I'll check them out

opaque ledge
#

you have to check collection's scripting api section

safe lintel
loud matrix
#

is it me or is there very little info on NativeHashMaps? I can find the docs, and many many posts of people just pointing at the docs saying NativeHashMap is the solution, but nothing much else.

coarse turtle
#

what do you need to know about it?

loud matrix
#

Don't really know what i want to know about it, just trying to learn more about what it is and it's use, The docs don't contain a definition for the thing, so I'm having to guess as to its usage from the functions currently.

amber flicker
#

Googling HashMap will tell you more about the structure in general but it really is quite simple

#

Like a dictionary - NativeHashMap can store one value per key, NativeMultiHashMap can store multiple values per key

#

You can write to them in parallel if you want/need to and you mostly use it via TryAdd and TryGet I believe

#

You would need to use Allocate.Persistent and also dispose of it appropriately

loud matrix
#

Ahh thanks, Now to work out where and how to dump this into a static i can access

#

From the looks of it I'm probaby better off ditching my blobAssets and storing my data as a NativeHashMap inside a shared static

amber flicker
#

As you already have it, personally I would say fill a nativehashmap full of blob asset references

#

static public NativeHashMap<int, BlobAssetReference> AllBlobs = new NativeHashMap<int, BlobAssetReference>(Allocate.Persistent); or something

loud matrix
#

I was thinking of it being more useful to have things string Id based rather than int based in the BlobArray

amber flicker
#

sure - however you want to handle keys

#

you can start with strings and change later potentially

loud matrix
#

Ahh right, i see why this was suggested to me now, with the reference to the hashmap i can just add stuff into the static reference, well that does solve my current issue quite well

amber flicker
#

ass stuff πŸ˜‚

loud matrix
#

Now if only i could remember why i was using blobassets in the first place, could swear i had some other reason for it.

amber flicker
#

yea it's good - the hashmap ensures it's full of unique keys and when you get the asset reference, it's giving you a reference to your blob - so you shouldn't have any duplication of data and it'll all be quick

#

at least.. this is pretty theoretical - don't want to state that this is the optimum solution for you but from what you've described it's how I'd tackle it

loud matrix
#

It sounds like a better solution than I've managed to find so far

#

I'll have a play, see what i come up with, and then what new fun random stoping block comes up

#

last one was me discovering the debug.log is a nono in jobs, god knows how i never saw that anywhere

coarse turtle
#

hmm I thought that worked πŸ˜…

fallow mason
#

without burst and run, sure

amber flicker
#

yea, not in jobs

#

er multithreaded

coarse turtle
#

o - it's been a while since I used debug.log in a job

loud matrix
#

I've likely had multiple solutions that worked perfectly over the weeks, so now my mental knowledge of what actually works is kind of screwed up.

amber flicker
#

I think you're close πŸ‘

#

good luck

loud matrix
#

My last real issue was having a static reference to the blob assets, so even with a shared static i can make something work πŸ™‚ thanks again for the help

#

Who knows, maybe I'll be able to stat making the game part of the game soon UnityChanExcited

opaque ledge
#

baby steps^^

#

it will be very hard to learn stuff if you try to convert your existing monobehaviour workflow to ECS without actually knowing what ECS is all about and how their workflow works

loud matrix
#

My Mono workflow is have a bootstrap and ignore everything thats not pure ECS so, not hard. Everything In my project is currently just test code mostly, only thing I actually did fully is player control

#

I tend to not start fleshing out a system until I have done some testing on it to know I'm not going to have to rip it all out. Or else I'd have a lot of ScriptbleObjects and be reallllly pissy if I had to scrap them.

mint iron
#

ugh, still no fix for ArgumentException: A component with type:BoneIndexOffset has not been added to the entity. 😞

safe lintel
#

are you looking to add animation or just disable that message?

#

someone else' solution World.GetOrCreateSystem<CopySkinnedEntityDataToRenderEntity>().Enabled = false;

#

mine was to remove the other skinned component from the entity on conversion so it didnt trigger

fringe sinew
#

This may not be about ECS per se, but it is related. It's the question about Unity's serialization.

Let's say that I have an authoring component or such, the struct field is serialized and default-created via a constructor.

Let's say that I want to add one more property to that struct. Say, a float. I also update my constructor, now my authoring component passes 1f to it.

What will happen in this case with Unity's serialization: will the authoring component's struct float property be 0f or 1f provided that the component is already serialized and not created just now or from scratch?

loud matrix
#

Well it works, but ... I've created a monster!

#

StaticDatabase.Items.Data.Value.data[cargoBuffer[i].index].name

#

Reference ception

safe lintel
#

@mint iron are you trying to use joachim's vertex anim repo?

mint iron
#

no i just have a character with skinned mesh renderer in a subscene as a placeholder and the exception was annoying.

safe lintel
#

ah

#

i think you could just add in the anim package as well, if you arent animating it should just convert the model properly

mint iron
#

having trouble just getting something to render at all with the new hybrid 0.50

#

feel like im taking crazy pills

#

mmmk, helps if i read the documentation

storm ravine
#

What problems?

loud matrix
#

Oi, not reading the docs, getting your head in a tizzy and getting stressed out is my job @mint iron

mint iron
#

πŸ˜› i didn't have ENABLE_HYBRID_RENDERER_V2 define, and they changed the package manager to apparently not automatically list preview packages as upgrades, so there was a newer version of URP i didnt see.

storm ravine
#

πŸ™‚

safe lintel
#

do you ever envision switching to one fo the srps for the lifetime of your game eizenhorn?

storm ravine
#

Yes, I not only digging DOTS but SRP's also, because graphic programming is my second favourite thing, but we decided not switch to them at current state πŸ™‚ But I always have couple test projects with latest HDRP and URP πŸ™‚

safe lintel
#

was curious given that you are kinda living on the edge using dots in production, srp + dots currently kinda feels like tiptoeing on the edge

storm ravine
#
  • Addressables (using them actively) and UI Elements (which currently in frozen state in our project) πŸ˜„
#

We just haven't enough time for making workaround replacements for our shaders. But some day... πŸ™‚

opaque ledge
#

You cant still use Addressables inside ForEach(Run) right ?

storm ravine
#

Without burst and with Run they should

opaque ledge
#

i remember someone mentioning that Addressables was doing "invalid IL code" even it was used with WithoutBurst Run

storm ravine
#

We not use AssetReference in systems directly, thus can't tell you more, we use them for load things at application start asynchronous and converting all stuff to blobs, entity prefabs etc. and then we just use this regular things.

#

We not using them in a middle of game, because just don't need that πŸ™‚

opaque ledge
#

how do you handle hybrid components that need assets ? if you have that kind of hybrid components

storm ravine
#

Many parts of our game procedurally generated, and all other things doesn't take much memory. full build takes just ~100mb πŸ™‚

#

how do you handle hybrid components that need assets ? if you have that kind of hybrid components
@opaque ledge which one (just example for understand your question)

opaque ledge
#

lets say you have an unit on map and you want to have an health bar above the unit's head, assuming you are going to use Quad for it, that means you need a material asset to show to healthbar, or lets say unit is invincible and now you are going to make that healthbar yellow to indicate that unit is invincible etc..

storm ravine
#

Well health bars I draw through post processing πŸ™‚

#

But I see what you mean

opaque ledge
#

i am doing all these from MB side, i just call the function from ForEach but MB side takes cares of the addressables and stuff

storm ravine
#

And this things same - I converted every thing at start

opaque ledge
#

await doesnt work in ForEach for example

storm ravine
#

and have singleton entities with maps of things

opaque ledge
#

yeah i understand that

storm ravine
#

also I wrote custom guid system

#

which not relates on unity serialization mechanism

#

and every thing have unique persistent ID

#

Which we using in all places

opaque ledge
#

but i thought that was a bad practice since you are holding assets that you are not using inside memory, this is why Resources folder isnt used anymore

storm ravine
#

for get mesh\entity prefab\ etc

#

Bad practice if you have many things

#

we have small assets database

opaque ledge
#

was your game for mobile ?

storm ravine
#

No

#

I posted above

opaque ledge
#

ah, well it doesnt really matter then but yeah its still good practice

#

yeah

storm ravine
#

I know good practices

#

And when we can sacrifice them πŸ™‚

opaque ledge
#

fair πŸ™‚

storm ravine
#

With this approach we also serializing\deserializing whole worlds to files as game saves, fully save game state, even animation frame, and when loading your swordsman will hit enemy right from millisecond when you saved that πŸ™‚

#

We have couple of pre-serealization\post-deserialization systems

opaque ledge
#

just like Skyrim πŸ˜„

#

one of the best thing about ECS is serialization, everything is data so you dont need to do anything special πŸ˜„

#

how are you doing animations ?

#

from MB ?

storm ravine
#

Which moves things to different worlds, replace blobs and reference things to regular components with this unique ID, thus on serialization we don't serialize blobs and reference types, and store only easy serializable things

#

And on deserialization we process deserialized entities and remap from ID to blobs, animation meshes etc.

#

Thus when we release patch or dlc with changed parameters\meshes etc. even saved games correctly will handle that changes and will use them without problems

#

how are you doing animations ?
@opaque ledge custom rendering system with custom shader for animation. And animations baked in to textures. I also described all that yesterday πŸ™‚

opaque ledge
#

ah okay, thats one level up above me πŸ˜›

coarse turtle
#

I'm genuinely impressed since the first time I read your forum post about using it in production @storm ravine πŸ™‚

sand prawn
#

Updated a couple of packages this morning trying to get Linux build working, but running into something that seems like it SHOULD be unrelated to package updates:

Library\PackageCache\com.unity.netcode@0.1.0-preview.6\Runtime\ClientServerWorld\ClientSimulationSystemGroup.cs(148,56): error CS0103: The name 'm_systemsToUpdate' does not exist in the current context

Looks like this code SHOULD be using m_systemsInGroup, how did it ever compile?

#

Is there a new NetCode being released soon? Anyone know?

opaque ledge
#

ah, there was a forum post about this

#

basically wait for new net package i suppose

sand prawn
#

@opaque ledge Oh, awesome. Thanks

#

Hum. Not super helpful in itself, though, is it?

#

Wonder if there's a temp. hackaround

storm ravine
#

Yep they moved many systems fields from protected to internal in latest release

sand prawn
#

A bit frustrating that they're not following their usual path and deprecating these until their own libs catch up

#

This SortSystemUpdateList() looks like a horrific hack anyway

opaque ledge
#

@low tangle Heya, sorry to ping, there was a snippet for creating SystemBase inherited class, was that you who made/linked that ?

#

If so, can you put it again πŸ˜…

low tangle
#

yep

#

documents/visual studio 2019/snippets/visual c#/my code snippets/

safe lintel
#

do you need to dispose a NativeMultiHashMap when clearing it?

north bay
low tangle
#

clear marks the memory inside it as empty, it does not release the memory

opaque ledge
#

Thank you^^

safe lintel
#

i know but it shouldnt be triggering a dispose error when just clearing right?

low tangle
#

no it should not

sand prawn
#

@north bay Thanks!

#

@north bay Essentially s/m_systemsToUpdate/base.Systems ?

north bay
#

Yea, and writing back to systemsToUpdate through reflection

sand prawn
#

oh, man. ugh

#

ok

safe lintel
#

oh was allocating a command buffer, was not the hashmap at all πŸ˜‰

sand prawn
#

@north bay Thanks, that gets me some progress. I feel icky, though. Gonna go shower

north bay
#

It is. See it positive now Unity is forced to give us a new Netcode package πŸ™‚

sand prawn
#

hah yeah

#

Hopefully soon

dull copper
#

oh neato, new packages (been off computer for a while)

mint iron
#

earlier today we were all like, why didn't we know about this?!?!!

dull copper
#

lol

#

well, ECS samples are still 2 months old

#

kinda weird that they dont push them since they keep them up-to-date internally....

#

@mint iron well now you know I haven't written a bot for that...

#

..which I totally should have

coarse turtle
#

wondering when the next 2d entities will drop πŸ€”

dull copper
#

oh, new entities now finally use that 0.3 platforms

#

since hybrid is updated, that hdrp lighting issue should now be resolved

#

and according to the forums they are working on the ambient probe fix

#

also, netcode package hasn't been updated and its not compatible with this latest update batch πŸ˜„

#

nothing new there though

mint iron
#

they're doing something interesting with ArchetypeChunk, it can now have sub-chunk slices / EntityBatches (defined within the ArchetypeChunk)

dull copper
#

/ spam

storm ravine
#

@dull copper you're a bit late πŸ˜„

dull copper
#

I know πŸ˜„

storm ravine
#

changelogs already was in chat above πŸ™‚

dull copper
#

they were?

#

I tried to search for them

dull copper
#

heh

#

well that was a wasted effort then πŸ˜„

#

hmmm

#

since the platforms update was gone through, it means this is live now as well:```Build pipeline major overhaul: build pipelines are no longer asset based, and instead must be implemented in code by deriving from BuildPipelineBase class. Build steps are no longer mandatory but can still be used by deriving from BuildStepBase.

#

what do they refer to with the build pipeline assets? πŸ€”

#

I initially thought they were going to get rid of the build configuration assets but thats something different (or at least the old build conf assets still seem to work)

#

I did have to install platforms.windows package

#

in past you could just use platform alone

coarse turtle
#

oh I thought the build pipeline assets were the build configuration assets too

tardy locust
#

Huh.

fallow mason
#

Does latest platforms package finally work with latest entities?

dull copper
#

yes

#

it depends on 0.3 now

#

like mentioned above, I had to install platforms.windows manually for the building to work from build conf asset

fallow mason
#

Cool. That was the last package I couldn't get to the latest version without errors. The completionist part of my brain will be happy to have checkmarks on all my packages :)

dull copper
#

try to install netcode package now πŸ˜…

fallow mason
#

Nooooo don't tell me that! I just added it last week!

dull copper
#

In this session Unity evangelist Mike Geig chats with Peter Andreasen and Martin KΓΌmmel from our internal production team. You might know them as the authors of projects like FPS Sample, Megacity or DOTS Sample. Their focus is on ensuring our solutions and features are working together in production environments. They'll discuss what we've learned from their previous projects, and what the team is working on now.

storm ravine
#

Yep unfortunately it was short session πŸ™‚

wide fiber
#

To dispose a NativeMultiHashMap in a scheduleParallel Foreach (SystemBase) I can't use WithDeallocateOnJobCompletition()...

Should I dispose it at the end of OnUpdate()?

#

It says NativeMultiHashMap<int, float3> is an unsupported type for WithDeallocateOnJobCompletition

#

NativeMultiHashMap don't even support parallel writing..

bright sentinel
#

You should indeed Dispose it at the end of OnUpdate, or at least after your job is complete

#

You can even pass the dependency to the dispose method to do it after the job is completed

wide fiber
#

Ok

bright sentinel
#

Also, there's this: AsParallelWriter()

#

@wide fiber So you can use that to support parallel writing

wide fiber
#

πŸ‘

wide fiber
bright sentinel
#

Do you really get the same error when you use the ParallelWriter?

#

Show me a version where you use the ParallelWriter and it gives you the error

wide fiber
#

Ok

bright sentinel
#

I think you forgot the code πŸ˜…

bright sentinel
#

Well, you're still using the non-parallel one in your parallel job

wide fiber
#

The second Foreach?

bright sentinel
#

Yeah

#

But I also see that you're only reading from it

#

So you don't need a parallel writer in this instance

wide fiber
#

Yeah

bright sentinel
#

You just need to mark it with ReadOnly

#

In the ForEach

#

Entities.WithReadOnly(targetsQuadrant).ForEach(...).ScheduleParallel()

wide fiber
#

Ok

bright sentinel
#

And then don't use the parallel writer anywhere

#

As your first foreach is a .Run

#

Which you can turn into a parallel one with a parallelwriter though

wide fiber
#

πŸ‘

bright sentinel
#

But one problem at a time πŸ˜„

#

Also, you should pass the dependency to the Dispose method of the native container, as it will be disposed before the jobs of the ScheduleParallel will get a chance to run

wide fiber
#

So I should put targetsQuadrant.Dispose(Dependency)?

bright sentinel
#

Yep

scarlet inlet
#

@scarlet inlet about ForEach and different attributes, all attributes from job will work with Entities.ForEach it you create custom struct like you does that before for IJobForEach, (but without IJobForEach obviously) and use that struct inside ForEach. like that:
@storm ravine oh interesting thanks. I will keep that in mind, although it's less convenient

storm ravine
#

Depends. For big ForEach it's convinient, because code will be much cleaner and much more readable

#

In comparison with all this .WithReadOnly, WitnNativeXXX .WithoutXXX etc. πŸ™‚

#

And if systems use regular jobs code will be in similar fashion πŸ™‚

#

But for 1-2 line ForEach is yeah a bit boilerplate πŸ™‚

#

In my codebase I use that as described - for big ForEach - wrapped struct

#

For small - inline

#

Anyway it's up to you, I just gave you info about attributes πŸ™‚

scarlet inlet
#

interesting point of view yours

amber flicker
#

damn I think they might have broken a safety system thing when mixing JCS with SystemBases 😦 (edit: rolling back entities doesn't fix it, leaving me very confused)

bold pebble
#

Is it possible to use dots in combination with IL2CPP? I am asking because I wonder if I could use DOTS on the HoloLens2 which seems to only support Unity builds via IL2CPP.

lusty otter
#

Not sure about that device specifically but IL2CPP itself is fine.

#

Is there a reverse of NativeArrayUnsafeUtility.GetUnsafeBufferPointerWithoutChecks?

bright sentinel
#

@bold pebble Yes, DOTS supports IL2CPP

storm ravine
#

@amber flicker System1 IJobChunk out of dependency chain, expected error.

#

Internal BeforeUpdate completes only jobs in dependency chain

#

Ah

#

Run

#

missed that

#

1 sec

amber flicker
#

thanks πŸ‘

#

can be paired down to without the UpdateInGroup stuff

storm ravine
#

Well Run should work

#

and work in my case

amber flicker
#

with the JCS version you don't get an error in editor when hitting play?

storm ravine
#

Yes

#

It should work

amber flicker
#

I've tried with multiple editor versions, multiple package versions and in a clean project

storm ravine
#

because it not scheduling any thing

#

and Run right here

#

Ah

#

Yep

#

As I tol above

#

dependency chain

#

previous system (Sys2) use same type - Rotation

#

And you try to write to rotation

#

in ArchetypeChunkComponentType

amber flicker
#

Both versions of System1 write to Rotation

storm ravine
#

yes

#

but problem is System 2 read

#

And you write when it read

#

Race condition

#

which safety check tell you

amber flicker
#

yes.. but if you comment in the SystemBase version of System1, it works fine

storm ravine
#

Yes it work

#

because it handle dependency

#

automatically

warped trail
#

may i ask why are you using JobHandle.CombineDependencies?

amber flicker
#

because this is a simplified version of code with multiple jobs

storm ravine
#

And in system 2 you don't need manually handle dependency it will handle that in System2 automatically

amber flicker
#

so how could I modify the JCS to include the dependency? Other than by doing what I've already done (via the query and the lack of [ReadOnly])

#

the SystemBase version compiles down to a version of JCS right?

storm ravine
#

Well, similar, it compiles with better codegen, but idea of dependency chain - same

amber flicker
#

So... are you suggesting that System2 is actually auto codegen including a reference to System1's job when System1 is a SystemBase? Surely not

storm ravine
#

It not link on any thing

#

Read source code

#

it's dependency chain

amber flicker
#

that's cool... I guess I'm asking how I can add Rotation to the dependency chain in the case of a JCS

storm ravine
#

Problem is completing dependency chain

#

It's already here (Rotation in chain)

#

if you put complete on inputDeps in JCS you'll see that job which read will complete

amber flicker
#

hmm thank you.. I see. Does that mean every SystemBase is calling .Complete() on inputDeps?

storm ravine
#

Or replace to Schedule

warped trail
#

your code works fine in my projectπŸ€”

amber flicker
#

@warped trail which editor/entities version?

storm ravine
#

@warped trail put both systems

warped trail
#

9.1 and latest alfa

amber flicker
#

you need at least one version of System1 commented in as well as System2

warped trail
amber flicker
#

hmm interesting.. I'm on latest beta.. might try latest alpha

storm ravine
#

@amber flicker for fix that fot JCS put Complete on inputDeps or use Schedule instead for IJobChunk whih inputDeps

warped trail
#

jobsdebuger on and full leakdetection

storm ravine
#

It not depends on latest alpha

#

System runs?

#

in EntityDebugger

amber flicker
#

yup thanks @storm ravine understood that now.. just a bit confused how SystemBase is automatically handling that - I may try and look through source

warped trail
#

oh, it works when you have something with rotation in scene and error with empty sceneπŸ˜…

storm ravine
#

Yes

#

because otherwise system just not run

#

It's absolutely expected (behaviour and error both)

#

And recommend you drop JCS

amber flicker
#

the thing I can't understand is how this has only just become a problem for me.. 🀷 .. oh well

#

I'd love to drop the JCS but unfortunately it's a beast, very much in the hot path and very hard to replace without chunk api

storm ravine
#

Why?

#

It's very easy to change

#

you change only system itself

#

there is nothing super different between them (exclude that SB better)

#

Super fast replacement (even just by replace in file) JCS -> SB and inputDeps->Dependency

#

And just remove OnUpdate argument and return value

#

You still use same jobs (exclude IJobForEach)

amber flicker
#

sure, that part is easy.. the issue is at the moment there's a lot of conditional logic that chunk.HasComponent works very well for - not having to pay the cost of CDFE hascomponent

storm ravine
#

And how it relates?

#

You still use same jobs πŸ™‚

warped trail
#

you can use IJobChunk in systembase πŸ€”

storm ravine
#

No one force you replace IJobChunk to ForEach

#

Moreover ForEach compiles exactly in to IJobChunk under hood

amber flicker
#

oh sorry, I misunderstood that you could have IJobChunk with SystemBase for some reason

storm ravine
#

No

#

nothing changed except OnUpdate signature and replacement inputDeps to Dependency (from system looks point of view, not count codegen)

#

You still use absolutely the same jobs (except IJobForEach which deprecated and Entities.ForEach it's replacement for that job type)

amber flicker
#

yup, that makes sense... thanks.. in my head SystemBase is tightly coupled with moving things over to lambdas but of course, that's not what you were suggesting πŸ‘

tardy locust
#

Does turning a method into a lambda call optimise anything? Or is it syntactic sugar?

lusty otter
#

Once I get the pointer of a NativeArray using UnsafeUtility, how do I access the NativeArray with the pointer?

#

And how do I dispose of the NativeArray once I'm done with it?

storm ravine
#

GetUnsafePointer GetUnsafePointerReadOnly ? Ahh missread...morning

#

Well call Dispose πŸ™‚

#

Well you have pointer, you want get element

#

from pointer

#

Yes?

lusty otter
#

Yes, ideally I want to turn that pointer back into NativeArray so I can still use the methods and what not.

#

I don't have access to the original NativeArray that I get the pointer from, only the pointer now.

warped trail
#

dereference it to native array?πŸ€”

#

or it does not work this way? πŸ˜…

storm ravine
#

var ptr = arr.GetUnsafePtr();
UnsafeUtility.WriteArrayElement(ptr, 0, 5);
UnsafeUtility.WriteArrayElement(ptr, 1, 4);
UnsafeUtility.WriteArrayElement(ptr, 2, 3);
UnsafeUtility.WriteArrayElement(ptr, 3, 2);
UnsafeUtility.WriteArrayElement(ptr, 4, 1);
        
Debug.Log(UnsafeUtility.ReadArrayElement<int>(ptr, 1)); //Will be 4``` Simplified version with UnsafeUtility for example
lusty otter
#

Yeah but that means I need to change everything that uses it

storm ravine
#

Read\Write by ptr, but don't forget about safety, you always should know length of your array for exclude writing out of this array memory bounds

#

What do you mean

lusty otter
#

Like my function accepts a NativeArray, but now I need to write an overload that accepts a pointer.

#

I want if it's possible, to just turn the pointer back into NativeArray so nothing else needs to be changed.

storm ravine
#

Well thus you should use NativeArrayUnsafeUtility.ConvertExistingDataToNativeArray

#

it will give you NativeArray which points to same memory

#
      {
        m_Buffer = dataPointer,
        m_Length = length,
        m_AllocatorLabel = allocator,
        m_MinIndex = 0,
        m_MaxIndex = length - 1
      }``` How it looks under hood, where dataPointer is your pointer
lusty otter
#

What should I put as allocator?

#

I also read that you need to use SetAtomicSafetyHandle to set things up.

storm ravine
#

Allocator 🀣 What a question

#

SetAtomicSafetyHandle Yes if you want safety system for that

#

But for that you should have initial array not as ptr and get handle from

lusty otter
#

So I just do ConvertExistingDataToNativeArray(ptr, length, Allocator.None)?

#

What about disposing, I can use it for that as well?

storm ravine
#

Why None

#

This obvious that you should use same allocator as initial array πŸ™‚

#

Because you work with pointer to memory which allocated with specific allocator

lusty otter
#

I guess I'm just confused what it's actually doing under the hood.

storm ravine
#

Under hood you just "get" your array here

#

it's still same array

#

pointer same

lusty otter
#

If the original NativeArray already have memory allocated, and I'm just trying to access the same memory with the pointer

storm ravine
#

And you work with that array like you work with original one

lusty otter
#

Then why do I need to pass it an allocator again if it's not allocating anything new?

storm ravine
#

Allocator itself it's just marker

#

which marks how allocate and deallocate memory

#

hwo your new array will know that allocator label for freeing memory if you have only pointer from original array

#

I posted image above

#

for same reason you put length too

#

because it's just helper parts of struct

lusty otter
#

Ahh okay got it.

#

So I just need to pass in the same things as when I created the NativeArray initially.

storm ravine
#

Yep, but anyway you need SetAtomicSafetyHandle because of internal checks

#

technically all work but will throw null ref error

#

because it will try to check safety here and m_Safety null

lusty otter
#

What does the safety handle stuffs do under the hood?

storm ravine
#

Prevent you from shooting in to feet

lusty otter
#

So basic stuffs like index out of range check, etc?

storm ravine
#

No

#

for that it has simple checks inside idexers\methods

#

Check if no one write when you read or read when you write

lusty otter
#

Cool.

#

So do the conversion, set the safety handler, and basically I can just use that as if it was the original?

storm ravine
#

Yes.

#

About dispose, because I can be not clear about that above

#

you should dispose only original one

lusty otter
#

Hmm

#

So I still need to keep the original NativeArray for disposing?

#

Can't I use the converted one for disposing?

storm ravine
#

Technically you will dispose and original one when you dispose new one, but because of safety handle it will complain that array not disposed, but if you'll try to dispose original one it will complain that it's already disposed πŸ™‚

#

Memory will be freed, but pointer (just number) in struct wasn't set to null

#

It can be tricky

lusty otter
#

That shouldn't cause any trouble though right

#

So it's just annoying error messages even though memory are correctly freed.

storm ravine
#

Memory yes, but it's not fine and error is trouble

lusty otter
#

😰

#

To give more context to what I'm doing, because you can't do NativeHashMap<int, NativeArray<float>>, I'm trying to use pointer in place of it.

#

And all future operations will just operate with the pointer and not the original NativeArray, which I won't have it anymore.

storm ravine
#

For that case I just wrote my struct

#

without any safety handle stuff

#

not native array, just struct which contains some utility methods and couple of pointers

#

And ofcourse couple of my own NativeContainers which also useful

#

but don't forget cover that by tests from every side

lusty otter
#

That's certainly an option but is there really no way around it?

storm ravine
#

Well you can store your original arrays somwere on system for example which only have on create on destroy

#

and dispose them on destroy properly

opaque ledge
#

btw Eizen, you mentioned you report the bugs you find to ECS team ? i reported a bug that makes editor crash when a certain system runs, but it works pretty fine in build

#

i reported it 2 weeks ago but no answer

#

how much do they take to answer for your case ?

lusty otter
#

I don't know how many original arrays will be there and that's why I need a NativeHashMap of them

storm ravine
#

I spoke with them directly

#

They will answer, it just depends on how case importat, all have priority

#

For example? i reported a bug that makes editor crash when a certain system runs,

#

I mean what you see in crash and editor log

#

And what exactly cause crash, show that system which cause crash

#

I don't know how many original arrays will be there and that's why I need a NativeHashMap of them
@lusty otter well because safety handle you should use your own struct here

#

Main point of safety prevent you from something which you can corrupt easily

opaque ledge
#

i already gave them the project, and necessary information, they only need to click 2 buttons to see πŸ˜„

#

but yeah fair, i just hope that it will be resolved soon

lusty otter
#

Welp, I guess in the end I still need to write an overload for functions that expect to work with both NativeArray and the custom struct then.

#

πŸ˜”

storm ravine
#

If you'll have your struct

#

why you need native array then? )

lusty otter
#

That means I'll have to change all my things to use my own struct.

#

It feels like we are just reinventing the wheel here

#

I know safety system is there to prevent people do dumb stuffs, but if I know what I'm doing and go so far, then I feel like there should just be a way to let us do it.

storm ravine
#

Well this is things which should be investigated on app architect stage πŸ™‚

#

Well you also can use unsafe collections here

#

but it anyway force you rewrite code to that unsafe collections

#

and this limitation about native container inside native container here from the beginning

#

This is why initial game architecture process important πŸ™‚

#

I use that case of NHM with custom struct for that region edges (magneta lines) (don't look at trees pattern and disabled fog of war πŸ˜„ it's sandbox test scene for prototyping things)

lusty otter
#

I'm basically just making my extremely simplified ECS, NativeHashMap<int, array> the int here is just an entity identifier, and the array is fixed sized.

#

My project is also really tiny and nothing complex so I decided it's better to just use Job System and do with my own instead of introducing all these preview instability.

storm ravine
#

Well it was fine for us from first versions πŸ™‚

#

With own solution it's not guarantee you stability πŸ™‚

lusty otter
#

Right, but that decision aside, I'm really just trying to solve that problem of using NativeArray inside of NativeHashMap.

storm ravine
#

unsafe collections or own struct your options πŸ™‚

lusty otter
#

Yeah that's what I'll have to do it seems.

#

Just kind of a bummer that I couldn't just use pointer of NativeArray for rest of its lifetime.

storm ravine
#

Well because it's not just pointer but bunch of additional things

#

And not intended for that usage πŸ™‚

#

Because (how you all spoke it) regular joe wouldn't use that like this πŸ™‚

vivid copper
#

Heey guys
can somebody tell me how I can pause my game with dots with GO i could do timescale = 0 but I can't find a simular thing with dots

storm ravine
#

Same

opaque ledge
#

i do that with singleton components, and make my gameplay systems require for that singleton component existence

storm ravine
#

If you can't "find" timescale inside system it's because you just should use not Time property but UnityEngine.Time

#

In our game we have own time system πŸ™‚

vivid copper
#

well I use dots physics will this work also

storm ravine
#

well they havent saparate tick yet, and anyway relates to timescale

#

And what prevent you from just put timescale = 0 by space press in any place and check if physic will stop πŸ™‚

#

it's sort of things which even not require any specific test sandbox, just one row because you already have something with physics in your game πŸ˜„

mystic mountain
#

Hey, so have a bit of structural thinking question; I have three different kind of teleporters. One that moves a entity within same "space", one that moves from normal space=>special space, and one from special space=>normal space. (the three cases are different in fetching components etc) So I'm using triggers to check if entity enters teleporter. Currently I'm using a component for "teleportable" and different kind of component for each of the teleporters. I do the logical things in the TriggerEventsJob, which each are total of 30 lines something for checking if components exist etc. Would it be better to merge the teleporters into one component, and have a ID of what type of teleporter it is? Which would mean that I could use the same trigger and send a response with the entity, do a switch on a later job with the logic? Any good ideas of how to structure these things? x)

scarlet inlet
#

@storm ravine heads up, your suggestion didn't work. Add to put WithReadOnly anyway

warped trail
#

you have to create struct outside of ForEachπŸ€”

#
var tmp = new ComputeGroundCollisionJob
{
  ...
};
Entities.ForEach((...)=>
{
  tmp.Execute(...);
})```
scarlet inlet
#

oh I see

#

can't see why is different though

#

but ok

#

that seems to work

storm ravine
#

Because of lambda scope πŸ™‚

#

Yes struct outside

#

because in this case you access this containers already inside lambda which require them being ReadOnly, etc. at this moment

lusty otter
#

What should alignment be when using unsafe malloc for an array of floats?

#

Just size of float?

storm ravine
#

Array of floats is pointer to that array in your case?

#

And note about UnsafeUtility.AlignOf<T> it's hardcoded 4 bytes for any type πŸ™‚

lusty otter
#

Yeah I'm going to make my own struct to store array of floats

#

It would just has a pointer field, a length field.

#

Malloc when creating and assign the pointer to field, and Free when I'm done with it.

storm ravine
#

Be careful with just lenght field on struct because it will copy by value you will modify data pointer properly for all structs with same pointer but length field will be own by every struct πŸ™‚

#

Just remember that

#

You can use just UsafeUtility.AlignOf<YourStruct> which will be anyway 4

lusty otter
#

That’s fine, it’s meant to be fixed sized so length should never be modified (or pointer either)

#

Thanks.

wide fiber
coarse turtle
#

You might need a concurrent structure access for the NHM

storm ravine
#

Because you using that in parallel context, you can't read and write here at the same time because of possible race conditions, which from safety check prevent you and throw error.

coarse turtle
#

πŸ€”

storm ravine
#

Not help here

#

ParallelWriter allow only write here

#

ReadOnly it's your case here

wide fiber
#

I am not writing and reading at the same time, I said UpdateAfter(QuadrantSystem)

#

Shouldn't it wait for the quadrant system?

craggy orbit
#

is there something different about dot product with DOTS? i've got 2 entities facing towards each other (0, 0, 0) vs (0, 180, 0) and the dot product for their rotations is 0. shouldn't it be -1?

UPDATE: directions work, just not quaternions

storm ravine
#

Computer don't know that you know that πŸ™‚

#

Also

#

it's pure native container

#

dependency not handle that

#

you should track dependencies manually

#

Ah you have shared type well thus you don't as side effect of tracking Translation it will solve that for you

#

You should only use WithReadOnly here

wide fiber
#

ReadOnly it's your case here
@storm ravine so in the Foreach of the HunterRadiusSystem I should put .WithReadOnly(QuadrantSystem.Quadrants)?

storm ravine
#

Yep

wide fiber
#

And it should work? (No other things to do?)

storm ravine
#

Ah no

#

Because of both systems

#

schedule independant jobs

#

They have shared Translation type

#

But because in both cases it's in thus they read only

#

and safety system decide that this systems jobs can run at the same time

#

WithReadOnly definitely will be required here

#

but dependency tracking also required here

wide fiber
#

Ok, I should study better how dependencies work

storm ravine
#

Just for fast check try put quadrant system deps to some static JobHadleField and use this dependency int HunterRadiusSystem and combine that deps and use as input for ScheduleParallel in HunterRadiusSystem

#

And don't forget add WithReadOnly for that ForEach

#

Static field only for fast check that it's problem

#

But it's definitely that πŸ™‚

wide fiber
#

Ok ty, I'll try in a few minutes πŸ™‚

storm ravine
#

@mint iron writing something loooong πŸ˜„

mint iron
#

@mystic mountain i think for situations like that, assuming its still under a query RequireForUpdate and rarely executed, i would do whatever is most readable and pleasant to work with. Performance shouldn't really be a consideration there - if it only occurs at worst once every few seconds, then it probably doesn't matter if it takes 0.15ms or 0.01ms. I'm starting to prefer using multiple tag components instead of a merged component with id; because it tends to make the code cleaner when you can have a cleanly triggered system by ForEach or group multiple ForEach blocks within one system if they're related. Even in perf critical situations, the tag approach is often worth the cost upfront unless it needs to be added/removed a lot. The only thing to be careful of is that in GetComponent chunk calls they iterate every type used, its fast but if you're getting a LOT of components on one entity then it will cost you.

storm ravine
#

I knew

mint iron
#

hehe

wide fiber
#

@storm ravine it says WithReadOnly can only be used with a local variable (QuadrantSystem.Quadrants it's another class)

storm ravine
#

Yes var map = QuadrantSystem.Quadrant

wide fiber
#

I've used a local variable and it works

#

@storm ravine yeah

loud matrix
#

So if I try and access a blobString directly I'm told I need to access it by ref. And if I try to access it by ref I'm told to access it by ref. I'm sensing a issue here.

storm ravine
#

show code

#

it's ref someString = ref blob.string?

loud matrix
#

ref BlobString desc = ref Database.Reference.Items.Data.Value.data[cargoBuffer[i].index].description;

mystic mountain
#

@mint iron Cool, thanks for the input. Since it's a TriggerEventsJob I don't think I can exclude it from always be queried as the teleporter and player are always present.

loud matrix
#

And yes that madness is a blob string

storm ravine
#

post exact error please

loud matrix
#

\Scripts\CargoSystem.cs(21,21): error MayOnlyLiveInBlobStorageViolation: BlobString may only live in blob storage. Access it by ref instead: ref BlobString yourVariable = ref ...

storm ravine
#

@wide fiber I saw....wlgMlg

#

You forgot replace to that var inside lambda? πŸ™‚

wide fiber
#

I was still using QuadrantSystem.Quadrants inside a function called inside lambda πŸ˜… 😁

storm ravine
#

Yes it's what I wrote above

wide fiber
#

πŸ‘

mint iron
storm ravine
#

@loud matrix I guess it error also contains Access it by (non-readonly) ref instead?

loud matrix
#

Thats the entire error minus my folder structure

storm ravine
#

Ah no

#

yep i see

#

Your blob reference stored on static field?

loud matrix
#

The reference to it is yes

#
namespace Database
{
    public abstract class Reference
    {
        public static readonly SharedStatic<BlobAssetReference<ItemBlobAsset>> Items = SharedStatic<BlobAssetReference<ItemBlobAsset>>.GetOrCreate<Reference, ItemsKey>();

        private class ItemsKey { }
    }

}
storm ravine
#

Ah shared staticks also involved here

#

Well let me think

mint iron
#

does the .data array indexer return by ref?

storm ravine
#

Well

coarse turtle
#

Hey @dull copper have you tried the build configuration pipelines with subscenes by any chance πŸ€”

loud matrix
#

No the data is just a BlobArray

#

And if i reference it to then get the description I get the same error

storm ravine
#

You need BlobString here?

#

I mean not ToString?

dull copper
#

@coarse turtle oh right, I haven't

#

but I do know they work without subscenes as that I did test πŸ˜„

#

I'm not really looking to get back in trouble with dots subscenes again

coarse turtle
#

ah ok - no worries just curious if you tried it by any chance

dull copper
#

do you have issues with it?

storm ravine
#

Will it complain if you do ref var blob = ref Database.Reference.Items.Data.Value; and then acces blob.data[idx].description?

loud matrix
#

That's what im trying now

storm ravine
#

Technically that should solve it at first thought

coarse turtle
#

Honestly I've no idea if its a direct issues with subscenes - it might just be w/ Android gradle πŸ€”

loud matrix
#
ref BlobAssetReference<ItemBlobAsset> reference = ref Database.Reference.Items.Data;
ref BlobString desc = ref reference.Value.data[cargoBuffer[i].index].description;
Debug.Log(desc.ToString());

that doesn;t have a compil;ation error, however it does error on run

storm ravine
#

string desc = reference.Value.data[cargoBuffer[i].index].description.ToString(); too?

#

And which error btw

#

And one more

loud matrix
#

Burst error BC1016: The managed function Unity.Entities.BlobString.ToString(Unity.Entities.BlobString* this) is not supported

storm ravine
#

Data is your root struct?

#

Well it's okay

#

if you disable burst will it work?

loud matrix
#

Yeah it runs fine without burst

storm ravine
#

strings not supported directly in burst

#

This is why you see that error

#

They added limited support for debug strings

loud matrix
#

Damnit, im not using my job logger

#

yeah it works with the refs then

storm ravine
#

Well that problem solved then? πŸ™‚

loud matrix
#

i switched over when trying out the sample code and pasting it here to avoid confusion :p

#

Now i just need a new job logger that doesn;t cap out at 3 logs for some reason, or get debugging in Visual studio working with native debug mode compilation

opaque ledge
#

Burst new package πŸ‘€

warped trail
#

finally

dull copper
loud matrix
#

Oh goodie, I heard through the grapevine they were adding string support of some kind

dull copper
#

not much on DOTS coming up though

#

in fact, I didn't spot anything upcoming

warped trail
#

Where is the talk Mike?😑

dull copper
#

GDC Summer will be completely virtual as well btw

#

maybe he'll prepare it for that πŸ˜„

#

altho at this point, I could see Unity moving all their stuff for UniteNow/virtual Unite

#
## [Burst 1.3.0-preview.11] - 2020-04-30

### Fixed
- Fix potentially different hashes returned from `BurstRuntime.GetHashCode32/64` if called from different assemblies.
- Fixed an issue where Burst was misidentifying F16C supporting CPUs as AVX2.
- SDK level bumped for MacOS to ensure notarization requests are compatable.
- Fixed a typo `m256_cvtsi256_si32` -> `mm256_cvtsi256_si32` and `m256_cvtsi256_si64` -> `mm256_cvtsi256_si64`.
- The compiler is now generating a proper compiler error if a managed type used directly or indirectly with SharedStatic<T>.
- Fixed a bug where implicitly stack allocated variables (`var foo = new Foo();`) in Burst were not being zero initialized, so any field of the variable that was not initialized during construction would have undefined values.
- Fix potential race condition when accessing on-disk library cache
- Fixed a bug where Burst was sometimes producing invalid code for iOS 11.0.3+.

### Added
- Added support for `System.Threading.Volatile` methods `Read` and `Write`, and for the `System.Threading.Thread.MemoryBarrier` method.
- New FMA X86 intrinsics. These are gated on AVX2 support, as our AVX2 detection requires the AVX2, FMA, and F16C features.
- `UnsafeUtility.MemCmp` now maps to a Burst optimal memory comparison path that uses vectorization.
warped trail
#

Fixed an issue where Burst was misidentifying F16C supporting CPUs as AVX2. πŸ₯³

dull copper
#

tbh, I don't know if AVX2 is even worth enabling at the time

#

I guess it gets more common with Ryzens

#

but its still quite nice on consumer CPU's

#

when I last tested it, AVX2 did have small gain to AVX but it wasn't notable difference

warped trail
#

i hate this new package manager🀬

dull copper
#

2020.2.0a9?

warped trail
#

yeah

dull copper
#

yes, I ranted about that earlier

#

it's like EVERY UX change Unity does

#

they first screw it up monumentally

#

then people start crying about it on forums and in 6 months, they've fixed half of the issues

#

same pattern repeats all around the engine where they change things

#

they never seem to ask actual users about these changes beforehand.. so basically every UX update ruins basic usability

coarse turtle
#

what's the new package manager look like?

dull copper
#

horrible πŸ˜„

coarse turtle
#

πŸ˜…

dull copper
#

I mean, I do like the new color coding

warped trail
#

it looks like giant waste of space

dull copper
#

but they've totally made it so much less usable again

#

main list it twice long now because they put useless info and icons there

#

they force you to expand for dependencies and samples

#

also they can't even display full package description without you having to expand the 4 line long description despite there's like 20 rows free on the bottom

warped trail
coarse turtle
#

oh :/

dull copper
warped trail
#

it looks a little bit better with dark themeπŸ˜’

dull copper
#

like, it's listed... why point out that I can install it

#

whole icon is 100% pointless

#

and clutters the visuals

warped trail
#

at least they could put it on same line

dull copper
#

I hate the space wasting on the big list the most

#

I now have to scroll to even see my installed packages

#

in the old setup I could fit all in single screen

loud matrix
#

So i'm using the DOTS sample Game Debug script https://github.com/Unity-Technologies/DOTSSample/blob/master/Assets/Unity.Sample.Core/Scripts/GameDebug/GameDebug.cs modified to remove the bits i don't need and just keeping the string logging for now. Whenever I use this, or similar scripts in a job it only seems to want to log twice, then srops. If i do it without burst it runs every update but when scheduling its only 2 times (2 times, then an error then once more if there's an error for some reason).
Any idea why this is?

coarse turtle
#

IOException: Sharing violation on path D:\Documents\Projects\Unity\UGUIDots.Samples\Temp\Android\gradleOut\local.properties
Hmm shoot wondering what's causing this with the build configs - guess I'll post on the forum πŸ€”

wide fiber
#

math.cross is the function to get the angle from two float3? (I am noob)

warped trail
#

no

wide fiber
#

Sorry I need a function to get the angle between a point and a quaternion

storm ravine
#

cross will give you normal of two vectors

#

It's vector product

wide fiber
#

Basically I need to know how near (in rotation, so "how much aligned") is my turret to the target. The target is a point in the world, for the turret I have the Rotation quaternion

storm ravine
#

For what purpose? FOV?

#

If so - dot product is your case

wide fiber
#

I want the turret to fire when the angle is near enough

#

When it's aligned enough to the target

#

(Sorry for my bad English)

storm ravine
#

dot product is what you need

wide fiber
#

Ok ty

storm ravine
#

If you need exact angle you can get it

wide fiber
#

But I have a quaternion (the rotation of my turret) and a float3 (the position of the target), math.dot doesn't accept 2 arguments of these types

#

I am not very good in math πŸ˜…

storm ravine
#

dot is vector dot product

#

extract forward from your quaternion

warped trail
#

math.mul(rotation.Value, new float3(0,0,1)) will give you forward vector of your turret if your rotation is in world space πŸ€”

wide fiber
#

Ok

storm ravine
#

But stop

wide fiber
#

Ty

storm ravine
#

math.dot accept 2 quaternions

#
        {
            var dot = math.dot(q1, q2);
            return !(dot > 0.999998986721039) ? (float) (math.acos(math.min(math.abs(dot), 1f)) * 2.0) : 0.0f;
        }```
#

I wrote some methods for myself, and math.dot definitely accepth 2 quaternions

wide fiber
#

Yeah I know that but I have a quaternion and a float3, not 2 quaternions (I have found the way)

storm ravine
#

And it's in radians

#

just multiply result by * 57.2957801818848

#

will give you eulers

wide fiber
#

math.degrees()

storm ravine
#

Yes or that

#

same thing under hood and will be inlined to x * 57.2957801818848

wide fiber
#

πŸ‘

sly moon
#

Hey,

Does anybody have an idea how to fix this? Google and Forum didn't help finding a solution.

ArgumentException: A component with type:BoneIndexOffset has not been added to the entity.

storm ravine
#

@wide fiber Well mul of your quaternion to forward vector will give you world forward

sly moon
#

Trying to get a SkinnedMeshRenderer renderer through HybridRenderer V2 in URP. I already added the Animations package but that didn't change anything.

storm ravine
#

It's known bug iirc

#

CopySkinnedEntityDataToRenderEntity throwing that behaviour, as temporary workaround disable that system and destroy

sly moon
#

I wasn't sure if it should work in the newest version. Thank you for clarifying!

wide fiber
#

math.mul(rotation.Value, new float3(0,0,1)) will give you forward vector of your turret if your rotation is in world space πŸ€”
@warped trail Rotation (the Unity component) is in world space? Could I also use LocalToWorld.Forward instead?

warped trail
#

i guess you canπŸ€”

mint iron
#

did they rename Animation package to Animation Rigging or is that something else

sly moon
#

@mint iron that is something else. The Animation package is semi-private

warped trail
#

@wide fiber but be aware that LocalToWorld is basically data from previous frameπŸ€”

wide fiber
#

Ok

storm ravine
#

@wide fiber but be aware that LocalToWorld is basically data from previous frameπŸ€”
@warped trail no, depends where you use it before or after transform system group

#

But anyway 1 frame doesn't matter here

wide fiber
#

My game is a top down 2D shooter, sprites rotate in the Z axis (I forgot to mention this πŸ˜… )
I've tried also LocalToWorld.Right and .Up but they give me wrong values.. I'll post pastebin

#

Maybe I've solved the problem

#

So
var angle = math.degrees(math.dot(localToWorld.Right, otherPointPosition));
should work? (Objects rotate on the Z axis)

warped trail
#

degrees converts from radians to degrees πŸ˜…

wide fiber
#

math.dot returns what?

warped trail
#

not radians πŸ˜…

wide fiber
#

Ah ok..

#

And how can I convert the return value of math.dot into degrees? (It returns a float, I don't know what it is)

storm ravine
#

Look at my Angle above

#

for 2 vectors you need something like that:

#
        {
            return math.acos(math.dot(v1, v2) / (math.length(v1) * math.length(v2)));
        }```
wide fiber
#

Ok ty :D

warped trail
#

these update is cool, you can easily add components to subscenesπŸ€”

safe lintel
lusty otter
#
public unsafe struct UnsafeFixedArray<T> where T : struct {
    public int Length;
    public Allocator Allocator;
    public void* Pointer;

    public UnsafeFixedArray(int length, Allocator allocator) {
        Length = length;
        Allocator = allocator;
        Pointer = UnsafeUtility.Malloc(length * UnsafeUtility.SizeOf<T>(), UnsafeUtility.AlignOf<T>(), allocator);
    }

    public T this[int index] {
        get => UnsafeUtility.ReadArrayElement<T>(Pointer, index);
        set => UnsafeUtility.WriteArrayElement(Pointer, index, value);
    }

    public void Dispose() {
        UnsafeUtility.Free(Pointer, Allocator);
    }
}
#

Does this look good?

mint iron
#

looks fine, i'd put the ptr first as a general rule so it can be cast if needed without calculating the offset

#

how long is your length going to be?

lusty otter
#

Small, 64 currently.

mint iron
#

have you considered using FixedList64?

lusty otter
#

That's how I used to do it, for what I'm doing (64 of floats) I need to use FixedListFloat512 and waste half the space.

mint iron
#

@safe lintel how would i install it?

wide fiber
#

When I play my game, after a few seconds the unity editor crashes randomly (also if I build the game, the build crashes). I can't understand the problem, does Unity log things on some file?

mint iron
#

are you using Visual Studio?

wide fiber
#

VS code

warped trail
#

@lusty otter just out of curiosity, have you considered creating FixedList256 yourself? πŸ€”

mint iron
#

what i do, is find the crashes folder (mine is C:\Users\{user}\AppData\Local\Temp\Unity\Editor\Crashes) and then open the .dmp file in visual studio, Start Native Debug and checkt he call stack, it will sometimes know the exception line in source code if your project was generated with all the packages, otherwise you can glimpse an idea of where issue lies from the callstack.

gusty comet
#

Hello,
Is it requited to use ECS, meaning entities concept, to be able to use Job and burst ? I'd like to thread and "burst" a method that needs to compute datas and applied them to Monobehaviours.

mint iron
#

@gusty comet no u can just use Burst/Jobs without ECS.

gusty comet
#

Ho great !

#

Thanks.

lusty otter
#

@warped trail How would I do that?

wide fiber
#

@mint iron there aren't folders created today at that path.. When the editor crashes basically it first freezes, then it closes randomly, without the pop-up of the crash

mint iron
#

ugh, thats the absolute worst situation.

warped trail
#

@lusty otter just look at source codeπŸ€”

lusty otter
#

Also the length is small but it can vary, it's still would be a headache to create and change lots of them whenever the length I'm using changes.

wide fiber
#

If I build the game when it crashes a "pop-up" (I think the UnityCrashHandler.exe) appears

low tangle
#

The crash stack might be inside the editor log

#

It's in appdata

#

C:\Users\Username\AppData\Local\Unity\Editor

wide fiber
#

Ok

#

Is that file deleted and recreated every time I open the Unity Editor?

#

(How can I understand when the log has been written?)

left oak
#

Anybody know why GetSingletonEntity<MyComponent> might return 0 when I can confirm there is exactly one entity with that component in the debugger?

mint iron
#

does it have Prefab or Disabled components on it?

left oak
#

it might have a Disabled...

#

Does Convert wrap-up before the first InitializationSystemGroup call?

#

I see what happened..

#

Once I add a disabled component, I can't get that entity anymore with GetSingletonEntity

#

So I succeed the first time only

mint iron
#

i think so, except that runtime conversions with IConvertGameObject will convert whenever the GameObject is instantiated, and SubScenes are pre-converted but get added to the world in the InitializationSystemGroup in SceneSystemGroup so if you need to access that data you'd [UpdateAfter]

left oak
#

Good to know, thanks xzjv!

wide fiber
#

Boxing a value type to a managed object is not supported is the first error.. Can't I use .HasFlag()?

mint iron
#

try checking the flag manually, HasFlag has always been absolutely rubbish in c#

wide fiber
#

Ok, I'll try..
The second error?
Loading from a non-readonly static field is not supported
Can't I use static variables?

#

Maybe I should put .WithReadOnly()

mint iron
#

you can use static readonly variables

zinc plinth
#

in an EntityQueryDesc, if the component is a dynamic buffer, does it change anything to the syntax(ComponentType.ReadOnly<DynamicBufferType>()) ?

coarse turtle
#

in an EntityQueryDesc, if the component is a dynamic buffer, does it change anything to the syntax(ComponentType.ReadOnly<DynamicBufferType>()) ?
@zinc plinth not from what I've seen

zinc plinth
#

alright, thanks !

wide fiber
#

@mint iron but I can't use read-only variable, I change the value of that variable outside the Foreach.
I can't even use .WithReadOnly() because float2 is unsopported

opaque ledge
#

i think flag enums arent supported in Burst

loud matrix
#

@opaque ledge did you say you were using nativeHashMaps in a shared static?

opaque ledge
#

yes

loud matrix
#

I'm having a play with it, does seem a lot easier than Blobs to access and setup.
It does not seem to like the shared static, you ever have issues with creating the shared static? It thinks ive created it before Unable to create a SharedStatic for this key. It is likely that the same key was used to allocate a shared memory with a smaller size while the new size requested is bigger I've probably doen somethig dumb in there somewhere :p

mint iron
#

Flags are fine in burst, its just checking some bits

    public static unsafe class UnsafeExtensions
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static unsafe bool IsFlagSet<T>(this T flags, T flag) where T : unmanaged, Enum
        {
            return (*(int*)&flags & *(int*)&flag) != 0;
        }
    }
wide fiber
#

Yeah they are working in another script normally (where I don't use .HasFlag())

storm ravine
#

Flags supported by burst fine

#

Angelo13C.QuadrantSystem._mapOffset

wide fiber
storm ravine
#

store it in field outside of ForEach

#

like with Quadrants

#

and just use that field inside

mint iron
#

@storm ravine are you using the unity Animation package or you rolled your own custom solution?

storm ravine
#

Well I can tell my animation story third time through 2 days πŸ˜„

mint iron
#

sorry :S

storm ravine
#

I'll give you link to previous messages

mint iron
#

i only processed that you were using it through shaders, which animation package does too.

mint iron
#

thnx

wide fiber
#

store it in field outside of ForEach
@storm ravine I think the problem is float2..

#

It doesn't give me errors for the other static variables

mystic mountain
#

Is there any way to stop Static Optimize Entity? Or do I need to keep stuff in seperate hierarchies?

wide fiber
#

It gives me an error also at the "getter":
public static float2 MapOffset => _mapOffset;

storm ravine
#

Show code

#

Where it give you error on getter

#

Outside of ForEach

wide fiber
#

I'll post code and errors in a few seconds

#

At the declaration

storm ravine
#

Again - you should store them OUTSIDE ForEach in local variable

wide fiber
#

Yeah but there is a problem also at the line 28

storm ravine
#

Ah sorry

wide fiber
#

Which is outside functions

storm ravine
#

it's different system

#

1 sec

#

Yeah, it's static fields on system

#

Same

#

you should store them outside ForEach in local variable

wide fiber
#

I hate the fact that I need to store a local variable to use the global static one.. can't the compiler add it automatically :(

storm ravine
wide fiber
#

Ok

storm ravine
#

Even if they wouldn't be static

#

and just non static fields on system

#

you'll get error

wide fiber
#

The burst compiler should support this

storm ravine
#

It's not burst compiler thing

#

I mean burst compiler of course but not fully on that πŸ™‚

warped trail
opaque ledge
#

you can put them into native array and you can access them inside your ForEach

wide fiber
#

Now I can't even build, I'll send the errors

opaque ledge
#

and you have to dispose after ForEach

wide fiber
#

@opaque ledge Are you talking with me?

opaque ledge
#

yeah πŸ˜„

wide fiber
#

The variables are of different types

opaque ledge
#

make different arrays then^^

wide fiber
#

Ah ok

storm ravine
#

you can put them into native array and you can access them inside your ForEach
@opaque ledge unnecessary, they just should be declared ourside of local lambda scope. Even with native array you'll see same error if that native array is system instance field. There is no need use native containers here at all πŸ™‚

opaque ledge
#

πŸ€”

storm ravine
#

For example

#

Error tell you clear what you should do πŸ™‚

opaque ledge
#

yeah i see, yeah you have to catch them outside of ForEach, locally

storm ravine
#

And for just float\int etc. same rule

wide fiber
storm ravine
#

It's different system

#

Hunter system

wide fiber
#

I think now it should be workinf

storm ravine
#

where you should do same thing

#

HunterRadiusSystem

wide fiber
#

Ok I've updated it

#

I am building

storm ravine
#

And just my personal note - this bunch of statics is a mess for me πŸ˜„ it require additional dependency managment meeeh πŸ˜„ It potential place for problems with disabled domain reload πŸ˜„ Code become ugly πŸ˜„ But it's only my toughts πŸ˜„

wide fiber
#

What should I do to improve? I don't know other ways to do it
(Well actually I've disabled domain reloading to start playing faster, because I am temporarily using a pc that is really slow)

#

It works, ty :D (sorry if I am stupid but I am still learning a lot of things, I am 16 years old so yeah)

storm ravine
#

Well statics of coure simple

#

But when project grow....

#

If you look above at video of our region system. I just use singleton entity which can be queried anywhere, which store areas regions and links. some system query and fill values, other systems also can query that entity and read values, dependency chain builded automatically based on component type of that entity

#

this component type is class IComponentData, not struct

#

And cleanup system just query all similar type singleton entities end dispose native containers

wide fiber
#

So singleton entities may be better for this?

#

An entity with a component that is singleton

storm ravine
#

Also it allow you use Require methods for preventing systems run utill required entity with maps\configs\etc. not created yet

wide fiber
#

πŸ‘

storm ravine
#

Thus you can easily load every thing asynchronously (this is what we doing for every thing)

opaque ledge
#

how do you do camera culling Eizen ?

storm ravine
#

I converting that and have controller system for that

opaque ledge
#

i am doing with adding/removing tags but i was wondering how you do it

storm ravine
#

and query camera through my component type wrapper

#

And wrapper

#

all components on camera converted through companion

#

And system with var cameraRootEntity = GetSingletonEntity<MainCameraRoot>();

safe lintel
#

@mint iron just add it to your manifest latest is "com.unity.animation": "0.3.0-preview.9" but its not compatible with the samples unless you update it yourself, preview.7 is compatible though

#

i cant figure out how to use humanoid animation clips with it though 😦

storm ravine
#

And on conversion I just put Camera entity reference in to root entity component field

#

Ang can get camera entity from cameraRootEntity easily

storm ravine
#

Aaaaah culling

#

sorry miss that part of message πŸ˜„

#

Tired a bit

#

I have region system

#

and every object know in which region he is (by sampling cell position) and region know animation renderers in region and rendering system iterates through visible regions. Because I have custom animated only buildings parts (which static usually) and units\citizens\fish it works fast on ~50k, tbh even without culling it works without problem πŸ™‚ All trees rendered by HybridRenderer, I just wrote small wind shader fot them. Same for cliffs just static entity with regular shader. And for ground again custom triplanar shader with HybridRendere

opaque ledge
#

why everything in your game is custom dude

#

why not game engine custom as well xD

mint iron
#

cause unity doesn't do what he need :S

storm ravine
#

Because we started using DOTS when nothing was a thing except basic jobs\burst\systems

#

And I wrote all that for myself

fallow mason
#

lol was thinking the same thing earlier

storm ravine
#

And if it works very well for our game and optimized, why I should drop and use something from Unity? πŸ™‚

#

Same for navigation, physics etc.

fallow mason
#

"this guy just like the unity splashscreen"

mint iron
#

you should put it on the asset store then profit

storm ravine
#

And because we have full control here and implement only things which we need, without any additional things which may (or may not) have even small cost

mint iron
#

"replacement game engine" for unity

safe lintel
#

id buy it

storm ravine
#

Well, navigation and fog of war will be on asset store

#

Old video

opaque ledge
#

OOOOOH i forgot to buy fog of war asset in spring sale off 😦

#

is it still going πŸ‘€

mint iron
#

but your men run through the trees πŸ˜›

storm ravine
#

yep old video

#

And trees without colliders

mint iron
#

just kidding around, looks awesome

storm ravine
#

we decided that for convenience, trees walkable

#

You can look video above with region system

#

where I enable debug move

#

you can see red cells

#

One more old video

#

First iteration of siege machines

#

Without rotation smoothnes etc.

#

Red cells in case of buildings and cliffs it's rasterized to map obstacles (sandbox scene without enviroment randomization don't look at this)

#

About collision and local obstacle avoidance in my custom collision system and navigation

storm ravine
#

Why?

#

yep it's also old one πŸ™‚ with some navigation bugs

mint iron
#

cause the its fun seeing hordes of guys get smashed and go flying

storm ravine
#

Oh language barrier πŸ™‚

#

Tought about wicked as evil

mint iron
#

sorry, yeah, child of the 90s, i sometimes throw in a 'wicked' or 'rad' here and there

storm ravine
#

Mostly because of I'm from Russia

#

And English not my native language πŸ™‚

mint iron
#

awesome, i'm from NZ but I've tried learning German, and now i need to learn French. I have a lot of respect for people who can speak multiple languages.

storm ravine
mint iron
#

i saw people taking materials from a stock yard, do you have to mine resources and then use that stockpile to build stuff?

warped trail
#

it looks like they are billionsπŸ€”

storm ravine
#

i saw people taking materials from a stock yard, do you have to mine resources and then use that stockpile to build stuff?
@mint iron yep all resources is not numbers in UI

#

It's real objects

#

if you have 100 wood

#

youl see exactly 100 wooden planks on storages in sum

vagrant surge
#

thats so unnecesary lol. Great stuff

storm ravine
#

construction and producing not abstract too

#

If you need 20 wood and 10 stone for building

#

You put building on map

#

And builders shoud transfer 20 wood and 10 stone from storage in real time

#

if builder died (from hunger, age, desiese) he drops resource

#

and porter should go, pick that resource and transfer back to storage

#

Until produced resource (food for example) not transfered from farm to granary - it not counts in UI

#

only after transfer you can use that

#

and if all porters died and you havent food in granary will be hunger

#

even if you see many food on farms

#

Also died peoples is real things which spread desease

#

and gravediggers should transfer them to cemetery and bury them

#

Construction example

vagrant surge
#

i can see you are taking inspiration from dwarf fortress

#

most of those mechanics are a thing there

#

thats also quite a lot of complexity, is it all done in DOTS?

storm ravine
#

Nope at all. Stronghold mostly πŸ™‚ with settlers and they are billions

vagrant surge
#

how many systems you have

storm ravine
#

Fully on DOTS

vagrant surge
#

what a madlad

#

how do you think it scales on such amount of mechanics?

#

as in dev-time, programming flow

storm ravine
#

around 80-90 systems I think

#

It scales very well on them

#

ususally systems very atomic

#

Like Day\Night system just rotates sun. Food Consuming system just reduce food in granaries and calc hungry people and decide they hungry long time (some range) and if yes - mark them to be killed at end of frame

#

All DOD very convinient for me. After many years of OOP programming (enterprise, before gamedev and mix of OOP and COP in Unity)

#

old video too

#

Here you can notice cemeteries, where every tombstone is real buried citizen πŸ™‚ on 1:10

warped trail
#

looks awesome πŸ€”

loud matrix
#

Medievil they are billions, looking good πŸ™‚

opaque ledge
#

and here i was just being happy because i implemented quest/mission system πŸ˜’

#

joking btw, wishing you my best πŸ˜„

#

Getting

InvalidOperationException: The type Unity.Collections.NativeList`1[System.Int32] used in SharedStatic<Unity.Collections.NativeList`1[System.Int32]> must be unmanaged (contain no managed types).

after burst 11

loud matrix
#

What version were you on previously?

opaque ledge
#

10

#

"The compiler is now generating a proper compiler error if a managed type used directly or indirectly with SharedStatic."

#

but its NativeList with int generic

storm ravine
#

Yep, expected πŸ™‚

#

NativeList itself managed

opaque ledge
#

and it was working properly

storm ravine
#

This is why you can't use NativeContainer inside NativeContainer

opaque ledge
#

i thought that was because they were simply not blittable, not because they are managed

#

why do we dispose them if they are managed ?

#

and why it worked properly before ?

storm ravine
#

Not properly there was bugs which you just not caused

opaque ledge
#

so it was a bug that it was working 'properly' ?

storm ravine
#

They not working properly, you just not noticed problems πŸ™‚

#

On forum you cand find threads

#

I just can't remember them exactly

#

why do we dispose them if they are managed ?
@opaque ledge you disposing pointers inside

opaque ledge
#

well i am kinda screwed then

storm ravine
#

native containers contains managed things too

opaque ledge
#

how am i suppose to fix this problem

storm ravine
#

not only pointers

loud matrix
#

Come CurlyOne,, join me in confusing blob bliss

opaque ledge
#

i am kinda sad rn

coarse turtle
#

what if you swapped it to its unsafe counterpart? πŸ€”

opaque ledge
#

yeah thats what i am going to try

mint iron
#

whats worse is that the dispose sentinal will get garbage collected because no class holding on it, and report a leak :S

storm ravine
#

btw if someone interested in our game (as game, not tech part, about tech part I'll post on forum and here, because they directly connected with DOTS), and look funny roadmap, gifs etc, join our game discord, because it will be offtop to put it here πŸ™‚

safe lintel
#

is there a way to use unsafe with the systembase lambda?

storm ravine
#

unsafe what?

#

lambda itself?

safe lintel
#

just like accessing a colliders pointer

opaque ledge
#

yep, thats how you cast raycasts actually πŸ˜„

storm ravine
#

just access them? πŸ™‚

safe lintel
#

like old IJFE private unsafe struct MyJob:IJobForEachetc not sure what to do for the ForEach

storm ravine
#

wrap unsafe part to unsafe {}

safe lintel
#

ahh thanks

opaque ledge
#

alright, making to Unsafe versions actually solved it (at least no errors)

zinc plinth
#

for shared component filters in entity queries, the filter is by the overall value of the struct or ?

coarse turtle
#

for shared component filters in entity queries, the filter is by the overall value of the struct or ?
@zinc plinth it should be the value in the struct - I'm pretty sure they use a hashcode to determine equality.

storm ravine
#

Hard to read sentence πŸ™‚ But if I understand your question right - it's up to you, because you implement IEquatable

coarse turtle
#

Oh right in ISCD you also have to override IEquatable - think @storm ravine is right - it might be using that instead πŸ€”

storm ravine
#

And if your IEquatable implementation use 1 field it will filter by that field, if you use more and calculate hash by 2-3 and more fields it of course will relate on that, because you will use them for hash calculation

zinc plinth
#

hoo ok

#

thank you both!

loud matrix
#

Anyone have any resources for someone far too used to runtime languages and needs a refresher on managed/unmanaged with unity? I can't find much outside of basic "this is the stack, this is lifo" memory stuff with c#. It's coming up an awful lot with ECS and i think i should probably have a firmer grasp in my head. not sure what I should be googeling :p

safe lintel
#

i like how no nonsense it all is

coarse turtle
mint iron
#

we got nothing going on, post your questions

loud matrix
#

The question is currently just what in unity is managed or unmanaged, but I know there are things I don't know to ask, that;s why I'm looking for some more resources.

storm ravine
#

But it's not Unity specific πŸ™‚ C# docs should cover that πŸ™‚

#

Or I understand your question wrong?

loud matrix
#

I've not seen them called that when looking for c# docs related to it

loud matrix
#

Why are c# tutorials and docs eigther written as babies first code or arcane runes?

storm ravine
#

?

loud matrix
#

The microsoft docs are a extremly hard read, but the alternative seems to generally be literal introduction to c#, but they sprinkle in a single useful, nugget every 30 min video.

storm ravine
#

Hm, MS docs one of easiest imo

loud matrix
#

I've had to dive into them a couple times before when fixing up .net websites we still support at work from like 10 years ago, so we didn't get off on the best foot

safe lintel
#

my mind cant handle microsoft docs, i need to search problem + stackexchange to make sense of things most of the time πŸ˜„

#

i need that eli5 breakdown

loud matrix
#

One thing I can't seem to find defined is if unitys "native" functions are synonymous with unmanaged, as I've heard some sources say to just assume they are, others disagreeing. Looking at nativeArray in the docs it says it exposes a buffer of native memory to managed code, so it sounds like they're using it as a bridge between the two. But without looking up every function it's hard to tell.