#archived-dots
1 messages ยท Page 113 of 1
Though its good if you want to be ahead of the curve to check in on the previews... but not sure why so many people are trying to actually dev with them like they are production ready.
If your project has a 1+ year time horizon I think now is a good time to cut your teeth with dots. Starting new projects with tech that is clearly going to be legacy in a couple years has its disadvantages as well.
The DOTS API doesn't really scare me. If the concepts are sound that's all I really care about. A moving target for an API is probably ill advised but if the alternative is only being able to render 5% of what I could with DOTS then the choice is fairly simple.
I also think the comment "basic programming tasks crushingly difficult" totally depends on your background. If your primarily a coder with a background in systems design its actually quite refreshing. If you are used to using unity with minimal low level coding then I can see that.
anyone feel dots audio is remotely ready to use? last I checked it was rough as hell
there's one big issue with that argument
there really isn't solid alternative for netcode built-in to unity right now
all you got basically are 3rd party offerings and half baked built-in solution
so when there's a promise of better, many are willing to take a gamble (altho we all here probably can agree it's super early atm)
and there's a notable risk on running 3rd party offerings too, it's not like it's some dream deal
no framework even official is going to be a walk in the park
hmm, if i had a character controller using mono how would I get it to collide with the ground? which gets entitied...
one thing with the 3rd party stuff is that they always lag behind the releases
and the direction unity is moving at, there's going to always be a ton of outdated 3rd party dots packages out there
yeah which is why you should pick and choose what other peoples code your going to depend on
asset publishers can't even keep up because there's no early access to upcoming previews
I do almost everything in house to get around that
yeah I don't really use 3rd party stuff anymore either
really prefer using built-in stuff
That conversation pretty much went where expected.
are there any dots-based multiplayer titles that have been announced and have shown their work? I would be curious to hear the stories from the trenches by people trying to actually get a title out.
i think personally i would be spending way longer learning c++ in unreal than the time spent learning dots
ue4's c++ is only tedious, it's not hard if you know c# well
and tedious because lacking c++ api docs
i dont consider myself thoroughly versed in c# either ๐
that being said, it's not like their netcode covers all use cases there either
they basically have super bloated char controller that embeds all client prediction stuff in it
and for the rest of engine, you can just replicate stuff normally
if you want to do client side prediction for other things, you are on your own again
my multi player game is based on dots transport
netcode as I know it is just a very specific game type strongly coded as a demo, its not really meant to be a generic system.
but not the high level framework they are building
I only needed a job compatible udp messaging lib so its a perfect fit
How far along are you?
released
cool, what's the name?
right now I'm reworking our voice network system a bit
eh, I dont like sharing it
got review bombed by haters
um, k. Not really going to get a lot of buzz like that, but your biz.
I'm finishing up a bit of work for a marketing round
so I'm just keeping it quiet till then
What is LavenderLavender is a community driven social sandbox centered around users expressing themselves and having a great time. We want our users to be able to create and share their ideas in an easy and intuitive manner. We support both VR and Desktop players together on t...
$19.99
all of our media is out of date
dots was worth it if you were wondering
just dont do everything in it
Looks cool, though not getting much of a sense of what kind of networking is involved
its a vr sandbox
its 100% multi player
compressing full body tracked avatars and networking them was fun in dots
looks neat. how many fully motion tracked clients can you have running around at once?
~100
this was from play testing last night
everything being driven from dots entities and what not
Create and customise your entire games UI though HTML, CSS, JS. (Check the games folder, BrowserAssets) that's a pretty cool feature @low tangle
yep
CEF
ah here we go, this was the other one https://streamable.com/hp8ef
not trying to spam this chat though
I'm always down to see cool stuff made with DOTS
I don't think anyone is going to complain if its on topic. its relevant to dots and netcode talk.
true true
How big should subscenes be? should you make it a single buolding?a few? is there a difference?
building*
i doubt it differs
yeah seems so
am i supposed to dispose of the array in the first function or it doesnt need it
I never tried such a thing but it shouldnt matter as long as you dispose it properly, also afaik you dont need to dispose Temp native containers, they will dispose themselves automatically
the NativeArray<int> is a struct that is a pointer to the unmanaged memory
you can just copy it like that
just dont forget to dispose it
oh June, congrats on releasing your game^^
hopefully mine will be released in 1-2 months as well ๐
tho mine is a small game compare to yours
Hi all! I'm learning DOTS and I've encountred a couple of issues regarding jobs that I don't know how to solve.
First, how can I use a SharedComponentData as filter in a JobForEach? I have a "Dead" tag to mark the entities ready to be destroyed, but, in order to iterate them in a job, I've had to declare it as ComponentData instead of SharedComponentData
SharedComponentDatas is more for.. very specific uses, you should use ComponentData in your case.
@sharp kayak
Also you probably dont need to learn jobs at first,
code monkey tutorials are pretty good imo
teaches the basics without jobs
is it ok to use static methods from a static class inside burst jobs
if the methods are purely functional and dont access static variables
Yes it's fine and Burst will happily make them run super fast
@digital scarab
@opaque ledge
Maybe I misunderstood the purpose of SharedComponentData. I assumed it was useful for components that don't change between entities. For that reason I used it for tags.
SCD is for separating entities by chunk for performance/filtering reasons https://docs.unity3d.com/Packages/com.unity.entities@0.6/manual/shared_component_data.html
Oooh, I understand. Thank you!
so, you could use dummy SCD just for forcing bunch of entities into same chunk?
never thought about using it that way
If you're not using it for the value comparison there's no point in using it over a normal tag component
Same effect
I was more of thinking about my use case where I have bunch of entities that I have to query components from using ComponentDataFromEntity
so if they are on the same chunk, it would result in less cache misses, right?
Maybe I'm not understanding the use case but adding a scd to them would just splinter them further from whatever archetype they were already in wouldn't it?
If you had two entities with two different archetypes, adding as single shared value to both of them just results in two new chunks
basically I have component data which I'd prefer all to be in the same entity but can't because need multiple same type components (can I now do this with fixedarray sorta thing?)
so far I've just added these components then into separate entities
but in the end, there's a strong relationship between these data elements
Couldn't you just use a dynamic buffer instead?
could
Where each element is a "component" as you're describing it
I guess I could just try to do some brute force test without and with it
it wont make two disjoint archtypes be in the same chunk though
only same sets
if you think of your data components as a 'stride' you can only have one kind of data in your chunk
you want to keep your strides minimal in order to get the most useful data in your chunk
a chunk is just a fancy byte pointer with whatever data you want to say it is
It sounds like all the entities have the same archetype, so scd will let them explicitly move related entities from within that archetype to their own chunk for specific processing.
i learned a little bit of C++ and after hearing this statement a chunk is just a fancy byte pointer with whatever data you want to say it is thought appears in the back of my head. Isn't all this ECS thing just reinventing the wheel? Or am i just too stupid, to see the whole picture?๐ค
there is quite a bit of stuff going on in the background, such as managing systems & their memory, clever alignment strategies this kind of stuff.
It's basically just a framework that you can use.
ECS is actually quite an old architecture too, it hasn't been invented recently
@warped trail As Life is Good said, it's not a new thing. Another thing is that it's definitely a regression in terms of abstraction compared to OOP. DOTS is definitely more close to C++, but that's exactly because it's a lot more performant in terms of data processing and memory layout. As for reinventing the wheel, Unity doesn't already have that kind of framework, so it's just their implementation of it.
been used a long time for mmo's and is a great way to get memory performance
I remember this thread quite fondly: https://www.gamedev.net/forums/topic/463508-outboard-component-based-entity-system-architecture/?page=1
As far as I know it was the birth of the ECS system Unity is adopting now, where they separate components, systems and worlds.
Or at the very least the first public discussion of it.
its even older than that really
remember reading a article on a mmo from 04 ish that used it
with ecs its in the details of how you manage them thats important
unity went with the rigid setup that lets you minimize memory and build a multi threaded safety system on top of which doesnt just work with each kind of ecs pattern
yeah, it must have been older, would be interesting reading something older
So I am trying out the net Entities 0.6 and I run into the issues that when I instantiate some of my entities that they don't have any component on them. Before the update it worked but now it doesn't anymore. Has anyone run into a similar issue?
my multi player game is based on dots transport
@low tangle
did you switch? thought you were using enet
Is it possible to set default value for GenerateAuthoring ?
I wanted something that would behave well inside the unity job system
I hadn't touched c interop inside of jobs yet so I went with unitys solution
I've done some c calls inside of jobs now for opus and its not bad, but I'm glad I used theirs for the networking
enet to transport was quite awhile ago
but it was easy since all network stuff was just entities
so I just had to go to the send receive systems and change from enet to transport deserialization
I used that same time to port to jobs using DataStreamWriter and reader
which is what transport uses
@mystic mountain That's where you would use the explicit conversion from a MonoBehavior instead
I see...
Is there a method which takes a prefab, converts it into an entity and returns it?
Not as far as I'm aware of, because the conversion happens right at the start of runtime in an internal system
GameObjectConversionUtility.ConvertGameObjectHierarchy()
Note it converts into a prefab entity, so you'll have to use entityManager/commandBuffer to instantiate it afterwards
you could RemoveComponent<Prefab>(ent) if it doesn't have children but you shouldnt
but yeah just instantiate it
How can i manually Update Unity.Physics systems?
@round summit What do you mean manually update?
I want to call BuildPhysicsWorld's OnUpdate myself i mean
And StepPhysicsWorld etc
For multiplayer purposes
Well, I'm not sure if there's some sort of API built for it. But you can always go into the source and look how they do it, disable that and then write it yourself
Since the source is available
ah
This is what i need to call manually
i think one of the most ideal way to do this will be taking full control of SimulationSystemGroup
Not necessarily you should be able to call system.Update() which calls the internal update and should call OnUpdate(JobHandle inputDeps) (but I might not know the full context of the situation)
then you can use World.PushTime() and World.PopTime()
to update your group with desired deltaTimes
should i use FixedList (or just custom fixed arrays) instead of DynamicBuffer if the size doesn't change?
also i find it hard to grasp the internal capacity of DynamicBuffers
my current understanding is this: if you put internal capacity to 32, it'll always allocate size of 32 elements for each entity in the chunk
even if you use less than that, it'll still have 32 elements allocated
now if you change capacity to 33, all 32 + 1 get moved to a new array outside the chunk, but in the chunk it still has a buffer of 32 elements allocated, except that's now just unused memory
is that correct?
I dont think the buffer allocates that amount that would just be a waste
its only up to that amount then it goes into a new chunk I presume
i don't understand how it could not though
doesn't each entity (or rather component collection) in the chunk need to be the same size? and be known at compile time
1 entity will occupy 2 chunks?
As soon as you exceed capacity it moves to the heap. Until then it exists in a chunk
but what happens to the part in the chunk
yes but i mean
I don't think its elements, its in bytes
let's say your entity in your chunk gets 32 bytes, 1 for each bufferelement and let's ignore the overhead bytes for example sake
wouldn't it be impossible to give each entity a different amount of bytes
The manual says it moves existing elements out of the chunk into the heap
since in order to get entity 10, it'd just do entity size * 10 for the offset in the chunk
Oh wait confusing when you said buffers and fixedlist nm
how would I even know the amount of bytes that I need?
sizeof(type)*elements
Yeah thats the case i believe Scorr
Probably minus a few bytes for overhead
this is why if you exceed buffer limit, buffer will move to outside of the heap
I'm doing this for a buffer I guess that's wrong for a 1000 size dynamicbuffer csharp [InternalBufferCapacity(1000)] public struct GridBuffer : IBufferElementData { public Translation value; }
i guess bytes in chunk that represented the buffer gets unused ?
so if your internalcapacity is 32 and you make a buffer with capacity 33 and it moves to the heap, won't it still have 32 bytes or whatever allocated in the chunk, just now unused because its real buffer is in the heap?
yeah, that would make sense ๐ค
I would assume so
@pliant pike In that case if you want it to stay off the heap the capacity you want would be (sizeof(float) * 3) * maxElements
I have to use maths to work it out 
Well that would be the bytes, I'm assuming InternalBufferCapacity means the elements
i don't think you have to do sizeof yourself, if you put [capacity(1000)] like above doesn't it just automatically allocate 1000 * size of component
Yes probably
also so changing your buffer's capacity to less than the internalbuffercapacity shouldn't matter huh
So just set capacity to the most translations you think you would have in that buffer
since it'll always be the same
The capacity is fixed at compile time from the perspective of keeping the buffer inside a chunk
cool so I was right
Tho there is a 'weird' behaviour if you do internalcapacity a lot, since a chunk can have 16kb and your internal capacity exceeds that then it will give an error
ya but then you'd need to have 1 entity that takes up more than 16kb
I think you would only get that error if you tried to explicitly set internal capacity to be larger than a chunk
If you add to the buffer, rather than setting the capacity, it can grow larger than 16kb
yeah thats.. what i tried to say
i just find it hard to see the use case then for DynamicBuffers
since if you want something inside the chunk you could just use fixed arrays
and if you want something outside then you could use fholm's unsafecollections (or maybe nativearrays? forgot if that works on components)
i can't think of a case where you sometimes want it to be inside the chunk and sometimes inside on a entity-by-entity basis
NativeArrays don't typically work unless you have your own implementation that doesn't use the DisposalSentinel
The use case is if I just want a resizable buffer and don't 100% care if it's inside a chunk or not. I just want to iterate resizable buffers in a query in a relatively efficient way
its an array you can use anywhere and store permanently
The capacity just gives me a way to give a hint to unity to keep it efficient
Also looks like you can call TrimExcess() if your length != Capacity
One nice thing DynBuffer has that unsafeCollections don't is that they get auto-deallocated when the entity is destroyed
ooo
If you absolutely need your arrays to always exist inside a chunk then yeah you're probably better off using a FixedArray, but then you can never exceed your capacity
yea i hadn't considered that, auto deallocation is pretty nice
Do the fixed collections not get auto disposed either?
i think those do because then it's still in the chunk
Yeah I guess they must, they are just allocated on the stack
yup, but then those have the downside that they can't grow to an arbitrary size
would anyone kindly have a look at my question? :https://forum.unity.com/threads/confusion-with-must-not-be-a-non-nullable-value-type.835372/
{
public bool toRandomise;
}```
This should be a `struct`
Doh!!
How should I move my character with DOTS? Should I just set the Translation to the prefered direction and smoothe things or should I use velocity?
afaik if its physics driven, if you simply move via translation it may not be picked up in the physics systems properly
What do you mean by physics driven?
If you're using physics move by velocity
Right now I don't use a RigitBody or PhysicsBody
If you're not then you can do it however you want
But I wonder if I should, I will need Physics Shape for sure
if you dont need physics then just modify the translation
Is anyone familiar with using the BuildConfiguration asset with ECS?
sorry @zenith wyvern wish I was ): haven't played around with the build configs stuff yet
outside of the PhysicsVelocity there isnt a regular "velocity" component(which is what I thought you meant) @formal scaffold
well I use it but I cant say Im really familiar with it @zenith wyvern ๐
It seems nice and I have it building properly but when I try to "run" from the asset it says there's no run step defined
yeah I think the latest update kinda borked it, run worked for me prior to 0.6
or whatever that updated the linked dependency to
Ahh okay, good to know, thank you
@safe lintel how was the process of using the build configs? Was it simple when it worked?
Ive been recycling something I copy pasted from the samples which has served me well enough for just testing a single scene, im actually a little annoyed that the latest update made the namespace internal or inaccessible as I was calling it from the resources folder on a little editor ui script
i think if you arent using subscenes you can skip it for now
Is there an equivalent to Mathf.SmoothDampAngle in Unity.Mathematics?
math.lerp seems good ๐ค
Ah thanks @safe lintel i might hold off on it - not in the immediate need of using it but definitely want to down the road lol
So how can i update "SimulationSystemGroup" manually?
Instead of having it run automatically
i think you have to create your own world for that
Is there any example about this?
I've seen something similar in the unity ecs example
But it just controls update of a user-made system
Haven't found one that controls update of physics system or its group
i dont know any sorry, i never tried to create my own world
I generally control if my systems should update or not by creating singleton tags and i make my systems require that singleton.
for example to 'pause' the game when my player is in UI menu, i create "PlayerInUI" singleton and remove "PlayerIsPlaying" singleton, and my runtime has requireforsingleton<PlayerIsPlaying>, so when my player is in UI, my runtime systems wont update.
@opaque ledge Can you make the physics run like 30 frames in 1 frames time with that kind of setup?
(i need it for multiplayer prediction)
No i dont think so
i use this to "pause" my systems, i dont think thats what you are looking for
@opaque ledge Oh, this actually worked
public void Simulate(int frames)
{
sysGroup.Enabled = true;
for (int i = 0; i < frames; i++)
{
sysGroup.Update();
}
sysGroup.Enabled = false;
}
Not sure it will be deterministic this way though
I need to see how to control the time delta
Pass your own delta time based on your prediction
Also i don't know if there's a chance it may update more than 10 times
maybe you should look at netcode sample?๐ค
Hmm, i think i got it though.
I did some tests, it doesn't do this:
Also i don't know if there's a chance it may update more than 10 times
I just need to set the timedelta now
Hi all, is there any way to animate skinned mesh models with DOTS?
the asset uses traditional Animator and Skinned Mesh Renderer, but if I use Convert To Entity, the object disappears when I press Play
so I reckon Animator and Skinned Mesh Renderer are not supported in DOTS
It's still very very early
Looking for feedback from experienced ecs folks https://forum.unity.com/threads/simulating-a-lot-of-entities-in-ecs-in-an-interactive-world.835504/
sees 'looking for feedback' YAY, sees 'from experienced ecs folks' awww
@zenith wyvern ever heard of priority queue?
Yeah I've used it before for pathfinding. I don't know if it's relevant since I need to sort the buffer on every turn anyways in case any relevant state changes
my thinking is... do not bother. its a rogelike, you are alredy pushing comical counts of objects
for rogelike type stuff, you wont deal with more than 100 actors basically ever
so feel free to do tons of structural changes, and to not have "thinking" stuff parallelized
Yeah I'm not too worried about the performance anyways, the biggest bottleneck right now is the sort, by far. I'm more concerned with having to basically abandon all the typical ECS workflow to make it work
why sorting?
i also think you might be running into unity ecs issues (system overhead?)
if you are running the actor systems 1000 times per frame
the thing with a rogelike, is that it works somewhat in "reverse" from typical ecs
instead of being "one system runs thousand entities in lockstep". is "one entity runs N systems in order"
when its the time to act
you can still use all of the typical ecs patterns, and in fact they still work great
but i think you are being eaten by job launch overhead? and system overhead
Like I said I have to sort every turn in case state changes. So for 2500 actors that's 2500 sorts in a frame. I could reduce that by only doing it if I know there was a change but yeah, like I said not too worried about the performance anyways.
The actual calls to the systems are just a normal function call at this point, there should be basically no overhead there
An actor takes a turn. The turn buffer has to be sorted before the next turn in case the actor changed any relevant state, like changing another actor's energy or killing them
whats that turn buffer
All actor turns might happen in a single frame
TurnBuffer is an array where actors get put when they have enough energy to act
priority queue that
instead of resorting
or at the very least run insertion-sort
I guess I could do that and re-insert after changing state
as insertionsort should work well on a "definitely 99.9% sorted" array
now that i think about it
why are you sorting
And you think going back to relying on state changes is the right way to go? It just felt awkward and yeah there was definitely overhead issues once the entity count got really high
just grab the smallest element
@zenith wyvern state changes make the code super easy to follow
in the systems
on normal rogelike counts, it shouldnt be a perf issue at all
Right I guess just iterating once and marking the right actor to act would be faster
Good idea
roguelikedev reddit has TONS of stuff written about rogelikes with ecs
I guess I'm thinking of having DF levels of entities, potentially a few hundred at once. 100% putting the cart ahead of the horse in terms of where my roguelike is at but this is like a core system
both "classic" oop ecs, and the modern data-oriented ones
So I want to do it right
the truth is
unity dots sucks for tihs
Entt would be much better
so would Entitas
all ECS libs optimize towards sometihng. Unity ECS optimizes towards "scaling"
running million entities and stuff
Entitas optimizes towards "literally everything is static until something triggers"
and entt is somewhat middleground
for a rogelike, add/remove component being spammed to death is "normal"
and unity ecs main weakness is that add/remove is super expensive (in comparaison)
Yeah the Entitas way definitely sounds like a better fit for this specific use case if that's how it works
Entitas is nowhere near as fast when running a single system over like 10k entities
but entitas add/remove component is faster than unity ecs
the main idea of entitas is that you would have a good amount of systems done as "reactive", that only run when something changes
like your turn systems. Systems that do nothing until they detect that an entity just got a "DoTurn" component added to it
entt can also do that
unity ecs can too, but that add is more expensive and i think launching systems has a bit of overhead (not sure how much)
Kind of a bummer to hear that Unity ECS is just not a good fit for the problem. No silver bullets as usual
btw i still doubt you can have problems on a dwarf-fortress scale game on unity ecs
unless you do some seriously stupid stuff
in those sort of games you are much more bottlenecked by AI
than by send/act on events and calculate damage and things like that
DF itself main bottleneck is actually pathfinding
I was definitely hitting some slowdown when I got around 1k structural changes in a single frame
Not just pathing itself, but the mega-possibility-tree of finding which job among any possibly job is the most optimal at this moment
and thats a horrible use case for ecs
luckily unity has added support for attaching "normal" C# structs as components
so you can just link into a more "oop-ish" stuff
that makes sense for a decision tree
TBF ECS would still be better than trying to make it in monobehaviors
no one would do it on monobehaviors themselves, they would do some sort of BrainClass or similar
True, but at that point you aren't really doing it in Unity as much as the code just happens to run inside unity
i made that once on unreal ๐ค . I had my normal AIController actor, and then just linked into a pure Cpp class with a complex decision tree, outside of ue4 view
that ai was a masterpiece, havent done anything nearly as overkill since then
turns out basically all games dont need fancy AIs
they just need a dumb state machine or hardcoded behavior tree for attack patterns
but basically, you can do that on unity ecs now. Create a component that is C# managed, and it points into a decision tree class
And I do believe hooking that up to ECS could be easier, if nothing else other than the strong separation/loose coupling it forces (this being by default, going by naive/normal solutions. Particularly poorly or well designed solutions always stray from that baseline)
i like to keep on the ecs stuff that is basically "allways on", or defines the object
not everything has to be done on top of the ecs
Doing everything in a system makes it less clunky to use burst and jobs though. Now you don't even need to bother with function pointers or job structs for most things
no such thing as needing burst or jobs for a think-component
or stuff that is turn based, as you are only doing things 1 at a time
nothing to parallelize
Jobs could be a decent way to do thinking-logic, though. Maybe not necessarily ECS-linked jobs, but unless you have preexisting experience writing parallel code, working within the design patterns you're using for the rest of the game seems like a decent decision.
Also, I would argue that for at least some turn-based stuff you definitely want to parallelize what can be parallelized - after all, eveyrone hates slow CPU turns, which is a result of all that logic running in one burst
is dots's netcode good enough to make mmorpg
Most modern MMOs use some form of ECS under the hood, as otherwise such massive scales become a nightmare of spaghetti
they do
the ECS pattern (modern one) is extremelly OP for mmos
because in mmo you are doing crazy throughput. Some gameplay logic, but multiplied by 1000 players
Add to that, the logic itself tends to be relatively simple, and as you might have realized from basically any ECS/DOTS demo/sample, DOTS is amazing at doing a little bit of work, for a crapton of 'things'
yup
i was working with some guys on a research WoW server using ecs and stuff very similar to DOTS (job graph and stuff), and it was an amazingly good fit
it almost made it too easy
but DOTS networking isnt it
gotta roll your own networking
As for netcode specifically, as your edit asks... Does anyone have experience with that yet?
At any rate, netcode for an MMO will almost definitely require some custom, standalone stuff. At least server-side - but the client is, again, pretty simple and could probably be done in DOTS, using the builtin stuff or otherwise
im not sure now
DOTS networking in general or this fps oriented staff?๐ค
but i grabbed the sample
and it was terrible
first open the thing ran at 10 fps in editor
after disabling the checks, it bricked the project
had to reinstall
second time it did work. 60 fps now
but i was looking at the profiler, and the performance overhead for server with 1 client was atrocious
it was using like 10ms doing nothing
basically SIGNIFICANTLY slower than unreal engine ShooterGame
meh
so no mmorpg
we must wait
but the networking gotta have to be yours
so they write OP networking
DOTS networking will never be mmo worth
in the same way that ue4 networking isnt
its just not the focus
due to the amount of players and stuff, mmos need custom-built networking
^
You might be able to do MMO-lite, but even then I would strongly argue that the backend should be custom
and btw, any and all "generalized" mmo backends are not good
i'm a little bit confused, isn't there low level DOTS network and high level DOTS network which they are using in DOTS tps sample?๐ง
because they will be much less effcient than self-rolled
Unless you're makign a generalized MMO, of course. WoW clone #8223?
even like that
a well optimized wow-like tab-target mmo can run 5000 players a server
i would like to know that software solution that reaches 500+ a server
couse stuff like Spatial OS cant
and actually, optimizing a tab-target mmo is not that hard. They have very lax latency requirements
WoW vanilla runs 2 updates a second
its basically turn based
Some clever design helps there
Like, you can queue an ability to be used before its off cooldown or other abilities are finished
in a wow-like server, you would have 2 main threadgroups. Some of them deal with the low level networking (syncing player movements for example), and the others run the actual game logic (damage/effects)
and they are NOT synced
WoW also did stuff like not checking anything server side
thats why stuff like fly-hacks and speedhacks exist
client goes "hey server, im at X,Y,Z", server goes "ok bruh" with some minimal checks
wow pirate servers do not do any checking
couse checking costs cpu, and they dont want to pay that cost
Note: making the server non-authorative is generally not the greatest idea
meh, just ban the guy
Usually you can find at least basic checks for cheap enough, though. Stuff like "Is the player roughly within an area they could potentially have gotten to within this timeframe?"
wow pirate servers dont even do that lmao
Not surprisingly getting rid of the stupid sort helped a lot, I can get around 4k monsters before I start to feel some input lag
Which stops crazy teleporting and super-speedhacks, but by nature needs some wiggleroom - and if you choose 20%, then hackers have a 10% speedboost (with margins)
mmos dont have much of a hacker issue because you just banhammer
hackers cant give themselves endless levels or items, couse thats server-auth
so what can they do, run around? they are level 1
will get inmediately swatted like a fly
(btw, i used to use cheat-engine to hack on f2p mmos)
was fun
most f2p mmos didnt even have anti-speedhack
so you are ruining other peoples fun
which is as easy as it gets
nice
nah, i wasnt griefing. Just doing dumb shit like speedhack to see if it worsk
in Metin 2 i once did a mistake where i increased the "range" of my weapon, instead of the "damage"
i then proceeded to aggro half the map
Welp, regret
and get inmediately destroyed after 100+ enemies come after me
i wonder if they patched that
last time i checked metin2 did fix the speedhack
it was just too easy
I am passing ComponentDataFromEntity to IJobParallelFor job with readonly false:
GetComponentDataFromEntity<IComponentData>(isReadOnly= false)
But I get error:
InvalidOperationException: SomeJob.ComFromEntity is not declared [ReadOnly] in a IJobParallelFor job. The container does not support parallel writing. Please use a more suitable container type.
Regarding performance, Should I use non parallel job, run it on main thread or use ECB? I understand that ECB comes with overhead but I am not sure should I avoid using it if I can?
Basically what I am doing is I have NativeStream of bullet hits and wanted to apply its effects to corresponding entity componentdatas.
At least that was the case with ECB, but I am not sure if it is more optimized now
There should be almost no overhead for just setting the value of a component
ECB would probably be faster, you should only use CDFE if you need it to be set immediately inside the job, or if you need to read a component that's not in your query
Alright, thanks ๐ธ ๐๐ผ
huhu
Since the event is adding velocity to the target, I now had CDFE for reading the initial component and ECB for setting the updated velocity, which seems to work... but I just realized that if I have multiple events on same target, they are not going to add up and the last is going to override the components value.
From top of my mind I need collect all changes to list per entity and add up after everything that could be modifying those are done. Does this sound right? So adding those to DynamicBuffer with ECB and then post job cumulate the buffers to the end value.
Sometimes when I try to find a solution to something myself it feels like I am making stuff overly complicated. I guess partly it is true since I don't know all the tools I have available to me.
if you have a entitycount < 10000 dont think to much about overhead
I feel like that image is applicable to my life๐
public class UpdateInterpolator : JobComponentSystem
{
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var translations = GetComponentDataFromEntity<Translation>(true);
return Entities.ForEach(
(ref TargetBody target) => { target.position = translations[target.body].Value; })
.Schedule(inputDeps);
}
}
There seems to be a fundamental misunderstanding I have.
The safety system says I can't parallel write the container.
but it's readonly. I cannot decorate it with a [ReadOnly] attribute, though.
I'm confused.
Seriously.
๐ค
Wow, thank you @zenith wyvern
So, is this the order of systems that are schedules? Because this should happen before MoveRenderers.
I guess I got my reading work cut out for me
Thanks again for your help, I'm getting the hang of it now.
there's new tiny and platform packages
Probably because you're calling it 40000 times
yeah just not sure what I change to stop it
theres about 60 meshes, all using a single shader and masks
Ah, this is using the new Batched rendering API?
im guessing thats what im missing then, since these meshes are ripped out of megacity as well as the material
im just importing them into a dots project to use
Yeah I'm not sure, there's like next to no information online about how to actually use that api
is there a way around it? possibly make a single material for each instead? just duplicate it?
I really don't know enough about it to say, sorry. All I can suggest is to really make sure they're sharing the same material. If you can set things to static that should help a lot too
i would but I thought using gpu instancing was better?, activating static disables that
I'm pretty sure the only reason MegaCity actually works is because 99% of it is static geometry
That's what it's optimized for
Well, 99% is an exaggeration but yeah
ah cool, also whats the best setting for material creation on meshes? remapping or set it to none and apply the materials to the LODs in the hierarchy?
Welp, can anyone explain to me why am I having an error with these two lines of code?
InvalidOperationException: The NativeContainer GatherComponentDataJob`1.Data.ComponentData is allocated with Temp memory. Temp memory containers cannot be used when scheduling a job, use TempJob instead.
I am not scheduling job after all, am I?
In a any kind of system you can only allocate "Temp" containers inside a job. Otherwise you need to use TempJob/Persistent and manually dispose
Not sure why but that's how it is
Does Schedule in SystemBase mean not in parallel? So basically ScheduleSingle? Or is it up to ECS to decide or something?
Agreed ScheduleSingle would be clearer if its single-threaded equivalent
Yeah, Schedule is Single, ScheduleParallel is Parallel
Yep, platforms package is also updated
any cool changes/features/fixes?
- Support for building testable players (`TestablePlayer` component) as a step towards integration with the Unity Test Framework.
- Enable Burst for DotNet builds on Windows
For netcode, looks like they moved some things over from dots sample
* Added integration with UnityPhysics, including the lag compensation from DotsSample.
* Ghost types are now selected based on the guid of the ghosts prefab asset instead of the archetype. This makes it possible to have multiple different ghosts with the same archetype. If a ghost is not a valid prefab you will get an error during conversion.
and some API breaking changes in Transport that bleeds into Netcode as well
Haha I knew that you must have posted on this already, I just couldn't find it during my scroll
Hmm, how can i modify the time interval at which physics systems get updated at?
I think you can adjust the regular fixed timestep value on project settings Time
You mean this?
And that will affect the Unity.Physics systems update rate?
Okay, i'll try
yes, I think it does
pretty sure you can set it from unity physics somewhere too but on my testing, that value seemed to update physics at right pace
like if I've set unity physics to update on fixedupdates and change that value, physics clearly runs at the same speed regardless of the fixed timestep value I put there
if it didn't take that value into account, physics would speed up/slow down accordingly (that value also affects fixedupdate inverval so if it didn't adjust the physics stepping, it would change the physics speed)
No, that will not affect Unity.Physics update rate ๐
physics systems are updated in regular update๐
Regarding my messages yesterday about registering hits to entity DynamicBuffer (using ECB) and in another job sum the total change to velocity component and remove dynamicbuffer during the same frame.
I have read that this should be avoided since it changes the archtype back and forth during the same frame, but I don't really know any way around it ๐ค
@warped trail it does seem to change the physics simulate value, or how else it would explain that the physics speed stays the same if you force simulation group to run at fixedupdate
I don't now talk about the stock setup
where simulation group is indeed tied to update
every regular update StepPhysicsSystems advances simulation by UnityEngine.Time.fixedDeltaTime
by default๐
yes
so what was discussed was correct, no?
oh, the systems update rate
yeah that will not change that
@round summit ^
but it does change the simulation timestep when the systems run
did he tied his physics to fixedUpdate?
no idea
I also haven't checked how netcode package does this
they have some separate scheme there
I'm going to call physics update in code
netcode also has interpolation afaik
And whenever i call, i needed it to run with same intervals
So i think i'm good with fixedupdate interval from unityengine
the point drUiD tried to make was that the out of the box unity physics setup doesn't run that physics simulation at fixed timesteps but if you handle that aspect yourself, it's all good
it's like half baked setup out of the box
the actual physics sim assumes there's fixed timesteps and it uses that time.fixedDeltaTime but the stepping happens on Update ๐
world has very convenient methods like PushTime(), PopTime()
you can push your time to world and then call your system or whole system group and after update PopTime()
this is how built in systemgroups can update in fixed interval right now, but this functionality is internal, you have to edit componentsystegroup.cs to use it freely๐
thanks for info
@round summit you plan to use this with the new netcode package?
I'm just asking because there probably are similar mechanism there already and latest netcode package added some code from DOTS sample to be able to use Unity Physics better
Um, no actually
I only want stateless physics from dots to help with my state switching issues
ah ok
I am pretty much making a rigidbody mono that uses Unity.Physics backend
(I won't have too many bodies, game is not too complicated neither)
you figured the transform sync already?
yeah
no idea how he did it there
simplest way I know is to just use convert to entity with convert and inject gameobject and add this to your conversion script:
dstManager.AddComponentData(entity, new CopyTransformToGameObject());```
it's from the old GameObjectEntity workflow
of course you could just make new authoring component to that too and just slap that to the gameobject instead
you create a IDataComponent on a child object
that references its entity to its public field in OnConvert()*
and on the original gameobject you have reference to that to-be-converted-object
so it's the same as the physics samples? you query the entity each update for it's current position?
No not at all
TestEntity is a gameobject that will be converted to an entity when prefab is instantiated
Thats how a gameobject can reference to its entity
yes, and then how you get the transform?
Translation translation = entityManager.GetComponentData<Translation>(entity);
transform.position = translation.Value;
@dull copper
this really sounds like the same thing I was talking about all along
๐
Oh, sorry then ๐
so it's the same as the physics samples? you query the entity each update for it's current position?
they do exactly that
I may not have paid attention to the sample ๐ :
anyway, that's fine if you don't have much to update, the CopyTransformToGameObjectSystem does update the transforms on jobs so it's more efficient
it's really leftover from GameObjectEnitity workflow, they used to have that component with proxy setup there
i see it's how it's supposed to be the, data oriented way
(i don't think i can set transforms though since unityengine is supposed to be single thread)
I've duplicated the system and modified it to work with interpolation system from @warped trail
getting quite hacky again
I've been evaluating the options on this because current hybrid isn't all that great with HDRP so would be alternative to just render things on the gameobject side
there's an update coming to hybrid rendering tho
don't use that๐
it's just a proto
ultimately, if the netcode package starts to become worthy, would need to make things work with it's strategies instead
I wonder if i could make my silly interpolation system to not use "buffer" component๐ค
im lerping from A to B and storing result in C
also the time buffering on each entity was extra
like, it would always be the same for each entity anyway
oh, i don't use dynamic buffers at all๐
what do you mean by " just write to componentdata directly"?
I dunno, have just extra components there where you store the previous and current data which you now use buffers for
buffers was bad idea, i just tried to copy thing from that blog about smooth motion๐
i don't want to use any additional component at all๐ค
translation is most recent data and LocalToWorld is data from previous frame. I don't need anything else๐ค
how can i do this easily A = math.lerp(A,B,t) with same result as C = math.lerp(A,B,t)?๐
Recreate A looking at the velocity, ang vel, etc?
Does that work at all?
You are talking about stateless frame interpolation right?
i am just lerping two positions
you need to have the previous transform data stored somewhere if you do interpolation
it's like the bare minimum
this is the only thing I add when I implement fixed timesteps myself
the last physics sim always gives you the current
so you don't really need duplicate for it unless you overwrite it
and in this case since the result goes to localtoworld, you only miss the previous physics sim data
thats the problem, i want to store last physics sim at LocalToWorld, but not like the last physics sim more like already interpolated value๐ค
well, technically you could just overwrite the local to worlds data as the last thing after the rendering is done, set the current physics translation and rotation to it there, and then use it as your source for previous physics step data on the next run
like, if you really don't want to add extra componentdata for previous translation and previous rotation
this will work at firs render update after fixed update, but what to do next?
i don't want to๐ง
then some magic needs to happen somewhere ๐
oh, i can calculate previous interpolation factor T at time- delta time. So LTW is interpolated value at T(time -dt), I know end position, so (EndPosition - LTW) / (1-(time -dt)) will be speed(V) at which im interpolating . So LTW + V*(T - T(time -dt) will be answer๐ค
it works, but i still need component to block default TRS system๐ญ
Is there a way I can write to components and their fields programmatically?
I want to write a debug tool that takes input and writes it to a component. So it needs the entity/query, component and field names at edit time (exposed in the editor/inspector), and turn them into a system at runtime or compile time.
It's okay if that happens in a synchronous non-burst system. Just wondering how I can use reflection etc. in such a loop over the entities in a query.
Can anyone tell me how ECS is called but without having systems? so you have Entities that are composed of components. Only found the short term CBE but couldn't find anything about it.
Hello, after updated Entities to 0.6.0 (latest version) the world is null so the convert Entity didn't work (nothing work), do you know anything about it?
All types must be known at compile time, so i guess code regen ? @warm panther
@static cradle You can use World.DefaultGameObjectInjectionWorld.EntityManager to get the entity manager of default world, after that you can make your queries, set component, read etc.
@opaque ledge That's not what i meant
@gusty comet you might want to restart your editor if you havent already, also default world is now World.DefaultGameObjectInjectionWorld, World.Active is deprecated, if you are still using that
Entity Component Systems
@opaque ledge I've effectively replaced every World.Active but the DefaultGameObjectInjectionWorld is still null
are there any errors and did you restart your editor ?
@opaque ledge i am talking about OOB, not DOD. Like those MonoBehaviors. Just looking for the term of the principle
Anyone know where the reference for the buildconfigs are?
thx @opaque ledge that was the editor effectively, I've restart it several times, but maybe not after updated all references changes, thank you ๐
@mystic mountain you want to use that for implementing some build tool?
I want to know e.g. what things like "Auto Load" on Scene List actually means
that sounds like it'll automatically load those scenes on the build when it runs?
not really sure of the setting, never seen it myself
ah I see it now
Yeah, sure it sounds like it could mean that, but you don't need to tick one to make the first scene load. So ambiguous, hence I want a reference.
maybe it makes more sense with dots subscenes, like if you don't want to load the base scene at all on build etc
but could still want to load multiple subscenes automatically
no idea though, just throwing out ideas
Yep, also what Source Build Configuration "Enabled" means. Couldn't find any info in the packet it was so. :/
where is that setting even?
btw, gotta love this messaging:
doesn't sound like a success to me
heh
It was renamed to buildconfiguration , so might not be in the old one if you're using that.
yeah, I'm on it already
just took the new ones from ECS samples ๐
hmmm, it doesn't show up on my list still
ah
it's additional thing you can add
I wonder if that just creates sln for it
lets try
I would like to update a materials of some entity, so I've created a JobComponentSystem, on the OnCreate I instantiate a EntityQuery, but the m_Group.CalculateChunkCount() is zero and the OnUpdate is never called do you know how can I do?
I mean, in the old build tools, you could let the build tool just generate the solution and process the files but not compile it
and then just compile it yourself on VS etc
"Install In Builds Folder can only be used when building from source"
btw that error I got on new build tool... it's apparently because it can't find something in the end
actual build it there already and it runs fine
static readonly BuildAction k_BuildAndRun = new BuildAction
{
Name = "Build and Run",
Action = (config) =>
{
var buildResult = config.Build();
buildResult.LogResult();
if (buildResult.Failed)
{
return;
}
using (var runResult = config.Run())
{
runResult.LogResult();
}
}
};```
it fails on that runResult.LogResult();
so I guess the build only would work
Joachim - ..the next version of Hybrid Renderer which will require Unity 2020.1 fully support motion vectors. Keep an eye out on the release notes the next couple of weeks. ๐ค
stepPhysicsWorld.Simulation.CollisionEvents
Is this deprecated? I can't find anything that says it's deprecated but i don't see the CollisionEvents in my step physics world
I still can't get Joachim to comment if "full HDRP" support will include DXR
I mean, I'm 90% sure it will not
i just want URP support, there is no performance by default for me in HDRP, 24fps in default scene is a big no no๐ญ
@round summit Unity Physics samples on ECS Samples repo has collision events example
I'd start looking there if you have issues with it
@warped trail 24fps? ๐
you mean the dots shooter thing now?
i mean default scene with workbench and stuff
for me somewhat empty hdrp level with plane and few test objects with unity physics runs near 2000fps on build
yeah the workbench one wouldn't ๐
I thought initially you meant by default the new empty scene you get when you make new scene
that's weird tho
i have potato pc(660m)๐คทโโ๏ธ
did that workbench one have volumetric lighting enabled by default?
it's the single most expensive thing you can have on HDRP
but Megacity is 17-18 fps
it's also what makes most unity tech samples run really crap
like the old fps sample
or space ship demo
although should have profiled that before declaring it as root of all evil :p
if I remember right, megacity was quite cpu bound on my old i5 and gtx970
it didn't run much better there
I also have a potato PC for low end testing here that I have GT640 and GTX670 for, but I haven't really put it into test with proper HDRP scenes yet
I do expect it to be pain to get it scale that down tho
as another topic
they seem to have fixed IL2CPP build time regression on latest packages and 2020.1.0a24
i feel that my pc is more than enough to the games i wish to make in the future. Because Inside and Ori runs perfectly fine and i consider this two as best games made on Unity๐
when I last tested this (and made issue report) on a23, it took 20x longer on somewhat empty scene
I'm not disagreeing, I love well optimized games ๐
Hollow Knight is pretty cool as well but it's not technical marvel like the games you just mentioned, just cool gameplay and graphics
I think HK used like playmaker for AI
I mean, it worked still...
but ori and inside both got tons of cool custom tech
haven't noticed any positive changes in compilation times๐
oh I didnt mean like that
there was a HUGE regression on few earlier 2020.1 versions if you built with IL2CPP
took 20 minutes to build somewhat empty DOTS scene on my cpu
now it's little over 1 minute again, like it was on 2019.3
are there any channels for DOTS systems to write data for pickup by MonoBehaviour components? Example-- I want to do a more complex, almost database lookup-like operation to produce an asset reference and then use that asset reference with systems (Timeline) that do not have a DOTS binding
I was thinking I can save things out in a bridge component or muck around with shared components, but am unsure how I can examine that on the GameObject/MB end
@sour ravine This comes to mind https://github.com/periodyctom/Hydrogen.Entities/tree/master/Samples~/SimpleDatabaseExample if you can outline in more detail what you're trying to do i can come up with some more useful suggestions.
i read on the forums somewhere a comment from him about how they regretted splitting JobSystem/System, they considered it a big mistake and this seems to be the solution.
doing some reading, that's not exactly what I need (but is actually pretty valuable for the same system on the editor end)
the big thing is being able to change properties on a MonoBehaviour-derived component using ECS
@sour ravine you can do Entities.ForEach(ref MyMonoBehaviour mmb...)
No ref in that case
yes, though the syntax is a bit different (can't remember off the top of my head) - and @zenith wyvern is right about ref
You cant pass a managed type to a job, no. You can only do it WithoutBurst and .Run
that sounds like it would disallow the use of struct-based jobs
main thread access for any MonoBehaviour stuff but you can use it in a job as Sark says (using no burst and Run)
I mostly want to set the asset on a playable director here
that's the tricky data bit
Actually I think there are IJFE defined for UnityEngine.Object types
But yeah, you would still need to omit [BurstCompile] and call it with .Run
yeah already found all the component/bufferdata
Hmm, i was trying to grab some collisions like this in a ComponentSystem:
EntityQuery ImpulseGroup = GetEntityQuery(new EntityQueryDesc
{
All = new ComponentType[] { typeof(CollisionEvent) }
});
But then i get this error:
ArgumentException: Unknown Type:`Unity.Physics.CollisionEvent` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
Have you seen this error before? I thought this piece of code would get me the collisions from last step physics world?
any clue if 2019.3.3f1 breaks dots for some reason? Some systems that used to work
now directly don't
2019.3.3 came out ? ๐
and fbx issue is still ther
@round summit you have to use ICollisionEventsJob for collisions๐ค
Oh, i see thanks
CollisionEvent is not a component, that's why you saw that error
I see, i did some funky stuff in my desperate attempt
@round summit ICollisionsEventsJob and ITriggerEventsJob are not multithreaded so you can use regular EntityCommandBuffer not concurent one
Can i also use these in ComponentSystem?
Or it needs to be JobComponentSystem?
All the examples i'm seeing now are using JobComponentSystems ๐ค
you will have to sort events by yourself๐
So, as systems we have 3 classes, ComponentSystem, JobComponentSystem, SystemBase.
ComponentSystem runs on mainthread so it offers no parallelism, if you are already using them consider 'upgrading' them to JobComponentSystem which is multi threaded.
ComponentSystem is more for debug stuff
I might eventually do that upgrade
@opaque ledge SystemBase should be the replacement for both
after switching some systems over last night, I like how jobhandles are handled(heh) now
yep
Hello, what is the best way to convert prefabs without using subscenes?
SystemBase is relatively new, and since Dependency is a property now i thought people with no experience with scheduling stuff could have "wtf" moment, thats why i didnt advise it.
using GameObjectConversionUtility
blobAssetStore = new BlobAssetStore();
GameObjectConversionSettings settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, blobAssetStore);
Entity prefabEntity = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, settings);
well, they switched over all the samples to it, I think they think it should be encouraged over the previous solutions
yes I need to be careful about that tho, as it's very slow (creates a world every time) so what I did is to create a special monobehaviour that implements IDeclareReferencedPrefabs, IConvertGameObjectToEntity so that I can iterate over a list of prefabs at once
Yeah I am one who didn't understand the Dependency property. But I also didn't understand JobHandles either, soo..
Mainly I don't get where jobhandles come from, if they're not being passed in to Update()
@toxic mural so any job you schedule returns a jobhandle
@scarlet inlet you can do that as well, thats what i do as well on some prefabs
oh so SystemBase now has a Dependency property where you stuff all jobhandles to
you also use that as the jobhandle for scheduling jobs
so like
Dependency = new RotateJob().Schedule(this, Dependency);
@opaque ledge if I got it right when I do
public void DeclareReferencedPrefabs(List<GameObject> referencedPrefabs)
{
referencedPrefabs.AddRange(_prefabs);
}
_prefabs can contain hierarchical prefabs and the hierarchy will be properly converted
@toxic mural think like this, Unity's internal Job Scheduler is calling every JobComponentSystem's OnUpdate method and passes the "inputDeps" JobHandle, so think like.. Job scheduler is a mailman, and it collects every JobComponentSystem's 'mail'(which is a JobHandle), and goes to post office and.. process them in certain order so every mail is sent to it's proper destination... and.. yeah, thats it
@scarlet inlet yeah
you have to have IConvert interface as well
like.. they work 'together' so to speak
@opaque ledge cool. However I recently noticed that some gameobjects in the hierarchy are converted in unused entities and I would like to prevent their creation (or destroy them later). IS there a way to do so?
what do you mean unused entities ? I mean.. i am assuming you decide what entity is being used or not, if you dont want to convert certain gameobject and its' children you can put "Convert (Stop)" script on the gameobject
I need to convert all the prefabs, but some children are not needed
you can put that Convert Stop script on that children then
I can check at run time what is not needed, I am not sure that Convert Stop is used by GameObjectConversionUtility
you think so?
it should be yeah ๐ค
you can just try ๐
i havent tried it yet but i think it works
I did and didn't work, but maybe I was doing something wrong, let me try again
(checking the code it seems that that component is used only with the subscene flow, but I can still be wrong)
if it doesnt work you can destroy them i suppose, parent should have Child component, you can access that and destroy them
But yeah like i said, i never tried so
testing...
Right now, this is the only system and the only piece of code i have in my project.
I wanted to print "collision" when a collision happens in the scene.
[UpdateAfter(typeof(BuildPhysicsWorld))]
[UpdateAfter(typeof(StepPhysicsWorld))]
[UpdateBefore(typeof(ExportPhysicsWorld))]
public class AllSimulationSystem : JobComponentSystem
{
BuildPhysicsWorld m_BuildPhysicsWorldSystem;
StepPhysicsWorld m_StepPhysicsWorldSystem;
protected override void OnCreate()
{
m_BuildPhysicsWorldSystem = World.GetOrCreateSystem<BuildPhysicsWorld>();
m_StepPhysicsWorldSystem = World.GetOrCreateSystem<StepPhysicsWorld>();
}
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
JobHandle jobHandle = new CollisionJob().Schedule(
m_StepPhysicsWorldSystem.Simulation,
ref m_BuildPhysicsWorldSystem.PhysicsWorld,
inputDeps);
return jobHandle;
}
struct CollisionJob : ICollisionEventsJob
{
public void Execute(CollisionEvent collisionEvent)
{
Debug.Log("collision");
}
}
}
But i get this error about job dependency problems?
InvalidOperationException: The previously scheduled job AllSimulationSystem:CollisionJob reads from the NativeArray CollisionJob.InputVelocities. You are trying to schedule a new job Solver:ApplyGravityAndCopyInputVelocitiesJob, which writes to the same NativeArray (via ApplyGravityAndCopyInputVelocitiesJob.InputVelocities). To guarantee safety, you must include AllSimulationSystem:CollisionJob as a dependency of the newly scheduled job.
Why is this?
i think you should put "UpdateAfter(typeof(BuildPhysicsWorld))" attribute to your system
oh i did that too sorry
same error with that too
i updated the class attributes in the code
try exportphysicsworld
i did this?
[UpdateBefore(typeof(ExportPhysicsWorld))]
after
can you try UpdateBefore(typeof(BuildPhysicsWorld))
thats what i have on my trigger job
@opaque ledge same error
Where does InputVelocities coming from ?
Solver:ApplyGravityAndCopyInputVelocitiesJob this i think
something in physics systems i believe
hmm ๐ค
inputDeps = JobHandle.CombineDependencies(inputDeps, _stepPhysicsWorldSystem.FinalSimulationJobHandle);
@round summit ^^
the unity physic ECS dependency system relies on the FinalJobHandle pattern
it doens't work just with the automatic component dependency system
actually you may need even to add this:
//this is necessary because we must be sure that the extra jobs are completed by the end of the
//final step
_endFramePhysicsSystem.HandlesToWaitFor.Add(updateCollisionStateJob);
this is our code:
inputDeps = JobHandle.CombineDependencies(inputDeps, _stepPhysicsWorldSystem.FinalSimulationJobHandle);
var updateCollisionFlagJob = new UpdateCollisionFlagJob
{
CollisionsFromEntity = GetBufferFromEntity<CollisionEventData>()
}.Schedule(this, inputDeps);
var collisionEventJob = new CollisionEventJob()
{
Bodies = _buildPhysicsWorldSystem.PhysicsWorld.Bodies,
PhysicsVelocityGroup = GetComponentDataFromEntity<PhysicsVelocity>(true),
PhysicsMassGroup = GetComponentDataFromEntity<PhysicsMass>(true),
CollisionsFromEntity = GetBufferFromEntity<CollisionEventData>(),
Counter = (int*) _counter
};
var collisionEventJobHandle = collisionEventJob.Schedule(_stepPhysicsWorldSystem.Simulation,
ref _buildPhysicsWorldSystem.PhysicsWorld, updateCollisionFlagJob);
var updateCollisionStateJob = new UpdateCollisionStateJob
{
CollisionsFromEntity = GetBufferFromEntity<CollisionEventData>()
}.Schedule(this, collisionEventJobHandle);
//this is necessary because we must be sure that the extra jobs are completed by the end of the
//final step
_endFramePhysicsSystem.HandlesToWaitFor.Add(updateCollisionStateJob);
return updateCollisionStateJob;
but I think you can see this from their examples too
allright, i'm trying now
Did it work ๐
still trying
i guess ITrigerEventsJob different?๐ค
that would explain my situation i think
Maybe, but i only have 1 triggereventsjob, raycast also works without problem if you only have 1, but gives errors if you have more than 1
with readonly collision 'hack' it works but not sure about itrigger or icollision job
ITriggerEventsJob are similar
but im using ITriggerEventsJob without FinalSimulationJobHandle and there is no errors and everything works fine๐ค
multiple trigger jobs ?
I am not sure how the JobDebugger works
but it may not detect problems due to the final job handle pattern
yeah, come to think of it, everything related to dots physics is pain
Hmm, this class in the unity ecs sample has "unsafe" attribute:
https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/UnityPhysicsSamples/Assets/Demos/2. Setup/2d. Events/Scripts/CollisionEventImpulseBehaviour.cs
The one for detecting collisions.
But the one detecting the triggers doesn't have the "unsafe" attribute
the problem is that the job dependency systems starts to crumble once external dependencies (like the final handle pattern) are used
well makes sense because trigger doesnt do any physics so
meaning that you have to pay much more attention
what's the relation with the unsafe attribute?
I just noticed that
doing pointer stuff i suppose, i dont do any collision so i never tried it
yeah unsafe is related only to the use of pointers
it's unrelated to the job dependency system
note that the reason why I know this stuff about the final handle is because we checked the physic examples, you will find the same code there
if not, I am wrong ๐
Is the code you are referring to the one i just sent?
@scarlet inlet
I really wish jobcompsystems would run in a straightforward way
@round summit yes
It doesn't do any *ptr stuff but it still has the unsafe attribute?
like I create an entity in the Onstartrunning if I leave it like that its fine and it creates the entity
@round summit sorry that code proves that I am actually wrong
I can see that the Schedule<T> extensions does the FinalSimulationJobHAndle concatenation already
I need to check this with my colleagues tomorrow
but if I then use an Entities.foreach in Onupdate that checks for and uses that entity then the whole jobcompsys doesnt run at all and the entity is never created
so yeah that schedule should do already what I suggested to do, sorry about that
reagarding the unsafe, it's not necessary, not for the jobs to work
still get the errors though,
i'll try to run the example project as it is
I was just taking that code alone and try to make it print stuff on a collision
don't forget to disable burst if you want to use debug.log
I need to go now, good luck, maybe tag me with the solution if you find it
thanks, i will
found the solution๐
var jh = new CollisionJob().
Schedule(m_StepPhysicsWorldSystem.Simulation,
ref m_BuildPhysicsWorldSystem.PhysicsWorld,inputDeps);
jh.Complete();
return inputDeps;```
will work like this๐
so just complete then ? ๐
yes๐คทโโ๏ธ
yeah well fair enough.
but you don't have to call complete on triggereventsjob๐ค
Does HasSingleton() not work with DynamicBuffers ๐ค
nop ๐ฆ
disappointed! ๐
yeah, not a biggie tho i suppose, you just put a singleton component to it, and do getsingletonentity with that component and do getbuffer inside a job
kinda annoying but at least its not impossible to do
yeah just means I'm gonna have to use a tag as well
aren't netcode samples are using buffer singlton for input?
@warped trail Did you see that the CollisionJob executes its code?
oh, didn't know about that
ill do it
.
@warped trail thanks alot, this stuff is very hard to figure out๐
@scarlet inlet , drUID got it, i'll tag you here in case you miss it:
var jh = new CollisionJob().
Schedule(m_StepPhysicsWorldSystem.Simulation,
ref m_BuildPhysicsWorldSystem.PhysicsWorld,inputDeps);
jh.Complete();
return inputDeps;
Can we do OnCollisionEnters/Exits without caching anything extra (keeping it stateless)?
Probably not i assume
is it possible to call InitializationSystemGroup, SimulationSystemGroup and PresentationSystemGroup manually? I know I can create my own World and systems and call those at my discretion, but I'd like to use all the setup and systems from the default world and run that with my own custom update loop ๐ค
i looked into the PlayerLoop but it seems I can only add calls to the update delegate? instead of replace it with my own update delegate, so to say
@timid beacon I'm sure there's an API for it, but you can always just go into the package source and disable the system from spawning
I also know that NetCode disables systems from spawning in the default world, maybe you can look into how they do it
@timid beacon I also just found this, which has some Bootstrapping which seems to be exactly what you're looking for https://docs.unity3d.com/Packages/com.unity.entities@0.6/manual/system_update_order.html#multiple-worlds
thanks @bright sentinel !
yes I found the bootstrap too, but latest entity package ICustomBootstrap does not reflect whats on that page
{
bool Initialize(string defaultWorldName);
}```
@timid beacon That's odd. Maybe you can look at how NetCode does it then
@timid beacon https://docs.unity3d.com/Packages/com.unity.entities@0.6/changelog/CHANGELOG.html#changes-2 Here you go, look for the codeblock at the place I linked you
Not sure why they decided to change it though
hi! i started playing with dots today and have a question: how would i go about updating data of one specific entity? i could create a system that queries the data type and then loop through the result until i match the element i want, but there's surely a better way?
I got it! Basically just removing the UpdatePlayerLoop part gets me all the systems but without the unity update
{
public bool Initialize(string defaultWorldName)
{
Debug.Log("Executing bootstrap");
var world = new World(defaultWorldName);
World.DefaultGameObjectInjectionWorld = world;
var systems = DefaultWorldInitialization.GetAllSystems(WorldSystemFilterFlags.Default);
DefaultWorldInitialization.AddSystemsToRootLevelSystemGroups(world, systems);
// ScriptBehaviourUpdateOrder.UpdatePlayerLoop(world); <- don't update
return true;
}
}
however, getting the three main groups and calling Update() on those manually does not seem to cascade down to their children, so for testing purposes now I just did
{
sys.Update();
}
which works! Not sure if it calls the systems in the right order though, but that's a problem to solve for tomorrow
also, you won't get the neat systems in the PlayerLoop tree view now, which is a bit of bummer but makes sense. I'll have to roll my own tree view and time measurement I suppose
@pliant pike @opaque ledge You cant call getsingleton with a buffer but you can call GetSingletonEntity with a buffer, so no tag is needed
you get errors with getsingleton/entity though if the singleton doesn't exist, also the entity has no designation I can find it with
If you have a dynamic buffer IntBuffer you can find a singleton entity with that buffer attached with GetSingletonEntity<IntBuffer>
Hmm does anyone have an example for Entities.WithNativeDisableUnsafePtrRestriction(capturedVariable)? - I'm having a hard time getting that working ๐ค
did someone try the DOTS Sample multiplayer project?
this one
the demo they're showing runs all good, but.. it runs at 5 fps on my PC
when I should get 60
make sure you disable the burst/jobs safety checks
@odd ridge do read the readme
I'm having issue with building my project (Android + IL2CPP)
After commenting out line by line I found the problem, and made a test project with the following code:
using Unity.Entities;
using Unity.Jobs;
using Unity.Collections;
public class TestSystem : JobComponentSystem {
EntityQuery entityQuery;
protected override void OnCreate() {
entityQuery = GetEntityQuery(ComponentType.ReadOnly<TestComponent>());
}
protected override JobHandle OnUpdate(JobHandle inputDeps) {
UnityEngine.Debug.Log("Test");
int count = entityQuery.CalculateEntityCount();
if (count > 0) {
NativeArray<Entity> entities = entityQuery.ToEntityArray(Allocator.TempJob);
Job
.WithReadOnly(count)
.WithReadOnly(entities)
.WithCode(() => {
for (int i = 0; i < count; i++) {
Entity entity = entities[i];
}
}).Run();
entities.Dispose();
}
return inputDeps;
}
}
public struct TestComponent : IComponentData {
public int Value;
}
Error log when building:
il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: <project_path>\Temp\StagingArea\Il2Cpp\il2cppOutput\Assembly-CSharp.cpp:2468:25: error: no member named 'get_count_0' in 'U3CU3Ec__DisplayClass2_1_tB1AB7DCE86D48C186E19893AA18115C9CC3DA6A1'
int32_t L_4 = __this->get_count_0();
~~~~~~ ^
1 error generated.
I looked at the cpp generated, there is indeed no get_count_0 for that class for some reason.
Any idea what's the cause?
If I comment out the line Entity entity = entities[i]; then it builds fine.
I'm starting to think it's a bug related to code striping, but just in case it's something really obvious that I overlooked.
Hello! Is there a difference in using this 2 approaches https://pastebin.com/zk9SxDpQ to work with entities?
@urban remnant Not other than the content of the job. Entities.Foreach() generates a job for you, so you don't have to write it yourself, but it's still possible.
Generally, ForEach is the new way and you'll probably be using that most of the time
And note that with the newest version of Entities, they have moved from JobComponentSystem to SystemBase, which combines ComponentSystem and JobComponentSystem
@bright sentinel how doe's that work? So it uses jobs or not when I use it?
It does use a job, it just generates the code for you
## [Platforms 0.2.1] - 2020-02-25
### Added
- Support for building testable players (`TestablePlayer` component) as a step towards integration with the Unity Test Framework.
- Add a UsesIL2CPP property to BuildTarget
### Changed
- Enable Burst for DotNet builds on Windows
- Revert namespace `Unity.Platforms.Build*` change back to `Unity.Build*`.
### Fixed
- Fix Build & Run fallback when build pipeline doesn't have a proper RunStep, BuildOption.AutoRunPlayer was being set too late, thus it didn't have any effect, this is now fixed.
- Build configuration/pipeline assets will now properly apply changes when clicking outside inspector focus.
- Fixed asset cannot be null exception when trying to store build result.```
that's from platforms 0.2.1-preview.5 despite the changelog hints it's final
@dull copper How do you know it's final? ๐ค
it's not
changelog is wrong
I'm guessing they planned next release to be final and forgot the add the preview tag back once they pushed it out or something
There are inconsistent line endings in the 'Assets/Scripts/Systems/Characters/Player/PlayerAnimationSystem.cs' script. Some are Mac OS X (UNIX) and some are Windows.
This might lead to incorrect line numbers in stacktraces and compiler errors. Many text editors can fix this using Convert Line Endings menu commands.
Anybody know fast way to fix those in VS 2019?
Edit->Advanced->Change line endings ->CR LF if you are on windows
also in project settings->Editor you can choose what endings new scripts will have, change to windows if you are on windows
Tnx
.
@warped trail thanks alot, this stuff is very hard to figure out๐@scarlet inlet , drUID got it, i'll tag you here in case you miss it:
var jh = new CollisionJob(). Schedule(m_StepPhysicsWorldSystem.Simulation, ref m_BuildPhysicsWorldSystem.PhysicsWorld,inputDeps); jh.Complete(); return inputDeps;
@round summit you are not supposed to call complete. I understand why you are doing it, but it's not how the job system should be used.
Also Collisionjob doesn't work in parallel so using run instead of complete is faster
Hello, how is it possible to acceed to the MeshRenderer in a Job please? I would like to change the color of a mesh with a job, I though I should use IJobChunk but it seems to be impossible: "The type 'Unity.Rendering.RenderMesh' cannot be used as type parameter 'T' in the generic type or method 'ComponentSystemBase.GetArchetypeChunkComponentType<T>(bool)'. There is no boxing conversion from 'Unity.Rendering.RenderMesh' to 'Unity.Entities.IComponentData'."
thanks @warped trail I've already saw that, I don't want to use HDRP :/ I just want to change the color of a Mesh :/
welcome to the club then๐
@warped trail Ahah, I didn't know it wasn't possible yet. Thanks you, you save me from an other day lost in search
PlayerAnimationSystem.cs(8,9): error DC0023: Entities.ForEach uses managed IComponentData Animator. This is only supported when using .WithoutBurst() and .Run().
Ghh
So if I want to use Animator, I can't get all the goodies
?
What overall the sate with Animations in ECS, some READABLE examples? ๐
@warped trail yeah I know that. But it's not very Readable
๐คทโโ๏ธ
wait a year or two I guess?
You might try to go hybrid tbh, its in very early stages
i remember Sark saying that only whoever wrote that package can understand it
as a beginner programmer i can tell that all this DOTS ECS stuff is not beginner friendly at all. But a have feeling that if you know how to do stuff, DOTS gives you freedom to do whatever you like and how you like. But for us beginners there is only to ways, try to use some hack to bridge old unity staff with dots, or just wait until unity make everything friendly for beginners๐ค
Yeah
a year or two ago the best option was to wait a year or two, just sayin'
don't ever bet on unity's experimental features, always consider whether it is usable NOW
if it doesn't suit your purposes, move on.
public struct MonoReference: IComponentData
{
public MyMonoClass myMonoClass;
}
Is this a bad idea?
I basicly want to call a public method in myMonoClass whenever a collision happens
I am making an "OnCollision" method in monobehaviour thats triggered in an ecs system
So i need the monobheaviours reference in ecs
.
But since unityengine stuff run in single thread, and collision detection is multithreaded, it's going to be weird
It also does let me set the reference in my MonoBehaviour, IConvertGameObjectToEntity
do public class, instead of public struct, however whenever you are going to use that in your system's ForEach you have to run with .WithoutBurst().Run()
For example, i am using this to update my UI position according to my entity's position:
public class TradeFleetUIMono : ISystemStateComponentData
{
public TradeFleetWorldUIMono Value;
}
var cameraEntity = GetSingletonEntity<CampaignCameraTag>();
var rotations = GetComponentDataFromEntity<Rotation>(true);
Entities.ForEach(
(TradeFleetUIMono mono, in Translation translation) =>
{
//logic
})
.WithReadOnly(rotations)
.WithoutBurst()
.Run();
oh, i needed to see how you were referencing to camera
ah nwm i see
public TradeFleetWorldUIMono Value;
@opaque ledge how is this field set initially?
just wanted to show how you can work with reference class, so this way your monobehaviour doesnt need to access a specific Entity's information, you can simply use the example above to set all your monobehaviour's fields.
var commandBuffer = endSim.CreateCommandBuffer();
Entities.ForEach((Entity entity, in TradeFleetData data, in DynamicBuffer<FleetBuffer> buffer) =>
{
var worldUI = mainGameObject.AddComponent<TradeFleetWorldUIMono>();
worldUI.MainText = "Trade Fleet";
worldUI.SetCooperation(data.owner);
worldUI.AddFleet(buffer);
commandBuffer.AddComponent(entity, new TradeFleetUIMono { Value = worldUI});
})
.WithNone<TradeFleetUIMono>()
.WithAll<TradeFleetTag>()
.WithoutBurst()
.Run();
Entities.ForEach((Entity entity, TradeFleetUIMono mono) =>
{
Object.Destroy(mono.Value);
commandBuffer.RemoveComponent<TradeFleetUIMono>(entity);
})
.WithNone<TradeFleetTag>()
.WithoutBurst()
.Run();
endSim.AddJobHandleForProducer(Dependency);
your ecs has reference only to one monobehaviour instance?
So whenever a tradeFleet is created this system creates the mono and assign it, when tradefleet entity is destroyed i destory that mono
they updated https://github.com/Unity-Technologies/multiplayer/:
# 2020-02-24
## Changes
* Upgraded Unity NetCode to 0.1.0, see the [Unity NetCode changelog](https://docs.unity3d.com/Packages/com.unity.netcode@0.1/changelog/CHANGELOG.html)
* Upgraded Unity Transport to 0.3.0, see the [Unity Transport changelog](https://docs.unity3d.com/Packages/com.unity.transport@0.3/changelog/CHANGELOG.html)
* Added new sample demonstrating lag compensation.```
well you can have multiple if you like, but for this specific case yeah
A sample showing a way to implement lag compensation based on Unity Physics. In a game based on the Unity NetCode the client will display an old world state, lag compensation allows the server to take this into account when performing raycasts so the player can aim at what is actually displayed on the client.
in TradeFleetWorldUIMono's Awake i have this:
worldUI = Instantiate(CampaignManagerMono.instance.TradeFleetWorldUIPrefab, new Vector3(0, 100, 0), Quaternion.identity);
controller = worldUI.GetComponent<TradeFleetWorldUIController>();
i instantiate the 'real' monobehaviour i want to manipulate
you can probably just insantiate from system as well but i rather do addcomponent there
and i also have other methods to manipulate the real mono, such as MainText, SetCooperation etc.
I'd like to assign this field (reference to mono i mean) in my "ConvertedEntityHolder : MonoBehaviour, IConvertGameObjectToEntity"
In it's "Convert()" method, but i get this error
ArgumentException: A component with type:RigidbodyMonoReference has not been added to the entity.
Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType)
private Entity entity;
private EntityManager entityManager;
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
{
this.entity = entity;
this.entityManager = dstManager;
RigidbodyMonoReference rigidbodyMonoReference = new RigidbodyMonoReference
{
rigidbodyMono = GetComponentInParent<RigidbodyMono>()
};
dstManager.SetComponentData(entity, rigidbodyMonoReference);
}
do AddComponentData, i believe Set only works if it already exists
๐
yeah, it works this way
Knowing how to do 'bridging' from ECS to Monobehaviour world is a very useful knowledge, you can use that knowledge to overcome ECS's current incapabilities.
to a certain degree anyway, i dont do any 'special' stuff, i am current using it for world UI
this schedule() method, it only adds the jobhandle in to the given inputDeps right?
with the right order
Schedule(inputDeps) means, the job you are currently scheduling depends on "inputDeps" jobHandle
When i call systemGroup.Update(); in monobehaviour, do you think it does the Comple(); thing?
Does it stop the main thread until everything is done i mean?
Or do i have to make it in a job and call Complete() on it?
I never tried sorry
Hmm, if i use class instead struct when defining the ComponentData, it doesn't let me use
GetComponentDataFromEntity<MyDataComponent>()
But if use struct, it doesn't let me store a class reference in the MyComponentData
I don't think i can do this with Entities.ForEach like you are doing
because i need to do this in a "ICollisionEventsJob"
Should i store an integer id instead?
And then i can look up in a dictionary for the class i want to reference?
Is that the only way?
This is what i mean
Hmm ๐ค
Is that the only way? thats the way i did it for ECS interacting with mono UI components. But uhh, have you looked at AddHybridComponent? thats a new thing since i evaluated the options.
so..... with the new SystemBase, we can finally get away of this IJobForEachWithEntity_EBC nonsense
you could do it with EntityQueries tho it would feel like its 'hacky', something like:
var query = GetEntityQuery(typeof(MonoBehaviourClass));
var queryEntities = query.ToEntityArray(Allocator.TempJob);
var queryMonos = query.ToComponentDataArray<MonoBehaviourClass>();
Then in your collision job:
//Do collision check and find hit entity
var index = queryEntities.IndexOf(hitEntity);
if(index>0) queryMonos[index].MonoMethod();
hmm, looks nice
I do wonder when they'll solve the lack of ReadOnly tags with the Entities.ForEach though, there has to be better solution than making intermediate struct that has the component you want with readonly tag
there is WithAll<Tag1, Tag2, Tag3>() method, thats enough for me ๐
is the WithAll cheaper than the ForEach or is just for convenience?
there used to be cap on parameters you could feed on those in past too so I could imagine it's just easier to filter with two separate things if the others don't need ref
oh wait I remember now, tags don't work on foreach
it still feels bit weird that it's done separately IMO
what do you mean by tags ? they are IComponentDatas without any data in it right ?