#archived-dots
1 messages Β· Page 172 of 1
TransformAccess, TransformAccessArray, and IJobParallelForTransform still are around
and give you direct access to the transform data
I saw that. I wish there was more of those kind of Jobs that are tightly coupled to the engine
They're.. around
Animation Jobs are there
and I think there's an audio job somewhere
but that's about the extent to which you have non-main thread access
You'll otherwise need to manually copy data in and out yourself
Yah, I really need to look at how many resulting "commands" I'd have, and the cost to back resolve reference data
OK, another noob question before I dig into this...
Lets say I have MyTransA: IJobParallelForTransform and MyTransB : IJobParallelForTransform
I can just make hundreds of A and B, and intermix them into the same JobHandle?
Or, can I just intermix anything in that JobHandle in general, irrelevant of it's interface
if you mean combine dependencies, use JobHandle.CombineDependencies(dep1, dep2)
Well, no. Dependencies are something separate. I'm just trying to get an idea of how to layout my data and calls
I think I know how I should lay it out. Maybe...
you want two jobs to do a write operation on the same list of tranforms?
what do you mean by MyTransA: IJobParallelForTransform, a native array being used in two jobs?
oh transform access array?
Here's my idea for the current work flow:
I'll have a container MyThing, that specifies four jobs, each depending on each other TransA > B > C > D. That container will return a JobHandle for the dependency chain with each precise Job implementation.
Once a frame, a manager will loop over all the MyThing in the game. Maybe a dozen, maybe hundreds, and schedule the MyThing jobs under one JobHandle as Schedule (each MyThing are self-contained)
Each Job MyThing may result in zero or more CommandThing. The manager then iterates over the CommandThing when the whole schebang is complete.
Any CommandThings that are Transform, will get batched under IJobParallelForTransform, but others may be relegated to the main thread due to referencing issues
I'm going to try to schedule this early frame, so it's definitely complete before Update(), and use LateUpdate or my own PlayerLoop injection
@violet cosmos generally speaking they will allow you to do so
But it likely aren't going to be what you expect
If both run at the same time
The application order or values may not be guaranteed
Orrr Unity might have a safety check for it
unity has a safety check for it
Sorry, what "both" run at the same time?
I'm not going to run the CommandThing on Update, fwiw. That needs to be on the main thread, or through IJobParallelForTransform whenever that can be slotted
Timing is something that is a big ? in my mind though
But if the data gets completed earlier than Update finishing, then it's a win, because then I can apply it when the thread is free
Is this a good place to ask a question regarding Animation rigging? Since it's running in Jobs?
@violet cosmos you can schedule both but not Complete them until all of them are already scheduled
This means they will both run at the same time
Instead you might want to Schedule one, Complete it, then schedule the second, wait for the frame to be over via Update, complete the second job, and repeat
This introduces a sync point
And is generally undesirable
So pass the JobHandle of the first job into the Schedule of the second instead of calling Complete
This schedules the second to run only after the first is done
what you mean dots style coding?
I have experience with Gameobject style. I need to know a good starting point to DOTS way
think database.
entities are indexes,
components are your columns,
systems are your sql statements
Okay @deft stump
It's as simple as thatπ₯°
I was thinking wrong the whole time
Thanks
Im using "event-entities" for the communication between systems... but there something i cant find a solution for... the destruction, each system fires those events on their own, but they should not get destroyed at the end of the frame, instead they should get destroyed after one frame in total... [SystemA, SystemB, SystemC] -> [SystemB spawns Event-Entity] -> [Event Entity travels to System C, SystemA and SystemB] -> [Once it reaches the System it was created by, it should get destroyed]
Any idea how we could implement this ?
idk but there is already a 3rd party package for that
As the original post is a bit outdated now I've moved it to here
The project and documentation can be found here:...
@stone osprey you just need a way to track them. eg. instead of creating the events straight away, queue them into a system that runs at the end of the frame/group. That event system keeps track of the things it has created and therefore can remove them straight away next update before creating new ones.
By having one system that handles it start/end frame, you don't have to worry about the update order on each system using events, that x must be after y so the event still exists etc that would be a nightmare.
The only downside is that a simple implementation would have most events becoming visible in the next frame rather than the current frame. Which should be fine if everything you've written is designed to be async. But it could be done per-group if you really wanted it.
its also worth pointing out that Tertle's new implementation doesn't use Unity ECS; doesn't create entities or components. Which is probably good if you want super fast performance (if you're doing thousands of events per frame for example for input or something). But if you wanted systems to be able to be reactive / ForEach on the existence of that event data, not gonna work.
@mint iron Thanks a lot ! π That should do the trick... i looked at it, and i actually asked myself how hes able to create those "event-entities" multithreaded π makes sense now... those arent entities
@mint iron Can that be used outside of ECS, for example in just pure Jobs?
@violet cosmos seems like it
It's a wrapper around NativeStreams
Which is a typical native container for CSP style communication
That might solve one of my issues that we discussed yesterday, about building a queue of commands
Depends on the context of what those commands need to be used in
If latency is critical, I don't suggest using NativeStreams and overlapping concurrent systems
As it may break the cache coherency of your CPU
Yah, still need to tighten up that design... Was kind of hoping it would become apparent later
Also if those commands need to be used on the main thread, it's better to build a buffer of commands
Copy out the buffer and run the commands in the main thread while the worker threads continue on simulating
For which, a NativeList or Queue may be sufficient
Yah, that's what I was thinking too. Keeping it simple, but it's nice to have a tool like that should the need arise
NativeStreams really are only useful when you have multiple jobs running concurrently and need to have some streaming communication between them
Netcode is a good example of this use case
If you've ever written concurrent Go or Rust code, they're the functional equivalents of channels
NativeList is thread safe for writes?
I don't think it has a concurrent version no
Pretty sure it does - NativeList<>.ParallelWriter?
Oh it does
Nice, good to know
I just tend not to use it since order can't be guaranteed without sorting
For those interested in netcode: https://forum.unity.com/threads/dots-netcode-0-3-0-released.955890/
NetCode 0.3.0 is a significant change to the authoring workflows for ghosts. We now automatically generate code per component and no longer do any code generation per ghost prefab.
this sounds very nice
Btw do people have ideas about clean ways to do Example scenes & Systems? i.e. I want examples systems to only run for particular scenes and never touch another part of a project. So far I'm thinking [DisableAutoCreation] on the system and ScriptBehaviourUpdateOrder.AppendSystemToPlayerLoopList in Awake() on a monobehaviour in the scene?
when i looked at netcode and saw that its basically creating a heavily hyper-hardcoded codegen per each archetype that you have networked, i inmediately dismissed it
@amber flicker In ECS?
? An example ECS System yes.
If you're doing it in ECS, then there's a tag (I forget which) that you can set on the system that Unity will skip automatically adding it. Then you can inject it only when you need
[DisableAutoCreation] - yes sorry, that was my suggestion above - will edit it in.
That's what I would try first, for simplicity sake
well one issue is you also need to remove it from the player loop on destroy. Not a big deal just wondered if there were any other approaches I haven't considered.
If it's just ECS, you don't need to worry about that... Inject it through the World
If it's in PlayerLoop, then yes... You need to worry about that
Which version? This has changed a lot since the last few releases
0.14 - latest
From what I know, systems arn't in the playerloop, EXCEPT for the root systems
which are the init, simul, render groups
So if you want to remove a normal system, just remove it from it's parent
So someGroup.RemoveSystemFromUpdateList(systemToRemove)
Sweet, thanks... I may have been overcomplicating it. Just trying it now
Hello, can i write to DynamicBuffer from IJobChunk buffer acessor ?
yes
@mint iron example just reading value
Where is write? I have a problem here to write buffer
is it work?
mmm thats a good point, youd have to check to see if making a copy in those methods or giving you access to the source
yes, do u know, about source access of dynamic buffers accessor? i dose not know is it possible or not.
i want refactor arch and i need this information
looks like it gives you a DynamicBuffer instance so you can just set the value normally.
here's a working example, cause im nice like that. :D
https://gist.github.com/jeffvella/16033b6182ee7758ccf609b67f3f6ea0
Hello, I'm wondering if anyone can help me understand pointers a little better.
I found this very interesting code on the dots forum here:
https://forum.unity.com/threads/confusion-about-behaviortree-in-dots.955875/#post-6231711
enum State : ulong
{
WALKING,
TALKING,
CHEWING_GUM
}
unsafe struct Node
{
State state;
ulong paddingSoThatDataIsAlignedOn16Bytes;
fixed byte data[240];
void update(ref Blackboard e)
{
switch(me.state)
{
case WALKING: ((WalkingState*) (void*) data)->update(ref e); break;
case TALKING: ((TalkingState*) (void*) data)->update(ref e); break;
case CHEWING_GUM: ((ChewingState*) (void*) data)->update(ref e); break;
}
}
}
struct WalkingState
{
float3 targetPosition;
void update(ref Blackboard e)
{ /* ... */ }
}
It appears to be an example of how to do a behaviour tree with structs.
I get that we want to cast the byte array to a WalkingState struct pointer, but why do we need to cast to void* first?
((WalkingState*) (void*) data)->update(ref e)
@minor sapphire without knowing the actual return type of Update it's difficult to explain
void* is nothing but a fixed memory address
It can be casted from and to any pointer type
But dereferencing it is a compiler error
And holds no type information so you can't do pointer arithmetic on it
If update returns a pointer
The void* cast may be necessary
But if it already returns a void pointer, that's sort of redundant
it looks to me like update returns void, all it does it interact with the blackboard passed in by ref
the switch is just casting the byte array to a struct instance, it already knows what type to cast to, but is going through (void*) before casting to its final type
@minor sapphire you shouldn't need to cast to (void*) first, but maybe the compiler gets confused cos data is a fixed expression
so you need to insert to void* cast to make the compiler happy
also this thing
unsafe struct Node
{
State state;
ulong paddingSoThatDataIsAlignedOn16Bytes;
fixed byte data[240];
isn't safe for alignment
Today has been one of those days where you think you know c# pretty well but then see how much you still don't know lol
[StructLayout(LayoutKind.Explicit)]
unsafe struct Node
{
[FieldOffset(0)]
State state;
[FieldOffset(16)]
fixed byte data[240];
@minor sapphire this is how you align properly
interesting. this is just so when we fetch data we are minimising the amount of memory words we're accessing or something?
aligning on 16 byte boundry is fairly odd tho unless you are doing SIMD operations, etc. normally you'll align on 8 byte boundry on a 674 bit machine
@minor sapphire depends a bit on exact use case, it's so you don't do un-aligned reads or writes, which are more expensive
now, the compiler will usually align thing properly for you, so u dont need to think about it
but there are cases where it's needs to be done by hand
right
we have built fairly complex AI graphs that all rely on native memory only
i can't say i agree with the way it's done in that blog post
Does it use unsafe?
After seeing what people are accomplishing with pointers it seems like it's a tool one really should know, so I'm trying to wrap my head around these techniques now
yes entire code base is nothing but unsafe code
lol
we have our own C# memory allocator, all collections implemented in native memory, etc.
just mark whole solution as unsafe
yes π
Does anyone know how to get the children entities while using IConvertGameObjectToEntity?
I need to add some components to all of the children in the hierarchy
Try this?
// In the Convert method
for (int i = 0; i < transform.childCount; i++) {
var child = transform.GetChild(i);
var e = conversionSystem.GetPrimaryEntity(child);
// Do something with e
}
GetPrimaryEntity returns the root...
Does GameObjectConversionUtility build it leaf first or root first?
hmm I don't remember π€
You can try a conversion system in GameObjectAfterConversionGroup to try and post process the children
I'm actually manually using GameObjectConversionUtility for this
@coarse turtle hmmm
your method worked
I think one alternative (not that you need it by the sounds of it) would be to have a system that runs in the after conversion group that uses the LinkedEntityGroup buffer
oh cool - didn't know a buffer like that existed
No longer using the Hybrid renderer, but I got some ECS powered animations in now
The fresnel hitboxes are pure ECS
sweet. how do the hitboxes follow the transforms at the moment? are the relevant transforms preserved as ecs entities with hierarchical relations (LocalToParent etc)?
- Construct a Playable
- Copy Player transform from ECS to GameObjects via CopyTransformToGameObject
- Evaluate the playable for the gameobjects given data in ECS
- Copy bone transforms into ECS via CopyTransformFromGameObject
- Use bone locations to drive hitboxes
All of which runs in a manually run loop
I need to verify whether this is Burst-style deterministic
since it leaves ECS to sample animation right now
And I need to confirm this doesn't break existing rollback
oh, that's neat!
can't say anything about determinism, think fholm mentioned that everything animation related in unity's internal systems is probably not deterministic, but it would be great if this approach works.
It's a holdover until the new DOTS Animation system is more stable
and I'm not too worried about determinism of hitbox placement all that much
realistically the inaccuracies may break determinism much less than if physics were non-deterministic
I see,
it is still surprising to me that say gamecube emulator games on dolphin can work deterministically with lockstep netcode (different topic but was just surprised that the approach works, since it works across so many different hardware)
@minor sluice because its an emulator
makes it easy to make it deterministic
you have 100% control over every instruction that executes
and yes, correct - none of the unity DOTS stuff is deterministic except for a very specific condition: Burst running on the same architecture + platform, that is deterministic
is that a given that that the instructions are translated in a way that they behave the same when translated to different hardware architectures when emulating, or is that more a choice of how the programmers handle the mapping (I guess it's this one?) - with sometimes accepting less accurate but faster emulation
@minor sluice well, depends i suppose - you can have have full control in the translation ofc
something like a snes/nes emulator is just something that reads a binary file (the game) and mapes it to "something" the current architecture understands
and with how fast toadys computers are vs old gaming systems, etc. you have A LOT of leeway
"is just something that reads a binary file ..." is a gross simplification ofc
Ah I see. haven't ever looked into emulation, but the more modern ones seem highly complex.
Anyone try out Svelto.ECS ? Looking into it, looks pretty cool. Also he has a demo project where he uses it and just does the rendering on Hybrid Renderer using Unity ECS as a simple API layer. Neato.
Thanks for sharing, alex. That project seems pretty crazy to take on as a solo dev.
Haha, yeah it's actually really cool, and the example projects have well documented code. Some of the concepts are slightly different than Unity ECS, so there's definitely some learning curve again, but in my mind it could be worth learning as even though the guy built it for Unity game dev for his own studio, it's completely platform agnostic so you could apply it to any C# project. He has a concept called "implementors" that he demonstrates a lot which are basically a service layer between whatever program you're interacting with and SveltoECS, so he uses those to access the components (Transform, Animator, etc) on Monobehaviours, etc.
Example of the commented code... it's good shit.
Unity should follow this guys approach. He said (paraphrasing) "It's impossible to keep my blog updated and write about all the details of new functionality because it becomes outdated, but I will keep the core mini samples always updated to the current release, demonstrating the current best practices".
That seems like a reasonable and really good approach when it's impossible to make full docs all the time.
@tardy spoke The best thing you could do for them is to document the code while you're working on it, and let the autogen docs be more complete
tbh i never saw the benefit of any of the ECSes which are just systems to structure
like they dont provide anything
and at that point you might aswell use unitys or build a bespoke system
they still rely on unity for anything complex
like rendering, path finding, physics, etc.
There is a sense of enforced memory optimization, and structure for multi threaded code. Those kinds of designs are useful
Also, Unity is inching towards making things ECS. Unity Physics package for example is full ECS
yes, but then just use unitys ecs with all its flaws
im talking about third party ECSes like svelto, entitas, etc.
Svetlo has memory layout and "Tasks" for multi-threading, it seems
I'm not one to knock that there's different options
I think you're missunderstanding me slightly
If you use some third party ecs
which still has to hook in unity
to perform any complex task
what's the point?
you're just shoveling data between unity and some unsupported third party ecs for no reason at all
like you cant really DO anything with the ecs, so yeah multi threading and such is great
but when the physics engine, path finding, etc. that it hooks into
doesnt support threaded queries, etc.
or any threading at all basically
what's the point
Those APIs that Unity provides aren't just trash because you've structured your application code differently
It really depends on the application you're developing. Some have a distinct benefit for using an ECS system, others it might actually be a detriment
I could see how a Civ like game could benefit greatly from ECS, where a Match Three type game would be more difficult
So, if you have the bulk of your work per frame in application logic, CPU side...
But then just use unitys ecs? because it can actually benefit from the threading for real as it can perform queries and interact with the rest of the parts of the engine on threads
Unity ECS isn't so... complete. It feels like it's mixed visions. At least something like Svetlo was developed with a clear vision in mind from someone who's out there making games. Unity, honestly should really make games like Epic. Not tech demos, real production games with a the most talented workflow oriented people they can afford
idk, i just don't get the point - unless you have some very specific requirements for w/e reason
Trust me, I have a great use case for ECS, but it doesn't work with Unity's system, at least not now
But, I'm moving that system into Jobs because.
I don't fault anyone for organizing their code in a way that makes their life easier and more matches their desired workflow. That's why we have options π
like i see the point of ecs in general ofc, i just don't see the point of these ECSes which dont actually provide anything, other than an architectural pattern which sure is a benefit, but not enough imho
we use an ECS, and unitys ecs im sure will be good in the end also
Enforcing structure is what API does
The ECS craze just reminds me of the MVC craze around 2005 in the web world, everyone and their cat builds an ECS lol.
and maybe 1/100 of them are actually usefull
Possibly, yah. But here's another angle to look at. We have people here who are very new into programming, and yes you could make the argument that they should learn how to organize their code so it's laid out in a memory efficient way.... if a structure provides that through pattern, then it's a win. Said people can get on to making games
Look at any good framework at all, not just ECS. They enforce patterns and structure upon the developer that optimizes the workflow to the needs
I'm sure even a quality netcode library does that, enforces a structure that reflects best practices π
Sometimes though, that structure doesn't work. The exceptions break the rule. For example, for me. I can't use Unity ECS or Hybrid in the way it's "designed efficiency", unless I make some serious changes to the application design
There is nothing bad with having well architected solutions to problems.
I never claimed that either :p
But this thing where, i mean i lost track of the amount of ecs:es there are just for unity
And they all provide.. basically nothing
And most people using them don't need the "performance" they can deliver
I say "performance" because most of them don't perform that well tbh
ECS is old as dirt in games... My first experience with ECS was using libGDX in Java years and years ago: https://github.com/libgdx/ashley
For libGDX, it added a lot, because that's just a graphics library at it's core
Yeah, its the same with MVC is old as shit way before the web craze about it
Just people picked it up around than
and it became the "in" thing
and yeah sure, if you just have a thin rendering api
i'm not saying it's wrong to structure your code well
For Unity, ECS adds a way to manage large homogeneous pieces of data
For Svelto, I think the goal for ECS was to make a more maintainable pattern for data/threading
i'm saying that this influx of ECS:es, which essentially don't do anything other than bind you to someone elses architecture - they are just not needed
True, but if you're not interesting in writing that, and want to get onto the work of making games, what's wrong? Unity "soft enforces" a pattern too, with MonoBehaviour, GO, and Components
What im saying is just, we don't need all the ecs:es and most of them are shit anyway. I have no idea if svelto is good or not, or how it performs or anything like that. I just think they are utterly pointless.
@trail burrow A few potential reasons could be 1. Don't like OOP. 2. Don't need performance of Unity ECS and would rather use GO's. 3. Don't want to wait for equivalent DOTS functionality. 4. Almost every third party package has documentation and is designed to work with GO's.
The guys in the functional side of programming think classes, interfaces and inheritance is pointless too π
I use FP every day fwiw, for game dev
They're just a framework... OOP is also a framework, haha.
That's the thing: It's the flavors and options that work for the person/studio. If you forced functional programming on everyone, then someone who would rather work in OOP wouldn't feel like they're working in their most comfortable workflow
A tool to get a job done. For me my own concern is with code architecture at scale since I don't have enough experience to do it properly, I would need to rely on a framework that handles that aspect for me for any type of success, haha.
The benefit of ECS would have the same affect as React had on web dev stuff. It will create a form of standardization which, even if the approach is imperfect, helps unify efforts between devs because at least there are some standard practices.
If I was running a game studio, I would enforce the usage of ECS simply to keep everyone on the same "page" without needing a ton of lengthy discussions because there are literally limitless options to architecture. Some limitations are great, especially when it comes to actually getting things finished.
ECS is a pattern, React is an implementation of MVVM isnt it?
And again, im not against ECS.... we use a custom linear memory ecs ourselves
You could also write a program in binary, but you have to draw a line somewhere, right? I feel there is a continiuum of abstraction and the appropriate tool for the job at hand, and the most appropriate tool will definitely vary from person to person.
You are missing the point im trying to make, I'm just saying this influx of random ECSes is not needed, not saying we don't need a good architectural pattern to deal with game-dev in general.
I'm not convinced ECS is "it", but it offers some clear benefits in terms of structure so for now that's what we're doing
Oh, if you're telling me everything has already been invented and programming trends just cycle, yeah totally agree.
GitHub has like 30-40 unique ECSes just for unity
No, it definitely won't be the last trend and something else trendy will come along, haha. Or technology will change and make it's approach irrelevant, haha.
I think a lot of those ECS systems for Unity are really just fighting against the MonoBehaviour.Start/Update paradigm, that fits their own flavor
However, for me, I much prefer the ECS approach because I find it easier to learn things when the structure is more ridgid. OOP has evolved quite a bit over time and there are a lot of "exceptions" to it that I find make it difficult to really learn "well". It would take a long time.
It's almost like learning the English language (exceptions and "magic" everywhere) compared to learning something like Spanish (extremely few exceptions to grammar rules across the entire language).
What people call 'OOP' now a days isn't really how it was originally intended, but tbh that's another discussion
Yeah, I agree, totally.
the whole inheritance-chain-interface-etc. thing is just stupid
I basically agree with @trail burrow - I'm glad those projects exist and I wouldn't be surprised if Sebs Svelto has some better ideas in it. I'm not going to install any of them though.
But to me I feel that since OOP keeps bending it's own rules to basically implement functional programming practices... why not just do functional programming, haha.
Haha, if y'all think that level of fuckery is bad
@amber flicker They are, essentially - useless. They give a slightly different way to structure your code... ugh so what is all i'm saying.
Y'all should see the hoops people go through to get mutability in Haskell
They serve 0 purpose
@dusky wind I think ur missing the point of the discussion we're having :p
Well, the thing I like about Svelto is the platform agnostic nature of it means it could be reused, so you're not just learning a bunch of custom syntax for a "one off" necessarily. I would prefer to learn Unity ECS as it will evolve and increase in value, but I feel right now svelto may be a good train off to learn because you learn a lot of the concepts, and you're not restricted by waiting months/years for DOTS functionality to catch up. Realistically you could make a full featured game in Svelto today, but not with DOTS yet.
@tardy spoke you dont really make a 'game' in svelto tho, you strap svelto on top of unity and make your game in unity go/mb system
Yeah, totally
its just structured differently vs how it would be in normal unity
which is why i think it's basically useless
No it makes plenty of sense, structurally ECS doesn't necessitate better code.
Which is why it's called DOTS
But that's actually what I'm looking for. Ever since I tried putting a DOTS animation in a subscene, I realized it would be quicker to learn an entire new system that uses GO's than for me to figure out how to "hack" DOTS into working for my needs. Massive chances I'll run into other issues as well that have already been solved in GO world.
ECS for unity and many other engines is really just a way to more generically apply data oriented design
Though you can have ECS without it
@dusky wind we're talking about all these third party ECS:es for unity, which basically serve no purpose IMHO.
not unity ecs
at least me alex/benjamin were
anyhow, convo derailing fast and i think i said all i had to say π
or feels like it will derail
Ehhh, I've messed around with Entitas and several other codegen based ECSes
They serve no purpose imho
They definitely don't immediately show good results when there's a lot of global behavior.
They allow people familiar with ECS systems to implement their knowledge in Unity. Isn't that valuable enough? Even if they have no performance benefit?
But to say they have no purpose is a overly broad statement
They may not be valuable to a lot of people, but to some people they would be extremely valuable. Like in my case - I can't really make the game without it.
my POV more comes from the fact that they are just strapped on top of unitys default systems and offer basically nothing other than locking u into some architecture that you dont have control over
but anyway said that like 10 times now so
Β―_(γ)_/Β―
So you just don't like frameworks in general?
That's cool. I understand both sides of that.
@tardy spoke if they provide something of value sure
I don't quite understand why to use a third-party ECS due lack of features in Unity's ECS, if in the end you will need to find a way to communicate the GOs with that third-party api just like you would with missing Unity ECS features in hybrid
Some of them are divorced entirely from Unity's default systems
@rancid geode bingo.
And some run entirely outside of Unity
yes, ours can do that also
yea you'd probably just get a frankenstein like system architecture which gets difficult to follow along with third party systems sometimes
but it actually PROVIDES something you cant get with unity
not just a fancy archicetural pattern
So some do have some added benefit of running completely independently of the engine
that someone obessed about over and over
If you intent is to not stick to Unity, then it is a valid point @dusky wind, but for someone who alredy settled the engine to be used, why then?
The idea is mostly for using Unity as a frontend
@rancid geode running outside of unity has massive scalability benefits when dealing with server hosting/networking
@dusky wind this what quantum does, client side frontend
Svelto ECS system is designed to interact with GO's. Unity ECS seems like it really isn't designed well for that, though you could "hack" it into working.
Yes, and that has a provides a decent common structure.
Well, actually
Like you admit that these frameworks can be used to isolate game logic from the actual engine
But see no purpose in them?
Dunno, having worked on quite a few large projects across teams, I feel architectural patterns are important
@dusky wind no you missunderstood
@violet cosmos totally agree
@dusky wind it is a benefit to be able to run outside of Unity, if the framework can handle that and allow you to lift your entire game outside of Unity. But none of these third party ECSes can do that because they are bound to unity because they use all of unitys features for physics, navigation, etc.
Yes sure some games you can build without that, but not a lot
So then there's no point again.
I do agree that these frameworks do need to provide a significant win over vanilla Unity other than just structure
Because sure they CAN run outside of unity, but if you want to make a game... they cant
My question is if you feel that the solution of learning a third party ECS is not good, what would your solution be? And would your solution change if you were bad at OOP? Haha.
But to say that they inherently have no value is an oversimplification
@dusky wind yeah sure, it is - but not too far off from the truth
I understand if I was godly at OOP I would definitely not go this route, but that's not the case.
As someone trying to limit my use of MonoBehaviours.... There's a benefit. I'm sure we've all read the "10000 Updates" article
@tardy spoke well i have my own ECS i build all my games in, but its actually a standalone system which doesnt depend on unity for ANY game logic.
So your solution for me is to become you and build my own ECS?
That may be difficult
that's not what i said π
I will start with mimicking your movements and speech patterns and we'll go from there. Seems like learning an ECS may be easier though.
Β―_(γ)_/Β―
@rancid geode running outside of unity has massive scalability benefits when dealing with server hosting/networking
@trail burrow well, yeah, this is a valid reason, but this is due your project needs that, not due "Unity ECS is lacking too much"
I'd always say evaluate the project requirements before deciding on a solution.
@rancid geode not talking about a specific project here or anything, just said thats a proper benefit.
In this industry, there really is no one size fits all
not just "oh i can structure my code a bit differently but still nailed down to gameobjects old ball and chain" π
@dusky wind yeah, agree. You also have to evaluate your own skill levels and weaknesses, haha.
Svelto ECS system is designed to interact with GO's. Unity ECS seems like it really isn't designed well for that, though you could "hack" it into working.
@tardy spoke I find it quite the opposite, Svelto ECS is designed to interact with any engine, Unity ECS is designed to interact with GO
the work you will have to integrate GOs with Svelto ECS will not be that different (if not bigger) than with Unity's ECS
GameObjects aren't really a ball and chain, I mean zillions of games were made with them hahah
I don't really need the performance. What I need is a finished game.
I can have a really fast nothing, or a slower, but hopefully playable something.
@rancid geode yeah, it is designed to be agnostic, that's true. UECS can definitely interact with GO's, but I feel you'd have to build a bit of additional tooling unless I'm missing something about a clean direct way to interface with a GO right from a System.
Currently, it is possible to do a full ECS game using only existing GO stuff (without Hybrid Renderer and Unity Physics, for example). You probably won't have performance gain, neither multi-threading, but your code would be well structured already (and once the missing features lands, you could migrate little by little too)
you're just creating more work for yourself strapping some third party thing on top which provides almost nothing
making most of your code and workflows
incompatible with various assets, etc.
I think the problem is when we try to do UECS stuff with GO stuff with performance in mind, which is when we start to hack the system to try to fit them together
Fitting UECS with GO is as easy as using Convert & Inject and using AddComponentObject when needed
There are... A few more quirks
Hmm, maybe my best approach would just be UECS with GO's and then adding in the DOTS functionality as it's released
if there was one word i would descrive the unity ecs with it's "quirks" yes @dusky wind lol
And the bonus part is that it works with existing Asset Store assets too without (much) additional work
The only problem is that you have to use GO's until basically ALL the entities DOTS shit is done lol
But yes it's not as hard as it is in most other GO-wrapping frameworks
If you are used to event-driven architecture it is even easier to join those two "worlds"
Hmm, maybe my best approach would just be UECS with GO's and then adding in the DOTS functionality as it's released
@tardy spoke this is what I have been doing to be precise
I'm not sure how well they've standardized the use of Disabled wrt linked GOs
@rancid geode do you have an example of on of your Systems accessing a GO directly?
Or as "easily" as you could?
What was your solution for that? Is it fairly clean?
I can see to provide some for you, yes, most of my stuff is under NDA so it is hard to just pull something right away haha
Yeah, no worries, just curious haha
I don't remember exactly how to do it, but I distinctly remember it involves IManagedJob
Or something along those lines
And just fetching the GO/components via AddComponentObject and ComponentDataFromEntity
Might have changed in later versions of Entities
if someone has a clean solution I'll do it, but my thinking is I always seem to just run into weird stuff with DOTS / hybrid, and I think in terms of actually trying to get something "done" it may not be the best approach at the moment.
I also won't even be able to use subscenes for my main world with GO's which was pretty much 70% of the reason I wanted to use DOTS in the first place, haha.
Yeah, that's what I'm talking about
And am just using the GOs to render
Like you have to go full GO or full DOTS, and DOTS simply isn't complete, so it just makes things pretty awkward for development.
@tardy spoke here for example would be an GO -> Entity interaction
public sealed class FpsCounterSystem : SystemBase
{
public delegate void FpsUpdateHandler(int fps);
public event FpsUpdateHandler OnFpsUpdated;
private int _elapsedFrameCount;
private float _elapsedTime;
protected override void OnUpdate()
{
_elapsedTime += Time.DeltaTime;
while (_elapsedTime > 1)
{
_elapsedTime--;
OnFpsUpdated?.Invoke(_elapsedFrameCount);
_elapsedFrameCount = 0;
}
_elapsedFrameCount++;
}
}
public sealed class FpsText : MonoBehaviour
{
public string FpsTextFormat = "FPS: {0}";
private Text _text;
private void Awake()
{
FpsCounterSystem fpsCounterSystem = World.DefaultGameObjectInjectionWorld.GetExistingSystem<FpsCounterSystem>();
fpsCounterSystem.OnFpsUpdated += HandleFpsUpdated;
}
private void Start()
{
if (TryGetComponent(out _text))
{
_text.enabled = false;
}
}
private void HandleFpsUpdated(int fps)
{
if (_text == null)
{
return;
}
_text.enabled = true;
_text.text = string.Format(FpsTextFormat, fps);
}
}
It's almost like the best approach right now is "learn ECS, but make your stuff in GOs with ECS in mind, and plan to migrate it over in a year or so", haha.
I just have a simple few systems that import/export between GO and ECS state
Yah, that's my plan for the systems that I'll use Unity ECS for
For me, ECS is the real game simulation
They will just be organization systems, with many inputs and few outputs
GOs just display the view of the data in that simulation
But, depending on how my learning with Jobs goes, may not be necessary, because I feel like you have more control over pure Jobs in the frame lifecycle
@dusky wind you were able to check the size of your world, right? how'd you do that?
@hollow sorrel SerializzeUtility
Then just record the size of the buffer
Realistically it's bounded by 16KB * the number of chunks in the world
Not a particularly good solution when you have a lot of singleton archetypes
seems serializeworld also serializes blobassets tho, dunno how i feel about holding a copy of each static blobasset for every rollback frame
does it serialize the entire chunk no matter what?
@rancid geode thanks for the example, I'm studying it, haha
would it be better to just hold an int pointing to a blobasset? 
@hollow sorrel oh for rollback
seems kinda roundabout
I just make dummy Worlds
since a blobassetref already basically is a pointer
And use EntityManager.CopyAndReplaceEntitiesFrom
Nope
It's a MemCpy
gotcha
Takes max 0.1ms on my machine for a small 220kb world
I havent tried scaling it
It's negligible compared to full serialization or the simulation latency
you do this how many times per frame? or only on rollbacks when you reset to a verified state?
I do it once per game tick
To save multiple copies of the world, one for every game tick
Then once again when rolling back
you do it once for every predicted frame also?
Yes
basically a ringbuffer of worlds
Yep
128 game ticks is about 27MB of memory
Less than a 1024x1024 uncompressed texture
So I don't particularly worry about the memory usage
nah thats usually fine no matter
because u will have porlbems with rollback perf before u run out of memory
on any modern machine
i.e. its too much data to copy
I haven't tried this yet with managed components
But it worked perfectly when in Pure ECS
we moved away from the ring-buffer model
it's too slow for more complex games with a large game state
but for fighting/brawler/etc absolutely it's a good way of doing it
easy to implement, rock solid
@hollow sorrel I'm not sure if I showed you this already
I'm under an anti-NDA
So here's the code for my world pool and rollback world save/load
lol anti-NDA
oo you actually have a bunch of worlds, didn't know if they were lightweight enough
ah makes sense
And when you make them, they come without any systems
So it doesn't simulate, ideal for a snapshot
Late joiners are not a problem for my game genre
reconnect is the same problem-ish
Reconnects I'm considering sending them a replay file
I just implemented replays
Assuming determinism
They're less than 100KB for a minute of gameplay
that seems like a lot
So I don't think it's unreasonable to just sent them the full input history after a certain frame
why not just latest snapshot + inputs in between
Most of these games is less than 5 minutes
Yeah
not a lot of data
Includes checksums for each frame
But realistically any long term disconnect is likely just going to boot the player's back to the lobby
It's fast paced enough that I don't expect players to get hung up on disconnect issues
Only when it happens repeatedly
Which I think is mitigatable outside of the core game
Crap, well ran into my first problem with generalizing a scheduling system...
If I have a class that has a method like public IJob CreateJob(foo,bar); I can't schedule it because the Jobs API complains it doesn't have a type
@hollow sorrel haha, the game state is already 200+kb
A snapshot is worth 2 minutes of gameplay
I feel like there's some way I can mark the struct to do this....
true but i imagine loading would be faster than resimulating the game
Also the snapshot includes local information like pointers
Which will probably segfault if I loaded it elsewhere
ah
yea i'm trying to avoid any local info like pointers in sim world
and if there is then it should be rebuildable
@violet cosmos back when jobs came out I figured out how to make my own custom jobs
Any thoughts on how to markup the return value so it can take anything IJob?
@trail burrow what is the alternative to ringbuffer
@hollow sorrel internal pointers was a huge issue
But it may take me some time to dig it up
until we solved it once and for all with the allocator
i mean not an issu eas it would break the games, but having to deisgn everything w/o internal pointers is a PITA
rollback netcode and simulation for figthing game is easy because their structure is clean without too much internal complexity
but for more complex games, it becomes a PITA
yea i'm designing with indirection everywhere and it is kinda a pita
I'm assuming y'all just used integer IDs that were universally consistent
before the custom allocator yes we used that
but its just a pain to deal with on a large complex codebase
I can see why, haha
what's the alternative to ringbuffer that is somehow faster
just using 2 states, one verified and one predicted
and dont save any inbetween states
say im on Frame40 verified and Frame50 predicted
Your simulation needs to be pretty darn fast for this though
when i get all input for Frame 41, i simulate that on the verified state
and then copy it over to predicted, and re-run the sim
to catch up again
its faster than saving a ring buffer
cos theres a lot less memory to shovel around
For large worlds, I can see that yeah
ah i see, so result is you're always resimulating max frames right
no
i re-sim whatever is incorrectly predicted
or rather to whatever tick is incorrectly predicted
its much faster for large worlds, as you will get to a point where the actual shoveling of memory around is a substantial part of ur frame time
espc on mobile
ahh
but its a more complex setup
the ring buffer solution is what we used originally
because its a clean, clear system
very easy to reason about
but it has drawbacks when u start getting into larger game states
Do you know at what threshold did it start overtaking the other parts of the loop?
Size wise?
and we have people building 64 player games on quantum, with tons of NPCs, players, etc.
@dusky wind on mobile its already around the size ur at now
on pc its at around 1mb iirc
Interesting
maybe 2mb
im working on another idea, which is just a prototype, which uses copy-on-write semantics and immutable memory to not ever have to copy any memory at all... but that's just a... hobby prototype for now
nothing thats considered for quantum itself
it also gives "automagic" safe threading
LMDB does something similar for it's storage engine
yeah, but we operate on such tight timings that a lot of the traditional 'best practices' to scale systems like this goes out the window
i've read more whitepapers on this stuff than i'd like to admit lol
I'm not sure if the immutable memory will work well with data oriented systems though
It definitely seems like a fast way to invalidate your cache lines
it does work, i used it for a prototype mmo backend
it performs very well, but it imposes a bunch of annoying architectural restrictions
on how you design the game
so i dont think its generally applicable for "any game"
but some types of games could benefit from it
if i ever get to finishing it into something useable
@hollow sorrel are you designing ur own predict-rollback thing?
or just curious
this is the third or 4th day we've discussed stuff like this
yea would like rollback multiplayer in the future for my lil metroidvania
but also i think determinism would help with doing time shenanigans
e.g. time rewinding/forwarding as a mechanic
yeah there's a few fun benefits
like how you can do perfectly slow motion stuff even in MP, etc.
and mess with time and all kinds of fun shit
which is something we used to do in regular unity but it basically the most inefficient game you could imagine
idk if i ever showed you phased but it's a project from like 4 years ago that i was making with skarik
am rebuilding it now with actual proper architecture instead of gamejam architecture
Haha
Uff, that's super annoying.... .Schedule isn't part of the IJob interface, it's an extension method. Not sure how that solves anything, because Execute is part of the interface and obviously doesn't suffer from unboxing issues but the things you run on the main thread, Run and Schedule aren't
That was is exactly what I was designing for too
One of my characters is supposed to have a time stop on their kit
im fiddling on a little card game on the side, which uses fully immutable data structure for entire game (doesnt need to be efficient or rollback ofc) so i have a full history on entire game and can go back in time and mess with things, etc.
Well, for everyone except thrm
it's fun - not in quantum tho, just built that on the side standalone
@trail burrow played 5D chess?
i have not
i dont have much time to play now a days, but will check it out
Time travelling chess game
Close to the same idea as your card game
will check it out
yea we basically had a full history as well but that was a time when i had no clue about memory management and it was just piling up
we built our own 3D tilemap solution as level builder, think sorta like minecraft
but each single tile would take like 100+ bytes memory lmao
Sounds like it could accrue fast
main problem was we're storing all 6 faces of each voxel since could be a different sprite for front than back/top etc
thought of a more efficient solution for that now still gotta implement tho
god we dont have any recent videos of anything made with quantum that shows the time-fuckery stuff
but yeah its absolutely a benefit
i usually say that building a predic/rollback deterministic game is like building a couch co-op game that automatically works online
and it's a HUGE benefit not having to really think about networking, we have a lot of studios which might not have a dedicated network programmer on staff and they can still pull of insanely good games, with tight AF mp
just because... u dont need to do shit to get mp
yeah i don't want to bother with making sure each seperate action has seperate networking code for it to make sure the other player sees it.. i just want to make game and have other person see the same thing
yup
one other massive benefit i been thinking about
is for testing you can just play your game once, store all the inputs of that playthrough and next time you just hit play on your robot and check if end position/win condition is still achieved
need to redo that if main stuff changes ofc but still
should save a lot of time making sure level still works as intended
yes
we have people doing that
espc once they get pretty far into dev of the game
to be able to verify everything still works properly
they have huge piles of replays
with pre-recorded start state, input and end state
this can also run outside of unity
so easily hooked into a test runner, tooling, etc.
yeah
the largest benefit is not having to think about MP at all in the gamelogic
i could never go back to doing it the old way
i feel like even if a game is fully singleplayer i'd prob still try to make it deterministic tho, at least if you already have basics like deterministic physics etc built once
the costs aren't that big compared to the benefits of debugging, being able to use it in game mechanics, is nice for speedrunners too since it's always same result, etc
and having a seperate render/sim loop is also huge
public override void Update(Frame f, ref Filter filter) {
var input = f.GetPlayerInput(filter.PlayerLink->PlayerRef);
var thrust = (FP) input->Thrust / 100;
var rotation = default(FPVector3);
rotation.X = -input->Pitch;
rotation.Y = input->Yaw;
thrust = FPMath.Max(thrust, rotation.Magnitude / 10);
var fwd = filter.Ship->Engine.EngineThrust = FPMath.Lerp(filter.Ship->Engine.EngineThrust, thrust, f.DeltaTime * 5);
filter.PhysicsBody3D->Velocity += filter.Transform3D->Forward * filter.Ship->Engine.EnginePower * fwd * f.DeltaTime;
filter.PhysicsBody3D->Velocity += filter.Transform3D->Right * filter.Ship->Engine.RollPower * input->Roll * f.DeltaTime;
this is some code from some random space ship prototype i made
and that's... it right
there's no replication of state, no manual prediction, no nothing
@hollow sorrel tbh making something deterministic, espc if you need like physics and navigation and shit is a huge task
yeah but that's stuff you only have to do once right
i'd prob do that anyway because i try not to use unity stuff
depending on what game ur trying to build
making like a deterministic 3d physics engine
is SO. MUCH. WORK.
hah i guess so
hole in the market there tho
0 CCU quantum package aimed at singleplayer games
we have one person on each part now a days
of the engine
they had to, legitmately, come up with custom algorithms for various collision checks because of the lack of precision in fixed point
so at least 2 completely new ways of doing collisions checks for some volumes had to be developed
yea i imagine there's a lot of cool tech in there
one of them was sphere<>ray, where the classic techniques you can read about online dont work when distance between sphere and ray origin is too large
or basically the "way" to do that check, does not work in fixed point
i know there was another one but it slipped my mind which it was
if you started to make a singleplayer game today tho
would you go the normal route
unity way
or use quantum
depends on what it is
the card game im making i did not use quantum for
i wrote a new framework for that
but card game doesnt need any fancy physics or shit
tru
thats also mp, co-op at least
but yeah idk tbh
depends on the game
if i could make it in quantum i would
because it gives me 'free' mp
when/if i want it
yea makes sense
wow a competitor to FPSSample
ye
that's pretty cool tho, a lot of advantages to building full games with your own tools
assuming it's more than a sample
we'll see what it ends up as
do you have a seperate team for it or is it same quantum engine ppl
could just have a buncha teams for seperate games
infinite growth
separate team doing fps stuff

nice
but yea just to steer it back to DOTS talk i don't think i'd bother with determinism if it wasn't for DOTS, even though a lot of it isn't deterministic
making deterministic tools with ecs architecture is a lot easier than the monobehaviour mess we had before
still not happy with my current render/sim seperation tho
right now i'm just querying components that i want to copy data from in the sim world and copy it into render world
but that's a lotta boilerplate and not sure if efficient either
dunno what alternative would be tho
Hey there. Anyone knows why the Unity Physics doesn't appear in my package list?
I enabled preview packages in advanced settings
Thanks @tardy spoke I thought I was going mad
If I have ConvertAndDestroy and OnDrawGizmos on an object, it doesn't draw after a play-stop cycle until I select it in the hierarchy - does this happen to anyone else?
convert and destroy wont work with ondrawgizmos during runtime, ondrawgizmos is a monobehaviour function(which gets destroyed when you convert and destroy the gameobject into an entity)
@safe lintel Sure, but once I stop the game, the gameObjects come back, right? When they do, they don't draw.
I just want them to draw when the game is stopped, (impostors for where enemies are supposed to be summoned)
oh, well not sure in that case, you are definitely using OnDrawGizmos and not OnDrawGizmosSelected?
I saw in the other channel @proven minnow 's sure about that - main other thing I can think of is it's some static array and you have domain reload disabled?
otherwise it could well be a Unity bug
Soo.... What's the way to pass data from one job to another?
I thought I saw that jobs that are in a dependent chain could do that, but maybe I just imagined it. All the examples I see are using the main thread
@violet cosmos assign them both the same collection and put a dependancy between them
job 1 put data into collection, job 2 consumes it
I'm not seeing any good examples how to reference Job1 from Job2, outside of the main thread
no i mean give them accces to the same block of memory frmo the main thead
before u schedule them
job1 writes to it, job2 reads from it
Ahh, so....
var data = new NativeArray<int>();
var job1 = new Job1 {
Fill = data;
};
job1.Schedule();
var job2 = new Job2 {
Use = data;
};
job2.Schedule(job1);
??
ye
Gotcha, didn't realize it had back references to Unity.Collections types declared on the main thread
Do you think it's worth throwing this code snippet up in the wiki?
Just a simple test of what @rancid geode said about controlling GO's
that'd only let you rotate 1 GO?
Yeah, really what I'm trying to get across would be how to access a System from a monobehaviour.
I actually didn't even think of that and know you could do that, haha.
slightly cleaner imo to do Entities.WithAll<Test>().ForEach((ref Rotation... if you're just using it as a tag
in fact I don't know if let's you use in for a tag
Yeah, I can clean it up. Really it just needs the rotation component to get the idea across.
why dont you add the monobehaviour as a param to the foreach?
@safe lintel show an example :O
I'm looking for the most efficient way to do that.
Then I'll toss a wiki page up with the different ways.
var deltaTime = Time.DeltaTime;
Entities.ForEach((Entity entity, MyMonobehaviour myMonobehaviour, ref Rotation rotation, in RotationSpeed rotationSpeed, in Test test)=>{
myMonobehaviour.transform.rotation = math.mul(rotation.Value, quaternion.AxisAngle(math.up(), rotationSpeed.value * deltaTime ));
})
this assumes you have added inject to your monobehaviour or added it somewhere via AddComponentObject
Awesome! I'll fiddle around with it and throw an example of that up as well.
I could see this becoming spaghetti pretty quickly though because for it to actually rotate you have to run the same math on the actual components as well, haha.
Otherwise the component values don't change so the rotation doesn't happen.
Would be handy for some small things like a GUI, but I'm not certain architecting with GO's is actually that straight forward with ECS
if you have added the transform directly on your monobehaviour you could also just directly modify the transform the lambda
//convert interface on monobehaviour
dstManager.AddComponentObject(transform);
// foreach
Entities.ForEach((Entity entity, MyMonobehaviour myMonobehaviour, Transform transform, ref Rotation rotation, in RotationSpeed rotationSpeed, in Test test)=>{
transform.rotation = math.mul(rotation.Value, quaternion.AxisAngle(math.up(), rotationSpeed.value * deltaTime ));
})
ah kinda already on the discord https://github.com/DOTS-Discord/Unity-DOTS-Discord/wiki/Adding-Hybrid-Components
page can probably be expanded to include the variations between hybridcomponent, companion gameobjects and just addcomponentobject
That's awesome!
What happens if you use that and convert and inject or whatever? Is it possible to keep entire games in GO's with ECS that way, or are there weird side effects/it doesn't work? Haha
yeah you keep the gameobject around. its what I do, I dont use AddHybridComponent because theres still a big old warning that its not for production use and I have no idea how its gonna change in the future
Hmmm
@safe lintel I wonder if they would prefer the use of ManagedICD's over AddHybridComponent? It's pretty much the same thing, isn't it?
afaik addhybridcomponent makes use of the companion gameobject system where it hides your resulting gameobject for the sake of tidiness and you kinda work with it but its just invisible, also if you create or destroy the entity, the gameobject follows the same, ie created or destroyed
RayCastCommand seems kind of jank... It just takes a NativeArray, what if you don't know the number of results? Could be 0, could be 100?
Hmmm, strangeness
the number of results is what you input
@safe lintel I don't understand that. If I cast a ray through the world... I can cast one ray that has a number of hits, correct?
but for the hybrid companion gameobject workflow, theres still a warning that its not recommended for use outside of experimenting, so that on top of them not recommending using entities for production has me just ignoring it for the moment entirely, addcomponentobject and just manually managing everything is my own strategy until theres more stability or declaration of intent on what unity intend for hybrid workflows
So, the intention is to allocate an array that is larger than what I expect, and loop through that until Collider is null? That's what the API seems to indicate
i think there was a bug with the number of hits with raycastcommand, its kinda finicky
like it only recorded the first hit? its been a long time since ive used it
"If maxHits is larger than the actual number of results for the command the result buffer will contain some invalid results which did not hit anything. The first invalid result is identified by the collider being null. The second and later invalid results are not written to by the raycast command so their colliders are not guaranteed to be null. When iterating over the results the loop should stop when the first invalid result is found."
Some API there, Unity π
Double you tee eff
How do they anticipate people actually using that?
That's another "might as well not even have made it" type of thing
lmao
seems like another something they wrote on a friday afternoon and then never looked at it again
are you still using physx?
sometimes i feel like unity wields this weird power over me, like, i'll shamelessly eat what they dogfood me because the alternative is write my own physics, renderer, whatever
@safe lintel A link would have sufficed
Fuck, well... Here I was getting my thing ported to Jobs and now this. Like, how do I get all the targets in a sphere?
physics.overlapsphere
Yup, on the main thread
how many things are you running in your scene?
eh there's spherecastcommand but dunno if it has same issue as the raycast one
@safe lintel This system is a light test, many things have raycasts/under/within/etc... But I have a Weapons System that is raycasting hell that I want to put on threads. But, if I can't tell all the things it crossed through, then it's pointless
unity's physx implementation just doesn't really support jobs very well
if you're doing things on large scale consider moving to ecs physics
if small scale then it doesn't matter, overlapspherenonalloc is pretty performant
Then I have to convert everything, it forces me into Hybrid
The thing is... if some use ray casts, and some use sphere overlap, etc etc... and Raycast is broken, then I can't just generalize it as a fully jobified system
yeah
Considering that SphereCastCommand uses the same interface, I'm willing to bet it's the same restriction. One sphere cast, one result
would imagine so
Welp, another few days of my life wasted on DOTS
@safe lintel so you're saying this way is how you're doing it? Haha, seems the end result is pretty much the same, so if this approach is cool it's probably what I'll do as well
Except this is really all just ... kind of pointless since subscenes can't store this shit anyway (can't convert and inject a GO in a subscene) so it's useless for my game and I'll have to wait for DOTS animation, but could be useful for other things... maybe audio?
Wait... nothing will work in this way in a subscene haha
because it all has to reference a GO... lolol
Subscenes = life ruiners
The original terminology was Life Ruiners but they changed it last minute. "Throw all your game objects under the Life Ruiner".
technically there is camera conversion for subscenes, if you enable some scripting define with the hybridrenderer
π€¦ββοΈ
but for everything else yeah antiquated unity stuff wont work with em
The only thing in my game not under a subscene is the character with the camera hahaha
I guess I could switch to world streamer
and give ECS the finger
but like... one of the BIGGEST benefits of DOTS is the subscene loading times lol
could always scale back your idea π©
I think I'd run into the same issues with any idea really
could consider reversing your dependency
add a component that you read at runtime to spawn a GO and link it
then your subscene is 100% entities
They all have unique challenges, etc
Hmmm... I like what you're saying Scorr.
IoC that shit
Actually, yeah, that could work
kinda like how a healthbar doesn't spawn health, health spawns a healthbar
Yeah good thinking to with just a simple component or something and some sort of system that just figures out what to spawn... hmm...
Does loading GO's like that cause a lag spike? Do they async at all? I heard they are pretty heavy to instantiate, but I would only be instantiating I think maybe 20 per tile (subscene)
probably usually 4 or 5 kinda thing.
i used to do similar thing but all i needed is sprites
i would just have an entity with a 'sprite' component, then a spritesystem would spawn a gameobject with a spriterenderer for the actual representation
and a systemstatecomponent to track if the original entity is alive, and if it gets destroyed then destroy the rendering GO too
if your gameobjects are only used for rendering it's pretty simple
if you need more stuff i guess maybe you could link an actual prefab on the component
It might get a bit greasy with my "world moves around player" solution as I'll have to also move the translations of the spawned GO's.
And if you have complex hierarchies, you're hosed
loading GO's is pretty heavy, yeah
you prob wanna look into gameobject pooling
Yeah, could pool 'em
with the open world though there will likely be a couple hundred discrete NPC's at the end or more though... quite a bit to keep instantiated.
I'm thinking maybe switch to world streamer and use the AddComponentObject method and use ECS paradigms while basically creating a GO game. Just use ECS for heavy logic systems or systems that can be optimized... maybe switch some systems over when the tech comes out...
Systems that don't require Hybrid
I forsee multiplayer and VR interaction being a huge issue with entities
Yea exactly @violet cosmos
I'd definitely use Unity.Physics if I could get away from GameObject conversion and they gave me the option to just inject the entity part
Hybrid is like... terrifying, haha. It could change at any moment, you pretty much know all the code you write will have to be re-done later.
if you go full seperation between simulation and rendering, where simulation = your ecs and rendering = your GO's, you could despawn GO's that aren't in view, but keep their entity representation ticking for AI behaviour and whatnot
Hybrid is going to have to change. What they have now: There's no way this is "the way", SubScene is teh suck
Subscenes ... don't work.
They work for what they're kinda supposed to do, but what they do isn't very conducive to making games, hahah.
they're great if you don't use GO's π
@hollow sorrel yeah I think that's the idea. The server will be keeping track of all locations of enemies
Client will be mainly rendering I believe
Yeah, totally
Exactly
And SpatialOS has it's manual written for integration with GO's, so that could potentially be a rabbit hole to try to get it working with entities
Between implementing SpatialOS and some VR framework, the thought of having to convert them to work with entities is pretty concerning, hahah. Could easily take me months of work, if I could even get it to work at all.
I'm not a big fan of world streamers approach to world streaming (I loathe build times), but at least it's tried and true.
Haha, yeah, I always have a huge project on the go for some reason. I must just prefer the journey. π€·ββοΈ
@tardy spoke When you work on a large project like World Streamer, you just work on sections at a time. You have the build machine do it's thing overnight
You can just organize your areas to be hidden and out of view under a parent
I really wish Unity had a more detailed road map.... Like, if I knew that they'd implement some basic physics calls in Jobs next month, I could keep working on this thing with it's limitations
But, as it stands I can't plan... anything. I can only plan that things will be broken until they're fixed, which may be never
NativeMultiHashMap is really awkward to use, isn't it
(and in regards to the ongoing conversation, I went full-bore dots, no gameobjects for my project, and except for not having particles or a UI, I'm pretty satisfied so far)
@proven minnow How do you deal with nested hierarchies? With my experimentation, if I use EntityManager.Instantiate() or Destroy() on an entity with a hierarchy, it just destroys the top level Entity, and ignores the children exist
What's your way of loading/unloading entities from the disk into memory? Like, prefabs and things?
Do you have any integration with skeletal animation? Mecanim? IK solvers?
@violet cosmos yeah I get it, but subscenes were nice because they actually totally unloaded the sections. Not sure if hiding stuff or disabling GO does a true unload?
@violet cosmos you need a LinkedEntityGroup for the hierarchy
If you delete the root, the children will be deleted too
World streamer does let you only rebuild one target section though, which could really keep those build times down
@dusky wind This is with entities converted by Hybrid. If I load them from a SubScene, and then call Instantiate() it only instantiates the parent
If the entity has the linkedentitygroup in the Subscene it should be saved
Also IIRC unity physics is decoupled from ECS
You can manually make your own PhysicsWorld and query it
Nope, Unity Physics requires IConvertToEntity
It does? The samples don't seem to use it
requires is strong wording, you can construct the physics components manually
Yes, but you can manually create your own colliders
And add it to a physics world without entities
Yes, believe me I've thought of that. But it's kind of all or nothing.... I don't want to pay the penalty for two physics sims running
Yes, but I have tons of code on the existing. Even then, I'm not entirely sure the benefit if the game isn't Hybrid
If you don't need the determinism
Yes there isn't much use for it beyond
Maybe using Havok
PhysX is fast enough. That's not the problem. The problem currently is that I can't call squat usefully from Jobs into PhysX
Ah yeah
*CastCommand is some of the most useless API I've ever seen
The Collider/Ray Cast APIs in Unity physics goes wide pretty easily
Yah, I like how Unity Physics does some things. I don't like the workflow to get there
I fit around 512 spherecasts in under half a millisecond
I really wish they would have packaged tools that didn't do the whole GO conversion, but just the physics side
I mean the only other option is rolling your own conversion
Yah, which... Now I have to maintain that. Again, it's not an API, without that it's feeling like a toy
Like... where's the real world consideration on any of this stuff? Are they making it purposefully difficult?
No, but in my quick tests, the GO's didn't do anything until I added ConvertToEntity
There's also a lot going on when I look at the Entity, that isn't quite apparent how it's getting injected
I mean if you aren't using ECS
It makes sense that it doesn't do anything without the system to build the physics world?
You will need to do that manually
If outside of ECS
Likewise you'll need to make your own exporter for the physics world data
I just want to convert the few things that are just required for physics, not all or nothing. I'm honestly really surprised they didn't build that
I should make a project and take out Hybrid and see if it behaves differently
For my use cases, I have just been using ECS
And exporting the data to GameObjects
The core ECS is actually pretty solid
they don't implement convert because it uses a conversion system to convert them
Oh that explains it
It's so annoying to have to open this thread every time I want to create a new project π https://forum.unity.com/threads/visibility-changes-for-preview-packages-in-2020-1.910880/
yeah creating new projects is a pain, not just because packages but also project settings etc
i've just started copying my main ecs project and deleting everything in assets then using that
to save setup time
I really need to get back to making a game. DOTS has been a huge waste of my time
Yup, Unity Physics doesn't seem to work without Hybrid
I just uninstalled hybrid yesterday/this morning
and my physics hasn't broken
What error are you getting?
If I use Convert and Inject, it renders, but no physics sim
If I use Convert and Destroy, it doesn't render
oh by hybrid you mean hybrid renderer? wasn't sure what you were talking about earlier
Unity Physics doesn't have any dependencies on hybrid renderer, that'd be weird
What components are you adding? because if you don't add the correct ones, it won't simulate as expected.
Make sure the motion type in the body is not set to kinematic
and double check the entity debugger to see if the physics related systems are both there and enabled
The Plane is Static and the Cubes are Dynamic
I also have the Physics Step component, and Convert to Entity on it in the root of the scene
what does BuildPhysicsWorld show?
That's with "Convert and Inject". If I use Convert and Destroy, the scene is empty
Maybe I need to use an SRP?
Right now this is just a new project with the built in renderer
Mine doesn't use the hybrid renderer at all
I'm installing URP to see
does convert and inject actually sync transforms?
I don't think so
By itself no
you'll need to add CopyTransformToGameObject and CopyTransformFromGameObject manually to the entities.
it's likely because it can't automatically tell what the authoritative source of transform information is
you'll need to inform it
then sounds like that's the issue, with inject transform doesn't sync and with destroy it doesn't render because not using hybrid renderer
URP isn't gonna fix it
@violet cosmos double check the position/transform values for the entities?
if the ydon't match up with their original gameobjects, they're likely not copying the values over
Even with URP, Convert and Destroy results in an empty scene
You don't have the Hybrid Renderer installed yes?
What Scorr says is probably accurate if that's the case
So, that validates what I said earlier: Unity Physics requires Hybrid to work
sure I can simulate stuff there, but it's completely disjointed from the game
That's if and only if you are using Hybrid to render your entities
So, brings me back to not having nice hierarchies
no
If you don't need the performance of ECS, you can still back your rendering with GameObjects.
unity physics has nothing to do with hybrid renderer
how were you rendering your entities before?
So, if I was using Convert and Inject, I need to link back the transforms?
you can use gameobjects, you just gotta add a copy component james mentioned
Yes, you'll likely need to make a few authoring scripts to add CopyTransformToGameObject and CopyTransformFromGameObject components to the entities.
Which, all things considered, isn't too bad
Gotcha, didn't knows those existed. That works, with Convert and Inject
The real issue comes when GameObjects no longer scale to what you need.
but if your game remains small scale enough
it's not really an issue.
I get a warning that "Copy Transform to Game Object Proxy has been deprecated"
Did you add the Proxy or the non-proxy version?
This might be true in newer versions of Entities
I am still on v0.11 and 2019.4
You need the non proxy version and just put it in an IConvertGameObjectToEntity
dstManager.AddComponent<CopyTransformToGameObject>(entity);
{
/// <summary>
/// Copy Transform to GameObject associated with Entity from TransformMatrix.
/// </summary>
public struct CopyTransformToGameObject : IComponentData {}
[UnityEngine.DisallowMultipleComponent]
[Obsolete("CopyTransformToGameObjectProxy has been deprecated. Please use the new GameObject-to-entity conversion workflows instead. (RemovedAfter 2020-07-03).")]
public class CopyTransformToGameObjectProxy : ComponentDataProxy<CopyTransformToGameObject> {}
}```
Yes, use the first one
That's the class you just told me to use. Note the [Obsolete] tag now
yea proxy is the monobehaviour, they deprecated the authoring component but the ecs component still works so you gotta add it manually with your own authoring component
The class is deprecated
I don't have any that aren't labled "proxy"
the component is not
/// <summary>
/// Copy Transform to GameObject associated with Entity from TransformMatrix.
/// </summary>
public struct CopyTransformToGameObject : IComponentData {}
So I custom inject that on conversion?
using Unity.Entities;
using Unity.Transforms;
using UnityEngine;
public class CopyTransformOut : MonoBehaviour, IConvertGameObjectToEntity {
public void Convert(Entity entity, EntityManager manager, GameObjectConversionSystem system) {
entityManager.AddComponent<CopyTransformToGameObject>(entity);
entityManager.AddComponentObject(entity, transform);
}
}
add that to your codebase, and attach it your objects
Edited, forgot that you also need the Transform as a component object
OK, this conversion process that doesn't involve Hybrid actually happens rapidly
especially once a prefab is converted... Subsquent conversions/injections are as fast as I'd expect for a regular GO
So, now to figure out how to query the physics worlds with Jobs π
https://github.com/HouraiTeahouse/FantasyCrescendoECS/blob/main/Assets/Code/src/Runtime/Match/Systems/HitboxCollisionSystem.cs#L60
@violet cosmos if you need a full example
this is basically it, get the PhysicsWorld from BuildPhysicsWorld, pass it readonly into a job, and run queries against it
it should be able to go as wide as you want, I have it running in parallel there
In the Job struct, getting an error like "pointers and fixed sized buffers may only be used in an unsafe context, on trying to assign the Collider to ColliderCastInput
@violet cosmos you'll need to mark the function unsafe
this is unavoidable for Unity Physics in it's current state
or wrap it in an unsafe context
void Foo() {
unsafe {
// Do some unsafe fun stuff here :)
}
}
Yah, it's not added to project right now. I'm also looking into scoping
The question is: Why is this not just API?
Everyone's out here making calls like Unity.Physics.Collider* sphereCollider = (Unity.Physics.Collider*)Unity.Physics.SphereCollider.Create(sphereGeometry, filter).GetUnsafePtr();
In a way it is
And it's much more powerful than your original SphereCast
since it can take ANY collider, including convex hulls,and (maybe?) meshes
yea and it is a way to have sorta subclasses while still using structs without boxing
- burst compatible
the burst part is amazing when it comes to performance, it took me almost 10ms to do full 1000 sphere casts in the past
now it's under half a millisecond on a release build
oh that was a worst case benchmark
seems reducing solver iteration count is a massive difference, dunno how much it impacts stability tho
yea i mean base cost with low collider count
different scenario
But, if I have to put in unsafe in almost every physics Job, will Burst just be negated?
seems with solver count set to 1 it only takes ~0.2ms base cost which is pretty good, but dunno if that's a good setting to fiddle with
Just be sure to never alias your pointers
it negates a lot of the compiler optimization that can be done
@violet cosmos you can wrap the unsafe parts into your own API if it feels like too much tedium
@hollow sorrel the bigger cost is from building/stepping the physics world
which you can get around by using Havok if you don't mind the licensing requirements and don't need determinism
due it's caching, no
@dusky wind I'm definitely going to wrapping this into an API. Because I have a feeling Unity will change the implementation
{
public PhysicsWorld World;
public float3 Position;
public float Radius;
bool haveHit;
NativeList<ColliderCastHit> hits;
public void Execute()
{
CollisionFilter filter = new CollisionFilter()
{
BelongsTo = ~0u,
CollidesWith = ~0u, // all 1s, so all layers, collide with everything
GroupIndex = 0
};
SphereGeometry sphereGeometry = new SphereGeometry() { Center = float3.zero, Radius = Radius };
hits = new NativeList<ColliderCastHit>();
unsafe
{
Unity.Physics.Collider* sphereCollider = (Unity.Physics.Collider*)Unity.Physics.SphereCollider.Create(sphereGeometry, filter).GetUnsafePtr();
ColliderCastInput jobInput = new ColliderCastInput()
{
Collider = sphereCollider,
Orientation = float4.zero,
Start = Position,
End = Position
};
haveHit = World.CastCollider(jobInput, ref hits);
}
}
}
vs Physics.SphereCast()
Imagine that in a tutorial π
Haha
I mean, com'on
To be fair, there are about 20-30 different things you can customize with the query
They couldn't have abstracted that out in the PhysicsWorld?
Havok Physics for Unity is a deterministic but stateful engine. This implies that a copy of a physics world will not simulate identically to the original world unless all of the internal simulation caches are also copied. Therefore, for networking use cases that depend on deterministic simulation of a "rolled back" physics world, you should rather use the Unity Physics simulation since it is stateless.
oh, so technically deterministic but still not suited for rollback
it'd be one hell of a method call if it weren't this complex
Oh I must have misread then
Most people don't need that. Radius. Center. Flags.
That's 98% of a SphereCast, and how people use it. If you need more, then cool. But most people, myself included in this case, don't
@violet cosmos all of them pertain to that specific query.
Yes but the idea is that it generalizes to any geometry
not just spheres
BoxCasts, ColliderCasts, etc. all depend on those additional parameters.
I agree it's not beginner friendly
but it gives full access to all of the tunable parameters.
Yes, even if it was
PhysQuery q = PhysicsWorld.CreateSphereCastQuery(new float3(0f,0f,0f), 5f, layerFlags);
PhysicsWorld.Query(q, ref hits);
That's far more acceptable from a general point of view, correct?
I know, that's not my point. Fringe cases shouldn't define the norm
I'm sure they'll eventually provide simpler wrappers
Agreed, which is why I'm going to wrap it first haha
but while the API is in flux, that's likely not going to be available.
I'm not doing this shit each time I need a sphere cast. That's going to be so much more code to maintain
Shit, I might even just make them extensions of PhysicsWorld
i wonder if you could still use havok for rollback if you can copy the internal cache tho 
