#archived-dots
1 messages ยท Page 204 of 1
megacity only runs on high end pcs?
it runs on iphone
i just remember watching the unite vids
never tried it myself
and to use megacity in latest ecs is a massive update process
megacity is using old one yes?
now i just want to see netcode working with ecs because for now its bugs and its just not working, like its issues with time delta and i need to use vsync because some guy from unity team said that
its possible to use easily ecs and custom networking?
def not easy
nothing about networking is easy
depends on your target game type i guess
my game is just facility nothing big for render just game based on rooms
i want a rts/strategy/management and netcode def wont work for that
currently we using Mirror networking but yes its just still monobehaviovurs
and aka based on unet
first/third person controllers would probably work fine with netcode
honestly if you have it working in normal unity i wouldnt update
its working but performance side its shit
youll be going very var back to ground 0 and rebuilding everything
theres tons of optmization options in normal unity
game is generated from seed and occlussion culling uhm nah
sometimes i have like 30 fps but looking in another way i getting like 10
have you actually tried any optmization tricks?
idk
also is it code or rendering causing the issues?
its basic rendering
rendering wont benifit too much by ecs
we tried HDRP but its hard
most of the performance gain is being able to jobify your gameplay code
well hdrp is not for performance
if i looking at profiler its just most by rendering
yea sounds like you need to look at rendering performance tricks
things like LODs, merging models, impostors (is there a large view distance?)
manual culling/urp custom culling might be a option too
we have settings for graphics, shadow distance and draw distance everything is low
"API Server"
Programmers, am I right?
cj_beans: https://www.youtube.com/channel/UCg2Et_ljwnuEHjwz5PyyT9w
โถDISCORD : https://discord.gg/wMmkC5X
โถTWITTER : http://www.twitter.com/Deathazori
โถINSTAGRAM : http://www.instagram.com/Deathazori
โถSNAPCHAT : https://snapchat.com/add/Deathazori
graphics wise it dosnt look anything crazy, should def be able to optmize that
that gameplay is not latest and most things is fixed like player pos sync and other stuff
but yes, for me game is running like at 10-30 fps
its not good while what game need to render is not big
yo roy
would you mind taking a quick scan of my project
lmk if i didn't any dumb shit in ecs?
i can drop a link
i only really know the core stuff, havnt done much job stuff yet
send me a pm in a few days
not a ton of time atm
aight will do
i just idk why aka game is running like shit, and most reviews on steam is like GAME is crypto miner, performance is bad
for those that do have some time id love to heaer your opinions on my code
also its EARLY access and most is just bitching about that
@timber ivy Ill ask you to review mine at some point ๐
no problem haha
honestly i have no clue
all rooms have realtime light
we cant bake while its prefab and map is generated from seed
yea ive run into that
my solution was to move the procedural generation into the editor, and then generate like 1000s of scenes (as prefabs) during my automated builds, then ill bake them all out
was annoying getting lightmaps from many scenes merging together
Im trying to create a custom navmesh for dots
anyone see an issue with just
creating X amount of points
that represent a shape
and anypoint within those points
is a valid walkable area?
like a bunch of rects for a lack of better words
im not really finding much info on creating triangular meshes
I've found an issue where NativeArray<T>.CopyTo(T[]) would fail for some reason in Android build, adb logcat shows ArgumentException: Object contains non-primitive or non-blittable data.
The struct is definitely primitive and it works just fine in editor, the same struct also goes through Bursted jobs without issue.
I've found an old issue tracker related to IL2CPP which is what my project uses, so it's probably that.
I don't have time to trim down for a minimal reproduction and file a bug report, but in case anyone hits the same problem, I solved it by doing a manual loop to copy instead of using that method.
Not efficient but what can you do.
@lusty otter damn I'm using alot of copy to
It's not consistently failing, only seems to fail at that specific point in my code for seemingly no reason at all ๐คทโโ๏ธ
var nodeLibEntity = GetSingletonEntity<NodeLibraryBufferComponent>();
var nodeLibBuffer = EntityManager.GetBuffer<NodeLibraryBufferComponent>(nodeLibEntity);
Entity masterEntity = EntityManager.Instantiate(nodeLibBuffer[0]);
Entity masterEntity1 = EntityManager.Instantiate(nodeLibBuffer[1]);
for the life of me i dont understand why this is not working
anyone see any thing wrong her
e
What you see in console?
you can use memcpy like that method does, assuming its one of their safety checks that is causing the issue.
Oh true.
Well I'll leave it for now because it's a part of the code that's not performance critical, and I'll just see if it magically gets fixed sometimes later.
it means the stuff in Assets/NetCodeGenerated needs to be deleted and generated with the new version
also i looking at GhostSnapshotValue and that thing got removed and idk any replacement for that
that deserialiize thing is not required anymore I don't think. it just gets generated now I think
public struct Request : IRpcCommand
{
public long Version;
}
ICommandData needs tick and that's it
what is the context of GhostSnapshotValue?
I forget what that was
perhaps the code around it will ring a bell for me
now i just trying to update dotssample to latest packages on 2020.2 unity
oof yeah I dunno what that is but.... I've tried updating dotssample before and there's a LOT in there that's changed
the whole animation system has been completely revamped and the old version of the package isn't available anymore
i see, every thing from animation is just dont exists
yea. is unity.animation in preview yet? when I checked late last year it was still unlisted (had to manually add github link)
I think you'll be doing a lot of rewriting to update dotssample sadly
if your plan is to use that sample to learn... you've got a catch 22
i just want to see some sample with netcode and most things like dots animation/physics
dots animation isn't really ready tbh
there's plenty of dots tutorials on youtube and in the docs and pinned in this channel
best place for netcode is getting started guide
not many ppl working with netcode but I've faught my way through it so feel free to ask questions
netcode is only UDP? or transport have option to make custom one like steam networking
netcode is UDP only
This blog was last updated, 27th April 2020. As many of you know, we put UNet into maintenance mode because we believe there is a better way forward with our new connected games stack. Since this announcement, we have learned that many of our developers need guidance about the best path for their game during [โฆ]
personally my plan is to use UDP for player-server interactions and I plan to try and get gRPC running for server-server communications
also, sync of pos is better by done sending just pos/rot than inputs?
depends killers
depends on the game. sending pos will let clients just teleport anywhere. if you're subtracting the new pos from the old pos on the server to protect against this then it's really the exact same thing
that's very susceptible to hacking
does Allocator.Temp not work anymore or something? I get an error saying must use TempJob etc, I 'm not even using it for a job I'm just using it in Onupdate() ๐
i use it everywhere but I'm not on super latest code I guess
what's the wording of the error?
InvalidOperationException: The Unity.Collections.NativeArray1[Unity.Entities.Entity] GatherEntitiesJob.JobData.Entities is allocated with Temp memory. Temp memory containers cannot be used when scheduling a job, use TempJob instead.`
is this inside a query with .schedule()?
Do ToEntityArray and ToComponentDataArray still require a TempJob allocation? What version are you on @pliant pike?
Oh sorry, entities version
this seems to worrk for me
oh,, i'm on 2020.1.17f1 which is maybe close to ur version
I'm using ToEntitieArray()
I'm basically just getting the entity to get a buffer then disposing after that entity array straight after
those aren't inside a query tho. they are just in onupdate directly
you sure you aren't passing it into a job later somewhere?
yep there's not even a job in the system, its just an input system
oof yeah no idea man
no worries tempjob will do just as good I guess
syncing position of players while game is based on rooms in facility and its 16+ players
or more
its not like fast shooter or something
just explore facility and escape
it could definitely work yes
The reason it won't let you use temp there is because you can't pass temp to/from any kind of job, even a job that runs on the main thread. A temp container can never safely change scope
So ToEntityArray involves a bursted job that tries to output a nativecontainer
how comes ToComponentDataArray works that's also a bursted job ๐
I wouldn't have thought it would, huh
yeah maybe simoyd was confused I can't test it with mine because it was a buffer
I thought they changed ToComponentDataArray/ToEntityArray to also work with temp in the latest version
Definitely possible, I could be working off outdated info
no i said my examples were just in onupdate
Can I control which order the OnCreate system methods are called? I have a simulation system that reads from an initialization system in OnCreate, but they don't run in that order for some reason. Even though I'm calling GetOrCreateSystem to get it.
The order goes all OnCreates => Initilize systems OnUpdate => Sim OnUpdate => Pres OnUpdate
So that's a no? I can't initialize my systems in OnCreate if they depend on other systems being initialized in OnCreate?
i dont think you can control no
what are you trying todo tho?
oncreates can get the other systems
You're saying a init system runs it's OnCreate befre your Sim System's OnCreate?
then in onupdate you access them to get stuff
Err the other way around
Yeah. The other way around.
I'm trying to cache an array from a system.
yea i always just cache the system, then do system.Array to access the array
Aight, guess I'll go with that.
I would have thought OnCreate would respect system order as well, that's lame that it doesn't
copying Native collections can be a bit tricky, as its a struct so when you copy you come SOME of the instance info (IsCreated for example) and if you dispose it only the one you dispose IsCreated gets changed
the actual items is not copied tho
protected override void OnCreate()
{
StationManager = World.GetOrCreateSystem<StationLoaderUnloaderSystem>().StationManager;
InstanceManager = World.GetOrCreateSystem<InstanceLoaderUnloaderSystem>().InstanceManager;
}
this should create the system if it doesn't exist
GetOrCreateSystem
Doesn't call OnCreate for me.
oh
i mean. you could put things into the constructor I guess maybe?
not sure if that causes problems :S
So waitup
That makes sense.
select a version dropdown @timber ivy
@timber ivy no i dont think so
the issue is you take a struct (value type) and box it into the interface.
I think this does stuff with the underlying memory
makes it into a reference type
all good
there are 2 options to kinda let you reuse code like interfaces would give you
i guess things like inheritance patterns are what ecs tries to avoid
generics and code gen
Ill just design around it.
can a component reference a regular struct?
not really a reference at that point ik but jw if i can
as long as the struct contains blittable data
ye
the data will exist within the compoent
you can do something like this too if you need to:
unsafe struct SomeStruct : IComponentData {
SomeBlittableType* Pointer;
IntPtr IntPtr;
}
WriteGroups are a interesting concept
is there any more info on them anywhere
not sure ive got my head around them completly yet
i think it's just the manual and looking at the transform systems as the key examples
i tried to use them once but I couldn't figure it out fully
from a quick read, looks like external components can modify my entity querys
but theres some sort of overriding/extending options too
ok will it be possible to use two diff variables on the component and monobehavior?
two diff variable types*
ive tried to digest write groups several times and still failed
@timber ivy what do you mean by 2 diff variable types?
like
I want to have 3 variables on my component
3 bytes
red green blue
and Color
on the generated monobehavior
yea thats fine
but not generated
you would manually create the MB, implement that IConvert... interface
how do I tag it to a specific component?
in the Convert method you read your color values and manually add the component
ah gotcha
manual IConvert's are my fav way to get data into entities
the generate attribute feels too limited
and full on conversion systems is a bit much
@safe lintel the way im kinda understanding them is its a .WithNone that gets specified using attributes instead of on your actual query
no clue if you can create custom inspectors for generated authoring types
probably can
cause
then i could just
use a color field
and save the data in ongui
and really
for every variable
honestly feels like simlar amount of work to create the mb, have a public color field and implement IConvert
up to you what you want your workflow to be
yeah yu're right its similar
but idk the authoring system
just doesn't click for me
I really like IConverts instead of the per component (GenerateAuthoring) approach. With custom convert scripts you can actually specify all components your systems need without having your gameobject inspector consist of +20 empty components...
really? i'm actually starting to really like it
yea thats why i started with IConvert, having a TON of generated authoring types or 1 fancy mb with all my fields which adds all my components
I had all of those as GenerateAuthorings before
Now I just put them into one character script and done
damn
Super clean and easy for me to reason about
Those are basically all components (without config data) my character needs for a specific gamemode
this is my component, basicly you mark what types you want networked, and internally it does a ton of stuff, adding both client and server types to the entity and creates a background entity for the server
You are working on a networking framework?
What genres are you targeting?
rts/stragety
Ohhh
Feel free to share some stuff once it is ready (testable) ๐
yea im considering making it open source
i've built the same stuff a few times now
but never really polished it
This is the code generator, external types are added to the list manually, but you can attribute your own types to add networked support, commands are all attributes as they need to be custom built
the idea is you can mark any struct (blitable) type and get that synced over the network
and even specify what fields you want to sync/watch
If I add the DOTS packages to my project, but end up not using it, can I remove them cleanly or will they do hinky stuff to my project that I can't easily undo?
yeah figured that would be the answer ๐
I use source control so I should be covered
if i do generatingauthoringcomponent
and then
add the generated component to a gameobject via code
wil things still work out correctly
umm kinda confused by that
when you say add generated compoent to gameobject
are you talking about in editor?
or runtime?
editor
that should be fine
then when i press play it will convert them all to entities automatically correct?
yea that needs to be the auto generated component
instead of the one generated by codegen
You cannot reference the generated component
well i guess you need IConvert then
so i cannot addcomponent<T> it?
ive actually seen that complaint on the fourms
thats lamee
i think the generated component is private or something
someone was using reflection to get it
I think that will be fixed once we have roslyn based codegen
Ooo roslyn? like source generators?
Yea
I don't think you can in the current version
is it not generating source files as of now?
just gave up and made my own ๐
You have to change your compiler or something
its just generating a dll? xd
yea i think they generate a new dll from your dll
but i guess you cant reference the new dll
yes @slim nebula
like you want to reference the authoring component? why?
im trying to AddComponent<T> the generated component
editor stuff
because i am making an editor script
like to a monobehavior?
yes
ohhhhhhhhhhhhh
it creates a gameobject
sorry my bad
attaches generated component
and then when i press play it will convert it to entities
so
remove [GenerateAuthoringComponent]
and
create my own monobehavior
that impliments iconvert
yup
am i missing any steps?
i mean your type gets built into an assembly, then your code gen uses refleciton on that assembly to create the code. It would be a circle to then use that by the original assembly
awesome
thank you roy
I still dont understand how its a circular dependency the code is in your project how is referencing it a circle
dll 1 (your code with your component) <= generated dll1 (authoring component)
if it changes you wont be able to compile your project
cant also have dll1 use generated dll1 cause it references dll1
because your code would reference the generated type
does the generated type reference our code?
it builds without it, then adds it
but if it references the type and you change it then you can't compile the generated code, but iif you delete it to regen it then your code doesn't compile because you needed it
anyway, you can make dll2 and should be able to reference the type
I dunno if it's public tho
yea but relying on generated code is a terriable idea ive discovered
you can work around circular deps with interfaces in your own types in the 2 dlls
i generate a ton of files, but if something goes wrong then generation fails. leaves me with failing code cause files are missing
yeah generated code is probably owned by the person who wrote the generator. so it's almost like internal unity code.... referenccing it is prolly bad
yup. thats why i wanted source generators
I was certain that it just edits the dll. Just checked via Ilspy and it keeps them in the same assembly
oh damn
wonder how they did that
wish we could plug into their code gen
but its internal
and it dosnt exist in your code
It comes together with the entities package in assemblies ending with .CodeGen
And you really don't want to touch it, it's a mess
๐ which is super duper complicated
you code still needs to compile first without it. so you can't reference it
yea
That's one part that roslyn source code generators are supposed to solve
Let's see how this will go...
yeah rofl
will be a while off i think
My guess is 2021.2/2022.1
2021.2 is already out
what noo thats way too quick
The IL post processing time is just so f* annoying
yea im already using 2021.1
it stable?
i remember the first 2020 editor that came out
but its wayyy better then any beta/alpha ive ever used
2021.2:
Scripting: Update Roslyn to 5.0.102, Update NetCore to 5.0.2
Idk if that version already includes source generators
unity uses netcore now?
Bottom of the page
when did they move from mono to netcore?
wow i really didnt expect anything like that anytime soon
maybe they havnt? and its just editor?
i read somewhere that .netcore referred to a background tool
that's the version I WANT
so unity doesn't use mono at all anymore?
not even on 2020.2 yet tho rofl
might just wait for 2021.2 to get more stable
but 2021.2 is that lts? or do I have to wait for 2022.2?
I do expect that will be .NET 6 though, not .NET 5, since .NET 6 is the LTS release from Microsoft. ```
I'm getting some mixed information right now
yea sounds like thats for editor/background tools ๐ฆ
maybe the editor now uses updated roslyn tho
even if its still mono underneeth
I'm really looking forward to code gen
@north bay you can do it now tho
it would be super sick to allow client side c# scripts
im using this https://github.com/scriban/scriban
source generators still dont give you a templating language
Because of stupid Entities.ForEach calls
I went from 40 seconds to 15-20 by getting rid of half of my entities.foreach calls and replacing them with manually written IJobChunks
well that expains my creeping compile times ๐
i mean they mention safe which is a plus. the syntax doesn't make me immediately barf. i might look at it. would be ideal to just have proper c# tho
marking 1 type as syncable = 7ish systems with Entities.Foreach
what's more efficient with manually written IJobChunks? can you post an example?
@north bay
the advantages of source generates is that they generate 'into' your dlls at coding time, so you can reference and use the new types
@north bay whats the best way of making all the IJobChunks? did you just take the generated jobs and copy them into your project?
or full on manually wrote them?
No, I manually rewrote them
oh damn
Took me a week
At least 150+ systems
Also took that opportunity to optimize the jobs to use HasComponent on the chunks so... whatever i guess
IJobChunk is the fastest runtime wise?
Basically using chunk operations where possible. But I really like how simple Entities.ForEach is to get running
Like the boilerplate you have to write for jobs is just so annoying
I think there's a new one that is able to operate on subset of entities instead of on a chunk basis for parallel work
So that might be better
haha yea i need to build those up
@north bay Do you know what the new job type is called? i should probably start learning/rewriting my entities foreach
if not now then soon when i start focusing on performance
What namespace is IConvertGameObjectToEntity in?
im in the process of reinstalling visual studio so i can't just right click it
@timber ivy get rider
is it free?
namespace Unity.Entities
it says it can't be found
IConvertGameObjectToEntity
yeah and im able to use
the create add component etc
I reference Unities.Entities assembly
damn so much code for manual jobs
Ooo and this IJobChunk has been superseded by IJobEntityBatch, which should be used for new code.
Is a chunk component the same thing as a Shared component?
i think many chunks can have the same shared component, but chunk components are not shared
Thanks
still unsure where i would even use them yet
i expect if i was doing more chunk based manual jobs it might make sense
Is there some way to stop hybrid renderer from adding sprites to gameobjects with spriterenderers that get converted?
Does anybody know what causes this error: "Trying to render a batch from the Hybrid Renderer V2 with SRP Batcher OFF. This is not supported.
Please turn SRP Batcher ON to use the Hybrid Renderer V2."
SRP batcher ist turned on in the render pipeline settings ๐ค
@pulsar jay basically if you have hybridv2 enabled, need to enable srp batcher.
@safe lintel yeah thats the thing - SRP batcher is enabled
ah, in that case do you have v2 enabled?
as i think its the opposite if v2 is not enabled
check your scripting defines in the player settings if you have ENABLE_HYBRID_RENDERER_V2
yeah its in there
I am currently trying to update packages and see if it goes away with more recent versions
restart unity? all out of ideas if that doesnt work
already tried that
it also only happens in built
but I already made multiple builds with restarting in between
i made this script a while ago because for whatever reason unity decided to auto disable the srp batcher on its own, so for recompiles id reenable it. i suppose you could try it out for scene loads and see if srp batcher is somehow being disabled https://pastebin.com/g68NtaQN
but one more thing, if you made a packages only build and just plopped in a cube and still get that error, probably a bug to report
great thx for the script
playmode, hdrp, hybrid renderer v2, why i see low fps?
use the profiler
Also disable safety checks and such
new to dots, how do i rotate my entity?
i tried this
rotation.Value = quaternion.Euler(math.mul(rotation.Value, rotator.axis * rotator.speed * deltaTime));
but it rotates only once
rotation is IComponentData
repeat the code the next frame? not sure what the rest of your code is doing
@covert cairn how and where are you calling that code?
in Entities.ForEach
i have translation which works fine and my entity moves but the rotation happening only once
here's the complete code
Entities.ForEach(
(ref Translation translation,
ref Rotation rotation,
in MoverComponent mover,
in RotatorComponent rotator) =>
{
translation.Value += mover.Speed * deltaTime;
if (translation.Value.y > 4) translation.Value.y = -4f;
rotation.Value = quaternion.Euler(math.mul(rotation.Value, rotator.axis * rotator.speed * deltaTime));
}).Schedule();
You are creating the same quaternion each frame.
Try something like this instead:
rotation.Value = math.mul(rotation.Value, quaternion.AxisAngle(rotator.axis, rotator.speed * deltaTime))
@north bay thanks that fixed the rotation
one weird doubt, lets say there's 2 system both of which take in the Move & Rotate component, at runtime will both of them be executed so the final translation & rotation is sum of the two systems or only one will run?
if you schedule the dependencies properly, one system will run after the other one - both modifying the rotation.
be aware though that with hierarchies, the local to world matrix is updated in the Transform system, once per frame. So if you want to position something in system 2, based on the world position of an entity after system1 has run, you need to think about that.
Hey guys, I'm trying to setup a new dots project in 2020.2... And to get the samples because I wanted to check the physic last updates. Bunch of errors, last one is that I'm missing ECSTestsFixture. Di you know which package I should add please?
that makes sense, so as long as the systems are properly scheduled & the output are handled, its normal practice to have multiple systems taking in same components?
yup absolutely ๐
@safe lintel I tried your script but it does not trigger as SRP batching is already active. Also the error does only happen in built. Could it be connected to me still using the classic build pipeline?
not sure. i thought the new build pipeline primarily addressed subscenes in builds but maybe it affects other things? i think id do a packages only build, (and then maybe a packages + scripts only build) and see if rendering something super simple like a cube/sphere works or not
yeah I guess I have to try that
Also happening to me in builds. The game seems to be rendering things just fine though. Someone just asked about this on the forums yesterday: https://forum.unity.com/threads/how-to-please-turn-srp-batcher-on-to-use-the-hybrid-renderer-v2.1067003/
oOOoOooo he's the author of dotsnav ๐
which version of unity are you guys using?
Same error in 2021.1.0b8
ok was curious and made a new project, just urp sample scene and latest hybrid renderer and the built player renders entities properly with hybridv2 and srp batcher
wonder if its some specific combo of packages now
or hdrp?
How would you handle situation when there is a huge lag in a frame because of heavy entity processing (~1000 entities) but you can only determine that you need to process that entities in this exact frame?
I need to somehow spread the load on multiple frames because burst + parallel jobs is not enough and there will be even more load in future.
- I suppose I could schedule a single job but I have no idea how to make it to safely write data back to entities - I can't use ECB since computing would be not a single frame job i.e there are no sync points
- I need to manually determine which amount of entities possible to process without framerate drop and keep it in special singleton that stores remaining "dirty" entities for next updates. It's easier approach but I don't like because I'll need to constantly change the value of maximum allowed entities for smooth fps.
Let's say they are chunks
but some ideas are:
you tag only X entities, and have X number of tags, each tag can be used to run a job with less entities
and you only update 1 'tag' each frame
idea 2
theres a new WithFilter or something like that, its kinda rough still but allows you to provide a native list of entities, ONLY those entities will be ForEached over
Idea 3
You can use a SharedCompnnetData to move your entities between chunks
then you schedule a job /Foreach only for entities where SCD = X
so in your case where your 'discovering' that the entities must be processed this frame, probably idea 2 would be best
as you can quickly spit entities out into a native list
Idea 3 would probably be better but you dont want to be moving entities around that much
so if you could preprocess them (eg at entitiy creation or subsceens) and sort them into SCD Update Groups that would be best i think
WithFilter seems like a quite flexible approach. With some queue in component it would be even better. AFAIK you can't put native queue in component but probably can store it in system and convert elements to tags
yea no collections in components
and i think thats the wrong way to be thinking about this
as you would end up with random access
eg foreach entity with your collection of other entities to update
instead you want to be , foreach entities that need update
personally i really like the SCD approach, you could even make it time based which will give you the most flexilibilty
What about a separate world? Is it a good idea? I don't know much about it but suppose it can be detached from frames
actually time based would be bad ๐ as you would need to change after every update
seprate world could work
it really depends on what your trying todo
other worlds are great for things like: loading in background, procedual generation, creating a TON of entitis, splitting rendering and simulation
To send lightweight entities (say, requests) to this world and copy processed data back to "primary" world.
but requests for what?
that copy back would be a slowish sync point
so i use 2 worlds for my networking stuff (all custom not netcode)
with no real issues, but im not moving entities between them
basically I do procedural and vertex generation so I need only a little set of properties like position, seed etc. as input
does it have to be completed 'this' frame?
i think the better option would be a manual job that is semi long running
but seprate worlds would probably be simplier
make sure you remove the presentation group
and probably things like physics
Hard to say. It will change fast but not every frame
Hey, I have a bool component on my particle entities that says if they are involved in a dynamic collision. This is calculated in a different system. Now I want to loop through these (true) entities sequentially (order doesn't matter) and perform the collision. I don't think I can use foreach for this but I am not sure... What should I use?
@ocean tundra thanks for help
however i imangine you have TONS of particle entities and only a few can be in a collision at once?
Can also use empty "flag" components as markers for stuff like that
yea 'tag' components are probably the way to go
Yeah exactly, I was hoping to not run over all of them
they will move your entities between chunks ๐ฆ
but that optmization is comming one day
ok so adding/taking away a component each frame from every particle?
another opetion is what i suggested to @acoustic spire you can gather a native list of all your entities (maybe where your setting collision = true) and provide that into Entities.WithFilter(list).FOreach
but im unsure if this feature is stable
adding/remoing each frame is bad
but its only on collision start right
so not as bad
collision start?
when your partical collides?
Sorry I don't understand quite what you mean
I don't really mind running over all N as this is still only a O(N) operation
When collison happens (so not every frame) then you add tag component,,, then process,, then later (next frame using a CommandBuffer?) you remove it
oh right I get you
yeah I suppose it will involve a component addition then removal each time
yea
unity has said theres 2 optimisations coming to help
tag components - can be made much faster to add/remove to entities
enabled - all components will get a Enabled bool somewhere, meaning you can set enabled = true instead of adding a component (and moving between chunks)
but no clue when any of these will land
ah ok fair enough, I have a deadline soon so probs can't wait for that
tbh as I am calculating stats each frame also I think I will probably just stick to a bool component
yea
What I am worried about is the sequential part
a bool would be easist to update to the enabled flag
as I need to conserve momentum and energy
i dont belive you can control ordering
Luckily I don't think the exact order matters
it just needs to run like a good ol fashioned for (int i =0 ; ...)
then do each collision in turn
in OOP terms I just want a system to run once and then go through all the collisions in any order
even if I don't set the for each to run in parallel will the values be updated in between each case?
i dont understand your last question
if your using foreach (.... ref Type data)
data.thing = x
that will be updated immediatly
So I need to perform a collision and update both the particle and the other object before going to the next colliding particle
but you cant have random reads, where your reading from another entity
yea the updating of Other will be your bottleneck
yeah that's what I was worried about
it doesn't have to be that fast as there will probably only be a few particles each frame
At the moment I have nativearrays of the other objects components, how can I write to that in the Foreach?
ok well I suppose i could have a placeholder and just update the final value to the entity?
might be better to do your loop, and NOT update at all
instead write out to a native list of some sort
then you loop over the list after and use that to write back
so you look over all
every entity that has a collion could be written out into a mutihashmax (entity1 = hits = entity2, entity 3 ect
so you get a list of every entity hitting the others
then you loop over it again in another job
and group that data back into your pairs (entity 1 = entity 2)
finally loop over your pairs and random write the data back as needed
OK that seems like a good plan, I don't really need to be using an array of other objects yet as I only have the one so far. Just to get that working I think just having a placeholder variable for its velocity is the way to go. As you said earlier if I update this single variable in the foreach, its new value will be passed into the next foreach right?
Then I can just write this back to the other object at the end?
How to make a custom world to run in background though? I can tick it manually from "caller" world but it won't be actually executed in background, right?
Does anyone here have any experience with MaskableGraphic class?
Reason I'm asking is that there's this function with absolutely no documentations whatsoever.... https://docs.unity3d.com/2018.1/Documentation/ScriptReference/UI.Graphic.SetVerticesDirty.html
Yeah like... Thanks for telling me it's "Dirty" but exactly what is "Dirty"???
Dirty usually refers to "In need of update" or "changed"
... very weird way of saying these vertices are dirty, better clean it by redrawing over it...
thanks
@acoustic spire You cant
cant have a world updating in background
jobs can only be scheduled on the main thread still
even if the whole world is seprate ๐ฆ
can anyone help me get started on dots animation? what resources are available
i see this is pinned:
Animation Samples (HDRP): https://github.com/Unity-Technologies/Unity.Animation.Samples
and I see the DOTS animation forum: https://forum.unity.com/forums/dots-animation.583/
and that's it. is there anything else useful in getting started?
is dots okay to build for web? I'm trying but I have a bunch of errors
Afaik Tiny is the only supported way right now
so how do we select empty entities?
I am creating millions of entities ๐ฆ
I'm building a command/message system for my networking, the user may add a command component to ANY entity, if its a networked entity the command will sync over to the matching entity on the other side, but it could also be a throw away entity (like the entity event pattern)
I remove the command component and send it off over the network
BUT im left with empty entities building up
I need to either
- select empty entities and throw them at EntityManager.DestoryEntity
OR - Figure out if the command entity is empty of other components, if so i can remove using a command buffer
any ideas how to do either of those?
EntityQuery.UniversalQuery (or something like that from memory) will let you query for all but as for myself Iโd rather not let it get to that point. Have them all have a specific tag in common. Likely an ISystemStateComponentData
@sleek idol import the dataflowgraph samples from the package manager and go thru them first before tackling animation
if you mean some websites that have articles further explaining it - no
it took me several attempts to really understand it but thats most likely due to my limited brainpower ๐ฅฒ
and its fairly decently explanatory(its called guided tour in code), more so than the animation samples imo
does anyone have an example of a job returning a list of things
basically I'm doing some processing and then for a small but indeterminate amount of them after the operation I want to loop over just the ones I need to
can I just allocate a nativearray and assign it as a field to the job then put the objects onto the end of it?
I would think you'd want a NativeList rather than an array but yeah
They resize themselves yes
hm
Up to a limit based on cache line size I think
You need the com.unity.collections package
I had a version of it
but it looks like I am able to get a new version
hm
native list doesn't let me write to it in parallel
I don't care about order
oh cool
The description for DynamicBuffers sounds a lot like a NativeList. What's the difference?
NativeList is a native container and can be used completely separate from ECS. It also can't be used in a component or associated with an entity in a safe context
A dynamic buffer is specifically for associating a resizable list with an entity
I'm hoping I'll be able to keep ECS and jobs to a minimum, just use them where I really need them instead of doing everything ECS
honestly i find mixing ecs harder then pure
but if you can identify a 'sub section' of your game thats kinda isolated you have better luck then me
wondering if someone could help me with a simple question
if i have an entity on a component , how can i check if that entity exists in a system
reactive based on if a has been set
if (ComponentEntity == Enity.Null ) was my attempt but that does not catch it
EntityManager.Exists
or if your using any of the **FromEntity things they also have a .Exists
excellent , thank Roycon
If you don't know beforehand what component type the entity has I also wrote this some time ago https://gist.github.com/LukasKastern/0116c2884421710a87005ab3bae862bf
whatif it in a job
You do need internal package access for that tho
For the usage in jobs?
yea
You can pass ComponentDataFromEntity or the thing I posed above to jobs
ok ty
Is this a true statement?
JobComponentSystem/ComponentSystem - deprecated and will be removed eventually.
SystemBase - combines better from both + better codegen. Only this recommended for usage.
Yes
Good stuff. I'm trying to keep on track with what's preferred in Unity DOTS but I keep getting confused with all the different tutorials/documentation.
Is there a good source of truth for this stuff? Maybe a wiki or a tutorial series that's regularly updated?
Also, any good explanation on what SystemBase does better over the JobComponentSystem/ComponentSystem?
Only stuff kept up to date is the manual and the github samples. There's also a new best practices guide https://forum.unity.com/threads/introducing-the-dots-best-practices-guide.1054991/
It's a bit smarter about handling dependencies, handles job -> main thread dependencies automatically where JCS doesn't, a bit less boilerplate for foreaches
ComponentSystem is ancient as this point and should just not be used. You can already schedule jobs on the main thread with .Run so there's no reason to use it
i did notice that input seemed broken on the latest samples. had to fix it manually ๐ค
yea that's exactly why I ended up just going the jobs route
yea probably a good idea
I would love to embrace ECS when it's ready
but there's too much tooling missing right now
I mean it's super fast and cool
When I made a little demo of like 25k spheres in a pyramid
falling onto the floor
and rolling
at 60fps
I was like :0
but then I started juggling converted game objects and it was a bit much
i acutally like the sub scene workflow
but its almost too limiting
i want mods
but subscenes make that SUPER hard
mods would be nice. really nice ๐ข
my thoughts are some sort of load step, after the subscenes have loaded, with all the prefabs
my file format has some sort of prefab id, can find and then update the prefab with mod info
would be nice to actaully edit the subscene data, but loading that, editing it and then saving it again sounds super hard
my first attempt at mods was kinda simlar tho, i loading all the gameobjects (not as entities)
converted them manually
then applyed the mod data
then used world serialaztion stuff to save the world out
was a pain
Anyone have any ideas on how to support mods?
not a scripting language tho, thats a whole different subject more around data modifications/additions/removals
and is there a already designed 'data' language, for describing this stuff?
like mods often have a load order
and multiple mods can edit the same 'thing' in a game
do i need to custom create a file format to descibe this?
maybe the json patch format would work: http://jsonpatch.com/
but then need a way to take a entity => to json, and back again
How can i avoid system update when entities of EntityQuery i use in that system are exist
you mean not existing?
if your using entities.foreach it already does that
only updates when entityquery count > 0
if you want to do it manually, call RequireForUpdate(yourEntityQuery)
No no no. In my system i use Entities.Foreach for normal use (entities exists - update pls), but also i use some queries to extract data for calculation, but i don't want system to update by those queries.
this method is SystemBase member?
yea
hm
lol, i'm sorry, i always try to search by myself before asking, but today my eyes failed me. Thank you a lot ๐
can i create text input fields for tiny?
just curious, should I be asking job system stuff here or in #archived-dots ? (I'm not using ecs but figured I should check)
this is #archived-dots
The job system is a part of dots so here's fine anyway
k cool thank you.
I'm curious if I should be following the pattern used in MeshData and MeshDataArray for structs that I create for usage in jobs
In the way they handle the underlying native data I mean.
They don't give direct access to the fields themselves but rather expose methods that copy a pointer to it and implement atomic safety handles etc
I figured that way I could return read-only native arrays that point to my underlying read/write native arrays when appropriate
but at the same time, the safety system only exists in-editor and in play-mode from what I understand; doesn't exist in shipped builds
Why is this code throwing
Unknown Type:`{0}` All ComponentType must be known at compile time & be successfully registered.
var time = Time.ElapsedTime;
Entities
.WithAll<PlayerMasterEntity>()
.ForEach((Entity e, int entityInQueryIndex) =>
{
buffer.AddComponent(entityInQueryIndex, e, new SendTimePingCommand()
{
ServerTime = time
});
})
.ScheduleParallel();
_endFixedStepSimulationEntityCommandBufferSystem.AddJobHandleForProducer(Dependency);```
Its only happening when Burst is on
But my components are nothing special, standard IComponents, all structs
No generics or anything magic
hmmm commented out the buffer.add.... and still getting weird exceptions, something about The UNKNOWN_OBJECT_TYPE has been declared as [ReadOnly] in the job, but you are writing to it.
wtf.... I updated the namespace (i had moved it to another folder and forgotten about namespace) and its fine
whats a simple way to check an entity matches an archetype? I can use a query and use .Matches(e), but that doesn't seem to work in a job
basically i'm queuing a list of entities for a system to process, but in the meantime the entity may have lost/added components which will throw errors for the job they are being dequeued into. when dequeuing i want to verify it still has all the components it needs
You can get the archetype of the chunk in IJobChunk
its going into an ijobparallelfor
and the dequeuing is in an ijob/lambda job
so don't really have chunk info
Question of the day : Whats more performant ? Lets say we have a velocity and rotation component. Therefore we have one Entities.ForEach loop, iterating over all velocitys and one iterating over all rotations. We have 1 k entities with both components. That means we actually loop 1k times over velocity and 1k times over rotation = 2k times in total.
We could actually create a Entities.ForEach loop that targets both components and then it only runs 1k times over them.
The question here is... Are many loop, with light calculation or less code faster than less loops with heavy or a lot code ?
Hey guys, has someone used the dots animation package? The animation clip of the example are "corrupted" (even with the same versions). So I don't have a clue of how it should be done properly
Generally speaking the answers to these questions are to profile it
The answer can vary based on how the memory for the components you are talking about get laid out
So try it both ways and check the profiler
My gut for what you just described is that a single loop would be better
@worthy rampart Well ok... The problem is that im actually done with the most parts of my game and i always choosed multiple loops over combined loops due to the flexibility ๐ those are things that didnt came into my mind
Actually... Both should be O(n) if i remember complexity correctly
The speed difference here wouldn't be algorithmic
It'd be due to hardware differences
Cache line sizes
Hmmm... Thats right, so it really depends on the size of the components. Nevertheless i thing that the speed difference shouldnt be too big. Probably its overoptimization
Unless you're having a performance related issue, reworking things for theoretical performance gains is a waste of time
That said combining two for each loops that run on the same components one right after the other is a relatively small change
@gusty comet what do you mean corrupted?
Even unity editor won't use it. It say that it may be corrupted or serialized with another unity version.
But I checked the version used and downloaded the same, so I can't really do better here.
Did you try redownloading the samples? There shouldnt be any problems
Yeap I openned the freshly downloaded samples directly with it's own unity version. But if you say you had no problems, I'll do it again after my window update
I think I'm just a fucking idiot...
Yeah works perfectly now x) Thanks
while you're at it, download the dataflowgraph samples from the package manager too. Important for understanding animation in its current state
can I not use GetEntityQuery() in an external struct?
on another note you can't put DynamicBuffers on separate entity's into a single NativeArray either can you
I'm doing some stress tests on my android (11) mobile with jobs & burst. I've been able to build using Mono, but if I switch to il2cpp and arm64, the build succeeds but something related to burst throws an error after the application is launched, and it doesn't run. The error says Unable to find internal function Unity.Burst.LowLevel.BurstCompilerService::GetOrCreateSharedMemory . Am I missing something or is it time for bug reporting? I've tried updating the burst version that is installed as dependency to the jobs package, but same thing. Using 2020.2.6f1 and latest jobs package btw.
I'm not sure what you mean. That's a system helper. Can't be outside.
You could query the buffers from multiple components and merge (or split) them in a native array, yeah ?
You're talking about GetENtityQuery's in a job struct ?
OoOoooh "from multiple entities", I missed that part ^^ yeah you can still do that. You will end up with a system and or jobs done on multiple steps, but that works
Basically, you gather info from n sources instead of 1, but that's okay
gtg eat, you guys tell me if I'm drunk and utterly wrong
Hey all
I've been thinking about mods and decided I'll use my code gen stuff to make a Dots Modding kit and wanted to run my rough approach by people
This is only for DATA type mods, but it should be possiable to include asset changes in the mod too (Models, Materials, Sounds ect)
During dev we add [Moddable] attributes to our components (probably on the Field members too)
Then run the code generator - this will generate strongly typed systems that will apply the mod data
In editor
Setup some setting like mod directory paths
Make sure all moddable things have a 'mod id' (probably a guid)
During runtime
Create a entity and attach a ordered buffer of mod file ids along with a LoadMod component which specifies some load settings (things like apply to prefabs, apply to all entities ect)
I will then load the mod data, construct some blobs, then loop over every mod and apply its data to the world/prefabs
Making a mod:
A mod will be a collection of http://jsonpatch.com/ files
file name is the moddable id
There will also be some ways to extract the reference json file
Basicly looping over every moddable entity and its moddable components and creating a json file compatible with jsonPatch
Scripting/code based mods is something i want too, but still unsure how to do that
The ReadOnlyAttribute and WriteOnlyAttribute for NativeArray<T> members are only used by the safety system within the jobs system on the native side right?
like, when I don't have any jobs operating on data using members marked [ReadOnly], I can operate on it in the managed side without issues right?
I'm trying to sort out if I should be passing copies of native containers to jobs and copying the modified data back into the external original containers once a job is done or if I should just be passing the actual data to the job
native containers dont copy their data when you copy them
they copy some 'stuff' like IsCreated
but the actual underlying items never get copied
also i dont think native collections have a 'unmanaged' part
instead all existing with c# space
I'm meaning an actual copy into a new buffer.
?? like native array .CopyTo?
yeah
why not send the origional data?
thread safety
but I do want a separate copy in these cases
thats what I'm wondering. Do people always just pass in the actual data or do they sometimes pass copies and resync after the job completes
my main concern is can I still write to a NativeArray member marked as read-only outside of a job when no jobs are executing on it if I were to just pass the actual data to jobs instead of copies
but I'll just test and see lol I'm just being lazy and asking while I'm working on other stuff :p
i always pass the actual data
but its often structured so it dont have many jobs writing to the same indexs
yeah, I think I'm overthinking this lol
just dont write to the data on the main thread
do it all via jobs
and pass/handle dependancies
then you wont have any conflicts
@ocean tundra seems like a decent idea
out of curiosity tho what problem does jsonpatch solve? why not just use the entire json and replace?
Json patch Is to help with mod data conflicts
So the mods are more likely to be compatible
And also support removing or replacing components
remove/replace could just be handled events by your game tho
are people going to hand write these add/remove jsonpatches?
yea that would be the idea
True, but using json patch gives me a standard format/rules, instead of needing to design my own file format for mod makers
the idea is that somehow (during build?) us game devs can create the mod json reference file per moddable 'thing' and distribute that with our game for modders, that data is never actally used, instead using faster prefabs/subscene data
but a mod maker can look at that file and see things like, moddable unit has attack power of 5, they can then create a json patch file replacing that
and if 6 different mods want to change that attack power field they can, but the last one with a 'replace' wins
yeah that makes sense, just think it's putting a lot of faith in your modders
just adding or replacing one field is now 4 times as much to type as regular json and make sure is fully correct with commas and everything
it sounds very robust and flexible, but also a pain to work with ๐
that's your tradeoff to make tho, i was just wondering
maybe have 2 options?
let the modder copy the json reference file directly and edit as they like, during mod loading that file is compared to the origional reference file and a patch file is created
if its already a patchfile then no need to do the compare
that gives simple mods a easy path, and for harder/more complex mods they can directly write the patch files
yeah if both are an option that'd be neat
but i also know if i were a modder and in case i'm not targeting already existing specific mods that mine needs be compatible with, 100% i will just take the path of least resistance and not bother with future compatibility
yea true,, the main advantage of json patch is you can effect other mods, using just the main file editing prevents that
but as long as reference file editing creates a patch it would be compatable with most mods by default, they just wont be able to target/modify other mods that add new components
also the modder could always start with reference file editing, and then copy/access a generated patch file and build on that
ty for the feedback ๐
I'm a beginner who recently became interested in DOTS.
I'm asking a question because I'm curious about the opinions of the users who are actually using it.
I don't know exactly about these things yet.
The advantages that they claim seem surprisingly outstanding.
But on the other hand, the experience I've seen in the community says:
- It is still under development and unstable.
- As the version changes, too many concepts and usage changes occur, making it inappropriate to learn or develop something.
- Difficult to use and complex
- Debugging becomes very difficult.
Despite the great advantages of DOTS, these experiences seem to tell me that they are not yet suitable for practical use.
q1) Do I really need these?
q2) Is it appropriate to learn and use these from now on?
q3) One of the assets I am using requires the Burst, Jobs package. If I understand correctly,
if I don't use attribute even if I install them, there is no difference in the existing system.(Operational problems, performance, etc.)
Is there any issue that could be a problem when installing Burst and Jobs in the existing project?
Any experience or advice from you is welcome.
@shut yacht so DOTS is awesome
but its still early
thats why its been hidden via the package manager
it really depends on the game you want to make if you want to use DOTS or not
yea generally if you install those packages but dont use them they should be more or less inert
everything you say is true, its slowly getting more stable, breaking changes are less and less, complexity is either explained or hidden away, and debugging is getting better
under the hood jobs is used by unity already, and depending what you have installed burst may or may not be a hidden dependency for other packages
in time it wont have those issues, but still awhile away
all depends on your appetite for the early adopter experience.
i think that generally unity want you to kinda steer clear unless you are a really persistent self learner or kind of an expert user already. that said just jobs and burst are out of preview and ready to use for the masses i think.
@safe lintel @ocean tundra
Wow, thank you so much.
It was a great help to me who knew nothing.
My question was solved so clearly. ๐
Is there an approximate roadmap or goal that Unity has officially proposed?
(Note: Eventually, it will completely replace the existing system. / It will be released in Unity 202x version. etc.. )
honestly no ๐ฆ really sucks, they were getting better at road maps/planning for DOTS but then the shift to focus on stability came and DOTS communication has dropped off
also i recently found out some DOTS sub packages are on development hiatus, i expect cause their devs were pulled elsewhere inside unity
specifically the AI Planner package
but i think it happened to kinematica too
i dont view those things as being put elsewhere actually. they kinda both utilized jobs(i think) but they were monobehaviour front facing
so my assumption(more of a guess) is that they actually put a stop to the monobehaviour dev and focus on ecs workflow instead because it wouldnt make sense to make those next gen packages not work within the context of ecs/dots
I have given up on kinematica with similar ideas (for similar reasons).
It's sad that something similar happens here.
The advantages of DOTS look amazing.
I hope the development will be normalized so that we can enjoy them.
Thank you again for giving me a surprisingly clear and quick answer to the field I don't know.
I hope you have a good day.๐
@ocean tundra @safe lintel
@shut yacht what sort of game do you want to make tho
RTS/Strategy/Management games would all benefit soooo much from DOTS
It is a single game with high graphics requirements for a 3D base.
Many objects, such as RTS, need to be simulated at the same time, or physical interactions do not account for much.
What requires DOTS is an Asset called Magica Cloth.
It is used to simulate the physics of cloth material.
(Because I felt that the basic Cloth of Unity wasn't enough)
In fact, in the case of my ongoing project, I don't think there is much advantage.
It is still in the early stages of the project and it is possible to redesign it.
Therefore, I was looking at the amazing performances and charms that DOTS showed and I was researching if there was anything that could be used.
@ocean tundra as someone who has done a fair bit of modding, having the ability to partially patch something sounds great
even if it causes a little bit of boilerplate for each part
I'd rather have only the parts that I'm changing in my mod
than to worry about reconciling everything
on updates
@worthy rampart sweet ty for the feedback
nice to hear its not completly crazy ๐
sounds like some sort of mod tool to take any reference files the modder uses make generate a patch and output it, then all mods will be patches
but there will be a simpler "authoring" flow for mod makers
As a programmer, I have been working in a field other than a game for a few years.(C++, c# was used primarily.)
I quit the company early this year and formed a team to develop indie games through Unity. (I expect 2~3 years.)
yea since it dosnt sounds like a hobby project probably not worth taking on even more risk
but there are some released games using DOTS
616 I recently tried to use dots on my not so hobby project
And decided it wasn't quite worth the risk
There's lots of missing features still
And bugs
The hybrid workflow is a little wierd
I think in a year or two it'll be the absolute best choice
But it's possible there could be some big changes that force a rewrite from now until then
You can get some good performance utilizing techniques like jobs and compute shaders
Without delving into DOTS
Yea, all my stuff is hobby, and im aiming to build and release tools for DOTS not games untill its more stable
So im ok with taking on the risks
Yea that makes sense
@worthy rampart Did you take a look at the JSON patch link (http://jsonpatch.com/)
Just wondering what you think of the patch format
and when you were doing modding were there any common file formats you prefered?
the patch format looks useable
with proper formatting it probably looks a lot beter than that example
yea single line is a terrible idea ๐
haha ok
never really liked xml anyway
thanks again @worthy rampart and @hollow sorrel
anyone know how to create unity packages?
hi, is there a beginners course for unity project tiny programming?
I think unity made an official tutorial on that.
I normally just copy the package.json of an existing package and modify it.
How can i fast copy values from one NativeHashMap to another? I know only one way that i should iterate through first NativeHashMap and call Add
@ocean tundra interesting endeavour. I never done moddable content but that's something I'll try to implement in the future. You say you prefer to focus on tools rather than games while DOTS gets better, but aren't you as much afraid of breaking changes when you build tools ?
@hollow sorrel @ocean tundra about the pain in the butt from json format editing. You could bring a web interface so json gen is less error-prone. More work tough... But could be community maintained.
Also, like I said i never done modding, but to bounce on your statement :
if 6 different mods want to change that attack power field they can, but the last one with a 'replace' wins
wouldnt it be better that the original game uses a "base" power value, and expect mods to add/subtract from it ? Basically asking your modders to work with modifiers instead of overriding values ? i.e. +1 or +20% power instead of a flat =10 and "I don't care of other mods".
ECS and DOTS are not the same thing, ECS is one of the DOTS techs
and no, Unity is not using ECS "by default" (whatever that means), but Unity is switching some inner systems to run with Jobs + Burst (which are others DOTS techs)
and they said gameobject is entity
discord? ๐
that guy clearly doesn't know that he is talking about lol
So... what should be an entity and what shouldnt be one ? Thats a question im struggling with since months. For example in my case the player is an entity. And he has a inventory that are pointing towards his items. Those items are also entities. So im basically going with the "everything is an entity" approach. Is this "too much" ? What do you think ?
Entities are distinct things that should "own" stuff
@worthy rampart So things that are independent ? Like an item in an inventory always depends on another entity. Like a player or mob. So it shouldnt be an entity, because it does not "own" other relations ?
Yea items to me feel like they should just be a struct
Not a full entity
But that depends
On what you can really do with them
And how much information they may end up containing
Imo do whatever makes the most sense in your head
@worthy rampart Thanks ^^ When would you make an item an entity ? In my case... my items are pretty standard. They have a quantity, a name, an id, should be equipable and can be used to buff the wearers stats. But its still dependend on the wearer.
And then stress test it
Devise a worse case scenario
In terms of how many of them there could be
Spawn that many
And see if your systems keep up
Actually its not about performance at this point ^^ Its about clean code and flexibility. So i dont care about performance in this case
@worthy rampart So you mean player as entities and their items also being entities ?
Yea but it starts to come down to personal preference
Alright thanks ^^ I guess that makes the saving a bit harder. In my case i wanna persist my entities into a database. Therefore references between them are always a bit... problematic. But probably im wrong
If you never have to query for an item
Without having it's player
Or container
Then I probably wouldn't make them entities
Just make an inventory component
Which holds all the items in an inventory
And put that on anything that can hold items
@worthy rampart Alright thanks ^^ I think this is actually a good way to combine the ECS with an EC. Like having a player ecs entity with that inventory component. And inside the inventory component there EC entities. This way both would stay flexible.