#archived-dots
1 messages Β· Page 287 of 1
Where do I assign the scene to the asset then?
scene list
And where is the scene list?
it's a component
Ah, that's what you meant
I must have misunderstood earlier
It works now, sweet, thanks
the preview one right?
Yep
Ah, that explains a lot
hence you get random null refs and other issues
I was seeing "old" behavior from some burst functions
this issue is close to my heart because i spent hours working with a burst dev to provide them data as I had a somewhat reliable repo but they couldn't repo it
then took them 3 weeks of work to actually track down problem and fix it
it's this super weird combination of things
but yeah it hasn't made 1.8 yet as the preview was released before 1.7.2
Well done π
I wasted a few hours on it too today, thanks for letting me know though, I'm sure it would have cost me even more time down the line not knowing
it was absolutely gutting our build machines
which constantly change branches and run integration tests
found a way to still get simd. int instead of bool
inlined method to ensure ushort doesn't overflow
it's one hell of a burst assembly! π
even without the bump. give me a sec
yep, but not bump version related. i still have to find out how to improve that
first time i split a job and it got from 1.8ms to 0.48ms and 0.11ms
the second timing is the posted job
i think the jumps are related to how many values are loaded into the register
or the jump is related to the continue
i have to say, now that I have a grasp of utilising version changes gracefully, it's a lot of fun π
using write handles with RO pointers and bumping version manually was the key. without the custom changeVersion method I would have no idea how to do it
Unity should really make this a public method.
without the custom changeVersion method
technically you can just use GetNativeArray to bump it, you don't need the custom method
i just like the custom method to be clear what's happening
sure, it just has a lot of unnecessary overhead. I'd never recommend using that to just bump the version
hmm, i find it unlikely 1 call per chunk (and that assumes every chunk has changes) is not going to be noticeable on the profiler vs the SetChangeVersion
you could also just use GetComponentDataPtrRW as well to remove overhead even more
i'd actually be surprised if burst doesn't strip a lot of the overhead anyway as it's returning something unused
it will be noticeable in a full running game with 10000s of chunks. not game breaking sure but why not take the shortcut. The other methods have lookups into arrays that have already been done at that point. never checked if burst removes that. possibly
unity hasn't really made it easy to work with versions because of some questionable auto magic without parameters. that stuff could be noob-friendly with just a pre-defined parameter. anyone goes like, bool bumpToGlobalVersion = true. - huh, yeah I want that, or not
and versioning is such a key factor to proper ecs usage. i'd bet, most people who use ecs don't use versioning right
at the end if the day it's about control and you only have control over versioning in unsafe space. that alone should be reason enough for changes
hey so im finally taking a look into DOTS, but I have one major issue when playing (event an empty scene) my FPS tanks massively because of console spam saying there's old allocations being deleted
do you have the netcode package installed?
yes
limit to 60fps. (vsync or Application.targetFrameRate) it's a known issue
huh.. weird
wonder why one of those methods doesn't work: ```// works
private UnsafeParallelHashMap<int, BlobAssetReference<SpellBlobRoot>> blobLookup;
blobLookup = *...blobLookup.GetUnsafeParallelHashMapPtr();
on job: blobLookup = blobLookup,
in job: public UnsafeParallelHashMap<int, BlobAssetReference<SpellBlobRoot>> blobLookup
// doesn't work
private UnsafeParallelHashMap<int, BlobAssetReference<SpellBlobRoot>>* blobLookup;
blobLookup = ...blobLookup.GetUnsafeParallelHashMapPtr();
on job: blobLookup = *blobLookup,```
on job: blobLookup = *blobLookup,
why would you think this was safe?
why not? it's the same as blobLookup[0]
sorry highlighted wrong line
private UnsafeParallelHashMap<int, BlobAssetReference<SpellBlobRoot>>* blobLookup;
how are you pinning your UnsafeParallelHashMap<int, BlobAssetReference<SpellBlobRoot>> in memory?
what would you expect if you have a private variable int in ISystem
i wouldn't have expected the value to be pinned
not that I've tested this, but that would not be my expectation
why would I need to pin a pointer to unmanaged memory?
you aren't pointing to unmanaged memory
you're pointing to a struct
that holds a pointer to unmanaged memory
oh damn, internal UnsafeParallelHashMap<TKey, TValue> m_HashMapData; i could have sworn this was a pointer. what the hell was I looking at before ...
i was looking at internal UnsafeParallelHashMapData* m_Buffer; ok that clears things up then...lol thanks
looks like my DB stat change referencing works with removals. that was quite the pointer juggle π
had to add this little method ```public int RemoveAtSwapBackReportIndex<T>(DynamicBuffer<T> buffer, int index)
where T : struct
{
buffer.Length -= 1;
// ref var l = ref buffer.Length;
// l -= 1;
// int newLength = l;
if (index != buffer.Length)
{
byte* basePtr = (byte*) buffer.GetUnsafePtr();
UnsafeUtility.WriteArrayElement(basePtr, index, UnsafeUtility.ReadArrayElement<T>(basePtr, buffer.Length));
return index;
}
return -1;
}``` and I'm confused what they are doing with the ref l and then newLength
did you ever test ISystem ECB? is it actually faster?
i don't expect it to be any faster
just let me used ECB in ISystem
i'm not really using it because I can live with 2 systems being SystemBase for now
since ECBS support for ISystem is coming in 1.0 anyway
was just more of a challenge
I just logged some info about the custom transform systems I would like to add to my simulation world.
The custom TransformSystemGroup is successfully added
However all the custom systems like the EndFrameParentSystem aren't added to the TransformSystemGroup, even though they have the correct UpdateInGroup attribute.
Has anyone else experienced this issue before?
Maybe your custom system is expecting the older EndFrameParentSystem to exist?
Ah yes that could be the issue. Good to know that systems can fail silently like that.
I think I'm going to use a simpler solution for now. Getting https://github.com/Kimbatt/unity-deterministic-physics transform systems to work in 0.51 is daunting.
Is unity physics not truly deterministic due to the floats it uses?
Ah so it's not necessarily deterministic on all platforms
Either vsync or the CPU is waiting on gpu to finish last frame
no Vsync
yet fps is locked on 74.7
for some reason
I literally have only 9 draw calls from SpriteRenderer
Compute shaders? Constant gpu uploads?
whats your monitor hz
welp, PC restart helped, kek
it's 75, yeah
seems like it got locked to vsync somehow
No unity physics is only deterministic specific to each hardware. So the same simulation will run exactly the same each time but there can be differences between machines.
yes :p
We've done a bunch of testing on determinism, not specifically for physics but world generation with floats and bursts and our conclusion is basically all modern x64 chips will produce the same result
It breaks down when using different chips, like xbox and playstation but in ~3 years we have not been able to break determinism on Windows over a lot of different machines and hardware configurations
Now we don't relay on being deterministic due to cross platform play but it is a very useful feature for debugging procedural world generation when someone reports an issue with a seed.
One misc point is that il2cpp and mono (editor) will produce different results for float maths even on the same hardware
Thank you for letting me know about this. I might give using regular floats a go at some point.
For now I'll try to stick to soft floats for my logic which has to be deterministic, just to be safe.
any ideas on what this unity merger means for dots?
I think I just found the answer
Unlike the new systems window the Entity Debugger doesn't display systems which are currently not running π
Just read that, also read this that they've just paid off a few hundred employees mostly in AI and Engineering:
https://www.pcgamer.com/unity-lays-off-hundreds-of-employees-to-realign-resources/
cool cool cool
I wonder if any working on DOTS have lost jobs
I think they're probably going to cut DOTS development completely. Evidently its no longer just speculation that the company now needs to cater to short term profitability prospects
and Unity is specifically not profitable right now, and its very difficult to be profitable during an economic downturn, and much less when you're in the middle of a rebuild. I'm assuming DOTS has been moved to the wings and is now viewed as a pure cost driver
I want to be told I'm wrong about this.
I'm not really sure I'd believe it, but I'd really really like to be wrong.
I mean, the company clearly has no ability to be consistent with its own promises, that article mentions that just two weeks ago, the CEO promised its employees they weren't in financial trouble and no one had to worry about their jobs
Mm economic downturn yes, and several of the big tech companies have announced hiring freezes etc.. DOTS sidelined i'm not so sure.. I can understand pursuing monetization capabilities more aggressively ( ie the takeover ) cos that's the whole business model, but i think DOTS is going to be important for the future of the engine.
I didn't actually realize they'd bought WETA Digital, what was that all about?
ironically i'm now read Jason Schreier's Press Reset book about ruining companies and career
DOTS is already part of Unity engine ,kek
they literally move Physics engine on it
no way they drop it
yes, but it is only about burst and jobs for particular things
when people say development of dots they mean not usual unity stuff with dots under the hood, but dots for developing games
maybe worth checking twitter bios etc of any of the known dots devs
+2 runtime performance for certain physics scenarios doesn't really strike me as "mission accomplished"
i think they've committed to LTS for dots 1.0 right?
@devout prairie where did you see ai and engineering from the layoffs? From what I saw the biggest visible hit was the gigaya team, that pcgamer article is from that time iirc
π€·
I guess it could be speculation
Iβm only just catching up on the merger which hmm part of me thinks is π€¦ββοΈ the other side is also πΈ maybe this gets them profitable after all this time
I would hope that despite the term merger, unity is the one holding the reins after the dust settles and not the other way around
im not happy but tbh that particular forum crew is never happy
haha someone posted the steve jobs video I was thinking of π
unity makes a lots of weird acquisitions where I'm like, coooolsees, and how does that help me? then I look at Unreal and they make acquisitions where I could start drooling ...
people don't seem to be happy, yet I'm feeling pretty great in my DOTS bubble. before we see anything about dots being cancelled, we see Joachim's resignation as CTO. i think with him dots is pretty safe
they literally just announced this week 1.0 pre-release with 2022.2 and 1.0 release with 2022.3
people saying it's being cancelled are so weird
i confess i have missed that post! but yeah, this doom & gloom stuff is annoying and weird
Unityβs data-oriented tech stack (DOTS) makes it possible to build more ambitious games, and we are in the final stretches of preparing the first pre-release version of Entities 1.0 for launch. Entities 1.0 will bring compatibility with 2022.2, and will be available at a later point during the beta. The full release of Entities 1.0 is planned for 2022 LTS. ```
part of the 2022.2 beta announcement what's new
huh i've read the 2022.2 beta announcement yesterday but seemingly missed the entities 1.0 preview. holy crap, that's awesome π
they are on a good track when they say this mid july
hm new ai nav package as well?
well nice to see that officially we will get some preview packages for 1.0
Outstanding pushback here, not DOTS related but thought you guys might be interested in it:
https://www.pcgamer.com/developer-turns-future-of-gaming-talk-into-a-surprise-attack-on-conventions-nft-and-blockchain-sponsors/
yeah I saw that earlier, thought it was fantastic
i got a unity survey not long ago about nfts and monetization and made my feelings about crypto/nft heard π― π€‘
I suppose on the bright side of this whole 4billion dollar acquisition, its not crypto or nft related
Thing is I don't mind blockchain or nfts as such, but the monetization above all else is so destructive.. the guy in the article really nails it
oh man unity gave me a survey about nfts
i did not respond positively
i actually have a masters in cryptography and studied blockchain a lot when i did this (and this was like 8 years ago)
so i'm quite fond of the technology
even ntfs have huge applications - one great example is concert tickets
you can use nfts to prevent scalping
(i was pretty anti nfts completely until i learnt of some actual good real world examples)
but yeah i don't think they belong in games purely because i don't think they bring any benefits to gamers
the only interesting idea i ever had with nfts and games was simply making access to your game an nft
so you print say, only 10000 keys to access your game
you make your contract give 20% of resale to developer, and you can't resell for more than the original price
therefore you can effectively rent the game for 20% of the cost
im not sure this is a good thing at all, but it felt like at least a bit of a win win from all sides. developer gets constant resale $$ and gamers get to play game much cheaper
but i thought it was an interesting idea
is GetEntityQuery depreciated?
hmmm also how do you schedule jobs now that onupdate doesn't give you the jobhandle as a parameter
those damn nfts man ... devs hate them, gamers hate them. just investors love them. they have some merit for the real world, but in the gaming space... i hope we can soon get over it because every time i hear about them it kills my vibes. the discussion about them is so depressing.
no, still there
I made a lot of money off of those π
there's a public field for every systemBase called Dependency that's used instead
nice π what did you sell?
mekaverse net me $60k, all nfts are rekt now tho
except bored apes I guess
ah, I heard about some selling yacht 3d models for high prices. i dunno ... just π€£
i lost pretty much all understanding how and why people spend money. but hey, i can code, that accounts for something
I missed out on about $200 million worth of profit by selling certain tokens too early
so yeah my sense of money has been changed forever too
think that's enough off topic stuff for this channel tho
@viral sonnet so we no longer need to return the jobhandle, and Dependency just...gets updated?
if you use Entities.ForEach in the update it gets handled for you. otherwise Dependency = new JobStruct { ... }.Schedule(Dependency);
Is EntityCommandBuffer.Concurrent now ParallelWriter?
@rotund token i do like that resale idea, I do think the tech is interesting but 99% of the current uses of it currently are just get rich quick schemes
@gusty comet yes
hmm someone mentioned somewhere that if I use SystemBase I should make the class partial
is that a requirement?
yeah for .50/51 upwards
What games are you guys making right now? Me a colony sim.
"boomer" shooter
I don't make games, I just make libraries for other people to make games
Unfortunately I also don't release these libraries π©
rts
Does anyone know if it is it possible to get a jobhandle from a .foreach?
Nice, then I'll just pass a new JobHandle if I don't have any dependencies
you should be passing in Dependency
then writing back to Dependency
also if you don't pass in the handle it's still written to Dependency automatically
so you can just use Dependency
Entities.ForEach(() => {}).ScheduleParallel()
is the same as
Dependency = Entities.ForEach(() => {}).ScheduleParallel(Dependency)
unity just does it for you
note that
Entities.ForEach(() => {}).ScheduleParallel(Dependency)
is not the same thing
as you are passing in a handle you are saying you are taking control of dependency management and Entities.ForEach now writes the handle back and you have to pass it back to Dependency at some point
Dependency = handle;```
the tldr:
Entities.ForEach(() => {}).ScheduleParallel()
Dependency at this point will be from the previous job and you can just use that for dispose etc
Does Dependency also take into account other systems?
Dependency is created in BeforeOnUpdate
based off the dependencies the system uses
what your queries read/write components are, ComponentFromEntity etc
how does it know about them? codegen?
If I don't pass Dependency to Entities.ForEach but a new dummy JobHandle, could there be conflicts between jobs trying to write to the same components?
Yes
You have to pass in Dependency
if you have anohter handle you need to be dependent on as well, you can use Dependency = JobHandle.CombineDependencies(Dependency, myhandle)
Thank you, it's good to know that conflicts between jobs are avoided by using Dependency
The safety system will scream at you
If you leave out dependency
It's why it's there, don't turn off jobs debugger unless you are performance testing
In your experience, does using asmdefs increase the frequency of the burst compiler becoming bugged and having to restart Unity?
I'm getting quite a few 'this indicates a bug in the DOTS compiler' exceptions lately.
Could it have something to do with using static classes within DOTS code?
I have a NativeList pointer question...
Let's say I get the pointer to a NativeList like this
void* ptr = new NativeList<int>(Allocator.Persistent).GetUnsafePtr();
is there anyway for me to use that pointer later to add a new element to that NativeList or access an element from that NativeList?
Basically I am struggling on how I can use this ptr to once again access the NativeList
what version of burst
1.6.6
I somehow doubt that this is what I want to do
void* ptr = new NativeList<int>(Allocator.Persistent).GetUnsafePtr();
NativeList<int> test = new NativeList<int>(Allocator.Persistent);
test.GetUnsafeList()->Ptr = ptr;
yeah you have the cache bug
just upgrade to 1.7.2+ (but not 1.8 preview)
okay thank you!
For context, I am trying to create a NativeHashMap that stores a key and the value is a pointer to a NativeList
that way I can have a NativeHashMap of NativeList values
yeah that's exactly my take on it there are some great applications for blockchain and nft technology and whether it's a net benefit over fiat currency is an argument that that still needs to be settled.. but this idea of nft companies crowding the investment space for gaming, muscling in to push their agenda, although indy game developers obviously require funding i think it's important to collectively push back against that.
you can simply use MultiHashMap for same behaviour
So a more complete example of my question would be:
private static NativeHashMap<int, IntPtr> _myMap = new NativeHashMap<int, IntPtr>(1, Allocator.Persistent);
.
. //later in code...
.
// initialize a new NativeList for a new index I am adding
void* ptr = new NativeList<int>(Allocator.Persistent).GetUnsafePtr();
_assetDependecyMap.Add(index, new IntPtr(ptr));
.
. //later in code again...
.
// access the previously initialized NativeList and add a value to it
void* nativePtr = _assetDependecyMap[index].ToPointer();
// at this point I don't know how to use the nativePtr to do what I want
hey, wondering should i use some kind of math clamp function or just use if statements while in an entity for each loop (burst enabled)?
I've read those can be slow, and I also did try to use a MultiHashMap initially and was pretty confused on how it worked
it's literally like Dictionary of key, list<value>
as far as I could tell, I couldn't just do myMultiHashMap[index] = myValue
i had to do something with enumerators, and it got very confusing to me
i'm talking about accessing an existing key
{
do
{
// Use child
}
while (ParentChildrenToRemove.TryGetNextValue(out child, ref it));
}```
is the pattern
to use all values that share the same key
also when I declare a MultiHashMap, is it like this, or like this?
MultiHashMap<int, int> or MultiHashMap<int, NativeList<int>> ??
ultimately I want key: int, value: List of ints
NativeHashMap<int, int>
is Dictionary<int, int>
NativeMultiHashMap<int, int>
is Dictionary<int, List<int>>
ok, that clears that part up
(not exactly but they are what they are meant to replace)
Also they've been renamed for some reason
i'll give it another go, though I would prefer the NativeHashMap<int, IntPtr> if it were possible
i'm just unsure if I can use the NativeList ptr the way I was trying to
You can use an unsafelist in there
yeah, ultimately NativeList points to an UnsafeList inside of itself, and using .GetUnsafePtr(); gets that pointer
but once I have the pointer, I don't know what to do with it
Yep
do I allocate a new unsafe list?
No just store the ptr in there as intptr
yes I have done that part
but now that I want to access it later, how do I treat it as an UnsafeList again?
Cast it
That said I don't recommend this
The memory management will be a pain
You still have to keep all the native lists around to dispose
hard to unallocate it?
can I unallocate it with the pointer?
because those pointers won't be going away
Nope
You need the dispose handle otherwise unity will complain that you're leaking memory
Because that's how it checks
the AtomicSafetyHandle?
DisposeSentinel
I see
this is what unity currently uses for dispose checking (in 1.0 this will change)
what if I don't create NativeList's and grab their pointers, and just create UnsafeLists?
^
heh, ok, I didn't realize initially there would be a difference
is it possible to deallocate/dispose UnsafeLists on my own then?
i still don't recommend using a collection in there over a multi hash map
unless you very specifically need to maintain order
you can just call dispose on it
cool.
honestly I'm mostly spooked about how people have reported that it's kinda slow
because I'm ignorant mostly
i haven't done this kind of programming since college
feels like C++ all over again
except I think DOTS is trying to be more like C, right?
object oriented programming be damned and all that
thanks for the help
i really hate necro bumping, but imma necrobump, sorry....
hi i'm not sure what you mean, you can use math.clamp() and you can use if statements inside entity foreach loops with burst
just wondering, say i want something to always be above 0, should i use math.clamp() or just use an if statement saying that if it is below 0 then set it to 0, which is more performant, does that make more sense?
ah.. i'd assume that using math.clamp() would be faster as i think the Unity.Mathematics library has been written to be vectorizable and in line with burst compilation
ok thank you so much, once ive got my code running nicely, ill probably test both and see if i can find any noticeable difference!
If it's just above 0 you should use math.max(value, 0)
oh ok, thank you so much!
weird...calling void* ptr = new UnsafeList(Allocator.Persistent).Ptr is just returning memory address 0x00000000
you dont need to do that for unsafelist
just store it in the hashmap
also dont use that version
oh I will be, i'm just doing that one line above
void* ptr = new UnsafeList<int>(1,Allocator.Persistent).Ptr;
myMap.Add(index, new IntPtr(ptr));
use the generic
and yeah, i forgot the generic
just make it NativeHashMap<int, UnsafeList<int>>
oh, heh
(again i don't recommend doing this but that's up to you)
just make sure you write the list back to the hashmap when you make changes to it
I see. and that's because i'm not accessing the UnsafeList by reference?
yep it's just a struct
if I used pointers like I was doing initially, wouldn't that mean I could skip that step?
you cant get the ptr from the unsafe list though
you'd hvae to malloc a container the size of an unsafelist
write a new list to it
then use that poniter
because it will change on resize
if you add an element, old pointer will be disposed and new memory allocated
no? I see. I thought the .Ptr method would have been a pointer to the start of the UnsafeList, essentially, and it would handle itself internally
when you change capacity (i.e. add an element)
Ptr is rewritten to a new value (line 387 UnsafeList)
in Realloc<U>
so the pointer your holding is now invalid memory
Ptr = newPointer;```
because it's been disposed
interesting, for me line 252 is where Resize is
i can tell you're not on latest because you're calling it NativeHashMap
and that's been deprecated and using it is now a compile error
yeah i'm not
[StructLayout(LayoutKind.Sequential)]
[NativeContainer]
public unsafe struct NativeHashMap<TKey, TValue>```
anyway, I can see what you are saying about the pointer being reset after a new memory allocation
I will try the NativeMultiHashMap once again
though I'm still confused on how to add multiple values to the same key to it
it says calling .Add when a key already exists will throw an exception
which makes sense for a Dictionary, but with the way this thing works, it seems confusing
Add(key, value1)
Add(key, value2)
Add(key, value3)
so that doesn't throw an exception?
my docs say it would. that stinks.
You're using wrong version
private static NativeMultiHashMap<int, int> _testMap = new NativeMultiHashMap<int, int>();
Well you're looking at wrong documention
i mean I could just try and find out, docs be damned
Because that's the documentation for native hash map
well thanks Jetbrains Rider intellisense
The native multi hash map is different
This code obviously doesn't work though
You havent allocated it
oh right, yeah I keep forgetting to put that in there
ok internet dropped for a little so was on phone
but i wanted to post htis
/// Adds a new key-value pair.
/// </summary>
/// <remarks>
/// If a key-value pair with this key is already present, an additional separate key-value pair is added.
/// </remarks>
/// <param name="key">The key to add.</param>
/// <param name="item">The value to add.</param>
public void Add(TKey key, TValue item)
{
CheckWrite();
m_MultiHashMapData.Add(key, item);
}```
oh right, I forgot these "docs" just are generated from method comments
must be a version difference, code is the same but comments are different
/// <summary>
/// Add an element with the specified key and value into the container. If the key already exist an ArgumentException will be thrown.
/// </summary>
/// <param name="key">The key of the element to add.</param>
/// <param name="item">The value of the element to add.</param>
public void Add(TKey key, TValue item)
{
CheckWrite();
m_MultiHashMapData.Add(key, item);
}
Could it be a problem if I have different components which differ in name only?
Does DOTS take care of not mistaking one for the other?
I upgraded burst to 1.7.3 but I have an error again.
Assets\Scripts\ECS\Shared\Components\RealPosition.cs(1,1): error SGICE004: Seeing this error indicates a bug in the dots compiler. We'd appreciate a bug report (About->Report a Bug...). Thnx! <3 System.IO.IOException: Cannot create 'F:\Unity Projects\PiscesRTS2021\Temp\GeneratedCode\SharedBetweenWorlds' because a file or directory with the same name already exists.
Is this the cache bug? I added back the asmdefs so it could be caused by that π€·ββοΈ
I just encountered something odd
First I used a component which had an Entity field but for some reason its index changed when it was moved it between worlds.
Now I'm using a component with an Index and Version field and it's working fine. π€
what if that entity already existed in the world you were moving from
Is there any equivalent to the string type usable in DOTS yet? for example, NativeList<string> where string is some other DOTS friendly type?
FixedStringX
is this bleeding edge stuff?
oh, where X is a number π
so FixedString32 would hold, 16 characters?
assuming a char is 2 bytes
you are a fountain of knowledge tertle, thanks
it stores UTF-8 which are 1-4 bytes depending on character
for regular characters that'd be 1 byte each
and it has 2 bytes for length
and 1 byte for null termination
hence 29+2+1=32
my strings can get pretty long, I guess I could hash them to make unique, smaller strings of more predictable characters
it goes up to 4096
but in general it's just a poor idea to store strings in burst
and very rarely unneeded
like, it's not exactly performant
yeah, in my case i'm keeping a lookup table for "string"->integer, and going to be doing most of my operations in the integer containers
unfortunately the lookup table is necessary, but I can do that part outside of burst I guess
I'm currently syncing up my presentation world entities with the simulation world entities by storing the entity id and index in components.
The entity indexes are also updated appropriately to not loose any 'references'.
I imagine that this will fall apart once entities are added or removed in the simulation world, because entity ids are reused as far as I know.
This could probably be better solved by using the EntityRemapping utilities, but I don't understand how they are supposed to work.
I read a bit in this article https://gametorrahod.com/entity-remapping/ but I don't get it π€¨
So my current line of thought is that I could instantiate all entities that could possibly 'exist' at the start of the game and add a component to them which differenciates entities which 'are dead' from those that aren't. This way, entity IDs should always stay the same even if entities are 'destroyed'.
What do you guys think? Could entity remapping utilities help me out here? How do they work? π€
no
oh
presentation world is for pretty movement of everything + rendering
and the simulation world is for doing all the calculations that actually matter and need to be deterministic
ooof
that would be hell of a headache to sync that
because in fact, it's double simulation
So far it's not so bad but the entity id stuff worries me
well sir
it's not fast
what you are looking for
this kind of stuff is meant for save/loading
and things like that
not for runtime
Have you worked with the entity remapping utils before?
yeah
Guess I'll go for the IDontExistComponent approach then
but it was save/load and I literally remapped through byte array of chunk's component data
kek
How slow was it? I would only need to do remapping once or twice every 33ms
well
it might take about the same time
kek
probably depends on amount of data
in short what you want is simply create dictionary of old entity/new entity pair
and when you create new entities you just swap old with new
during remapping
can be even done manually
IDK, perhaps my current solution will even work. It's just too confusing for me to think about much more π
sir
what if instead of having 2 worlds
you'll your long running jobs in one
you'll just have to copy all data for jobs
before running them
and keep JobHandle outside of Dependency system
once they are done you just apply all data back to entities
that would probably be faster than copying entities
Good thinking, if my current approach won't work I'll give this a try π
your current approach is just meant to cause pain
I'm moving entities. Only some components are copied
I swear, coding in binary would be easier
it's still moving large amount of data beween memory
which is costly
and which is way more costly then simply copying data before job
It's been a long day and i think i'm missing something obvious - any idea why this collision job isn't running?
you need to add input dependency to build physics world
_buildPhysicsWorld.AddInputDependencyToComplete(Dependency);
like rtype?
how many units?
are you making a rimworld clone? xD
i wouldn't dare π
Hmm doesn't seem to make any difference..
They don't use that in ECS Physics samples either but those could be out of date
is it possible to have a burst compiled static method return a value, or do I have to do that inside of Burst compiled struct jobs only?
So it depends on the number of players but probably not more than 1000 units per player.
You could write a non-burst static method which returns a value and run a burst-job within the method.
very cool, like supreme commander. did you find ECS easier to manage all that?
So far it's been really challenging. It might get easier with time. I prefer ECS for the 'free' extra performance.
I'm going more for a C&C Tib Wars 3 kinda game π
mmm, i couldn't get into it and i need to sim ecosystem in the background, i was thinking of doing it on there gpu instead of ecs
oh gotcha, is navigation a challenge in ECS?
haven't got to that part I'm still very much in the beginning. That's going to be a challenge for sure
have you writte compute shaders before?
If I pass in a NativeList to the burst method and write to it, does that data get written to the same NativeList that I can access from the non-burst method?
I think ECS / Burst is much simpler than compute shaders and extremely performant if used correctly @elfin spire
but if you already have experience with that kind of thing its of course an interesting option
i wrote an influence map
0.51 a step up? in the past ecs had too many constraints for me. was in fact thinking keeping it mono when the creatures appear onscreen, centralized mono on flocks
yes something like this could be possible
static List<MyType> MyStaticMethod(List<MyType> list) {
NativeList<MyType> nonce = list.ToNativeList(Allocator.Temp);
var job = new MyJob { listToBeWorkedOn = nonce }
job.Run();
var result = nonce.toList();
nonce.Dispose();
return result;
}
```
Of course converting between native container and container isn't performant. Just an example
Its a step up but not a big step imho. Some things are a bit more convenient but that's mostly about it.
what's the biggest hurdle still?
besides no animation no nav
lol
ECS instead of OOP is the main hurdle for me π€·ββοΈ
then your setup with shapes/bodies is wrong probably
imo 51 is mostly behind the scenes changes
did you already write the core game loop in mono before you started converting to ecs?
No I wrote everything with ECS in mind from the start
and it's taking you 10x as long uh (did for me before i gave up) i wonder if ecs are well suited only for already well established game loops
he is doing some hacky double world experiment, so it's not fair
here the way it works kek
xd
I agree with that graph
this graph is my hope ^^
and yolo reaches vertical tangent as soon as you need to fix bugs after release
I am currently doing very little project and it's already beating OOP with effort
even though it barely requires scale
since my average amount of entities is 30-50
kek
ah its sad to see unity devs on twitter rt critical tweets of the current situation, its like seeing smoke signals from a desert island π
what's up? Unity is in trouble?
@safe lintel I'd like to see some screens/vids of your shooter. DM me if you don't want to post them public π
yeah the acquisition+ layoffs is really bad fking timing. also that the team that was essentially making one of the first functional games (gigaya) was laid off is bad optica no matter how you put it.
Is anyone here using anything from the Latios framework?
@viral sonnet https://gfycat.com/cleanbetterkid this is back when the project was all monobehaviours(ugh 2018). sadly its been a bit of a shambles since I got sidetracked to dots(the animation/lackof being kind of a persistent thorn that I have been reworked one too many times and is getting old)
if you go to gfycat.com/@safe lintel you can see chronologically random dev gifs(mostly bugs heh) of how everything has sort of unravelled since lol
cool, i'll check it out
you're remaking this in ecs?
uh I like it! nice progress. what the hell took the wrong link before. https://gfycat.com/unitedpoliticalasianporcupine
really! what type? i made a proto of creator god game in a week in mono and i don't see how i'd done it in ecs even preplanning everything
a bit like flappy bird by gameplay
this is cool! i can imagine hundreds of them dismembered flopping around. puppet physics exists in ecs uh
Is there a way to make custom struct show up in the inspector?
Implementing IFormattable doesn't seem to cut it.
Is it System.Serializable or DebuggerTypeProxy which could make this possible?
This now works, even without the Serializable attribute
public struct sfloat : IEquatable<sfloat>, IComparable<sfloat>, IComparable, IFormattable
{
#if UNITY_EDITOR
public float _value;
#endif
/// <summary>
/// Raw byte representation of an sfloat number
/// </summary>
private readonly uint rawValue;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private sfloat(uint raw)
{
rawValue = raw;
#if UNITY_EDITOR
_value = ReinterpretIntToFloat32(raw);
#endif
}
```
@elfin spire its basically already remade in ecs, but currently I think my 5th rewrite of the animation/characters for it
i mean you are in too deep now but have you ever thought about just replacing them with sprites?
sprites for characters just arent my jam π
I really just want the dots animation package to get back to public previews, its really my only need now as far as dots related things
fair enough π yeah, but even with entities 1.0 it's still far off :/
if you ever watched the gdc doom2016 talks on animation for it, they go into some interesting details how animation drives ai and vice versa for correcting behaviours and what not, and dataflowgraph+ecs was shaping into a pretty performant way of doing that. I mean you can do that now but without deep burst ecs integration so I dont think its really super viable for hordes of enemies
When designing systems would you consider optimizing for chunk utilization over random accesses?
animation using vertex textures? even in mono that's what I use for crowds
its back to regular mecanim, not sure of a way to do hitbox/locational/ragdoll damage with gpu animation(also not sure how to blend vertex anims)
maybe in the same way the entity picker works. render with a shader that has the ids as color output. then project the raycast to the correct pixel.
That looks really nice mate, the mood/feels is top notch
thanks, that was the only time it looked so cohesive π₯²
@viral sonnet could be a cool idea for location damage but not sure about the ragdolling
all this talk from john riccitiello gave me some new ideas. i should probably pull my open source asset from the store. make it closed source, bundle it with an installer that has ads and some great software included that speeds up your pc and makes it safe and secure. also make it a 1-seat license with no additional support, only with a perpetual annualy license and every new feature that gets requested is DLC content, available as upgrade package. man, if we would all be great business man like john riccitiello, the world would be so much better and i would be swimming in money.
the sad state of mobile is that without a budget you have nearly 0 downloads. this talk about monetization is so utterly dumb and ignorant. also, ad money is joke.
the moment you cram enough ads into a loop to get somewhere, users will cry about it in the review section with 1 star reviews. if you make it "fair" you won't have enough impressions.
it all seems to me like a pyramid scheme, 90%+ will fail horribly
and don't get me started on the 30% asset store cut ... meh, enough venting π
Unity has been hemorrhaging money according to their quarterly reports. Some parts due to their questionable acquisitions, other parts due to their stalled development (dots hello?). Unfortunately Unity is not a charity and needs a net positive income stream. I'm thinking that if DOTS doesnt pan out within the next 2 years, unity is gonna implode.
They're chucking 750M into RnD and a significant chunk of that is probably going into DOTS development. Remember that talk by the dev about how everyone in the company were required to take workshops on how DOTS function? I think unity has put a lot riding on the success of DOTS.
Oh, unity will live regardless of the performance of DOTS on the market. As an mobile advertising company if it falls flat though.
I hate to say it but the merger with ironsource is possibly their smartest acquisition yet. Smarter than Weta at the minimum. This guarantees their continuation even if the editor stops developmeny
Its like the development of Java post Oracle acquisition. Java is now a law firm.
is it really survival for a company if their continuation is worth 1/4 of their market?
Its still millions of dollars and not complete liquidation. It's like blockbuster. Theres still a store up in alaska.
there's only 1 blockbuster left and it's in oregon
and it's not the original company - it's just a privately owned franchise
so that isn't a great example
Oracle and java is probably the best example. In that case, if I remember correctly it actually made the shareholders extremely happy. Oracle is worth a lot more following their purchase of Sun in 2009. Very bad for the development industry though until Microsoft stepped up with c#.
The same can possibly happen with Unity. Game editor development is not that profitable. Seeing how unity has lost money every quarter since they started publishing financial data. Haven't checked Unreal but I doubt they're profitable either .
yeah but that doesn't seem like a good example either? that's like Unity buying iron source and then not selling any advertising anymore ^_^'
most of oracles money comes from cloud computing and database licensing
i don't disagree with your assessment of engines and lack of profits atm though
124m 2018, 97m 2019, 100m 2020 revenue
for epic engine
the apple vs epic got all this disclosed π
unity doing about 1.2B in revenue in last year (4 qtrs being 320m, 315m, 286m, 273m)
No way they're 1/2 to 1/3 of unity.
i dont know what to tell you, that's all the made on unreal engine
400m on the epic store
Is that annual revenue for unreal?
3b on fortnite
Holy shit. They practically give the engine away for free. Well it is a free limit of 1M
yeah
then it's only 5%
you make 1 billion you only pay $50m
which means people with more than 1mill rev generated a about $2bill in revenue on epic games
that doesn't sound too farfetched to me
also don't forget unity numbers aren't just the engine licensing
it's advertising, services, etc
Yea, given all the AAA titles using it.
Iirc, unith makes most of its revenue from mobile game advertisements and taking a cut.
Which puts the CEO's comments into context. Mobile developers not imbedding ads and in app purchases into their game directly hurts Unity's bottom line.
Create Solutions revenue was $99.9 million, an increase of 49%;
Operate Solutions revenue was $194.6 million, an increase of 45%;
Strategic Partnerships and Other revenue was $21.3 million
Operate is their advertising etc
so yeah hefty chunk
this was final qtr last year
it's more than just advertising but it's wear it fits - includes all their services
If unity could take over mobile game development. Sure their reputation will go from the gutter straight to advanced decomposition as they link themselves to shovel ware. But they'll be flush with cash.
Rip the bandaid off. Drop PC game engine development. Go all in on being the universal mobile game engine with in app purchases and advertisement solutions. Mobile games apparently dwarf PC and Console markets combined by orders of magnitude.
If unity could take over mobile game development.
how do they not already own it? seems to be at 50-61%
That wouldn't be unity anymore
"Around 65% of everything developed to operate on devices for VR or AR or any XR-based gadgets are made in Unity. Around 50% of all the games created for Nintendo's devices are developed using Unity. Figures regarding this fall slightly below that for Sony and Microsoft. However, combined, it's more than 50%."```
it's not shocking at all they bought an advertising tech company
what's shocking is they bought one with a terrible reputation and then paid a huge premium
the market did not react well to the news
To be fair, outside of google adsense and facebook, you only have bottom feeders in terms of internet reputation
i'm kind of hoping they just take the cool AR tech etc that iron source has
and then throw out all the BS
but what i'm really hoping is their share price tanks a bit more and investors find a new CEO
Its fallen 80% since it's high. 30% down from initial IPO. I dont know how far down the stock needs to go before shareholders revolt.
Oh 30 as in 30 dollars. Read it wrong. Yea that's a disaster.
now to be fair, all tech stocks have been smashed recently
but unity started way before the downturn
anyway we took this channel way off-topic
hope it works out for them, i've put a lot of effort into learning dots and cbf learning unreal ^_^'
Yea. Dots is great and open source. I've personally transitioned to compute shaders for a large part of my needs. Not as flexible but I was basically number crunching floats in Burst anyways.
intentionally avoiding compute shaders for anything on my server
so i can the server without a gpu
saves a lot on hosting costs
Imagine multiplayer, ha.
Singleplayer all the way. No need to worry about networking in my life. It's so nice.
i never play single player games so it feels weird to make one
Mobile hotspot internet here. I can barely play multiplayer and usually just turn based ones
And compute shaders are so much faster. 64 lane wide wave fronts. With the new wave intrinsic, theres now even more flexibility (kinda) in parallel computing.
there's no doubt they're faster
I haven't found a use for them yet though. Instead twisting frag shaders and using vertex culling optimizations for performance boosts.
the thing i always say to people though, if you have a good looking game on 4k, you are much more likely to have free cpu cores
so performance is free
even if it's slower it's not costing you anything
i feel like this is something that is often overlooked
and people then wonder why they're getting stalls on cpu while it waits for gpu
CPU cores are used for things other than your game though. Like internet browsers that gobble up memory by the gigabytes.
Not nearly as much
i'm running 100,000,000 entities over 16 jobs 100% simd, no sync points
and i'm only using 60% of my cpu
While, if you disable hardware acceleration on browsers, only the game should be using the GPU.
these days you have way too much free cpu cores
Just open more tabs in chrome
Everything is chrome. Unless you're one of those firefox weirdos
I usually run video and tons of tabs in chrome while doing pretty much anything and CPU usage is rarely above 10 percent
firefox is amazing
Or that apple thing
when i had to leave firefox for chrome 12 years ago because it sucked in comparison i was sad
but now they're back and better
I personally use 4 browsers xD
3 chroms and firefox
And none of them eat CPU enough
(does chrome support plugins on mobile yet? one of the reasons i switched off)
So I'd prefer jobs over compute shader
Discord is a chromium wrapper. Edge is a chromium fork. Chrome is chromium with google characteristics.
compute shaders are great. i just only use them if i don't have the send the data back to the cpu.
Also the reason I prefer jobs over gpu - way easier debugging
(or for like really large noise because it's just that much faster)
Debugging shader I agree is such a pain. WHY IS THIS PIXEL RED??
Just toggle off burst and insert breakpoint
you know can break point with burst on right?
i swear no one knows this
cant step through math functions with Burst on though?
Do you need to do anything specific?
turn on that, and instead of hooking up a managed debugger hook up a native one
Huh
Ewww, visual studio
Rider has a native debugger now
But
I have not been able to get it to work with burst
I can hook it up to native libraries burst is calling
but yeah, when i really want to debug things i just have VS hooked up as a native debugger for burst code
and rider hooked up managed for non-burst code
then i can break wherever i want
Or just... turn off burst?
i have an algorithm in my project that takes 1 second to run with burst on
or 180 seconds (3min) with burst off
turning off burst is not a good idea sometimes
that and have you tried to use the new Dots Hierarchy with burst off and any decent size number of entities?
just locks up the editor for a minute
ALSO burst math operations on floats return different values than mono math operations on floats
so you're not even debugging the same code
Hrm. True. Debugging and step through is very helpful. Imagine if shaders could do something similar.
Do I understand correctly that DestroyEntity is only removing all components except SystemState ones?
yes
system stats will be left
the entity will only actually be destroyed once all system states are removed
yeah, but on next frame
could be 100 frames later
no destruction anymore?
depends entire when you clear it up
no no no
what I am trying to figure out
is whether there's anything that gets created
that keeps track of that entity after creation
I mean, after calling Destroy on it
no
so, it's as simple as removing all components?
yes
and by default if you remove all components manually
entity is destroyed by iteslf
without Destroy call?
no
at least they didn't used to be
btw
if you call Destroy on frame X
and then on next frame Y you add some components
will they be affected in any way?
or Destroy is only affecting moment it's called?
ok so if you really want to know what's going on
when you call destroy it's moved to an archetype and one of the flags is called
SystemStateCleanupNeeded
internal enum ArchetypeFlags : ushort
{
SystemStateCleanupComplete = 1,
SystemStateCleanupNeeded = 2,```
if you have system states it sets that flag instead of destroying entity
and once all system states are set the entity is destroyed
you can't just add to it after it's considered a destroyed entity
yeah, but if you have state comps on it
for a while
and then you add some components to it
I wonder about how it'll work out
since I want to use DestroyEntity as a tool to transform entity into smth else
like
why would you do it that way....
Entity used to be a character, but after it died it's transformed into memory of character
you may as well just write to a random memory address ^_^'
just set the archetype to something new
yeah, but you wouldn't know about all state components
EntityManager.SetArchetype();
and what if some of them will be actually required in order for correct "transformation"?
then you're using system states wrong
well, or maybe that's just another way to use them, kek
we do this in our game btw, we convert actors from 1 type to another
so they can 'grow' up
(and it was a terrible idea - probably going to have to rewrite the entire system next week to fix issues with it that are blocking new features)
so, do you know what actually happens in that case or I better try and test it?
public void DestroyEntityDuringStructuralChange(UnsafeCachedChunkList cache,
UnsafeMatchingArchetypePtrList archetypeList, EntityQueryFilter filter,
in SystemHandleUntyped originSystem = default)
{
if (archetypeList.Length == 0)
return;
#if ENABLE_PROFILER
using (var scope = StructuralChangesProfiler.BeginDestroyEntity(m_WorldUnmanaged))
#endif
using (var chunks = ChunkIterationUtility.CreateArchetypeChunkArray(cache, archetypeList, Allocator.TempJob,
ref filter, DependencyManager))
{
var errorEntity = Entity.Null;
var errorReferencedEntity = Entity.Null;
if (chunks.Length > 0)
{
EntityComponentStore->AssertWillDestroyAllInLinkedEntityGroup(chunks,
GetBufferTypeHandle<LinkedEntityGroup>(false), ref errorEntity, ref errorReferencedEntity);
// #todo @macton DestroyEntities should support IJobChunk. But internal writes need to be handled.
if (errorEntity == Entity.Null)
{
#if (UNITY_EDITOR || DEVELOPMENT_BUILD) && !DISABLE_ENTITIES_JOURNALING
EntitiesJournaling.RecordDestroyEntity(in m_WorldUnmanaged, in originSystem, (ArchetypeChunk*) chunks.GetUnsafeReadOnlyPtr(), chunks.Length);
#endif
RunDestroyChunks(chunks);
}
else
{
EntityComponentStore->ThrowDestroyEntityError(errorEntity, errorReferencedEntity);
}
}
}
}
in source it's pretty messed
i have never tried to add components to a destroyed entity
but at the very least they will exist in a separate chunk
or they will mark not destroyed entities as destroyed
would be my guess if it just doesn't error
I see, I guess gotta test to figure
allthought I don't get why you think it's wrong way of using state comps
you think calling Destroy and then trying to undestroy something is a good idea?
you are basically using undefined behaviour that Unity could change at any point
state components are very specifically designed not to be transferred (hence they aren't Instantiated or storable in conversion). you are effectively bypassing this and transferring them
is there any other way to call Remove components on literally all, but state?
yes
SetArchetype
but that would affect state components too, no?
you just keep the state components in the new archetype
but what if I don't know them
let's say some modder will add new state component that will be kept on entity
it will be excluded
Archetype.GetComponentTypes()
thus making modder unable to add behaviour to such "death" mechanic
and that would make such calls kind of slow, since I'd have to first figure out archetype and etc
don't really understand what's slow about it when the whole thing is burstable
it's really not much different to what Destroy is doing
except without a bunch of extra checks
you could even convert to your new memory of a character
in a single structural change
instead of potentially dozens/hundreds
as you just add components 1 at a time
this is interesting but i preferred the conversation about unity revenue π
allthough I haven't ever managed to make it work
hmmm
so how would you generally burst code like that?
well so you can actually pass entity manager into jobs
since ForEach loop would require WithStructuralChanges
if you call EntityManager here
which would make it unbursted
but it has invalid safety issues
you could just pass it to a job struct and Run() it
and still have [BurstCompile]?
i cant remember if this works atm i think it does
personally i just have a bunch of wrappers
I guess I'll have to check
for entity component store
to avoid these invalid safety issues
i.e. my classic SharedComponentDataFromIndex
many of these are safe in threads for reading
but yeah for any writing still needs to be mainthread
it's ok, as long as it's bursted
alternatively they might have fixed ExclusiveEntityTransaction in 0.51
i havent actually tested
if they have fixed it then that's what you should be using as that's how you're meant to use entity manager in jobs
in works in threads
(not parallel)
// do work
this.EntityManager.EndExclusiveEntityTransaction();```
it's just a wrapper of EntityManager
hmm though it doesn't have set archetype π₯²
oh wait that doesn't matter as you can just use the EM
(they broke this in 0.50 though and i haven't tested it was fixed)
do let me know if your Destroy plan works i'm curious
all right, will do
this is still throwing me
the job is showing in the profiler, but it's not doing the debug print
you don't have any collisions
i do
and you marked the colliders to raise events?
no
then it won't fire any events!
I mentioned it earlier though π
just relying on conversion from std colliders to physics shape so i hadn't looked at it specifically
well not quite π
that's very vague
well yeah, because it can be either filter options or material
to be fair, i should have realised, bit of a silly oversight
btw I don't even remember whether kinematic - kinematic raise events
i ended up switching to a different approach as i didn't realllllyy want to poll all those potential collisions, but i think i'm going to need it
well yeah you shouldn't mark everything as raising events
but you can crunch quite a few collisions/frame without too much effort
basically it's a ragdoll setup, so there's 14 bones per ragdoll
i was aiming to obviously have as many ragdolls as possible in theory
implement first, optimize later!
i'm not sure if raising collision events would scale for example say you have a million rigidbodies, but only ten collide, would the impact be negligable, or is there overhead associated with just having them capable of raising events
i'm thinking potential cache/memory overhead as it will strap extra data to the internal physics system jobs
but yeah you're absolutely right, optimize later
million rigidbodies
i can tell you that you won't have a million dynamic physics objects
haha this is true, but hypothetically
anybody looked in detail at the ecs Physics samples implementation of stateful collisions at all?
it seems nice, but as with everything in ECS samples they seem to write code in the most abstract way to demonstrate relatively simple concepts
classes with static methods and interfaces scattered around that try to handle all of the demo cases, and lots of generics
rather than, just put everything for each case in a group of systems and set of components/buffers for that case
just makes it a bit of a headache to deconstruct
making the transition from mono's with OnCollisionEnter OnCollisionExit etc to DOTS physics i think needs to be simpler
obviously the physics engine is stateless, so that's always going to involve getting into the weeds on the mechanics of how to set that up
but i think the physics samples could be more approachable, in order to ease that transition
as it is one of those really obvious, key parts of many games
if you want stateful events
you s imply import their implementation system
aaaaand that's it
then you just call different jobs
on stateful events buffer
how du mean?
that file
with stateful events
it's not just sample
it's fully working solution
just import it into your porject
kek
well it's several files tbh
authoring component with bool for collect details
stateful event buffer / collector system
buffer component and methods
etc
really i just want to understand how/what/why the code they've written, and do my own thing
well, they literally just go over all trigger and collision events
write a dictionary of those that already triggered previously and sort them
if event doesn't exist in hashmap - it's Enter state
if it exists and triggers again - it's stay state
if it hasn't triggered since last frame - it's exit state
system is somewhat simple on concept but complex on implementation
so easier just to import Unity one
exactly
well this is obviously an option, but i do think the Samples exist as a guide/examples of how common use cases can be implemented, and in some cases how to properly use the core API's
the way they've written it, it's almost as if they've imposed an OOP structure onto the DOD framework, with the generics and struct interfaces etc
so while i get it, it's maybe ultimately how you'd end up building that kind of system, it's also a bit of a rats nest to deconstruct
Hello guys, can I ask you something in Unity ECS? Why should components have no logic? I am not saying that they should have all the code of the game, but is it a problem if a component has helper functions?
no it's not, but generally your components should be as simple as raw data
so that other systems might use it however they want
hello guys, i have a question about the job system. can you pass structs containing blittable types into jobs ?
things like Vector3, float3
or should I pass their components separated into 3 arrays ?
good to know, thank you π
protected override void OnCreate()
{
_spaceCameraSystem = World.GetExistingSystem<SpaceCameraSystem>();
_curSystem = GetEntityQuery(ComponentType.ReadOnly<StarNormal>(),
ComponentType.ReadOnly<StarShared>(),
ComponentType.ReadOnly<DisableRendering>());
_allSystems = EntityManager.CreateEntityQuery(ComponentType.ReadOnly<StarNormal>(),
ComponentType.ReadOnly<StarShared>(),
ComponentType.Exclude<DisableRendering>());
_starsQuery = GetEntityQuery(ComponentType.ReadOnly<StarTag.Child>(),
ComponentType.ReadOnly<StarShared>());
_fixQuery = GetEntityQuery(typeof(FixRendering));
RequireForUpdate(_fixQuery);
}
I don't get it.
I set requirment for update and for some reason it requires all queries for update
for some reason it doesn't run
even though all queries are filled
ok nvm, it's running
is there a way to ensure that my system's OnCreate is called before some other's system?
Are these two functionally equivalent? ```cs
Dependency = JobHandle.CombineDependencies(new SomeJob {
// etc
}.Schedule(someQuery), Dependency);
Dependency = new SomeJob {
// etc
}.Schedule(someQuery, Dependency);```
no
whatever Job returns is ready Dependency
you don't need to combine it with previous
it's useless work
even if I had scheduled a job before this one and assigned the handle to dependency?
it's pretty confusing, so potentially you'll have to figure out errors anyway, kek
but as long as you pass SystemBase's Dependency somewhere in that chain
it should be fine
one more question about Job system
do stackallocs incur performance penalties ?
and just to confirm, is allocating simple arrays bad for job performance regardless of their size ?
just want to use a couple of small int buffers inside a job for convinience
not sure what you mean by simple arrays
the same performance characteristics as always apply, memory allocation takes time, the more you need, the longer it takes. temp memory is quite fast but there's still some overhead. using pre-exisiting memory is the fastest you can do. nativearray/list can be reused for a job thread and only allocated once which speeds things up quite a bit.
when the size is always the same for each thread, allocate an array before the for loop and check for IsCreated. for unknown sizes, allocate a list, set the length via Resize and cast to nativeArray
Rendermesh.mesh.SetTriangles() doesn't support NativeArray<int>()'s. Why would this be? How are you supposed to set the triangles on an entity? Thanks!
yet setvertices and setUVs does (for appropriate floats)
Use SetIndices
Oh? What's that??
SetTriangles is dated
just choose MeshTopology.Triangles
but SetIndices also lets you do quads etc if you have different mesh formats
Thank you for the quick response! I appreciate it.
I wanted to use the BuildConfiguration search window for some of my own UI so I debugged what was wrong with the search in 0.51. If anyone is being annoyed with the build config window in 0.51 and wants to fix it just add m_List.RefreshItems(); to SetCurrentSelectionNode in SearchView.cs
{
m_CurrentNode = node;
m_List.itemsSource = m_CurrentNode.Children;
m_ReturnButton.text = m_CurrentNode.Value.Name;
m_List.RefreshItems(); // Add this```
Any idea about static components?
If I create entity with fixed archetype that won't change until world is destroyed. For purpose of storing global values like current Tick, or input and etc
Can I somehow get a pointer/reference to it, that will last?
goal is to avoid sync points by calling EntityManager
are you talking about singleton components?
yeah
I need a way to be able to access them randomly in any system without a sync point
too much code, kek
also annoying part is that I'll have to access it on every iteration
it's only choice to be safe without a sync point
you can do it per chunk
yeah, per chunk is also per iteration
if your data is actually static then you can just use EntityManager.GetComponetData
but then why not just store data locally
so what
you mean literally using System reference/static field?
i mean just OnStartRunning()
myComponentvalue = GetSingleton<MyComponent>()
and then just use that value from then out
In what cases that call will cause a sync point?
Only if this type is part of dependency?
it will only cause a sync point on the handles that are writing to it
it doesn't sync point the entire project
Is that how you access input struct?
pretty sure i just pass entity to job
and use componentdatafromentity
considering input is only for the player
you don't have an iteration issue
because there is only 1 iteration of the local player ^_^'
what kind of data is it? i'm lazy and have tick as a static uint π
no system references = good time
Yeah
singleton entities have their place but sometimes they are just overengineering
Refactoring whole project currently because of it
I decided to work through a route of event entities
If I have some action that needs to be done
I just create entity with component with settings
And whatever system that makes action reacts on it and then clears query
Makes code so much more clear
But probably at a cost of perfomance
depends how many you're creating
event entities are great for architecture, i have all my network etc setup with them
just not so good for gameplay performance
bummer we can't add something to unmanaged World. that way we could add data types like time, version etc...
Sad times of c#
Allthough
Maybe you can grab source
And just dew it hehehe
Would be kind of pog if they could implement some kind of codegen for it
So when you declare some strcut with special interface
It'll get adsigned as field to world
they would just need to make it partial and we could add all kinds of stuff
world is partial, it's mostly a wrapper to WorldUnmanaged which is sadly not partial
like with any other partial class/struct. just make new file and write a new class/struct
But it just wouldn't give me the world
on compilation they all get added together.
nah, not when used with partial.
(are you matching namespaces?)
But I got pretty sure it wasn't possible
If only I knew it was possible
I could avoid so many troubles with global referencrs
i have bundled up a looot of methods for a big job with partials. now i have split it into a nice amount of files
any reason to just not use extension methods?
(apart from storing state i guess?)
Entity references kek, so you don't have to call getsingleton
too many parameters π
i see no downside of partials or upside of extensions. yet extensions are annoying with parameters
Oh man, that would be a game changer
i had them in the beginning
i mean, it's a job and i have lots of access to different arrays
totally doable with asmref
that said i think this is a terrible idea in general π
that's not what we want to hear!
i can see some usefulness that wouldn't be too gross (things like time)
Asmref? What would you need with ir?
you can't extend a partial from another assembly
exactly, my only idea for a use case is saving the tick in world
easy access and no static to some other class
funny enough at one point i had a huge hate for World.Time
you can't really 'save' it or manipulate it